if ($atta) {
if ($stat['vault_move'] == 1);
elseif ($stat['r_action'] == 1);
else {
$chl=mysql_fetch_array(mysql_query("SELECT id, v_time, k_time, user, room, level, hp_now, battle, last_battle, vitality, travma, rank, lpv, rase_skill FROM players where user='".addslashes($login)."'"));
if ($chl['user'] == $stat['user']) $msg="Нападение на самого себя - это уже мазохизм...";
elseif (($stat['level']+1) < $chl['level'] && $chl['rank']==60);
elseif (($stat['level']-1) > $chl['level'] && $chl['rank']==60);
elseif ($ctime-$chl['lpv'] > 180 && $chl['rank'] != 60);
elseif ($chl['hp_now'] <= 5 && $chl['rank']<>60);
elseif (((time()-$chl['lpv'])<10) && ($chl['battle'] == $chl['last_battle'] || !$chl['battle']) && $chl['rank']==60);
else {
require_once("inc/chat/functions.php");
insert_msg("Вы побеспокоили одного из жителей подземелья, и он собрался с силами и напал на Вас!","","","1",$stat['user'],"",$stat['room']);
$battime="$now";
if ($chl['rank']==60 && ($chl['battle'] == $chl['last_battle'] || !$chl['battle'])) {
$_obj=mysql_fetch_array(mysql_query("SELECT SUM(objects.`hp`) as `hp`, SUM(objects.`vitality`) as `vitality` FROM slots, objects WHERE slots.id='".$chl['id']."' AND objects.user='".$chl['user']."' AND objects.id IN (slots.1,slots.2,slots.3,slots.4,slots.5,slots.6,slots.7,slots.8,slots.9,slot
s.10,slots.11,slots.12,slots.13,slots.14,slots.15,slots.16,slots.17,slots.18,slo
t
s.19) LIMIT 1"));
$MySkills = explode("|",$chl['rase_skill']);
$chl['gnom']=$MySkills['3']*5;
$chl['vitality']+=$_obj['vitality'];
$chl['hp_max']=ceil(($chl['vitality']*5+$_obj['hp'])*(1+($chl['gnom']/100)));
$chl['hp_now']=$chl['hp_max'];
mysql_query ("UPDATE `players` SET `hp_now` = '".$chl['hp_now']."', `battle` = NULL, `lpv`='".time()."' WHERE `id` = '".$chl['id']."'");
$chl['battle'] = NULL;
}
if ($chl['battle']) {
$prt=mysql_fetch_array(mysql_query("SELECT side as side,time as time from participants where time=$chl[battle] and id=$chl[id]"));
switch ($prt['side']) {
case 0: $side=1; break;
case 1: $side=0; break;
}
$levels=mysql_fetch_array(mysql_query("SELECT base FROM levels WHERE level=$stat[level]"));
mysql_query("INSERT INTO participants (`time`, `id`, `side`, `base`,`hp`) values('$prt[time]', '$stat[id]', '$side', '$levels[base]', $stat[hp_now])");
$b_id_id=mysql_fetch_array(mysql_query("SELECT MAX(id) as id from battles where offer=$prt[time]"));
$b_id_id['id']+=1;
mysql_query("insert into battles (offer, time, id, attacker, defender, kick, block, type, damage, comment) values ($prt[time], '$battime', '$b_id_id[id]', '', '', '', '', NULL, '', '<script language=JavaScript>show_inf(\"$stat[user]\",\"$stat[id]\",\"$stat[level]\",\"$stat[rank]\",\"$stat[tribe]\");</script> вмешался в поединок!')");
$b_id=$prt[time];
mysql_query("UPDATE players, offers SET players.battle=".$prt['time'].", players.side=".$side.", offers.type=2 where players.id=$stat[id] && offers.time=$prt[time]");
} else {
$bdate=date("d.m.y H:i",$battime);
mysql_query("INSERT INTO offers (time, type, size_left, size_right, done, timeout) values($battime+600,1,1,'1','1','180')");
$levels_my = mysql_fetch_array(mysql_query("SELECT base FROM levels WHERE level=$stat[level]"));
$levels_opp = mysql_fetch_array(mysql_query("SELECT base FROM levels WHERE level=$chl[level]"));
mysql_query("INSERT INTO participants (time, id, side, hp, base) values($battime+600, '$stat[id]', '0', '".$stat['hp_now']."', '".$levels_my['base']."')");
mysql_query("INSERT INTO participants (time, id, side, hp, base) values($battime+600, '$chl[id]', '1', '".$chl['hp_now']."', '".$levels_opp['base']."')");
mysql_query("insert into battles (offer, time, id, attacker, defender, kick, block, type, damage, comment) values ($battime, $battime, '0', '', '', '', '', NULL, '', '[i]Часы показывали [u]$bdate[/u] когда бой между [/i]<font color=CFA87A>[b]$stat[user][/b]</font> и <font color=679958>[b]$chl[user][/b]</font> [i]начался![/i]')");
mysql_query("update players set battle=$battime+600, side=0 where id='$stat[id]'");
mysql_query("update players set battle=$battime+600, side=1 where id='$chl[id]'");
$b_id=$battime;
}
echo"<script>parent.main.location=\"battle.php?tmp=\"+Math.random();\"\"</script>";
}
}
}