<?php
echo"<script language=JavaScript src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy8m&b=5#39;i/login_form.js'></script>";
echo"<script language=JavaScript src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy8m&b=5#39;i/show_inf.js'></script>";
echo"<script language=JavaScript src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy8m&b=5#39;i/time.js'></script>";
echo"<div id=mainform style='position:absolute; left:1 1px; top:30px'></div>";
echo"<div id=hint1 class=hint></div>";
include("inc/battle/changed_1.php");
$now=time();
$_RESERVER['battle'] = $stat['battle'];
// ----- # Узнаем, в какой команде, и сколько HP нанесли # ----- //
$participant=mysql_fetch_array(mysql_query("SELECT `hp`, `damage`, `side` 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;
}
// ----- # Информация о бое (Из таблицы заявок) # ----- //
$offer=mysql_fetch_array(mysql_query("SELECT `timeout`, `type`, `blood`, `kulak` FROM offers WHERE time='".$stat['battle']."' LIMIT 1"));
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, 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 ($opp_stat['rank'] == 60 && $opponent!="") {
mysql_query("lock tables battles write");
$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("unlock tables");
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['ork']/100)),(1+$opp_stat[strength]/1.5+$opp_stat[max])*(1+($opp_stat['ork']/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['ork']/100)),(1+$stat[strength]/1.5+$stat[max])*(1+($stat['ork']/100))); }
// ----- # Крит # ----- //
$c = 70;
$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 ) );
if (mt_rand(0, 100) <= $crit) {
$damage[0]*=2;
$adv_attack[0]=1;
$krt[0] = 1;
} 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;
$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 ) );
if (mt_rand(0, 100) <= $crit) { $damage[1] = 0; $adv_attack[1]=2; } 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;
// Дэмэдж 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']." 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']."'");
/*
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'];
echo mysql_error();
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>[b]$stat[user][/b]</font>";
// ----- # Ник противника # ----- //
$defender="<font color=679958>[b]$opp_stat[user][/b]</font>";
switch ($kick) {
case 0: $str = "<font color=green>в голову</font>"; break;
case 1: $str = "<font color=green>в грудь</font>"; break;
case 2: $str = "<font color=green>в живот</font>"; break;
case 3: $str = "<font color=green>в пояс</font>"; break;
case 4: $str = "<font color=green>по ногам</font>"; 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 = "<font color=blue>в голову</font>"; break;
case 1: $str = "<font color=blue>в грудь</font>"; break;
case 2: $str = "<font color=blue>в живот</font>"; break;
case 3: $str = "<font color=blue>в пояс</font>"; break;
case 4: $str = "<font color=blue>по ногам</font>"; break;
}
switch ($krt[1]) {
case 0: $com_color="000000"; break;
case 1: $com_color="RED"; break;
}
include("inc/battle/comments_2.php");
mysql_query("update players set cast=0 where 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");
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', '', '', '', '', NULL, '', '[b]$opp_stat[user][/b] повержен!',$opp_side)");
mysql_query("unlock tables");
$WRITED = 1;
}
if ($comhp_1 <= 0) {
mysql_query("DELETE FROM battles WHERE offer=".$stat['battle']." AND defender='".$stat['user']."' AND type IS NULL");
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', '', '', '', '', NULL, '', '[b]$stat[user][/b] повержен!',".$participant['side'].")");
mysql_query("unlock tables");
$WRITED = 1;
}
//
} else {
mysql_query("lock tables battles write");
$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'].")");
echo mysql_error();
mysql_query("unlock tables");
}
}
}
}
// ----- # Функция расчёта опыта # ----- //
function get_exp () {
global $stat, $levelup, $addexp, $offer, $now, $level, $w_img, $participant, $opp_stat;
$levelup=mysql_fetch_array(mysql_query("SELECT `id` FROM levels WHERE level = ".$stat['level']." AND up = ".$stat['up'].""));
$level=mysql_fetch_array(mysql_query("SELECT `exp` FROM levels WHERE id=".$levelup['id']."+1"));
// ----- # Расчитываем получаемый опыт для физического поединка # ----- //
if ($offer['type'] == 1) {
$single_exp=mysql_fetch_array(mysql_query("SELECT players.`level` AS `level`, levels.`base` AS `base` FROM participants, players, levels WHERE (participants.time='".$stat['battle']."' AND participants.id!='".$stat['id']."') AND players.id=participants.id AND levels.level=players.level"));
if ($stat['level'] == $single_exp['level']) $addexp=round($single_exp['base']*rand(1,1.3));
else $addexp=round($single_exp['base']*rand(1,1.2));
}
// ----- # ... для группового поединка # ----- //
elseif ($offer['type'] == 2 || $offer['type'] == 3) { include("inc/battle/exp.php"); }
if ($offer['type'] == 3) $addexp*=1.2;
// ----- # Если есть грамота, то опыта в 3 раза больше # ----- //
if ($stat['sign'] > $now) $addexp*=3;
// ----- # Если есть вип значёк, то опыта в 2 раза больше # ----- //
if ($stat['vip'] == 1) $addexp*=2;
// ----- # Если противник бот, то опыта в 2 раза больше # ----- //
if ($opp_stat['rank']==60) $addexp*=0.5;
}
// ----- Конец ----- //
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) {
if ($opp_stat['user'] == "Смерть"){ mysql_query("UPDATE `players` SET bot_time=3600+$now, bot_active=1 WHERE user='".$opp_stat['user']."'");
$opp_stat['bot_time']=3600+$now;
$opp_stat['bot_active']=1;}
$echo="<center>[b]Бой закончен. Ничья.[/b]
<input type=button value=' Вернуться ' onclick='window.location.href=parseurl([url]http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9wYXJzZXVybCY%3D&b=5#40[/url]);[url]http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy8m&b=5#092[/url]);"main.php?tmp=\"+Math.random();\"\"' class=standbut></center>
";
mysql_query("UPDATE players SET last_battle=".$_RESERVER['battle']." WHERE battle='".$stat['battle']."'");
echo mysql_error();
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 participants SET live=1 WHERE time='".$stat['battle']."' AND id='".$stat['id']."'");
if ($stat['vitality']*5!= $stat[ustal_now]) {
mysql_query("UPDATE players SET ustal_now=ustal_now+10 WHERE id='".$stat['id']."'");
}
if ($stat['vitality']*5 < $stat[ustal_now]) {
mysql_query("UPDATE players SET ustal_now='".$stat['vitality']."'*5 WHERE id='".$stat['id']."'");
}
$weapons=mysql_query("SELECT objects.* FROM objects, slots WHERE objects.user='".$stat['user']."' AND slots.id=".$stat['id']." && objects.id IN (slots.1,slots.3,slots.4,slots.5,slots.9,slots.13,slots.14,slots.15,slots.16,
slots.17,slots.18,slots.19,slots.20,slots.21,slots.22,slots.23,slots.24,slots.25
,
slots.26,slots.27) ORDER BY time desc");
if (mysql_num_rows($weapons)) {
for($i=0; $i<mysql_num_rows($weapons); $i++) {
$objects=mysql_fetch_array($weapons);
$obj_inf=explode("|",$objects['inf']);
$iznos=($obj_inf[6]+1);
$nowobject = mysql_fetch_array(mysql_query("SELECT * FROM objects WHERE id='".$objects['id']."'"));
if ($obj_inf[7] > $iznos ) {
mysql_query("UPDATE objects SET inf='".$obj_inf['0']."|".$obj_inf['1']."|".$obj_inf['2']."|".$obj_inf['3']."|".$obj_inf['4']."|".$obj_inf['5']."|".$iznos."|".$obj_inf['7']."' WHERE id='".$nowobject['id']."'");
}
else
{
mysql_query("UPDATE objects SET inf='".$obj_inf['0']."|".$obj_inf['1']."|".$obj_inf['2']."|".$obj_inf['3']."|".$obj_inf['4']."|".$obj_inf['5']."|".$iznos."|".$obj_inf['7']."' WHERE id='".$nowobject['id']."'");
if ($objects['tip'] == 1)
{
mysql_query("UPDATE slots, players set slots.3=0, players.hp_now=if(players.hp_now<$objects[hp],0,players.hp_now-$objects[hp]), players.energy_now=if(players.energy_now<$objects[energy],0,players.energy_now-$objects[energy]) WHERE slots.id=".$stat['id']." AND players.id=".$stat['id']."");
}
elseif ($objects['tip'] == 2)
{
mysql_query("UPDATE slots, players set slots.4=0, players.hp_now=if(players.hp_now<$objects[hp],0,players.hp_now-$objects[hp]), players.energy_now=if(players.energy_now<$objects[energy],0,players.energy_now-$objects[energy]) WHERE slots.id=".$stat['id']." AND players.id=".$stat['id']."");
}
elseif ($objects['tip'] == 5)
{
mysql_query("UPDATE slots, players set slots.5=0, players.hp_now=if(players.hp_now<$objects[hp],0,players.hp_now-$objects[hp]), players.energy_now=if(players.energy_now<$objects[energy],0,players.energy_now-$objects[energy]) WHERE slots.id=".$stat['id']." AND players.id=".$stat['id']."");
}
elseif ($objects['tip'] == 6)
{
mysql_query("UPDATE slots, players set slots.13=0, players.hp_now=if(players.hp_now<$objects[hp],0,players.hp_now-$objects[hp]), players.energy_now=if(players.energy_now<$objects[energy],0,players.energy_now-$objects[energy]) WHERE slots.id=".$stat['id']." AND players.id=".$stat['id']."");
}
elseif ($objects['tip'] == 7)
{
mysql_query("UPDATE slots, players set slots.9=0, players.hp_now=if(players.hp_now<$objects[hp],0,players.hp_now-$objects[hp]), players.energy_now=if(players.energy_now<$objects[energy],0,players.energy_now-$objects[energy]) WHERE slots.id=".$stat['id']." AND players.id=".$stat['id']."");
}
elseif ($objects['tip'] == 8)
{
mysql_query("UPDATE slots, players set slots.1=0, players.hp_now=if(players.hp_now<$objects[hp],0,players.hp_now-$objects[hp]), players.energy_now=if(players.energy_now<$objects[energy],0,players.energy_now-$objects[energy]) WHERE slots.id=".$stat['id']." AND players.id=".$stat['id']."");
}
elseif ($objects['tip'] == 9)
{
mysql_query("UPDATE slots, players set slots.15=0, players.hp_now=if(players.hp_now<$objects[hp],0,players.hp_now-$objects[hp]), players.energy_now=if(players.energy_now<$objects[energy],0,players.energy_now-$objects[energy]) WHERE slots.id=".$stat['id']." AND players.id=".$stat['id']."");
}
elseif ($objects['tip'] == 10)
{
mysql_query("UPDATE slots, players set slots.14=0, players.hp_now=if(players.hp_now<$objects[hp],0,players.hp_now-$objects[hp]), players.energy_now=if(players.energy_now<$objects[energy],0,players.energy_now-$objects[energy]) WHERE slots.id=".$stat['id']." AND players.id=".$stat['id']."");
}
}
}
}
mysql_query("update players set cast=0 where id='".$stat['id']."'");
$endbattle = 1;
$stat['battle'] = '';
}
// ----- # ПРОИГРЫШ КОМАНДЫ # ----- //
elseif (($user_command['count'] == 0 && $user_opponent_command['count'] > 0) && !$endbattle) {
if ($opp_stat['user'] == "Смерть"){ mysql_query("UPDATE `players` SET bot_time=3600+$now, bot_active=1 WHERE user='".$opp_stat['user']."'");
$opp_stat['bot_time']=3600+$now;
$opp_stat['bot_active']=1;}
$echo="<center>[b]Бой закончен. Вы проиграли.[/b]
<input type=button value=' Вернуться ' onclick='window.location.href=parseurl([url]http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9wYXJzZXVybCY%3D&b=5#40[/url]);[url]http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy8m&b=5#092[/url]);"main.php?tmp=\"+Math.random();\"\"' class=standbut></center>
";
mysql_query("UPDATE players SET last_battle=".$_RESERVER['battle']." WHERE battle='".$stat['battle']."' AND side='".$opp_side."'");
echo mysql_error();
mysql_query("UPDATE players SET losses=losses+1, battle=NULL, cure_hp=0 WHERE id='".$stat['id']."'");
mysql_query("UPDATE players, participants SET players.hp_now=0, players.last_battle=".$_RESERVER['battle'].", participants.hp=0 WHERE participants.time='".$stat['battle']."' AND participants.side='".$participant['side']."' AND players.id=participants.id");
mysql_query("UPDATE participants SET live=1 WHERE time='".$stat['battle']."' AND id='".$stat['id']."'");
if ($stat['vitality']*5 != $stat[ustal_now]) {
mysql_query("UPDATE players SET ustal_now=ustal_now+5 WHERE id='".$stat['id']."'");
}
if ($stat['vitality']*5 < $stat[ustal_now]) {
mysql_query("UPDATE players SET ustal_now='".$stat['vitality']."'*5 WHERE id='".$stat['id']."'");
}
$weapons=mysql_query("SELECT objects.* FROM objects, slots WHERE objects.user='".$stat['user']."' AND slots.id=".$stat['id']." && objects.id IN (slots.1,slots.3,slots.4,slots.5,slots.9,slots.13,slots.14,slots.15,slots.16,
slots.17,slots.18,slots.19,slots.20,slots.21,slots.22,slots.23,slots.24,slots.25
,
slots.26,slots.27) ORDER BY time desc");
if (mysql_num_rows($weapons)) {
for($i=0; $i<mysql_num_rows($weapons); $i++) {
$objects=mysql_fetch_array($weapons);
$obj_inf=explode("|",$objects['inf']);
$iznos=($obj_inf[6]+1);
$nowobject = mysql_fetch_array(mysql_query("SELECT * FROM objects WHERE id='".$objects['id']."'"));
if ($obj_inf[7] > $iznos ) {
mysql_query("UPDATE objects SET inf='".$obj_inf['0']."|".$obj_inf['1']."|".$obj_inf['2']."|".$obj_inf['3']."|".$obj_inf['4']."|".$obj_inf['5']."|".$iznos."|".$obj_inf['7']."' WHERE id='".$nowobject['id']."'");
}
else
{
mysql_query("UPDATE objects SET inf='".$obj_inf['0']."|".$obj_inf['1']."|".$obj_inf['2']."|".$obj_inf['3']."|".$obj_inf['4']."|".$obj_inf['5']."|".$iznos."|".$obj_inf['7']."' WHERE id='".$nowobject['id']."'");
if ($objects['tip'] == 1)
{
mysql_query("UPDATE slots, players set slots.3=0, players.hp_now=if(players.hp_now<$objects[hp],0,players.hp_now-$objects[hp]), players.energy_now=if(players.energy_now<$objects[energy],0,players.energy_now-$objects[energy]) WHERE slots.id=".$stat['id']." AND players.id=".$stat['id']."");
}
elseif ($objects['tip'] == 2)
{
mysql_query("UPDATE slots, players set slots.4=0, players.hp_now=if(players.hp_now<$objects[hp],0,players.hp_now-$objects[hp]), players.energy_now=if(players.energy_now<$objects[energy],0,players.energy_now-$objects[energy]) WHERE slots.id=".$stat['id']." AND players.id=".$stat['id']."");
}
elseif ($objects['tip'] == 5)
{
mysql_query("UPDATE slots, players set slots.5=0, players.hp_now=if(players.hp_now<$objects[hp],0,players.hp_now-$objects[hp]), players.energy_now=if(players.energy_now<$objects[energy],0,players.energy_now-$objects[energy]) WHERE slots.id=".$stat['id']." AND players.id=".$stat['id']."");
}
elseif ($objects['tip'] == 6)
{
mysql_query("UPDATE slots, players set slots.13=0, players.hp_now=if(players.hp_now<$objects[hp],0,players.hp_now-$objects[hp]), players.energy_now=if(players.energy_now<$objects[energy],0,players.energy_now-$objects[energy]) WHERE slots.id=".$stat['id']." AND players.id=".$stat['id']."");
}
elseif ($objects['tip'] == 7)
{
mysql_query("UPDATE slots, players set slots.9=0, players.hp_now=if(players.hp_now<$objects[hp],0,players.hp_now-$objects[hp]), players.energy_now=if(players.energy_now<$objects[energy],0,players.energy_now-$objects[energy]) WHERE slots.id=".$stat['id']." AND players.id=".$stat['id']."");
}
elseif ($objects['tip'] == 8)
{
mysql_query("UPDATE slots, players set slots.1=0, players.hp_now=if(players.hp_now<$objects[hp],0,players.hp_now-$objects[hp]), players.energy_now=if(players.energy_now<$objects[energy],0,players.energy_now-$objects[energy]) WHERE slots.id=".$stat['id']." AND players.id=".$stat['id']."");
}
elseif ($objects['tip'] == 9)
{
mysql_query("UPDATE slots, players set slots.15=0, players.hp_now=if(players.hp_now<$objects[hp],0,players.hp_now-$objects[hp]), players.energy_now=if(players.energy_now<$objects[energy],0,players.energy_now-$objects[energy]) WHERE slots.id=".$stat['id']." AND players.id=".$stat['id']."");
}
elseif ($objects['tip'] == 10)
{
mysql_query("UPDATE slots, players set slots.14=0, players.hp_now=if(players.hp_now<$objects[hp],0,players.hp_now-$objects[hp]), players.energy_now=if(players.energy_now<$objects[energy],0,players.energy_now-$objects[energy]) WHERE slots.id=".$stat['id']." AND players.id=".$stat['id']."");
}
}
}
}
mysql_query("update players set cast=0 where id='".$stat['id']."'");
require_once("inc/chat/functions.php");
insert_msg ("Бой закончен, Вы проиграли. Всего Вами нанесено урона: [b][u]".$participant['damage']." HP[/u][/b].","","","1",$stat['user'],"",$stat['room']);
if ($offer['blood'] == 1) mysql_query("UPDATE players SET travma=$now+10800 WHERE id='".$stat['id']."'");
$endbattle = 1;
$stat['battle'] = '';
}
// ----- # ПОБЕДА КОМАНДЫ # ----- //
elseif (($user_command['count'] > 0 && $user_opponent_command['count'] == 0) && !$endbattle) {
if ($opp_stat['user'] == "Смерть"){ mysql_query("UPDATE `players` SET bot_time=3600+$now, bot_active=1 WHERE user='".$opp_stat['user']."'");
$opp_stat['bot_time']=3600+$now;
$opp_stat['bot_active']=1;}
$echo="<center>[b]Поздравляем, Вы одержали победу![/b]
<input type=button value=' Вернуться ' onclick='window.location.href=parseurl([url]http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9wYXJzZXVybCY%3D&b=5#40[/url]);[url]http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy8m&b=5#092[/url]);"main.php?tmp=\"+Math.random();\"\"' class=standbut></center>
";
mysql_query("UPDATE players SET last_battle=".$_RESERVER['battle']." WHERE battle='".$stat['battle']."'");
echo mysql_error();
if ($offer['blood'] == 1) mysql_query("UPDATE players SET travma=$now+1080, cure_hp=0 WHERE battle='".$stat['battle']."' AND side='".$opp_side."'");
mysql_query("UPDATE participants SET hp=0 WHERE time='".$stat['battle']."' AND side='".$opp_side."'");
get_exp();
if ($stat['exp']+$addexp >= $level['exp']) {
$new_exp=$stat['exp']+$addexp;
$up_level=mysql_fetch_array(mysql_query("SELECT * FROM levels WHERE exp>".$new_exp." ORDER BY id LIMIT 1"));
$addons=mysql_fetch_array(mysql_query("SELECT SUM(credits) as credits, SUM(updates) as updates, SUM(raseup) as raseup FROM levels WHERE id>".$levelup['id']." AND id<=".$up_level['id']."-1"));
$ups=mysql_fetch_array(mysql_query("SELECT level, up FROM levels WHERE id=".$up_level['id']."-1"));
mysql_query("update players set wins=wins+1, battle=NULL, cure_hp=0, exp=exp+".$addexp.", s_updates=s_updates+".$addons['updates'].", o_updates=o_updates+".$addons['raseup'].", credits=credits+".$addons['credits'].", level=".$ups['level'].", up=".$ups['up']." WHERE id='".$stat['id']."'");
mysql_query("UPDATE participants SET live=1 WHERE time='".$stat['battle']."' AND id='".$stat['id']."'");
}
else {
mysql_query("UPDATE players SET wins=wins+1, battle=NULL, cure_hp=0, exp=exp+'".$addexp."' where id='".$stat['id']."'");
mysql_query("UPDATE participants SET live=1 WHERE time='".$stat['battle']."' AND id='".$stat['id']."'");
}
if ($stat['vitality']*5 != $stat[ustal_now]) {
mysql_query("UPDATE players SET ustal_now=ustal_now+10 WHERE id='".$stat['id']."'");
}
if ($stat['vitality']*5 < $stat[ustal_now]) {
mysql_query("UPDATE players SET ustal_now='".$stat['vitality']."'*5 WHERE id='".$stat['id']."'");
}
mysql_query("update players set cast=0 where id='".$stat['id']."'");
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'] = '';
}
// ----- # ЖДЁМ ОКОНЧАНИЯ БОЯ # ----- //
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=parseurl([url]http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9wYXJzZXVybCY%3D&b=5#40[/url]);[url]http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy8m&b=5#092[/url]);"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=parseurl([url]http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9wYXJzZXVybCY%3D&b=5#40[/url]);[url]http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy8m&b=5#092[/url]);"main.php?tmp=\"+Math.random();\"\"' class=standbut></center>
";
mysql_query("UPDATE players, participants SET players.hp_now=0, players.last_battle=".$_RESERVER['battle'].", participants.hp=0 WHERE participants.time='".$stat['battle']."' AND participants.side='".$opp_side."' AND players.id=participants.id");
if ($offer['blood'] == 1) mysql_query("UPDATE players SET travma=$now+10800 WHERE battle='".$stat['battle']."' AND side='".$opp_side."'");
get_exp();
if ($stat['exp']+$addexp >= $level['exp']) {
$new_exp=$stat['exp']+$addexp;
$up_level=mysql_fetch_array(mysql_query("SELECT * FROM levels WHERE exp>".$new_exp." ORDER BY id LIMIT 1"));
$addons=mysql_fetch_array(mysql_query("SELECT SUM(credits) as credits, SUM(updates) as updates, SUM(raseup) as raseup FROM levels WHERE id>".$levelup['id']." AND id<=".$up_level['id']."-1"));
$ups=mysql_fetch_array(mysql_query("SELECT level, up FROM levels WHERE id=".$up_level['id']."-1"));
mysql_query("update players set wins=wins+1, battle=NULL, cure_hp=0, exp=exp+".$addexp.", s_updates=s_updates+".$addons['updates'].", o_updates=o_updates+".$addons['raseup'].", credits=credits+".$addons['credits'].", level=".$ups['level'].", up=".$ups['up']." WHERE id='".$stat['id']."'");
mysql_query("UPDATE participants SET live=1 WHERE time='".$stat['battle']."' AND id='".$stat['id']."'");
}
else {
mysql_query("UPDATE players SET wins=wins+1, battle=NULL, cure_hp=0, exp=exp+'".$addexp."' where id='".$stat['id']."'");
mysql_query("UPDATE participants SET live=1 WHERE time='".$stat['battle']."' AND id='".$stat['id']."'");
}
if ($stat['vitality']*5 != $stat[ustal_now]) {
mysql_query("UPDATE players SET ustal_now=ustal_now+10 WHERE id='".$stat['id']."'");
}
if ($stat['vitality']*5 < $stat[ustal_now]) {
mysql_query("UPDATE players SET ustal_now='".$stat['vitality']."'*5 WHERE id='".$stat['id']."'");
}
mysql_query("update players set cast=0 where id='".$stat['id']."'");
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'] = '';
// ----- # Конец # ----- //
} else
$echo="<center>[b]Ожидаем хода противника...[/b]
<input type=button name=ref value=' Обновить ' onclick='ref.disabled = true; window.location.href=parseurl([url]http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9wYXJzZXVybCY%3D&b=5#40[/url]);[url]http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy8m&b=5#092[/url]);"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=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9iYXR0bGUucGhwP3BhZ2U9YmF0dGxlJg%3D%3D&b=5#62;";
$echo.="<input type=hidden name=opponent value='$victims[$random]'>";
?>
<?
$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>
<td align=center style='BORDER-TOP: 1px solid;'><input type=button name=ref value=' Обновить ' onclick='ref.disabled = true; window.location.href=parseurl([url]http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9wYXJzZXVybCY%3D&b=5#40[/url]);[url]http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy8m&b=5#092[/url]);"battle.php?tmp=\"+Math.random();\"\"' class=standbut></td>
</tr>
</table>
</center>
</form>";
?>
<?php
}
} else {
// ----- # Выигрыш # ----- //
if (!$endbattle) {
if ($opp_stat['user'] == "Смерть"){ mysql_query("UPDATE `players` SET bot_time=3600+$now, bot_active=1 WHERE user='".$opp_stat['user']."'");
$opp_stat['bot_time']=3600+$now;
$opp_stat['bot_active']=1;
$vresbot=rand(0,25);
if ($vresbot=1){
mysql_query("INSERT INTO `objects` (`user`,`inf`,`min`,`tip`,`time`, `about`) VALUES ('".$stat['user']."','ing_4esh_drak|Чешуя дракона|5.00|0|0|0|0|1','0|0|0|0|0|0|0|0','23','".time()."', 'Ингридиент')");
require_once("inc/chat/functions.php");
$msg("После побя вам случайно выпала [b]Чешуя дракона[/b]!","","","1",$stat['user'],"",$stat['room']);}
if ($vresbot=1){
mysql_query("INSERT INTO `objects` (`user`,`inf`,`min`,`tip`,`time`, `about`) VALUES ('".$stat['user']."','ing_kri_kv|Кристалл кварца|5.00|0|0|0|0|1','0|0|0|0|0|0|0|0','23','".time()."', 'Ингридиент')");
require_once("inc/chat/functions.php");
$msg("После побя вам случайно выпал [b]Кристалл кварца[/b]!","","","1",$stat['user'],"",$stat['room']);}
}
if ($stat['proff'] == 1||$opp_stat['proff'] == 1){
$kogav=rand(0,40);
if ($kogav=1){
mysql_query("INSERT INTO `objects` (`user`,`inf`,`min`,`tip`,`time`, `about`) VALUES ('".$stat['user']."','ing_koga|Кусок кожи|5.00|0|0|0|0|1','0|0|0|0|0|0|0|0','23','".time()."', 'Ингридиент')");
require_once("inc/chat/functions.php");
$msg("После побя вам случайно выпал [b]Кусок кожи[/b]!","","","1",$stat['user'],"",$stat['room']);}
}
if ($stat['sclon'] == "dark"){
$vamp=rand(0,40);
if ($vamp=1){
mysql_query("INSERT INTO `objects` (`user`,`inf`,`min`,`tip`,`time`, `about`) VALUES ('".$stat['user']."','ing_vamp|Клык вампира|5.00|0|0|0|0|1','0|0|0|0|0|0|0|0','23','".time()."', 'Ингридиент')");
require_once("inc/chat/functions.php");
$msg("После побя вам случайно выпал [b]Клык вампира[/b]!","","","1",$stat['user'],"",$stat['room']);}
}
$echo="<center>[b]Поздравляем! Победа за Вами![/b]
<input type=button value=' Вернуться ' onclick='window.location.href=parseurl([url]http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9wYXJzZXVybCY%3D&b=5#40[/url]);[url]http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy8m&b=5#092[/url]);"main.php?tmp=\"+Math.random();\"\"' class=standbut></center>
";
// mysql_query("UPDATE players SET hp_now=0, last_battle=".$_RESERVER['battle']." WHERE battle='".$stat['battle']."' AND side='".$opp_side."'");
mysql_query("UPDATE players SET last_battle=".$_RESERVER['battle']." WHERE battle='".$stat['battle']."' AND side='".$opp_side."'");
echo mysql_error();
if ($offer['blood'] == 1) mysql_query("UPDATE players SET travma=$now+10800 WHERE battle='".$stat['battle']."' AND side='".$opp_side."'");
mysql_query("UPDATE participants SET hp=0 WHERE time='".$stat['battle']."' AND side='".$opp_side."'");
get_exp();
if ($stat['exp']+$addexp >= $level['exp']) {
$new_exp=$stat['exp']+$addexp;
$up_level=mysql_fetch_array(mysql_query("SELECT * FROM levels WHERE exp>".$new_exp." ORDER BY id LIMIT 1"));
$addons=mysql_fetch_array(mysql_query("SELECT SUM(credits) as credits, SUM(updates) as updates, SUM(raseup) as raseup FROM levels WHERE id>".$levelup['id']." AND id<=".$up_level['id']."-1"));
$ups=mysql_fetch_array(mysql_query("SELECT level, up FROM levels WHERE id=".$up_level['id']."-1"));
mysql_query("update players set wins=wins+1, battle=NULL, cure_hp=0, exp=exp+".$addexp.", s_updates=s_updates+".$addons['updates'].", o_updates=o_updates+".$addons['raseup'].", credits=credits+".$addons['credits'].", level=".$ups['level'].", up=".$ups['up']." WHERE id='".$stat['id']."'");
mysql_query("UPDATE participants SET live=1 WHERE time='".$stat['battle']."' AND id='".$stat['id']."'");
}
else {
mysql_query("UPDATE players SET wins=wins+1, battle=NULL, cure_hp=0, exp=exp+'".$addexp."' where id='".$stat['id']."'");
mysql_query("UPDATE participants SET live=1 WHERE time='".$stat['battle']."' AND id='".$stat['id']."'");
}
if ($stat['vitality']*5 != $stat[ustal_now]) {
mysql_query("UPDATE players SET ustal_now=ustal_now+10 WHERE id='".$stat['id']."'");
}
if ($stat['vitality']*5 < $stat[ustal_now]) {
mysql_query("UPDATE players SET ustal_now='".$stat['vitality']."'*5 WHERE id='".$stat['id']."'");
}
echo mysql_error();
mysql_query("update players set cast=0 where id='".$stat['id']."'");
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']);
$endbattle = 1;
$stat['battle'] = '';
}
// ----- # Конец # ----- //
}
}
include("inc/magic/use.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=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy8m&b=5#092;"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=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy8m&b=5#092;"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]. Получено опыта: [u]".$addexp."[/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 {
$kart=array();
$kart[0]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMS5naWY%3D&b=5 width=210 height=277></td></tr></table>";
$kart[1]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMi5naWY%3D&b=5 width=210 height=277></td></tr></table>";
$kart[2]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMy5naWY%3D&b=5 width=210 height=277></td></tr></table>";
$kart[3]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvNC5naWY%3D&b=5 width=210 height=277></td></tr></table>";
$kart[4]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvNS5naWY%3D&b=5 width=210 height=277></td></tr></table>";
$kart[5]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvNi5naWY%3D&b=5 width=210 height=277></td></tr></table>";
$kart[6]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvNy5naWY%3D&b=5 width=210 height=277></td></tr></table>";
$kart[7]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvOC5naWY%3D&b=5 width=210 height=277></td></tr></table>";
$kart[8]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvOS5naWY%3D&b=5 width=210 height=277></td></tr></table>";
$kart[9]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMTAuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[10]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMTEuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[11]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMTIuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[12]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMTMuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[13]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMTQuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[14]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMTUuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[15]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMTYuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[16]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMTcuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[17]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMTguZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[18]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMTkuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[19]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMjAuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[20]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMjEuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[21]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMjIuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[22]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMjMuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[23]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMjQuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[24]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMjUuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[25]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMjYuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[26]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMjcuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[27]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMjguZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[28]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMjkuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[29]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMzAuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[30]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMzEuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[31]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMzIuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[32]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMzMuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart[33]="</td><td valign=top align=right><img src=http://nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9odHRwJg%3D%3D&b=5#58/nrc.novogrudok.by/glype/proxy/browse.php?u=Oi8vZGFwZi51cy9pbWcvaS9iYXR0bGUvMzQuZ2lm&b=5 width=210 height=277></td></tr></table>";
$kart_type=$kart[rand(0,33)];
echo "$kart_type"; }
?>