View file sdark.mobi/task/fight/siege.php

File size: 12.85Kb
<?
require_once'../../core/system.php';
echo only_reg();
echo ban();
echo blok();
mysql_query("UPDATE `user` set `mesto` = 'Бой' where `id` = '".$user['id']."'");
$reqa = mysql_query("SELECT * FROM `task` WHERE `usr`='".$user['id']."' and `status`='2'");
$task = mysql_fetch_array($reqa);
$avto = mysql_num_rows($reqa);
if($avto == 0){
	header ("Location: /");
	exit;
}
$header = $task['name'];
require_once'../../core/head.php';
$timer = $_SERVER['REQUEST_TIME'] + 300;
$req = mysql_query("SELECT * FROM `battle` WHERE `usr`='".$user['nick']."' and `task`='".$task['task']."'");
$reqn = mysql_query("SELECT * FROM `battle` WHERE `usr`='".$user['nick']."' and `task`='".$task['task']."' and `status`='no'");
$avto = mysql_num_rows($req);
$avtod = mysql_num_rows($reqn);
if($avtod>0){
mysql_query("DELETE FROM `battle` WHERE `usr`='".$user['nick']."'");
mysql_query("DELETE FROM `duellog` WHERE `usr`='".$user['nick']."'");
mysql_query("DELETE FROM `link` WHERE `usr`='".$user['id']."'");
header ("Location: ?");exit;}
$kolis = mysql_result(mysql_query("SELECT  COUNT(*)  FROM `battle` WHERE `usr`='".$user['nick']."' and `status`='off'"),0);
if($user['battle']==0 and $kolis>0 and $kolis<3){ 
mysql_query("DELETE FROM `battle` WHERE `usr`='".$user['nick']."'");
mysql_query("DELETE FROM `duellog` WHERE `usr`='".$user['nick']."'");
mysql_query("DELETE FROM `link` WHERE `usr`='".$user['id']."'");
header ("Location: ?");exit;}
if($avto==0){
$t=time()+3600;
$nextudar=rand(3,12);
$nextud=time()+$nextudar;
$nextudd=time()+$nextudar+2;
mysql_query("INSERT INTO `link` SET `usr`='".$user['id']."',`timer`='$t', `link`='$_SERVER[PHP_SELF]'");
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Орк', `status`='', `task`='".$task['task']."', `hpmax`='1200', `hp`='1200', `sila`='50', `prot`='40', `time`='$t', `nextud`='$nextud'");
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Орк', `status`='', `task`='".$task['task']."', `hpmax`='1200', `hp`='1200', `sila`='50', `prot`='40', `time`='$t', `nextud`='$nextudd'");
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Орк', `status`='', `task`='".$task['task']."', `hpmax`='1200', `hp`='1200', `sila`='50', `prot`='40', `time`='$t', `nextud`='$nextudd'");
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Орк', `status`='', `task`='".$task['task']."', `hpmax`='1200', `hp`='1200', `sila`='50', `prot`='40', `time`='$t', `nextud`='$nextudd'");
mysql_query("UPDATE `user` SET `battle`='1' WHERE `id`='".$user['id']."'");
mysql_query("DELETE FROM `duellog` WHERE `usr`='".$user['nick']."'");
header ("Location: ?");exit;
}
if($user['battle']==0){
$_SESSION['err'] = ' Ошибка';
header ("Location: /");exit;}
$avtomob = mysql_num_rows($req);

