2018-01-28 16:40:49 +00:00
< ? php
2020-02-17 15:03:21 +00:00
$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); " ));
2018-01-28 16:40:49 +00:00
$magic = mysql_fetch_array ( mysql_query ( " SELECT `chanse` FROM `magic` WHERE `id` = '23' ; " ));
2020-02-17 15:03:21 +00:00
$effect = mysql_fetch_array ( mysql_query ( " SELECT `id` FROM `effects` WHERE `owner` = ' { $us [ 'id' ] } ' AND `time` > ' " . time () . " ' AND `type` = '227' LIMIT 1 " ));
2018-01-28 16:40:49 +00:00
if ( $user [ 'intel' ] >= 4 ) {
2020-02-17 15:03:21 +00:00
$int = $magic [ 'chanse' ] + ( $user [ 'intel' ] - 4 ) * 3 ;
if ( $int >= 100 ) {
$int = 100 ;
}
} else {
$int = 0 ;
}
2018-01-28 16:40:49 +00:00
if ( $user [ 'battle' ] > 0 ) {
2020-02-17 15:03:21 +00:00
echo " Н е в бою..." ;
} elseif ( ! $us [ 'online' ]) {
echo " Персонаж не в игре! " ;
} elseif ( $us_b [ 'type' ] == 3 || $us_b [ 'type' ] == 5 ) {
echo " Запрещено входить в хаотический бой! " ;
} elseif ( $us [ 'battle' ] > 0 && $us_b [ 'open' ] == 0 ) {
echo " Бой закрыт для вмешательства! " ;
2018-01-28 16:40:49 +00:00
} elseif ( $user [ 'zayavka' ] > 0 ) {
2020-02-17 15:03:21 +00:00
echo " Вы ожидаете поединка... " ;
2021-03-10 21:03:59 +00:00
} elseif ( in_array ( $us [ 'room' ], UNKILABLE [ 'rooms' ])) {
2020-02-17 15:03:21 +00:00
echo " В данной комнате запрещены нападения ..." ;
2021-03-10 21:03:59 +00:00
} elseif ( in_array ( $us [ 'id' ], UNKILABLE [ 'users' ])) {
2020-02-17 15:03:21 +00:00
echo " Персонаж под защитой от нападений ... " ;
} elseif ( isset ( $effect [ 'id' ])) {
echo " Персонаж под защитой от нападений ... " ;
2018-01-28 16:40:49 +00:00
} elseif ( $owntravma [ 'id' ] && ! $us [ 'battle' ]) {
2020-02-17 15:03:21 +00:00
echo " Персонаж тяжело травмирован... " ;
2021-02-01 19:20:23 +00:00
} elseif ( $user -> getRoom () != $us [ 'room' ]) {
2020-02-17 15:03:21 +00:00
echo " Персонаж в другой комнате! " ;
2018-01-28 16:40:49 +00:00
} elseif ( $us [ 'level' ] < 1 ) {
2020-02-17 15:03:21 +00:00
echo " Новички находятся под защитой Мироздателя! " ;
} 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 " Вы не можете напасть на погибшего! " ;
} elseif ( mt_rand ( 1 , 100 ) < $int ) {
if ( $user [ 'sex' ] == 1 ) {
$action = " напал " ;
} else {
$action = " напала " ;
}
$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' ] } " " );
2020-08-27 12:17:02 +00:00
addchp ( '<font color=red>Внимание!</font> Н а вас ' . $action . ' <B>' . $user [ 'login' ] . '</B>.<BR>\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ' , '{[]}' . Nick :: id ( $jert [ 'id' ]) -> short () . '{[]}' );
2020-02-17 15:03:21 +00:00
//destructitem($row['id']);
$bet = 1 ;
//а р х
if ( $jert [ 'id' ] > _BOTSEPARATOR_ ) {
$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 ] = [ 0 , 0 , time ()];
$battle [ $k ][ $user [ 'id' ]] = [ 0 , 0 , time ()];
}
$t1 = explode ( " ; " , $bd [ 't1' ]);
// проставляем кто-где
if ( in_array ( $jert [ 'id' ], $t1 )) {
$ttt = 2 ;
} else {
$ttt = 1 ;
}
2021-02-01 19:20:23 +00:00
addch ( " <b> " . Nick :: id ( $user [ 'id' ]) -> short () . " </b> вмешался в <a href=logs.php?log= " . $id . " target=_blank>поединок »»</a>. " , $user -> getRoom ());
2020-02-17 15:03:21 +00:00
//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'].'');
2020-08-27 12:17:02 +00:00
addlog ( $jert [ 'battle' ], '<span class=date>' . date ( " H:i " ) . '</span> ' . Nick :: id ( $user [ 'id' ]) -> short () . ' вмешался в поединок!<BR>' );
2020-02-17 15:03:21 +00:00
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 " );
2020-09-30 12:01:33 +00:00
//exit("<script>location.href='fbattle.php';</script>");
2020-02-17 15:03:21 +00:00
} 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 ('Архивариус','83','',' " . $jert [ 'hp' ] . " '); " );
$jert [ 'id' ] = mysql_insert_id ();
}
undressall ( $jert [ 'id' ]);
undressall ( $user [ 'id' ]);
$teams = [];
$teams [ $user [ 'id' ]][ $jert [ 'id' ]] = [ 0 , 0 , time ()];
$teams [ $jert [ 'id' ]][ $user [ 'id' ]] = [ 0 , 0 , time ()];
$sv = [ 3 , 4 , 5 ];
//$tou = array_rand($sv,1);
mysql_query ( " INSERT INTO `battle`
2018-01-28 16:40:49 +00:00
(
`id` , `coment` , `teams` , `timeout` , `type` , `status` , `t1` , `t2` , `to1` , `to2` , `blood`
)
VALUES
(
2020-02-17 15:03:21 +00:00
NULL , '' , '" . serialize($teams) . "' , '" . $sv[rand(0, 2)] . "' , '1' , '0' , '" . $user[' id '] . "' , '" . $jert[' id '] . "' , '" . time() . "' , '" . time() . "' , '0'
2018-01-28 16:40:49 +00:00
) " );
2020-02-17 15:03:21 +00:00
$id = mysql_insert_id ();
2018-01-28 16:40:49 +00:00
2020-02-17 15:03:21 +00:00
// апдейтим врага
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; " );
}
2018-01-28 16:40:49 +00:00
2020-02-17 15:03:21 +00:00
// создаем лог
2018-01-28 16:40:49 +00:00
2020-08-27 12:17:02 +00:00
$rr = " <b> " . Nick :: id ( $user [ 'id' ]) -> full ( 1 ) . " </b> и <b> " . Nick :: id ( $jert [ 'id' ]) -> full ( 1 ) . " </b> " ;
2021-02-01 19:20:23 +00:00
addch ( " <a href=logs.php?log= " . $id . " target=_blank>Бой</a> между <B><b> " . Nick :: id ( $user [ 'id' ]) -> short () . " </b> и <b> " . Nick :: id ( $jert [ 'id' ]) -> short () . " </b> начался. " , $user -> getRoom ());
2018-01-28 16:40:49 +00:00
2020-02-17 15:03:21 +00:00
//mysql_query("INSERT INTO `logs` (`id`,`log`) VALUES('{$id}',"Часы показывали <span class=date>".date("Y.m.d H.i")."</span>, когда ".$rr." бросили вызов друг другу. <BR>");
2018-01-28 16:40:49 +00:00
2020-02-17 15:03:21 +00:00
addlog ( $id , " Часы показывали <span class=date> " . date ( " Y.m.d H.i " ) . " </span>, когда " . $rr . " бросили вызов друг другу. <BR> " );
2018-01-28 16:40:49 +00:00
2020-02-17 15:03:21 +00:00
mysql_query ( " UPDATE users SET `battle` = { $id } ,`zayavka`=0 WHERE `id`= { $user [ 'id' ] } OR `id` = { $jert [ 'id' ] } " );
header ( " Location:fbattle.php " );
2020-09-30 12:01:33 +00:00
//exit("<script>location.href='fbattle.php';</script>");
2020-02-17 15:03:21 +00:00
}
} else {
echo '<font color=red>Мазохист?...</font>' ;
}
//$bet=1;
2018-01-28 16:40:49 +00:00
} else {
2020-02-17 15:03:21 +00:00
echo " Свиток рассыпался в ваших руках... " ;
$bet = 1 ;
}