View file sdark.mobi/hiking/ghost-trail/fight.php

File size: 38.13Kb
<?
require_once'../../core/system.php';
echo only_reg();
echo ban();
echo blok();
$header='Тропа Призраков';
require_once'../../core/head.php';
$time = time();
mysql_query("DELETE FROM `hik_otk` WHERE `time`<='".$time."'");
mysql_query("UPDATE `user` set `mesto` = 'Бой' where `id` = '".$user['id']."'");
mysql_query("DELETE FROM `hiking` WHERE `time`<='".$time."' and `status`='1'");

if($user['level'] < 50){
header('location: /'); 
$_SESSION['err'] = 'Доступно только с 50 уровня';
}
$req = mysql_query("SELECT * FROM `hiking` where (`lider`='".$user['id']."' || `usr1`='".$user['id']."' || `usr2`='".$user['id']."' || `usr3`='".$user['id']."')");
$hik = mysql_fetch_array($req);
$req = mysql_query("SELECT * FROM `battle` WHERE  `s`='".$hik['id']."' and `nextud`<='".$time."' and `status`='' LIMIT 10");
while($mobik = mysql_fetch_array($req)){
if($mobik['hp']>0 and $user['battle']==1){
$summastag = $user['max_health']+$user['sila']+$user['zashit']; 
$cp=$user['zashit']/$summastag;
$ym=1-$cp;
$um=rand($mobik['sila']-$mobik['sila']/8,$mobik['sila']);
$mudar=$um*$ym;
$muron=round($mudar,0);
$vrud=rand(1,3); 
if($vrud==1){$vrud='укусил';}
if($vrud==2){$vrud='поцарапал';}
if($vrud==3){$vrud='ударил';}
$vrutd=rand(1,4); 
if($vrutd==1){$vrutd='убил';}
if($vrutd==2){$vrutd='испепелил';}
if($vrutd==3){$vrutd='уничтожил';}
if($vrutd==4){$vrutd='растерзал';}
if($user['health']<$muron){
mysql_query("INSERT INTO `duellog` SET `usr`='".$user['nick']."',`text`='<font color=F26C13>".$mobik['name']."</font> ".$vrud."',`opon`='', `uron`='".$muron."', `timer`='".$time."'+'300',`kogo`='".$user['id']."', `umen`='".$um."'");
mysql_query("INSERT INTO `duellog` SET `usr`='".$user['nick']."',`text`='<font color=F26C13>".$mobik['name']."</font> ".$vrutd."', `timer`='".$time."'+'300', `dead`='1', `kogo`='".$user['id']."', `umen`='".$um."'");
mysql_query("UPDATE `user` SET `health` = '0', `loss`=`loss`+'1' WHERE `id`='".$user['id']."'");
}
if($user['health']>$muron){
$nextudar=rand(3,12);
$nextud=$time+$nextudar;
mysql_query("INSERT INTO `duellog` SET `usr`='".$user['nick']."',text='<font color=F26C13>".$mobik['name']."</font> ".$vrud."', opon='', `kogo`='".$user['id']."', `uron`='".$muron."', `timer`='".$time."'+'300', `umen`='".$um."'");
mysql_query("UPDATE `user` SET `health` = '".$user['health']."'-'".$muron."' WHERE `id`='".$user['id']."'");
mysql_query("UPDATE `battle` SET `nextud` = '".$nextud."' WHERE  `nextud`<='".$time."' and `status`='' and `name`='".$mobik['name']."'");
}
}
}
$req = mysql_query("SELECT * FROM `hiking` where (`lider`='".$user['id']."' || `usr1`='".$user['id']."' || `usr2`='".$user['id']."' || `usr3`='".$user['id']."')");
$hik = mysql_fetch_array($req);
$avto = mysql_num_rows($req);
if($avto==0){
$_SESSION['err'] = "Команда не найдена!";
header('Location: /');
exit;
}

if($hik['name']==4){$mijo='Тропа Призраков';}
if($mijo!=$header){
	$_SESSION['err'] = "Ошибка!";
header('Location: /');
exit;
}

$tjo = mysql_query("SELECT `status`,`vol` FROM `hik_otk` WHERE `usr`='".$user['id']."' and `hiking`='4'"); 
$avo = mysql_num_rows($tjo);
$otk = mysql_fetch_array($tjo);
if($avo > 0 && $otk['status']==1){
$_SESSION['err'] = "Поход уже пройден!";
header('Location: /');
exit;
}

$vrere = time() + 36000;


/* if($avo>0 && $otk['vol']>=5 && $otk['team']!=$hik['id'] && $otk['status']<1){
$_SESSION['err'] = "В прошлый раз поход не был завершен!";
header('Location: /');
exit;
} */

if($hik['vol']>=5 && $user['battle']==0 && $hik['fight']==1){
$_SESSION['err'] = "Нельзя войти, бой зашёл слишком далеко!";
header('Location: /');
exit;
}
if($user['mesto']!='Бой'){header ("Location: ?");}

