85 lines
4.0 KiB
PHP
85 lines
4.0 KiB
PHP
<?php
|
||
#$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `real_time` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;"));
|
||
$owntravma = mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = ".$us['id']." AND (type=13 OR ND type=12 OR type=14);"));
|
||
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '23' ;"));
|
||
$us_b=mysql_fetch_array(mysql_query("SELECT `type`,`open` FROM `battle` WHERE `id`='{$us['battle']}';"));
|
||
|
||
$int=101;
|
||
$jert = mysql_fetch_array(mysql_query("SELECT * FROM `bots` WHERE `name` = '{$_POST['target']}' LIMIT 1;"));
|
||
$effect = mysql_fetch_array(mysql_query("SELECT `id` FROM `effects` WHERE `owner` = '{$jert['id']}' AND `time` > '".time()."' AND `type` = '227' LIMIT 1"));
|
||
|
||
|
||
if ($user['battle'] > 0) {
|
||
echo "Не в бою...";
|
||
} elseif ($us_b['type']==3 || $us_b['type']==5) {
|
||
echo "Запрещено входить в хаотический бой!";
|
||
} elseif ($jert['battle']>0 && $us_b['open']==0) {
|
||
echo "Бой закрыт для вмешательства!";
|
||
} elseif ($user['zayavka'] > 0) {
|
||
echo "Вы ожидаете поединка...";
|
||
} elseif(in_array($jert['room'], Config::$unkilable['rooms'])) {
|
||
echo "В данной комнате запрещены нападения ...";
|
||
} elseif(in_array($jert['id'], Config::$unkilable['users'])) {
|
||
echo "Персонаж под защитой от нападений ...";
|
||
} elseif(isset($effect['id'])) {
|
||
echo "Персонаж под защитой от нападений ...";
|
||
} elseif ($user['hp'] < $user['maxhp']*0.33) {
|
||
echo "Вы слишком ослаблены для нападения!";
|
||
} elseif ($jert['hp'] < 1) {
|
||
echo "Вы не можете напасть на погибшего!";
|
||
} elseif (rand(1,100) < $int) {
|
||
|
||
if ($user['sex'] == 1) {$action="напал";} else {$action="напала";}
|
||
if ($user['align'] > '2' && $user['align'] < '3') {
|
||
$angel="Ангел";
|
||
} elseif ($user['align'] > '1' && $user['align'] < '2') {
|
||
$angel="Персонаж";
|
||
}
|
||
|
||
|
||
|
||
|
||
addch("<img src=i/magic/attack.gif> <B>{$user['login']}</B>, применив магию нападения, внезапно ".$action." на "{$_POST['target']}"");
|
||
$bet=1;
|
||
$bot=1;
|
||
|
||
if($jert['battle'] > 0) {
|
||
|
||
//вмешиваемся
|
||
$bd = mysql_fetch_array(mysql_query ('SELECT * FROM `battle` WHERE `id` = '.$jert['battle'].' LIMIT 1;'));
|
||
$battle = unserialize($bd['teams']);
|
||
$ak = array_keys($battle[$jert['id']]);
|
||
$battle[$user['id']] = $battle[$ak[0]];
|
||
foreach($battle[$user['id']] as $k => $v) {
|
||
$battle[$user['id']][$k] =array(0,0,time());
|
||
$battle[$k][$user['id']] = array(0,0,time());
|
||
}
|
||
$t1 = explode(";",$bd['t1']);
|
||
// проставляем кто-где
|
||
if (in_array ($jert['id'],$t1)) {
|
||
$ttt = 2;
|
||
} else {
|
||
$ttt = 1;
|
||
}
|
||
addch ("<b>".Nick::id($user['id'])->short()."</b> вмешался в <a href=logs.php?log=".$id." target=_blank>поединок »»</a>. ",$user->room);
|
||
|
||
//mysql_query('UPDATE `logs` SET `log` = CONCAT(`log`,\'<span class=date>'.date("H:i").'</span> '.nick::id($user['id'])->short().' вмешался в поединок!<BR>\') WHERE `id` = '.$jert['battle'].'');
|
||
|
||
//addlog($jert['battle'],'<span class=date>'.date("H:i").'</span> '.nick::id($user['id'])->short().' вмешался в поединок!<BR>');
|
||
|
||
mysql_query('UPDATE `battle` SET `teams` = \''.serialize($battle).'\', `t'.$ttt.'`=CONCAT(`t'.$ttt.'`,\';'.$user['id'].'\') WHERE `id` = '.$jert['battle'].' ;');
|
||
mysql_query("UPDATE users SET `battle` =".$jert['battle'].",`zayavka`=0 WHERE `id`= ".$user['id']);
|
||
|
||
header("Location:fbattle.php");
|
||
//exit("<script>location.href='fbattle.php';</script>");
|
||
}
|
||
else
|
||
{
|
||
echo("Не судьба!");
|
||
}
|
||
//$bet=1;
|
||
} else {
|
||
echo "Свиток рассыпался в ваших руках...";
|
||
$bet=1;
|
||
}
|