$kolss = mysql_result(mysql_query("SELECT  COUNT(*)  FROM `battle` WHERE `usr`='".$user['nick']."' and `task`='".$task['task']."' and `status`='off'"),0);
$kols = mysql_result(mysql_query("SELECT  COUNT(*)  FROM `battle` WHERE `usr`='".$user['nick']."'  and `status`=''"),0);
if($kolss==4 and $kols==0){
$t=time()+3600;
$nextudar=rand(3,12);
$nextudd=time()+$nextudar;
$nextuddd=time()+$nextudar+2;
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Орк', `status`='', `task`='".$task['task']."', `hpmax`='2000', `hp`='2000', `sila`='100', `prot`='60', `time`='$t', `nextud`='$nextuddd', `boss`=''");
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Орк', `status`='', `task`='".$task['task']."', `hpmax`='2000', `hp`='2000', `sila`='100', `prot`='60', `time`='$t', `nextud`='$nextudd', `boss`=''");
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Орк', `status`='', `task`='".$task['task']."', `hpmax`='2000', `hp`='2000', `sila`='100', `prot`='60', `time`='$t', `nextud`='$nextudd', `boss`=''");
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Орк', `status`='', `task`='".$task['task']."', `hpmax`='2000', `hp`='2000', `sila`='100', `prot`='60', `time`='$t', `nextud`='$nextuddd', `boss`=''");
}

if($kolss==8 and $kols==0){
$t=time()+3600;
$nextudar=rand(3,12);
$nextud=time()+$nextudar;
$nextudd=time()+$nextudar+2;
$nextuddd=time()+$nextudar+5;
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Орк', `status`='', `task`='".$task['task']."', `hpmax`='3000', `hp`='3000', `sila`='150', `prot`='60', `time`='$t', `nextud`='$nextudd', `boss`=''");
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Орк', `status`='', `task`='".$task['task']."', `hpmax`='3000', `hp`='3000', `sila`='150', `prot`='60', `time`='$t', `nextud`='$nextudd', `boss`=''");
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Орк', `status`='', `task`='".$task['task']."', `hpmax`='3000', `hp`='3000', `sila`='150', `prot`='60', `time`='$t', `nextud`='$nextud', `boss`=''");
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Орк', `status`='', `task`='".$task['task']."', `hpmax`='3000', `hp`='3000', `sila`='150', `prot`='60', `time`='$t', `nextud`='$nextuddd', `boss`=''");
}

if($kolss==12 and $kols==0){
$t=time()+3600;
$nextudar=rand(3,12);
$nextud=time()+$nextudar;
$nextudd=time()+$nextudar+2;
$nextuddd=time()+$nextudar+5;
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Орк', `status`='', `task`='".$task['task']."', `hpmax`='4000', `hp`='4000', `sila`='200', `prot`='60', `time`='$t', `nextud`='$nextuddd', `boss`=''");
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Орк', `status`='', `task`='".$task['task']."', `hpmax`='4000', `hp`='4000', `sila`='200', `prot`='60', `time`='$t', `nextud`='$nextud', `boss`=''");
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Орк', `status`='', `task`='".$task['task']."', `hpmax`='4000', `hp`='4000', `sila`='200', `prot`='60', `time`='$t', `nextud`='$nextuddd', `boss`=''");
}