if($hik['lider']==$user['id'] && $hik['fight']==0){
	mysql_query("UPDATE `hiking` set `vol`='1', `fight` = '1' where `id` = '".$hik['id']."'");
}


$timer=$_SERVER['REQUEST_TIME']+300;
$kols = mysql_result(mysql_query("SELECT  COUNT(*)  FROM `battle` WHERE  `s`='".$hik['id']."' and `status`=''"),0);

$ureq = mysql_query("SELECT * FROM `user` WHERE `id`='".$user['mob']."'");
$umob = mysql_fetch_array($ureq);
if($user['battle']==0 and $user['health']>0){
mysql_query("DELETE FROM `battle` WHERE `s`='".$hik['id']."'");
mysql_query("DELETE FROM `hik_us` WHERE `usr`='".$user['id']."'");
mysql_query("INSERT INTO `hik_us` SET `usr`='".$user['id']."', `hik`='".$hik['id']."'");
mysql_query("DELETE FROM `duellog` WHERE `usr`='".$user['nick']."'");
mysql_query("DELETE FROM `link` WHERE `usr`='".$user['id']."'");
mysql_query("INSERT INTO `link` SET `usr`='".$user['id']."',`timer`='".$_SERVER['REQUEST_TIME']."'+'3600', `link`='".$_SERVER['PHP_SELF']."'");
mysql_query("UPDATE `user` set `mob` = '', `battle`='1', `hexp`='0' where `id` = '".$user['id']."'");

header ("Location: ?");exit;
}

if($hik['vol']>$otk['vol']){
mysql_query("UPDATE `hik_otk` set `vol`='".$hik['vol']."' where `usr` = '".$user['id']."'");
}

$t=$_SERVER['REQUEST_TIME']+3600;
$nextudar=rand(1,17);
$nextud=$_SERVER['REQUEST_TIME']+$nextudar;
$nextudd=$_SERVER['REQUEST_TIME']+$nextudar+4;

if($hik['vol']==1 && $kols==0){
mysql_query("INSERT INTO `battle` SET  `name`='Призрак', `status`='', `s`='".$hik['id']."', `hpmax`='13000', `hp`='13000', `sila`='2000', `prot`='3600', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Призрак', `status`='', `s`='".$hik['id']."', `hpmax`='13000', `hp`='13000', `sila`='2000', `prot`='3600', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Призрак', `status`='', `s`='".$hik['id']."', `hpmax`='13000', `hp`='13000', `sila`='2000', `prot`='3600', `time`='".$t."', `nextud`='".$nextudd."'");
}


if($kols==0 and $hik['vol']==2  and $hik['otkat']<$tm){

mysql_query("INSERT INTO `battle` SET  `name`='Дух Воина', `status`='', `s`='".$hik['id']."', `hpmax`='12000', `hp`='12000', `sila`='1500', `prot`='13700', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Дух Воина', `status`='', `s`='".$hik['id']."', `hpmax`='12000', `hp`='12000', `sila`='1500', `prot`='13700', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Дух Воина', `status`='', `s`='".$hik['id']."', `hpmax`='12000', `hp`='12000', `sila`='1500', `prot`='13700', `time`='".$t."', `nextud`='".$nextudd."'");
mysql_query("INSERT INTO `battle` SET  `name`='Дух Воина', `status`='', `s`='".$hik['id']."', `hpmax`='12000', `hp`='12000', `sila`='1500', `prot`='13700', `time`='".$t."', `nextud`='".$nextudd."'");
mysql_query("INSERT INTO `battle` SET  `name`='Дух Воина', `status`='', `s`='".$hik['id']."', `hpmax`='12000', `hp`='12000', `sila`='1500', `prot`='13700', `time`='".$t."', `nextud`='".$nextudd."'");
mysql_query("INSERT INTO `battle` SET  `name`='Дух Воина', `status`='', `s`='".$hik['id']."', `hpmax`='12000', `hp`='12000', `sila`='1500', `prot`='13700', `time`='".$t."', `nextud`='".$nextudar."'");
mysql_query("INSERT INTO `battle` SET  `name`='Дух Воина', `status`='', `s`='".$hik['id']."', `hpmax`='12000', `hp`='12000', `sila`='1500', `prot`='13700', `time`='".$t."', `nextud`='".$nextudar."'");


}
if($kols==0 and $hik['vol']==3 and $hik['otkat']<$tm){

mysql_query("INSERT INTO `battle` SET  `name`='Дух Темного Воина', `status`='', `s`='".$hik['id']."', `hpmax`='20000', `hp`='20000', `sila`='3000', `prot`='9700', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Дух Темного Воина', `status`='', `s`='".$hik['id']."', `hpmax`='20000', `hp`='20000', `sila`='3000', `prot`='9700', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Дух Темного Воина', `status`='', `s`='".$hik['id']."', `hpmax`='20000', `hp`='20000', `sila`='3000', `prot`='9700', `time`='".$t."', `nextud`='".$nextudd."'");
mysql_query("INSERT INTO `battle` SET  `name`='Дух Темного Воина', `status`='', `s`='".$hik['id']."', `hpmax`='20000', `hp`='20000', `sila`='3000', `prot`='9700', `time`='".$t."', `nextud`='".$nextudd."'");
}
if($kols==0 and $hik['vol']==4 and $hik['otkat']<$tm){

mysql_query("INSERT INTO `battle` SET  `name`='Призрак', `status`='', `s`='".$hik['id']."', `hpmax`='13000', `hp`='13000', `sila`='2000', `prot`='3600', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Призрак', `status`='', `s`='".$hik['id']."', `hpmax`='13000', `hp`='13000', `sila`='2000', `prot`='3600', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Призрак', `status`='', `s`='".$hik['id']."', `hpmax`='13000', `hp`='13000', `sila`='2000', `prot`='3600', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Призрак', `status`='', `s`='".$hik['id']."', `hpmax`='13000', `hp`='13000', `sila`='2000', `prot`='3600', `time`='".$t."', `nextud`='".$nextud."'");
}

