battles/magic/wis_earth_def2.php
2018-01-28 18:40:49 +02:00

46 lines
2.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
//параметры
$needint=0;
$effect_id=219;
$effect_text="Песчаный Щит [2]";
$log_text="<strong><font color=#086604>Песчаный Щит [2]</font></strong>";
$mag_id=130;
$book=908;$have_book=mysql_fetch_array(mysql_query("SELECT `id` FROM `inventory` WHERE `prototype`='{$book}' AND `owner`='{$user['id']}' LIMIT 1;"));
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$mag_def="`type` = '215'";
$md_arr=array("216","217","218","219","220","221","222","223","224","225","226");
foreach($md_arr as $mdi)
$mag_def.=" OR `type` = '".$mdi."'";
$effect = mysql_fetch_array(mysql_query("SELECT `time` FROM `effects` WHERE `owner` = '{$us['id']}' AND ({$mag_def}) LIMIT 1;"));
//шансы
if ($user['intel'] >= $needint) {
$int=$magic['chanse'] + ($user['intel'] - $needint)*3;
if ($int>98){$int=99;}
}
else {$int=0;}
if (!$have_book['id']) {
echo("У Вас нет необходимой книги магии!");
} elseif ($effect['time']) {
echo "На персонаже уже есть защита от магии!";
} elseif (!$us['online']) {
echo "Персонаж не в игре!";
} elseif ($user['battle'] > 0) { echo "Не в бою...";
} elseif (rand(1,100) < $int) {
$us_in = mysql_fetch_array(mysql_query("SELECT `id` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;"));
mysql_query("INSERT INTO `effects` (`owner`,`name`,`time`,`type`) values ('{$us_in['id']}','{$effect_text}',".(time()+7200).",'{$effect_id}');");
echo "<font color=red><b>На персонажа ".$_POST['target']." наложено заклятие </b></font>".$log_text;
$bet=1;
$outok=1;
} else {
echo "Свиток рассыпался в ваших руках...";
$bet=1;
}
?>