125 lines
5.0 KiB
PHP
125 lines
5.0 KiB
PHP
<?php
|
||
//параметры
|
||
$basedmg=70;
|
||
$needmana=65;
|
||
$needint=100;
|
||
$elem='e';
|
||
$t_min=3;
|
||
$t_max=5;
|
||
$count=mt_rand($t_min,$t_max);
|
||
$mag_id=106;
|
||
$log_text="<strong><font color=#086604>Каменный Дождь [2]</font></strong>";
|
||
$book=908;$have_book=mysql_fetch_array(mysql_query("SELECT `id` FROM `inventory` WHERE `prototype`='{$book}' AND `owner`='{$user['id']}' LIMIT 1;"));
|
||
|
||
if ($_SESSION['uid'] == null) {
|
||
header("Location: index.php");
|
||
exit;
|
||
}
|
||
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;"));
|
||
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
|
||
//mana needed
|
||
$t1 = explode(";",$bat['t1']);
|
||
$t2 = explode(";",$bat['t2']);
|
||
if(in_array($user['id'],$t1)) $e_team=$t2;
|
||
if(in_array($user['id'],$t2)) $e_team=$t1;
|
||
shuffle($e_team);
|
||
|
||
if ($user['battle'] == 0) {
|
||
echo "Это боевая магия...";
|
||
} elseif (!$have_book['id']) {
|
||
echo("У Вас нет необходимой книги магии!");
|
||
} elseif ($user['mana']<$needmana) {
|
||
echo "Недостаточно энергии!";
|
||
} else {
|
||
//attack script
|
||
if ($user['intel'] >= $needint) {
|
||
$int=$magic['chanse'] + ($user['intel'] - $needint)*3;
|
||
if ($int>98){$int=99;}
|
||
}
|
||
else {$int=0;}
|
||
|
||
if (rand(1,100) < $int) {
|
||
global $elem_align,$elem_bonus;
|
||
$user_elem=element(star_sign(substr($user['borndate'],3,2), substr($user['borndate'],0,2)));
|
||
|
||
switch($user_elem)
|
||
{
|
||
case 'f':$uel='mfire';break;
|
||
case 'a':$uel='mair';break;
|
||
case 'w':$uel='mwater';break;
|
||
case 'e':$uel='mearth';break;
|
||
}
|
||
switch($elem)
|
||
{
|
||
case 'f':$sel='mfire';break;
|
||
case 'a':$sel='mair';break;
|
||
case 'w':$sel='mwater';break;
|
||
case 'e':$sel='mearth';break;
|
||
}
|
||
$sex_action="применил";if($user['sex']==0) $sex_action.="а";
|
||
addlog($user['battle'],'<span class=date>'.date("H:i").'</span> '.Nick::id($user['id'])->short().' '.$sex_action.$targeted.' заклинание '.$log_text.'<BR>');
|
||
|
||
//mass magic
|
||
mysql_query ("UPDATE `users` SET `mana` = `mana`-'".$needmana."' WHERE `id` = '".$user['id']."';");
|
||
foreach($e_team as $v)
|
||
if($count>0)
|
||
{
|
||
$count--;
|
||
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
|
||
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `real_time` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `id` = '{$v}' LIMIT 1;"));
|
||
if(!$us) {$bot= mysql_fetch_array(mysql_query ("SELECT * FROM `bots` WHERE `id` = '{$v}' LIMIT 1;"));$b_maxhp=mysql_fetch_array(mysql_query("SELECT `maxhp` FROM `users`WHERE `id`='{$bot['prototype']}' LIMIT 1;"));$b_maxhp=$b_maxhp['maxhp'];}
|
||
//dmg=base+INT/LVL+X_magic
|
||
$dmg=$basedmg+($user['intel']/4)+$user[$sel];
|
||
//MF
|
||
$dmg*=$elem_align[$user_elem][$elem];
|
||
if($us) $dmg*=$elem_bonus[element(star_sign(substr($user['borndate'],3,2), substr($user['borndate'],0,2)))][element(star_sign(substr($us['borndate'],3,2), substr($us['borndate'],0,2)))];
|
||
//- MF
|
||
if($us) {
|
||
$def=magic_def($elem,$_POST['target'],$user_elem);$dmg*=(1-magic_def($elem,$us['login'],$user_elem,1)/100);
|
||
$dmg-=$def;
|
||
}
|
||
//rand +- 25%
|
||
$dmg=mt_rand(0.75*$dmg,1.25*$dmg);
|
||
$dmg=round($dmg);
|
||
if($us) $target=$us['id'];
|
||
else $target=$bot['id'];
|
||
|
||
$targeted='';
|
||
//dmg >0 - go
|
||
$all_dmg=unserialize($bat['damage']);
|
||
$all_exp=unserialize($bat['exp']);
|
||
$all_dmg[$user['id']]+=$dmg;
|
||
$all_exp[$user['id']]+=SolveExp($user['id'],$target,$dmg);
|
||
|
||
//сработало
|
||
if($dmg>0) $hit=1; else $hit=0;
|
||
$action=preg_replace("/Х/",Nick::id($target)->short(),magic_log($elem,$hit,$target));
|
||
if(!(($us['id']>0 && $us['hp']<1) || ($bot['id']>0 && $bot['hp']<1)))
|
||
if($dmg>0)
|
||
{
|
||
if($us)
|
||
mysql_query("UPDATE `users` SET `hp` = `hp`-'".$dmg."' WHERE `id` = '".$target."';");
|
||
else
|
||
mysql_query("UPDATE `bots` SET `hp` = `hp`-'".$dmg."' WHERE `id` = '".$target."';");
|
||
mysql_query("UPDATE `battle` SET `damage`='".serialize($all_dmg)."', `exp`='".serialize($all_exp)."' WHERE `id`='{$user['battle']}';");
|
||
|
||
|
||
addlog($user['battle'],'<span class=date>'.date("H:i").'</span> '.$action.' <strong>-'.$dmg.'</strong><BR>');
|
||
|
||
$bet=1;
|
||
}
|
||
else
|
||
//не сработало
|
||
{
|
||
addlog($user['battle'],'<span class=date>'.date("H:i").'</span> '.$action.'<BR>');
|
||
$bet=1;
|
||
}
|
||
}
|
||
|
||
} else {
|
||
echo "Свиток рассыпался в ваших руках...";
|
||
$bet=1;
|
||
}
|
||
}
|
||
|