
<?
$ma1 = mysql_query("SET NAMES cp1251");
$ma1 = mysql_query("SELECT * FROM magic_slots WHERE S_NICK=\"$_SESSION[s]\" AND S_KEY_MAGIC=\"$ski\"");
$ma2 = mysql_fetch_assoc($ma1);
$mobs = mysql_query("SET NAMES cp1251");
$mobs = mysql_query("SELECT * FROM mobs_world WHERE MOBSid=\"$src\"");
$mobs2 = mysql_fetch_assoc($mobs);
$ptime = time(); 
if($ski == 'm.kbf' AND mysql_num_rows($magA)>0){
if($ma2[S_TIME_NEED]>=$ptime){
$lU = mysql_query("SET NAMES cp1251");
$src = trim($src);
$lU = mysql_query("INSERT INTO logs (COU_DMG,POPAL_ILI_NET,NAPADENIE,DEFENDER,L_TIME,L_LOC,L_KEY) VALUES ('заклинание *клеймо божественного пламени* ',' еще не восстановилось','$_SESSION[s]','','$vremya','$nnick2[loc]','$src')");

}
$us = mysql_query("SET NAMES cp1251");
$us =mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
$us2 = mysql_fetch_assoc($us);
$mb = mysql_query("SET NAMES cp1251");
$mb =mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
if($buffs2[S_LVL_MAGIC]=='1'){$min = 90;    $max = 90;   $sw = "FIRE"; $mp = 120;}
if($buffs2[S_LVL_MAGIC]=='2'){$min = 70;   $max = 240;   $sw = "FIRE"; $mp = 180;}
if($buffs2[S_LVL_MAGIC]=='3'){$min = 105;   $max = 310;   $sw = "FIRE"; $mp = 240;}
if($buffs2[S_LVL_MAGIC]=='4'){$min = 140;   $max = 380;  $sw = "FIRE"; $mp = 300;}
if($buffs2[S_LVL_MAGIC]=='5'){$min = 175;   $max = 450;  $sw = "FIRE"; $mp = 360;}
if($buffs2[S_LVL_MAGIC]=='6'){$min = 210;   $max = 520;  $sw = "FIRE"; $mp = 420;}
if($buffs2[S_LVL_MAGIC]=='7'){$min = 245;   $max = 590;  $sw = "FIRE"; $mp = 480;}
if($buffs2[S_LVL_MAGIC]=='8'){$min = 280;  $max = 660;  $sw = "FIRE"; $mp = 540;}
if($buffs2[S_LVL_MAGIC]=='9'){$min = 315;  $max = 730;  $sw = "FIRE"; $mp = 600;}
if($buffs2[S_LVL_MAGIC]=='10'){$min = 340; $max = 920;  $sw = "FIRE"; $mp = 660;}
$sf2=rand($min,$max);//дмг
$pint = round($us2[SKILL_INT]/2);
$pint2 = round(($sf2*$pint)/100);
$krit = 3;
$pikr = round($pint2*2);
$kritR = rand(0,100);
$ok = rand(0,100);
$okS = 85;
$FIRE = rand(0,$mob2[MD_FIRE]);
$mbD = round($pint2-$FIRE);
if(mysql_num_rows($magA)>0 AND $us2[MINmp]<$mp){
$lU = mysql_query("SET NAMES cp1251");
$lU = mysql_query("INSERT INTO logs (COU_DMG,POPAL_ILI_NET,NAPADENIE,DEFENDER,L_TIME,L_LOC,L_KEY) VALUES ('клеймо божественного пламени',' <font color=\"red\">(недостаточно маны)</font>','$_SESSION[s]','','$vremya','$nnick2[loc]','$src')");
}

if(mysql_num_rows($magA)>0 AND $krit<$kritR AND $us2[MINmp]>=$mp AND $okS>$ok AND $FIRE>=$pint2 AND $ma2[S_TIME_NEED]<$ptime AND $mobs2[mb_MINhp]>$mbD){

$mpen=$us2[MINmp]-$mp;
$mp = mysql_query("SET NAMES cp1251");
$mp =mysql_query("UPDATE users SET MINmp=\"$mpen\" WHERE NICK=\"$_SESSION[s]\"");
$lU = mysql_query("SET NAMES cp1251");
$lU = mysql_query("INSERT INTO logs (COU_DMG,POPAL_ILI_NET,NAPADENIE,DEFENDER,L_TIME,L_LOC,L_KEY) VALUES ('- 0',' <font color=\"red\">(клеймо божественного пламени) </font>','$_SESSION[s]','$mobs2[MOBSname]','$vremya','$nnick2[loc]','$src')");
$ma3 = time()+$ma2[S_RESSURECTION];
$resp = mysql_query("SET NAMES cp1251");
$resp = mysql_query("UPDATE magic_slots SET S_TIME_NEED=\"$ma3\" WHERE S_KEY_MAGIC=\"$ski\"");
}
if(mysql_num_rows($magA)>0 AND $krit<$kritR AND $us2[MINmp]>=$mp AND $okS>$ok AND $FIRE<$pint2 AND $ma2[S_TIME_NEED]<$ptime AND $mobs2[mb_MINhp]>$mbD){

$mpen=$us2[MINmp]-$mp;
$dm = round($FIRE-$pint2);
$mp = mysql_query("SET NAMES cp1251");
$mp =mysql_query("UPDATE users SET MINmp=\"$mpen\" WHERE NICK=\"$_SESSION[s]\"");
$lU = mysql_query("SET NAMES cp1251");
$lU = mysql_query("INSERT INTO logs (COU_DMG,POPAL_ILI_NET,NAPADENIE,DEFENDER,L_TIME,L_LOC,L_KEY) VALUES (' $dm',' <font color=\"red\">(клеймо божественного пламени)</font>','$_SESSION[s]','$mobs2[MOBSname]','$vremya','$nnick2[loc]','$src')");
$ma3 = time()+$ma2[S_RESSURECTION];
$resp = mysql_query("SET NAMES cp1251");
$resp = mysql_query("UPDATE magic_slots SET S_TIME_NEED=\"$ma3\" WHERE S_KEY_MAGIC=\"$ski\"");
$minmh = $mobs2[mb_MINhp]-$mbD;
$minmb = mysql_query("UPDATE mobs_world SET mb_MINhp=\"$minmh\" WHERE MOBSid=\"$src\"");//создаем запрос на отнимание здоровья у моба
}
if(mysql_num_rows($magA)>0 AND $krit<$kritR AND $us2[MINmp]>=$mp AND $okS>$ok AND $FIRE<$pint2 AND $ma2[S_TIME_NEED]<$ptime AND $mobs2[mb_MINhp]<=$mbD){

$mpen=$us2[MINmp]-$mp;
$dm = round($FIRE-$pint2);
$mp = mysql_query("SET NAMES cp1251");
$mp =mysql_query("UPDATE users SET MINmp=\"$mpen\" WHERE NICK=\"$_SESSION[s]\"");
$lU = mysql_query("SET NAMES cp1251");
$lU = mysql_query("INSERT INTO logs (COU_DMG,POPAL_ILI_NET,NAPADENIE,DEFENDER,L_TIME,L_LOC,L_KEY) VALUES (' $dm',' <font color=\"red\">(клеймо божественного пламени) </font>','$_SESSION[s]','$mobs2[MOBSname]','$vremya','$nnick2[loc]','$src')");
$ma3 = time()+$ma2[S_RESSURECTION];
$resp = mysql_query("SET NAMES cp1251");
$resp = mysql_query("UPDATE magic_slots SET S_TIME_NEED=\"$ma3\" WHERE S_KEY_MAGIC=\"$ski\"");

echo"</div><div class=\"main_foot\"><div style=\"padding:5px\"><center><img src=\"img/win666.png\"></center><font color=\"white\"><img src=\"img/b18.png\"> Бой завершен. Ты выиграл.<br/>";
echo" <img src=\"img/exp.png\"> +$mobs2[EXP_p]<br/>";
echo"<a href=\"game.php\"><font color=\"yellow\"><img src=\"img/b15.png\"> покинуть бой</font></a></font></div></div>";
$moexp2 = $us2[EXPnow]+$mobs2[EXP_p];
$moexp = mysql_query("SET NAMES cp1251");
$moexp = mysql_query("UPDATE users SET EXPnow=\"$moexp2\" WHERE NICK=\"$_SESSION[s]\"");//добавляем золото и опыт игроку
$ress = time()+$mobs2[MNTM];
$minmb = mysql_query("UPDATE mobs_world SET mb_MINhp=\"0\",M_TIME=\"$ress\" WHERE MOBSid=\"$src\"");//создаем запрос на отнимание здоровья у моба
die;
}
if(mysql_num_rows($magA)>0 AND $krit>=$kritR AND $us2[MINmp]>=$mp AND $okS>$ok AND $FIRE>=$pint*2 AND $ma2[S_TIME_NEED]<$ptime AND $mobs2[mb_MINhp]>$mbD*2){

$mpen=$us2[MINmp]-$mp;
$mp = mysql_query("SET NAMES cp1251");
$mp =mysql_query("UPDATE users SET MINmp=\"$mpen\" WHERE NICK=\"$_SESSION[s]\"");
$lU = mysql_query("SET NAMES cp1251");
$lU = mysql_query("INSERT INTO logs (COU_DMG,POPAL_ILI_NET,NAPADENIE,DEFENDER,L_TIME,L_LOC,L_KEY) VALUES ('- 0',' <b>(клеймо божественного пламени) <font color=\"red\">[Крит!]</font></b> ','$_SESSION[s]','$mobs2[MOBSname]','$vremya','$nnick2[loc]','$src')");
$ma3 = time()+$ma2[S_RESSURECTION];
$resp = mysql_query("SET NAMES cp1251");
$resp = mysql_query("UPDATE magic_slots SET S_TIME_NEED=\"$ma3\" WHERE S_KEY_MAGIC=\"$ski\"");
}
if(mysql_num_rows($magA)>0 AND $krit>=$kritR AND $us2[MINmp]>=$mp AND $okS>$ok AND $FIRE<$pint*2 AND $ma2[S_TIME_NEED]<$ptime AND $mobs2[mb_MINhp]>$mbD*2){
$mpen=$us2[MINmp]-$mp;
$dm = round($FIRE-$pint2*2);
$mpen=$us2[MINmp]-$mp;
$mp = mysql_query("SET NAMES cp1251");
$mp =mysql_query("UPDATE users SET MINmp=\"$mpen\" WHERE NICK=\"$_SESSION[s]\"");
$lU = mysql_query("SET NAMES cp1251");
$lU = mysql_query("INSERT INTO logs (COU_DMG,POPAL_ILI_NET,NAPADENIE,DEFENDER,L_TIME,L_LOC,L_KEY) VALUES ('- $dm',' <b>(клеймо божественного пламени) <font color=\"red\">[Крит!]</font></b> ','$_SESSION[s]','$mobs2[MOBSname]','$vremya','$nnick2[loc]','$src')");
$ma3 = time()+$ma2[S_RESSURECTION];
$resp = mysql_query("SET NAMES cp1251");
$resp = mysql_query("UPDATE magic_slots SET S_TIME_NEED=\"$ma3\" WHERE S_KEY_MAGIC=\"$ski\"");
$minmh = $mobs2[mb_MINhp]-$mbD*2;
$minmb = mysql_query("UPDATE mobs_world SET mb_MINhp=\"$minmh\" WHERE MOBSid=\"$src\"");//создаем запрос на отнимание здоровья у моба
}

if(mysql_num_rows($magA)>0 AND $krit>=$kritR AND $us2[MINmp]>=$mp AND $okS>$ok AND $FIRE<$pint*2 AND $ma2[S_TIME_NEED]<$ptime AND $mobs2[mb_MINhp]<=$mbD*2){
$mpen=$us2[MINmp]-$mp;
$dm = round($FIRE-$pint2*2);
$mpen=$us2[MINmp]-$mp;
$mp = mysql_query("SET NAMES cp1251");
$mp =mysql_query("UPDATE users SET MINmp=\"$mpen\" WHERE NICK=\"$_SESSION[s]\"");
$lU = mysql_query("SET NAMES cp1251");
$lU = mysql_query("INSERT INTO logs (COU_DMG,POPAL_ILI_NET,NAPADENIE,DEFENDER,L_TIME,L_LOC,L_KEY) VALUES ('- $dm',' <b>(клеймо божественного пламени) <font color=\"red\">[Крит!]</font></b> ','$_SESSION[s]','$mobs2[MOBSname]','$vremya','$nnick2[loc]','$src')");
$ma3 = time()+$ma2[S_RESSURECTION];
$resp = mysql_query("SET NAMES cp1251");
$resp = mysql_query("UPDATE magic_slots SET S_TIME_NEED=\"$ma3\" WHERE S_KEY_MAGIC=\"$ski\"");
echo"</div><div class=\"main_foot\"><div style=\"padding:5px\"><center><img src=\"img/win666.png\"></center><font color=\"white\"><img src=\"img/b18.png\"> Бой завершен. Ты выиграл.<br/>";
echo" <img src=\"img/exp.png\"> +$mobs2[EXP_p]<br/>";
echo"<a href=\"game.php\"><font color=\"yellow\"><img src=\"img/b15.png\"> покинуть бой</font></a></font></div></div>";
$moexp2 = $us2[EXPnow]+$mobs2[EXP_p];
$moexp = mysql_query("SET NAMES cp1251");
$moexp = mysql_query("UPDATE users SET EXPnow=\"$moexp2\" WHERE NICK=\"$_SESSION[s]\"");//добавляем золото и опыт игроку
$ress = time()+$mobs2[MNTM];
$minmb = mysql_query("UPDATE mobs_world SET mb_MINhp=\"0\",M_TIME=\"$ress\" WHERE MOBSid=\"$src\"");//создаем запрос на отнимание здоровья у моба
}
 if(mysql_num_rows($magA)>0 AND $okS<=$ok AND $us2[MINmp]>=$mp AND $ma2[S_TIME_NEED]<$ptime){
 $lU = mysql_query("SET NAMES cp1251");
 $lU = mysql_query("INSERT INTO logs (COU_DMG,POPAL_ILI_NET,NAPADENIE,DEFENDER,L_TIME,L_LOC,L_KEY) VALUES ('клеймо божественного пламени',' <font color=\"red\">(заклинание сорвалось) </font>','$_SESSION[s]','','$vremya','$nnick2[loc]','$src')");
$mpen=$us2[MINmp]-$mp;
$mp = mysql_query("SET NAMES cp1251");
$mp =mysql_query("UPDATE users SET MINmp=\"$mpen\" WHERE NICK=\"$_SESSION[s]\"");
 $ma3 = time()+$ma2[S_RESSURECTION];
 $resp = mysql_query("SET NAMES cp1251");
$resp = mysql_query("UPDATE magic_slots SET S_TIME_NEED=\"$ma3\" WHERE S_KEY_MAGIC=\"$ski\"");
 }
 print('<SCRIPT>location.href="attack.php?menu=main&src='.$src.'";</SCRIPT>');
}
?>