Файл: battle.php
Строк: 155
<?
define('PROTECTOR', 1);
$textl='Главная';
include('files/db.php');
include($path.'files/auth.php');
if ($user_id==0){
header('location: index.php');exit;
}
$lv=time();
$last=date('d.m.Y - H:i:s');
mysql_query("UPDATE `users` SET
`lv`='".$lv."',
`last`='".$last."',
`mesto`='".$textl."'
WHERE `id`='".$udata['id']."'");
$mobs=mysql_query("SELECT * FROM `craft` WHERE `usr`='".$udata['id']."'");
$rows=mysql_num_rows($mobs);
if($rows!=0)
{
header('location: work.php');exit;
}
$mobs1=mysql_query("SELECT * FROM `arena_usr` WHERE `usr`='".$udata['id']."'");
$rows1=mysql_num_rows($mobs1);
if($rows1!=0)
{
header('location: arena.php');exit;
}
$mobs2=mysql_query("SELECT * FROM `avan_usr` WHERE `usr`='".$udata['id']."'");
$rows2=mysql_num_rows($mobs2);
if($rows2!=0)
{
header('location: avan.php');exit;
}
$mobs4=mysql_query("SELECT * FROM `ohota` WHERE `usr`='".$udata['id']."'");
$rows4=mysql_num_rows($mobs4);
if($rows4!=0)
{
header('location: b_oh.php');exit;
}
$mobs6=mysql_query("SELECT * FROM `str_usr` WHERE `usr`='".$udata['id']."'");
$rows6=mysql_num_rows($mobs6);
if($rows6!=0)
{
header('location: b_str.php');exit;
}
$mobs7=mysql_query("SELECT * FROM `terr_usr` WHERE `usr`='".$udata['id']."'");
$rows7=mysql_num_rows($mobs7);
if($rows7!=0)
{
header('location: terr_b.php');exit;
}
$bat=mysql_query("SELECT * FROM `battle` WHERE `usr`='".$udata['id']."'");
$num=mysql_num_rows($bat);
if($num==0)
{
header('location: game.php');exit;
}
else
{
$bt=mysql_fetch_array($bat);
if(isset($_GET['kick']))
{
if($bt['time_us']>time())
{
$re=rand($bt['sila']/100*10,$bt['sila']/100*50);
$sila=$re-$bt['arm_mob'];
if($sila<$udata['sila']/100*10)
{
$sila=round($udata['sila']/100*10);
}
$hp=$bt['hp_mob']-$sila;
$rk=rand(1,3);
if($rk==1)
{
$k='ударил';
}
if($rk==2)
{
$k='пронзил';
}
if($rk==3)
{
$k='двинул';
}
$lg='<img src=img/main/b1.png> <a href=>'.$udata['usr'].'</a> '.$k.' '.$bt['mob'].' -'.$sila.'';
mysql_query("INSERT INTO `log_battle` SET
`id`='',
`usr`='".$udata['id']."',
`text`='".$lg."'
");
if($hp<=0)
{
$hp=0;
$lg2='<img src=img/main/b7.png> <a href=>'.$udata['usr'].'</a> убил '.$bt['mob'].'';
mysql_query("INSERT INTO `log_battle` SET
`id`='',
`usr`='".$udata['id']."',
`text`='".$lg2."'
");
mysql_query("UPDATE `battle` SET `status`='1' WHERE `id`='".$bt['id']."'");
$exp=$udata['exp']+$bt['hp_mob']*5;
}
else
{
$exp=$udata['exp']+$sila*5;
}
$tim=time()+7;
mysql_query("UPDATE `battle` SET `hp_mob`='".$hp."', `time_us`='".$tim."' WHERE `id`='".$bt['id']."'");
mysql_query("UPDATE `users` SET `exp`='".$exp."' WHERE `id`='".$udata['id']."'");
header('location: ?');exit;
}
else
{
$sila=$bt['sila']-$bt['arm_mob'];
if($sila<$udata['sila']/100*10)
{
$sila=round($udata['sila']/100*10);
}
$hp=$bt['hp_mob']-$sila;
$rk=rand(1,3);
if($rk==1)
{
$k='ударил';
}
if($rk==2)
{
$k='пронзил';
}
if($rk==3)
{
$k='двинул';
}
$lg='<img src=img/main/b1.png> <a href=>'.$udata['usr'].'</a> '.$k.' '.$bt['mob'].' -'.$sila.'';
mysql_query("INSERT INTO `log_battle` SET
`id`='',
`usr`='".$udata['id']."',
`text`='".$lg."'
");
if($hp<=0)
{
$hp=0;
$lg2='<img src=img/main/b7.png> <a href=>'.$udata['usr'].'</a> убил '.$bt['mob'].'';
mysql_query("INSERT INTO `log_battle` SET
`id`='',
`usr`='".$udata['id']."',
`text`='".$lg2."'
");
mysql_query("UPDATE `battle` SET `status`='1' WHERE `id`='".$bt['id']."'");
$exp=$udata['exp']+$bt['hp_mob']*5;
}
else
{
$exp=$udata['exp']+$sila*5;
}
$tim=time()+7;
mysql_query("UPDATE `battle` SET `hp_mob`='".$hp."', `time_us`='".$tim."' WHERE `id`='".$bt['id']."'");
mysql_query("UPDATE `users` SET `exp`='".$exp."' WHERE `id`='".$udata['id']."'");
header('location: ?');exit;
}
}
if(isset($_GET['mag']))
{
$tn=time();
if($_GET['nin']==1)
{
$mobs=mysql_query("SELECT * FROM `mag` WHERE `usr`='".$udata['id']."' and `mag`='1' and `time`<='".$tn."' and `status`='on'");
$rows=mysql_num_rows($mobs);
if($rows==0)
{
header('location: ?');exit;
}
else
{
$skill=mysql_fetch_array($mobs);
$sila=10;
$hp=$bt['hp_mob']-$sila;
$lg='<img src=img/main/b10.png> <a href=>'.$udata['usr'].'</a> <font color=#009900>использовал</font> заклинание удара
<font color=#009900>(</font><font color=#999999>'.$bt['mob'].'</font> <font color=#009900>-'.$sila.')</font>';
mysql_query("INSERT INTO `log_battle` SET
`id`='',
`usr`='".$udata['id']."',
`text`='".$lg."'
");
if($hp<=0)
{
$hp=0;
$lg2='<img src=img/main/b7.png> <a href=>'.$udata['usr'].'</a> убил '.$bt['mob'].'';
mysql_query("INSERT INTO `log_battle` SET
`id`='',
`usr`='".$udata['id']."',
`text`='".$lg2."'
");
mysql_query("UPDATE `battle` SET `status`='1' WHERE `id`='".$bt['id']."'");
$exp=$udata['exp']+$bt['hp_mob']*5;
}
else
{
$exp=$udata['exp']+$sila*5;
}
$tm=time()+5;
mysql_query("UPDATE `mag` SET
`time`='".$tm."'
WHERE `mag`='1' and `usr`='".$udata['id']."'");
mysql_query("UPDATE `battle` SET `hp_mob`='".$hp."' WHERE `id`='".$bt['id']."'");
mysql_query("UPDATE `users` SET `exp`='".$exp."' WHERE `id`='".$udata['id']."'");
header('location: ?');exit;
}
}
}
if(isset($_GET['leav']))
{
if($bt['status']==0)
{
header('location: ?');
}
else
{
mysql_query("DELETE FROM `battle` WHERE `usr`='".$udata['id']."'");
mysql_query("DELETE FROM `log_battle` WHERE `usr`='".$udata['id']."'");
mysql_query("UPDATE `users` SET `kv`='4' WHERE `id`='".$udata['id']."'");
header('location: game.php');
}
}
if(isset($_GET['elic']))
{
$elic=mysql_query("SELECT * FROM `elic` WHERE `id`='".$_GET['ef']."' and `usr`='".$udata['id']."' and `status`='on'");
$cd=mysql_num_rows($elic);
if($cd==0)
{
header('location: ?');
}
else
{
$el=mysql_fetch_array($elic);
if($el['tip']=='hp')
{
if($el['time']>time())
{
header('location: ?');
}
else
{
if($bt['hp']==$udata['hp'] or $bt['hp']==0)
{
header('location: ?');
}
$hp=$bt['hp']+$el['ef'];
if($hp>$udata['hp'])
{
$hp=$udata['hp'];
}
mysql_query("UPDATE `battle` SET `hp`='".$hp."' WHERE `id`='".$bt['id']."'");
}
}
$elk=$el['kol']-1;
if($elk==0)
{
mysql_query("DELETE FROM `elic` WHERE `id`='".$el['id']."'");
}
else
{
$time=time()+$el['rest'];
mysql_query("UPDATE `elic` SET `kol`='".$elk."', `time`='".$time."' WHERE `id`='".$el['id']."'");
}
}
header('location: ?');
}
include($path.'files/head.php');
echo '
<div class="v2 brs bls v8 bts bbs p v12"><font color=#00ccff>
<img src=img/main/p6.png>'.$bt['hp'].' |
<font color=#ff0000>'.$bt['att'].'</font> | <font color=#ff0000>'.$bt['att2'].'</font>
| '.$bt['mob'].' <img src=img/main/p6.png>'.$bt['hp_mob'].'<br>
Состояние:
</font>
</div>';
echo '<div class="v3 bts brs bls b p v12">Битва</div><div class="v2 bts brs bls bbs p t2">';
if($bt['status']==0)
{
if($bt['time_mob']<=time())
{
$sila=$bt['sila_mob']-$bt['arm'];
if($sila<1)
{
$sila=1;
}
$hp=$bt['hp']-$sila-1;
$rk=rand(1,3);
if($rk==1)
{
$k='ударил';
}
if($rk==2)
{
$k='пронзил';
}
if($rk==3)
{
$k='двинул';
}
$lg='<img src=img/main/b1.png> <font color=#ff0000>'.$bt['mob'].' '.$k.'</font>
<a href=>'.$udata['usr'].'</a> <font color=#ff0000> -'.$sila.'</font> <font color=#880088>-1</font>';
mysql_query("INSERT INTO `log_battle` SET
`id`='',
`usr`='".$udata['id']."',
`text`='".$lg."'
");
if($hp<=0)
{
$hp=0;
$lg='<img src=img/main/b7.png> <font color=#ff0000>'.$bt['mob'].' убил</font>
<a href=>'.$udata['usr'].'</a>';
mysql_query("INSERT INTO `log_battle` SET
`id`='',
`usr`='".$udata['id']."',
`text`='".$lg."'
");
mysql_query("UPDATE `battle` SET `status`='2' WHERE `id`='".$bt['id']."'");
}
$tim=time()+10;
mysql_query("UPDATE `battle` SET `hp`='".$hp."', `time_mob`='".$tim."' WHERE `id`='".$bt['id']."'");
}
echo '<img src=img/mob/hunt12.jpg><br>
<a href=?kick><div class="v2s p"><img src=img/main/b17.png> <font color=#ffff00>бить '.$bt['mob'].'</font> <font color=#ffffff>['.$bt['hp_mob'].']</font></div></a>
';
$tn=time();
$mobs=mysql_query("SELECT * FROM `mag` WHERE `usr`='".$udata['id']."' and `mag`='1' and `status`='on'");
$rows=mysql_num_rows($mobs);
if($rows==0)
{
}
else
{
$mag=mysql_fetch_array($mobs);
if($mag['time']<=$tn)
{
echo '<a href=?mag&nin=1>
<div class="v2s p"><img src=img/main/b10.png> <font color=#ffff00>заклинание удара</font></div></a>';
}
else
{
$mag['time']=$mag['time']-time();
if($mag['time']<60){
$mag['time']=$mag['time']." с.</font>";
}
echo '<a href=?mag&nin=1>
<div class="v2s p"><img src=img/main/b10.png> <font color=#555500>заклинание удара</font><font color=#ffffff> ['.$mag['time'].']</font></div></a>';
}
}
$eq=mysql_query("SELECT * FROM `elic` WHERE `usr`='".$udata['id']."' and `tip`='hp' and `status`='on'");
$rowse=mysql_num_rows($eq);
if($rowse==0)
{
}
else
{
while($el=mysql_fetch_array($eq))
{
if($el['time']<=$tn)
{
echo '<img src=img/elic/'.$el['tip'].''.$el['ef'].'.png> <a href=?elic&ef='.$el['id'].'>пить</a>';
}
else
{
$el['time']=$el['time']-time();
if($el['time']<60){
$el['time']=$el['time']." с.</font>";
}
echo '<img src=img/elic/'.$el['tip'].''.$el['ef'].'.png> '.$el['time'].' ';
}
}
}
echo '</div>';
echo '<div class="v8"><div class="v3 bts brs bls b p v12">Твой противник:</div>';
echo '<div class="v2 bts brs bls bbs p"><font color=#cccccc>';
echo ''.$bt['mob'].' <img src=img/main/p6.png>'.$bt['hp_mob'].'</font></div></div>';
}
elseif($bt['status']==1)
{
echo '<div align=center><img src=img/inter/win.jpg></div>
<img src=img/main/b18.png> Вы победили! Бой завершен!<br>
<a href=?leav><img src=img/main/p21.png> Покинуть бой</a>
</div><div class="v8">
';
}
elseif($bt['status']==2)
{
echo '<div align=center><img src=img/inter/lose.jpg></div>
<img src=img/main/b18.png> Вы проиграли! Бой завершен!<br>
<a href=?leav><img src=img/main/p21.png> Покинуть бой</a>
</div><div class="v8">
';
}
$mobs=mysql_query("SELECT * FROM `log_battle` WHERE `usr`='".$udata['id']."' ORDER BY `id` DESC LIMIT 10");
$rows=mysql_num_rows($mobs);
if($rows==0)
{
}
else
{
echo '<div class="v3 bts brs bls b p v12">Лог боя:</div><div class="v2 bts brs bls bbs p">';
while($log=mysql_fetch_array($mobs))
{
echo $log['text'].'<br>';
}
}
}
?>