182 lines
8.7 KiB
PHP
182 lines
8.7 KiB
PHP
|
<?php
|
|||
|
if($user['room']==20){
|
|||
|
//нападение
|
|||
|
$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;"));
|
|||
|
$battle = mysql_fetch_array(mysql_query("SELECT `closed` FROM `battle` WHERE `id` = '{$us['battle']}' ;"));
|
|||
|
$owntravma = @mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = ".$us['id']." AND (type=13 OR type=12 OR type=14);"));
|
|||
|
$owntravma1 = @mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = ".$_SESSION['uid']." AND (type=13 OR type=12 OR type=14);"));
|
|||
|
if($user['invis']=='1') {$user['login'] = '</a><b><i>невидимка</i></b>'; $user['klan']=''; $user['level']='??';}
|
|||
|
|
|||
|
echo"<font color=red><b>";
|
|||
|
if ($battle['closed']== 1) {
|
|||
|
echo "Этот бой изолирован от внешнего мира";
|
|||
|
}
|
|||
|
elseif ($user['battle'] > 0) {
|
|||
|
echo "Не в бою...";
|
|||
|
}
|
|||
|
elseif ($us['login']=='Устроитель') {
|
|||
|
echo "На Устроителя нельзя напасть!</b></font>";
|
|||
|
}
|
|||
|
elseif (!$us['online'] && ($us['login']!="Общий Враг" or vrag!="on")) {
|
|||
|
echo "Персонаж не в игре!";
|
|||
|
}
|
|||
|
elseif ($user['zayavka'] > 0) {
|
|||
|
echo "Вы ожидаете поединка...";
|
|||
|
}
|
|||
|
elseif ($owntravma1['id']) {
|
|||
|
echo "Только безумец спасобен на такое";
|
|||
|
}
|
|||
|
elseif ($owntravma['id'] && !$us['battle']) {
|
|||
|
echo "Персонаж тяжело травмирован...";
|
|||
|
} elseif ($user['klan'] != '' && ($user['klan'] == $us['klan'])) {
|
|||
|
echo "Чтите честь ваших сокланов.";
|
|||
|
} elseif ($user['align'] >1 && $user['align'] <2 && $us['align'] >1 && $us['align'] <2) {
|
|||
|
echo "Чтите честь братьев.";
|
|||
|
} elseif ($user['room'] != $us['room']) {
|
|||
|
echo "Персонаж в другой комнате!";
|
|||
|
} elseif ($us['room'] == 31) {
|
|||
|
echo "Нападения в этой локации запрещены!";
|
|||
|
} elseif ($us['room'] == 402) {
|
|||
|
echo "Нападения в этой локации запрещены!";
|
|||
|
} elseif ($us['room'] == 403) {
|
|||
|
echo "Нападения в этой локации запрещены!";
|
|||
|
} elseif ($us['room'] == 404) {
|
|||
|
echo "Нападения в этой локации запрещены!";
|
|||
|
} elseif ($us['level'] < 3) {
|
|||
|
echo "Нельзя напасть на персонажа ниже 3 уровня! Даже ночью, даже на Центральной площади...";
|
|||
|
} elseif ($us['hp'] < $us['maxhp']*0.33 && !$us['battle']) {
|
|||
|
echo "Жертва слишком слаба!";
|
|||
|
} elseif ($user['hp'] < $user['maxhp']*0.33) {
|
|||
|
echo "Вы слишком ослаблены для нападения!";
|
|||
|
} elseif ($us['hp'] < 1 && $us['battle']) {
|
|||
|
echo "Вы не можете напасть на погибшего!";
|
|||
|
} else {
|
|||
|
|
|||
|
if ($user['sex'] == 1) {$action="напал";} else {$action="напала";}
|
|||
|
if ($user['align'] > '2' && $user['align'] < '3') {
|
|||
|
$angel="Ангел";
|
|||
|
} elseif ($user['align'] > '1' && $user['align'] < '2') {
|
|||
|
$angel="Персонаж";
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
$jert = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;"));
|
|||
|
if($jert['id']!=$user['id']) {
|
|||
|
addch("<img src=i/magic/attack.gif> <B>{$user['login']}</B>, применив магию нападения, внезапно ".$action." на "{$_POST['target']}"");
|
|||
|
addchp ('<font color=red>Внимание!</font> На вас '.$action.' <B>'.$user['login'].'</B>.<BR>\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ','{[]}'.nick7 ($jert['id']).'{[]}');
|
|||
|
//destructitem($row['id']);
|
|||
|
$bet=1;
|
|||
|
//арх
|
|||
|
if($jert['id'] > _BOTSEPARATOR_ or $us['login']=="Общий Враг") {
|
|||
|
$arha = mysql_fetch_array(mysql_query ('SELECT * FROM `bots` WHERE `prototype` = '.$jert['id'].' LIMIT 1;'));
|
|||
|
$jert['battle'] = $arha['battle'];
|
|||
|
$jert['id'] = $arha['id'];
|
|||
|
$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>".nick7($user['id'])."</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> '.nick5($user['id'],"B".$ttt).' вмешался в поединок!<BR>\') WHERE `id` = '.$jert['battle'].'');
|
|||
|
|
|||
|
addlog($jert['battle'],'<span class=date>'.date("H:i").'</span> '.nick5($user['id'],"B".$ttt).' вмешался в поединок!<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,`hit`=0,`parry`=0,`krit`=0,`counter`=0,`hp2`=0 WHERE `id`= ".$user['id']);
|
|||
|
|
|||
|
header("Location:fbattle.php");
|
|||
|
//die("<script>location.href='fbattle.php';</script>");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
// начинаем бой
|
|||
|
//$bet=1;
|
|||
|
// если чел в заявке, выбиваем его
|
|||
|
if($jert['zayavka']) {
|
|||
|
$fict1 = mysql_fetch_array(mysql_query("SELECT * FROM `zayavka` WHERE `team1` LIKE '{$jert['id']};%' OR `team1` LIKE '%;{$jert['id']};%' LIMIT 1;"));
|
|||
|
$fict2 = mysql_fetch_array(mysql_query("SELECT * FROM `zayavka` WHERE `team2` LIKE '{$jert['id']};%' OR `team2` LIKE '%;{$jert['id']};%' LIMIT 1;"));
|
|||
|
if($fict1) { $team=1; }
|
|||
|
elseif($fict2) { $team=2; }
|
|||
|
|
|||
|
mysql_query("UPDATE `users` SET `zayavka` = '' WHERE `id` = {$jert['id']} LIMIT 1;");
|
|||
|
$z = mysql_fetch_array(mysql_query("SELECT `team{$team}` FROM `zayavka` WHERE `id`=".$jert['zayavka'].";"));
|
|||
|
|
|||
|
$teams = str_replace($jert['id'].";","",$z[0]);
|
|||
|
mysql_query("UPDATE `zayavka` SET team{$team} = '{$teams}' WHERE id = {$jert['zayavka']};");
|
|||
|
}
|
|||
|
|
|||
|
//arch
|
|||
|
if($bot) {
|
|||
|
mysql_query("INSERT INTO `bots` (`name`,`prototype`,`battle`,`hp`) values ('Общий Враг','3954','','30000');");
|
|||
|
$jert['id'] = mysql_insert_id();
|
|||
|
}
|
|||
|
|
|||
|
$teams = array();
|
|||
|
$teams[$user['id']][$jert['id']] = array(0,0,time());
|
|||
|
$teams[$jert['id']][$user['id']] = array(0,0,time());
|
|||
|
$sv = array(3,4,5);
|
|||
|
//$tou = array_rand($sv,1);
|
|||
|
mysql_query("INSERT INTO `battle`
|
|||
|
(
|
|||
|
`id`,`coment`,`teams`,`timeout`,`type`,`status`,`t1`,`t2`,`to1`,`to2`,`blood`
|
|||
|
)
|
|||
|
VALUES
|
|||
|
(
|
|||
|
NULL,'','".serialize($teams)."','".$sv[rand(0,2)]."','1','0','".$user['id']."','".$jert['id']."','".time()."','".time()."','0'
|
|||
|
)");
|
|||
|
|
|||
|
$id = mysql_insert_id();
|
|||
|
|
|||
|
// апдейтим врага
|
|||
|
if($bot) {
|
|||
|
mysql_query("UPDATE `bots` SET `battle` = {$id} WHERE `id` = {$jert['id']} LIMIT 1;");
|
|||
|
} else {
|
|||
|
mysql_query("UPDATE `users` SET `battle` = {$id} WHERE `id` = {$jert['id']} LIMIT 1;");
|
|||
|
}
|
|||
|
|
|||
|
// создаем лог
|
|||
|
|
|||
|
|
|||
|
$rr = "<b>".nick3($user['id'])."</b> и <b>".nick3($jert['id'])."</b>";
|
|||
|
addch ("<a href=logs.php?log=".$id." target=_blank>Бой</a> между <B><b>".nick7($user['id'])."</b> и <b>".nick7($jert['id'])."</b> начался. ",$user['room']);
|
|||
|
|
|||
|
//mysql_query("INSERT INTO `logs` (`id`,`log`) VALUES('{$id}',"Часы показывали <span class=date>".date("Y.m.d H.i")."</span>, когда ".$rr." бросили вызов друг другу. <BR>");
|
|||
|
|
|||
|
mysql_query("UPDATE users SET `battle` ={$id},`zayavka`=0 WHERE `id`= {$user['id']} OR `id` = {$jert['id']}");
|
|||
|
if($us['login']=="Общий Враг"){$jert['id']=3954;}
|
|||
|
$rr = "<b>".nick3($user['id'])."</b> и <b>".nick3($jert['id'])."</b>";
|
|||
|
addlog($id,"Часы показывали <span class=date>".date("Y.m.d H.i")."</span>, когда ".$rr." бросили вызов друг другу. <BR>");
|
|||
|
|
|||
|
if($jert['id'] && $user['id'] && $jert['id']<999999){
|
|||
|
$btfl=fopen('tmp/'.$user['id'].'.btl','a');
|
|||
|
fwrite($btfl,'{[='.$jert['id'].'=]}');
|
|||
|
fclose($btfl);
|
|||
|
$btfl=fopen('tmp/'.$jert['id'].'.btl','a');
|
|||
|
fwrite($btfl,'{[='.$user['id'].'=]}');
|
|||
|
fclose($btfl);
|
|||
|
}
|
|||
|
die("<script>location.href='fbattle.php';</script>");
|
|||
|
}
|
|||
|
} else {
|
|||
|
echo 'Мазохист?...';
|
|||
|
}
|
|||
|
//$bet=1;
|
|||
|
}
|
|||
|
echo"</b></font></div>";
|
|||
|
}
|
|||
|
?>
|