2018-01-28 16:40:49 +00:00
< ? php
//параметры
$needmana = 80 ;
$needint = 100 ;
$effect_id = 208 ;
$effect_text = " Гравитация [3] " ;
$log_text = " <strong><font color=#086604>Гравитация [3]</font></strong> " ;
$mag_id = 83 ;
$book = 909 ; $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; " ));
2020-10-28 20:21:08 +00:00
$magic = mysql_fetch_array ( mysql_query ( " SELECT `chanse` FROM `magic` WHERE `id` = ' { $mag_id } ' ; " ));
2018-01-28 16:40:49 +00:00
$bat = mysql_fetch_array ( mysql_query ( " SELECT * FROM `battle` WHERE `id`=' { $user [ 'battle' ] } '; " ));
$mag_def = " `type` = '203' " ;
$md_arr = array ( " 204 " , " 205 " ,
" 206 " , " 207 " , " 208 " ,
" 209 " , " 210 " , " 211 " ,
" 212 " , " 213 " , " 214 " );
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; " ));
// команды
$t1 = explode ( " ; " , $bat [ 't1' ]);
$t2 = explode ( " ; " , $bat [ 't2' ]);
if ( in_array ( $user [ 'id' ], $t1 )) {
$us_team = " B1 " ;
}
else {
$us_team = " B2 " ;
}
//шансы
if ( $user [ 'intel' ] >= $needint ) {
$int = $magic [ 'chanse' ] + ( $user [ 'intel' ] - $needint ) * 3 ;
if ( $int > 98 ){ $int = 99 ;}
}
else { $int = 0 ;}
if ( $user [ 'battle' ] == 0 ) {
echo " Это боевая магия... " ;
} elseif ( ! $have_book [ 'id' ]) {
echo ( " У В а с нет необходимой книги магии!" );
} elseif ( in_array ( $user [ 'id' ], $t1 ) &&! in_array ( $us [ 'id' ], $t1 ) || in_array ( $user [ 'id' ], $t2 ) &&! in_array ( $us [ 'id' ], $t2 )) {
echo ( " Персонаж не в Вашей команде! " );
} elseif ( $us && $us [ 'battle' ] != $user [ 'battle' ]) {
echo " Персонаж не в Вашем бою! " ;
} elseif ( $user [ 'mana' ] < $needmana ) {
echo " Недостаточно энергии! " ;
} elseif ( $effect [ 'time' ]) {
echo " Н а персонаже уже есть защита от магии!" ;
} elseif ( ! $us [ 'online' ]) {
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 ;
$sex_action = " применил " ; if ( $user [ 'sex' ] == 0 ) $sex_action .= " а " ;
if ( $user [ 'id' ] == $us_in [ 'id' ])
2020-08-27 12:17:02 +00:00
addlog ( $user [ 'battle' ], '<span class=date>' . date ( " H:i " ) . '</span> ' . Nick :: id ( $user [ 'id' ]) -> short () . ' ' . $sex_action . ' на себя заклятие </font></b>' . $log_text . ' <BR>' );
2018-01-28 16:40:49 +00:00
else
2020-08-27 12:17:02 +00:00
addlog ( $user [ 'battle' ], '<span class=date>' . date ( " H:i " ) . '</span> ' . Nick :: id ( $user [ 'id' ]) -> short () . ' ' . $sex_action . ' на ' . Nick :: id ( $us_in [ 'id' ]) -> short () . ' заклятие </font></b>' . $log_text . ' <BR>' );
2018-01-28 16:40:49 +00:00
$bet = 1 ;
mysql_query ( " UPDATE `users` SET `mana` = `mana`-' " . $needmana . " ' WHERE `id` = ' " . $user [ 'id' ] . " '; " ); $outok = 1 ;
} else {
echo " Свиток рассыпался в ваших руках... " ;
$bet = 1 ;
}