if($kols==0 and $hik['vol']==5 and $hik['otkat']<$tm){

mysql_query("INSERT INTO `battle` SET  `name`='Мертвец', `status`='', `s`='".$hik['id']."', `hpmax`='37000', `hp`='37000', `sila`='2500', `prot`='2570', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Мертвец', `status`='', `s`='".$hik['id']."', `hpmax`='37000', `hp`='37000', `sila`='2500', `prot`='2570', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Зараженный Мертвец', `status`='', `s`='".$hik['id']."', `hpmax`='700', `hp`='700', `sila`='6000', `prot`='2570', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Зараженный Мертвец', `status`='', `s`='".$hik['id']."', `hpmax`='700', `hp`='700', `sila`='6000', `prot`='2570', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Зараженный Мертвец', `status`='', `s`='".$hik['id']."', `hpmax`='700', `hp`='700', `sila`='6000', `prot`='2570', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Зараженный Мертвец', `status`='', `s`='".$hik['id']."', `hpmax`='700', `hp`='700', `sila`='6000', `prot`='2570', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Зараженный Мертвец', `status`='', `s`='".$hik['id']."', `hpmax`='700', `hp`='700', `sila`='6000', `prot`='2570', `time`='".$t."', `nextud`='".$nextud."'");

$yoka = mysql_result(mysql_query("SELECT COUNT(id) FROM `hik_otk` WHERE `usr`='".$user['id']."' and `hiking`='4'"),0);
if($yoka==0){
	mysql_query("INSERT INTO `hik_otk` SET `usr`='".$user['id']."', `hiking`='4', `time`='".$vrere."'");
} else {
	mysql_query("UPDATE `hik_otk` set `time` = '".$vrere."' where `usr` = '".$user['id']."' and `hiking`='4'");
}
}
if($kols==0 and $hik['vol']==6 and $hik['otkat']<$tm){

mysql_query("INSERT INTO `battle` SET `name`='Ползучий Кошмар', `status`='', `s`='".$hik['id']."', `hpmax`='45000', `hp`='45000', `sila`='3500', `prot`='27000', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET `name`='Ползучий Кошмар', `status`='', `s`='".$hik['id']."', `hpmax`='45000', `hp`='45000', `sila`='3500', `prot`='27000', `time`='".$t."', `nextud`='".$nextudd."'");
$yoka = mysql_result(mysql_query("SELECT COUNT(id) FROM `hik_otk` WHERE `usr`='".$user['id']."' and `hiking`='4'"),0);
if($yoka==0){
	mysql_query("INSERT INTO `hik_otk` SET `usr`='".$user['id']."', `hiking`='4', `time`='".$vrere."'");
} else {
	mysql_query("UPDATE `hik_otk` set `time` = '".$vrere."' where `usr` = '".$user['id']."' and `hiking`='4'");
}
}
if($kols==0 and $hik['vol']==7 and $hik['otkat']<$tm){

mysql_query("INSERT INTO `battle` SET  `name`='Химера', `status`='', `s`='".$hik['id']."', `hpmax`='30000', `hp`='30000', `sila`='2600', `prot`='20700', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Химера', `status`='', `s`='".$hik['id']."', `hpmax`='30000', `hp`='30000', `sila`='2600', `prot`='20700', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Химера', `status`='', `s`='".$hik['id']."', `hpmax`='30000', `hp`='30000', `sila`='2600', `prot`='20700', `time`='".$t."', `nextud`='".$nextudd."'");
mysql_query("INSERT INTO `battle` SET  `name`='Химера', `status`='', `s`='".$hik['id']."', `hpmax`='30000', `hp`='30000', `sila`='2600', `prot`='20700', `time`='".$t."', `nextud`='".$nextudd."'");

$yoka = mysql_result(mysql_query("SELECT COUNT(id) FROM `hik_otk` WHERE `usr`='".$user['id']."' and `hiking`='4'"),0);
if($yoka==0){
	mysql_query("INSERT INTO `hik_otk` SET `usr`='".$user['id']."', `hiking`='4', `time`='".$vrere."'");
} else {
	mysql_query("UPDATE `hik_otk` set `time` = '".$vrere."' where `usr` = '".$user['id']."' and `hiking`='4'");
}
}
if($kols==0 and $hik['vol']==8 and $hik['otkat']<$tm){

mysql_query("INSERT INTO `battle` SET  `name`='Одинокий Призрак', `status`='', `s`='".$hik['id']."', `hpmax`='70000', `hp`='70000', `sila`='4500', `prot`='47000', `time`='".$t."', `nextud`='".$nextud."'");
$yoka = mysql_result(mysql_query("SELECT COUNT(id) FROM `hik_otk` WHERE `usr`='".$user['id']."' and `hiking`='4'"),0);
if($yoka==0){
	mysql_query("INSERT INTO `hik_otk` SET `usr`='".$user['id']."', `hiking`='4', `time`='".$vrere."'");
} else {
	mysql_query("UPDATE `hik_otk` set `time` = '".$vrere."' where `usr` = '".$user['id']."' and `hiking`='4'");
}	
}
if($kols==0 and $hik['vol']==9 and $hik['otkat']<$tm){
mysql_query("INSERT INTO `battle` SET  `name`='Дух Воина', `status`='', `s`='".$hik['id']."', `hpmax`='12000', `hp`='12000', `sila`='1500', `prot`='13700', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Дух Воина', `status`='', `s`='".$hik['id']."', `hpmax`='12000', `hp`='12000', `sila`='1500', `prot`='13700', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Дух Воина', `status`='', `s`='".$hik['id']."', `hpmax`='12000', `hp`='12000', `sila`='1500', `prot`='13700', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Дух Воина', `status`='', `s`='".$hik['id']."', `hpmax`='12000', `hp`='12000', `sila`='1500', `prot`='13700', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Дух Воина', `status`='', `s`='".$hik['id']."', `hpmax`='12000', `hp`='12000', `sila`='1500', `prot`='13700', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET  `name`='Дух Воина', `status`='', `s`='".$hik['id']."', `hpmax`='12000', `hp`='12000', `sila`='1500', `prot`='13700', `time`='".$t."', `nextud`='".$nextudd."'");

$yoka = mysql_result(mysql_query("SELECT COUNT(id) FROM `hik_otk` WHERE `usr`='".$user['id']."' and `hiking`='4'"),0);
if($yoka==0){
	mysql_query("INSERT INTO `hik_otk` SET `usr`='".$user['id']."', `hiking`='4', `time`='".$vrere."'");
} else {
	mysql_query("UPDATE `hik_otk` set `time` = '".$vrere."' where `usr` = '".$user['id']."' and `hiking`='4'");
}
}

