File size: 11.75Kb
<?
define('PROTECTOR', 1);
$head = 'duel';//фикс. места
if($_GET[mod]=="udar"){
$header=TRUE;
}else{
$textl='Онлайн Перестрелки - Бой';}
@include('files/db.php');
@include('files/auth.php');
@include('files/func.php');
@include('files/core.php');
@include('files/head.php');
@include('files/zag.php');
//
$time=time();
$timer=time()+300;
///Глобальные переменные///
$req = mysql_query("SELECT * FROM `userduel` WHERE `usr` = '$log' LIMIT 1");
$duel = mysql_fetch_array($req);
$redu = mysql_query("SELECT * FROM `duel` WHERE `id` = '$duel[duid]' LIMIT 1");
$dued = mysql_fetch_array($redu);
switch($_GET[mod]){
default:
if($dueli==0){echo'<div class="dot"><center>Вы не участвуете в бою</center></div>
<a href="duel.php?">Продолжить »</a>';break;
}
if($duel[storona]=="white"){$pr="black";}else{$pr="white";}
$rand=rand(1000000,10000000);
echo"<center><b>Битва</b></center>$div";
$win = mysql_num_rows(mysql_query("SELECT `duid` FROM `userduel` WHERE `storona` = '$pr' and `duid`='$duel[duid]'"));
if($win<=0){
echo'<div class="dot"><center>Дуэль не началась, так как нет противников</center></div>';
mysql_query("DELETE FROM `duel` WHERE `id` = '$duel[duid]'");
echo"<br/>";
echo"<a href=\"fiting.php?rand=$rand\"> <img src='pic/game/reload.png' alt='*'/> Обновить </a><br/>";
echo"<a href=\"fiting.php?mod=exit\"> <img src='pic/game/ext.png' alt='*'/> Покинуть бой </a>";break;
}
if($win>=1){
if(empty($duel[usr])){
echo"<img src='pic/game/ext.png' alt='*'/><a href=\"start.php?\"> Продолжить »</a> ";break;
}
$wins = mysql_num_rows(mysql_query("SELECT `duid` FROM `userduel` WHERE `storona` = '$pr' and `status`='die' and `duid`='$duel[duid]'"));
if($win=$wins){
if($udata[lvl]>=1 and $udata[lvl]<=10){$bon=30;}
if($udata[lvl]>10 and $udata[lvl]<=20){$bon=50;}
if($udata[lvl]>20 and $udata[lvl]<=30){$bon=100;}
if($udata[lvl]>30 and $udata[lvl]<=40){$bon=200;}
if($udata[lvl]>40 and $udata[lvl]<=50){$bon=300;}
if($udata[lvl]>50 and $udata[lvl]<=60){$bon=400;}
if($udata[lvl]>60 and $udata[lvl]<=71){$bon=500;}
if($duel[status]="active"){
$viz=round($udata[lvl]*1.5+$bon);}else{$viz=0;}
$wins=$udata[lvl]+$bon;
$die=$duel[dies]*$bon;
$itogo=$wins+$die;
echo"<div class='dot'><center><img src='pic/game/wins.png' alt='*'/> Бой завершен. Ты выиграл</center></div>";
echo"<font color='#ffc22b'><b>Твоя награда:</font></b>";
echo"<div class='log'>
Выживание: <img src='pic/bazar.gif' alt='*'/> <b>$viz</b><br/>
Победа: <img src='pic/main/auction.png' alt='*'/> <b>$wins</b><br/>
Убийство: <img src='pic/main/auction.png' alt='*'/> <b>$die</b><br/>
Итого: <b><img src='pic/bazar.gif' alt='*'/> $viz <img src='pic/main/auction.png' alt='*'/> $itogo</b><br/></div>";
mysql_query("UPDATE `users` SET `money` = '$udata[money]'+'$viz', `exp`='$udata[exp]'+'$itogo' WHERE `usr`='$log'") or die (mysql_error());
$usr="$log x";
mysql_query("UPDATE `userduel` SET `usr` = '$usr' WHERE `usr`='$log' LIMIT 1") or die (mysql_error());
$du = mysql_num_rows(mysql_query("SELECT `duid` FROM `userduel` WHERE `storona` = '$duel[storona]' and `status`='active' and `duid`='$duel[duid]'"));
if($du<=0){mysql_query("DELETE FROM `duel` WHERE `id` = '$duel[duid]'");}
echo"<img src='pic/game/ext.png' alt='*'/><a href=\"start.php?\"> Продолжить »</a> ";break;
}
}
if($udata[hp]<=0){
echo'<div class="dot"><center><font color="red">Ты мертв. Эта битва завершена для тебя</font></center></div>';
echo"<a href=\"fiting.php?rand=$rand\"> <img src='pic/game/reload.png' alt='*'/> Обновить </a><br/>";
echo"<a href=\"fiting.php?mod=exit\"> <img src='pic/game/ext.png' alt='*'/> Покинуть бой </a><br/>";
}else{
if(empty($_GET[oponent])){
$boy=mysql_query("SELECT * FROM `userduel` WHERE `storona`='$pr' and `duid`='$dued[id]' and `status`='active' ORDER BY RAND() LIMIT 1");
$oponent = mysql_fetch_array($boy);
$_GET[oponent]="$oponent[usr]";
}
echo"<a href=\"fiting.php?mod=udar&oponent=$_GET[oponent]\"> <img src='pic/red.png' alt='*'/> Атаковать $_GET[oponent] </a><br/>";
$req=mysql_query("SELECT umen,timer FROM duellog WHERE usr = '$log' and timer>='".time()."' and umen='1' ORDER BY id DESC LIMIT 1");
$su = mysql_fetch_array($req);
if($su[timer]+8>$timer){$vr=8-($timer-$su[timer]);$vre="0:0$vr";$cvet="<font color='#AAAAAA'>";}
echo"<a href=\"fiting.php?mod=udar&oponent=$_GET[oponent]&umen=sudar\"> <img src='pic/game/sudar.png' alt='*'/>$cvet Сильный удар $vre </a></font><br/>";
////Рандом игроков///
$users=mysql_num_rows(mysql_query("SELECT `duid` FROM `userduel` WHERE `storona`='$pr' and `duid`='$dued[id]' and `status`='active'"));
if($users>=2){
$users=mysql_fetch_array(mysql_query("SELECT `usr` FROM `userduel` WHERE `usr`!='$_GET[oponent]' and `storona`='$pr' and `duid`='$dued[id]' ORDER BY RAND() LIMIT 1"));
echo"<a href=\"fiting.php?mod=udar&oponent=$users[usr]\"> <img src='pic/red.png' alt='*'/> Атаковать любого </a><br/>";
}
}//die
$kom=mysql_num_rows(mysql_query("SELECT `duid` FROM `userduel` WHERE `storona`='$duel[storona]' and `duid`='$dued[id]' "));
echo"<a href=\"fiting.php?mod=kom\"> <img src='pic/game/kom.png' alt='*'/> Моя команда ($kom) </a><br/>";
echo"$div <center>Противники:</center>";
///Враги///
$boy=mysql_query("SELECT * FROM `userduel` WHERE `storona`='$pr' and `duid`='$dued[id]' ");
While($vrag=mysql_fetch_array($boy)){
if($vrag[status]=="active"){
echo"<img src='pic/main/$vrag[storona].png' alt='*'/> <a href='fiting.php?mod=udar&oponent=$vrag[usr]'>$vrag[usr]</a>
<img src='pic/up.png' alt='*'/> $vrag[lvl] [<img src='pic/game/mob/hp.gif' alt='*'/>";
$hp=mysql_fetch_array(mysql_query("SELECT hp FROM `users` WHERE `usr`='$vrag[usr]' LIMIT 1"));
echo"$hp[hp]] <br/>"; }
if($vrag[status]=="die"){
echo"<img src='pic/main/$vrag[storona].png' alt='*'/> <font color='gray'>$vrag[usr]</font>
<img src='pic/game/die.png' alt='*'/> $vrag[lvl] <br/> ";
}
}
echo"$div";
$protiv = mysql_query("SELECT * FROM `userduel` WHERE `duid` = '$duel[duid]' and `storona`='$pr' ");
$souz = mysql_query("SELECT * FROM `userduel` WHERE `duid` = '$duel[duid]' and `storona`='$udata[storona]' ");
log_duel($tlog='duel');
break;
case 'udar':
$req=mysql_query("SELECT umen,timer FROM duellog WHERE usr = '$log' and timer>='".time()."' and umen='1' ORDER BY id DESC LIMIT 1");
$su = mysql_fetch_array($req);
if($su[timer]+8>$timer and $_GET[umen]=="sudar"){header ("Location: fiting.php?");exit;}
if(empty($_GET[oponent])){header ("Location: fiting.php?");exit;}
if($udata[hp]<=0){header ("Location: fiting.php?");exit;}
$oponent = htmlspecialchars(addslashes(stripslashes($_GET['oponent'])));
$user = mysql_query("SELECT * FROM `users` WHERE `usr`='$oponent' ");
$rest = substr("$oponent", 0, -2);
if($rest==" x"){header ("Location: fiting.php?");exit;}
$vrag = mysql_fetch_array($user);
$udar = $udata[sila]*3-$vrag[prot];
if($udar>=0 and $udar<=10){$bon=2;}
if($udar>10 and $udar<=30){$bon=4;}
if($udar>30 and $udar<=50){$bon=8;}
if($udar>50 and $udar<=70){$bon=12;}
if($udar>70 and $udar<=100){$bon=16;}
if($udar>100){$bon=20;}
if($udar<=0){
$shans=rand(0,100);
if($shans>=0 and $shans<=10){$udar=rand(3,5);}
if($shans>=10 and $shans<=30){$udar=rand(2,4);}
if($shans>=30 and $shans<=60){$udar=rand(1,3);}
if($shans>=60 and $shans<=100){$udar=rand(1,2);}
}else{
$shans=rand(0,100);
if($shans>=0 and $shans<=10){$udar=rand(7,10);}
if($shans>=10 and $shans<=30){$udar=rand(6,8);}
if($shans>=30 and $shans<=60){$udar=rand(5,6);}
if($shans>=60 and $shans<=100){$udar=rand(4,4);}
}
if($udata[lovk]-$vrag[lovk]<0){$uvorot=50;}else{$uvorot=25;}
$umen=mysql_query("SELECT `sfera` FROM `userduel` WHERE `usr`='$oponent' ");
$sfera = mysql_fetch_array($user);
if($_GET[umen]=="sudar" and $sfera[sfera]==0){$udar=$udar*5;}
$req=mysql_query("SELECT * FROM duellog WHERE usr = '$log' and timer>='".time()."' ORDER BY id DESC LIMIT 1");
$ilog=mysql_fetch_array($req);
$razn=$timer-$ilog[timer];
if($razn<=2){$uvorot=$uvorot+25;}
if($razn>=2 and $razn<=5){$uvorot=$uvorot;}
if($razn>=5 and $razn<=10){$uvorot=$uvorot-15;}
$sravn=rand(0,100);
if($sravn<$uvorot){$udar=0;}
if($udar==0){$sms="Промах";$pr=1;}
if($pr!==1){
$uron=round($vrag[hp]-(($vrag[hp]/100)*$udar)-$bon);
$udar=round(($vrag[hp]/100)*$udar+$bon);
$msg=rand(0,2);
if($msg=="0"){$sms="травмировал";}
if($msg=="1"){$sms="поразил";}
if($msg=="2"){$sms="атаковал";}
if($_GET[umen]=="sfera"){$sms=html_entity_decode("использовал</font> сфера защиты");$um=1;$uron=0;}
if($_GET[umen]=="sudar"){$sms=html_entity_decode("использовал</font> сильный удар");$um=1;}
if($uron<=0){$sms="убил";
$die=$duel[dies]+1;
mysql_query("UPDATE `userduel` SET `status` = 'die' WHERE `usr`='$oponent'") or die (mysql_error());
mysql_query("UPDATE `userduel` SET `dies` = '$die' WHERE `usr`='$log'") or die (mysql_error());
}
mysql_query("UPDATE `users` SET `hp` = '$uron' WHERE `usr`='$oponent'") or die (mysql_error());
mysql_query("UPDATE `userduel` SET `hp` = '$uron' WHERE `usr`='$oponent'") or die (mysql_error());
mysql_query("INSERT INTO duellog SET usr='$log',text='$sms',opon='$oponent',uron='$udar',timer='$timer', umen='$um'");}
else{
mysql_query("INSERT INTO duellog SET usr='$log',text='$sms',timer='$timer', umen='$um'");
}
$b = html_entity_decode($_POST[name]);
if($uron<=0){$oponent="";}
header ("Location: fiting.php?oponent=$oponent");exit;
break;
case 'exit':
$usr="$log x";
mysql_query("UPDATE `userduel` SET `usr` = '$usr' WHERE `usr`='$log' LIMIT 1") or die (mysql_error());
echo"<center><b>Битва</b></center>$div";
echo"<font color='red'>Вы покинули бой. </font><br/><a href=\"start.php?\">Продолжить »</a>";
break;
case 'exit':
$usr="$log x";
mysql_query("UPDATE `userduel` SET `usr` = '$usr' WHERE `usr`='$log' LIMIT 1") or die (mysql_error());
echo"<center><b>Битва</b></center>$div";
echo"<font color='red'>Вы покинули бой. </font><br/><a href=\"start.php?\">Продолжить »</a>";
break;
case 'kom':
echo"<center><b>Моя команда</b></center>$div";
if($duel[storona]=="white"){$pr="black";}else{$pr="white";}
$boy=mysql_query("SELECT * FROM `userduel` WHERE `storona`='$duel[storona]' and `duid`='$dued[id]' ");
While($vrag=mysql_fetch_array($boy)){
if($vrag[status]=="active"){
echo"<img src='pic/main/$vrag[storona].png' alt='*'/> <a href='fiting.php?mod=udar&oponent=$vrag[usr]'>$vrag[usr]</a>
<img src='pic/up.png' alt='*'/> $vrag[lvl] [<img src='pic/game/mob/hp.gif' alt='*'/>";
$hp=mysql_fetch_array(mysql_query("SELECT hp FROM `users` WHERE `usr`='$vrag[usr]' LIMIT 1"));
echo"$hp[hp]],"; }
if($vrag[status]=="die"){
echo"<img src='pic/main/$vrag[storona].png' alt='*'/> <font color='gray'>$vrag[usr]</font>
<img src='pic/game/die.png' alt='*'/> $vrag[lvl], ";
}
}
echo"$div<img src='pic/game/vrag.png' alt='*'/> Противники:$div";
$boy=mysql_query("SELECT * FROM `userduel` WHERE `storona`='$pr' and `duid`='$dued[id]' ");
While($vrag=mysql_fetch_array($boy)){
if($vrag[status]=="active"){
echo"<img src='pic/main/$vrag[storona].png' alt='*'/> <a href='fiting.php?mod=udar&oponent=$vrag[usr]'>$vrag[usr]</a>
<img src='pic/up.png' alt='*'/> $vrag[lvl] [<img src='pic/game/mob/hp.gif' alt='*'/>";
$hp=mysql_fetch_array(mysql_query("SELECT hp FROM `users` WHERE `usr`='$vrag[usr]' LIMIT 1"));
echo"$hp[hp]],"; }
if($vrag[status]=="die"){
echo"<img src='pic/main/$vrag[storona].png' alt='*'/> <font color='gray'>$vrag[usr]</font>
<img src='pic/game/die.png' alt='*'/> $vrag[lvl], ";
}
}
break;
}
@include('files/down.php');
?>