Файл: battle.mob.php
Строк: 98
<?php
require ('lib/core.php');
$title="$log: Бой";
require ('theme/header.php');
require ('lib/zag.php');
error_reporting(E_ALL | E_STRICT);
if (ini_get('display_errors') != 1) {
ini_set('display_errors', 1);
};
// расшифровуем
$hid = dsCrypt($_GET['id'], 1);
//отделяем
$mid = explode('mob', $hid);
//получаем ид
$mobid = $mid['1'];
// фильтруем
$mob_id = (int)htmlspecialchars(strip_tags($mobid));
// проверяем на существование
$q = mysql_query("SELECT * FROM `l2_all_mobs` WHERE `id`='".mysql_real_escape_string($mob_id)."'");
// если существует,перенаправляем
if(mysql_num_rows($q)>='1'){
$mob = mysql_fetch_assoc($q);
}else{
// если не существует,в меню
setsession('url_error', "<font color=red>Ошибка, сессия или ссылка устарели</font><hr>");
header('Location: /main');
exit;
}
mysql_query("UPDATE `l2_all_mobs` SET `user`='$uid' WHERE `id`='$mob[id]'");
$mbid=$mob['id'];
if($mob['user']!=='0' and $mob['user']!==$uid){
header('Location: /main');
exit;
}
$url_g = dsCrypt('mob'.$mob['id']);
$last=time()+150;
mysql_query("UPDATE `l2_all_mobs` SET `last`='$last' WHERE `id`='$mob[id]'");
switch($sd){
default:
echo "<img src='/pic/mob/$mob[race].jpg' width='16'> ";
$q = mysql_query("SELECT * FROM `l2_battle_log` WHERE `user`='$uid' ORDER BY `id` DESC LIMIT 1");
if(mysql_num_rows($q)>='1'){
while($w = mysql_fetch_assoc($q)){
echo " $w[text] ";
mysql_query("DELETE FROM `l2_battle_log` WHERE `user`='$uid'");
}
}
$l4=$user['level']-4;
$l7=$user['level']-7;
$l9=$user['level']-9;
$ll4=$user['level']+4;
$ll7=$user['level']+7;
$ll9=$user['level']+9;
$l2=$user['level']-2;
$ll2=$user['level']+2;
if($mob['level']>=$l9){$mc = "<font color=blue>";}
if($mob['level']>=$l7){$mc = "<font color=#6666FF>";}
if($mob['level']>=$l4){$mc = "<font color=#33CC33>";}
if($mob['level']>=$l2 or $mob['level']>=$ll2){$mc = "<font color=white>";}
if($mob['level']>=$ll4){$mc = "<font color=yellow>";}
if($mob['level']>=$ll7){$mc = "<font color=#CC6666>";}
if($mob['level']>=$ll9){$mc = "<font color=red>";}
if($user['translate']=='0'){echo "$mc $mob[lat]</font> ";}
if($user['translate']=='1'){echo "$mc $mob[name]</font> ";}
echo "<small>($mob[level] ур. <font color=red>$mob[hp]</font>/<font color=red>$mob[hpall]</font>)</small>";
$mhp = ($mob['hp']/$mob['hpall'])*100;
echo '
<div class="status_style status_mob" style="margin-bottom:1px;margin-top:3px; background-color:#54422C;">
<div class="status_style status_mob" style="width:'.$mhp.'%; background-color:red;"></div>
</div><hr>';
echo "<img src='/pic/Swords.png'> <a href='/battle.mob/patt/?id=$url_g'>Физическая атака</a><hr>";
echo "<ul class='list'><li><a href='/battle.mob/escape/?id=$url_g'>Сбежать (<small>-50%<font color=red>HP</font>)</a></small></li></ul>";
break;
/** Физическая атака **/
case 'patt':
if($user['spec']=='war'){$my_att=$my_patt;$my_def=$my_pdef;$mob_att=$mob['patt'];$mob_def=$mob['pdef'];}
if($user['spec']=='wizard'){$my_att=$my_matt;$my_def=$my_mdef;$mob_att=$mob['matt'];$mob_def=$mob['mdef'];}
$uron=$my_att-$mob_def;
if($uron<'0'){$uron=0;}
$mob_uron=$mob_att-$my_def;
if($mob_uron<'0'){$mob_uron=0;}
mysql_query("UPDATE `l2_all_mobs` SET `hp`=`hp`-'$uron' WHERE `id`='$mob[id]'");
mysql_query("UPDATE `l2_user` SET `hp`=`hp`-'$mob_uron' WHERE `id`='$uid'");
if($mob['hp']<='0' or $mob['hp']<=$uron){
header("Location: /battle.mob/win/?id=$url_g");
exit;
}
if($uron>'0'){
$ltext="<font size=2 color=lightgreen>-$uron</font>";
}
if($mob_uron>'0'){
$ltext2="<font size=2 color=red>-$mob_uron</font>";
}
@$text="$ltext $ltext2";
mysql_query("INSERT INTO `l2_battle_log` SET `user`='$uid',`text`='$text'");
header("Location: /battle.mob/?id=$url_g");
exit;
break;
/** победа **/
case 'win':
if($mob['hp']>'0'){
header("Location: /battle.mob/?id=$url_g");
exit;
}
$timeleft=time()+180;
mysql_query("UPDATE `l2_all_mobs` SET `hp`='0',`time`='$timeleft',`user`='0' WHERE `id`='$mob[id]'");
$exp=win_exp($mob['exp']);
$win_aden=mt_rand($mob['min_aden'],$mob['max_aden']);
$aden=win_aden($win_aden);
$sp=win_sp($mob['sp']);
mysql_query("UPDATE `l2_user` SET `exp`=`exp`+'$exp',`aden`=`aden`+'$aden',`sp`=`sp`+'$sp',`win`=`win`+'1',`vp`=`vp`-'0.01' WHERE `id`='$uid'");
setsession('win', "<div class='infob'><font color=lightgreen>Победа</font></div><div class='persb'><img src='/pic/dropaden.png'> <small>".cena($aden)."</small><br><img src='/pic/dropexp.png'> <small>".number_format($exp)."</small><br><img src='/pic/dropsp.png'> <small>".number_format($sp)."</small></div>");
header('Location: /zal');
exit;
break;
case 'escape':
mysql_query("UPDATE `l2_all_mobs` SET `user`='0',`hp`=`hpall` WHERE `id`='$mob[id]'");
$eshp=round(($user['hp']/100)*50);
mysql_query("UPDATE `l2_user` SET `hp`=`hp`-'$eshp' WHERE `id`='$uid'");
header('Location: /zal');
exit;
break;
}
require ('lib/down.php');
require ('theme/foot.php');
?>