if($kols==0 and $hik['vol']==10 and $hik['otkat']<$tm){
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Ловец Душ', `status`='', `s`='".$hik['id']."', `hpmax`='170000', `hp`='170000', `sila`='5000', `prot`='12070', `time`='".$t."', `nextud`='".$nextudd."', `boss`='1'");
mysql_query("INSERT INTO `battle` SET `name`='Дух Темного Воина', `status`='', `s`='".$hik['id']."', `hpmax`='20000', `hp`='20000', `sila`='3000', `prot`='9700', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET `name`='Дух Темного Воина', `status`='', `s`='".$hik['id']."', `hpmax`='20000', `hp`='20000', `sila`='3000', `prot`='9700', `time`='".$t."', `nextud`='".$nextud."'");
mysql_query("INSERT INTO `battle` SET `name`='Дух Темного Воина', `status`='', `s`='".$hik['id']."', `hpmax`='20000', `hp`='20000', `sila`='3000', `prot`='9700', `time`='".$t."', `nextud`='".$nextudd."'");
mysql_query("INSERT INTO `battle` SET `name`='Дух Темного Воина', `status`='', `s`='".$hik['id']."', `hpmax`='20000', `hp`='20000', `sila`='3000', `prot`='9700', `time`='".$t."', `nextud`='".$nextudd."'");

$yoka = mysql_result(mysql_query("SELECT COUNT(id) FROM `hik_otk` WHERE `usr`='".$user['id']."' and `hiking`='4'"),0);
if($yoka==0){
	mysql_query("INSERT INTO `hik_otk` SET `usr`='".$user['id']."', `hiking`='4', `time`='".$vrere."'");
} else {
	mysql_query("UPDATE `hik_otk` set `time` = '".$vrere."' where `usr` = '".$user['id']."' and `hiking`='4'");
}
}

 
if($kols==0 and $hik['vol']==11 and $hik['otkat']<$tm){
if($user['clan'] > 0){
mysql_query("UPDATE `clan` SET `rating`=`rating`+'25' WHERE `id`='".$user['clan']."'");
}/* 
$_SESSION['light'] = "Вы получили <img src='/images/icon/key.png'>1";//,`snow`=`snow`+'1' */
mysql_query("UPDATE `user` SET `rating`=`rating`+'25', `gold`=`gold`+'200' WHERE `id`='".$user['id']."'");
mysql_query("UPDATE `hik_otk` set `time` = '".$vrere."', `status`='1' where `usr` = '".$user['id']."' and `hiking`='4'");

mysql_query("UPDATE `hiking` SET `time` = '".$vrere."', `status` = '1' WHERE `id`='".$hik['id']."'");

header ("Location: /hiking/ghost-trail/");
exit;
} 
	
