<?
$BotName = "Босс";
$BotInfo = mysql_fetch_array(mysql_query("SELECT * FROM players WHERE user='".$BotName."' LIMIT 1"));
if ($chl['user'] == $BotInfo['user'])
$nms="Нападение на самого себя - это уже мазохизм...";
//elseif ($ctime-$chl['lpv'] > 60)
// $nms="Персонаж [u]$login[/u] отстутствует!";
elseif ($BotInfo['hp_now'] < (($BotInfo['hp']+$BotInfo['vitality']*5)*0.33))
$nms="Скелет еще не собрал свои кости!";
elseif ($chl['hp_now'] <= 5)
$nms="Персонаж [u]$login[/u] слишком слаб для поединка!";
else {
include("inc/magic/drop.php");
$levels=mysql_fetch_array(mysql_query("SELECT base FROM levels WHERE level=".$BotInfo['level'].""));
if ($chl['battle']) {
mysql_query("LOCK TABLES participants WRITE, battles WRITE");
$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;
}
mysql_query("INSERT INTO participants (`time`, `id`, `side`, `base`,`hp`) values('".$prt['time']."', '".$BotInfo['id']."', '".$side."', '".$levels['base']."', ".$BotInfo['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'].", ".$now.", ".$b_id_id['id'].", '', '', '', '', NULL, '', '<script language=JavaScript>show_inf(\"".$BotInfo['user']."\",\"".$BotInfo['id']."\",\"".$BotInfo['level']."\",\"".$BotInfo['rank']."\",\"".$BotInfo['tribe']."\");</script> вмешался в поединок!')");
mysql_query("UNLOCK TABLES");
mysql_query("UPDATE players, offers SET players.battle=".$prt['time'].", players.side=".$side.", offers.type=2 WHERE players.id=".$BotInfo['id']." && offers.time=".$prt['time']."");
}
else {
$time = $now + 600;
$chl_base=mysql_fetch_array(mysql_query("SELECT base FROM levels WHERE level=".$chl['level'].""));
$bdate=date("d.m.y H:i",$time);
mysql_query("LOCK TABLES offers WRITE");
while (mysql_fetch_array(mysql_query("SELECT * FROM offers WHERE time=".$time."")))
$time++;
mysql_query("INSERT INTO offers (time, type, size_left, size_right, done, timeout, blood) values(".$time.",1,1,'1','1','180', '1')");
mysql_query("UNLOCK TABLES");
mysql_query("INSERT INTO participants (`time`,`id`,`side`,`base`,`hp`) VALUES (".$time.",".$BotInfo['id'].",0,".$levels['base'].",".$BotInfo['hp_now'].")");
mysql_query("INSERT INTO participants (`time`,`id`,`side`,`base`,`hp`) VALUES (".$time.",".$chl['id'].",1,".$chl_base['base'].",".$chl['hp_now'].")");
mysql_query("INSERT INTO battles (offer, time, id, attacker, defender, kick, block, type, damage, comment) values (".$time.", ".$time.", '0', '', '', '', '', NULL, '', '[i]Часы показывали [u]".$bdate."[/u] когда бой начался!')");
mysql_query("UPDATE players SET battle=".$time.", side=0 WHERE id='".$BotInfo['id']."'");
mysql_query("UPDATE players SET battle=".$time.", side=1 WHERE id='".$chl['id']."'");
}
require_once("inc/chat/functions.php");
insert_msg("Мертвый [b][u]".$BotInfo['user']."[/u][/b] был призван против Вас, если вы не убете его получите травму!","","","1",$chl['user'],"",$chl['room']);
echo"<script>parent.main.location=\"battle.php?tmp=\"+Math.random();\"\"</script>";
}
?>