Кароче такой баг. когда бой заканчивается таймом то победу дает обоим сторонам. пробовал немного редактировать файл батла то получалось ни чем не лучше давалось как бы рандомам победу. что можно сделать вот файл батла
[spoilerbox="ololo"]
[/spoilerbox]
[spoilerbox="ololo"]
Код:
<?php
$_POST['kick']=round($_POST['kick']);
echo"<script language=JavaScript src='i/login_form.js'></script>";
echo"<script language=JavaScript src='i/show_inf.js'></script>";
echo"<script language=JavaScript src='i/time.js'></script>";
echo"<script language=JavaScript src='i/battle.js'></script>";
echo"<div id=mainform style='position:absolute; left:11px; top:30px'></div>";
echo"<div id=hint1 class=hint></div>";
print "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"30; URL=battle.php?refresh=".$_GET['refresh']."&tmp=".time()."\">";
if (!empty($use_priem)){
if (!preg_match("/^[0-9]{1,10}$/", $use_priem)) die("Ошибка1");
$qqqq = mysql_query("select wait, name from priem where id='$use_priem'");
if (!$qqqq) die("Ошибка3");
else{
$qq1 = mysql_fetch_array($qqqq);
mysql_query("update participants set priem=$use_priem, wait=$qq1[wait] where time='".$stat['battle']."' AND id='".$stat['id']."' LIMIT 1");
echo"<script>parent.main.location=\"battle.php?tmp=\"+Math.random();\"\"</script>";
$participant=mysql_fetch_array(mysql_query("SELECT `hp`, `damage`, `side` FROM participants WHERE time='".$stat['battle']."' AND id='".$stat['id']."' LIMIT 1"));
$type=mysql_fetch_array(mysql_query("SELECT `type` FROM offers WHERE time='".$stat['battle']."' LIMIT 1"));
$max=mysql_fetch_array(mysql_query("select max(id) as id from battles where offer='".$stat['battle']."'"));
if (!$max)
$new_id=1;
else
$new_id=$max['id']+1;
mysql_query("lock tables battles write");
$new_id+=1;
mysql_query("INSERT INTO battles (offer, time, id, attacker, defender, kick, block, type, damage, comment, side) VALUES ($stat[battle], $now, '$new_id', '$stat[user]', '$chl[user]', '', '', '$type[type]', '', 'Персонаж $stat[user] использовал приём $qq1[name]',".$participant['side'].")");
mysql_query("unlock tables");
$p_p = mysql_query("select krit, parry, dam, mag from priem where id='$use_priem'");
$pr=mysql_fetch_array($p_p);
$p_krit=round($pr['krit']*10);
$p_mag=round($pr['mag']*10);
$p_parry=round($pr['parry']*10);
$p_hp=round($pr['dam']*10);
mysql_query("update participants set krit=krit-$p_krit, mag=mag-$p_mag, parry=parry-$p_parry, dam=dam-$p_hp where time='".$stat['battle']."' AND id='".$stat['id']."'");
}}
include("inc/battle/changed_1.php");
$now=time();
$_RESERVER['battle'] = $stat['battle'];
// ----- # Узнаем, в какой команде, и сколько HP нанесли # ----- //
$participant=mysql_fetch_array(mysql_query("SELECT `hp`, `damage`, `side`, `krit`, `mag`, `parry`, `dam`, `wait`, `priem` FROM participants WHERE time='".$stat['battle']."' AND id='".$stat['id']."' LIMIT 1"));
if ($participant['side'] == "") $participant['side'] = $stat['side'];
switch ($participant['side']) {
case 0: $opp_side=1; break;
case 1: $opp_side=0; break;
}
if ($participant['wait'] == 1 AND $participant['priem'] == 6){
$id_p = $participant['priem'];
include("inc/battle/priem/6.php");
}
// ----- # Информация о бое (Из таблицы заявок) # ----- //
$offer=mysql_fetch_array(mysql_query("SELECT `timeout`, `type`, `blood`, `kulak` FROM offers WHERE time='".$stat['battle']."' LIMIT 1"));
$max11=mysql_fetch_array(mysql_query("SELECT MAX(time) AS time FROM battles WHERE offer='".$stat['battle']."'"));
if ($stat['hp_now'] && $participant['hp']) {
if ($kick!="" && $block!="" && $opponent!="") {
$user_turn=mysql_fetch_array(
mysql_query(
"select * from battles
where offer=$stat[battle]
and attacker='$stat[user]'
and defender='".addslashes($opponent)."'
and type is NULL"));
if (!$user_turn) {
$opp_stats=mysql_query("SELECT id, user, level, strength, dex, agility, vitality, razum, hp_now, invisible, battle, rank FROM players WHERE user='".addslashes($opponent)."' LIMIT 1");
$opp_stat=mysql_fetch_array($opp_stats);
if ($opp_stat['hp_now'] == 0)
$opponent = "";
include("inc/battle/changed_opp.php");
if ($participant['wait'] == 1 AND $participant['priem'] != 0 AND $participant['priem'] != 6){
$id_p = $participant['priem'];
include("inc/battle/priem/$id_p.php");
}
if ($opp_stat['rank'] == 60 && $opponent!="") {
$max=mysql_fetch_array(mysql_query("select max(id) as id from battles where offer='".$stat['battle']."'"));
if (!$max)
$new_id=1;
else
$new_id=$max['id']+1;
$opponent_turn['kick'] = rand(0,4);
$opponent_turn['block'] = rand(0,4);
$opponent_turn['id'] = $new_id;
mysql_query(
"insert into battles (offer, time, id, attacker, defender, kick, block, side)
values ($stat[battle],$now,$new_id,'".$opp_stat['user']."','$stat[user]','".$opponent_turn['kick']."','".$opponent_turn['block']."', ".$opp_side.")");
mysql_query("UPDATE `players` SET `lpv` = '".time()."' WHERE `id`='".$opp_stat['id']."'");
}
elseif ($opponent!="")
$opponent_turn=mysql_fetch_array(
mysql_query(
"select * from battles
where offer='".$stat['battle']."'
AND attacker='".addslashes($opponent)."'
AND defender='".$stat[user]."'
AND type is NULL"));
if ($opponent_turn) {
$opponent_turn['kick']=round($opponent_turn['kick']);
if (!is_numeric($opponent_turn['kick']) || ($opponent_turn['kick']<0 || $opponent_turn['kick']>4)) $opponent_turn['kick']=$block;
if ($opponent_turn[kick]==$block) $damage[1] = 0;
elseif ($opponent_turn[kick]==0 && ($block==0 || $block==4)) $damage[1] = 0;
elseif (($opponent_turn[kick]>=1 && $opponent_turn[kick]<=4) && $block==$opponent_turn[kick]-1) $damage[1] = 0;
else {
$damage[1] = rand(($opp_stat[strength]/3+$opp_stat[min])*(1+($opp_stat['warattack']/100)),(1+$opp_stat[strength]/1.5+$opp_stat[max])*(1+($opp_stat['warattack']/100)));
}
$kick=round($kick);
if (!is_numeric($kick) || ($kick<0 || $kick>4)) $kick=$opponent_turn['block'];
if ($kick==$opponent_turn[block]) $damage[0] = 0;
elseif ($kick==0 && ($opponent_turn[block]==0 || $opponent_turn[block]==4)) $damage[0] = 0;
elseif (($kick>=1 && $kick<=4) && $opponent_turn[block]==$kick-1) $damage[0] = 0;
else {
$damage[0] = rand(($stat[strength]/3+$stat[min])*(1+($stat['warattack']/100)),(1+$stat[strength]/1.5+$stat[max])*(1+($stat['warattack']/100))); }
// ----- # Крит # ----- //
$c = 70 + $priem_krit;
$crit = $c * ( ( $stat['dex'] + ( $stat['dex'] * ($stat['krit'] - $opp_stat['unkrit'])/100 ) ) - $opp_stat['dex'] ) / abs( $stat['dex'] + ( $stat['dex'] * ($stat['krit'] - $opp_stat['unkrit'])/100 ) );
$crit1 = $crit/($priem_krit+1);
if (mt_rand(0, 100) <= $crit) {
$damage[0]*=2;
$adv_attack[0]=1;
$krt[0] = 1;
$krit = round($crit1);
$krit = rand(round($krit/2), $krit);
mysql_query("UPDATE players, participants SET participants.krit=participants.krit+$krit WHERE players.id='".$stat['id']."' AND participants.time='".$stat['battle']."' AND participants.id='".$stat['id']."'");
$participant['krit']+=$krit;
} else {
$adv_attack[0]=0;
$krt[0] = 0;
}
//
// Крит
$c = 70;
$crit = $c * ( ( $opp_stat['dex'] + ( $opp_stat['dex'] * ($opp_stat['krit'] - $stat['unkrit'])/100 ) ) - $stat['dex'] ) / abs( $opp_stat['dex'] + ( $opp_stat['dex'] * ($opp_stat['krit'] - $stat['unkrit'])/100 ) );
if (mt_rand(0, 100) <= $crit) {
$damage[1]*=2;
$adv_attack[1]=1;
$krt[1] = 1;
} else {
$adv_attack[1]=0;
$krt[1] = 0;
}
//
// ----- # Уворот # ----- //
$c = 70 + $priem_parry;
$crit = $c * ( ( $stat['agility'] + ( $stat['agility'] * ($stat['uv'] - $opp_stat['unuv'])/100 ) ) - $opp_stat['agility'] ) / abs( $stat['agility'] + ( $stat['agility'] * ($stat['uv'] - $opp_stat['unuv'])/100 ) );
$crit1 = $crit/($priem_parry+1);
if (mt_rand(0, 100) <= $crit) {
$damage[1] = 0;
$adv_attack[1]=2;
$parry = round($crit1);
$parry = rand(round($parry/2), $parry);
mysql_query("UPDATE players, participants SET participants.parry=participants.parry+$parry WHERE players.id='".$stat['id']."' AND participants.time='".$stat['battle']."' AND participants.id='".$stat['id']."'");
$participant['parry']+=$parry;
} else $adv_attack[1]=0;
//
// Уворот
$c = 70;
$crit = $c * ( ( $opp_stat['agility'] + ( $opp_stat['agility'] * ($opp_stat['uv'] - $stat['unuv'])/100 ) ) - $stat['agility'] ) / abs( $opp_stat['agility'] + ( $opp_stat['agility'] * ($opp_stat['uv'] - $stat['unuv'])/100 ) );
if (mt_rand(0, 100) <= $crit) { $damage[0] = 0; $adv_attack[0]=2; } else $adv_attack[0]=0;
$damage[0]+=$priem_dam;
// Дэмэдж 1 наносится по $stat, т.е. по мне
switch ($opponent_turn[kick]) {
case 0: $damage[1]-=rand(round($stat[br1]/3),$stat[br1]); if ($damage[1]<0) $damage[1]=0;
if ($damage[1]>$stat[hp_now]) $damage[1]=$stat[hp_now]; break;
case 1: $damage[1]-=rand(round($stat[br2]/3),$stat[br2]); if ($damage[1]<0) $damage[1]=0;
if ($damage[1]>$stat[hp_now]) $damage[1]=$stat[hp_now]; break;
case 2: $damage[1]-=rand(round($stat[br3]/3),$stat[br3]); if ($damage[1]<0) $damage[1]=0;
if ($damage[1]>$stat[hp_now]) $damage[1]=$stat[hp_now]; break;
case 3: $damage[1]-=rand(round($stat[br4]/3),$stat[br4]); if ($damage[1]<0) $damage[1]=0;
if ($damage[1]>$stat[hp_now]) $damage[1]=$stat[hp_now]; break;
case 4: $damage[1]-=rand(round($stat[br5]/3),$stat[br5]); if ($damage[1]<0) $damage[1]=0;
if ($damage[1]>$stat[hp_now]) $damage[1]=$stat[hp_now]; break;
}
switch ($kick) {
case 0: $damage[0]-=rand(round($opp_stat[br1]/3),$opp_stat[br1]); if ($damage[0]<0) $damage[0]=0;
if ($damage[0]>$opp_stat[hp_now]) $damage[0]=$opp_stat[hp_now]; break;
case 1: $damage[0]-=rand(round($opp_stat[br2]/3),$opp_stat[br2]); if ($damage[0]<0) $damage[0]=0;
if ($damage[0]>$opp_stat[hp_now]) $damage[0]=$opp_stat[hp_now]; break;
case 2: $damage[0]-=rand(round($opp_stat[br3]/3),$opp_stat[br3]); if ($damage[0]<0) $damage[0]=0;
if ($damage[0]>$opp_stat[hp_now]) $damage[0]=$opp_stat[hp_now]; break;
case 3: $damage[0]-=rand(round($opp_stat[br4]/3),$opp_stat[br4]); if ($damage[0]<0) $damage[0]=0;
if ($damage[0]>$opp_stat[hp_now]) $damage[0]=$opp_stat[hp_now]; break;
case 4: $damage[0]-=rand(round($opp_stat[br5]/3),$opp_stat[br5]); if ($damage[0]<0) $damage[0]=0;
if ($damage[0]>$opp_stat[hp_now]) $damage[0]=$opp_stat[hp_now]; break;
}
// ----- # Отнимаем жизни # ----- /
mysql_query("UPDATE players, participants SET players.hp_now=if(players.hp_now<$damage[1],0,players.hp_now-$damage[1]), participants.hp=if(participants.hp<$damage[1],0,participants.hp-$damage[1]), participants.damage=participants.damage+".$damage['0'].", participants.dam=participants.dam+".$damage['0']." WHERE players.id='".$stat['id']."' AND participants.time='".$stat['battle']."' AND participants.id='".$stat['id']."'");
mysql_query("UPDATE players, participants SET players.hp_now=if(players.hp_now<$damage[0],0,players.hp_now-$damage[0]), participants.hp=if(participants.hp<$damage[0],0,participants.hp-$damage[0]), participants.damage=participants.damage+".$damage['1']." WHERE players.id='".$opp_stat['id']."' AND participants.time='".$stat['battle']."' AND participants.id='".$opp_stat['id']."'");
$participant['dam']+=$damage[0];
/*
mysql_query("UPDATE players SET hp_now=if(hp_now<$damage[1],0,hp_now-$damage[1]) WHERE id='".$stat['id']."'");
mysql_query("UPDATE participants SET hp=if(hp<$damage[1],0,hp-$damage[1]), damage=damage+".$damage['0']." WHERE time='".$stat['battle']."' AND id='".$stat['id']."'");
mysql_query("UPDATE players SET hp_now=if(hp_now<$damage[0],0,hp_now-$damage[0]) WHERE id='".$opp_stat['id']."'");
mysql_query("UPDATE participants SET hp=if(hp<$damage[0],0,hp-$damage[0]), damage=damage+".$damage['1']." WHERE time='".$stat['battle']."' AND id='".$opp_stat['id']."'");
*/
$participant['damage'] += $damage['0'];
if($stat['hp_now'] > $damage['1']) $stat['hp_now']-=$damage['1'];
else $stat['hp_now']=0;
// HP для комментариев
if ($opp_stat['hp_now']<$damage[0]) $comhp_0=0; else $comhp_0=$opp_stat['hp_now']-$damage[0];
$comhp_1=$stat['hp_now'];
//
// ----- # Мой ник # ----- //
$attacker="<font color=CFA87A>$stat[user]</font>";
// ----- # Ник противника # ----- //
$defender="<font color=679958>$opp_stat[user]</font>";
switch ($kick) {
case 0: $str = "в голову"; break;
case 1: $str = "в грудь"; break;
case 2: $str = "в живот"; break;
case 3: $str = "в пояс"; break;
case 4: $str = "по ногам"; break;
}
switch ($krt[0]) {
case 0: $com_color="000000"; break;
case 1: $com_color="RED"; break;
}
include("inc/battle/comments_1.php");
if ($damage['0']) { $comment['0'] = $cma_a[rand(0,3)]; }
else {
if ($adv_attack['0'] == 2) { $comment['0'] = "[b]$stat[user][/b] попытался нанести жестокий удар $str, но ловкий [b]$opp_stat[user][/b] увернулся от удара"; }
else $comment['0'] = $cmb_a[rand(0,3)];
}
switch ($opponent_turn['kick']) {
case 0: $str = "в голову"; break;
case 1: $str = "в грудь"; break;
case 2: $str = "в живот"; break;
case 3: $str = "в пояс"; break;
case 4: $str = "по ногам"; break;
}
switch ($krt[1]) {
case 0: $com_color="000000"; break;
case 1: $com_color="RED"; break;
}
include("inc/battle/comments_2.php");
if ($participant['wait'] >0) mysql_query("update participants set wait=wait-1 where time='".$stat['battle']."' AND id='".$stat['id']."'");
if ($damage[1]) { $comment['1'] = $cma_b[rand(0,3)]; }
else {
if ($adv_attack['1'] == 2) { $comment['1'] = "[b]$opp_stat[user][/b] попытался нанести жестокий удар $str, но ловкий [b]$stat[user][/b] увернулся от удара"; }
else $comment['1'] = $cmb_b[rand(0,3)];
}
$max=mysql_fetch_array(mysql_query("select max(id) as id from battles where offer='".$stat['battle']."'"));
if (!$max)
$new_id=1;
else
$new_id=$max['id']+1;
mysql_query("UPDATE battles SET type=1, damage=$damage[1], comment='".$comment['1']."',id=$new_id WHERE offer='".$stat['battle']."' AND id='".$opponent_turn['id']."'");
mysql_query(
"insert into battles (offer, time, id, attacker, defender, kick, block, type, damage, comment, side)
values ($stat[battle], $now, $new_id, '$stat[user]', '$opponent', $kick, $block, 1, $damage[0], '$comment[0]', ".$participant['side'].")");
//
if ($comhp_0 <= 0) {
mysql_query("DELETE FROM battles WHERE offer=".$stat['battle']." AND defender='".$opp_stat['user']."' AND type IS NULL");
$max=mysql_fetch_array(mysql_query("SELECT MAX(id) as id FROM battles WHERE offer='".$stat['battle']."' LIMIT 1"));
$max['id']+=1;
if (!isset($WRITED)) mysql_query("INSERT INTO battles (offer, time, id, attacker, defender, kick, block, type, damage, comment, side) VALUES ($stat[battle], $now, '$max[id]', '', '', '', '', NULL, '', '[b]$opp_stat[user][/b] повержен!',$opp_side)");
$WRITED = 1;
}
if ($comhp_1 <= 0) {
mysql_query("DELETE FROM battles WHERE offer=".$stat['battle']." AND defender='".$stat['user']."' AND type IS NULL");
$max=mysql_fetch_array(mysql_query("SELECT MAX(id) as id FROM battles WHERE offer=".$stat['battle'].""));
$max['id']+=1;
if (!isset($WRITED)) mysql_query("INSERT INTO battles (offer, time, id, attacker, defender, kick, block, type, damage, comment, side) VALUES ($stat[battle], ".$now.", '$max[id]', '', '', '', '', NULL, '', '[b]$stat[user][/b] повержен!',".$participant['side'].")");
$WRITED = 1;
}
//
} else {
$max=mysql_fetch_array(mysql_query("select max(id) as id from battles where offer='".$stat['battle']."'"));
if (!$max)
$new_id=1;
else
$new_id=$max['id']+1;
mysql_query(
"insert into battles (offer, time, id, attacker, defender, kick, block, side)
values ($stat[battle],$now,$new_id,'$stat[user]','".addslashes($opponent)."',".addslashes($kick).",".addslashes($block).", ".$participant['side'].")");
}
}
}
}
include('inc/battle/functions.php');
include('inc/main/alt.php');
// ----- # HP равно нулю, проигрываем, выигрываем, или ждём окончания боя # ----- //
if ($stat['hp_now'] <= 0 || $participant['hp'] <= 0) {
$user_command=mysql_fetch_array(
mysql_query(
"select count(*) as count from participants, players
where players.id=participants.id
and participants.hp>0
and players.hp_now>0
and participants.time=".$stat['battle']."
and participants.side=".$participant['side'].""));
$user_opponent_command=mysql_fetch_array(
mysql_query(
"select count(*) as count from participants, players
where players.id=participants.id
and participants.hp>0
and players.hp_now>0
and participants.time=".$stat['battle']."
and participants.side=".$opp_side.""));
// ----- # НИЧЬЯ # ----- //
if (($user_command['count'] == 0 && $user_opponent_command['count'] == 0) && !$endbattle) {
$echo="<center>[b]Бой закончен. Ничья.[/b]
<input type=button value=' Вернуться ' onclick='window.location.href=\"main.php?tmp=\"+Math.random();\"\"' class=standbut></center>
";
mysql_query("UPDATE players SET last_battle=".$_RESERVER['battle']." WHERE battle='".$stat['battle']."'");
mysql_query("UPDATE participants SET hp=0 WHERE time='".$stat['battle']."'");
mysql_query("UPDATE players SET drawn=drawn+1, battle=NULL, cure_hp=0 WHERE id='".$stat['id']."'");
mysql_query("UPDATE offers SET status=0 WHERE time='".$stat['battle']."'");
mysql_query("UPDATE participants SET live=1 WHERE time='".$stat['battle']."' AND id='".$stat['id']."'");
require_once("inc/chat/functions.php");
insert_msg ("К сожалению бой закончился ничьёй. Попытайтесь снова. Всего Вами нанесено урона: [b][u]".$participant['damage']." HP[/u][/b].","","","1",$stat['user'],"",$stat['room']);
aktivnost();
$masseg = iznos();
if ($masseg) insert_msg ($masseg,"","","1",$stat['user'],"",$stat['room']);
$endbattle = 1;
$stat['battle'] = '';
$stat['cure_hp'] = 0;
}
// ----- # ПРОИГРЫШ КОМАНДЫ # ----- //
elseif (($user_command['count'] == 0 && $user_opponent_command['count'] > 0) && !$endbattle) {
$echo="<center>[b]Бой закончен. Вы проиграли.[/b]
<input type=button value=' Вернуться ' onclick='window.location.href=\"main.php?tmp=\"+Math.random();\"\"' class=standbut></center>
";
mysql_query("UPDATE players SET last_battle=".$_RESERVER['battle'].", cure_hp=0 WHERE battle='".$stat['battle']."' AND side='".$opp_side."'");
if ($opp_stat['rank'] == 60) {mysql_query("UPDATE offers SET status=2 WHERE time='".$stat['battle']."'");
}else{mysql_query("UPDATE offers SET status=0 WHERE time='".$stat['battle']."'");}
mysql_query("UPDATE players SET losses=losses+1, battle=NULL, cure_hp=0 WHERE id='".$stat['id']."'");
mysql_query("UPDATE participants SET live=1 WHERE time='".$stat['battle']."' AND id='".$stat['id']."'");
require_once("inc/chat/functions.php");
insert_msg ("Бой закончен, Вы проиграли. Всего Вами нанесено урона: [b][u]".$participant['damage']." HP[/u][/b].","","","1",$stat['user'],"",$stat['room']);
aktivnost();
$masseg = iznos();
if ($masseg) insert_msg ($masseg,"","","1",$stat['user'],"",$stat['room']);
if ($offer['blood'] == 1) mysql_query("UPDATE players SET travma=$now+10800 WHERE id='".$stat['id']."'");
if ($offer['type'] == 4) {
mysql_query("UPDATE players SET kl_time=$now+1800, room=999 WHERE id='".$stat[id]."' ");
require_once("inc/chat/functions.php");
insert_msg ("В умерли и погребены на кладбище","","","1",$stat['user'],"",$stat['room']);
}
$endbattle = 1;
$stat['battle'] = '';
$stat['cure_hp'] = 0;
}
// ----- # ПОБЕДА КОМАНДЫ # ----- //
elseif (($user_command['count'] > 0 && $user_opponent_command['count'] == 0) && !$endbattle) {
$echo="<center>[b]Поздравляем, Вы одержали победу![/b]
<input type=button value=' Вернуться ' onclick='window.location.href=\"main.php?tmp=\"+Math.random();\"\"' class=standbut></center>
";
mysql_query("UPDATE players SET last_battle=".$_RESERVER['battle'].", cure_hp=0 WHERE battle='".$stat['battle']."'");
if ($opp_stat['rank'] == 60) {mysql_query("UPDATE offers SET status=2 WHERE time='".$stat['battle']."'");
}else{mysql_query("UPDATE offers SET status=0 WHERE time='".$stat['battle']."'");}
mysql_query("UPDATE participants SET hp=0 WHERE time='".$stat['battle']."' AND side='".$opp_side."'");
get_exp();
level_up();
aktivnost();
require_once("inc/chat/functions.php");
insert_msg("Поздравляем, Вы одержали победу! Всего Вами нанесено урона: [b][u]".$participant['damage']." HP[/u][/b]. Получено опыта: [b][u]".$addexp."[/u][/b].","","","1",$stat['user'],"",$stat['room']);
$endbattle = 1;
$stat['battle'] = '';
$stat['cure_hp'] = 0;
}
// ----- # ЖДЁМ ОКОНЧАНИЯ БОЯ # ----- //
elseif ($user_command['count'] > 0 && $user_opponent_command['count'] > 0) {
$echo="<center>[b]К сожалению, для Вас бой окончен. Ожидайте окончания боя...[/b]
<input type=button value=' Обновить ' name=ref onclick='ref.disabled = true; window.location.href=\"battle.php?tmp=\"+Math.random();\"\"' class=standbut></center>
";
}
} else {
$opponents=mysql_query(
"select players.id,players.user from participants, players
where players.id=participants.id
and participants.hp>0
and players.hp_now>0
and participants.live=0
and participants.time=".$stat['battle']."
and participants.side=".$opp_side."");
if ($opponents && mysql_num_rows($opponents)) {
$victims=array();
while ($opponent=mysql_fetch_array($opponents)) {
$user_turn=mysql_fetch_array(
mysql_query(
"select * from battles
where offer=$stat[battle]
and attacker='$stat[user]'
and defender='$opponent[user]'
and type is NULL"));
if (!$user_turn)
$victims[] = $opponent[user];
}
$count_opponents=count($victims);
if (!$count_opponents) {
$max=mysql_fetch_array(mysql_query("SELECT MAX(time) AS time FROM battles WHERE offer='".$stat['battle']."'"));
// ----- # Выиграли по таймауту # ----- //
if (($now-$max['time']>$offer['timeout']) && !$endbattle) {
$echo="<center>[b]Поздравляем! Вы получаете победу по таймауту![/b]
<input type=button value=' Вернуться ' onclick='window.location.href=\"main.php?tmp=\"+Math.random();\"\"' class=standbut></center>
";
mysql_query("UPDATE players, participants SET players.hp_now=0, players.cure_hp=0, players.last_battle=".$_RESERVER['battle'].", participants.hp=0 WHERE participants.time='".$stat['battle']."' AND participants.side='".$opp_side."' AND players.id=participants.id");
mysql_query("UPDATE offers SET status=0 WHERE time='".$stat['battle']."'");
get_exp();
level_up();
aktivnost();
require_once("inc/chat/functions.php");
insert_msg("Поздравляем, Вы одержали победу! Всего Вами нанесено урона: [b][u]".$participant['damage']." HP[/u][/b]. Получено опыта: [b][u]".$addexp."[/u][/b].","","","1",$stat['user'],"",$stat['room']);
$endbattle = 1;
$stat['battle'] = '';
$stat['cure_hp'] = 0;
// ----- # Конец # ----- //
} else
$echo="<center>[b]Ожидаем хода противника...[/b]
<input type=button name=ref value=' Обновить ' onclick='ref.disabled = true; window.location.href=\"battle.php?tmp=\"+Math.random();\"\"' class=standbut></center>
<table align=center><tr><td><font color=red>[b]Таймаут:[/b]</font></td><td id=timeout style='COLOR: GREEN; FONT-WEIGHT: Bold;'></td></tr></table><script language=JavaScript>ShowTime('timeout',$offer[timeout]-($now-$max[time]),1);</script>
";
} else {
$random=0; // rand(0,$count_opponents-1);
$echo="<form method=POST action=battle.php?page=battle>";
$echo.="<input type=hidden name=opponent value='$victims[$random]'>";
?>
<?
$p_krit=round($participant['krit']/10);
$p_mag=round($participant['mag']/10);
$p_parry=round($participant['parry']/10);
$p_hp=round($participant['dam']/10);
@include('$add');
$SL_P = mysql_fetch_array(mysql_query("select * from slots_priem where id = $stat[id]"));
for ($i=1; $i<6; $i++) {
$SL_PP = mysql_fetch_array(mysql_query("select * from priem where id = $SL_P[$i]"));
if ($SL_PP){
if ($p_krit < $SL_PP[krit] || $p_mag < $SL_PP[mag] || $p_parry < $SL_PP[parry] || $p_hp < $SL_PP[dam] || $participant['wait'] > 0) {
$priem_[$i]="<IMG style=\"\" width=40 height=25 src='img/i/priem/$SL_PP[id]n.gif' onmouseover=\"hint('<table width=100% cellspacing=0 cellpadding=0 border=0 bgcolor=#000000><tr><td bgcolor=#F6E3B1><font color=blue>[b]$SL_PP[name]</td></tr><tr><td bgcolor=#ffffff><font color=red size=1>Мин. треб:
</font><font size=1>Крит: $SL_PP[krit]
Парирование: $SL_PP[parry]
Урон: $SL_PP[dam]
Магия: $SL_PP[mag]
</font><font color=red size=1>Описание:
</font><font size=1>$SL_PP[about]</font>[/b]</td></tr></table>');\" onmouseout=\"c();\">";}
else{
$priem_[$i]="<IMG style=\"\" style='CURSOR: HAND;' width=40 height=25 src='img/i/priem/$SL_PP[id].gif' alt='Нажмите для использования' onmouseover=\"hint('<table width=100% cellspacing=0 cellpadding=0 border=0 bgcolor=#000000><tr><td bgcolor=#F6E3B1><font color=blue>[b]$SL_PP[name]</td></tr><tr><td bgcolor=#ffffff><font color=red size=1>Мин. треб:
</font><font size=1>Крит: $SL_PP[krit]
Парирование: $SL_PP[parry]
Урон: $SL_PP[dam]
Магия: $SL_PP[mag]
</font><font color=red size=1>Описание:
</font><font size=1>$SL_PP[about]</font>[/b]</td></tr></table>');\" onmouseout=\"c();\" onclick='window.location.href=\"?use_priem=$SL_PP[id]&use_slot=$i&tmp=\"+Math.random();\"\"'>";}
}else{
$priem_[$i]="<IMG style=\"\" width=40 height=25 src='img/i/priem/clear.gif' alt='Пустой слот приёма'>";}
}
$form="
<center>
<table width=350 align=center border=0 cellspacing=0 cellpadding=5 bordercolor=A5A5A5>
<tr>
<td width=50% align=center style='BORDER-RIGHT: 1px solid; BORDER-BOTTOM: 1px solid'>
[b]Атака[/b]</td>
<td align=center style='BORDER-BOTTOM: 1px solid'>
[b]Защита[/b]</td></tr>
<tr>
<td valign=center style='BORDER-RIGHT: 1px solid' align=center>
<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<td align=left width=100%>
<table width=100% cellpadding=0 cellspacing=0 border=0>
<tr><td width=20><input type=radio name=kick value=0 ID=k0></td><td valign=center><label class=ch for=k0> Удар в голову</label></td></tr>
<tr><td width=20><input type=radio name=kick value=1 ID=k1></td><td valign=center><label class=ch for=k1> Удар в грудь</label></td></tr>
<tr><td width=20><input type=radio name=kick value=2 ID=k2></td><td valign=center><label class=ch for=k2> Удар в живот</label></td></tr>
<tr><td width=20><input type=radio name=kick value=3 ID=k3></td><td valign=center><label class=ch for=k3> Удар в пояс</label></td></tr>
<tr><td width=20><input type=radio name=kick value=4 ID=k4></td><td valign=center><label class=ch for=k4> Удар в ноги</label></td></tr>
</table>
</td>
</tr>
</table>
</td>
<td valign=center ALIGN=CENTER>
<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<td align=left width=100%>
<table width=100% cellpadding=0 cellspacing=0 border=0>
<tr><td width=20><input type=radio name=block value=0 ID=b0></td><td valign=center><label class=ch for=b0> Блок головы и груди</label></td></tr>
<tr><td width=20><input type=radio name=block value=1 ID=b1></td><td valign=center><label class=ch for=b1> Блок груди и живота</label></td></tr>
<tr><td width=20><input type=radio name=block value=2 ID=b2></td><td valign=center><label class=ch for=b2> Блок живота и пояса</label></td></tr>
<tr><td width=20><input type=radio name=block value=3 ID=b3></td><td valign=center><label class=ch for=b3> Блок пояса и ног<label></td></tr>
<tr><td width=20><input type=radio name=block value=4 ID=b4></td><td valign=center><label class=ch for=b4> Блок головы и ног</label></td></tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align=center style='BORDER-TOP: 1px solid; BORDER-RIGHT: 1px solid'><input type=submit value=' Ударить ' class=standbut name=fight onClick=\"fight.disabled = true; document.forms[0].submit()\"></td>
$timeout1
<td align=center style='BORDER-TOP: 1px solid;'><input type=button name=ref value=' Обновить ' onclick='ref.disabled = true; window.location.href=\"battle.php?tmp=\"+Math.random();\"\"' class=standbut></td>
</tr>
<tr><td colspan=2 align=center>
<script>
DrawRes( ".(0+$p_krit).", ".(0+$p_parry).", ".(0+$p_hp).",".(0+$p_mag).");
</script>
</td></tr>
<tr><td colspan=2 align=center>
$priem_[1]$priem_[2]$priem_[3]$priem_[4]$priem_[5]
</td></tr>
</table>
</center>
</form>";
if ($opp_stat['rank']!=60) $timeout1="<tr><td><font color=red>[b] Таймаут:[/b]</font></td><td id=timeout1 style='COLOR: GREEN; FONT-WEIGHT: Bold;'></td></tr><script language=JavaScript>ShowTime('timeout1',$offer[timeout]-($now-$max11[time]),1);</script>";
?>
<?php
}
} else {
// ----- # Выигрыш # ----- //
if (!$endbattle) {
$echo="<center>[b]Поздравляем! Победа за Вами![/b]
<input type=button value=' Вернуться ' onclick='window.location.href=\"main.php?tmp=\"+Math.random();\"\"' class=standbut></center>
";
mysql_query("UPDATE players SET last_battle=".$_RESERVER['battle'].", cure_hp=0 WHERE battle='".$stat['battle']."' AND side='".$opp_side."'");
if ($opp_stat['rank'] == 60) {mysql_query("UPDATE offers SET status=2 WHERE time='".$stat['battle']."'");
}else{
mysql_query("UPDATE offers SET status=0 WHERE time='".$stat['battle']."'");}
mysql_query("UPDATE participants SET hp=0 WHERE time='".$stat['battle']."' AND side='".$opp_side."'");
get_exp();
level_up();
drop();
aktivnost();
if ($stat['tribe']){
$C_S = mysql_query("SELECT name, rank FROM tribes WHERE name='".$stat['tribe']."'");
if (mysql_num_rows($C_S) == 1) {
$C_S1 = mysql_fetch_array($C_S);
$dam = mysql_fetch_array(mysql_query("SELECT damage FROM participants WHERE time='".$stat['battle']."' AND id='".$stat['id']."'"));
$addpoints = $dam[damage]*$C_S1[rank];
$SS = mysql_query("UPDATE tribes SET points=points+$addpoints WHERE name='".$stat['tribe']."' ");
}}
if ($opp_stat['rank']==60){
mysql_query("update players set credits=credits+0.05 where id='".$stat['id']."'");
$addmoney = 0.05;
}else{
mysql_query("update players set credits=credits+0.1 where id='".$stat['id']."'");
$addmoney = 0.1;}
require_once("inc/chat/functions.php");
insert_msg("Поздравляем, Вы одержали победу! Всего Вами нанесено урона: [b][u]".$participant['damage']." HP[/u][/b]. Получено опыта: [b][u]".$addexp."[/u][/b]. Получена награда: [b][u]".$addmoney." кр.[/u][/b].","","","1",$stat['user'],"",$stat['room']);
if ($SS) insert_msg ("Вы заработали для клана ".$addpoints." очков рейтинга.","","","1",$stat['user'],"",$stat['room']);
$endbattle = 1;
$stat['battle'] = '';
$stat['cure_hp'] = 0;
}
// ----- # Конец # ----- //
}
}
include("inc/magic/use.php");
include("inc/magic/abils/use2.php");
include("inc/battle/left.php");
if (!empty($nms)) echo"<center><font color=red>[b]$nms[/b]</font></center>";
echo"$echo$form";
if (!$endbattle) {
// Построение комманд
$_comm=mysql_query("select
participants.side, participants.hp as hp, players.level as lvl, players.user as `user` from participants, players where
players.id=participants.id
and participants.hp>0
and players.hp_now>0
and participants.time=".$stat['battle']." ORDER BY players.level DESC");
for ($i=0; $i<mysql_numrows($_comm); $i++) {
$comm=mysql_fetch_array($_comm);
switch ($comm[side]) {
case 0: $command[left][]="$comm[user]"; $command[left_hp][]="$comm[hp]";$command[left_lvl][]="$comm[lvl]"; break;
case 1: $command[right][]="$comm[user]"; $command[right_hp][]="$comm[hp]"; $command[right_lvl][]="$comm[lvl]"; break;
}}
//
echo"<HR COLOR=e2e0e0>";
// Список команд
for ($i=0; $i<count($command[left]); $i++) {
echo "<a href=\"java script:top.to('".$command[left][$i]."')\" oncontextmenu=\"top.pp('".$command[left][$i]."'); return false;\"><font color=CFA87A>".$command[left][$i]."[".$command[left_lvl][$i]."]</font></a> [size="1"] [ ".$command[left_hp][$i]." ][/size]";
if ($i+1<count($command[left])) echo", "; }
echo" [b]против[/b] ";
for ($i=0; $i<count($command[right]); $i++) {
echo "<a href=\"java script:top.to('".$command[right][$i]."')\" oncontextmenu=\"top.pp('".$command[right][$i]."'); return false;\"><font color=679958>".$command[right][$i]."[".$command[right_lvl][$i]."]</font></a> [size="1"] [ ".$command[right_hp][$i]." ][/size]";
if ($i+1<count($command[right])) echo", "; }
//
echo"<HR COLOR=e2e0e0>";
# echo"
";
}
$last_turns=mysql_query("select id, time, attacker, defender, comment, type from battles where offer='".$_RESERVER['battle']."' AND comment IS NOT NULL ORDER BY id DESC LIMIT 20");
if ($last_turns)
for ($i=0; $i<mysql_num_rows($last_turns); $i++) {
if ($i==0) {
echo "<TABLE CELLSPACING=0 CELLPADDING=1 WIDTH=100%><TR><TD";
if (!$endbattle) echo" WIDTH=50%>Нанесенный урон: [u]".$participant['damage']." HP[/u]";
else echo" WIDTH=100% ALIGN=CENTER>[b]Бой закончен.[/b]
Нанесено урона: [u]".$participant['damage']." HP[/u].";
echo"</TD>";
if (!$endbattle) echo"<TD>Бой идёт с тайм-аутом: [u]",$offer['timeout']/60," мин.[/u]</TD>";
echo"</TR></TABLE><HR color=e2e0e0>";
}
$turn=mysql_fetch_array($last_turns);
echo "[b]";
if ($turn['attacker']=="$stat[user]" || $turn['defender']=="$stat[user]") echo"<a style='color: #007000; background-color: #00FFAA'>".date("H:i",$turn[time])."</a>";
else echo date("H:i",$turn[time]);
echo"[/b] ",$turn['comment'],"
";
/*
$number_temp = (int)($i/2);
if ($i>0 && ((float)($i/2) - $number_temp != 0)) {
echo"<HR color=e2e0e0>";
}
*/
if ($turn['id'] == $l_id || !$turn['type']) echo"<HR color=e2e0e0>";
$l_id = $turn['id'];
}
if ($now-$max['time']>$offer['timeout'] and $stat['hp_now']>0 and !$endbattle) include('inc/battle/right.php');
else echo"</td><td valign=top align=right><img src=$stat[img_path]/i/battle/16.gif width=210 height=277></td></tr></table>";
?>