if($user['battle']==0){
$_SESSION['err'] = ' Вы не находитесь в бою';
header ("Location: /");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'])){
$ureq = mysql_query("SELECT * FROM `battle` WHERE  `s`='".$hik['id']."' and `id`='".$id."'");
$mobc = mysql_fetch_array($ureq);
if(empty($id)){$_SESSION['err']="Не выбран противник";
header ("Location: ?");exit;}
if($mobc['hp']<=0 or $user['health']<=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<0.8){$_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='победили';}
/* $whack = mysql_num_rows(mysql_query("SELECT * FROM `task` WHERE `usr`='".$user['id']."' and `status`='2' and `task`='25'"));
if($whack>0){mysql_query("UPDATE `task` SET `min` = `min`+'1'  WHERE `usr`='".$user['id']."' and `status`='2' and `task`='25'");}
  */
$ureq = mysql_query("SELECT * FROM `battle` WHERE  `s`='".$hik['id']."' and `boss`='1'");
$rbc = mysql_fetch_array($ureq);

if($mobc['boss']<1 and $hik['vol']==10 and $rbc['hp']>0){
mysql_query("INSERT INTO `battle` SET `name`='Дух Темного Воина', `status`='', `s`='".$hik['id']."', `hpmax`='20000', `hp`='20000', `sila`='3000', `prot`='9700', `time`='".$t."', `nextud`='".$nextudd."'");
mysql_query("INSERT INTO `battle` SET `name`='Дух Темного Воина', `status`='', `s`='".$hik['id']."', `hpmax`='20000', `hp`='20000', `sila`='3000', `prot`='9700', `time`='".$t."', `nextud`='".$nextudd."'");
} 
$kos = mysql_result(mysql_query("SELECT  COUNT(*)  FROM `battle` WHERE  `s`='".$hik['id']."'  and `status`=''"),0);
if($kos==1){
	$lala = $tm + rand(1,4);
	mysql_query("UPDATE `hiking` set   `otkat` = '".$lala."', `vol` = `vol`+'1' where `id` = '".$hik['id']."'");
}
if($hik['vol']==10 and $mobc['boss']==1){

$laka = rand(1,8);
if($laka == 1) {

mysql_query("INSERT INTO `kompl_us` set `type` = 'голова', `komplekt`='103', `id_komp` = '131', `id_us` = '".$user['id']."', `sila`='180', `prot`='180', `hp`='180', `fleece`='0'");
mysql_query("INSERT INTO `hik_gift` set `usr` = '".$user['id']."', `hik`='".$hik['id']."', `weapon`  = '131', `time`='".$vrere."'"); 

}

if($laka == 2) {

mysql_query("INSERT INTO `kompl_us` set `type` = 'плечи', `komplekt`='103', `id_komp` = '132', `id_us` = '".$user['id']."', `sila`='180', `prot`='180', `hp`='180', `fleece`='0'");
mysql_query("INSERT INTO `hik_gift` set `usr` = '".$user['id']."', `hik`='".$hik['id']."', `weapon`  = '132', `time`='".$vrere."'"); 

}

if($laka == 3) {

mysql_query("INSERT INTO `kompl_us` set `type` = 'тело', `komplekt`='103', `id_komp` = '133', `id_us` = '".$user['id']."', `sila`='180', `prot`='180', `hp`='180', `fleece`='0'");
mysql_query("INSERT INTO `hik_gift` set `usr` = '".$user['id']."', `hik`='".$hik['id']."', `weapon`  = '133', `time`='".$vrere."'"); 

}

if($laka == 4) {

mysql_query("INSERT INTO `kompl_us` set `type` = 'рука 2', `komplekt`='103', `id_komp` = '135', `id_us` = '".$user['id']."', `sila`='180', `prot`='180', `hp`='180', `fleece`='0'");
mysql_query("INSERT INTO `hik_gift` set `usr` = '".$user['id']."', `hik`='".$hik['id']."', `weapon`  = '135', `time`='".$vrere."'"); 

}

if($laka == 5) {

mysql_query("INSERT INTO `kompl_us` set `type` = 'рука 1', `komplekt`='103', `id_komp` = '134', `id_us` = '".$user['id']."', `sila`='180', `prot`='180', `hp`='180', `fleece`='0'");
mysql_query("INSERT INTO `hik_gift` set `usr` = '".$user['id']."', `hik`='".$hik['id']."', `weapon`  = '134', `time`='".$vrere."'"); 

}

if($laka == 6) {

mysql_query("INSERT INTO `kompl_us` set `type` = 'ноги', `komplekt`='103', `id_komp` = '136', `id_us` = '".$user['id']."', `sila`='180', `prot`='180', `hp`='180', `fleece`='0'");
mysql_query("INSERT INTO `hik_gift` set `usr` = '".$user['id']."', `hik`='".$hik['id']."', `weapon`  = '136', `time`='".$vrere."'"); 

}

if($laka == 7) {

mysql_query("INSERT INTO `kompl_us` set `type` = 'кольцо', `komplekt`='103', `id_komp` = '137', `id_us` = '".$user['id']."', `sila`='180', `prot`='180', `hp`='180', `fleece`='0'");
mysql_query("INSERT INTO `hik_gift` set `usr` = '".$user['id']."', `hik`='".$hik['id']."', `weapon`  = '137', `time`='".$vrere."'"); 

}

if($laka == 8) {

mysql_query("INSERT INTO `kompl_us` set `type` = 'шея', `komplekt`='103', `id_komp` = '138', `id_us` = '".$user['id']."', `sila`='180', `prot`='180', `hp`='180', `fleece`='0'");
mysql_query("INSERT INTO `hik_gift` set `usr` = '".$user['id']."', `hik`='".$hik['id']."', `weapon`  = '138', `time`='".$vrere."'"); 

}


}

mysql_query("UPDATE `battle` SET `status` = 'off', `hp` = '0'  WHERE  `s`='".$hik['id']."' 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>";
$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."',`hexp` = '$user[hexp]'+'".$udar."', `mob`='".$id."' WHERE `id`='".$user['id']."'");

header ("Location: ?");exit;
} 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 `s`='".$hik['id']."' 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;	
}
mysql_query("UPDATE `user` SET `exp` = '$user[exp]'+'".$udar."',`hexp` = '$user[hexp]'+'".$udar."', `mob`='".$id."' WHERE `id`='".$user['id']."'");
header ("Location: ?");exit;
}
}
if($user['health']<=0){
echo"</div><div  class='but-list'>
<a href=\"?\"> <img src='/images/icon/reload.png'> Обновить </a></font>
<a href=\"/\"> <img src='/images/icon/error.png'> Покинуть бой </a></div></div>";
} else {
	
$ureq = mysql_query("SELECT * FROM `battle` WHERE  `s`='".$hik['id']."' and `id`='".$user['mob']."'");
$umob = mysql_fetch_array($ureq);
$avt = mysql_num_rows($ureq);
if($avt>0){
echo'<div class="foot"><table  width="100%">
<tbody>
<td class="center"><div class="empty2"></div>';
 if($umob['boss']==1){echo"<font color='orange'>".$umob['name']."</font>";}
if($umob['boss']!=1){echo"".$umob['name']."";}
 echo'<div class="empty2"></div>';
$kol70=$umob['hpmax']*0.70;
$kol30=$umob['hpmax']*0.30;
if($umob['hp']>=$kol70){$health="green";}
if($umob['hp']>=$kol30 and $umob['hp']<$kol70){$health="orange";}
if($umob['hp']<$kol30){$health="red";}
echo"<div class='hp'>
<div class='".$health."' style='width:".floor(100/($umob['hpmax']/$umob['hp']))."%'></div>
</div>";
echo'<div class="empty2"></div><div class="empty2"></div><font color="#CDC9C9"> ('.$umob['hp'].'/'.$umob['hpmax'].')</font></td>
</tbody></table></div><hr>
';}
echo"<div class='head'><table  width='100%' border='0' cellpadding='5px' cellspacing='0' style='padding-top: 5px;'>
<tbody>";

$randomob = mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `s`='".$hik['id']."' and `status`='' ORDER BY RAND() LIMIT 1"),0);
 
if($kols==0){echo'<td width="45%"><a class="fight center" href="?">  Обновить  </a></div></td>';}
if($kols==1 and $umob['hp']>0){echo' <td width="45%"><a class="fight center" href="?udar&id='.$umob['id'].'">  Атаковать  </a></div></td>';}
if($kols==1 and $umob['hp']<=0){echo' <td width="45%"><a class="fight center" href="?udar&id='.$randomob['id'].'">  Атаковать  </a></div></td>';}
if($kols>1){
if($user['mob']>0 and $umob['hp']>0){echo' <td width="45%"><a class="fight center" href="?udar&id='.$umob['id'].'">  Атаковать  </a></div></td>';}
echo' <td width="45%"><a class="fight center" href="?udar&id='.$randomob['id'].'">  Бить любого  </a></div></td>';}
echo"</tbody></table><table  width='100%' border='0' cellpadding='1px' cellspacing='0' style='padding-top: 5px;'>
<tbody>";
$req = mysql_query("SELECT timer FROM `umen` WHERE `usr` = '".$user['id']."' and `img`='whack' LIMIT 1");
$umen = mysql_fetch_array($req);
$avto = mysql_num_rows($req);
if($avto == 0){
echo"<td width='30%'><div class='big-but'><div class='imgwrap'><img src='/images/umen/whack_grey.png' height='20' width='20'></div><div class='empty'></div>Недоступно</td></div>"; 
}
if($avto > 0){
if($umen['timer']<= $_SERVER['REQUEST_TIME']){
if($umob['hp'] > 0){
echo"<td width='30%'>
<a class='big-but' href=\"?udar&whack&id=".$umob['id']."\">
<div class='imgwrap'><img src='/images/umen/whack.png' height='35' width='35'>
</div> 
<div class='empty'></div> 
</a>
</td>
</div>";
}
if($umob['hp'] <= 0){	
echo"<td width='30%'>
<a class='big-but' href=\"?udar&whack&id=".$randomob['id']."\"><div class='imgwrap'><img src='/images/umen/whack.png' height='35' width='35'>
</div> 
<div class='empty'>	</div> 
</a>
</td>
</div>";
} 
} else {
$recharge = $umen['timer'] - $_SERVER['REQUEST_TIME'];
echo"<td width='30%'><div class='big-but'><div class='imgwrap'><img src='/images/umen/whack_grey.png' height='20' width='20'></div>
<div class='empty'></div>".$recharge." сек</td>
</div>";
}
}
$req = mysql_query("SELECT timer FROM `umen` WHERE `usr` = '".$user['id']."' and `img`='healing'");
$umen = mysql_fetch_array($req);
$avto = mysql_num_rows($req);
if($avto==0){
echo'<td width="30%"><div class="big-but"><div class="imgwrap"><img src="/images/umen/healing_grey.png" height="20" width="20"></div><div class="empty"></div>Недоступно</td></div>'; 
} else {
if($umen['timer'] <= $_SERVER['REQUEST_TIME']){
echo'<td width="30%"><a class="big-but" href=\'?healing\'><div class="imgwrap"><img src="/images/umen/healing.png" height="35" width="35"></div><div class="empty"></div></a></td></div>'; 
} else {
$recharge=$umen['timer']-$_SERVER['REQUEST_TIME'];
echo' <td width="30%"><div class="big-but"><div class="imgwrap"><img src="/images/umen/healing_grey.png" height="20" width="20"></div>
<div class="empty"></div>'.$recharge.' сек</td>
</div>';
}
}
$req = mysql_query("SELECT timer FROM `umen` WHERE `usr` = '".$user['id']."' and `img`='gift_of_the_Gods'");
$umen = mysql_fetch_array($req);
$avto = mysql_num_rows($req);
if($avto==0){
echo'<td width="30%"><div class="big-but"><div class="imgwrap"><img src="/images/umen/gift_of_the_Gods_grey.png" height="20" width="20"></div><div class="empty"></div>Недоступно</td></div>'; 
} else {
if($umen['timer'] <= $_SERVER['REQUEST_TIME']){
echo'<td width="30%"><a class="big-but" href=\'?gift_of_the_Gods\'><div class="imgwrap"><img src="/images/umen/gift_of_the_Gods.png" height="35" width="35"></div><div class="empty"></div></a></td></div>'; 
} else {
$recharge=$umen['timer']-$_SERVER['REQUEST_TIME'];
echo'<td width="30%"><div class="big-but"><div class="imgwrap"><img src="/images/umen/gift_of_the_Gods_grey.png" height="20" width="20"></div>
<div class="empty"></div>'.$recharge.' сек</td>
</div>';
}
}
echo'</td></tbody></table></td>
</tbody>
</table><table width="100%" cellpadding="4px">
<tbody><tr><td width="30%">
<a class="inpc-ar center" href="?bottle=1"><div class="imgwrap"><img src="/images/icon/bottle/0.png">
</div> 
<div class="empty"></div> 
</a>
</td>
<td width="30%"><a class="inpc-ar center" href="?bottle=2"><div class="imgwrap"><img src="/images/icon/bottle/0.png"></div><div class="empty"></div></a></td>
<td width="30%"><a class="inpc-ar center" href="?bottle=3"><div class="imgwrap"><img src="/images/icon/bottle/0.png"></div><div class="empty"></div></a></td>
</tr></tbody>
</table></div>';
}

$requ = mysql_query("SELECT id,prava,font,nick,health,max_health,hexp FROM `user` WHERE (`id`='".$hik['lider']."' || `id`=".$hik['usr1']." || `id`=".$hik['usr2']." || `id`=".$hik['usr3'].") and `id`!=".$user['id']." and `mesto`='Бой'  LIMIT 3");
$avto = mysql_num_rows($requ);
if($avto>0){
echo"<hr><div class='foot foot'><div class='center'>Союзники</br><div class='empty2'></div></div>";
while($ank = mysql_fetch_array($requ)){
$kol70=$ank['max_health']*0.7; 
$kol30=$ank['max_health']*0.3; 
if($ank['health']>=$kol70){$hp='<font color="green">'.$ank['health'].'</font>';}
if($ank['health']>=$kol30 and $ank['health']<$kol70){$hp='<font color="orange">'.$ank['health'].'</font>';}
if($ank['health']<$kol30){$hp='<font color="red">'.$ank['health'].'</font>';}
if($post['prava']=="5"){$status="<font color='ffc22b'>[A]</font>";$color="#F7990D";}
if($post['prava']=="4"){$status="<font color='ffc22b'>[a]</font>";$color="EBC621";}
if($post['prava']=="3"){$status="<font color='ffc22b'>[M]</font>";}
if($post['prava']=="2"){$status="<font color='ffc22b'>[m]</font>";}
echo"<a class='inpc-ar' href='/user/".$ank['id']."/'>";
echo online($ank['id']);
echo"<font color='".$ank['font']."'> ".$ank['nick']."</font>";
if($ank['prava']>"1"){echo" ".$status."";}
 echo"<font color='grey'> (".$hp.")</font> <span class='float-right'><img src='/images/icon/exp.png'>".$ank['hexp']."</span></a>";
}echo"</div>";}

$requ = mysql_query("SELECT * FROM `battle` WHERE `s`='".$hik['id']."' and `status`=''  ");
$avto = mysql_num_rows($requ);
if($avto>0){
echo"<hr><div class='foot foot'><div class='center'>Противники</br><div class='empty2'></div></div>";
$req = mysql_query("SELECT DISTINCT `name` FROM `battle` WHERE  `s`='".$hik['id']."' and `status`='' ");
while($mob = mysql_fetch_array($req)){
$randomobu = mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE  `name`='".$mob['name']."' and `s`='".$hik['id']."' and `status`='' ORDER BY RAND() LIMIT 1"),0);
$kol70=$randomobu['hpmax']*0.7; 
$kol30=$randomobu['hpmax']*0.3; 
if($randomobu['hp']>=$kol70){$health="green";$hp="<font color='green'>".$randomobu['hp']."</font>";}
if($randomobu['hp']>=$kol30 and $randomobu['hp']<$kol70){$health="orange";$hp="<font color='orange'>".$randomobu['hp']."</font>";}
if($randomobu['hp']<$kol30){$health="red";$hp="<font color='red'>".$randomobu['hp']."</font>";}
$koll = mysql_result(mysql_query("SELECT  COUNT(*)  FROM `battle` WHERE `name`='".$mob['name']."' and `s`='".$hik['id']."' and `status`=''"),0);
if($koll>1){
echo"<a class='fight' href='?udar&id=".$randomobu['id']."'>".$mob['name']." <font color='#CDC9C9'>(".$koll.")</font></a>";}else{
if($randomobu['boss']=='1'){echo"<a class='fight' href='?udar&id=".$randomobu['id']."'><font color='orange'>".$mob['name']."</font> (".$hp.")</a>";}
if($randomobu['boss']!='1'){echo"<a class='fight' href='?udar&id=".$randomobu['id']."'>".$mob['name']." (".$hp.")</a>";}}
}echo"</div>";}

$req = mysql_query("SELECT * FROM `duellog` WHERE (`kogo` = '".$user['id']."' and `del2`!='1') or (`usr` = '".$user['nick']."' and `del1`!='1') and `timer`>='".$_SERVER['REQUEST_TIME']."' ORDER BY `id` DESC LIMIT 9");
$avto = mysql_num_rows($req);
if($user['plem']=='ogn'){$race=0;$pik='ogn';$race2=1;$pik2='mol';}
if($user['plem']=='mol'){$race=1;$pik='mol';$race2=0;$pik2='ogn';}
if($avto>=1){
echo"<hr><div class='foot foot'><div class='center'>Журнал боя</br><div class='empty2'></div></div>";
While($ilok = mysql_fetch_array($req)){
$timeudar=$_SERVER['REQUEST_TIME']-$ilok['timer']+300;
if($timeudar<60){
$timeudar=''.$timeudar.' сек.';
}else{
$timeudar=round($timeudar/60);
$timeudar=''.$timeudar.' мин.';
}

if($ilok['kogo']>0){
if($user['plem']=='ogn'){$plem='0';}
if($user['plem']=='mol'){$plem='1';}
if($ilok['dead']==1){echo '<img src="/images/icon/dead.png" height="16" width="16">
<font color="#AAAAAA"> '.$ilok['text'].' <img src=/images/icon/race/'.$plem.'.png><a href="/user/'.$user['id'].'/"><font color="'.$user['font'].'">'.$user['nick'].'</font></a></font><span class="mit">'.$timeudar.'</span>  <div class="empty"></div>';}else{
echo'<font color="#AAAAAA"> '.$ilok['text'].' <img src=/images/icon/race/'.$plem.'.png><a href="/user/'.$user['id'].'/"><font color="'.$user['font'].'">'.$user['nick'].'</font></a> на <font color="F5E17E">'.$ilok['uron'].'</font> урона</font><span class="mit">'.$timeudar.'</span>  <div class="empty"></div>';}}

}}
echo"</div>";





 
echo'<hr><div class="head center"><a class="fight" href="/hiking/ghost-trail/?exit"> Покинуть команду</a></div>';


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