2018-01-28 18:40:49 +02:00
< ? php
class fbattle
{
2018-02-27 04:48:51 +02:00
var $status = 0 ;
2018-01-28 18:40:49 +02:00
var $battle = array ();
var $battle_data = array ();
var $enemy = null ;
var $damage = array ();
var $t1 = array ();
var $t2 = array ();
var $team_enemy = array ();
var $team_mine = array ();
var $user = array ();
var $enemyhar = array ();
var $enemy_dress = array ();
var $user_dress = array ();
var $en_class , $my_class ;
var $bots = array ();
var $botsid = array ();
var $log = '' ;
var $to1 ;
var $to2 ;
var $exp = array ();
var $log_debug = '' ;
var $needrefresh = 0 ;
var $rep = 0 ;
var $needupdate = 0 ;
var $har = array ();
var $color_battle = array ();
var $mf = array ();
var $user_inf_1 = array ();
var $user_inf_2 = array ();
var $max = 70 ;
var $err = '' ;
/*-------------------------------------------------------------------
создание класса и сбор основной инфы
--------------------------------------------------------------------*/
2019-01-16 19:45:30 +02:00
function __construct ( $battle_id )
2018-01-28 18:40:49 +02:00
{
2018-02-27 04:48:51 +02:00
global $mysql , $user , $_POST , $cavedata , $caverooms , $cavebots , $party ;
2018-01-28 18:40:49 +02:00
// соединяем мускуль и юзера
$this -> mysql = $mysql ;
$this -> user = $user ;
// перебираем варианты
if ( $battle_id > 0 ) {
// ставим статус битвы на "есть битва"
$this -> status = 1 ;
// вставляем драчующихся
$this -> battle_data = mysql_fetch_array ( mysql_query ( " SELECT `id`, `coment`, `teams`, `timeout`, `razmen_time`, `type`, `status`, `t1`, `t2`, `date`, `time_m`, `win`, `damage`, `to1`, `to2`, `exp`, `blood`, `t1hist`, `t2hist`, `magic`, `open`, `close`, `protivnik`, `protivnik_type`, `dungeon_bot`, `dn_id`, `aren_of`, `needbb`, `clone`, `fiz` FROM `battle` WHERE `id` = ' { $battle_id } ' LIMIT 1 " ));
$this -> sort_teams ();
// получили дамагу
$this -> damage = unserialize ( $this -> battle_data [ 'damage' ]);
//
$this -> magic = unserialize ( $this -> battle_data [ 'magic' ]);
// кто драчуется?
$this -> battle = unserialize ( $this -> battle_data [ 'teams' ]);
// получаем экспу
$this -> exp = unserialize ( $this -> battle_data [ 'exp' ]);
// таймі
$this -> to1 = $this -> battle_data [ 'to1' ];
$this -> to2 = $this -> battle_data [ 'to2' ];
// ============СИСТЕМА БОТОВ=================
$bots = mysql_query ( 'SELECT * FROM `bots` WHERE `battle` = ' . $battle_id . ' AND `hp` > 0;' );
while ( $bot = mysql_fetch_array ( $bots )) {
$this -> bots [ $bot [ 'id' ]] = $bot ;
// листаем противников, и выставляем удары для живых персонажей
if ( $bot [ 'hp' ] > 0 ) {
foreach ( $this -> battle [ $bot [ 'id' ]] as $k => $v ) {
if ( $this -> battle [ $bot [ 'id' ]][ $k ][ 0 ] == 0 && $k < 10000000 ) {
mt_srand ( microtime ( true ));
$this -> battle [ $bot [ 'id' ]][ $k ] = array ( mt_rand ( 1 , 4 ), mt_rand ( 1 , 6 ), time ());
$this -> battle [ $k ][ $bot [ 'id' ]] = array ( 0 , 0 , time ());
}
if ( $this -> battle [ $k ][ $bot [ 'id' ]][ 0 ] == 0 && $k < 10000000 ) {
if ( in_array ( $user [ 'id' ], array_keys ( $this -> battle [ $bot [ 'id' ]]))) {
//echo "111";
// если я противник бота
if ( $this -> my_class == 'B2' ) {
if ( $this -> to2 <= $this -> to1 ) {
$endr = (( time () - $this -> to2 ) > $this -> battle_data [ 'timeout' ] * 60 );
}
} else {
if ( $this -> to2 >= $this -> to1 ) {
$endr = (( time () - $this -> to1 ) > $this -> battle_data [ 'timeout' ] * 60 );
}
}
if ( $endr && ! $uje ) {
$uje = true ;
// если сдул - заканчиваем бой
$this -> add_log ( " <span class=date> " . date ( " H:i " ) . " </span> Бой закончен по таймауту.<BR> " );
//$this->write_log ();
foreach ( $this -> battle [ $bot [ 'id' ]] as $k => $v ) {
if ( $k > _BOTSEPARATOR_ ) {
$bots = mysql_fetch_array ( mysql_query ( 'SELECT `hp` FROM `bots` WHERE `id` = ' . $k . ' LIMIT 1;' ));
$us [ 'hp' ] = $bots [ 'hp' ];
} else {
$us = mysql_fetch_array ( mysql_query ( 'SELECT `hp` FROM `users` WHERE `id` = ' . $k . ' LIMIT 1;' ));
}
if ( $us && ( int ) $us [ 'hp' ] > 0 ) {
$tr = settravma ( $k , 0 , 86400 , 1 );
2020-08-27 15:17:02 +03:00
$this -> add_log ( '<span class=date>' . date ( " H:i " ) . '</span> ' . Nick :: id ( $k ) -> short () . ' получил повреждение: <font color=red>' . $tr . '</font><BR>' );
2018-01-28 18:40:49 +02:00
}
}
//$this->write_log ();
foreach ( $this -> battle [ $bot [ 'id' ]] as $k => $v ) {
mysql_query ( 'UPDATE users SET `hp` =0, `fullhptime` = ' . time () . ' WHERE `id` = ' . $k . ';' );
}
}
}
}
}
$this -> update_battle ();
}
}
//==============================================
if ( $_POST [ 'enemy' ] > 0 ) {
// ударяемся
$this -> razmen_init ( $_POST [ 'enemy' ], $_POST [ 'attack' ], $_POST [ 'defend' ]);
}
2019-09-24 12:49:05 +03:00
if ( isset ( $_POST [ 'smena' ])) {
$sm = db :: c () -> query ( 'SELECT `id`, `login`, `battle`, `bot`, `hp` FROM `users` WHERE `hp` > 0 AND `login` = "?s" AND `battle` = ?i' , $_POST [ 'smena' ], $user [ 'battle' ]) -> fetch_assoc ();
2018-01-28 18:40:49 +02:00
if ( isset ( $sm [ 'id' ])) {
if ( $sm [ 'bot' ] > 0 ) {
$bt = mysql_fetch_array ( mysql_query ( 'SELECT `id`, `hp` FROM `bots` WHERE `name` = "' . mysql_real_escape_string ( $_POST [ 'smena' ]) . '" LIMIT 1' ));
if ( isset ( $bt [ 'id' ])) {
if ( $bt [ 'hp' ] > 0 ) {
$mb = $this -> select_enemy2 ( $bt [ 'id' ]);
$i = 0 ;
$mb2 = 0 ;
while ( $i < count ( $mb )) {
if ( $mb [ $i ] == $sm [ 'id' ]) {
$mb2 = 1 ;
}
$i ++ ;
}
if ( $mb2 == 1 ) {
$this -> enemy = $bt [ 'id' ];
$_SESSION [ 'enemy' ] = $bt [ 'id' ];
}
echo " <center><b style='color: Red;'>Успешно сменили противника</b></center> " ;
} else {
echo " <center><b style='color: Red;'>Персонаж мертв</b></center> " ;
}
}
} else {
$mb = $this -> select_enemy2 ( $sm [ 'id' ]);
$i = 0 ;
$mb2 = 0 ;
while ( $i < count ( $mb )) {
if ( $mb [ $i ] == $sm [ 'id' ]) {
$mb2 = 1 ;
}
$i ++ ;
}
if ( $mb2 == 1 ) {
$this -> enemy = $sm [ 'id' ];
$_SESSION [ 'enemy' ] = $sm [ 'id' ];
}
echo " <center><b style='color: Red;'>Успешно сменили противника</b></center> " ;
}
} else {
$sm = mysql_fetch_array ( mysql_query ( 'SELECT `id`, `hp` FROM `bots` WHERE `name` = "' . mysql_real_escape_string ( $_POST [ 'smena' ]) . '" AND `battle` = ' . $user [ 'battle' ] . ' LIMIT 1' ));
if ( isset ( $sm [ 'id' ])) {
if ( $sm [ 'hp' ] > 0 ) {
if ( in_array ( $sm [ 'id' ], $this -> team_enemy )) {
$mb = $this -> select_enemy2 ( $sm [ 'id' ]);
$i = 0 ;
$mb2 = 0 ;
while ( $i < count ( $mb )) {
if ( $mb [ $i ] == $sm [ 'id' ]) {
$mb2 = 1 ;
}
$i ++ ;
}
if ( $mb2 == 1 ) {
$this -> enemy = $sm [ 'id' ];
$_SESSION [ 'enemy' ] = $sm [ 'id' ];
}
echo " <center><b style='color: Red;'>Успешно сменили противника</b></center> " ;
} else {
echo " <center><b style='color: Red;'>Персонаж в вашей команде</b></center> " ;
}
} else {
$t = mysql_real_escape_string ( $_POST [ 'smena' ]);
echo " <center><b style='color: Red;'>Персонаж мертв</b></center> " ;
}
} else {
echo " <center><b style='color: Red;'>Персонаж не найден</b></center> " ;
}
}
}
$this -> sort_teams ();
$this -> fast_death ();
// вібираем вражину
$this -> enemy = ( int ) $this -> select_enemy ();
if ( $this -> enemy > 0 ) {
// табличка удара-блока
$this -> return = 1 ;
} else {
//проверяем тайм
if ( $this -> get_timeout () && $this -> user [ 'hp' ] > 0 ) {
// табличка тайма
$this -> return = 3 ;
} else {
// ожидаем хода...
$this -> return = 2 ;
}
}
if ( $_POST [ 'victory_time_out2' ]) {
$this -> end_draft ();
}
if ( $_POST [ 'victory_time_out' ]) {
$this -> end_gora ();
}
if ( $this -> battle_end ()) {
$this -> return = 2 ;
}
$this -> write_log (); // пишем лог
return $this -> return ;
} else {
// ставим статус битвы на "нет битвы"
$this -> status = 0 ;
//header ("Location:main.php");
//die();
//$this->return = 5;
//return $this->return;
}
}
function sort_teams ()
{
// режем тимзы
$this -> t1 = explode ( " ; " , $this -> battle_data [ 't1' ]);
$this -> t2 = explode ( " ; " , $this -> battle_data [ 't2' ]);
// проставляем кто-где
if ( in_array ( $this -> user [ 'id' ], $this -> t1 )) {
$this -> my_class = " B1 " ;
$this -> en_class = " B2 " ;
$this -> team_mine = $this -> t1 ;
$this -> team_enemy = $this -> t2 ;
} else {
$this -> my_class = " B2 " ;
$this -> en_class = " B1 " ;
$this -> team_mine = $this -> t2 ;
$this -> team_enemy = $this -> t1 ;
}
}
function add_log ( $text )
{
$this -> log .= $text ;
}
/*-------------------------------------------------------------------
проверка и выставление конца боя
--------------------------------------------------------------------*/
function update_battle ()
{
2019-09-24 12:49:05 +03:00
return db :: c () -> query ( 'UPDATE `battle` SET `exp` = "?s", `teams` = "?s", `damage` = "?s", WHERE `id` = ?i' , serialize ( $this -> exp ), serialize ( $this -> battle ), serialize ( $this -> damage ), $this -> battle_data [ 'id' ]);
2018-01-28 18:40:49 +02:00
}
/*-------------------------------------------------------------------
gora - я победил
--------------------------------------------------------------------*/
function razmen_init ( $enemy , $attack , $defend )
{
// проверяем прафильность
2019-09-24 12:49:05 +03:00
if ( in_array ( $attack ,[ 1 , 2 , 3 , 4 , 5 ]) AND in_array ( $defend ,[ 1 , 2 , 3 , 4 ]) AND $enemy AND $this -> user [ 'hp' ] > 0 ) {
// if (($attack == 1 OR $attack == 2 OR $attack == 3 OR $attack == 4 OR $attack == 5) && $defend < 5 && $defend > 0 && $enemy && $this->user['hp'] > 0) {
2018-01-28 18:40:49 +02:00
if ( $this -> battle [ $enemy ][ $this -> user [ 'id' ]][ 0 ] > 0 ) {
// ==================================
2019-09-24 12:49:05 +03:00
# Реплики комментатора:
$this -> add_log ( $this -> get_comment ());
# Подсчёт характеристик бойцов:
2018-01-28 18:40:49 +02:00
$mf = $this -> solve_mf ( $enemy , $attack );
// проверяем кто куда попал
2019-09-24 12:49:05 +03:00
2018-01-28 18:40:49 +02:00
// удар по мне
$uvorotme = $this -> get_chanse ( $mf [ 'me' ][ 'uvorot' ]);
$krithe = $this -> get_chanse ( $mf [ 'he' ][ 'krit' ]);
if ( $uvorotme && ! $krithe ) {
$uve = 1 ;
} else if ( ! $uvorotme && $krithe ) {
$uve = 2 ;
} elseif ( $uvorotme && $krithe ) {
$uve = rand ( 1 , 2 );
} else {
$uve = 0 ;
}
if ( $uve == 1 ) {
// я увернулся;
$this -> add_log ( $this -> razmen_log ( " uvorot " , $this -> battle [ $enemy ][ $this -> user [ 'id' ]][ 0 ], $this -> get_wep_type ( $this -> enemyhar [ 'weap' ]), 0 , $enemy , $this -> en_class , $this -> user [ 'id' ], $this -> my_class , 0 , 0 ));
} elseif ( $uve == 2 ) {
// меня кританули
if ( ! $this -> get_block ( " me " , $this -> battle [ $enemy ][ $this -> user [ 'id' ]][ 0 ], $defend , $enemy )) {
$hs = 1 ;
$m = 'a' ;
} else {
$hs = 2 ;
$m = '' ;
}
$this -> damage [ $enemy ] += ( $mf [ 'he' ][ 'udar' ] * $hs );
$jv = ( $this -> user [ 'hp' ] - $mf [ 'he' ][ 'udar' ] * $hs );
$this -> exp [ $enemy ] += SolveExp ( $enemy , $this -> user [ 'id' ], $mf [ 'he' ][ 'udar' ] * $hs );
$this -> add_log ( $this -> razmen_log ( " krit " . $m , $this -> battle [ $enemy ][ $this -> user [ 'id' ]][ 0 ], $this -> get_wep_type ( $this -> enemyhar [ 'weap' ]), ( $mf [ 'he' ][ 'udar' ] * $hs ), $enemy , $this -> en_class , $this -> user [ 'id' ], $this -> my_class , ( $this -> user [ 'hp' ] - $mf [ 'he' ][ 'udar' ] * $hs ), $this -> user [ 'maxhp' ]));
mysql_query ( 'UPDATE users SET `hp` = `hp` - ' . ( $mf [ 'he' ][ 'udar' ] * $hs ) . ' WHERE `id` = ' . $this -> user [ 'id' ] . '' );
} elseif ( $this -> get_block ( " me " , $this -> battle [ $enemy ][ $this -> user [ 'id' ]][ 0 ], $defend , $enemy )) {
// противник попал куда надо
$this -> damage [ $enemy ] += ( $mf [ 'he' ][ 'udar' ]);
$jv = ( $this -> user [ 'hp' ] - $mf [ 'he' ][ 'udar' ]);
$this -> exp [ $enemy ] += SolveExp ( $enemy , $this -> user [ 'id' ], $mf [ 'he' ][ 'udar' ]);
$this -> add_log ( $this -> razmen_log ( " udar " , $this -> battle [ $enemy ][ $this -> user [ 'id' ]][ 0 ], $this -> get_wep_type ( $this -> enemyhar [ 'weap' ]), $mf [ 'he' ][ 'udar' ], $enemy , $this -> en_class , $this -> user [ 'id' ], $this -> my_class , ( $this -> user [ 'hp' ] - $mf [ 'he' ][ 'udar' ]), $this -> user [ 'maxhp' ]));
mysql_query ( 'UPDATE users SET `hp` = `hp` - ' . ( $mf [ 'he' ][ 'udar' ]) . ' WHERE `id` = ' . $this -> user [ 'id' ] . '' );
} else {
// противник мазила
$this -> add_log ( $this -> razmen_log ( " block " , $this -> battle [ $enemy ][ $this -> user [ 'id' ]][ 0 ], $this -> get_wep_type ( $this -> enemyhar [ 'weap' ]), 0 , $enemy , $this -> en_class , $this -> user [ 'id' ], $this -> my_class , 0 , 0 ));
}
$uvorothe = $this -> get_chanse ( $mf [ 'he' ][ 'uvorot' ]);
$kritme = $this -> get_chanse ( $mf [ 'me' ][ 'krit' ]);
if ( $uvorothe && ! $kritme ) {
$uve = 1 ;
} else if ( ! $uvorothe && $kritme ) {
$uve = 2 ;
} elseif ( $uvorothe && $kritme ) {
$uve = rand ( 1 , 2 );
} else {
$uve = 0 ;
}
// удар по противнику
if ( $uve == 1 ) {
// он увернулся;
$this -> add_log ( $this -> razmen_log ( " uvorot " , $attack , $this -> get_wep_type ( $this -> user [ 'weap' ]), 0 , $this -> user [ 'id' ], $this -> my_class , $enemy , $this -> en_class , 0 , 0 ));
} elseif ( $uve == 2 ) {
// его кританули
if ( ! $this -> get_block ( " he " , $attack , $this -> battle [ $enemy ][ $this -> user [ 'id' ]][ 1 ], $enemy )) {
$hs = 1 ;
$m = 'a' ;
} else {
$hs = 2 ;
$m = '' ;
}
$this -> damage [ $this -> user [ 'id' ]] += ( $mf [ 'me' ][ 'udar' ] * $hs );
$this -> exp [ $this -> user [ 'id' ]] += SolveExp ( $this -> user [ 'id' ], $enemy , $mf [ 'me' ][ 'udar' ] * $hs );
$this -> add_log ( $this -> razmen_log ( " krit " . $m , $attack , $this -> get_wep_type ( $this -> user [ 'weap' ]), ( $mf [ 'me' ][ 'udar' ] * $hs ), $this -> user [ 'id' ], $this -> my_class , $enemy , $this -> en_class , ( $this -> enemyhar [ 'hp' ] - $mf [ 'me' ][ 'udar' ] * $hs ), $this -> enemyhar [ 'maxhp' ]));
if ( $enemy > _BOTSEPARATOR_ ) {
mysql_query ( 'UPDATE `bots` SET `hp` = `hp` - ' . ( $mf [ 'me' ][ 'udar' ] * $hs ) . ' WHERE `id` = ' . $enemy . '' );
} else {
mysql_query ( 'UPDATE `users` SET `hp` = `hp` - ' . ( $mf [ 'me' ][ 'udar' ] * $hs ) . ' WHERE `id` = ' . $enemy . '' );
}
} elseif ( $this -> get_block ( " he " , $attack , $this -> battle [ $enemy ][ $this -> user [ 'id' ]][ 1 ], $enemy )) {
// я попал куда надо
$this -> damage [ $this -> user [ 'id' ]] += ( $mf [ 'me' ][ 'udar' ]);
$this -> exp [ $this -> user [ 'id' ]] += SolveExp ( $this -> user [ 'id' ], $enemy , $mf [ 'me' ][ 'udar' ]);
$this -> add_log ( $this -> razmen_log ( " udar " , $attack , $this -> get_wep_type ( $this -> user [ 'weap' ]), $mf [ 'me' ][ 'udar' ], $this -> user [ 'id' ], $this -> my_class , $enemy , $this -> en_class , ( $this -> enemyhar [ 'hp' ] - $mf [ 'me' ][ 'udar' ]), $this -> enemyhar [ 'maxhp' ]));
if ( $enemy > _BOTSEPARATOR_ ) {
mysql_query ( 'UPDATE `bots` SET `hp` = `hp` - ' . ( $mf [ 'me' ][ 'udar' ]) . ' WHERE `id` = ' . $enemy . '' );
} else {
mysql_query ( 'UPDATE `users` SET `hp` = `hp` - ' . ( $mf [ 'me' ][ 'udar' ]) . ' WHERE `id` = ' . $enemy . '' );
}
} else {
// я мазила
$this -> add_log ( $this -> razmen_log ( " block " , $attack , $this -> get_wep_type ( $this -> user [ 'weap' ]), 0 , $this -> user [ 'id' ], $this -> my_class , $enemy , $this -> en_class , 0 , 0 ));
}
// обновить битку
$this -> battle [ $enemy ][ $this -> user [ 'id' ]] = array ( 0 , 0 , time ());
mysql_query ( " UPDATE `battle` SET `to1` = ' " . time () . " ',`to2` = ' " . time () . " ' WHERE `id` = " . $this -> user [ 'battle' ] . " LIMIT 1; " );
$this -> update_battle ();
} else {
// выставляем удар противнику... просто...
$this -> battle [ $this -> user [ 'id' ]][ $enemy ] = array ( $attack , $defend , time ());
if ( $this -> my_class == " B1 " && $jv > 0 ) {
mysql_query ( " UPDATE `battle` SET `to1` = ' " . time () . " ', `to2` = ' " . ( time () - 1 ) . " ' WHERE `id` = " . $this -> user [ 'battle' ] . " LIMIT 1; " );
} elseif ( $jv > 0 ) {
mysql_query ( " UPDATE `battle` SET `to2` = ' " . time () . " ', `to1` = ' " . ( time () - 1 ) . " ' WHERE `id` = " . $this -> user [ 'battle' ] . " LIMIT 1; " );
} else {
mysql_query ( " UPDATE `battle` SET `to2` = ' " . time () . " ', `to1` = ' " . ( time ()) . " ' WHERE `id` = " . $this -> user [ 'battle' ] . " LIMIT 1; " );
}
// обновить битку
$this -> update_battle ();
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " " );
die ();
}
} else {
return false ;
}
}
/*-------------------------------------------------------------------
draft - ничья
--------------------------------------------------------------------*/
function get_comment ()
{
$boycom = array (
'А танцуешь ты лучше.' ,
'А мы что, в прятки тут играем?' ,
'А вы разве пингвинов никогда не видели?' ,
'А, ведь когда-то, вы были красивыми… А теперь? Ну и рожи! Жуть!' ,
'А потом еще труп пинать будут.' ,
'А я вчера ночью за соседями подглядывал. Они точно так же кувыркались' ,
'А ведь вы живых людей дубасите...' ,
'А вот я вчера в зоопарке был...' ,
'А вы в стройбате не служили?' ,
'А вы видели, чтобы так на улице делали!?' ,
'А вы знали что ёжики размножаются в интернете?' ,
'А жить-то, как хочется:' ,
'А из-за чего вы собственно дерётесь?' ,
'А чего ржёте, вы ещё остальных не видели' ,
'А что произойдёт если ты испугаешся до полусмерти дважды?!' ,
'Больше так не делай. Ты же не садист?' ,
'Без комментариев...' ,
'Больно ведь!' ,
'Быстро ты за монитор спрятался!' ,
'Все хотят попасть в рай, но никто не хочет умирать!' ,
'Вчера с такой девчонкой познакомился.' ,
'Всего 5 минут знакомы, а дерутся, словно супруги с 20-ти летним стажем...' ,
'Все. Я так больше не могу.' ,
'В конце концов, кто-то победит?' ,
'Вы чего, с дерева упали? ' ,
'Возятся как сонные мухи... давайте я вам лучше анекдот расскажу: ...' ,
'Вот видишь, как полезно чистить зубы на ночь?' ,
'Вот вы все руками махаете, а за вами уже очередь' ,
'Вот попадёте вы в плен и вас там будут долго бить. Но вы ничего не расскажете... и не потому, что вы такой стойкий, просто вы ничего не знаете' ,
'Вы бы лучше пошли потренировались!' ,
'Вы все еще разминаетесь? Позовите, когда кости в муку друг другу разминать будете.' ,
'Вы же бойцы! Имейте совесть!' ,
'Гаси недоумка!' ,
'Да, если бы я смог это остановить, то получил бы нобелевскую премию "За мир" ' ,
'Да куда они бьют?!' ,
'Давайте быстрее! За вами уже очередь образовалась.' ,
'Давайте обойдемся сегодня таймаутом. А? А то мне уже кошмары скоро будут сниться.' ,
'Дерутся как девчонки!' ,
'Дети, посмотрите налево... Ой!.. Нет, туда лучше не смотреть.' ,
'Если так будет продолжаться, то скоро мы заснем!' ,
'Если бы у меня было кресло-качалка, я бы в нём качался...' ,
'Если вы что-то сказать хотите, то лучше молчите :)' ,
'Жестокость не порок.' ,
'Жизнь вне нашего клуба - это пустая трата кислорода!!!' ,
'Жми! Дави! Кусай! Царапай!' ,
'За такие бои надо в хаос отправлять!' ,
'Знаете откуда в комиссионном магазине столько вещей? Это я после ваших гулянок собираю и сдаю туда. Иногда вместе с частями тела, застрявшими в них.' ,
'Здесь люди так близки друг к другу. Просто иначе ударить нельзя.' ,
'И пролитая кровь еще пульсирует...' ,
'Инвалидов развелось...' ,
'Какой бой!!!' ,
'Кто!? Кто здесь?!' ,
'Кто вас этому научил?' ,
'Кузнечик, блин...' ,
'Куплю импортный проигрыватель грампластинок.' ,
'Лошадью ходи!' ,
'Лучше враг, чем друг - враг.' ,
'Ладно, вы тут пока друг друга за волосы таскайте, а я пойду, пообедаю.' ,
'Мне ваш балет уже надоел!' ,
'Может, начнется-таки настоящий бой???' ,
'Мысли лезут в голову изнутри, а удары снаружи.' ,
'Ну и где ваши коронные удары? Где живописные падения я спрашиваю!' ,
'Ну, нельзя же так наотмашь лупить!' ,
'Надо раньше было думать, теперь смертельно поздно...' ,
'На такое зрелище билеты продавать можно. Народ ухохочется!' ,
'Нет! Не надо драки! А... ладно деритесь, все равно не умеете.' ,
'Нет, ну должен быть повод, должен же быть повод?' ,
'Нет, я отказываюсь это комментировать!' ,
'Не таких обламывали!' ,
'Ну выпили вы рюмку, ну две... ну литр, ну два... так зачем же после этого драку затевать?!' ,
'Ну и кто за этот погром платить будет?' ,
'Ну и оскал у вас. Из вашей улыбки кастеты делать можно.' ,
'Ну, что же ты..? Не печалься. Выше голову, так по ней удобней попасть.' ,
'Ничего... Блок тоже удар.' ,
'Обернись!!!.... Поздно...' ,
'Ого! Научите меня так не делать.' ,
'Осторожно! Сделаешь дырочку, уже не запломбируешь!' ,
'Оно вам надо???' ,
'Обычное дело...там что-то отклеилось.' ,
'Ой, и заболтался я с вами...' ,
'Он же не промахнётся если ты не отойдёшь!' ,
'По-моему, кому-то светит инвалидность.' ,
'Подкинь ему грабли, на которые он еще не наступал.' ,
'Прав был кот Леопольд, давайте жить дружно?' ,
'При ударе в живот нарушается кислотно-щелочной баланс.' ,
'Проверь, не торчит ли у тебя нож из живота.' ,
'Перестаньте мне орать!' ,
'Подкинь ему грабли, на которые он еще не наступал.' ,
'Прыгают тут как блохи... Все, я пошел за дихлофосом!' ,
'Разбудите меня, когда это закончится...' ,
'Ребенок сильнее ударил бы!' ,
'Славно вмазал!' ,
'Славно они веселятся' ,
'Смотрю вот на вас, и слезы наворачиваются.' ,
'Сначала учатся ходить, а потом только в драку лезут.' ,
'Так они друг другу что-нибудь сломают.' ,
'Так ты ему все кости переломаешь!' ,
'У меня в подъезде точно так же соседа прессанули' ,
'Убогих развелось...' ,
'Ух ты, какой прыткий!' ,
'Фашист!! Надо ж, так по больному месту врезать...' ,
'Хватит бить его об угол моей кабинки! Мне же потом ее чинить.' ,
'Хулиганы, прекратите немедленно!' ,
'Хочешь, подскажу, куда он ударит?' ,
'Хорошо, что у меня ловкости больше чем у вас всех, а то б вы и меня в инвалидную коляску посадили бы.' ,
'Хороший бой!' ,
'Хороший удар!' ,
'Хиляк-разрядник!' ,
'Что ты его за волосы схватил?! Отпусти немедленно!' ,
'Щас я вас настигну, вот тогда мы и похохочем' ,
'Это была какая-то неизвестная мне техника...' ,
'Это же противник, а не глина! Хватит мяться!' ,
'Это не бой, это издевательское избиение.' ,
'Это поубавит спеси' ,
'Это и был твой план "Б" ?' ,
'Это была какая-то неизвестная мне техника...' ,
'Я же предупреждал, - будет больно.' ,
'Я не страдаю безумием. Я наслаждаюсь им каждую минуту :)' ,
'Я красивый, я сильный, я умный, я добрый. А вот вы? Вы себя-то видели?!' ,
'Я тоже умею драться, но не буду...' ,
'(тревожно озираясь) я вам по секрету скажу... за вами наблюдают!' ,
'<вырезано цензурой> после боя я этих <вырезано цензурой> обоих в <вырезано цензурой> и <вырезано цензурой>' ,
'<вырезано цензурой> каратисты фиговы' );
// рандомайзим и шансуем ;)
if ( mt_rand ( 0 , 3 ) == 1 ) {
return '<span class=date>' . date ( " H:i " ) . '</span> <i>Комментатор: ' . $boycom [ mt_rand ( 0 , count ( $boycom ) - 1 )] . '</i><BR>' ;
} else {
return false ;
}
}
/*-------------------------------------------------------------------
мочим трупов
--------------------------------------------------------------------*/
function solve_mf ( $enemy , $myattack )
{
2019-09-20 18:13:09 +03:00
// БОНУСЫ! Как бы работают, но просто отвратительно.
// todo переоформить всю таблицу effects, чтобы туда писался сам параметр и его значение, чтобы на выхлопе суммировать;
// $zo = mysql_fetch_row(mysql_query("SELECT id FROM effects WHERE type=201 AND owner=" . (int)$this->user['id'] . ";"));
// $zo1 = mysql_fetch_row(mysql_query("SELECT id FROM effects WHERE type=201 AND owner=" . (int)$this->enemyhar['id'] . ";"));
// $zo2 = mysql_fetch_row(mysql_query("SELECT id FROM effects WHERE type=205 AND owner=" . (int)$this->user['id'] . ";"));
// $zo3 = mysql_fetch_row(mysql_query("SELECT id FROM effects WHERE type=205 AND owner=" . (int)$this->enemyhar['id'] . ";"));
// $sokr = mysql_fetch_row(mysql_query("SELECT id FROM effects WHERE type=202 AND owner=" . (int)$this->user['id'] . ";"));
// $sokr1 = mysql_fetch_row(mysql_query("SELECT id FROM effects WHERE type=202 AND owner=" . (int)$this->enemyhar['id'] . ";"));
// $sokr2 = mysql_fetch_row(mysql_query("SELECT id FROM effects WHERE type=204 AND owner=" . (int)$this->user['id'] . ";"));
// $sokr3 = mysql_fetch_row(mysql_query("SELECT id FROM effects WHERE type=204 AND owner=" . (int)$this->enemyhar['id'] . ";"));
// $mfusil = @mysql_fetch_row(@mysql_query("SELECT id,name FROM effects WHERE type=50 AND owner=" . (int)$user['id'] . ";"));
// $bmfud = $sokr[0] > 0 ? 1 : 0;//владение оружием !
// $bmfud = $sokr2[0] > 0 ? 1.5 : 0;//владение оружием !
// $bmfbron = $zo[0] > 0 ? 2 : 0;//броня
// $bmfbron = $zo2[0] > 0 ? 5 : 0;//броня
$bmfud = 0 ;
$bmfbron = 0 ;
2018-01-28 18:40:49 +02:00
$bmfuv = 0 ;
$bmfauv = 0 ;
$bmfakrit = 0 ;
2019-09-20 17:17:42 +03:00
$bmfkrit = 0 ;
2019-09-20 18:13:09 +03:00
// $bmfuv += $mfusil['mfuvorot'];
// $bmfauv += $mfusil['mfauvorot'];
// $bmfakrit += $mfusil['mfakrit'];
// $bmfkrit += $mfusil['mfkrit'];
// $bmfud1 = $sokr1[0] > 0 ? 1 : 0;//владение оружием
// $bmfud1 = $sokr3[0] > 0 ? 1.5 : 0;//владение оружием
// $bmfbron1 = $zo1[0] > 0 ? 2 : 0;//броня
// $bmfbron1 = $zo3[0] > 0 ? 5 : 0;//броня
$bmfud1 = 0 ;
$bmfbron1 = 0 ;
2018-01-28 18:40:49 +02:00
$bmfuv1 = 0 ;
$bmfauv1 = 0 ;
$bmfakrit1 = 0 ;
2019-09-20 17:17:42 +03:00
$bmfkrit1 = 0 ;
2019-09-20 16:57:58 +03:00
if ( $this -> user [ 'sila' ] >= 25 ) {
$bmfakrit += round ( $this -> user [ 'sila' ] / 3 );
$bmfauv += round ( $this -> user [ 'sila' ] / 3 );
}
if ( $this -> user [ 'lovk' ] >= 25 ) {
$bmfuv += round ( $this -> user [ 'sila' ] / 2 );
$bmfauv += round ( $this -> user [ 'sila' ] / 3 );
}
if ( $this -> user [ 'inta' ] >= 25 ) {
$bmfkrit += round ( $this -> user [ 'sila' ] / 2 );
$bmfakrit += round ( $this -> user [ 'sila' ] / 3 );
}
if ( $this -> user [ 'vinos' ] >= 25 ) {
$bmfbron += round ( $this -> user [ 'vinos' ] / 25 );
}
if ( $this -> enemyhar [ 'sila' ] >= 25 ) {
$bmfakrit1 += round ( $this -> enemyhar [ 'sila' ] / 3 );
$bmfauv1 += round ( $this -> enemyhar [ 'sila' ] / 3 );
}
if ( $this -> enemyhar [ 'lovk' ] >= 25 ) {
$bmfuv1 += round ( $this -> enemyhar [ 'sila' ] / 2 );
$bmfauv1 += round ( $this -> enemyhar [ 'sila' ] / 3 );
}
if ( $this -> enemyhar [ 'inta' ] >= 25 ) {
$bmfkrit1 += round ( $this -> enemyhar [ 'sila' ] / 2 );
$bmfakrit1 += round ( $this -> enemyhar [ 'sila' ] / 3 );
}
if ( $this -> enemyhar [ 'vinos' ] >= 25 ) {
$bmfbron1 += round ( $this -> enemyhar [ 'vinos' ] / 25 );
}
2018-01-28 18:40:49 +02:00
//*************
$mf = array ();
if ( $enemy > _BOTSEPARATOR_ ) {
$bots = mysql_fetch_array ( mysql_query ( 'SELECT * FROM `bots` WHERE `id` = ' . $enemy . ' LIMIT 1;' ));
$this -> enemyhar = mysql_fetch_array ( mysql_query ( 'SELECT * FROM `users` WHERE `id` = \'' . $bots [ 'prototype' ] . '\' LIMIT 1;' ));
$this -> enemy_dress = mysql_fetch_array ( mysql_query ( 'SELECT sum(minu),sum(maxu),sum(mfkrit),sum(mfakrit),sum(mfuvorot),sum(mfauvorot),sum(bron1),sum(bron2),sum(bron3),sum(bron4) FROM `inventory` WHERE `dressed`=1 AND `owner` = \'' . $bots [ 'prototype' ] . '\' LIMIT 1;' ));
$this -> enemyhar [ 'hp' ] = $bots [ 'hp' ];
} else {
$this -> enemyhar = mysql_fetch_array ( mysql_query ( 'SELECT * FROM `users` WHERE `id` = \'' . $enemy . '\' LIMIT 1;' ));
$this -> enemy_dress = mysql_fetch_array ( mysql_query ( 'SELECT sum(minu),sum(maxu),sum(mfkrit),sum(mfakrit),sum(mfuvorot),sum(mfauvorot),sum(bron1),sum(bron2),sum(bron3),sum(bron4) FROM `inventory` WHERE `dressed`=1 AND `owner` = \'' . $enemy . '\' LIMIT 1;' ));
}
$this -> user_dress = mysql_fetch_array ( mysql_query ( 'SELECT sum(minu),sum(maxu),sum(mfkrit),sum(mfakrit),sum(mfuvorot),sum(mfauvorot),sum(bron1),sum(bron2),sum(bron3),sum(bron4) FROM `inventory` WHERE `dressed`=1 AND `owner` = \'' . $this -> user [ 'id' ] . '\' LIMIT 1;' ));
$this -> enemy_dress [ 6 ] += $bmfbron1 ;
$this -> enemy_dress [ 7 ] += $bmfbron1 ;
$this -> enemy_dress [ 8 ] += $bmfbron1 ;
$this -> enemy_dress [ 9 ] += $bmfbron1 ;
$this -> user_dress [ 6 ] += $bmfbron ;
$this -> user_dress [ 7 ] += $bmfbron ;
$this -> user_dress [ 8 ] += $bmfbron ;
$this -> user_dress [ 9 ] += $bmfbron ;
$mykrit = $this -> user_dress [ 2 ] + $this -> user [ 'inta' ] * 2.95 + $bmfkrit ;
$heakrit = ( $this -> enemy_dress [ 3 ] + $this -> enemyhar [ 'inta' ] * 2.75 + $this -> enemyhar [ 'lovk' ]) * 0 + $bmfakrit1 ;
$myuvorot = $this -> user_dress [ 4 ] + $this -> user [ 'lovk' ] * 5 + $bmfuv ;
$heauvorot = $this -> enemy_dress [ 5 ] + $this -> enemyhar [ 'lovk' ] * 4 + $this -> enemyhar [ 'inta' ] * 1.35 + $bmfauv1 ;
$mf [ 'me' ] = array (
'udar' => rand ( floor ( $this -> user [ 'sila' ] / 3 ) + 1 + $this -> user_dress [ 0 ], floor ( $this -> user [ 'sila' ] / 3 ) + 5 + $this -> user_dress [ 1 ]) - mt_rand ( 0 , $this -> enemy_dress [ 5 + $myattack ] / 1.25 ),
2018-02-27 04:48:51 +02:00
'krit' => $mykrit / $heakrit * 100 - 100 ,
'uvorot' => $myuvorot / $heauvorot * 100 - 100
2018-01-28 18:40:49 +02:00
);
if ( $mf [ 'me' ][ 'udar' ] < 1 ) {
$mf [ 'me' ][ 'udar' ] = 1 ;
}
if ( $mf [ 'me' ][ 'krit' ] < 1 ) {
$mf [ 'me' ][ 'krit' ] = 1 ;
} elseif ( $mf [ 'me' ][ 'krit' ] > 50 ) {
$mf [ 'me' ][ 'krit' ] = 50 ;
}
if ( $mf [ 'me' ][ 'uvorot' ] < 1 ) {
$mf [ 'me' ][ 'uvorot' ] = 1 ;
} elseif ( $mf [ 'me' ][ 'uvorot' ] > 65 ) {
$mf [ 'me' ][ 'uvorot' ] = 65 ;
}
if ( $this -> get_wep_type ( $this -> user [ 'weap' ]) == 'kulak' && $this -> user [ 'align' ] == '2' ) {
$mf [ 'me' ][ 'udar' ] += $this -> user [ 'level' ];
}
switch ( $this -> get_wep_type ( $this -> user [ 'weap' ])) {
case " noj " :
$mf [ 'me' ][ 'udar' ] += $this -> user [ 'noj' ];
break ;
case " dubina " :
$mf [ 'me' ][ 'udar' ] += $this -> user [ 'dubina' ];
break ;
case " topor " :
$mf [ 'me' ][ 'udar' ] += $this -> user [ 'topor' ];
break ;
case " mech " :
$mf [ 'me' ][ 'udar' ] += $this -> user [ 'mec' ];
break ;
}
$mf [ 'me' ][ 'udar' ] += $bmfud ;
// МФ врага в отношении меня
mt_srand ( microtime ());
$myakrit = $this -> user_dress [ 3 ] + $this -> user [ 'inta' ] * 2.75 + $this -> user [ 'lovk' ] * 0 + $bmfakrit ;
//if($myakrit < 1) { $myakrit = 1; } elseif ($myakrit > 50) { $myakrit = 50; }
$hekrit = $this -> enemy_dress [ 2 ] + $this -> enemyhar [ 'inta' ] * 2.95 + $bmfkrit1 ;
//if($hekrit < 1) { $hekrit = 1; } elseif ($hekrit > 50) { $hekrit = 50; }
$myauvorot = $this -> user_dress [ 5 ] + $this -> user [ 'lovk' ] * 4 + $this -> user [ 'inta' ] * 1.35 + $bmfauv ;
//if($myauvorot < 1) { $myauvorot = 1; } elseif ($myauvorot > 50) { $myauvorot = 50; }
$heuvorot = $this -> enemy_dress [ 4 ] + $this -> enemyhar [ 'lovk' ] * 5 + $this -> enemyhar [ 'inta' ] * 0 + $bmfuv1 ;
$mf [ 'he' ] = array (
'udar' => rand ( floor ( $this -> enemyhar [ 'sila' ] / 3 ) + 1 + $this -> enemy_dress [ 0 ], floor ( $this -> enemyhar [ 'sila' ] / 3 ) + 4 + $this -> enemy_dress [ 1 ]) - mt_rand ( 0 , $this -> user_dress [ 5 + $this -> battle [ $enemy ][ $this -> user [ 'id' ]][ 0 ]] / 1.25 ),
'krit' => $hekrit / $myakrit * 100 - 100 , //(1-($myakrit+70)/($hekrit+70))*70, //(1 - $myakrit/$hekrit)*100, //
'uvorot' => $heuvorot / $myauvorot * 100 - 100 //(1-($myauvorot+80)/($heuvorot+80))*53, //(1 - $myauvorot/$heuvorot)*0.8*100, //
);
if ( $mf [ 'he' ][ 'udar' ] < 1 ) {
$mf [ 'he' ][ 'udar' ] = 1 ;
}
if ( $mf [ 'he' ][ 'krit' ] < 1 ) {
$mf [ 'he' ][ 'krit' ] = 1 ;
} elseif ( $mf [ 'he' ][ 'krit' ] > 50 ) {
$mf [ 'he' ][ 'krit' ] = 50 ;
}
if ( $mf [ 'he' ][ 'uvorot' ] < 1 ) {
$mf [ 'he' ][ 'uvorot' ] = 1 ;
} elseif ( $mf [ 'he' ][ 'uvorot' ] > 65 ) {
$mf [ 'he' ][ 'uvorot' ] = 65 ;
}
if ( $this -> get_wep_type ( $this -> enemyhar [ 'weap' ]) == 'kulak' && $this -> enemyhar [ 'align' ] == '2' ) {
$mf [ 'he' ][ 'udar' ] += $this -> enemyhar [ 'level' ];
}
switch ( $this -> get_wep_type ( $this -> enemyhar [ 'weap' ])) {
case " noj " :
$mf [ 'he' ][ 'udar' ] += $this -> enemyhar [ 'noj' ];
break ;
case " dubina " :
$mf [ 'he' ][ 'udar' ] += $this -> enemyhar [ 'dubina' ];
break ;
case " topor " :
$mf [ 'he' ][ 'udar' ] += $this -> enemyhar [ 'topor' ];
break ;
case " mech " :
$mf [ 'he' ][ 'udar' ] += $this -> enemyhar [ 'mec' ];
break ;
}
$mf [ 'he' ][ 'udar' ] += $bmfud1 ;
if ( $enemy > _BOTSEPARATOR_ ) {
$mf [ 'he' ][ 'krit' ] -= 6 ;
}
return $mf ;
}
2018-02-27 04:48:51 +02:00
/**
* Получаем тип оружия
* @param $idwep
* @return string
*/
2018-01-28 18:40:49 +02:00
function get_wep_type ( $idwep )
{
2018-02-27 04:48:51 +02:00
$wep = db :: c () -> query ( 'SELECT `otdel` FROM `inventory` WHERE `id` = ?i' , $idwep ) -> fetch_assoc ();
switch ( $wep [ 'otdel' ]) {
2018-11-01 12:40:06 +02:00
case 1 :
return " noj " ;
break ;
case 11 :
return " topor " ;
break ;
case 12 :
return " dubina " ;
break ;
case 13 :
return " mech " ;
break ;
case 14 :
return " priklad " ;
break ; //???
default :
return " kulak " ;
break ;
2018-01-28 18:40:49 +02:00
}
}
2018-02-27 04:48:51 +02:00
/**
* Процентник 1d100. Передавать значения от 1 до 100.
* @param $persent
* @return bool
*/
2018-01-28 18:40:49 +02:00
function get_chanse ( $persent )
{
2018-11-01 12:40:06 +02:00
if ( rand ( 1 , 100 ) <= $persent ) {
2018-01-28 18:40:49 +02:00
return true ;
} else {
return false ;
}
}
/*-------------------------------------------------------------------
инициализируем размен
--------------------------------------------------------------------*/
function razmen_log ( $type , $kuda , $chem , $uron , $kto , $c1 , $pokomy , $c2 , $hp , $maxhp )
{
2020-08-27 15:17:02 +03:00
$this -> write_stat ( Nick :: id ( $kto ) -> short () . " |++| " . Nick :: id ( $pokomy ) -> short () . " |++| " . $type . " |++| " . $uron . " |++| " . $kuda . " |++| " . $chem );
2018-02-27 04:48:51 +02:00
2018-01-28 18:40:49 +02:00
if ( $this -> enemyhar [ 'sex' ] && $kto == $this -> enemyhar [ 'id' ]) {
$sex1 = false ;
}
if ( ! $this -> enemyhar [ 'sex' ] && $kto == $this -> enemyhar [ 'id' ]) {
$sex1 = true ;
}
if ( $this -> enemyhar [ 'sex' ] && $pokomy == $this -> enemyhar [ 'id' ]) {
$sex2 = false ;
}
if ( ! $this -> enemyhar [ 'sex' ] && $pokomy == $this -> enemyhar [ 'id' ]) {
$sex2 = true ;
}
if ( $this -> user [ 'sex' ] && $kto == $this -> user [ 'id' ]) {
$sex1 = false ;
}
if ( ! $this -> user [ 'sex' ] && $kto == $this -> user [ 'id' ]) {
$sex1 = true ;
}
if ( $this -> user [ 'sex' ] && $pokomy == $this -> user [ 'id' ]) {
$sex2 = false ;
}
if ( ! $this -> user [ 'sex' ] && $pokomy == $this -> user [ 'id' ]) {
$sex2 = true ;
}
if ( $hp < 0 ) {
$hp = 0 ;
}
$hiden_warior = mysql_fetch_array ( mysql_query ( 'SELECT `id`, `invis` FROM `users` WHERE `id` = "' . $pokomy . '" LIMIT 1' ));
if ( $hiden_warior [ 'invis' ] == 1 ) {
$hp = '??' ;
$maxhp = '??' ;
$uron = '??' ;
}
// текст по промазыванию
if ( ! $sex1 ) {
$textfail = array ( 'думал о <вырезано цензурой>, вследствие чего' ,
'пытался нанести удар, но ' ,
'подскользнулся, и' ,
'старался провести удар, но' ,
'закашлялся, и' ,
'пытался провести удар, но' ,
'потерял самоконтроль, вследствие чего' ,
'думал не о том, и' );
} else {
$textfail = array ( 'думала о <вырезано цензурой>, вследствие чего' ,
'пыталась нанести удар, но ' ,
'подскользнулась, и' ,
'старалась провести удар, но' ,
'закашлялась, и' ,
'пыталась провести удар, но ' ,
'потеряла самоконтроль, вследствие чего' ,
'думала не о том, и' );
}
// чем били
$textchem = array (
" kulak " => array ( " грудью " , " ребром руки " , " лбом " , " кулаком " , " ногой " , " левой ногой " , " правой ногой " , " коленом " ),
" noj " => array ( " ножом " , " тыльной стороной лезвия ножа " , " рукоятью ножа " , " лезвием ножа " ),
" dubina " => array ( " сучковатой палкой " , " поленом " , " тяжелой дубиной " , " дубиной " , " рукоятью молота " ),
" topor " => array ( " секирой " , " топором " , " лезвием секиры " , " алебардой " , " тяжелым держаком " , " длинной секирой " ),
" mech " => array ( " ножнами " , " гардой " , " мечом " , " лезвием меча " , " рукоятью меча " , " тупым лезвием " , " острой стороной меча " , " огромным мечом " ,),
" buket " => array ( " охапкой цветов " , " веником " , " букетом " , " колючками " , " снопом " , " стеблем " , " листьями " , " бутоном " ,)
);
$textchem = $textchem [ $chem ];
// куда били
$udars = array (
'1' => array ( 'в нос' , 'в глаз' , 'в челюсть' , 'по переносице' , 'в кадык' , 'по затылку' , 'в правый глаз' , 'в левый глаз' , 'в скулу' ),
'2' => array ( 'в грудь' , 'в корпус' , 'в солнечное сплетение' , 'в сердце' , 'в бок' , 'в область лопаток' , 'по желудку' , 'по левой руке' , 'по правой руке' ),
'3' => array ( 'по <вырезано цензурой>' , 'в пах' , 'в промежность' , 'по левой ягодице' , 'по правой ягодице' ),
'4' => array ( 'по ногам' , 'в область правой пятки' , 'в область левой пятки' , 'по коленной чашечке' , 'по икрам' )
);
$kuda = $udars [ $kuda ][ mt_rand ( 0 , count ( $udars [ $kuda ]) - 1 )];
//тест по попаданию
if ( ! $sex1 ) {
$hark = array ( 'бесчувственный' , 'расстроенный' , 'храбрый' , 'обезумевший' , 'неустрашимый' , 'злобный' , 'жестокий' , 'наглый' ,
'разъяренный' , 'продвинутый' , 'хитрый' , 'мужественный' , '' , '' , '' , '' , '' , '' );
} else {
$hark = array ( 'бесчувственная' , 'расстроенная' , 'храбрая' , 'обезумевшая' , 'неустрашимая' , 'злобная' , 'жестокая' , 'наглая' ,
'разъяренная' , 'продвинутая' , 'хитрая' , 'прекрасная' , '' , '' , '' , '' , '' , '' );
}
if ( ! $sex2 ) {
$hark2 = array ( 'бесчувственный' , 'расстроенный' , 'храбрый' , 'обезумевший' , 'неустрашимый' , 'злобный' , 'жестокий' , 'наглый' ,
'разъяренный' , 'продвинутый' , 'хитрый' , 'мужественный' , '' , '' , '' , '' , '' , '' );
} else {
$hark2 = array ( 'бесчувственная' , 'расстроенная' , 'храбрая' , 'обезумевшая' , 'неустрашимая' , 'злобная' , 'жестокая' , 'наглая' ,
'разъяренная' , 'продвинутая' , 'хитрая' , 'прекрасная' , '' , '' , '' , '' , '' , '' );
}
if ( ! $sex2 ) {
$textud = array ( 'забылся, и тут' ,
'замешкался, и за это' ,
'растерялся, как вдруг' ,
'ковырялся в зубах, и тут' ,
'поперхнулся, но вдруг' ,
'пытался что-то сказать но вдруг, неожиданно' ,
'растерялся, как вдруг' ,
'засмотрелся на <вырезано цензурой>, а в это время' ,
'высморкался, и в это время' ,
'думал не о том, и' ,
'пришел в себя, но в это время' ,
'обернулся, как внезапно' );
} else {
$textud = array ( 'забылась, и тут' ,
'замешкалась, и за это ' ,
'растерялась, как вдруг ' ,
'ковырялась в зубах, и тут ' ,
'поперхнулась, но вдруг ' ,
'пыталась что-то сказать но вдруг, неожиданно' ,
'растерялась, как вдруг' ,
'засмотрелась на <вырезано цензурой>, а в это время' ,
'высморкалась, и в это время' ,
'думала не о том, и' ,
'пришла в себя, но в это время ' ,
'обернулась, как внезапно' );
}
switch ( $type ) {
// уворот
case " uvorot " :
if ( $sex2 ) {
$textuvorot = array ( " <font color=green><B>уклонилась</B></font> от удара " , " <font color=green><B>увернулась</B></font> от удара " , " <font color=green><B>отскочила</B></font> от удара " );
} else {
$textuvorot = array ( " <font color=green><B>уклонился</B></font> от удара " , " <font color=green><B>увернулся</B></font> от удара " , " <font color=green><B>отскочил</B></font> от удара " );
}
2020-08-27 15:17:02 +03:00
return '<span class=date>' . date ( " [H:i:s] " ) . '</span> ' . Nick :: id ( $kto ) -> short () . ' ' . $textfail [ rand ( 0 , count ( $textfail ) - 1 )] . ' ' . $hark2 [ rand ( 0 , count ( $hark2 ) - 1 )] . ' ' . Nick :: id ( $pokomy ) -> short () . ' ' . $textuvorot [ rand ( 0 , count ( $textuvorot ) - 1 )] . ' ' . $textchem [ rand ( 0 , count ( $textchem ) - 1 )] . ' ' . $kuda . '.<BR>' ;
2018-01-28 18:40:49 +02:00
break ;
//блок
case " block " :
if ( $sex2 ) {
$textblock = array ( " заблокировала удар " , " остановила удар " , " отбила удар " );
} else {
$textblock = array ( " заблокировал удар " , " остановил удар " , " отбил удар " );
}
2020-08-27 15:17:02 +03:00
return '<span class=date>' . date ( " [H:i:s] " ) . '</span> ' . Nick :: id ( $kto ) -> short () . ' ' . $textfail [ rand ( 0 , count ( $textfail ) - 1 )] . ' ' . $hark2 [ rand ( 0 , count ( $hark2 ) - 1 )] . ' ' . Nick :: id ( $pokomy ) -> short () . ' ' . $textblock [ rand ( 0 , count ( $textblock ) - 1 )] . ' ' . $textchem [ rand ( 0 , count ( $textchem ) - 1 )] . ' ' . $kuda . '.<BR>' ;
2018-01-28 18:40:49 +02:00
break ;
//крит
case " krit " :
if ( $sex1 ) {
$textkrit = array ( " , напугав всех, неслышно подойдя сзади ударила " , " , сказав \" БУ! \" , ласково ударила " , " , расслабившись, ударила " , " , показав сразу два пальца, ударила " , " , напугав всех, укусила " , " , проклиная этот сайт, ударила " );
} else {
$textkrit = array ( " , напугав всех, неслышно подойдя сзади ударил " , " , сказав \" БУ! \" , ласково ударил " , " , расслабившись, ударил " , " , показав сразу два пальца, ударил " , " , напугав всех, укусил " , " , проклиная этот сайт, ударил " );
}
2020-08-27 15:17:02 +03:00
return '<span class=date>' . date ( " [H:i:s] " ) . '</span> ' . Nick :: id ( $pokomy ) -> short () . ' ' . $textud [ rand ( 0 , count ( $textud ) - 1 )] . ' ' . $hark [ rand ( 0 , count ( $hark ) - 1 )] . ' ' . Nick :: id ( $kto ) -> short () . ' ' . $textkrit [ rand ( 0 , count ( $textkrit ) - 1 )] . ' ' . $kuda . '.<b><font color=red>-' . $uron . '</font></b> [' . $hp . '/' . $maxhp . ']' . '<BR>' ;
2018-01-28 18:40:49 +02:00
break ;
//крит
case " krita " :
if ( $sex1 ) {
$textkrit = array ( " , напугав всех, неслышно подойдя сзади, пробив блок, ударила " , " , сказав \" БУ! \" , ласково, пробив блок, ударила " , " , расслабившись, пробив блок, ударила " , " , показав сразу два пальца, пробив блок, ударила " , " , напугав всех, пробив блок, укусила " , " , проклиная этот сайт, пробив блок, ударила " );
} else {
$textkrit = array ( " , напугав всех, неслышно подойдя сзади, пробив блок, ударил " , " , сказав \" БУ! \" , ласково, пробив блок, ударил " , " , расслабившись , пробив блок , ударил " , " , показав сразу два пальца , пробив блок , ударил " , " , напугав всех , пробив блок , укусил " , " , проклиная этот сайт , пробив блок , ударил " );
}
2020-08-27 15:17:02 +03:00
return '<span class=date>' . date( " [ H : i : s ] " ) . '</span> ' . Nick::id( $pokomy )->short() . ' ' . $textud [rand(0, count( $textud ) - 1)] . ' ' . $hark [rand(0, count( $hark ) - 1)] . ' ' . Nick::id( $kto )->short() . ' ' . $textkrit [rand(0, count( $textkrit ) - 1)] . ' ' . $kuda . '.<b><font color=red>-' . $uron . '</font> </b>[' . $hp . '/' . $maxhp . ']' . '<BR>';
2018-01-28 18:40:49 +02:00
break;
// попадание
case " udar " :
if ( $sex1 ) {
$textudar = array( " , разбежавшись , рубанула " , " отчаянно проткнула " , " нехотя уколола " , " не подумав , рубанула " , " , улыбаясь , саданула укол " , " приложила удар " , " ударила " , " сдуру вмазала " );
} else {
$textudar = array( " , разбежавшись , рубанул " , " отчаянно проткнул " , " нехотя уколол " , " не подумав , рубанул " , " , улыбаясь , саданул укол " , " приложил удар " , " ударил " , " сдуру вмазал " );
}
2020-08-27 15:17:02 +03:00
return '<span class=date>' . date( " [ H : i : s ] " ) . '</span> ' . Nick::id( $pokomy )->short() . ' ' . $textud [rand(0, count( $textud ) - 1)] . ' ' . $hark [rand(0, count( $hark ) - 1)] . ' ' . Nick::id( $kto )->short() . '' . $textudar [rand(0, count( $textudar ) - 1)] . ' ' . $textchem [rand(0, count( $textchem ) - 1)] . ' ' . $kuda . ' <b>-' . $uron . '</b> [' . $hp . '/' . $maxhp . ']' . '<BR>';
2018-01-28 18:40:49 +02:00
break;
}
}
/*------------------------------------------------------------------
получаем тип оружия
--------------------------------------------------------------------*/
function write_stat( $text )
{
$fp = fopen( " backup / stat / battle " . $this->user ['battle'] . " . txt " , " a " ); //открытие
flock( $fp , LOCK_EX); //БЛОКИРОВКА ФАЙЛА
fputs( $fp , $text . " \n " ); //работа с файлом
fflush( $fp ); //ОЧИЩЕНИЕ ФАЙЛОВОГО БУФЕРА И ЗАПИСЬ В ФАЙЛ
flock( $fp , LOCK_UN); //СНЯТИЕ БЛОКИРОВКИ
fclose( $fp ); //закрытие
}
/*------------------------------------------------------------------
генератор ударов =)
--------------------------------------------------------------------*/
function get_block( $komy , $att , $def , $enemy )
{
// по типам блоков
$blocks = array(
'1' => array(1, 2),
'2' => array(2, 3),
'3' => array(3, 4),
'4' => array(4, 1)
);
switch ( $komy ) {
case " me " :
if (!in_array( $this->battle [ $enemy ][ $this->user ['id']][0], $blocks[$def] )) {
return true;
} else {
return false;
}
break;
// бьем вражину
case " he " :
if (!in_array( $att , $blocks[$this->battle[$enemy] [ $this->user ['id']][1]])) {
return true;
} else {
return false;
}
break;
}
}
/*------------------------------------------------------------------
проверка на попадание " куда надо "
--------------------------------------------------------------------*/
function select_enemy2( $smena_id )
{
if (( $this->user ['hp'] > 0) && $this->battle ) {
foreach ( $this->battle [ $this->user ['id']] as $k => $v ) {
if ( $this->battle [ $this->user ['id']][ $smena_id ][0] == 0) {
$enemys [] = $smena_id ;
}
}
$_SESSION['enemy'] = $smena_id ;
$this->enemy = $smena_id ;
return $enemys ;
} else {
return 0;
}
}
/*------------------------------------------------------------------
возвращает получился шанс или нет
--------------------------------------------------------------------*/
function fast_death()
{
// убиваем трупов
if ( $this->battle ) {
// $this->battle [ $this->user ['id']]=1;
foreach ( $this->battle as $k => $v ) {
if ( $k > _BOTSEPARATOR_) {
$bots = mysql_fetch_array(mysql_query('SELECT * FROM `bots` WHERE `id` = ' . $k . ' LIMIT 1;'));
2018-11-01 12:40:06 +02:00
$us = mysql_fetch_array(mysql_query('SELECT `hp`, `maxhp`, `id`,`battle` FROM `users` WHERE `id` = ' . $bots['prototype'] . ' LIMIT 1;'));
2018-01-28 18:40:49 +02:00
$us['hp'] = $bots['hp'] ;
$us['battle'] = $bots['battle'] ;
} else {
2018-11-01 12:40:06 +02:00
$us = mysql_fetch_array(mysql_query('SELECT `hp`, `maxhp`, `id`,`battle` FROM `users` WHERE `id` = ' . $k . ' LIMIT 1;'));
2018-01-28 18:40:49 +02:00
}
if ( $us && (int) $us['hp'] <= 0) {
// $battle_data = mysql_fetch_array(mysql_query ('SELECT * FROM `battle` WHERE `id` = '. $this->user ['battle'].' LIMIT 1;'));
// $war = unserialize( $battle_data['teams'] );
// unset( $battle_data );
// $war =array_keys( $war );
// if(in_array( $k , $war )) {
unset( $this->battle [ $k ]);
2018-11-01 12:40:06 +02:00
2020-08-27 15:17:02 +03:00
$this->add_log ('<span class=date>' . date( " H : i " ) . '</span> ' . Nick::id( $k )->short() . ' проиграл бой!<BR>');
2018-11-01 12:40:06 +02:00
2018-01-28 18:40:49 +02:00
mysql_query('UPDATE `users` SET `hp` = 0, `fullhptime` = ' . time() . ' WHERE `id` = \ '' . $k . ' \ ' LIMIT 1;');
foreach ( $this->battle as $kak => $vav ) {
unset( $this->battle [ $kak ][ $k ]);
}
//}
}
if ( $k == null) {
//unset( $this->battle [ $k ]);
foreach ( $this->battle as $kak => $vav ) {
unset( $this->battle [ $kak ][ $k ]);
}
}
2019-01-16 19:45:30 +02:00
// if ( $us['battle'] == 0) {
// //unset( $this->battle [ $k ]);
// foreach ( $this->battle as $kak => $vav ) {
// //unset( $this->battle [ $kak ][ $k ]);
// }
// }
2018-01-28 18:40:49 +02:00
unset( $us );
}
// обновить битку
$this->update_battle ();
}
}
/*------------------------------------------------------------------
выбираем противничка
--------------------------------------------------------------------*/
function select_enemy()
{
if (( $this->user ['hp'] > 0) && $this->battle ) {
foreach ( $this->battle [ $this->user ['id']] as $k => $v ) {
if ( $this->battle [ $this->user ['id']][ $k ][0] == 0) {
$enemys [] = $k ;
}
}
return $enemys [mt_rand(0, count( $enemys ) - 1)];
} else {
return 0;
}
}
/*------------------------------------------------------------------
считаем модификаторы
--------------------------------------------------------------------*/
function get_timeout()
{
if ( $this->battle ) {
if ( $this->my_class == 'B1') {
if ( $this->to2 <= $this->to1 ) {
return ((time() - $this->to2 ) > $this->battle_data ['timeout'] * 60);
} else {
return false;
}
} else {
if ( $this->to2 >= $this->to1 ) {
return ((time() - $this->to1 ) > $this->battle_data ['timeout'] * 60);
} else {
return false;
}
}
}
}
/*------------------------------------------------------------------
сейвим бой
--------------------------------------------------------------------*/
function end_draft()
{
//foreach ( $this->battle [ $this->user ['id']] as $k => $v ) {
if (! $this->user ['in_tower']) {
if ( $this->get_timeout ()) {
$this->battle = null;
mysql_query( " UPDATE users SET `battle` = 0 , `fullhptime` = " . time() . " WHERE `battle` = { $this -> user [ 'battle' ]} " );
$this->add_log ( " < span class = date > " . date( " H : i " ) . " </ span > Бой закончен по таймауту . Ничья .< BR > " );
mysql_query( " UPDATE battle SET `win` = 0 WHERE `id` = { $this -> user [ 'battle' ]} " );
$this->exp = null;
$this->write_log ();
}
}
}
/*------------------------------------------------------------------
генератор фраз комментатора
--------------------------------------------------------------------*/
function write_log()
{
//mysql_query('UPDATE `logs` SET `log` = CONCAT(`log`, \ ''. $this->log .' \ ') WHERE `id` = '. $this->user ['battle'].'');
$fp = fopen( " backup / logs / battle " . $this->user ['battle'] . " . txt " , " a " ); //открытие
flock( $fp , LOCK_EX); //БЛОКИРОВКА ФАЙЛА
fputs( $fp , $this->log ); //работа с файлом
fflush( $fp ); //ОЧИЩЕНИЕ ФАЙЛОВОГО БУФЕРА И ЗАПИСЬ В ФАЙЛ
flock( $fp , LOCK_UN); //СНЯТИЕ БЛОКИРОВКИ
fclose( $fp ); //закрытие
$this->log = '';
}
/*------------------------------------------------------------------
есть ли тайм в советском союзе?
--------------------------------------------------------------------*/
function end_gora()
{
// я - царь горы
if ( $this->get_timeout ()) {
// $this->add_log ( " < span class = date > " .date( " H : i " ). " </ span > Бой закончен по таймауту .< BR > " );
// $this->write_log ();
foreach ( $this->team_mine as $v ) {
if (in_array( $v , array_keys( $this->battle ))) {
$vvv = $v ;
// $this->add_log ( " < BR > " . $v );
}
}
$this->add_log ( " < span class = date > " . date( " H : i " ) . " </ span > Бой закончен по таймауту .< BR > " );
foreach ( $this->team_enemy as $v => $k ) {
if ( $k > _BOTSEPARATOR_) {
$bots = mysql_fetch_array(mysql_query('SELECT `hp` FROM `bots` WHERE `id` = ' . $k . ' LIMIT 1;'));
$us['hp'] = $bots['hp'] ;
} else {
$us = mysql_fetch_array(mysql_query('SELECT `hp` FROM `users` WHERE `id` = ' . $k . ' LIMIT 1;'));
}
if ( $us && (int) $us['hp'] > 0) {
if (! $this->battle_data ['blood']) {
$tr = settravma( $k , 0, 86400, 1);
2020-08-27 15:17:02 +03:00
$this->add_log ('<span class=date>' . date( " H : i " ) . '</span> ' . Nick::id( $k )->short() . ' получил повреждение: <font color=red>' . $tr . '</font><BR>');
2018-01-28 18:40:49 +02:00
}
}
}
// $this->write_log ();
foreach ( $this->team_enemy as $v => $k ) {
mysql_query('UPDATE users SET `hp` =0, `fullhptime` = ' . time() . ' WHERE `id` = ' . $k . ';');
}
header( " Location : " . $_SERVER['PHP_SELF'] . " ? batl = " . $this->user ['battle']);
}
}
/*-------------------------------------------------------------------
работа с логами
--------------------------------------------------------------------*/
function battle_end()
{
/////////////OPITO MODIFIKATORIUS: 1-100; 2 - 200; 3 - 300 ir tt.
global $opoitas , $caverooms , $user , $cavebots , $party , $rep ;
$ddd = mysql_fetch_array(mysql_query( " SELECT * FROM `effects` WHERE `owner` = " . $user['id'] . " and `type` = 555 limit 1 ; " ));
if ( $ddd ) {
$opitas = 1.1;
} else {
$opitas = 1;
}
//////////////
if ( $this->battle_data ) {
$ss = @array_keys( $this->battle );
2019-01-16 19:45:30 +02:00
// if ( $this->user ['id'] == 10022) {
// //var_dump( $ss , $this->t1 );
// }
2018-01-28 18:40:49 +02:00
$t1life = 0;
$t2life = 0;
// проверяем живность команд
foreach ( $this->t1 as $k => $v ) {
if (in_array( $v , array_keys( $this->battle ))) {
$t1life ++;
}
}
foreach ( $this->t2 as $k => $v ) {
if (in_array( $v , array_keys( $this->battle ))) {
$t2life ++;
}
}
if ( $t2life == 0 OR $t1life == 0) {
$charge = mysql_fetch_array(mysql_query('SELECT `win` FROM `battle` WHERE `id` = ' . $this->battle_data ['id'] . ' LIMIT 1;'));
}
if (( $t2life == 0 OR $t1life == 0) && ( $charge[0] == 3 || $charge[0] == 9)) {
// ============================= конец боя ==========================
mysql_query( " UPDATE battle SET `win` = 0 WHERE `id` = { $this -> user [ 'battle' ]} " );
// оцениваем игроков
// $cost1 =0; $cost2 =0; $kula4ka = 0; $t2c =0; $t1c =0; $lvs1 =0; $lvs2 =0; $bxp = 0;
foreach ( $this->t1 as $k => $v ) {
2020-08-27 15:17:02 +03:00
$nks1 [] = Nick::id( $v )->short();
$nks1hist [] = Nick::id( $v )->full(1);
2018-01-28 18:40:49 +02:00
}
$lvs1 = $lvs1 / ( $t1c + 1);
foreach ( $this->t2 as $k => $v ) {
2020-08-27 15:17:02 +03:00
$nks2 [] = Nick::id( $v )->short();
$nks2hist [] = Nick::id( $v )->full(1);
2018-01-28 18:40:49 +02:00
}
// тима победителей
if (in_array( $ss[0] , $this->t1 )) {
$flag = 1;
foreach ( $this->t1 as $k => $v ) {
mysql_query('UPDATE `battle` SET `win` = 1 WHERE `id` = ' . $this->user ['battle'] . ' LIMIT 1');
2020-08-27 15:17:02 +03:00
$this->t1 [ $k ] = Nick::id( $v )->short();
2018-01-28 18:40:49 +02:00
$this->exp [ $v ] = $this->exp [ $v ] * $opitas / 1;
$this->exp [ $v ] = round( $this->exp [ $v ]);
if ( $this->user ['x'] != 0 || $this->user ['y'] != 0) {
if ( $this->user ['psh'] > 0) {
//Убиваем монстра, выдаем дроп
$lobj = mysql_fetch_array(mysql_query('SELECT * FROM `psh_bot` WHERE `dn` = " ' . $this->user[' psh '] . ' " AND `x` = " ' . $this->battle_data[' x '] . ' " AND `y` = " ' . $this->battle_data[' y '] . ' " LIMIT 1'));
if (isset( $lobj['id2'] ) && $this->user ['psh'] > 0) {
mysql_query('DELETE FROM `psh_bot` WHERE `dn` = " ' . $this->user[' psh '] . ' " AND `x` = " ' . $this->battle_data[' x '] . ' " AND `y` = " ' . $this->battle_data[' y '] . ' " ');
}
} else {
//Убиваем монстра, выдаем дроп
$lobj = mysql_fetch_assoc(mysql_query( " SELECT * FROM `laba_obj` WHERE `lib` = '" . $this->user[' laba '] . "' AND `x` = '" . $this->user[' x '] . "' AND `y` = '" . $this->user[' y '] . "' " ));
if (isset( $lobj['id'] )) {
$q2 = mysql_fetch_array(mysql_query('SELECT * FROM `qst_user` WHERE `uid` = " ' . $this->user[' id '] . ' " AND `cancel` = " 0 " AND `finish` = " 0 " LIMIT 1'));
if (isset( $q2['id'] )) {
$q1 = mysql_fetch_array(mysql_query('SELECT * FROM `qst` WHERE `id` = " ' . $q2[' qid '] . ' " LIMIT 1'));
if ( $q1['type'] == 3) {
//Выполняем квест на убийство
$jobs = 0;
$sp = mysql_query('SELECT * FROM `bots` WHERE `battle` = " ' . $this->battle_data[' id '] . ' " ');
while ( $pl = mysql_fetch_array( $sp )) {
if ( $q1['obj_id'] == $pl['prototype'] ) {
$jobs ++;
}
}
mysql_query('UPDATE `qst_user` SET `val` = " ' . ($q2[' val '] + $jobs) . ' " WHERE `id` = " ' . $q2[' id '] . ' " LIMIT 1');
}
}
mysql_query( " UPDATE `laba_obj` SET `use` = '" . time() . "' WHERE `lib` = '" . $lobj[' lib '] . "' AND `x` = '" . $lobj[' x '] . "' AND `y` = '" . $lobj[' y '] . "' " );
}
}
}
///////////////////////при победе = для подземки/////////////////////////////////////
$gess = mysql_query('SELECT * FROM `labirint` WHERE `user_id` = ' . $this->user ['id'] . '');
if ( $hokke = mysql_fetch_array( $gess )) {
$glav_id = $hokke["glav_id"] ;
$glava = $hokke["glava"] ;
$nm = $hokke["boi"] ;
/////////////////////////////////////////////////////////////
$DR = mysql_fetch_array(mysql_query( " SELECT * FROM `canal_bot` WHERE `glava` = '$glava' and `boi` = '$nm' " ));
if ( $DR ) {
$bot = $DR["bot"] ;
$nomer = $DR["nomer"] ;
////////////////////////////////////////////////////////////////
$shans1 = rand(0, 100);
$shans2 = rand(0, 100);
$shans3 = rand(0, 100);
////////////////////////////////////////////////////////////////
$est = 0;
$d1 = 0;
$d2 = 0;
$d3 = 0;
if ( $bot == '1' or $bot == '2' or $bot == '3' or $bot == '1.1' or $bot == '1.2' or $bot == '1.3' or $bot == '2.2' or $bot == '2.3' or $bot == '3.3' or $bot == '1.1.1' or $bot == '1.1.2' or $bot == '1.1.2' or $bot == '1.2.2' or $bot == '1.3.2' or $bot == '1.3.3' or $bot == '2.2.2' or $bot == '2.2.3' or $bot == '2.3.3' or $bot == '3.3.3' or $bot == '1.3.2') {
if ( $bot == '1' and $bot == '2' and $bot == '3') {
if ( $shans1 < '25') {
$d1 = 1;
}
}
if ( $bot == '1.1' or $shans2 < '25' and $bot == '1.2' or $shans2 < '25' and $bot == '1.3' or $shans2 < '25' and $bot == '2.2' or $shans2 < '25' and $bot == '2.3' or $shans2 < '25' and $bot == '3.3') {
if ( $shans1 < '25') {
$d1 = 1;
}
if ( $shans2 < '25') {
$d2 = 1;
}
}
if ( $bot == '1.1.1' or $shans3 < '25' and $bot == '1.1.2' or $shans3 < '25' and $bot == '1.1.2' or $shans3 < '25' and $bot == '1.2.2' or $shans3 < '25' and $bot == '1.3.2' or $shans3 < '25' and $bot == '1.3.3' or $shans3 < '25' and $bot == '2.2.2' or $shans3 < '25' and $bot == '2.2.3' or $shans3 < '25' and $bot == '2.3.3' or $shans3 < '25' and $bot == '3.3.3' or $shans3 < '25' and $bot == '1.3.2') {
if ( $shans1 < '25') {
$d1 = 1;
}
if ( $shans2 < '25') {
$d2 = 1;
}
if ( $shans3 < '25') {
$d3 = 1;
}
}
$est = $d1 + $d2 + $d3 + 500;
if ( $est > '500') {
mysql_query( " UPDATE podzem3 SET n $nomer = '$est' WHERE glava = '$glava' and name = '" . $hokke["name"] . "' " );
} else {
mysql_query( " UPDATE podzem3 SET n $nomer = '' WHERE glava = '$glava' and name = '" . $hokke["name"] . "' " );
}
}
if ( $bot == '4' or $bot == '5' or $bot == '6' or $bot == '8') {
if ( $shans1 < '99') {
$est = 504;
}
if ( $est > '500') {
mysql_query( " UPDATE podzem3 SET n $nomer = '$est' WHERE glava = '$glava' and name = '" . $hokke["name"] . "' " );
} else {
mysql_query( " UPDATE podzem3 SET n $nomer = '' WHERE glava = '$glava' and name = '" . $hokke["name"] . "' " );
}
}
if ( $bot == '7') {
if ( $shans1 < '99') {
$est = 510;
}
if ( $est == '510') {
mysql_query( " UPDATE podzem3 SET n $nomer = '$est' WHERE glava = '$glava' and name = '" . $hokke["name"] . "' " );
} else {
mysql_query( " UPDATE podzem3 SET n $nomer = '' WHERE glava = '$glava' and name = '" . $hokke["name"] . "' " );
}
if ( $this->user ['medal2'] == '0') {
mysql_query( " UPDATE `users` SET `medal2` = '1' WHERE `id` = " . $this->user ['id'] . " " );
}
}
//////////////////////////2 etaz/////////////////////////////////////////////////////////////////
if ( $bot == '9' or $bot == '11' or $bot == '9.9' or $bot == '11.11' or $bot == '9.9.9' or $bot == '11.11.11') {
if ( $bot == '9' or $bot == '11') {
if ( $shans1 < '50') {
$d1 = 1;
}
}
if ( $bot == '9.9' or $bot == '11.11') {
if ( $shans1 < '99') {
$d1 = 1;
}
if ( $shans2 < '50') {
$d2 = 1;
}
}
if ( $bot == '9.9.9' or $bot == '11.11.11') {
if ( $shans1 < '50') {
$d1 = 1;
}
if ( $shans2 < '50') {
$d2 = 1;
}
if ( $shans3 < '50') {
$d3 = 1;
}
}
$est = $d1 + $d2 + $d3 + 600;
if ( $est > '600') {
mysql_query( " UPDATE podzem3 SET n $nomer = '$est' WHERE glava = '$glava' and name = '" . $hokke["name"] . "' " );
} else {
mysql_query( " UPDATE podzem3 SET n $nomer = '' WHERE glava = '$glava' and name = '" . $hokke["name"] . "' " );
}
}//////////Чистая гайка////////////////////////////////////////////////////
if ( $bot == '13' or $bot == '13.13' or $bot == '13.13.13') {
if ( $bot == '13') {
if ( $shans1 < '50') {
$d1 = 1;
}
}
if ( $bot == '13.13') {
if ( $shans1 < '50') {
$d1 = 1;
}
if ( $shans2 < '50') {
$d2 = 1;
}
}
if ( $bot == '13.13.13') {
if ( $shans1 < '50') {
$d1 = 1;
}
if ( $shans2 < '50') {
$d2 = 1;
}
if ( $shans3 < '50') {
$d3 = 1;
}
}
$est = $d1 + $d2 + $d3 + 603;
if ( $est > '603') {
mysql_query( " UPDATE podzem3 SET n $nomer = '$est' WHERE glava = '$glava' and name = '" . $hokke["name"] . "' " );
} else {
mysql_query( " UPDATE podzem3 SET n $nomer = '' WHERE glava = '$glava' and name = '" . $hokke["name"] . "' " );
}
}//////////Гайка с резьбой////////////////////////////////////////////////////
if ( $bot == '10' or $bot == '10.10' or $bot == '10.10.10') {
if ( $bot == '10') {
if ( $shans1 < '50') {
$d1 = 1;
}
}
if ( $bot == '10.10') {
if ( $shans1 < '50') {
$d1 = 1;
}
if ( $shans2 < '50') {
$d2 = 1;
}
}
if ( $bot == '10.10.10') {
if ( $shans1 < '50') {
$d1 = 1;
}
if ( $shans2 < '50') {
$d2 = 1;
}
if ( $shans3 < '50') {
$d3 = 1;
}
}
$est = $d1 + $d2 + $d3 + 606;
if ( $est > '606') {
mysql_query( " UPDATE podzem3 SET n $nomer = '$est' WHERE glava = '$glava' and name = '" . $hokke["name"] . "' " );
} else {
mysql_query( " UPDATE podzem3 SET n $nomer = '' WHERE glava = '$glava' and name = '" . $hokke["name"] . "' " );
}
}//////////длинный болт////////////////////////////////////////////////////
if ( $bot == '12' or $bot == '12.12' or $bot == '12.12.12' or $bot == '15' or $bot == '15.15' or $bot == '15.15.15' or $bot == '16' or $bot == '16.16' or $bot == '16.16.16') {
if ( $bot == '12' or $bot == '15' or $bot == '16') {
if ( $shans1 < '50') {
$d1 = 1;
}
}
if ( $bot == '12.12' or $bot == '15.15' or $bot == '16.16') {
if ( $shans1 < '50') {
$d1 = 1;
}
if ( $shans2 < '50') {
$d2 = 1;
}
}
if ( $bot == '12.12.12' or $bot == '15.15.15' or $bot == '16.16.16') {
if ( $shans1 < '50') {
$d1 = 1;
}
if ( $shans2 < '50') {
$d2 = 1;
}
if ( $shans3 < '50') {
$d3 = 1;
}
}
$est = $d1 + $d2 + $d3 + 609;
if ( $est > '609') {
mysql_query( " UPDATE podzem3 SET n $nomer = '$est' WHERE glava = '$glava' and name = '" . $hokke["name"] . "' " );
} else {
mysql_query( " UPDATE podzem3 SET n $nomer = '' WHERE glava = '$glava' and name = '" . $hokke["name"] . "' " );
}
}//////////Нужный болт////////////////////////////////////////////////////
if ( $bot == '14' or $bot == '14.14' or $bot == '14.14.14' or $bot == '17' or $bot == '17.17' or $bot == '17.17.17' or $bot == '18' or $bot == '18.18' or $bot == '18.18.18') {
if ( $bot == '14' or $bot == '17' or $bot == '18') {
if ( $shans1 < '50') {
$d1 = 1;
}
}
if ( $bot == '14.14' or $bot == '17.17' or $bot == '18.18') {
if ( $shans1 < '50') {
$d1 = 1;
}
if ( $shans2 < '50') {
$d2 = 1;
}
}
if ( $bot == '14.14.14' or $bot == '17.17.17' or $bot == '18.18.18') {
if ( $shans1 < '50') {
$d1 = 1;
}
if ( $shans2 < '50') {
$d2 = 1;
}
if ( $shans3 < '50') {
$d3 = 1;
}
}
$est = $d1 + $d2 + $d3 + 612;
if ( $est > '612') {
mysql_query( " UPDATE podzem3 SET n $nomer = '$est' WHERE glava = '$glava' and name = '" . $hokke["name"] . "' " );
} else {
mysql_query( " UPDATE podzem3 SET n $nomer = '' WHERE glava = '$glava' and name = '" . $hokke["name"] . "' " );
}
}//////////Рабочий винтель////////////////////////////////////////////////////
}
mysql_query( " UPDATE `labirint` SET `boi` = '0' WHERE `user_id` = " . $this->user ['id'] . " " );
mysql_query( " DELETE FROM `canal_bot` WHERE `nomer` = '$nomer' and `glava` = '$glava' and `boi` = '$nm' " );
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
2018-02-27 04:48:51 +02:00
include " ../ darkness_quest . php " ;
2018-01-28 18:40:49 +02:00
$this->exp [ $v ] = round( $this->exp [ $v ]);
$dop_exp = check_proc( $this->user ['id']);
if ( $dop_exp > 100) {
$add = ( $dop_exp - 100);
$this->exp [ $v ] += round(( $this->exp [ $v ] * $add ) / 100, 0);
}
if ( $user['caveleader'] > 0 || $user['laba'] > 0) {
if ( $this->damage [ $v ] > 1) {
$this->exp [ $v ] = mt_rand(5, 10);
} else {
$this->exp [ $v ] = 0;
}
}
if (empty( $this->damage [ $v ])) {
$this->damage [ $v ] = 0;
}
if ( $user['caveleader'] > 0 || $user['laba'] > 0) {
$rep = floor( $this->damage [ $v ] / 300);
if ( $rep <= 0) {
$rep = 0;
}
$ads = '. Репутации: ' . $rep . ' ед.';
} else {
$rep = 0;
$ads = '.';
}
if ( $this->battle_data ['clone'] == 1 && $this->battle_data ['fiz'] == 0) {
$this->addAction (time(), 'kill_clone', 0, $this->user ['id']);
echo " < script > console . log ( 'Win clone' ); </ script > " ;
}
if ( $this->battle_data ['type'] == 3) {
$this->addAction (time(), 'win_haot', 0, $this->user ['id']);
echo " < script > console . log ( 'Win Haot' ); </ script > " ;
}
if ( $this->battle_data ['fiz'] == 1) {
$this->addAction (time(), 'win_fiz', 0, $this->user ['id']);
echo " < script > console . log ( 'Win Fiz' ); </ script > " ;
}
2020-08-27 15:17:02 +03:00
addchp('<font color=red>Внимание!</font> Победа! Бой окончен. Всего вами нанесено урона : ' . $this->damage [ $v ] . ' HP. Получено опыта : ' . $this->exp [ $v ] . ' (' . $dop_exp . '%)' . $ads . ' ', ' { []}' . Nick::id( $v )->short() . ' { []}');
2018-01-28 18:40:49 +02:00
mysql_query('UPDATE `users` SET `win` = (`win` +1), `fullhptime` = ' . time() . ' WHERE `id` = " ' . $v . ' " ');
GiveExp( $v , $this->exp [ $v ]);
if ( $user['caveleader'] > 0 || $user['laba'] > 0) {
GiveRep( $v , $rep );
}
if ( $user['klan'] ) {
mysql_query('UPDATE `clans` SET `clanexp` = (`clanexp`+' . (int) $this->exp [ $user['id'] ] . ') WHERE `id` = " ' . $v[$user[' klan ']] . ' " LIMIT 1');
}
}
$winers .= implode( " </ B > , < B > " , $this->t1 );
$lomka = $this->t2 ;
2019-09-20 16:57:58 +03:00
include('../cave/win.php');
2018-01-28 18:40:49 +02:00
} elseif (in_array( $ss[0] , $this->t2 )) {
$flag = 2;
foreach ( $this->t2 as $k => $v ) {
mysql_query('UPDATE `battle` SET `win` = 2 WHERE `id` = " ' . $this->user[' battle '] . ' " LIMIT 1');
2020-08-27 15:17:02 +03:00
$this->t2 [ $k ] = Nick::id( $v )->short();
2018-01-28 18:40:49 +02:00
if ( $this->battle_data ['aren_of'] == 1 && $this->t2 [ $k ] && $v < _BOTSEPARATOR_) {
mysql_query('INSERT INTO `logs_arena` (`battle`, `user`, `uid`, `damage`, `team`) VALUES ( " ' . $this->user[' battle '] . ' " , " ' . $this->t1[$k] . ' " , " ' . $v . ' " , " ' . $this->damage[$v] . ' " , " 2 " )');
}
if ( $this->user ['laba'] > 0) {
mysql_query('UPDATE `users` SET `x` = " ' . $this->user[' xf '] . ' " , `y` = " ' . $this->user[' yr '] . ' " WHERE `id` = " ' . $this->user[' id '] . ' " LIMIT 1');
}
$this->exp [ $v ] = round( $this->exp [ $v ]);
$dop_exp = check_proc( $this->user ['id']);
if ( $dop_exp > 100) {
$add = ( $dop_exp - 100);
$this->exp [ $v ] += round(( $this->exp [ $v ] * $add ) / 100, 0);
}
if ( $user['caveleader'] > 0 || $user['laba'] > 0) {
if ( $this->damage [ $v ] > 1) {
$this->exp [ $v ] = rand(5, 10);
} else {
$this->exp [ $v ] = 0;
}
}
if ( $this->battle_data ['clone'] == 1 && $this->battle_data ['fiz'] == 0) {
$this->addAction (time(), 'kill_clone', 0, $this->user ['id']);
echo " < script > console . log ( 'Win clone 1' ); </ script > " ;
}
if ( $this->battle_data ['type'] == 3) {
$this->addAction (time(), 'win_haot', 0, $this->user ['id']);
echo " < script > console . log ( 'Win haot 1' ); </ script > " ;
}
if ( $this->battle_data ['fiz'] == 1) {
$this->addAction (time(), 'win_fiz', 0, $this->user ['id']);
echo " < script > console . log ( 'Win fiz 1' ); </ script > " ;
}
mysql_query('UPDATE `users` SET `win` = (`win` +1), `fullhptime` = ' . time() . ' WHERE `id` = " ' . $v . ' " ');
GiveExp( $v , $this->exp [ $v ]);
if ( $user['caveleader'] > 0 || $user['laba'] > 0) {
GiveRep( $v , $rep );
}
if ( $user['klan'] ) {
mysql_query('UPDATE `clans` SET `clanexp` = (`clanexp`+' . (int) $this->exp [ $user['id'] ] . ') WHERE `id` = " ' . $v[$user[' klan ']] . ' " LIMIT 1');
}
}
$winers .= implode( " </ B > , < B > " , $this->t2 );
$lomka = $this->t1 ;
}
mysql_query( " UPDATE `users` , `bots` SET `users` . `fullhptime` = " . (time() + 300) . " , `users` . `hp` = `bots` . `hp` WHERE `users` . id = 83 AND `bots` . prototype = 83 ; " );
// ===================ломаем шмот=============
if (!empty( $lomka )) {
foreach ( $lomka as $k => $v ) {
if (mt_rand(1, 3) == 1) {
$us = mysql_query('UPDATE `inventory` SET `duration`=`duration`+1 WHERE `type` <> 12 AND `dressed` = 1 AND `owner` = \ '' . $v . ' \ ';');
}
$this->exp [ $v ] = 0;
2020-08-27 15:17:02 +03:00
addchp('<font color=red>Внимание!</font> Бой окончен. Всего вами нанесено урона ' . (int) $this->damage [ $v ] . ' HP. Получено опыта 0. ', ' { []}' . Nick::id( $v )->short() . ' { []}');
2018-01-28 18:40:49 +02:00
mysql_query('UPDATE `users` SET `lose`=`lose` +1 WHERE `id` = \ '' . $v . ' \ ';');
// если поединок был кровавым - еще и ставм травмы
}
if (in_array( $user['room'] , $caverooms )) {
$location = mysql_fetch_array(mysql_query( " SELECT `x` , `y` , `dir` FROM `caveparties` WHERE `user` = '" . $this->user[' id '] . "' LIMIT 1 " ));
if ( $location['dir'] == 0) {
$y = $location['y'] * 2;
$x = ( $location['x'] - 1) * 2;
}
if ( $location['dir'] == 1) {
$y = ( $location['y'] - 1) * 2;
$x = $location['x'] * 2;
}
if ( $location['dir'] == 2) {
$y = $location['y'] * 2;
$x = ( $location['x'] + 1) * 2;
}
if ( $location['dir'] == 3) {
$y = ( $location['y'] + 1) * 2;
$x = $location['x'] * 2;
}
mysql_query( " UPDATE `cavebots` SET `battle` = 0 WHERE `battle` = '" . $this->battle_data[' id '] . "' " );
}
if ( $this->battle_data ['x'] > 0 || $this->battle_data ['y'] > 0 && $this->user ['laba'] > 0) {
mysql_query('UPDATE `users` SET `x` = " ' . $this->user[' xf '] . ' " , `y` = " ' . $this->user[' yr '] . ' " WHERE `laba` = " ' . $this->user[' laba '] . ' " AND `x` = " ' . $this->battle_data[' x '] . ' " AND `y` = " ' . $this->battle_data[' y '] . ' " AND `battle` = " ' . $this->battle_data[' id '] . ' " LIMIT 1');
}
2019-09-20 16:57:58 +03:00
include( " ../ cave / lose . php " );
2018-01-28 18:40:49 +02:00
}
foreach ( $this->t1 as $k => $v ) {
$us = mysql_query('SELECT duration, maxdur, name FROM `inventory` WHERE `type` <> 12 AND `dressed` = 1 AND `owner` = \ '' . $v . ' \ ';');
while ( $rrow = mysql_fetch_row( $us )) {
if (( $rrow[1] - $rrow[0] ) == 1)
2020-08-27 15:17:02 +03:00
$this->add_log ('<span class=date>' . date( " [ H : i : s ] " ) . '</span> Внимание! У " ' . Nick::id($v)->short() . ' " предмет " ' . $rrow[2] . ' " в критическом состоянии! <BR><small>(на правах рекламы) <b>Ремонтная мастерская oldbbk</b>. Мы даем вторую жизнь старым вещам!</small><BR>');
2018-01-28 18:40:49 +02:00
elseif (( $rrow[1] - $rrow[0] ) == 2)
2020-08-27 15:17:02 +03:00
$this->add_log ('<span class=date>' . date( " [ H : i : s ] " ) . '</span> Внимание! У " ' . Nick::id($v)->short() . ' " предмет " ' . $rrow[2] . ' " нуждается в ремонте! <BR><small>(на правах рекламы) <b>Ремонтная мастерская oldbbk</b>. Мы даем вторую жизнь старым вещам!</small><BR>');
2018-01-28 18:40:49 +02:00
}
}
foreach ( $this->t2 as $k => $v ) {
$us = mysql_query('SELECT duration, maxdur, name FROM `inventory` WHERE `type` <> 12 AND `dressed` = 1 AND `owner` = \ '' . $v . ' \ ';');
while ( $rrow = mysql_fetch_row( $us )) {
if (( $rrow[1] - $rrow[0] ) == 1)
2020-08-27 15:17:02 +03:00
$this->add_log ('<span class=date>' . date( " [ H : i : s ] " ) . '</span> Внимание! У " ' . Nick::id($v)->short() . ' " предмет ' . $rrow[2] . ' в критическом состоянии! <BR><small>(на правах рекламы) <b>Ремонтная мастерская oldbbk</b>. Мы даем вторую жизнь старым вещам!</small><BR>');
2018-01-28 18:40:49 +02:00
elseif (( $rrow[1] - $rrow[0] ) == 2)
2020-08-27 15:17:02 +03:00
$this->add_log ('<span class=date>' . date( " [ H : i : s ] " ) . '</span> Внимание! У " ' . Nick::id($v)->short() . ' " предмет " ' . $rrow[2] . ' " нуждается в ремонте! <BR><small>(на правах рекламы) <b>Ремонтная мастерская oldbbk</b>. Мы даем вторую жизнь старым вещам!</small><BR>');
2018-01-28 18:40:49 +02:00
}
}
//==============================================
if ( $winers ) {
if (isset( $_SESSION['botas'] )) {
$_SESSION['botai'] [ $_SESSION['botas'] ][2] = 1; //uzmusam bota
}
$this->add_log ('<span class=date>' . date( " [ H : i : s ] " ) . '</span> ' . 'Бой закончен, победа за <B>' . $winers . '</B><BR>');
if ( $this->battle_data ['blood']) {
$this->add_log ('<span class=date>' . date( " [ H : i : s ] " ) . '</span> ... и победители стали калечить проигравших...<BR>');
foreach ( $lomka as $k => $v ) {
$tr = settravma( $v , 0, 86400, 1);
2020-08-27 15:17:02 +03:00
$this->add_log ('<span class=date>' . date( " [ H : i : s ] " ) . '</span> ' . Nick::id( $v )->short() . ' получил повреждение: <font color=red>' . $tr . '</font><BR>');
2018-01-28 18:40:49 +02:00
}
}
} else {
$this->add_log ('<span class=date>' . date( " [ H : i : s ] " ) . '</span> ' . 'Бой закончен. Ничья.<BR>');
$this->exp = null;
////////////////при Ничьей = для поземки///////////////////
$sd = mysql_query( " SELECT glav_id , boi , glava FROM `labirint` WHERE `user_id` = " . $this->user ['id'] . " " );
if ( $dd = mysql_fetch_array( $sd )) {
$glav_id = $dd["glav_id"] ;
$glava = $dd["glava"] ;
$nm = $dd["boi"] ;
mysql_query( " DELETE FROM `canal_bot` WHERE `boi` = '$nm' and `glava` = '$glava' " );
mysql_query( " UPDATE `labirint` SET `location` = '16' , `vector` = '0' , `dead` = dead + 1 , `t` = '226' , `l` = '454' , `boi` = '0' WHERE `user_id` = " . $this->user ['id'] . " " );
}
///////////////////////////////////
}
// sys
if ( $flag == 1) {
$rr = implode( " </ B > , < B > " , $nks1 ) . " < img src = i / flag . gif ></ B > и < B > " . implode( " </ B > , < B > " , $nks2 );
} elseif ( $flag == 2) {
$rr = implode( " </ B > , < B > " , $nks1 ) . " </ B > и < B > " . implode( " </ B > , < B > " , $nks2 ) . " < img src = i / flag . gif > " ;
} else {
$rr = implode( " </ B > , < B > " , $nks1 ) . " </ B > и < B > " . implode( " </ B > , < B > " , $nks2 ) . " " ;
}
// выносим хп-ку и выходим из боя
mysql_query('UPDATE `battle` SET `t1hist` = \ '' . implode( " , " , $nks1hist ) . ' \ ', `t2hist` = \ '' . implode( " , " , $nks2hist ) . ' \ ' WHERE `id` = ' . $this->battle_data ['id'] . ' ;');
addch( " < a href = logs . php ? log = " . $this->battle_data ['id'] . " target = _blank > Поединок </ a > между < B > " . $rr . " </ B > закончен . " , $user['room'] );
mysql_query('UPDATE `battle` SET `exp` = \ '' . serialize( $this->exp ) . ' \ ' WHERE `id` = ' . $this->battle_data ['id'] . ' ;');
mysql_query( " DELETE FROM `bots` WHERE `battle` = { $this -> user [ 'battle' ]}; " );
mysql_query( " UPDATE users SET `battle` = 0 , `fullhptime` = " . time() . " WHERE `battle` = { $this -> user [ 'battle' ]} " );
echo mysql_error();
unset( $this->battle );
//header( " Location : fbattle . php " ); die();
return true;
// =================================================================
}
}
return false;
}
function addAction( $time , $vars , $vls , $uid )
{
$ins = mysql_query('INSERT INTO `actions` (`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`) VALUES ( " ' . $uid . ' " , " ' . $time . ' " , " capitalcity " , " 0 " , " ' . mysql_real_escape_string($vars) . ' " , " ' . mysql_real_escape_string($_SERVER[' HTTP_X_REAL_IP ']) . ' " , " ' . mysql_real_escape_string($vls) . ' " )');
if ( $ins ) {
return true;
} else {
return false;
}
}
function solve_exp( $at_id , $def_id , $damage )
{
2018-02-27 04:48:51 +02:00
$mods = [
" perv " => 1.7,
" kulon " => 1.5,
" haos " => 2,
" alignprot " => 1.5,
" kulakpenalty " => 0.5,
" bloodb " => 3,
" btl_1 " => 1,
" btl_2 " => 0.5,
" btl_3 " => 0,
" krov_oop " => 0.2,
" krov_bitv " => 30,
" krov_op " => 1.15,
" krov_sech " => 150,
" krovs_op " => 1.4,
" velikaya " => 40,
" vel_op '" => 1.1,
"velichayshaya" => 90,
"velich_op' " => 1.15,
" epohalnaya " => 200,
" epoh_op " => 1.35,
];
$baseexp = [
2018-01-28 18:40:49 +02:00
" 0 " => " 5 " ,
" 1 " => " 10 " ,
" 2 " => " 20 " ,
" 3 " => " 30 " ,
" 4 " => " 60 " ,
" 5 " => " 120 " ,
" 6 " => " 180 " ,
" 7 " => " 230 " ,
" 8 " => " 350 " ,
" 9 " => " 500 " ,
" 10 " => " 800 " ,
" 11 " => " 1100 " ,
" 12 " => " 1200 " ,
" 13 " => " 1300 " ,
" 14 " => " 1400 " ,
" 15 " => " 1500 "
2018-02-27 04:48:51 +02:00
];
2018-01-28 18:40:49 +02:00
if ( $at_id > _BOTSEPARATOR_) {
$bots = mysql_fetch_array(mysql_query('SELECT * FROM `bots` WHERE `id` = ' . $at_id . ' LIMIT 1;'));
$at_id = $bots['prototype'] ;
$bot_active = true;
}
$at = mysql_fetch_array(mysql_query( " SELECT * FROM `users` WHERE `id` = '" . $at_id . "' LIMIT 1 ; " ));
$at_cost = mysql_fetch_array(mysql_query( " select 1 + IFNULL (( select SUM ( cost ) FROM inventory WHERE owner = users . id AND dressed = 1 ), 0 ), `align` FROM users WHERE id = " . $at_id . " LIMIT 1 ; " ));
$kulak1 = mysql_fetch_array(mysql_query( " select SUM ( cost ) FROM inventory WHERE owner = " . $at_id . " AND dressed = 1 LIMIT 1 ; " ));
if ( $def_id > _BOTSEPARATOR_) {
$bots = mysql_fetch_array(mysql_query('SELECT * FROM `bots` WHERE `id` = ' . $def_id . ' LIMIT 1;'));
$def_id = $bots['prototype'] ;
$bot_def = true;
}
$def = mysql_fetch_array(mysql_query( " SELECT * FROM `users` WHERE `id` = '" . $def_id . "' LIMIT 1 ; " ));
$def_cost = mysql_fetch_array(mysql_query( " select 1 + IFNULL (( select SUM ( cost ) FROM inventory WHERE owner = users . id AND dressed = 1 ), 0 ), `align` FROM users WHERE id = " . $def_id . " LIMIT 1 ; " ));
$kulak2 = mysql_fetch_array(mysql_query( " select SUM ( cost ) FROM inventory WHERE owner = " . $def_id . " AND dressed = 1 LIMIT 1 ; " ));
// модификаторы опыта
// 100% опыта
2018-02-27 04:48:51 +02:00
$expmf = 1;
2018-01-28 18:40:49 +02:00
// 200% опыта
// $expmf = 2;
//первичка
if ( $at['sergi'] == 0 && $at['kulon'] == 0 && $at['bron'] == 0 && $at['r1'] == 0 && $at['r2'] == 0 && $at['r3'] == 0 && $at['helm'] == 0
&& $at['perchi'] == 0 && $at['boots'] == 0 && $at['m1'] == 0 && $at['m2'] == 0 && $at['m3'] == 0 && $at['m4'] == 0 && $at['m5'] == 0
&& $at['m6'] == 0 && $at['m7'] == 0 && $at['m8'] == 0 && $at['m9'] == 0 && $at['m10'] == 0
&& $at['weap'] != 0 && $kulak1[0] < 17) {
$expmf = $expmf * $mods['perv'] ;
}
//кулонка
if ( $at['sergi'] == 0 && $at['bron'] == 0 && $at['helm'] == 0
&& $at['perchi'] == 0 && $at['boots'] == 0 && $at['m1'] == 0 && $at['m2'] == 0 && $at['m3'] == 0 && $at['m4'] == 0 && $at['m5'] == 0
&& $at['m6'] == 0 && $at['m7'] == 0 && $at['m8'] == 0 && $at['m9'] == 0 && $at['m10'] == 0
&& $at['weap'] != 0 && $at['kulon'] != 0 && $at['r1'] != 0 && $at['r2'] != 0 && $at['r3'] != 0) {
//mfkrit,mfakrit,mfuvorot,mfauvorot
$expmf = $expmf * $mods['kulon'] ;
}
if ( $this->battle_data ['blood']) { //кровавые массовые
if (( $this->t1 + $this->t2 ) >= $krov_bitv && ( $this->t1 + $this->t2 ) < $krov_rez ) $expmf = $expmf * $mods['krov_op'] ;
elseif (( $this->t1 + $this->t2 ) >= $krov_rez && ( $this->t1 + $this->t2 ) < $krov_sech ) $expmf = $expmf * $mods['krovr_op'] ;
elseif (( $this->t1 + $this->t2 ) >= $krov_sech ) $expmf = $expmf * $mods['krovs_op'] ;
} else { //обычные массовые
if (( $this->t1 + $this->t2 ) >= $velikaya && ( $this->t1 + $this->t2 ) < $velichayshaya ) $expmf = $expmf * $mods['vel_op'] ;
elseif (( $this->t1 + $this->t2 ) >= $velichayshaya && ( $this->t1 + $this->t2 ) < $epohalnaya ) $expmf = $expmf * $mods['velich_op'] ;
elseif (( $this->t1 + $this->t2 ) >= $epohalnaya ) $expmf = $expmf * $mods['epoh_op'] ;
}
if ( $at['align'] == 4) {
$expmf = $expmf * $mods['haos'] ;
}
if (((int) $at['align'] == 1 && $def['align'] == 3) || ((int) $def['align'] == 1 && $at['align'] == 3)) {
$expmf = $expmf * $mods['alignprot'] ;
}
if ( $at['level'] > 1 && $kulak1[0] == 0 && $kulak2[0] == 0) {
$expmf = $expmf * $mods['kulakpenalty'] ;
}
2018-02-27 04:48:51 +02:00
2018-01-28 18:40:49 +02:00
if ( $this->battle_data ['blood']) {
$expmf = $expmf * $mods['bloodb'] ;
}
2018-02-27 04:48:51 +02:00
2018-01-28 18:40:49 +02:00
if ( $this->battle_data ['type'] == 1) {
$btfl = fopen('/tmpdisk/' . $at_id . '.btl', 'r');
$contents = fread( $btfl , filesize('/tmpdisk/' . $at_id . '.btl'));
fclose( $btfl );
$cnt = substr_count( $contents , $def_id );
if ( $cnt <= 1) $exmod = $mods['btl_1'] ;
elseif ( $cnt == 2) $exmod = $mods['btl_2'] ;
elseif ( $cnt > 2) $exmod = $mods['btl_3'] ;
$expmf = $expmf * $mods['exmod'] ;
}
$standart = array(
" 0 " => 1,
" 1 " => 1,
" 2 " => 15,
" 3 " => 111,
" 4 " => 265,
" 5 " => 526,
" 6 " => 882,
" 7 " => 919,
" 8 " => 919,
" 9 " => 919,
" 10 " => 919,
" 11 " => 919,
" 12 " => 919,
" 13 " => 919,
" 14 " => 919,
" 15 " => 919
);
$mfit = ( $at_cost[0] / ( $standart[$at['level'] ] / 3));
if ( $mfit < 0.8) {
$mfit = 0.8;
}
if ( $mfit > 1.5) {
$mfit = 1.5;
}
2018-11-01 12:40:06 +02:00
$pls = count( $this->t1 ) + count( $this->t2 );
2018-01-28 18:40:49 +02:00
if ( $pls > 2) {
$mfbot = $bot_active == true ? 0.3 : 1;
$mfbot2 = $bot_def == true ? 0.7 : 1;
} else {
$mfbot = 1;
$mfbot2 = 1;
}
$expmf = 1;
$expek = ( $baseexp[$def['level'] ]) * ( $def_cost[0] / (( $at_cost[0] + $def_cost[0] ) / 2)) * ( $damage / $def['maxhp'] ) * $expmf * $mfit * $mfbot * $mfbot2 ;
return $expek ;
}
function write_stat_block( $text )
{
$fp = fopen( " backup / stat / battle_block " . $this->user ['battle'] . " . txt " , " a " ); //открытие
flock( $fp , LOCK_EX); //БЛОКИРОВКА ФАЙЛА
fputs( $fp , $text . " \n " ); //работа с файлом
fflush( $fp ); //ОЧИЩЕНИЕ ФАЙЛОВОГО БУФЕРА И ЗАПИСЬ В ФАЙЛ
flock( $fp , LOCK_UN); //СНЯТИЕ БЛОКИРОВКИ
fclose( $fp ); //закрытие
}
}