if($kolss==15){
$whack = mysql_num_rows(mysql_query("SELECT * FROM `task` WHERE `usr`='".$user['id']."' and `status`='2' and `task`='45'"));
if($whack>0){mysql_query("UPDATE `task` SET `min` = `min`+'1'  WHERE `usr`='".$user['id']."' and `status`='2' and `task`='45'");}

header ("Location: /task/complete?id=$task[id]");exit;}
if(isset($_GET['healing'])){
$reqx = mysql_query("SELECT * FROM `umen` WHERE `usr` = '".$user['id']."' and `img`='healing'");
$healing = mysql_fetch_array($reqx);
$vrem = $_SERVER['REQUEST_TIME'] + $healing['time'];
if($healing['timer'] > $_SERVER['REQUEST_TIME'] or $user['health'] <= 0){
$_SESSION['err']="Промах";
header ("Location: ?");
exit;
}
if($user['health'] >= $user['max_health']){
$_SESSION['err']="Лечение не требуется";
header ("Location: ?");
exit;
} else {
$u = rand($user['sila'] - $user['sila'] / 8,$user['sila']);
$kolhp = $u*$healing['sila'];
$kolhp = round($kolhp,0);
mysql_query("UPDATE `umen` SET `timer` = '".$vrem."' WHERE `usr`='".$user['id']."' and `img`='healing'");
$xphe = $user['health'] + $kolhp;
$um = mysql_num_rows(mysql_query("SELECT * FROM `bonus` WHERE `usr`='".$user['id']."' and `typ`='3'"));
if($um > 0){
	$kolexp = $kolhp*2;
} else { 
	$kolexp = $kolhp;
}
if($setgame['exp']==1)$kolexp = $kolexp*2;
if($xphe <= $user['max_health']){
mysql_query("UPDATE `user` SET `health` = `health`+'".$kolhp."', `exp` = `exp`+'".$kolexp."' WHERE `id`='".$user['id']."'");
} else {
mysql_query("UPDATE `user` SET `health` = '".$user['max_health']."', `exp` = `exp`+'".$kolhp."' WHERE `id`='".$user['id']."'");
}
$_SESSION['message']="Вы использовали <img src='/images/umen/healing.png' height='16px' width='16px'> <font color='#FFBF00'>Исцеление</font> <img src='/images/icon/stat/hp.png'>+".$kolhp."";
header ("Location: ?");
exit;
}
}
if(isset($_GET['gift_of_the_Gods'])){
$reqxs = mysql_query("SELECT * FROM `umen` WHERE `usr` = '".$user['id']."' and `img`='gift_of_the_Gods'");
$gift = mysql_fetch_array($reqxs);
$vrem = $_SERVER['REQUEST_TIME'] + $gift['time'] + 30;
if($gift['timer'] > $_SERVER['REQUEST_TIME']){
$_SESSION['err']='Промах';
header ("Location: ?");
exit;
}
$umen = mysql_fetch_array(mysql_query("SELECT * FROM `umen` WHERE `usr`='".$user['id']."' and `img`='gift_of_the_Gods'"));
$dar = 100*$umen['sila'];
mysql_query("INSERT INTO `bonus` set `usr` = ".$user['id'].", `name` = 'Дар Богов',`kol`='".$dar."',`param`='sila', `time` = '".$vrem."'-'".$gift['time']."', `bonus`='+".$dar."% к урону', `image`='14',`typ`='0'");
mysql_query("UPDATE `umen` SET `timer` = '".$vrem."' WHERE `usr`='".$user['id']."' and `img`='gift_of_the_Gods'");
$_SESSION['message']="Вы использовали <img src='/images/umen/gift_of_the_Gods.png' height='16px' width='16px'> <font color='#3B9CF6'>Дар Богов</font> +".$dar."% к урону";
header ("Location: ?");
exit;
}
if(isset($_GET['udar']) and $user['health'] > 0){
$ureq = mysql_query("SELECT * FROM `battle` WHERE `usr`='".$user['nick']."' and `task`='".$task['task']."' and `id`='".$id."'");
$mobc = mysql_fetch_array($ureq);
if(empty($id)){
$_SESSION['err'] = "Не выбран противник";
header ("Location: ?");
exit;
}
if($mobc['hp'] <= 0){
$_SESSION['err'] = "Промах";
header ("Location: ?");
exit;
}
$req = mysql_query("SELECT * FROM `umen` WHERE `usr` = '".$user['id']."' and `img`='whack'");
$umen = mysql_fetch_array($req);
$summastat = $mobc['hpmax'] + $mobc['sila'] + $mobc['prot'];
$p = $mobc['prot']/$summastat;
$y = 1-$p;
$u = rand($user['sila'] - $user['sila']/8,$user['sila']);
$udar = $u*$y;
if(isset($_GET['whack'])){
	$udar = $udar*$umen['sila'];
} else {
	$udar=$u*$y;
}
$udar = round($udar,0);
$dar = mysql_query("SELECT * FROM `bonus` WHERE `usr`='".$user['id']."' and `time`>'".$tm."' and `name`='Дар Богов'");
$adar = mysql_num_rows($dar);
$kdar = mysql_fetch_array($dar);
if($adar > 0){
$kolik = $kdar['kol']/100;
$udar = floor($udar+($udar*$kolik));
}
$uron = $mobc['hp'] - $udar;

$ool = $user['online'] + 300;
$sec = $timer-$ool;
if($sec < 1){
$_SESSION['err'] = "Промах";
header ("Location: ?");
exit;
}

if($udar > $user['max_uron']){
mysql_query("UPDATE `user` SET `max_uron` = '".$udar."' WHERE `id`='".$user['id']."' LIMIT 1");
}
$ttur = rand(1,4); 
if($ttur == 1){$ttur = 'ударили';}
if($ttur == 2){$ttur = 'поразили';}
if($ttur == 3){$ttur = 'сразили';}
if($ttur == 4){$ttur = 'зацепили';}

$sms=''.$ttur.' '.$mobc['name'].'';
if($uron <= 0){
$ttud = rand(1,5);
if($ttud == 1){$ttud = 'убили';}
if($ttud == 2){$ttud = 'уничтожили';}
if($ttud == 3){$ttud = 'разгромили';}
if($ttud == 4){$ttud = 'сокрушили';}
if($ttud == 5){$ttud = 'победили';}

mysql_query("UPDATE `battle` SET `status` = 'off', `hp` = '0'  WHERE `usr`='".$user['nick']."' and `id`='$id'");
mysql_query("UPDATE `user` SET `mob`='0', `wins`=`wins`+'1' WHERE `id`='".$user['id']."'");
if(isset($_GET['whack'])){
$vrem = $_SERVER['REQUEST_TIME'] + $umen['time'];
if($umen['timer']>''.$_SERVER['REQUEST_TIME'].''){
$_SESSION['err'] = "Промах";
header ("Location: ?");
exit;
}
mysql_query("UPDATE `umen` SET `timer` = '".$vrem."' WHERE `usr`='".$user['id']."' and `img`='whack'");
$_SESSION['light']="Вы использовали <img src='/images/umen/whack.png' height='16px' width='16px'> <font color='#FFBF00'>Сильный Удар</font> против ".$mobc['name']." <img src='/images/icon/stat/hp.png'><font color='#F5E17E'>-".$udar."</font>";
} else{
$_SESSION['light']="Вы <img src='/images/icon/stat/sila.png'>".$sms." <img src='/images/icon/stat/hp.png'><font color='#F5E17E'>-".$udar."</font>";
}
$_SESSION['light']="Вы  <img src='/images/icon/dead.png'>".$ttud." ".$mobc['name']." <img src='/images/icon/stat/hp.png'><font color='#F5E17E'>-".$udar."</font>";
} else {
if(isset($_GET['whack'])){
$vrem = $_SERVER['REQUEST_TIME'] + $umen['time'];
if($umen['timer'] > $_SERVER['REQUEST_TIME']){
$_SESSION['err'] = "Промах";
header ("Location: ?");
exit;
}
mysql_query("UPDATE `umen` SET `timer` = '".$vrem."' WHERE `usr`='".$user['id']."' and `img`='whack'");
$_SESSION['light']="Вы использовали <img src='/images/umen/whack.png' height='16px' width='16px'> <font color='#FFBF00'>Сильный Удар</font> против ".$mobc['name']." <img src='/images/icon/stat/hp.png'><font color='#F5E17E'>-".$udar."</font>";
} else {
$_SESSION['light']="Вы <img src='/images/icon/stat/sila.png'>".$sms." <img src='/images/icon/stat/hp.png'><font color='#F5E17E'>-".$udar."</font>";
}
mysql_query("UPDATE `battle` SET `hp` = '".$uron."' WHERE `usr`='".$user['nick']."' and `id`='".$id."'");
}
$ud = mysql_num_rows(mysql_query("SELECT * FROM `bonus` WHERE `usr`='".$user['id']."' and `typ`='3'"));
if($ud > 0){
	$udar = $udar*2;
} else {
	$udar = $udar;
}
if($setgame['exp']==1)$udar = $udar*2;
mysql_query("UPDATE `user` SET `exp` = '".$user['exp']."'+".$udar.", `mob`='".$id."' WHERE `nick`='".$user['nick']."'");
header ("Location: ?");
exit;
}

require_once __DIR__ . '../../tend.php';

require_once'../../core/foot.php';
?>