<?
$ma1 = mysql_query("SELECT * FROM magic_slots WHERE S_NICK=\"$_SESSION[s]\" AND S_KEY_MAGIC=\"$ski\"");
$ma2 = mysql_fetch_assoc($ma1);
$ptime = time(); 
if($ski == 'm.fired' AND mysql_num_rows($magA)>0){
$us =mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
$us2 = mysql_fetch_assoc($us);
if($ma2[S_TIME_NEED]>=$ptime){
$lU = mysql_query("INSERT INTO logs (COU_DMG,POPAL_ILI_NET,NAPADENIE,DEFENDER,L_TIME,L_LOC) VALUES ('заклинание *защита от огня* ',' еще не восстановилось','$_SESSION[s]','','$vremya','$nnick2[loc]')");

}
if($buffs2[S_LVL_MAGIC]=='1'){$sf = 5;$mp = 27;}
if($buffs2[S_LVL_MAGIC]=='2'){$sf = 10;$mp = 42;}
if($buffs2[S_LVL_MAGIC]=='3'){$sf = 15;$mp = 57;}
if($buffs2[S_LVL_MAGIC]=='4'){$sf = 20;$mp = 72;}
if($buffs2[S_LVL_MAGIC]=='5'){$sf = 25;$mp = 87;}
if($buffs2[S_LVL_MAGIC]=='6'){$sf = 30;$mp = 102;}
if($buffs2[S_LVL_MAGIC]=='7'){$sf = 35;$mp = 117;}
if($buffs2[S_LVL_MAGIC]=='8'){$sf = 40;$mp = 132;}
if($buffs2[S_LVL_MAGIC]=='9'){$sf = 45;$mp = 147;}
if($buffs2[S_LVL_MAGIC]=='10'){$sf = 50;$mp = 162;}
$sf2=round(($sf*$us2[S_FIRE])/$us2[S_FIRE]);
#Сопр.от огня*защита от огня/100
$bpr=mysql_query("SELECT * FROM buffs WHERE B_NICK=\"$_SESSION[s]\" AND FIRE>0");
$bpr2=mysql_fetch_assoc($bpr);
$rt=time()+900;
$fird = rand(0,100);
$firedS = 85;
if(mysql_num_rows($magA)>0 AND mysql_num_rows($bpr)<1 AND $bpr2[FIRE]<1 AND $firedS>$fird AND $us2[MINmp]>$mp AND $ma2[S_TIME_NEED]<$ptime){
$insF = mysql_query("INSERT INTO buffs (B_NICK,B_NAME,B_IMG,NO,FIRE,TIMER) VALUES ('$_SESSION[s]','защита от огня','magic_icon/fired.png','1','$sf2','$rt')");}//добавляем сопротивление огню игроку
if(mysql_num_rows($magA)>0 AND $bpr2[FIRE]>0 AND $firedS>$fird AND $us2[MINmp]>=$mp AND $ma2[S_TIME_NEED]<$ptime){$upd = mysql_query("UPDATE buffs SET FIRE=\"$sf2\",TIMER=\"$rt\" WHERE B_NICK=\"$_SESSION[s]\"");
}//перезаписываем заклинание
if(mysql_num_rows($magA)>0 AND $bpr2[FIRE]>0 AND $us2[MINmp]<$mp AND $ma2[S_TIME_NEED]<$ptime){$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($firedS>$fird AND $us2[MINmp]>$mp AND $ma2[S_TIME_NEED]<$ptime){
$lU = mysql_query("INSERT INTO logs (COU_DMG,POPAL_ILI_NET,NAPADENIE,DEFENDER,L_TIME,L_LOC,L_KEY) VALUES ('Защита от огня',' <font color=\"red\">(сопротивление огню + $sf2) </font>','$_SESSION[s]','','$vremya','$nnick2[loc]','$src')");
$mpen=$us2[MINmp]-$mp;
$mp =mysql_query("UPDATE users SET MINmp=\"$mpen\" WHERE NICK=\"$_SESSION[s]\"");
$ma3 = time()+$ma2[S_RESSURECTION];
$resp = mysql_query("UPDATE magic_slots SET S_TIME_NEED=\"$ma3\" WHERE S_KEY_MAGIC=\"$ski\"");
}
 if($firedS<=$fird AND $us2[MINmp]>$mp AND $ma2[S_TIME_NEED]<$ptime){
 $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("UPDATE users SET MINmp=\"$mpen\" WHERE NICK=\"$_SESSION[s]\"");
$ma3 = time()+$ma2[S_RESSURECTION];
$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>');
}
?>