From afde0b138026f684098fb7df54840acf06147adb Mon Sep 17 00:00:00 2001 From: Ivor Barhansky Date: Thu, 10 Aug 2023 17:51:16 +0300 Subject: [PATCH] removed deprecated mysql_fetch_row(). --- _incl_data/class/Battle.php | 8328 +++++++++++++++++---------------- _incl_data/class/Quests.php | 546 +-- _incl_data/mysql_override.php | 14 - forum_script/_forum.class.php | 23 +- modules_data/_clan.php | 6 +- 5 files changed, 4460 insertions(+), 4457 deletions(-) diff --git a/_incl_data/class/Battle.php b/_incl_data/class/Battle.php index 3821fe12..d213f01f 100644 --- a/_incl_data/class/Battle.php +++ b/_incl_data/class/Battle.php @@ -341,12 +341,29 @@ class Battle //Очистка кэша для ... public array $uclearc = []; public array $ucleari = []; + public $ainm = []; + public $rehodeff = []; + public $poglast = []; + public $prlog = []; + public $um_priem = []; + public $restart_stats_data = []; + public $import_atack = []; + public $contr = []; + + // + public $import_user = 0; + public $pr_not_use = [], $pr_reset = [], $pr_yrn = false, $prnt = []; + public $del_val = [], $re_pd = []; + + //Добавляем нанесенный урон public function __construct() { ignore_user_abort(true); } + //JS информация о игроке + public function maginfoattack($u1, $u2, $type): string { /* @@ -369,38 +386,6 @@ class Battle return ' magelogin=' . $v_l . ' onMouseOver=top.hi(this,maginfo(' . $v_z . ',' . $v_p . ',' . $v_m . ',this),event,3,1,1,1,null); onMouseOut=top.hic(); onMouseDown=top.hic(); '; } - private function typeBattle(int $x): array - { - $r = [0, 0, 'Обычный поединок', 'Кровавый Поединок']; - if ($x >= 50000 && $x < 100000) { - $r = [25, 50, 'Великая Битва', 'Кровавая Битва']; - } elseif ($x < 500000) { - $r = [50, 75, 'Величайшая Битва', 'Кровавая Резня']; - } elseif ($x < 1000000) { - $r = [75, 100, 'Историческая Битва', 'Кровавая Сеча']; - } elseif ($x < 2500000) { - $r = [100, 125, 'Эпохальная Битва', 'Кровавое Побоище']; - } elseif ($x >= 5000000) { - $r = [150, 150, 'Судный День', 'Судный День']; - } - return $r; - } - - /** - * Сохраняем лог в архив - * @return void - */ - private function saveLogs() - { - Db::sql( - 'insert into battle_logs_save select id, time, battle, id_hod, text, vars, zona1, zonb1, zona2, zonb2, type from battle_logs where battle = ? and id_hod <= ?', - [$this->info['id'], $this->hodID] - ); - Db::sql('delete from battle_logs where battle = ?', [$this->info['id']]); - Db::sql('delete from battle_stat where battle < ?', [$this->info['id'] - 100]); - Db::sql('delete from battle_actions where btl = ?', [$this->info['id']]); - } - public function hphe($uid, $hp, $false_t7 = false) { global $u; @@ -462,16 +447,20 @@ class Battle $this->stats[$this->uids[$uid]]['last_hp'] = -$hp; Db::sql( 'update stats set last_hp = ?, tactic7 = ? where id = ?', [ - $this->users[$this->uids[$uid]]['last_hp'], - $this->users[$this->uids[$uid]]['tactic7'], - $uid, - ] + $this->users[$this->uids[$uid]]['last_hp'], + $this->users[$this->uids[$uid]]['tactic7'], + $uid, + ] ); } return floor($hp); } + // todo stopped here // + + //Мини лог + /** * Какая-то хуедрыга для номерных файлов-приёмов * @param int $pid @@ -488,13 +477,7 @@ class Battle } } - private function clearСache($uid) - { - if ($uid > 0 && !isset($this->uclearc[$uid])) { - $this->uclearc[$uid] = true; - $this->ucleari[] = $uid; - } - } + //Проверяем завершение боя public function clear_cache_start() { @@ -502,7 +485,7 @@ class Battle Db::sql('delete from battle_cache where uid in (?)', [$uids]); } - // + //завершение поединка /** * Проверка урон приемов над защитными. @@ -536,216 +519,6 @@ class Battle return $hp; } - /** - * Расчет опыта - * @param $y - * @param $s2 - * @return int - */ - private function testExp($y, $s2): int - { - if ($s2['levels'] == 'undefined' || $this->users[$this->uids[$s2['id']]]['pass'] == 'saintlucia') { - return 0; - } - - $y = max(0, (int)$y); - $expmultiplier = 1; - if ($this->users[$this->uids[$s2['id']]]['level'] >= 8) { - $expmultiplier = $this->users[$this->uids[$s2['id']]]['level'] - 5; - } - - if ($s2['hpNow'] < 0) { - $y = 0; - } - if ($s2['hpNow'] < $y) { - $y = max(0, $s2['hpNow']); - } - $addExp = $y * $expmultiplier; - if ($s2['hpAll'] - $y <= 0) { - $addExp = 100; - } - - if ($this->info['razdel'] != 5 && Config::get('exp_limit_many')) { - $texp = Db::getValue( - 'select count(*) from battle_users as a where uid = ? and battle in (select battle from battle_users where uid = ? and team != a.team and time_enter > unix_timestamp() - 86400)' - ); - // - if ($texp > 5) { - $addExp = 0; - } elseif ($texp > 4) { - $addExp = $addExp * 0.50; - } elseif ($texp > 3) { - $addExp = $addExp * 0.75; - } elseif ($texp > 2) { - $addExp = $addExp * 1.00; - } elseif ($texp > 1) { - $addExp = $addExp * 1.00; - } else { - $addExp = $addExp * 1.00; - } - } - return (int)round($addExp); - } - - /** - * Добавляем опыт \ нанесенный урон. - * Кривовсрато, на переделку. - * @param $id - * @param $y - * @param $id1 - * @param $id2 - * @param $mgregen - * @param $nobattle_uron - * @return void - */ - public function takeExp($id, $y, $id1, $id2, $mgregen = false, $nobattle_uron = false) - { - global $u; - if (isset($this->users[$this->uids[$id]])) { - $s1 = $this->stats[$this->uids[$id1]]; - $s2 = $this->stats[$this->uids[$id2]]; - if ($id1 != $id2) { - $e = $this->testExp($y, $s2); - } else { - $e = 0; - } - - if ((int)$this->users[$this->uids[$id1]]['bot_id'] == 0 && $this->users[$this->uids[$id1]]['dnow'] != 0 && $this->info['dungeon'] != 1) { - $dun_limitForLevel = [ // Максимум для каждого уровня. - 4 => 750, - 5 => 1500, - 6 => 3500, - 7 => 8000, - 8 => 25000, - 9 => 50000, - 10 => 75000, - 11 => 125000, - 12 => 250000, - 13 => 500000, - 14 => 750000, - ]; - $dun_expFactor = [ // Максимум для каждого уровня. - 4 => 5, - 5 => 5, - 6 => 5, - 7 => 5, - 8 => 5, - 9 => 3, - 10 => 1, - 11 => 1, - 12 => 1, - 13 => 1, - 14 => 1, - ]; - - if (isset($dun_expFactor[(int)$this->users[$this->uids[$id1]]['level']])) { - $e = $e * $dun_expFactor[(int)$this->users[$this->uids[$id1]]['level']]; - } - if ($this->info['dungeon'] > 1 && $this->users[$this->uids[$id1]]['battle'] > 0) { // пещерный лимит - $dun_exp = []; // Текущий лимит опыта игрока в подземельях. - $rep = Db::getValue( - 'select dungeonexp from rep where id = ?', [$this->users[$this->uids[$id1]]['id']] - ); - $rep = explode(',', $rep); - foreach ($rep as $key => $val) { - $val = explode('=', $val); - if (isset($val[0]) && isset($val[1]) && $val[0] != '' && $val[1] != 0) { - $dun_exp[(int)$val[0]] = (int)$val[1]; - } // текущий лимит опыта в подземке - } - unset($rep); - - if (!isset($dun_exp[$this->info['dungeon']])) { - $dun_exp[$this->info['dungeon']] = 0; - } - if (!isset($dun_limitForLevel[(int)$this->users[$this->uids[$id1]]['level']])) { // Если лимит не задан, опыт не даем. - $e = 0; - } elseif ( - isset($dun_exp[$this->info['dungeon']]) && - $dun_exp[$this->info['dungeon']] >= $dun_limitForLevel[(int)$this->users[$this->uids[$id1]]['level']] - ) { // Если лимит уже достигнут, опыт не даем. - $e = 0; - } elseif ( - isset($dun_exp[$this->info['dungeon']]) && - $dun_limitForLevel[(int)$this->users[$this->uids[$id1]]['level']] > $dun_exp[$this->info['dungeon']] - ) { // Если текущая репутация не достигла лимита. - if (($dun_exp[$this->info['dungeon']] + $e) > $dun_limitForLevel[(int)$this->users[$this->uids[$id1]]['level']]) { - // Если опыта набрано достаточно, для достижения лимита. - $e = abs( - $e - abs( - $dun_limitForLevel[(int)$this->users[$this->uids[$id1]]['level']] - ($e + $dun_exp[$this->info['dungeon']]) - ) - ); - $dun_exp[$this->info['dungeon']] += $e; - } elseif ($dun_limitForLevel[(int)$this->users[$this->uids[$id1]]['level']] > ($dun_exp[$this->info['dungeon']] + $e)) { - // Если опыта недостаточно, для достижения лимита. - $dun_exp[$this->info['dungeon']] += $e; - } else { - $e = 0; - } - } else { // В любой непонятной ситуцаии. - $e = 0; - } - } - // Опыт в пещерах. - if ($this->info['dungeon'] == 102) { - $e = floor($e * 0.002); - } - } - - $this->users[$this->uids[$id1]]['battle_exp'] += floor($e); - if (!$mgregen && !$nobattle_uron) { - $this->users[$this->uids[$id1]]['battle_yron'] += floor($y); - if ($this->stats[$this->uids[$id1]]['notactic'] != 1) { - if ($s2['hpAll'] <= 1000) { - if ($this->stats[$this->uids[$id2]]['this_animal'] == 0) { - $this->users[$this->uids[$id1]]['tactic6'] += round( - 0.1 * (floor($y) / $s2['hpAll'] * 100), - 10 - ); - } else { - $this->users[$this->uids[$id1]]['tactic6'] += round( - 0.1 * (floor($y) / $s2['hpAll'] * 100), - 10 - ) / 3; - } - } else { - if ($this->stats[$this->uids[$id2]]['this_animal'] == 0) { - $this->users[$this->uids[$id1]]['tactic6'] += round(0.1 * (floor($y) / 1000 * 100), 10); - } else { - $this->users[$this->uids[$id1]]['tactic6'] += round(0.1 * (floor($y) / 1000 * 100), 10) / 3; - } - } - } - } - - Db::sql( - 'update stats set last_hp = ?, tactic6 = ?, battle_yron = ?, battle_exp = ? where id = ?', [ - $this->users[$this->uids[$id1]]['last_hp'], - $this->users[$this->uids[$id1]]['tactic6'], - $this->users[$this->uids[$id1]]['battle_yron'], - $this->users[$this->uids[$id1]]['battle_exp'], - (int)$id1, - ] - ); - - $this->stats[$this->uids[$id1]]['battle_exp'] = $this->users[$this->uids[$id1]]['battle_exp']; - $this->clearСache($id1); - $this->stats[$this->uids[$id1]]['tactic6'] = $this->users[$this->uids[$id1]]['tactic6']; - if ($id1 == $u->info['id']) { - $u->info['tactic6'] = $this->users[$this->uids[$id1]]['tactic6']; - $u->stats['tactic6'] = $this->users[$this->uids[$id1]]['tactic6']; - $u->info['battle_exp'] = $this->users[$this->uids[$id1]]['battle_exp']; - $u->info['battle_yron'] = $this->users[$this->uids[$id1]]['battle_yron']; - $u->info['notactic'] = $this->users[$this->uids[$id1]]['notactic']; - $u->stats['notactic'] = $this->users[$this->uids[$id1]]['notactic']; - } - - - } - } - - //Добавляем нанесенный урон public function takeYronNow($uid, $y) { global $u; @@ -762,7 +535,6 @@ class Battle Db::sql('update stats set battle_yron = battle_yron + ? where id = ?', [$y, $uid]); } - //JS информация о игроке public function myInfo($id, $t) { global $c, $u; @@ -1092,6 +864,8 @@ class Battle return $info; } + //Проводим удар + /** * Проверка на выживших. * Проклято и сломано. @@ -1123,29 +897,8 @@ class Battle return $r; } - // todo stopped here // + //Запускаем магические предметы, если в них что-то встроено - //Мини лог - private function miniLogAdd($user, $text) - { - $vLog = 'at1=00000||at2=00000||zb1=0||zb2=0||bl1=0||bl2=0||time1=' . time() . '||time2=' . time( - ) . '||s1=' . $user['sex'] . '||t1=' . $user['team'] . '||login1=' . $user['login'] . '||'; - $mas1 = [ - 'time' => time(), - 'battle' => $this->info['id'], - 'id_hod' => ($this->hodID + 1), - 'text' => $text, - 'vars' => $vLog, - 'zona1' => '', - 'zonb1' => '', - 'zona2' => '', - 'zonb2' => '', - 'type' => '1', - ]; - $this->add_log($mas1); - } - - //Проверяем завершение боя public function testFinish() { global $u; @@ -1584,8 +1337,7 @@ class Battle //конец излома $this->finishBattle($tml, $tmv, null, $tl); $fin1 = mysql_query( - 'INSERT INTO `izlom_rating` (`uid`,`time`,`voln`,`level`,`bots`,`rep`,`obr`,`btl`) VALUES ("' . $u->info['id'] . '","' . time( - ) . '","' . $this->info['izlomRoundSee'] . '","' . $this->info['izlomLvl'] . '","0","0","' . ($this->info['izlomObr'] - $this->info['izlomObrNow']) . '","' . $this->info['id'] . '")' + 'INSERT INTO `izlom_rating` (`uid`,`time`,`voln`,`level`,`bots`,`rep`,`obr`,`btl`) VALUES ("' . $u->info['id'] . '","' . time() . '","' . $this->info['izlomRoundSee'] . '","' . $this->info['izlomLvl'] . '","0","0","' . ($this->info['izlomObr'] - $this->info['izlomObrNow']) . '","' . $this->info['id'] . '")' ); } else { $this->info['izlomRound'] = $iz['round']; @@ -1641,15 +1393,13 @@ class Battle $this->finishBattle($tml, $tmv, null, $tl); if ($this->info['izlom'] > 0) { $fin1 = mysql_query( - 'INSERT INTO `izlom_rating` (`uid`,`time`,`voln`,`level`,`bots`,`rep`,`obr`,`btl`) VALUES ("' . $u->info['id'] . '","' . time( - ) . '","' . $this->info['izlomRoundSee'] . '","' . $this->info['izlomLvl'] . '","0","0","' . ($this->info['izlomObr'] - $this->info['izlomObrNow']) . '","' . $this->info['id'] . '")' + 'INSERT INTO `izlom_rating` (`uid`,`time`,`voln`,`level`,`bots`,`rep`,`obr`,`btl`) VALUES ("' . $u->info['id'] . '","' . time() . '","' . $this->info['izlomRoundSee'] . '","' . $this->info['izlomLvl'] . '","0","0","' . ($this->info['izlomObr'] - $this->info['izlomObrNow']) . '","' . $this->info['id'] . '")' ); } } if (isset($fin1)) { mysql_query( - 'INSERT INTO `eff_users` (`no_Ace`,`id_eff`,`overType`,`uid`,`name`,`data`,`timeUse`) VALUES ("1","31","23","' . $u->info['id'] . '","Касание Хаоса","nofastfinisheff=1","' . time( - ) . '")' + 'INSERT INTO `eff_users` (`no_Ace`,`id_eff`,`overType`,`uid`,`name`,`data`,`timeUse`) VALUES ("1","31","23","' . $u->info['id'] . '","Касание Хаоса","nofastfinisheff=1","' . time() . '")' ); $cmsg = new ChatMessage(); $cmsg->setCity($u->info['city']); @@ -1667,8 +1417,7 @@ class Battle $i01++; } mysql_query( - 'INSERT INTO `actions`(`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES ("' . $u->info['id'] . '","' . time( - ) . '","capitalcity","' . $u->info['room'] . '","izlom"," ","","")' + 'INSERT INTO `actions`(`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES ("' . $u->info['id'] . '","' . time() . '","capitalcity","' . $u->info['room'] . '","izlom"," ","","")' ); unset($fin1); } @@ -1687,7 +1436,222 @@ class Battle } } - //завершение поединка + //Поглощение урона + + public function get_chanse($percent): bool + { + if ($percent >= 100) { + $percent = 100; + } elseif ($percent == 0) { + $percent = 0; + } + return $this->dodge(1, $percent); + } + + public function dodge($a, $b): bool + { + $i = 0; + $arr = []; //массив для записи уникальных случайных чисел + while ($i < ($b - $a)) { + while (in_array($rand, $arr)) { + $rand = mt_rand(1, 100); + } + $arr[] = $rand; + $i++; + } + $n = mt_rand(1, 100); + return (bool)array_search($n, $arr); + } + + //Поглощение урона + + private function miniLogAdd($user, $text) + { + $vLog = 'at1=00000||at2=00000||zb1=0||zb2=0||bl1=0||bl2=0||time1=' . time() . '||time2=' . time() . '||s1=' . $user['sex'] . '||t1=' . $user['team'] . '||login1=' . $user['login'] . '||'; + $mas1 = [ + 'time' => time(), + 'battle' => $this->info['id'], + 'id_hod' => ($this->hodID + 1), + 'text' => $text, + 'vars' => $vLog, + 'zona1' => '', + 'zonb1' => '', + 'zona2' => '', + 'zonb2' => '', + 'type' => '1', + ]; + $this->add_log($mas1); + } + + public function add_log($mass) + { + if (empty($mass['text'])) { + return; + } + mysql_query( + 'INSERT INTO `battle_logs` (`time`,`battle`,`id_hod`,`text`,`vars`,`type`) VALUES (unix_timestamp(), "' . $mass['battle'] . '","' . $mass['id_hod'] . '","' . $mass['text'] . '","' . $mass['vars'] . '","' . $mass['type'] . '")' + ); + if (rand(2, 10) == 10) { + $this->get_comment(); + } + } + + + //Тестируем удары и т.д + + public function get_comment() + { + $boycom = [ + 'А танцуешь ты лучше.', + 'А мы что, в прятки тут играем?', + 'А вы разве пингвинов никогда не видели?', + 'А, ведь когда-то, вы были красивыми… А теперь? Ну и рожи! Жуть!', + 'А потом еще труп пинать будут.', + 'А я вчера ночью за соседями подглядывал. Они точно так же кувыркались', + 'А ведь вы живых людей дубасите...', + 'А вот я вчера в зоопарке был...', + 'А вы в стройбате не служили?', + 'А вы видели, чтобы так на улице делали!?', + 'А вы знали что ёжики размножаются в интернете?', + 'А жить-то, как хочется:', + 'А из-за чего вы собственно дерётесь?', + 'А чего ржёте, вы ещё остальных не видели', + 'А что произойдёт если ты испугаешся до полусмерти дважды?!', + 'Больше так не делай. Ты же не садист?', + 'Без комментариев...', + 'Больно ведь!', + 'Быстро ты за монитор спрятался!', + 'Все хотят попасть в рай, но никто не хочет умирать!', + 'Вчера с такой девчонкой познакомился.', + 'Всего 5 минут знакомы, а дерутся, словно супруги с 20-ти летним стажем...', + 'Все. Я так больше не могу.', + 'В конце концов, кто-то победит?', + 'Вы чего, с дерева упали?', + 'Возятся как сонные мухи... давайте я вам лучше анекдот расскажу: ...', + 'Вот видишь, как полезно чистить зубы на ночь?', + 'Вот вы все руками махаете, а за вами уже очередь', + 'Вот попадёте вы в плен и вас там будут долго бить. Но вы ничего не расскажете... и не потому, что вы такой стойкий, просто вы ничего не знаете', + 'Вы бы лучше пошли потренировались!', + 'Вы все еще разминаетесь? Позовите, когда кости в муку друг другу разминать будете.', + 'Вы же бойцы! Имейте совесть!', + 'Гаси недоумка!', + 'Да, если бы я смог это остановить, то получил бы нобелевскую премию `За мир` ', + 'Да куда они бьют?!', + 'Давайте быстрее! За вами уже очередь образовалась.', + 'Давайте обойдемся сегодня таймаутом. А? А то мне уже кошмары скоро будут сниться.', + 'Дерутся как девчонки!', + 'Дети, посмотрите налево... Ой!.. Нет, туда лучше не смотреть.', + 'Если так будет продолжаться, то скоро мы заснем!', + 'Если бы у меня было кресло-качалка, я бы в нём качался...', + 'Если вы что-то сказать хотите, то лучше молчите :)', + 'Жестокость не порок.', + 'Жизнь вне нашего клуба - это пустая трата кислорода!!!', + 'Жми! Дави! Кусай! Царапай!', + 'За такие бои надо в хаос отправлять!', + 'Знаете откуда в комиссионном магазине столько вещей? Это я после ваших гулянок собираю и сдаю туда. Иногда вместе с частями тела, застрявшими в них.', + 'Здесь люди так близки друг к другу. Просто иначе ударить нельзя.', + 'И пролитая кровь еще пульсирует...', + 'Инвалидов развелось...', + 'Какой бой!!!', + 'Кто!? Кто здесь?!', + 'Кто вас этому научил?', + 'Кузнечик, блин...', + 'Куплю импортный проигрыватель грампластинок.', + 'Лошадью ходи!', + 'Лучше враг, чем друг - враг.', + 'Ладно, вы тут пока друг друга за волосы таскайте, а я пойду, пообедаю.', + 'Мне ваш балет уже надоел!', + 'Может, начнется-таки настоящий бой???', + 'Мысли лезут в голову изнутри, а удары снаружи.', + 'Ну и где ваши коронные удары? Где живописные падения я спрашиваю!', + 'Ну, нельзя же так наотмашь лупить!', + 'Надо раньше было думать, теперь смертельно поздно...', + 'На такое зрелище билеты продавать можно. Народ ухохочется!', + 'Нет! Не надо драки! А... ладно деритесь, все равно не умеете.', + 'Нет, ну должен быть повод, должен же быть повод?', + 'Нет, я отказываюсь это комментировать!', + 'Не таких обламывали!', + 'Ну выпили вы рюмку, ну две... ну литр, ну два... так зачем же после этого драку затевать?!', + 'Ну и кто за этот погром платить будет?', + 'Ну и оскал у вас. Из вашей улыбки кастеты делать можно.', + 'Ну, что же ты..? Не печалься. Выше голову, так по ней удобней попасть.', + 'Ничего... Блок тоже удар.', + 'Обернись!!!.... Поздно...', + 'Ого! Научите меня так не делать.', + 'Осторожно! Сделаешь дырочку, уже не запломбируешь!', + 'Оно вам надо???', + 'Обычное дело...там что-то отклеилось.', + 'Ой, и заболтался я с вами...', + 'Он же не промахнётся если ты не отойдёшь!', + 'По-моему, кому-то светит инвалидность.', + 'Подкинь ему грабли, на которые он еще не наступал.', + 'Прав был кот Леопольд, давайте жить дружно?', + 'При ударе в живот нарушается кислотно-щелочной баланс.', + 'Проверь, не торчит ли у тебя нож из живота.', + 'Перестаньте мне орать!', + 'Подкинь ему грабли, на которые он еще не наступал.', + 'Прыгают тут как блохи... Все, я пошел за дихлофосом!', + 'Разбудите меня когда эта порнография закончится...', + 'Ребенок сильнее ударил бы!', + 'Славно вмазал!', + 'Славно они веселятся', + 'Смотрю вот на вас, и слезы наворачиваются.', + 'Сначала учатся ходить, а потом только в драку лезут.', + 'Так они друг другу что-нибудь сломают.', + 'Так ты ему все кости переломаешь!', + 'У меня в подъезде точно так же соседа отмудохали', + 'Убогих развелось...', + 'Ух ты, какой прыткий!', + 'Фашист!! Надо ж, так по больному месту врезать...', + 'Хватит бить его об угол моей кабинки! Мне же потом ее чинить.', + 'Хулиганы, прекратите немедленно!', + 'Хочешь, подскажу, куда он ударит?', + 'Хорошо, что у меня ловкости больше чем у вас всех, а то б вы и меня в инвалидную коляску посадили бы.', + 'Хороший бой!', + 'Хороший удар!', + 'Хиляк-разрядник!', + 'Что ты его за волосы схватил?! Отпусти немедленно!', + 'Щас я вас настигну, вот тогда мы и похохочем', + 'Это была какая-то неизвестная мне техника...', + 'Это же противник, а не глина! Хватит мяться!', + 'Это не бой, это издевательское избиение.', + 'Это поубавит спеси', + 'Это и был твой план `Б` ?', + 'Это была какая-то неизвестная мне техника...', + 'Я же предупреждал, - будет больно.', + 'Я не страдаю безумием. Я наслаждаюсь им каждую минуту :)', + 'Я красивый, я сильный, я умный, я добрый. А вот вы? Вы себя-то видели?!', + 'Я тоже умею драться, но не буду...', + '(тревожно озираясь) я вам по секрету скажу... за вами наблюдают!', + '<вырезано цензурой> после боя я этих <вырезано цензурой> обоих в <вырезано цензурой> и <вырезано цензурой>', + '<вырезано цензурой> каратисты фиговы', + ]; + if (rand(1, 12) === 1) { + $txt = '{tm1} Комментатор: ' . $boycom[rand(0, count($boycom) - 1)] . ''; + + $vLog = 'time1=' . time() . ''; + $mas1 = [ + 'time' => time(), + 'battle' => $this->info['id'], + 'id_hod' => $this->hodID, + 'text' => '', + 'vars' => $vLog, + 'zona1' => '', + 'zonb1' => '', + 'zona2' => '', + 'zonb2' => '', + 'type' => '1', + ]; + $mas1['text'] = $txt; + $this->add_log($mas1); + } else { + return false; + } + return true; + } + + //Игрок1 наносит удар Игрок2 + public function finishBattle($t, $v, $nl, $tl) { global $magic, $u, $q, $c; @@ -1751,8 +1715,7 @@ class Battle if (isset($tststrt['id'])) { if ($this->info['inTurnir'] == 0 || $this->info['type'] == 500) { mysql_query( - 'UPDATE `battle` SET `time_over` = "' . time( - ) . '",`team_win` = "' . $this->info['team_win'] . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1' + 'UPDATE `battle` SET `time_over` = "' . time() . '",`team_win` = "' . $this->info['team_win'] . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1' ); } mysql_query( @@ -1764,8 +1727,7 @@ class Battle $vtvl = ''; $relu = 0; while ($i < count($this->users)) { - $vl .= '("' . $this->users[$i]['login'] . '","' . $this->users[$i]['city'] . '","' . $this->info['id'] . '","' . $this->users[$i]['id'] . '","' . time( - ) . '","' . $this->users[$i]['team'] . '","' . $this->users[$i]['level'] . '","' . $this->users[$i]['align'] . '","' . $this->users[$i]['clan'] . '","' . $this->users[$i]['exp'] . '","' . $this->users[$i]['bot'] . '","' . $this->users[$i]['money'] . '","' . $this->users[$i]['money2'] . '","' . $this->users[$i]['money3'] . '"),'; + $vl .= '("' . $this->users[$i]['login'] . '","' . $this->users[$i]['city'] . '","' . $this->info['id'] . '","' . $this->users[$i]['id'] . '","' . time() . '","' . $this->users[$i]['team'] . '","' . $this->users[$i]['level'] . '","' . $this->users[$i]['align'] . '","' . $this->users[$i]['clan'] . '","' . $this->users[$i]['exp'] . '","' . $this->users[$i]['bot'] . '","' . $this->users[$i]['money'] . '","' . $this->users[$i]['money2'] . '","' . $this->users[$i]['money3'] . '"),'; if ($this->users[$i]['team'] == $this->info['team_win'] && $this->info['team_win'] > 0) { $vtvl .= '' . $this->users[$i]['login'] . ', '; } @@ -1992,8 +1954,7 @@ class Battle mysql_query( 'INSERT INTO `dungeon_items` (`dn`,`item_id`,`time`,`x`,`y`) VALUES ( - "' . $this->users[$i]['dnow'] . '","' . $plik['item_id'] . '","' . (time( - ) - 600) . '","' . $this->users[$i]['x'] . '","' . $this->users[$i]['y'] . '" + "' . $this->users[$i]['dnow'] . '","' . $plik['item_id'] . '","' . (time() - 600) . '","' . $this->users[$i]['x'] . '","' . $this->users[$i]['y'] . '" )' ); } @@ -2022,8 +1983,7 @@ class Battle $text = str_replace('{u1}', $usrreal, $text); mysql_query( 'INSERT INTO `bs_logs` (`type`,`text`,`time`,`id_bs`,`count_bs`,`city`,`m`,`u`) VALUES ( - "1", "' . mysql_real_escape_string($text) . '", "' . time( - ) . '", "' . $bs['id'] . '", "' . $bs['count'] . '", "' . $bs['city'] . '", + "1", "' . mysql_real_escape_string($text) . '", "' . time() . '", "' . $bs['id'] . '", "' . $bs['count'] . '", "' . $bs['city'] . '", "' . round($bs['money'] * 0.85, 2) . '","' . $i . '" )' ); @@ -2041,8 +2001,7 @@ class Battle ); //Обновляем заявку mysql_query( - 'UPDATE `bs_zv` SET `off` = "' . time( - ) . '" WHERE `inBot` = "' . $this->users[$i]['id'] . '" AND `off` = "0" LIMIT 1' + 'UPDATE `bs_zv` SET `off` = "' . time() . '" WHERE `inBot` = "' . $this->users[$i]['id'] . '" AND `off` = "0" LIMIT 1' ); unset($text, $usrreal, $usr_real); if ($this->users[$i]['pass'] != 'bstowerbot') { @@ -2236,8 +2195,7 @@ class Battle 'UPDATE `users` SET `battle` = "0" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' ); mysql_query( - 'UPDATE `stats` SET `zv` = "0",`team` = "0",`exp` = `exp` + `battle_exp`,`battle_exp` = "0",`battle_yron` = "0",`enemy` = "0", `timeGo` = "' . time( - ) . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' + 'UPDATE `stats` SET `zv` = "0",`team` = "0",`exp` = `exp` + `battle_exp`,`battle_exp` = "0",`battle_yron` = "0",`enemy` = "0", `timeGo` = "' . time() . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' ); mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $this->users[$i]['id'] . '" LIMIT 100'); } elseif ($this->users[$i]['bot'] > 0) { @@ -2246,8 +2204,7 @@ class Battle 'UPDATE `users` SET `battle` = "0" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' ); mysql_query( - 'UPDATE `stats` SET `zv` = "0",`team` = "0",`exp` = `exp` + `battle_exp`,`battle_exp` = "0",`battle_yron` = "0",`enemy` = "0", `timeGo` = "' . time( - ) . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' + 'UPDATE `stats` SET `zv` = "0",`team` = "0",`exp` = `exp` + `battle_exp`,`battle_exp` = "0",`battle_yron` = "0",`enemy` = "0", `timeGo` = "' . time() . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' ); mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $this->users[$i]['id'] . '" LIMIT 100'); } @@ -2312,8 +2269,7 @@ class Battle //Выпадает шмотка mysql_query( 'INSERT INTO `laba_obj` (`use`,`lib`,`time`,`type`,`x`,`y`,`vars`) VALUES ( - "0","' . $j1['lib'] . '","' . time( - ) . '","6","' . $j1['x'] . '","' . $j1['y'] . '","' . (0 + $botsi) . '" + "0","' . $j1['lib'] . '","' . time() . '","6","' . $j1['x'] . '","' . $j1['y'] . '","' . (0 + $botsi) . '" )' ); } @@ -2462,8 +2418,7 @@ class Battle } } mysql_query( - 'UPDATE `dungeon_bots` SET `delete` = "' . time( - ) . '" AND `inBattle` = "' . $this->info['id'] . '" WHERE `dn` = "' . $this->info['dn_id'] . '" AND `for_dn` = "0" AND `delete` = "0" ' + 'UPDATE `dungeon_bots` SET `delete` = "' . time() . '" AND `inBattle` = "' . $this->info['id'] . '" WHERE `dn` = "' . $this->info['dn_id'] . '" AND `for_dn` = "0" AND `delete` = "0" ' ); } else { //выкидываем всех игроков в клетку RESTART @@ -3250,17 +3205,14 @@ class Battle } if ($this->users[$i]['battle_yron'] > 0) { mysql_query( - 'INSERT INTO `eff_users` (`no_Ace`,`id_eff`,`overType`,`uid`,`name`,`data`,`timeUse`) VALUES ("1","478","111","' . $this->users[$i]['id'] . '","Право на подвиг","pravonapodvig=1","' . time( - ) . '")' + 'INSERT INTO `eff_users` (`no_Ace`,`id_eff`,`overType`,`uid`,`name`,`data`,`timeUse`) VALUES ("1","478","111","' . $this->users[$i]['id'] . '","Право на подвиг","pravonapodvig=1","' . time() . '")' ); } mysql_query( - 'INSERT INTO `actions`(`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES ("' . $this->users[$i]['id'] . '","' . (time( - ) - $timewait) . '","capitalcity","' . $this->users[$i]['room'] . '","end_trup"," ","","")' + 'INSERT INTO `actions`(`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES ("' . $this->users[$i]['id'] . '","' . (time() - $timewait) . '","capitalcity","' . $this->users[$i]['room'] . '","end_trup"," ","","")' ); mysql_query( - 'INSERT INTO `eff_users` (`no_Ace`,`id_eff`,`overType`,`uid`,`name`,`data`,`timeUse`) VALUES ("1","479","112","' . $u->info['id'] . '","Защита от нападения","zashitatk=1","' . time( - ) . '")' + 'INSERT INTO `eff_users` (`no_Ace`,`id_eff`,`overType`,`uid`,`name`,`data`,`timeUse`) VALUES ("1","479","112","' . $u->info['id'] . '","Защита от нападения","zashitatk=1","' . time() . '")' ); $ritem = rand(1, 1000); if ($ritem == 555) { @@ -3323,8 +3275,7 @@ class Battle 'UPDATE `rep` SET `rep3` = `rep3` + "' . $rzbvo . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' ); mysql_query( - 'INSERT INTO `actions`(`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES ("' . $this->users[$i]['id'] . '","' . time( - ) . '","capitalcity","' . $this->users[$i]['room'] . '","end_xaot"," ","' . $zadID . '","")' + 'INSERT INTO `actions`(`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES ("' . $this->users[$i]['id'] . '","' . time() . '","capitalcity","' . $this->users[$i]['room'] . '","end_xaot"," ","' . $zadID . '","")' ); } } @@ -3415,8 +3366,7 @@ class Battle $dies = $dies[0]; mysql_query( 'INSERT INTO `dungeon_actions` (`dn`,`uid`,`x`,`y`,`time`,`vars`,`vals`) VALUES ( - "' . $this->users[$i]['dnow'] . '","' . $this->users[$i]['id'] . '","' . $this->users[$i]['x'] . '","' . $this->users[$i]['y'] . '","' . time( - ) . '","dielaba","" + "' . $this->users[$i]['dnow'] . '","' . $this->users[$i]['id'] . '","' . $this->users[$i]['x'] . '","' . $this->users[$i]['y'] . '","' . time() . '","dielaba","" )' ); } else { @@ -3428,8 +3378,7 @@ class Battle $dies = $dies[0]; mysql_query( 'INSERT INTO `dungeon_actions` (`dn`,`uid`,`x`,`y`,`time`,`vars`,`vals`) VALUES ( - "' . $this->users[$i]['dnow'] . '","' . $this->users[$i]['id'] . '","' . $this->users[$i]['x'] . '","' . $this->users[$i]['y'] . '","' . time( - ) . '","die","" + "' . $this->users[$i]['dnow'] . '","' . $this->users[$i]['id'] . '","' . $this->users[$i]['x'] . '","' . $this->users[$i]['y'] . '","' . time() . '","die","" )' ); } @@ -3505,8 +3454,7 @@ class Battle ); //удаляем все предметы которые пропадают после выхода из пещеры mysql_query( - 'UPDATE `items_users` SET `delete` = "' . time( - ) . '" WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `delete` < 1234567890 AND `inShop` = "0" AND (`dn_delete` = "1" OR `data` LIKE "%fromlaba=1%")' + 'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `delete` < 1234567890 AND `inShop` = "0" AND (`dn_delete` = "1" OR `data` LIKE "%fromlaba=1%")' ); if ($this->users[$i]['login'] != '') { if ($this->users[$i]['sex'] == 0) { @@ -3560,12 +3508,10 @@ class Battle ); //удаляем все предметы которые пропадают после выхода из пещеры mysql_query( - 'UPDATE `items_users` SET `delete` = "' . time( - ) . '" WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `dn_delete` = "1" LIMIT 1000' + 'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `dn_delete` = "1" LIMIT 1000' ); mysql_query( - 'UPDATE `items_users` SET `delete` = "' . time( - ) . '" WHERE `uid` = "' . $u->info['id'] . '" AND `item_id` = "1189" OR `item_id` = "4447" OR `item_id` = "1174") LIMIT 1000' + 'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `uid` = "' . $u->info['id'] . '" AND `item_id` = "1189" OR `item_id` = "4447" OR `item_id` = "1174") LIMIT 1000' ); if ($this->users[$i]['sex'] == 0) { @@ -3592,8 +3538,7 @@ class Battle } $upd2 = mysql_query( - 'UPDATE `stats` SET `hpNow` = "' . $this->stats[$i]['hpNow'] . '",`mpNow` = "' . $this->stats[$i]['mpNow'] . '",`bn_capitalcity` = 0,`bn_demonscity` = 0,`smena` = 3,`tactic7` = "-100",`x`="' . $this->users[$i]['x'] . '",`y`="' . $this->users[$i]['y'] . '",`priems_z`="0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0",`last_pr`="0",`tactic1`="0",`tactic2`="0",`tactic3`="0",`tactic4`="0",`tactic5`="0",`tactic6`="0.00000000",`tactic7`="10",`exp` = "' . $this->users[$i]['exp'] . '",`battle_exp` = "' . $this->users[$i]['battle_exp'] . '",`battle_text` = "' . $this->users[$i]['battle_text'] . '",`battle_yron` = "0",`enemy` = "0",`last_b`="' . $this->info['id'] . '",`regHP` = "' . time( - ) . '",`regMP` = "' . time() . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' + 'UPDATE `stats` SET `hpNow` = "' . $this->stats[$i]['hpNow'] . '",`mpNow` = "' . $this->stats[$i]['mpNow'] . '",`bn_capitalcity` = 0,`bn_demonscity` = 0,`smena` = 3,`tactic7` = "-100",`x`="' . $this->users[$i]['x'] . '",`y`="' . $this->users[$i]['y'] . '",`priems_z`="0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0",`last_pr`="0",`tactic1`="0",`tactic2`="0",`tactic3`="0",`tactic4`="0",`tactic5`="0",`tactic6`="0.00000000",`tactic7`="10",`exp` = "' . $this->users[$i]['exp'] . '",`battle_exp` = "' . $this->users[$i]['battle_exp'] . '",`battle_text` = "' . $this->users[$i]['battle_text'] . '",`battle_yron` = "0",`enemy` = "0",`last_b`="' . $this->info['id'] . '",`regHP` = "' . time() . '",`regMP` = "' . time() . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' ); if ($this->info['turnir'] == 0) { //пишем в чат @@ -3607,8 +3552,7 @@ class Battle } //завершаем сам бой $upd3 = mysql_query( - 'UPDATE `battle` SET `time_over` = "' . time( - ) . '",`team_win` = "' . $this->info['team_win'] . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1' + 'UPDATE `battle` SET `time_over` = "' . time() . '",`team_win` = "' . $this->info['team_win'] . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1' ); @@ -3648,8 +3592,87 @@ class Battle mysql_query('UNLOCK TABLES'); } + //Проверка зоны и блока - public $ainm = []; + /** + * Сохраняем лог в архив + * @return void + */ + private function saveLogs() + { + Db::sql( + 'insert into battle_logs_save select id, time, battle, id_hod, text, vars, zona1, zonb1, zona2, zonb2, type from battle_logs where battle = ? and id_hod <= ?', + [$this->info['id'], $this->hodID] + ); + Db::sql('delete from battle_logs where battle = ?', [$this->info['id']]); + Db::sql('delete from battle_stat where battle < ?', [$this->info['id'] - 100]); + Db::sql('delete from battle_actions where btl = ?', [$this->info['id']]); + } + + //Проверка ухода удара в игрока + + public function addTravm($uid, $type, $lvl) + { + global $u; + $t = $type; + if ($t == 1) { + $name = 'Легкая травма'; + $stat = rand(1, 3); // пока без духовности + $timeEnd = rand(1, 3);// время травмы от 1.30 до 6 часов + $data = 'add_s' . $stat . '=-' . $lvl; + $img = 'eff_travma1.gif'; + $v1 = 1; + } elseif ($t == 2) { + $name = 'Средняя травма'; + $stat = rand(1, 3); // пока без духовности + $timeEnd = rand(3, 5);// время травмы от 6 до 12 часов + $data = 'add_s' . $stat . '=-' . ($lvl * 2); + $v1 = 2; + $img = 'eff_travma2.gif'; + } elseif ($t == 3) { + $name = 'Тяжелая травма'; + $stat = rand(1, 3); // пока без духовности + $timeEnd = rand(5, 7);// время травмы от 12 до 6 часов + $data = 'add_s' . $stat . '=-' . ($lvl * 3); + $v1 = 3; + $img = 'eff_travma3.gif'; + } elseif ($t == 4) { + $name = 'Неизлечимая травма'; + $stat = rand(1, 3); // пока без духовности + $timeEnd = 24;// время травмы от 24 часа + $data = 'add_s' . $stat . '=-' . ($lvl * 50); + $v1 = 4; + $img = 'eff_travma4.gif'; + } + $timeEnd *= 3600; + $ins = mysql_query( + 'INSERT INTO `eff_users` (`overType`,`timeUse`,`hod`,`name`,`data`,`uid`, `id_eff`, `img2`, `timeAce`, `v1`) VALUES ("0","' . time() . '","-1","' . $name . '","' . $data . '","' . $uid . '", "4", "' . $img . '","' . $timeEnd . '", "' . $v1 . '")' + ); + $ins = mysql_query( + 'INSERT INTO `eff_users` (`overType`,`timeUse`,`hod`,`name`,`data`,`uid`, `id_eff`, `img2`, `timeAce`, `v1`) VALUES ("0","' . time() . '","-1","Иммунитет: Защита от травм","add_notravma=1","' . $uid . '", "263", "cure1.gif","21600", "")' + ); + } + + //Расчет уворота игроков + + private function typeBattle(int $x): array + { + $r = [0, 0, 'Обычный поединок', 'Кровавый Поединок']; + if ($x >= 50000 && $x < 100000) { + $r = [25, 50, 'Великая Битва', 'Кровавая Битва']; + } elseif ($x < 500000) { + $r = [50, 75, 'Величайшая Битва', 'Кровавая Резня']; + } elseif ($x < 1000000) { + $r = [75, 100, 'Историческая Битва', 'Кровавая Сеча']; + } elseif ($x < 2500000) { + $r = [100, 125, 'Эпохальная Битва', 'Кровавое Побоище']; + } elseif ($x >= 5000000) { + $r = [150, 150, 'Судный День', 'Судный День']; + } + return $r; + } + + //Расчет крита игроков public function addGlobalItems($bid, $uid, $itm, $eff, $ico, $exp, $cr, $ecr) { @@ -4026,8 +4049,7 @@ class Battle mysql_query( 'SELECT `id` FROM `users_ico` WHERE `uid` = "' . mysql_real_escape_string( $uid - ) . '" AND (`endTime` > "' . time( - ) . '" OR `endTime` = 0) AND `img` = "' . mysql_real_escape_string( + ) . '" AND (`endTime` > "' . time() . '" OR `endTime` = 0) AND `img` = "' . mysql_real_escape_string( $ico_e[2] ) . '" LIMIT 1' ) @@ -4119,97 +4141,8 @@ class Battle // } - //Проводим удар - public function addNewAtack() - { - global $u; - if (!isset($this->ga[$u->info['id']][$u->info['enemy']])) { - if ($this->stats[$this->uids[$u->info['id']]]['hpNow'] > 0) { + //Расчет парирования игроков - $us = $this->stats[$this->uids[$u->info['id']]]; - $i = 1; - $no = 0; - - while ($i <= $us['zona']) { - if ($this->uAtc['a'][$i] == 0) { - $no = 1; - } - $i++; - } - - if ($this->uAtc['b'] == 0) { - $no = 1; - } - - if ($no == 0) { - //наносим удар - if ($u->info['enemy'] > 0) { - if (!isset($this->ga[$u->info['enemy']][$u->info['id']])) { - if ($this->stats[$this->uids[$u->info['id']]]['hpNow'] >= 1 && $this->stats[$this->uids[$u->info['enemy']]]['hpNow'] >= 1) { - //наносим новый удар - $a = $this->uAtc['a'][1] . $this->uAtc['a'][2] . $this->uAtc['a'][3] . $this->uAtc['a'][4] . $this->uAtc['a'][5]; - $b = $this->uAtc['b']; - mysql_query( - 'DELETE FROM `battle_act` WHERE `battle` = "' . $this->info['id'] . '" AND ((`uid2` = "' . $u->info['id'] . '" AND `uid1` = "' . $u->info['enemy'] . '") OR (`uid1` = "' . $u->info['id'] . '" AND `uid2` = "' . $u->info['enemy'] . '")) LIMIT 2' - ); - $d = mysql_query( - 'INSERT INTO `battle_act` (`battle`,`time`,`uid1`,`uid2`,`a1`,`b1`) VALUES ("' . $this->info['id'] . '","' . time( - ) . '","' . $u->info['id'] . '","' . $u->info['enemy'] . '","' . $a . '","' . $b . '")' - ); - if (!$d) { - $this->e = 'Не удалось нанести удар по противнику...'; - } else { - $this->ga[$u->info['id']][$u->info['enemy']] = mysql_insert_id(); - } - } - } else { - //отвечаем на удар противника - if ($this->stats[$this->uids[$u->info['id']]]['hpNow'] >= 1 && $this->stats[$this->uids[$u->info['enemy']]]['hpNow'] >= 1 && isset($this->atacks[$this->ga[$u->info['enemy']][$u->info['id']]]['id'])) { - $this->atacks[$this->ga[$u->info['enemy']][$u->info['id']]]['a2'] = $this->uAtc['a'][1] . '' . $this->uAtc['a'][2] . '' . $this->uAtc['a'][3] . '' . $this->uAtc['a'][4] . '' . $this->uAtc['a'][5]; - $this->atacks[$this->ga[$u->info['enemy']][$u->info['id']]]['b2'] = $this->uAtc['b']; - $this->startAtack($this->atacks[$this->ga[$u->info['enemy']][$u->info['id']]]['id']); - } - } - } - } else { - $this->e = 'Выберите зоны удара и блока'; - } - } else { - $this->e = 'Для вас поединок закончен, ожидайте пока завершат другие...'; - } - } - } - - //Запускаем магические предметы, если в них что-то встроено - public function magicItems($uid1, $uid2, $end) - { - global $u, $priem, $c, $code; - if (!isset($this->stats[$this->uids[$uid1]])) { - return; - } - $i = 0; - while ($i < count($this->stats[$this->uids[$uid1]]['items'])) { - $itm = $this->stats[$this->uids[$uid1]]['items'][$i]; - if (isset($itm['id'])) { - $e = ConversionHelper::dataStringToArray($itm['data']); - if (isset($e['bm_a1'])) { - if ($end > 0) { - if (file_exists('../../_incl_data/class/priems/' . $e['bm_a1'] . '.end.php')) { - require('../../_incl_data/class/priems/' . $e['bm_a1'] . '.end.php'); - } - } else { - if (file_exists('../../_incl_data/class/priems/' . $e['bm_a1'] . '.php')) { - require('../../_incl_data/class/priems/' . $e['bm_a1'] . '.php'); - } - } - } - } - $i++; - } - unset($itm); - } - - //Поглощение урона public function testPog($uid, $yr) { $yr2 = $yr; @@ -4267,1336 +4200,82 @@ class Battle return $yr2; } - public $rehodeff = []; - - //Поглощение урона - public $poglast = []; - - public function testPogB($uid, $yr, $pliid, $test = 0) - { - $yr2 = $yr; - $checktuman = mysql_fetch_array( - mysql_query( - 'SELECT * FROM `eff_users` WHERE `uid` = "' . $uid . '" - AND (`v2` = 273 OR `v2` = 286 OR `v2` = 287 OR `v2` = 288) - AND `delete` =0 LIMIT 1' - ) - ); //проверка на туманный образ - if ($yr > 0 && !isset($checktuman['id'])) { - $testmana = false; - global $u, $priem; - $i = 0; - $ypg22 = 0; - while ($i < count($this->stats[$this->uids[$uid]]['set_pog2'])) { - $j = $this->stats[$this->uids[$uid]]['set_pog2'][$i]; - if ($this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['id'] == $pliid || $test == 1) { - $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['data'] = str_replace( - 'add_pog2=' . $j['y'], - 'add_pog2=$', $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['data'] - ); - $dt3 = ConversionHelper::dataStringToArray($this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['data']); - $dt30 = 0; - $dt30 = floor($j['y'] / $yr2 * 100); - if ($dt30 < $dt3['add_pog2p']) { - $dt3['add_pog2p'] = $dt30; - } - unset($dt30); - if (isset($dt3['add_pog2mp'])) { - if ((round( - round($yr2 / 100 * (100 - $dt3['add_pog2p'])) * $dt3['add_pog2mp'] - )) > $this->stats[$this->uids[$uid]]['mpNow']) { - //не хватило маны, считаем сколько хватит % от поглощенного урона - $j['yhj'] = $this->stats[$this->uids[$uid]]['mpNow'] / (round( - round($yr2 / 100 * (100 - $dt3['add_pog2p'])) * $dt3['add_pog2mp'] - )) * 100; - $j['yhj'] = floor($j['yhj']); //Сколько % мы можем поглотить - $dt3['add_pog2p'] = floor($dt3['add_pog2p'] / 100 * $j['yhj']); - } - if ($test == 1) { - $priem->minMana($uid, round(round($yr2 / 100 * $dt3['add_pog2p']) * $dt3['add_pog2mp'])); - } - } - if (!isset($this->poglast[$uid])) { - $this->poglast[$uid] = 0; - } - $this->poglast[$uid] += $yr2; - if ($test == 1) { - //$j['y'] -= $this->poglast[$uid]; // осталось для поглощения - $j['y'] -= round($this->poglast[$uid] / 100 * $dt3['add_pog2p']); - $priem->minMana( - $uid, - round(round($this->poglast[$uid] / 100 * $dt3['add_pog2p']) * $dt3['add_pog2mp']) - ); - } - if (isset($dt3['add_pog2p'])) { - $yr2 = round($yr2 / 100 * (100 - $dt3['add_pog2p'])); - } - if ($j['y'] < 0 || ($this->stats[$this->uids[$uid]]['mpNow'] <= 0 && $dt3['add_pog2mp'] > 0)) { - $dt2 = ConversionHelper::dataStringToArray($this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['data']); - if (isset($dt2['endPog']) && $dt2['endPog'] == 1) { - //удаляем прием - //Добавляем в лог - $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['priem'] = mysql_fetch_array( - mysql_query( - 'SELECT * FROM `priems` WHERE `id` = "' . $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['v2'] . '" LIMIT 1' - ) - ); - $this->delPriem( - $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1], - $this->users[$this->uids[$uid]], 4, $uid - ); - $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1] = 'delete'; - } - unset($dt2); - $j['y'] = 0; - } - $this->stats[$this->uids[$uid]]['set_pog'][$i]['y'] = $j['y']; - if (isset($this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['data'])) { - $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['data'] = str_replace( - 'add_pog2=$', - 'add_pog2=' . $j['y'], $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['data'] - ); - $upd = mysql_query( - 'UPDATE `eff_users` SET `data` = "' . $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['data'] . '" WHERE `id` = "' . $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['id'] . '" LIMIT 1' - ); - } - if ($j['y'] - $this->poglast[$uid] + $yr2 < 0) { - $yr -= $yr + ($j['y'] - $this->poglast[$uid] + $yr2); - $yr2 = $yr; - $i = count($this->stats[$this->uids[$uid]]['set_pog2']) + 1; - } - } - $i++; - } - } - unset($checktuman); - return $yr2; - } - - - //Тестируем удары и т.д - public function newRazmen($id, $at = null) - { - $uid1 = $this->atacks[$id]['uid1']; - $uid2 = $this->atacks[$id]['uid2']; - - if ($this->atacks[$id]['out1'] == 0) { - $at[1] = $this->usersTestAtack($id, $uid1, $uid2); - } else { - $at[1] = [0]; - } - if ($this->atacks[$id]['out2'] == 0) { - $at[2] = $this->usersTestAtack($id, $uid2, $uid1); - } else { - $at[2] = [0]; - } - - return $at; - } - - //Игрок1 наносит удар Игрок2 - public function usersTestAtack($id, $uid1, $uid2): array - { - $r = []; - $block = [ - 0, - 0, - 0, - 0, - 0, - 0, - ]; - - //Проверка блоков - $i = 1; - if ($uid1 == $this->atacks[$id]['uid1']) { - $a = 2; - $j = $this->atacks[$id]['b2']; - $atack = [ - 0, - $this->atacks[$id]['a1'][0], - $this->atacks[$id]['a1'][1], - $this->atacks[$id]['a1'][2], - $this->atacks[$id]['a1'][3], - $this->atacks[$id]['a1'][4], - ]; - } elseif ($uid2 == $this->atacks[$id]['uid1']) { - $a = 1; - $j = $this->atacks[$id]['b1']; - $atack = [ - 0, - $this->atacks[$id]['a2'][0], - $this->atacks[$id]['a2'][1], - $this->atacks[$id]['a2'][2], - $this->atacks[$id]['a2'][3], - $this->atacks[$id]['a2'][4], - ]; - } - if ($this->atacks[$id]['out' . $a] == 0) { - while ($i <= $this->stats[$this->uids[$uid2]]['zonb']) { - $block[$j] = 1; - $j++; - if ($j > 5 || $j < 1) { - $j = 1; - } - $i++; - } - } - //Проверка ударов - $i = 1; - while ($i <= $this->stats[$this->uids[$uid1]]['zona']) { - if (!isset($atack[$i]) || $atack[$i] == 0) { - $atack[$i] = rand(1, 5); - } - if ($atack[$i] > 0) { - if ($block[$atack[$i]] == 1) { - //удар был заблокирован - // КУДА БИЛ , ТИП УДАРА - $r['atack'][] = [$atack[$i], 3, 0]; - } else { - //Удар прошел - // КУДА БИЛ , ТИП УДАРА - $r['atack'][] = [$atack[$i], 1, 0]; - } - } - $i++; - } - return $r; - } - - //Проверка зоны и блока - public function testRazmenblock1($id, $uid1, $uid2, $atack): bool - { - $r = false; - //Проверка блоков - $i = 1; - if ($uid1 == $this->atacks[$id]['uid1']) { - $j = $this->atacks[$id]['b2']; - } elseif ($uid2 == $this->atacks[$id]['uid1']) { - $j = $this->atacks[$id]['b1']; - } - if ($this->atacks[$id]['out2'] == 0) { - while ($i <= $this->stats[$this->uids[$uid2]]['zonb']) { - $block[$j] = 1; - $j++; - if ($j > 5 || $j < 1) { - $j = 1; - } - $i++; - } - } - //Проверка ударов - if ($atack > 0) { - $r = $block[$atack] == 1; - } - return $r; - } - - //Проверка ухода удара в игрока - public function yhod_user($uid1, $uid2, $type) - { - // 1 - кто бьет . 2 - в кого бьют . тип - //Удал летит прямо в противника - if ($this->import_user == 0) { - $r = $uid1; - $rand_user = false; - if ($type == 2) { - //Случайный персонаж из своей команды (в том числе игрок) - $i = 0; - while ($i < count($this->users)) { - if ($this->users[$i]['team'] == $this->users[$this->uids[$uid2]]['team']) { - $rand_user[] = $this->users[$i]['id']; - } - $i++; - } - } elseif ($type == 4) { - //Случайный персонаж, любой - $i = 0; - while ($i < count($this->users)) { - //if( $this->users[$i]['team'] == $this->users[$this->uids[$uid1]]['team'] ) { - $rand_user[] = $this->users[$i]['id']; - //} - $i++; - } - } elseif ($type == 5) { - //Случайный персонаж, любой (кроме игрока) - $i = 0; - while ($i < count($this->users)) { - if ($this->users[$i]['team'] == $this->users[$this->uids[$uid2]]['team'] && $uid2 != $this->users[$i]['id']) { - $rand_user[] = $this->users[$i]['id']; - } - $i++; - } - } elseif ($type == 6) { - //Случайный персонаж из команды противника - $i = 0; - while ($i < count($this->users)) { - if ($this->users[$i]['team'] != $this->users[$this->uids[$uid2]]['team']) { - $rand_user[] = $this->users[$i]['id']; - } - $i++; - } - } elseif ($type > 100) { - //Удар идет в конкретного игрока - if (!isset($this->users[$this->uids[$type]]) || $this->users[$this->uids[$type]]['id'] != $type) { - $r = $uid2; - } else { - $r = $type; - } - } - if ($rand_user && count($rand_user) > 0) { - $r = $rand_user[rand(0, (count($rand_user) - 1))]; - } - $this->import_user = $r; - } else { - $r = $this->import_user; - } - return $r; - } - - //Расчет уворота игроков - public function mf1Razmen($id, $at, $v, $pat = false, $rjd = 0) - { - global $u; - - if ($pat) { - $pat = $at; - $at = $pat['p']; - } else { - unset($pat); - } - - $uid1 = $this->atacks[$id]['uid1']; - $uid2 = $this->atacks[$id]['uid2']; - - if ($this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] > 0) { - $uid1 = $this->yhod_user( - $this->atacks[$id]['uid2'], $this->atacks[$id]['uid1'], - $this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] - ); - } elseif ($this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] > 0) { - $uid2 = $this->yhod_user( - $this->atacks[$id]['uid1'], $this->atacks[$id]['uid2'], - $this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] - ); - } - - $i = 1; - while ($i <= 2) { - if ($i == 1) { - $a = 1; - $b = 2; - $u1 = ${'uid1'}; - $u2 = ${'uid2'}; - } else { - $a = 2; - $b = 1; - $u1 = ${'uid2'}; - $u2 = ${'uid1'}; - } - - //Расчет уворота Цели (u2) от Атакующего (u1) - $j = 0; - $wp01 = 3; - $k01 = 0; - if ($rjd > 0) { - $j = $rjd - 1; - } - if (is_array($at[$a]['atack'])) { - while ($j < count($at[$a]['atack']) && $j < 8) { - // КУДА БИЛ , ТИП УДАРА - if ($k01 == 0 && isset($this->stats[$this->uids[$u1]]['wp3id'])) { - //Левая рука - $wp01 = 3; - $k01 = 1; - } else { - //Правая рука - if (isset($this->stats[$this->uids[$u1]]['wp14id']) && $this->stats[$this->uids[$u1]]['items'][$this->stats[$this->uids[$u1]]['wp14id']]['type'] != 13) { - $wp01 = 14; - } else { - $wp01 = 3; - } - $k01 = 0; - } - $witm01 = 0; - $witm_type01 = 0; - $witm01 = $this->stats[$this->uids[$u1]]['items'][$this->stats[$this->uids[$u1]]['wp' . $wp01 . 'id']]; - $witm_data01 = ConversionHelper::dataStringToArray($witm01['data']); - if ($at[$a]['atack'][$j][2] == $v) { - $tyv = $this->mfs( - 2, [ - 'u1' => $u1, - 'u2' => $u2, - 'mf' => $this->stats[$this->uids[$u2]]['m4'], - 'amf' => (int)$this->stats[$this->uids[$u2]]['m15'], - 'smf' => ($this->stats[$this->uids[$u1]]['m5'] + $witm_data01['sv_m5']), - 'asmf' => $this->stats[$this->uids[$u1]]['m21'], - ], $this->users[$this->uids[$u1]]['level'], $this->users[$this->uids[$u2]]['level'] - ); - if ($tyv == 1 && $this->atacks[$id]['out' . $b] == 0) { - //увернулся, гад :) - $this->stats[$this->uids[$u1]]['nopryh'] = floor( - 0 + (int)$this->stats[$this->uids[$u1]]['nopryh'] - ); - if (!isset($this->stats[$this->uids[$u1]]['nopryh']) || $this->stats[$this->uids[$u1]]['nopryh'] <= 0) { - $at[$a]['atack'][$j][1] = 2; - } else { - $this->stats[$this->uids[$u1]]['nopryh']--; - $this->stats[$this->uids[$u1]]['nopryh_act']++; - } - } - } - $j++; - } - } - $i++; - } - unset($witm01, $witm_type01, $wp01, $k01); - - if (isset($pat) && $pat) { - $pat['p'] = $at; - $at = $pat; - } - return $at; - } - - //Расчет крита игроков - public function mf2Razmen($id, $at, $v, $pat = false, $rjd = 0) - { - global $u; - if ($pat) { - $pat = $at; - $at = $pat['p']; - } else { - unset($pat); - } - - $uid1 = $this->atacks[$id]['uid1']; - $uid2 = $this->atacks[$id]['uid2']; - - if ($this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] > 0) { - $uid1 = $this->yhod_user( - $this->atacks[$id]['uid2'], $this->atacks[$id]['uid1'], - $this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] - ); - } elseif ($this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] > 0) { - $uid2 = $this->yhod_user( - $this->atacks[$id]['uid1'], $this->atacks[$id]['uid2'], - $this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] - ); - } - - $i = 1; - while ($i <= 2) { - if ($i == 1) { - $a = 1; - $b = 2; - $u1 = ${'uid1'}; - $u2 = ${'uid2'}; - } else { - $a = 2; - $b = 1; - $u1 = ${'uid2'}; - $u2 = ${'uid1'}; - } - - //Расчет крита Атакующего (u1) по Цели (u2) - $j = 0; - $wp01 = 0; - $k01 = 0; - if ($rjd > 0) { - $j = $rjd - 1; - } - - if (is_array($at[$a]['atack'])) { - while ($j < count($at[$a]['atack']) && $j <= 8) { - // КУДА БИЛ , ТИП УДАРА - if ($k01 == 0 && isset($this->stats[$this->uids[$u1]]['wp3id'])) { - //Левая рука - $wp01 = 3; - $k01 = 1; - } else { - //Правая рука - if (isset($this->stats[$this->uids[$u1]]['wp14id']) && $this->stats[$this->uids[$u1]]['items'][$this->stats[$this->uids[$u1]]['wp14id']]['type'] != 13) { - $wp01 = 14; - } else { - $wp01 = 3; - } - $k01 = 0; - } - $witm01 = 0; - $witm_type01 = 0; - $witm01 = $this->stats[$this->uids[$u1]]['items'][$this->stats[$this->uids[$u1]]['wp' . $wp01 . 'id']]; - $witm_data01 = ConversionHelper::dataStringToArray($witm01['data']); - if ($this->mfs( - 1, [ - 'u1' => $u1, - 'u2' => $u2, - 'mf' => $this->stats[$this->uids[$u1]]['m1'] + $witm_data01['sv_m1'], - 'amf' => $this->stats[$this->uids[$u1]]['m14'], - 'smf' => $this->stats[$this->uids[$u2]]['m2'], - 'aamf1' => (int)$this->stats[$this->uids[$u2]]['enemy_am1'], - ], $this->users[$this->uids[$u1]]['level'], $this->users[$this->uids[$u2]]['level'] - ) == 1) { - //кританул, гад :) - if ($at[$a]['atack'][$j][1] == 3) { - //в блок - $at[$a]['atack'][$j][1] = 4; //Тут тест - } elseif ($at[$a]['atack'][$j][1] != 2 && $at[$a]['atack'][$j][1] != 6 && $at[$a]['atack'][$j][1] != 7 && $at[$a]['atack'][$j][1] != 8) { - //обычный крит - $at[$a]['atack'][$j][1] = 5; - } else { - $at[$a]['atack'][$j][1] = 1; - } - } - $j++; - } - } - $i++; - } - unset($witm01, $witm_type01, $k01, $wp01); - - if (isset($pat) && $pat) { - $pat['p'] = $at; - $at = $pat; - } - - return $at; - } - - //Расчет парирования игроков - public function mf3Razmen($id, $at, $v, $pat = false, $rjd = 0) - { - if ($pat) { - $pat = $at; - $at = $pat['p']; - } else { - unset($pat); - } - - $uid1 = $this->atacks[$id]['uid1']; - $uid2 = $this->atacks[$id]['uid2']; - - if ($this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] > 0) { - $uid1 = $this->yhod_user( - $this->atacks[$id]['uid2'], $this->atacks[$id]['uid1'], - $this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] - ); - } elseif ($this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] > 0) { - $uid2 = $this->yhod_user( - $this->atacks[$id]['uid1'], $this->atacks[$id]['uid2'], - $this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] - ); - } - - $i = 1; - while ($i <= 2) { - if ($i == 1) { - $a = 1; - $b = 2; - $u1 = ${'uid1'}; - $u2 = ${'uid2'}; - } else { - $a = 2; - $b = 1; - $u1 = ${'uid2'}; - $u2 = ${'uid1'}; - } - - //Расчет парирования Цели (u2) от Атакующего (u1) - $j = 0; - if ($rjd > 0) { - $j = $rjd - 1; - } - - if (is_array($at[$a]['atack'])) { - while ($j < count($at[$a]['atack']) && $j < 8) { - // КУДА БИЛ , ТИП УДАРА - if ((!isset($this->stats[$this->uids[$u2]]['no_pr1']) || $this->stats[$this->uids[$u2]]['no_pr1'] == 0) && $at[$a]['atack'][$j][2] == $v) { - if ($this->mfs( - 3, [ - 'u1' => $u1, - 'u2' => $u2, - '1' => $this->stats[$this->uids[$u2]]['m7'], - '2' => $this->stats[$this->uids[$u1]]['m7'], - ], $this->users[$this->uids[$u1]]['level'], - $this->users[$this->uids[$u2]]['level'] - ) == 1 && $this->atacks[$id]['out' . $b] == 0) { - //Парировал, гад :) - $this->stats[$this->uids[$u1]]['nopryh'] = floor( - 0 + (int)$this->stats[$this->uids[$u1]]['nopryh'] - ); - if ((!isset($this->stats[$this->uids[$u1]]['nopryh']) || $this->stats[$this->uids[$u1]]['nopryh'] == 0) && $this->stats[$this->uids[$u1]]['nopryh_act'] < 1) { - $at[$a]['atack'][$j][1] = 6; - $this->stats[$this->uids[$u1]]['nopryh']--; - $this->stats[$this->uids[$u1]]['nopryh_act']++; - } - } - } - $j++; - } - } - $i++; - } - - if (isset($pat) && $pat) { - $pat['p'] = $at; - $at = $pat; - } - - return $at; - } - //Расчет блока щитом игроков - public function mf4Razmen($id, $at, $v, $pat = false, $rjd = 0) + + public function delPriem( + $pl, + $u1, + $t = 1, + $u2 = false, + $rznm = 'Очиститься Кровью', + $k2nm = null, + $yrn = null, + $yrnt = null + ) { - if ($pat) { - $pat = $at; - $at = $pat['p']; - } else { - unset($pat); + global $u, $priem; + if (!isset($pl['priem']['id']) || isset($this->del_val['eff'][$pl['priem']['id']])) { + return; } - - $uid1 = $this->atacks[$id]['uid1']; - $uid2 = $this->atacks[$id]['uid2']; - - if ($this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] > 0) { - $uid1 = $this->yhod_user( - $this->atacks[$id]['uid2'], $this->atacks[$id]['uid1'], - $this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] - ); - } elseif ($this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] > 0) { - $uid2 = $this->yhod_user( - $this->atacks[$id]['uid1'], $this->atacks[$id]['uid2'], - $this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] - ); + if ($pl['x'] > 1) { + $pl['name'] = $pl['name'] . ' x' . $pl['x'] . ''; } - - $i = 1; - while ($i <= 2) { - if ($i == 1) { - $a = 1; - $b = 2; - $u1 = ${'uid1'}; - $u2 = ${'uid2'}; - } else { - $a = 2; - $b = 1; - $u1 = ${'uid2'}; - $u2 = ${'uid1'}; - } - if ($this->stats[$this->uids[$u2]]['sheld1'] > 0) { - //Расчет блока щитом Цели (u2) от Атакующего (u1) - $j = 0; - while ($j < count($at[$a]['atack']) && $j < 8) { - // КУДА БИЛ , ТИП УДАРА - if ($at[$a]['atack'][$j][2] == $v) { - if ($this->mfs( - 5, - ($this->stats[$this->uids[$u2]]['m8'] / 2 + $this->stats[$this->uids[$u2]]['m18']), - $this->users[$this->uids[$u1]]['level'], - $this->users[$this->uids[$u2]]['level'] - ) == 1 && $this->atacks[$id]['out' . $b] == 0) { - //блокировал щитом, гад :) - $at[$a]['atack'][$j][1] = 7; - } - } - $j++; + if ($pl['timeUse'] == 77) { + //завершаем прием + mysql_query('DELETE FROM `eff_users` WHERE `id` = "' . $pl['id'] . '" LIMIT 1'); + } + $vLog = 'time1=' . time() . '||s1=' . $u1['sex'] . '||t1=' . $u1['team'] . '||login1=' . $u1['login'] . ''; + if (isset($u2['id'])) { + $vLog .= '||s2=' . $u2['sex'] . '||t2=' . $u2['team'] . '||login2=' . $u2['login'] . ''; + } + $mas1 = [ + 'time' => time(), + 'battle' => $this->info['id'], + 'id_hod' => $this->hodID, + 'text' => '', + 'vars' => $vLog, + 'zona1' => '', + 'zonb1' => '', + 'zona2' => '', + 'zonb2' => '', + 'type' => '1', + ]; + if ($t == 4) { + $mas1['id_hod']++; + $t = 2; + } + if ($t == 1) { + $mas1['id_hod']++; + if ($pl['priem']['file'] != '0') { + if (file_exists('../../_incl_data/class/priems/' . $pl['priem']['file'] . '.php')) { + require('priems/' . $pl['priem']['file'] . '.php'); } + } elseif ($pl['priem']['file3'] != '0') { + if (file_exists('../../_incl_data/class/priems/' . $pl['priem']['file3'] . '.php')) { + require('priems/' . $pl['priem']['file3'] . '.php'); + } + } else { + $mas1['text'] = '{tm1} {u1} {1x16x0} прием "' . $pl['name'] . '".'; + $this->del_val['eff'][$pl['priem']['id']] = true; } - $i++; + } elseif ($t == 2) { + $mas1['text'] = '{tm1} У персонажа {u1} закончилось действие магии "' . $pl['name'] . '".'; + } elseif ($t == 99) { + $mas1['text'] = '{u1} Снял эфект "' . $pl['name'] . '" с помощью ' . $rznm . ' .'; + } else { + if ($t == 100) { + $mas1['id_hod']++; + } + $mas1['text'] = '{tm1} Закончилось действие эффекта "' . $pl['name'] . '" для {u1}.'; } - - if (isset($pat) && $pat) { - $pat['p'] = $at; - $at = $pat; + if ($pl['priem']['id'] != 24) { + $this->add_log($mas1); } - - return $at; + $this->stats[$this->uids[$pl['uid']]] = $u->getStats($pl['uid'], 0, 0, false, false, true); } //Расчет контрудара игроков - public function mf5Razmen($id, $at, $v, $rjd = 0) - { - global $u; - $uid1 = $this->atacks[$id]['uid1']; - $uid2 = $this->atacks[$id]['uid2']; - - if ($this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] > 0) { - $uid1 = $this->yhod_user( - $this->atacks[$id]['uid2'], $this->atacks[$id]['uid1'], - $this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] - ); - } elseif ($this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] > 0) { - $uid2 = $this->yhod_user( - $this->atacks[$id]['uid1'], $this->atacks[$id]['uid2'], - $this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] - ); - } - - $i = 1; - while ($i <= 2) { - if ($i == 1) { - $a = 1; - $b = 2; - $u1 = ${'uid1'}; - $u2 = ${'uid2'}; - } else { - $a = 2; - $b = 1; - $u1 = ${'uid2'}; - $u2 = ${'uid1'}; - } - - //Расчет контрудара Цели (u2) по Атакующему (u1) - $j = 0; - if ($rjd > 0) { - $j = $rjd - 1; - } - while ($j < count($at[$a]['atack']) && $j < 8) { - // КУДА БИЛ , ТИП УДАРА - if ($at[$a]['atack'][$j][2] == $v) { - if ($at[$a]['atack'][$j][1] == 2) { - if ($this->mfs( - 6, [ - 'u1' => $u1, - 'u2' => $u2, - 'a' => $this->stats[$this->uids[$u2]]['m6'], - 'b' => $this->stats[$this->uids[$u1]]['m6'], - ], $this->users[$this->uids[$u1]]['level'], $this->users[$this->uids[$u2]]['level'] - ) == 1) { - //контрудар, гад :) - $at[$a]['atack'][$j][1] = 8; - $rnd_a = rand(1, 5); - $rjd = count($at[$b]['atack']); - if (!$this->testRazmenblock1($id, $u2, $u1, $rnd_a)) { - $at[$b]['atack'][] = [$rnd_a, 1, 0, 1]; // 3 , 0 , 1 - } else { - $at[$b]['atack'][] = [$rnd_a, 3, 0, 1]; // 3 , 0 , 1 - } - $at = $this->contrRestart($id, $at, 1, $rjd); - } - } - } - $j++; - } - $i++; - } - return $at; - } - - //Выделение из лог текста - public function addlt($a, $id, $s, $rnd = null): string - { - global $log_text; - if ($rnd === null) { - $rnd = rand(0, (count($log_text[$s][$id]) - 1)); - } - return '{' . $a . 'x' . $id . 'x' . $rnd . '}'; - } - - //Добавляем статистику - public function addNewStat($stat) - { - if (isset($stat[1])) { - mysql_query( - 'INSERT INTO `battle_stat` - ( `battle`,`uid1`,`uid2`,`time`,`type`,`a`,`b`,`ma`,`mb`,`type_a`,`type_b`,`yrn`,`yrn_krit`,`tm1`,`tm2` ) VALUES ( - "' . $this->info['id'] . '", - "' . $stat[1]['uid1'] . '", - "' . $stat[1]['uid2'] . '", - "' . $stat[1]['time'] . '", - "' . $stat[1]['type'] . '", - "' . $stat[1]['a'] . '", - "' . $stat[1]['b'] . '", - "' . $stat[1]['ma'] . '", - "' . $stat[1]['mb'] . '", - "' . $stat[1]['type_a'] . '", - "' . $stat[1]['type_b'] . '", - "' . $stat[1]['yrn'] . '", - "' . $stat[1]['yrn_krit'] . '", - "' . $stat[1]['tm1'] . '", - "' . $stat[1]['tm2'] . '" - )' - ); - } - if (isset($stat[2])) { - mysql_query( - 'INSERT INTO `battle_stat` - ( `battle`,`uid1`,`uid2`,`time`,`type`,`a`,`b`,`ma`,`mb`,`type_a`,`type_b`,`yrn`,`yrn_krit`,`tm1`,`tm2` ) VALUES ( - "' . $this->info['id'] . '", - "' . $stat[2]['uid1'] . '", - "' . $stat[2]['uid2'] . '", - "' . $stat[2]['time'] . '", - "' . $stat[2]['type'] . '", - "' . $stat[2]['a'] . '", - "' . $stat[2]['b'] . '", - "' . $stat[1]['ma'] . '", - "' . $stat[2]['mb'] . '", - "' . $stat[2]['type_a'] . '", - "' . $stat[2]['type_b'] . '", - "' . $stat[2]['yrn'] . '", - "' . $stat[2]['yrn_krit'] . '", - "' . $stat[2]['tm1'] . '", - "' . $stat[2]['tm2'] . '" - )' - ); - } - } - - public $prlog = []; - - //Добавляем статистику ударов - public function asr($u1, $u2, $type) - { - mysql_query( - 'INSERT INTO battle_static ( - `uid1`,`uid2`,`hod`,`type`,`time`,`bid` - ) VALUES ( - "' . $u1 . '","' . $u2 . '","' . $this->hodID . '","' . $type . '","' . time( - ) . '","' . $this->info['id'] . '" - )' - ); - } - - //Добавляем размены в лог - public function addlogRazmen($id, $at): bool - { - global $u; - - $r = ''; - - $uid1 = $this->atacks[$id]['uid1']; - $uid2 = $this->atacks[$id]['uid2']; - - $this->hodID++; - - $dies = [ - 1 => 0, - 2 => 0, - ]; - - //массив для статистики - $stat = [ - 1 => [ - 'uid1' => 0, - 'uid2' => 0, - 'time' => time(), - 'type' => 0, - 'a' => '00000', - 'b' => '0', - 'type_a' => '', - 'type_b' => '0', - 'yrn' => 0, - 'yrn_krit' => 0, - 'ma' => 0, - 'mb' => 0, - 'tm1' => 0, - 'tm2' => 0, - ], - 2 => [ - 'uid1' => 0, - 'uid2' => 0, - 'time' => time(), - 'type' => 0, - 'a' => '00000', - 'b' => '0', - 'type_a' => '', - 'type_b' => '0', - 'yrn' => 0, - 'yrn_krit' => 0, - 'ma' => 0, - 'mb' => 0, - 'tm1' => 0, - 'tm2' => 0, - ], - ]; - - - $i = 1; - while ($i <= 2) { - if ($i == 1) { - $a = 1; - $b = 2; - $u1 = ${'uid1'}; - $u2 = ${'uid2'}; - } else { - $a = 2; - $b = 1; - $u1 = ${'uid2'}; - $u2 = ${'uid1'}; - } - - if ($this->stats[$this->uids[$u1]]['yhod'] <= 0 && $this->stats[$this->uids[$u2]]['yhod'] > 0) { - $u2 = $this->yhod_user($u1, $u2, $this->stats[$this->uids[$u2]]['yhod']); - } - - $s1 = $this->users[$this->uids[$u1]]['sex']; - $s2 = $this->users[$this->uids[$u2]]['sex']; - - $stat[$a]['uid1'] = $u1; - $stat[$a]['uid2'] = $u2; - $stat[$a]['ma'] = $this->stats[$this->uids[$u1]]['zona']; - $stat[$a]['mb'] = $this->stats[$this->uids[$u1]]['zonb']; - $stat[$a]['tm1'] = $this->users[$this->uids[$u1]]['team']; - $stat[$a]['tm2'] = $this->users[$this->uids[$u2]]['team']; - $stat[$a]['a'] = $this->atacks[$id]['a' . $a]; - $stat[$a]['b'] = $this->atacks[$id]['b' . $a]; - - $vLog = 'at1=00000||at2=00000||zb1=' . $this->stats[$this->uids[$u1]]['zonb'] . '||zb2=' . $this->stats[$this->uids[$u2]]['zonb'] . '||bl1=' . $this->atacks[$id]['b' . $a] . '||bl2=' . $this->atacks[$id]['b' . $b] . '||time1=' . $this->atacks[$id]['time'] . '||time2=' . $this->atacks[$id]['time2'] . '||s' . $a . '=' . $s1 . '||s' . $b . '=' . $s2 . '||t2=' . $this->users[$this->uids[$u2]]['team'] . '||t1=' . $this->users[$this->uids[$u1]]['team'] . '||login1=' . $this->users[$this->uids[$u1]]['login2'] . '||login2=' . $this->users[$this->uids[$u2]]['login2'] . ''; - - $mas = [ - 'text' => '', - 'time' => time(), - 'vars' => '', - 'battle' => $this->info['id'], - 'id_hod' => $this->hodID, - 'vars' => $vLog, - 'type' => 1, - ]; - - if (!isset($at[$a]['atack'])) { //ТУТ тест пропуска - if ($this->atacks[$id]['tpo' . $a] == 2) { - $mas['text'] .= '{u1} потратил свой ход на магию.'; - } else { - // - if ($this->info['razdel'] == 0 && $this->info['dn_id'] == 0 && $this->info['izlom'] == 0) { - mysql_query( - 'INSERT INTO `battle_out` (`battle`,`uid1`,`uid2`,`time`,`out`) VALUES ( - "' . $this->info['id'] . '","' . $u1 . '","' . $u2 . '","' . time() . '","1" - )' - ); - } - // - if (isset($u1)) { - $mas['text'] .= '{u1} пропустил свой ход.'; - //Проверка сброс туманок - mysql_query( - 'UPDATE `eff_users` SET `delete` = "' . time( - ) . '" WHERE `uid` = "' . $u1 . '" AND `delete` = 0 AND `v1` = "priem" AND (`v2`=288 OR `v2`=287 OR `v2`=286 OR `v2`=273) LIMIT 1' - ); - } - } - $mas['text'] = '{tm1} ' . $mas['text']; - $this->add_log($mas); - } else { - $j = 0; - while ($j < count($at[$a]['atack']) && $j < 8) { - // - $mas['text'] = ''; - // - $wt = [ - 21 => 4, - 22 => 5, - 20 => 2, - 28 => 2, - 19 => 3, - 18 => 1, - 26 => 22, - ]; - $par = [ - 'zona' => '{zn2_' . $at[$a]['atack'][$j][0] . '} ', - 'kyda' => $this->lg_zon[$at[$a]['atack'][$j][0]][rand( - 0, - (count($this->lg_zon[$at[$a]['atack'][$j][0]]) - 1) - )], - 'chem' => $this->lg_itm[$wt[$at[$a]['atack'][$j]['wt']]][rand( - 0, - (count($this->lg_itm[$wt[$at[$a]['atack'][$j]['wt']]]) - 1) - )], - ]; - // - $this->atacks[$id]['uid_' . $u1 . '_t' . $at[$a]['atack'][$j][1]]++; - // - // - $this->asr($u1, $u2, $at[$a]['atack'][$j][1]); - // - if ($at[$a]['atack'][$j][1] == 1) { - //u1 ударил обычным ударом u2 - $mas['text'] .= $par['zona'] . '{u2} ' . $this->addlt($b, 1, $s2, null) . '' . $this->addlt( - $b, - 2, $s2, null - ) . '' . $this->addlt($a, 3, $s1, null) . ' {u1} ' . $this->addlt( - $a, 4, - $s1, null - ) . '' . $this->addlt($a, 5, $s1, null) . '' . $this->addlt( - $a, 6, $s1, - null - ) . ' ' . $this->addlt( - 1, 7, $s1, - $at[$a]['atack'][$j]['yron']['t'] - ) . ' ' . $par['chem'] . ' ' . $par['kyda'] . '. '; - } elseif ($at[$a]['atack'][$j][1] == 2) { - //u2 увернулся от u1 - $mas['text'] .= $par['zona'] . '{u1} ' . $this->addlt($a, 8, $s1, null) . '' . $this->addlt( - $a, - 9, $s1, null - ) . ' {u2} ' . $this->addlt( - $b, 11, $s2, - null - ) . ' ' . $par['chem'] . ' ' . $par['kyda'] . '. '; - } elseif ($at[$a]['atack'][$j][1] == 3) { - //u2 заблокировал удар u1 - $mas['text'] .= $par['zona'] . '{u1} ' . $this->addlt($a, 8, $s1, null) . '' . $this->addlt( - $a, - 9, $s1, null - ) . ' {u2} ' . $this->addlt( - $b, 10, $s2, - null - ) . ' ' . $this->addlt( - 1, 7, 0, $s1, - $at[$a]['atack'][$j]['yron']['t'] - ) . ' ' . $par['chem'] . ' ' . $par['kyda'] . '. '; - } elseif ($at[$a]['atack'][$j][1] == 4) { - //u1 пробил блок u2 критом - if (isset($at[$a]['atack'][$j]['yron']['t'])) { - $mas['text'] .= $par['zona'] . '{u2} ' . $this->addlt( - $b, 1, $s2, - null - ) . '' . $this->addlt($b, 2, $s2, null) . '' . $this->addlt( - $a, 3, $s1, - null - ) . ' {u1} ' . $this->addlt($a, 4, $s1, null) . '' . $this->addlt( - $a, 5, $s1, - null - ) . ', пробив блок, ' . $this->addlt( - $a, 6, $s1, - null - ) . ' ' . $this->addlt( - 1, 7, $s1, - $at[$a]['atack'][$j]['yron']['t'] - ) . ' ' . $par['chem'] . ' ' . $par['kyda'] . '. '; - } - } elseif ($at[$a]['atack'][$j][1] == 5) { - //u1 ударил критическим ударом u2 - $mas['text'] .= $par['zona'] . '{u2} ' . $this->addlt($b, 1, $s2, null) . '' . $this->addlt( - $b, - 2, $s2, null - ) . '' . $this->addlt($a, 3, $s1, null) . ' {u1} ' . $this->addlt( - $a, 4, - $s1, null - ) . '' . $this->addlt($a, 5, $s1, null) . '' . $this->addlt( - $a, 6, $s1, - null - ) . ' ' . $this->addlt( - 1, 7, $s1, - $at[$a]['atack'][$j]['yron']['t'] - ) . ' ' . $par['chem'] . ' ' . $par['kyda'] . '. '; - } elseif ($at[$a]['atack'][$j][1] == 6) { - //u2 парировал удар u1 - $mas['text'] .= $par['zona'] . '{u1} ' . $this->addlt($a, 8, $s1, null) . '' . $this->addlt( - $a, - 9, $s1, - null - ) . ' {u2} неожиданно парировал ' . $this->addlt( - 1, - 7, 0, $s1, - $at[$a]['atack'][$j]['yron']['t'] - ) . ' ' . $par['chem'] . ' ' . $par['kyda'] . '. '; - } elseif ($at[$a]['atack'][$j][1] == 7) { - //u2 блокировал щитом удар u1 - $mas['text'] .= $par['zona'] . '{u1} ' . $this->addlt($a, 8, $s1, null) . '' . $this->addlt( - $a, - 9, $s1, - null - ) . ' {u2}, воспользовавшись своим щитом, ' . $this->addlt( - $b, - 10, $s2, null - ) . ' ' . $this->addlt( - 1, 7, 0, $s1, - $at[$a]['atack'][$j]['yron']['t'] - ) . ' ' . $par['chem'] . ' ' . $par['kyda'] . '. '; - } elseif ($at[$a]['atack'][$j][1] == 8) { - //u2 увернулся от удара u1 и нанес по нему контрудар - $mas['text'] .= $par['zona'] . '{u1} ' . $this->addlt($a, 8, $s1, null) . '' . $this->addlt( - $a, - 9, $s1, null - ) . ' {u2} ' . $this->addlt( - $b, 11, $s2, - null - ) . ' ' . $par['chem'] . ' ' . $par['kyda'] . ' и нанес контрудар. '; - } - - $stat[$a]['type_a'] .= '' . $at[$a]['atack'][$j][1] . ''; - if ((!isset($this->stats[$this->uids[$u2]]['notravma']) || $this->stats[$this->uids[$u2]]['notravma'] == 0) && isset($at[$a]['atack'][$j]['yron']['travma']) && $at[$a]['atack'][$j]['yron']['travma'][0] > 0 && floor( - $at[$a]['atack'][$j]['yron']['hp'] - ) <= 0) { - $tr_pl = mysql_fetch_array( - mysql_query( - 'SELECT `id`,`v1` FROM `eff_users` WHERE `id_eff` = 4 AND `uid` = "' . $u2 . '" AND `delete` = "0" ORDER BY `v1` DESC LIMIT 1' - ) - ); - if (!isset($tr_pl['id']) || $tr_pl['v1'] < 3) { - //263 - if (isset($tr_pl['id'])) { - $at[$a]['atack'][$j]['yron']['travma'][0] = rand(($tr_pl['v1'] + 1), 3); - } - $tr_pl2 = mysql_fetch_array( - mysql_query( - 'SELECT `id` FROM `eff_users` WHERE `uid` = "' . $u2 . '" AND `delete` = "0" AND `name` LIKE "%Защита от травм%" LIMIT 1' - ) - ); - if (!isset($tr_pl2['id']) && $at[$a]['atack'][$j]['yron']['travma'][0] <= 3) { - $mas['text'] = rtrim($mas['text'], '. '); - $mas['text'] .= ', нанеся противнику '; - if ($at[$a]['atack'][$j]['yron']['travma'][0] == 1) { - $mas['text'] .= 'Легкую'; - $this->addTravm($u2, 1, rand(3, 5)); - } elseif ($at[$a]['atack'][$j]['yron']['travma'][0] == 2) { - $mas['text'] .= 'Среднюю'; - $this->addTravm($u2, 2, rand(3, 5)); - } elseif ($at[$a]['atack'][$j]['yron']['travma'][0] == 3) { - $mas['text'] .= 'Тяжелую'; - $this->addTravm($u2, 3, rand(3, 5)); - } - $mas['text'] .= ' травму. '; - } - } - unset($tr_pl); - } - if ($at[$a]['atack'][$j]['yron']['pb'] == 1 && isset($at[$a]['atack'][$j]['yron']['hp'])) { - $mas['text'] = rtrim($mas['text'], '. '); - $mas['text'] .= ' пробив броню. '; - } - if ($at[$a]['atack'][$j][3] == 1) { - $mas['text'] .= '(контрудар) '; - } - if (isset($at[$a]['atack'][$j]['yron'])) { - if ($at[$a]['atack'][$j]['yron']['w'] == 3) { - $mas['textWP'] = '(правая рука)'; - } elseif ($at[$a]['atack'][$j]['yron']['w'] == 14) { - $mas['textWP'] = '(левая рука)'; - } else { - $mas['textWP'] = '(непонятно чем)'; - } - if ($at[$a]['atack'][$j][1] == 4 || $at[$a]['atack'][$j][1] == 5 || $at[$a]['atack'][$j][1] == 1) { - if ($at[$a]['atack'][$j]['yron']['y'] < 1) { - $at[$a]['atack'][$j]['yron']['r'] = '--'; - } - } - if ($at[$a]['atack'][$j][1] == 4 || $at[$a]['atack'][$j][1] == 5) { - $stat[$a]['yrn_krit'] += -$at[$a]['atack'][$j]['yron']['r']; - $mas['text'] .= ' ' . $at[$a]['atack'][$j]['yron']['r'] . ''; - } else { - $mas['text'] .= ' ' . $at[$a]['atack'][$j]['yron']['r'] . ''; - } - $stat[$a]['yrn'] += -$at[$a]['atack'][$j]['yron']['r']; - } - if (isset($at[$a]['atack'][$j]['yron']['hp'])) { - if ($this->users[$this->uids[$u2]]['align'] == 9) { - $at[$a]['atack'][$j]['yron']['hp'] = $at[$a]['atack'][$j]['yron']['hp'] / ($at[$a]['atack'][$j]['yron']['hpAll'] / 100); - $at[$a]['atack'][$j]['yron']['hpAll'] = '100%'; - } - $mas['text'] .= ' [' . floor($at[$a]['atack'][$j]['yron']['hp']) . '/' . floor( - $at[$a]['atack'][$j]['yron']['hpAll'] - ) . ']'; - } - if ($mas['text'] != '') { - $mas['text'] = '{tm1} ' . $mas['text']; - } - - if (is_array($at[$a]['atack'][$j]['yron']['plog'])) { - $il = 0; - while ($il <= count($at[$a]['atack'][$j]['yron']['plog'])) { - if (isset($at[$a]['atack'][$j]['yron']['plog'][$il])) { - eval($at[$a]['atack'][$j]['yron']['plog'][$il]); - } - $il++; - } - } - $this->add_log($mas); - $j++; - } - } - $i++; - } - - //Добавляем статистику + записываем в баттл_юзерс НР игроков - $this->addNewStat($stat); - - //Вывод в лог смерти персонажа - if (floor($this->stats[$this->uids[$u1]]['hpNow']) < 1) { - $dies[1] = 1; - } - if (floor($this->stats[$this->uids[$u2]]['hpNow']) < 1) { - $dies[2] = 1; - } - if ($dies[1] > 0 || $dies[2] > 0) { - $s1 = $this->users[$this->uids[$u1]]['sex']; - $s2 = $this->users[$this->uids[$u2]]['sex']; - - $vLog = 'at1=00000||at2=00000||zb1=' . $this->stats[$this->uids[$u1]]['zonb'] . '||zb2=' . $this->stats[$this->uids[$u2]]['zonb'] . '||bl1=' . $this->atacks[$id]['b' . $a] . '||bl2=' . $this->atacks[$id]['b' . $b] . '||time1=' . $this->atacks[$id]['time'] . '||time2=' . $this->atacks[$id]['time2'] . '||s2=' . $this->users[$this->uids[$u2]]['sex'] . '||s1=' . $this->users[$this->uids[$u1]]['sex'] . '||t2=' . $this->users[$this->uids[$u2]]['team'] . '||t1=' . $this->users[$this->uids[$u1]]['team'] . '||login1=' . $this->users[$this->uids[$u1]]['login2'] . '||login2=' . $this->users[$this->uids[$u2]]['login2'] . ''; - - $mas = [ - 'text' => '', - 'time' => time(), - 'vars' => '', - 'battle' => $this->info['id'], - 'id_hod' => $this->hodID, - 'vars' => $vLog, - 'type' => 1, - ]; - - $rtngwin = [1, 2, 3, 5, 10, 20, 40, 80, 160]; - $rtnglos = [0, 0, 0, -1, -2, -5, -10, -20, -40]; - - if ($this->info['typeBattle'] == 99) { - if ($btlstatus[0] == 0) { - //Кровавые бои обычные - $rtngwin = [2, 4, 6, 10, 20, 40, 80, 160, 320]; - if ($this->info['razdel'] == 5) { - //не хаот - $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; - } else { - //хаот - $rtnglos = [0, 0, 0, 0, 0, 0, 0, 0, 0]; - } - } elseif ($btlstatus[0] == 25) { - //Кровавая битва - $rtngwin = [3, 6, 9, 15, 30, 60, 120, 240, 480]; - $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; - } elseif ($btlstatus[0] == 50) { - //Кровавая резня - $rtngwin = [4, 8, 16, 32, 64, 128, 256, 512, 1024]; - $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; - } elseif ($btlstatus[0] == 75) { - //Кровавая сеча - $rtngwin = [5, 10, 20, 40, 80, 160, 320, 640, 1280]; - $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; - } elseif ($btlstatus[0] == 100) { - //Кровавое побоище - $rtngwin = [6, 12, 24, 48, 98, 196, 392, 784, 1568]; - $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; - } elseif ($btlstatus[0] == 150) { - //Судный день - $rtngwin = [7, 14, 28, 56, 112, 224, 448, 896, 1792]; - $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; - } - } else { - if ($btlstatus[0] == 0) { - //Обычный поединок - $rtngwin = [1, 2, 3, 5, 10, 20, 40, 80, 160]; - if ($this->info['razdel'] == 5) { - //не хаот - $rtnglos = [0, 0, 0, -1, -2, -5, -10, -20, -40]; - } else { - //хаот - $rtnglos = [0, 0, 0, 0, 0, 0, 0, 0, 0]; - } - } elseif ($btlstatus[0] == 25) { - //великая битва - $rtngwin = [2, 4, 6, 10, 20, 40, 80, 160, 320]; - $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; - } elseif ($btlstatus[0] == 50) { - //величайшая битва - $rtngwin = [3, 6, 9, 15, 30, 60, 120, 240, 480]; - $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; - } elseif ($btlstatus[0] == 75) { - //историческая битва сеча - $rtngwin = [4, 8, 16, 32, 64, 128, 256, 512, 1024]; - $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; - } elseif ($btlstatus[0] == 100) { - //эпохальная битва - $rtngwin = [5, 10, 20, 40, 80, 160, 320, 640, 1280]; - $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; - } elseif ($btlstatus[0] == 150) { - //судный день - $rtngwin = [7, 14, 28, 56, 112, 224, 448, 896, 1792]; - $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; - } - } - - if ($this->info['dn_id'] > 0 || $this->info['izlom'] != 0 || $this->info['turnir'] != 0) { - //Пещерные бои не считаются и Изломы тоже, ну и Турниры - $rtngwin = [0, 0, 0, 0, 0, 0, 0, 0, 0]; - $rtnglos = [0, 0, 0, 0, 0, 0, 0, 0, 0]; - } elseif ($this->info['clan1'] > 0 && $this->info['clan2'] > 0) { - //Клановая война - $rtngwin = [3, 6, 9, 15, 30, 60, 120, 240, 480]; - $rtnglos = [-1, -2, -4, -8, -16, -32, -64, -128, -256]; - } - - - if ($dies[1] == 1) { - if ($this->info['dn_id'] <= 0 && $this->users[$this->uids[$u1]]['level'] >= 4) { - $rtng1 += $rtnglos[$this->users[$this->uids[$u1]]['level'] - 4]; - $rtng2 += $rtngwin[$this->users[$this->uids[$u1]]['level'] - 4]; - } - //Персонаж 1 погиб от рук персонаж 2 - $this->spaCheck($this->users[$this->uids[$u1]]['id']); - } - if ($dies[2] == 1) { - if ($this->info['dn_id'] <= 0 && $this->users[$this->uids[$u1]]['level'] >= 4) { - $rtng1 += $rtnglos[$this->users[$this->uids[$u1]]['level'] - 4]; - $rtng2 += $rtngwin[$this->users[$this->uids[$u1]]['level'] - 4]; - } - //Персонаж 2 погиб от рук персонаж 1 - $this->spaCheck($this->stats[$this->uids[$u2]]['id']); - } - //Записываем рейтинг - // - if ($this->info['type'] != 564 && $this->stats[$this->uids[$u1]]['inTurnir'] == 0 && $this->stats[$this->uids[$u2]]['inTurnir'] == 0 && $this->info['dn_id'] == 0 && $this->info['izlom'] == 0) { - // - if ($this->users[$this->uids[$u2]]['bot'] == 0) { - mysql_query( - 'INSERT INTO `users_reting` (`uid`,`time`,`val`,`align`,`clan`) VALUES ( - "' . $u1 . '","' . time( - ) . '","' . $rtng1 . '","' . $this->users[$this->uids[$u1]]['align'] . '","' . $this->users[$this->uids[$u1]]['clan'] . '")' - ); - } - unset($rtng); - if ($this->users[$this->uids[$u1]]['bot'] == 0) { - mysql_query( - 'INSERT INTO `users_reting` (`uid`,`time`,`val`,`align`,`clan`) VALUES ( - "' . $u2 . '","' . time( - ) . '","' . $rtng2 . '","' . $this->users[$this->uids[$u2]]['align'] . '","' . $this->users[$this->uids[$u2]]['clan'] . '")' - ); - } - } - unset($rtng1, $rtng2); - } - return true; - } - - //Добавляем в лог действия приема - public function priemAddLog($id, $a, $b, $u1, $u2, $prm, $text, $hodID, $tm1 = 0, $tm2 = 0) - { - $time = time(); - if ($tm1 == 0) { - $tm1 = isset($this->atacks[$id]) ? $this->atacks[$id]['time'] : $time; - } - if ($tm2 == 0) { - $tm2 = isset($this->atacks[$id]) ? $this->atacks[$id]['time2'] : $time; - } - $prm = str_replace('=', '^^^^', $prm); - $vLog = - 'prm=' . $prm . - '||at1=00000||at2=00000||zb1=' . $this->stats[$this->uids[$u1]]['zonb'] . - '||zb2=' . $this->stats[$this->uids[$u2]]['zonb'] . - '||bl1=' . $this->atacks[$id]['b' . $a] . - '||bl2=' . $this->atacks[$id]['b' . $b] . - '||time1=' . $tm1 . - '||time2=' . $tm2 . - '||s' . $a . '=' . $this->users[$this->uids[$u1]]['sex'] . - '||s' . $b . '=' . $this->users[$this->uids[$u2]]['sex'] . - '||t2=' . $this->users[$this->uids[$u2]]['team'] . - '||t1=' . $this->users[$this->uids[$u1]]['team'] . - '||login1=' . $this->users[$this->uids[$u1]]['login2'] . - '||login2=' . $this->users[$this->uids[$u2]]['login2']; - - $mas = [ - 'text' => $text, - 'time' => $time, - 'battle' => $this->info['id'], - 'id_hod' => $hodID, - 'vars' => $vLog, - 'type' => 1, - ]; - $this->add_log($mas); - } - - //Добавляем в лог действия приема (без атаки) public function priemAddLogFast($u1, $u2, $prm, $text, $hodID, $tm) { $vLog = 'prm=' . $prm . '||time1=' . $tm . '||time2=' . $tm . '||s1=' . $this->users[$this->uids[$u1]]['sex'] . '||s2=' . $this->users[$this->uids[$u2]]['sex'] . '||t2=' . $this->users[$this->uids[$u2]]['team'] . '||t1=' . $this->users[$this->uids[$u1]]['team'] . '||login1=' . $this->users[$this->uids[$u1]]['login2'] . '||login2=' . $this->users[$this->uids[$u2]]['login2'] . ''; @@ -5612,27 +4291,8 @@ class Battle $this->add_log($mas); } - //Считаем контру - public function contrRestart($id, $at, $v, $rjd = 0) - { - //уворот - $at = $this->mf1Razmen($id, $at, $v, true, $rjd); - //парирование - $at = $this->mf3Razmen($id, $at, $v, true, $rjd); - //контрудар - //$at = $this->mf5Razmen($id,$at,$v,true,$rjd); - //блок щитом (если есть щит, конечно) - $at = $this->mf4Razmen($id, $at, $v, true, $rjd); - //Проверяем урон - //$at = $this->yronRazmen($id,$at); - //крит - $at = $this->mf2Razmen($id, $at, $v, true, $rjd); - $at = $this->yronRazmen($id, $at, true, $rjd); - return $at; - } + //Выделение из лог текста - - //Расчитываем статы для конкретной зоны атаки public function yronGetrazmenStats($s, $z) { global $u; @@ -5702,1196 +4362,7 @@ class Battle return $s; } - //Расчитываем ед. урона - public function yronGetrazmen($uid1, $uid2, $wp, $zona): array - { - global $u; - - $r = [ - 'y' => 0, - 'r' => '--', - ]; - //Определяем тип урона - /* - Колющий - Рубящий - Режущий - Дробящий - */ - $witm = 0; - $witm_type = 0; - - if ($wp > 0) { - $witm = $this->stats[$this->uids[$uid1]]['items'][$this->stats[$this->uids[$uid1]]['wp' . $wp . 'id']]; - $witm_data = ConversionHelper::dataStringToArray($witm['data']); - $witm_type = $this->weaponTx($witm); - } - if ($witm_type == 0 || $witm_type == 12) { - $witm_type2 = ''; - } else { - $witm_type2 = $witm_type; - } - $r['t'] = $witm_type2; - //Расчет брони - /* - голова - грудь - живот - пояс - ноги - */ - $bron = [ - 1 => [$this->stats[$this->uids[$uid2]]['mib1'], $this->stats[$this->uids[$uid2]]['mab1']], - 2 => [$this->stats[$this->uids[$uid2]]['mib2'], $this->stats[$this->uids[$uid2]]['mab2']], - 3 => [$this->stats[$this->uids[$uid2]]['mib2'], $this->stats[$this->uids[$uid2]]['mab2']], - 4 => [$this->stats[$this->uids[$uid2]]['mib3'], $this->stats[$this->uids[$uid2]]['mab3']], - 5 => [$this->stats[$this->uids[$uid2]]['mib4'], $this->stats[$this->uids[$uid2]]['mab4']], - ]; - // - //Увеличиваем параметры от текущего оружия которым бьем - $iii = 1; - while ($iii <= 7) { - if (isset($witm_data['sv_a' . $iii]) && $witm_data['sv_a' . $iii] != 0) { - $this->stats[$this->uids[$uid1]]['a' . $iii] += $witm_data['sv_a' . $iii]; - } - if (isset($witm_data['sv_mg' . $iii]) && $witm_data['sv_mg' . $iii] != 0) { - $this->stats[$this->uids[$uid1]]['mg' . $iii] += $witm_data['sv_mg' . $iii]; - } - $iii++; - } - $iii = 1; - while ($iii <= 4) { - if (isset($witm_data['sv_aall']) && $witm_data['sv_aall'] != 0) { - $this->stats[$this->uids[$uid1]]['a' . $iii] += $witm_data['sv_aall']; - } - $iii++; - } - $iii = 1; - while ($iii <= 4) { - if (isset($witm_data['sv_mall']) && $witm_data['sv_mall'] != 0) { - $this->stats[$this->uids[$uid1]]['mg' . $iii] += $witm_data['sv_mall']; - } - $iii++; - } - $iii = 1; - while ($iii <= 7) { - if (isset($witm_data['sv_m2all']) && $witm_data['sv_m2all'] != 0) { - $this->stats[$this->uids[$uid1]]['mg' . $iii] += $witm_data['sv_m2all']; - } - $iii++; - } - - if (isset($witm_data['sv_m3']) && $witm_data['sv_m3'] != 0) { - $this->stats[$this->uids[$uid1]]['m3'] += $witm_data['sv_m3']; - } - - $iii = 1; - while ($iii <= 7) { - if (isset($witm_data['sv_pa' . $iii]) && $witm_data['sv_pa' . $iii] != 0) { - $this->stats[$this->uids[$uid1]]['pa' . $iii] += $witm_data['sv_pa' . $iii] + $witm_data['sv_m10']; - } - if (isset($witm_data['sv_pm' . $iii]) && $witm_data['sv_pm' . $iii] != 0) { - $this->stats[$this->uids[$uid1]]['pm' . $iii] += $witm_data['sv_pm' . $iii] + $witm_data['sv_m11a']; - if ($iii < 5) { - $this->stats[$this->uids[$uid1]]['pm' . $iii] += $witm_data['sv_m11']; - } - } - $iii++; - } - // - //мощность + подавление мощности противником - $wAp = 0; - $w3p = 0; - $w14p = 0; - - if ($witm_type == 12) { - //удар кулаком - $wAp += $this->stats[$this->uids[$uid1]]['m10']; - if ($this->users[$this->uids[$uid1]]['align'] == 7) { - $wAp += 15; - } - } elseif ($witm_type < 5) { - $wAp += $this->stats[$this->uids[$uid1]]['pa' . $witm_type . '']/* + $this->stats[$this->uids[$uid1]]['m10'] + $witm_data['sv_pa'.$witm_type.'']*/ - ; - $wAp -= $this->stats[$this->uids[$uid2]]['antpa' . $witm_type . '']; - } else { - $wAp += $this->stats[$this->uids[$uid1]]['m10'] + $this->stats[$this->uids[$uid1]]['pm' . ($witm_type - 4) . ''] + $this->stats[$this->uids[$uid1]]['m11a'] + $witm_data['sv_pm' . ($witm_type - 4) . '']; - $wAp -= $this->stats[$this->uids[$uid2]]['antpm' . ($witm_type - 4) . '']; - } - - //Владение данным оружием - $vladenie = 0; - - //Пробой брони - $proboi = 0; - $witm_data['m9'] = $this->stats[$this->uids[$uid1]]['m9']; - if (rand(1, 100) < floor($witm_data['m9'] / 2)) { - $proboi = floor($witm_data['m9'] / 2); - $r['pb'] = 1; - } - - $y = $this->yrn( - $this->stats[$this->uids[$uid1]], - $this->stats[$this->uids[$uid2]], - $this->users[$this->uids[$uid1]], - $this->users[$this->uids[$uid2]], - $this->users[$this->uids[$uid1]]['level'], - $this->users[$this->uids[$uid2]]['level'], - $witm_type, - $this->stats[$this->uids[$uid1]]['minAtack'], //мин. урон (добавочный) - $this->stats[$this->uids[$uid1]]['maxAtack'], //макс. урон - $bron[$zona][0], //броня мин. - $bron[$zona][1], //броня макс - $vladenie, //владения - (($wAp /*+ $w3p + $w14p*/)), //мощность урона - (round($this->stats[$this->uids[$uid1]]['m3'])), //мощность крита - (($this->stats[$this->uids[$uid2]]['za' . $witm_type2]) - $this->stats[$this->uids[$uid1]]['pza']), - //защита от урона - $this->stats[$this->uids[$uid1]]['ozash'], //подавление защиты - $proboi, //пробой брони - 0, //хз - ($witm_data['sv_yron_min'] + $this->stats[$this->uids[$uid1]]['yron_min']), - ($witm_data['sv_yron_max'] + $this->stats[$this->uids[$uid1]]['yron_max']), - $this->stats[$this->uids[$uid2]]['zaproc'], - $this->stats[$this->uids[$uid2]]['zmproc'], - (($this->stats[$this->uids[$uid2]]['zm' . ($witm_type2 - 4)]) - round( - $this->stats[$this->uids[$uid1]]['pzm'] * 0.8 - )), - //защита от урона - $this->stats[$this->uids[$uid1]]['omzash'], //подавление защиты - $witm['type'], - $witm - ); - - $r['y'] = round(rand($y['min'] + $proboi, $y['max'] + round($proboi / 2))); - $r['k'] = round(rand($y['Kmin'] + round($proboi / 4), $y['Kmax'] + round($proboi / 8))); - - $r['m_y'] = $y['max']; - $r['m_k'] = $y['Kmax']; - - $r['bRND'] = $y['bRND']; - - $r['w_type'] = $witm_type; - - //Если второе оружие - урон ниже на 50% - $wp1 = $this->stats[$this->uids[$uid1]]['items'][$this->stats[$this->uids[$uid1]]['wp3id']]; - $wp2 = $this->stats[$this->uids[$uid1]]['items'][$this->stats[$this->uids[$uid1]]['wp14id']]; - - //тип от оружия - if ($witm['type'] == 18) { - $tp = 1; - } elseif ($witm['type'] == 19) { - $tp = 2; - } elseif ($witm['type'] == 20) { - $tp = 3; - } elseif ($witm['type'] == 21) { - $tp = 4; - } else { - $tp = 0; - } - - if ($tp != $witm_type && $wp > 0) // ТУТ - { - (int)$r['y'] = round((int)$r['y'] / 3); - $r['r'] = round($r['r'] / 3); - $r['k'] = round($r['k'] / 3); - $r['m_k'] = round($r['m_k'] / 3); - $r['m_y'] = round($r['m_y'] / 3); - } - - if (isset($this->stats[$this->uids[$uid2]]['zaproc'])) { - $r['y'] = round($r['y'] - $r['y'] * $this->stats[$this->uids[$uid2]]['zaproc'] / 100); - (int)$r['r'] = round((int)$r['r'] - (int)$r['r'] * (int)$this->stats[$this->uids[$uid2]]['zaproc'] / 100); - $r['k'] = round($r['k'] - $r['k'] * $this->stats[$this->uids[$uid2]]['zaproc'] / 100); - $r['m_k'] = round($r['m_k'] - $r['m_k'] * $this->stats[$this->uids[$uid2]]['zaproc'] / 100); - $r['m_y'] = round($r['m_y'] - $r['m_y'] * $this->stats[$this->uids[$uid2]]['zaproc'] / 100); - if ($r['k'] < 1) { - $r['k'] = 2; - } - } - - if ($r['y'] < 1) { - $r['y'] = 1; - } - if ($r['r'] >= 0) { - $r['r'] = -1; - } - if ($r['k'] < 1) { - $r['k'] = 1; - } - if ($r['m_k'] < 1) { - $r['m_k'] = 1; - } - if ($r['m_y'] < 1) { - $r['m_y'] = 1; - } - return $r; - } - - //Считаем урон - public function yronRazmen($id, $at, $pat = false, $rjd = 0) - { - if ($pat) { - $pat = $at; - $at = $pat['p']; - } else { - unset($pat); - } - - $uid1 = $this->atacks[$id]['uid1']; - $uid2 = $this->atacks[$id]['uid2']; - - if ($this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] > 0) { - $yhod = [1 => 1, 2 => 0]; - } elseif ($this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] > 0) { - $yhod = [1 => 0, 2 => 1]; - } - - $i = 1; - while ($i <= 2) { - if ($i == 1) { - $a = 1; - $b = 2; - $u1 = ${'uid1'}; - $u2 = ${'uid2'}; - } else { - $a = 2; - $b = 1; - $u1 = ${'uid2'}; - $u2 = ${'uid1'}; - } - - $j = 0; - $k = 0; - $wp = 3; - if ($rjd > 0) { - $j = $rjd - 1; - } - - if (is_array($at[$a]['atack'])) { - while ($j < count($at[$a]['atack']) && $j < 8) { - if ($k == 0 && isset($this->stats[$this->uids[$u1]]['wp3id'])) { - //Левая рука - $wp = 3; - $k = 1; - } else { - //Правая рука - if (isset($this->stats[$this->uids[$u1]]['wp14id']) && $this->stats[$this->uids[$u1]]['items'][$this->stats[$this->uids[$u1]]['wp14id']]['type'] != 13) { - $wp = 14; - } else { - if (isset($this->stats[$this->uids[$u1]]['wp3id'])) { - $wp = 3; - } else { - //нет оружия - $wp = 3; - } - } - $k = 0; - } - $witm = $this->stats[$this->uids[$u1]]['items'][$this->stats[$this->uids[$u1]]['wp' . $wp . 'id']]; - $witm_type = $this->weaponTx($witm); - $at[$a]['atack'][$j]['wt'] = $witm['type']; - $at[$a]['atack'][$j]['yhod'] = $yhod[$a]; - if (!isset($at[$a]['atack'][$j]['yron']) && ( - $at[$a]['atack'][$j][1] == 1 || - $at[$a]['atack'][$j][1] == 4 || - $at[$a]['atack'][$j][1] == 5) - ) { - $at[$a]['atack'][$j]['yron'] = $this->yronGetrazmen( - $u1, $u2, $wp, $at[$a]['atack'][$j][0], - ); - - if ($at[$a]['atack'][$j][1] == 4) { - $at[$a]['atack'][$j]['yron']['y_old'] = $at[$a]['atack'][$j]['yron']['y']; - $at[$a]['atack'][$j]['yron']['y'] = round($at[$a]['atack'][$j]['yron']['k'] / 2); - } elseif ($at[$a]['atack'][$j][1] == 5) { - $at[$a]['atack'][$j]['yron']['y_old'] = $at[$a]['atack'][$j]['yron']['y']; - $at[$a]['atack'][$j]['yron']['y'] = $at[$a]['atack'][$j]['yron']['k']; - } - $at[$a]['atack'][$j]['yron']['2h'] = $witm['2h']; - $at[$a]['atack'][$j]['yron']['w'] = $wp; - if ($at[$a]['atack'][$j]['yron']['y'] < 1) { - $at[$a]['atack'][$j]['yron']['r'] = '--'; - } else { - $at[$a]['atack'][$j]['yron']['r'] = '-' . $at[$a]['atack'][$j]['yron']['y']; - } - } else { - $at[$a]['atack'][$j]['block'] = $this->yronGetrazmen( - $u1, $u2, $wp, $at[$a]['atack'][$j][0], - $yhod[$b] - ); - if ($at[$a]['atack'][$j][1] == 4) { - $at[$a]['atack'][$j]['block']['y_old'] = $at[$a]['atack'][$j]['block']['y']; - $at[$a]['atack'][$j]['block']['y'] = round($at[$a]['atack'][$j]['block']['k'] / 2); - } elseif ($at[$a]['atack'][$j][1] == 5) { - $at[$a]['atack'][$j]['block']['y_old'] = $at[$a]['atack'][$j]['block']['y']; - $at[$a]['atack'][$j]['block']['y'] = $at[$a]['atack'][$j]['block']['k']; - } - $at[$a]['atack'][$j]['block']['2h'] = $witm['2h']; - $at[$a]['atack'][$j]['block']['w'] = $wp; - if ($at[$a]['atack'][$j]['block']['y'] < 1) { - $at[$a]['atack'][$j]['block']['r'] = '--'; - } else { - $at[$a]['atack'][$j]['block']['r'] = '-' . $at[$a]['atack'][$j]['block']['y']; - } - } - $j++; - } - } - $i++; - } - if (isset($pat) && $pat) { - $pat['p'] = $at; - $at = $pat; - } - return $at; - } - - //Обновление здоровья - public function updateHealth($id, $at): array - { - $uid1 = $this->atacks[$id]['uid1']; - $uid2 = $this->atacks[$id]['uid2']; - - if ($this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] > 0) { - $uid1 = $this->yhod_user( - $this->atacks[$id]['uid2'], $this->atacks[$id]['uid1'], - $this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] - ); - } elseif ($this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] > 0) { - $uid2 = $this->yhod_user( - $this->atacks[$id]['uid1'], $this->atacks[$id]['uid2'], - $this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] - ); - } - - $i = 1; - while ($i <= 2) { - if ($i == 1) { - $a = 1; - $b = 2; - $u1 = ${'uid1'}; - $u2 = ${'uid2'}; - } else { - $a = 2; - $b = 1; - $u1 = ${'uid2'}; - $u2 = ${'uid1'}; - } - - //Рассчет дополнительных тактик - if ($this->atacks[$id]['out' . $b] > 0) { - //Игрок ${'u'.$a} получает тактики, возможно - if (rand(0, 100) < min(floor($this->stats[$this->uids[$u1]]['m6'] / 5), 20)) { - //выдаем тактику контрудара - if ($this->stats[$this->uids[$u2]]['this_animal'] == 0) { - $this->users[$this->uids[$u1]]['tactic3']++; - } - } - if (rand(0, 100) < min(floor($this->stats[$this->uids[$u1]]['m8'] / 4), 20)) { - //выдаем тактику щита - if ($this->stats[$this->uids[$u2]]['this_animal'] == 0) { - $this->users[$this->uids[$u1]]['tactic4']++; - } - } - } - - //Расчет удара Цели (u2) по Атакующему (u1) - $j = 0; - $k = 0; - $wp = 3; - while ($j < count($at[$a]['atack']) && $j < 8) { - //Добавляем тактики - if ($at[$a]['atack'][$j][1] == 1) { - //u1 ударил обычным ударом u2 - if ($this->stats[$this->uids[$u2]]['this_animal'] == 0) { - $this->users[$this->uids[$u1]]['tactic1']++; - } - //Двуручка - if ($at[$a]['atack'][$j]['yron']['2h'] == 1 && $this->stats[$this->uids[$u2]]['this_animal'] == 0) { - $this->users[$this->uids[$u1]]['tactic1'] += 2; - } - } elseif ($at[$a]['atack'][$j][1] != 2) { - if ($at[$a]['atack'][$j][1] == 3) { - //u2 заблокировал удар u1 - if ($this->stats[$this->uids[$u2]]['this_animal'] == 0) { - $this->users[$this->uids[$u2]]['tactic4']++; - } - } elseif ($at[$a]['atack'][$j][1] == 4) { - //u1 пробил блок u2 критом - if (!isset($at[$a]['atack'][$j]['notactic2'])) { - if ($this->stats[$this->uids[$u2]]['this_animal'] == 0) { - $this->users[$this->uids[$u1]]['tactic2']++; - } - } - $this->users[$this->uids[$u2]]['tactic4']++; //тактика за пробив блок - } elseif ($at[$a]['atack'][$j][1] == 5) { - //u1 ударил критическим ударом u2 - if (!isset($at[$a]['atack'][$j]['notactic2'])) { - if ($this->stats[$this->uids[$u2]]['this_animal'] == 0) { - $this->users[$this->uids[$u1]]['tactic2'] += 2; - } - //Двуручка - if ($at[$a]['atack'][$j]['yron']['2h'] == 1 && $this->stats[$this->uids[$u2]]['this_animal'] == 0) { - $this->users[$this->uids[$u1]]['tactic2'] += 1; - } - } - } elseif ($at[$a]['atack'][$j][1] == 6) { - //u2 парировал удар u1 - if (!isset($at[$a]['atack'][$j]['notactic5']) && $this->stats[$this->uids[$u1]]['this_animal'] == 0) { - $this->users[$this->uids[$u2]]['tactic5']++; - } - } elseif ($at[$a]['atack'][$j][1] == 7) { - //u2 блокировал щитом удар u1 //ТУТ ЩИТ - if ($this->stats[$this->uids[$u2]]['this_animal'] == 0) { - $this->users[$this->uids[$u2]]['tactic4']++; - } - } elseif ($at[$a]['atack'][$j][1] == 8) { - //u2 увернулся от удара u1 и нанес по нему контрудар - if ($this->stats[$this->uids[$u1]]['this_animal'] == 0) { - $this->users[$this->uids[$u2]]['tactic3']++; - } - } - } - // КУДА БИЛ , ТИП УДАРА - if (isset($at[$a]['atack'][$j]['yron']) && ( - $at[$a]['atack'][$j][1] == 1 || - $at[$a]['atack'][$j][1] == 4 || - $at[$a]['atack'][$j][1] == 5)) { - // - - if ($this->stats[$this->uids[$u2]]['hpNow'] <= $at[$a]['atack'][$j]['yron']['y']) { - $at[$a]['atack'][$j]['yron']['y'] = $this->stats[$this->uids[$u2]]['hpNow']; - } - if ($this->stats[$this->uids[$u2]]['hpNow'] <= $at[$a]['atack'][$j]['yron']['k']) { - $at[$a]['atack'][$j]['yron']['k'] = $this->stats[$this->uids[$u2]]['hpNow']; - } - - if ($at[$a]['atack'][$j]['yron']['y'] < 0) { - $at[$a]['atack'][$j]['yron']['y'] = 1; - $at[$a]['atack'][$j]['yron']['r'] = -1; - $at[$a]['atack'][$j]['yron']['k'] = 1; - } - if ($this->stats[$this->uids[$u2]]['hpNow'] < 1) { - $at[$a]['atack'][$j]['yron']['y'] = 0; - $at[$a]['atack'][$j]['yron']['r'] = -1; - $at[$a]['atack'][$j]['yron']['k'] = 0; - } - - //Добавляем нанесенный урон и опыт - $this->takeExp($u1, $at[$a]['atack'][$j]['yron']['y'], $u1, $u2); - //Отнимаем НР - $this->stats[$this->uids[$u2]]['hpNow'] -= $at[$a]['atack'][$j]['yron']['y']; - $this->users[$this->uids[$u2]]['last_hp'] = -$at[$a]['atack'][$j]['yron']['y']; - $at[$a]['atack'][$j]['yron']['hp'] = $this->stats[$this->uids[$u2]]['hpNow']; - if ($at[$a]['atack'][$j]['yron']['hp'] < 1) { - $at[$a]['atack'][$j]['yron']['hp'] = 0; - } - $at[$a]['atack'][$j]['yron']['hpAll'] = $this->stats[$this->uids[$u2]]['hpAll']; - if ($at[$a]['atack'][$j]['yron']['hp'] > $at[$a]['atack'][$j]['yron']['hpAll']) { - $at[$a]['atack'][$j]['yron']['hp'] = $at[$a]['atack'][$j]['yron']['hpAll']; - } - //Травмирование - if (rand(0, 100) <= 50) { - if ($at[$a]['atack'][$j][1] == 4 || $at[$a]['atack'][$j][1] == 5) { - if (!isset($at[$a]['atack'][$j]['yron']['travma']) && rand( - 0, - 1000 - ) < 500 && $this->users[$this->uids[$u2]]['level'] > 1 && $this->stats[$this->uids[$u1]] > 1) { - $trvm_chns = floor(rand(0, 200) / 10); - if ($trvm_chns > 3 || $trvm_chns < 1) { - $trvm_chns = 0; - } - $at[$a]['atack'][$j]['yron']['travma'] = [$trvm_chns, 'Обыкновенная травма']; - unset($trvm_chns); - } - } - } - } - $j++; - } - $i++; - } - return $at; - } - - //Добавляем новую статистику игрока - public function addstatuser($id) - { - if ($id > 0) { - $uid = $id; - $id = $this->uids[$uid]; - mysql_query( - 'INSERT INTO `battle_users` - ( `battle`,`uid`,`time_enter`,`login`,`level`,`align`,`clan`,`hpAll`,`hp`,`hpStart`,`team` ) - VALUES - ( - "' . $this->info['id'] . '", - "' . $uid . '", - "' . time() . '","' . $this->users[$id]['login'] . '", - "' . $this->users[$id]['level'] . '", - "' . $this->users[$id]['align'] . '", - "' . $this->users[$id]['clan'] . '", - "' . $this->stats[$id]['hpAll'] . '", - "' . $this->stats[$id]['hp'] . '", - "' . $this->stats[$id]['hpNow'] . '", - "' . $this->users[$id]['team'] . '" - )' - ); - } - } - - //Проверяем приемы - public function priemsRazmen($id, $at) - { - if ($at == 'fast') { - $uid1 = $id[0]; - $uid2 = $id[1]; - } else { - $uid1 = $this->atacks[$id]['uid1']; - $uid2 = $this->atacks[$id]['uid2']; - } - $i = 1; - while ($i <= 2) { - if ($i == 1) { - $a = 1; - $b = 2; - $u1 = ${'uid1'}; - $u2 = ${'uid2'}; - } else { - $a = 2; - $b = 1; - $u1 = ${'uid2'}; - $u2 = ${'uid1'}; - } - - //Получаем приемы и смотрим когда какой действует - $eff = $this->stats[$this->uids[$u1]]['effects']; - $this->stats[$this->uids[$u1]]['u_priem'] = []; - $j = 0; - while ($j <= count($eff)) { - if (isset($eff[$j]) && $eff[$j]['id_eff'] == 22 && $eff[$j]['v1'] == 'priem' && $eff[$j]['v2'] > 0) { - $this->stats[$this->uids[$u1]]['u_priem'][] = [ - $j, - $eff[$j]['v2'], - $this->prm[$eff[$j]['v2']]['act'], - $eff[$j]['id'], - $this->prm[$eff[$j]['v2']]['type_of'], - $this->prm[$eff[$j]['v2']]['moment'], - $this->prm[$eff[$j]['v2']]['moment_end'], - $this->prm[$eff[$j]['v2']]['type_sec'], - ]; - } - $j++; - } - $i++; - } - } - - //Приемы которые используются моментально - public function priemsRazmenMoment($id, $at) - { - $uid1 = $this->atacks[$id]['uid1']; - $uid2 = $this->atacks[$id]['uid2']; - - $i = 1; - while ($i <= 2) { - if ($i == 1) { - $a = 1; - $b = 2; - $u1 = ${'uid1'}; - $u2 = ${'uid2'}; - } else { - $a = 2; - $b = 1; - $u1 = ${'uid2'}; - $u2 = ${'uid1'}; - } - if (!isset($at['p']['p_cast'])) { - $at['p'] = $at; - $at['p']['p_cast'] = true; - } - //Приемы ухода от удара - if (!isset($this->stats[$this->uids[$u2]]['nopryh']) || $this->stats[$this->uids[$u2]]['nopryh'] == 0) { - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][5] == 1) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - $pr_moment = true; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - $this->stats[$this->uids[$u2]]['nopryh']--; - } - } - $j++; - } - } - //Приемы крита - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][5] == 2) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - $pr_moment = true; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - } - } - $j++; - } - //Приемы атаки - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][5] == 3) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - $pr_moment = true; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - if (isset($fx_priem)) { - $at = $fx_priem($id, $at, $u1, $j); - } - unset(${'fx_priem'}); - } - } - $j++; - } - //Приемы защиты - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][5] == 4) { - if ($this->testPriemVarTrueZash( - $i, 1, $this->stats[$this->uids[$u1]]['u_priem'][$j][1], $a, $b, - $u1, $u2 - ) == false) { - } elseif (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - $pr_moment = true; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - } - } - $j++; - } - //Прочие приемы - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][5] == 5) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - $pr_moment = true; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - } - } - $j++; - } - $i++; - } - return $at; - } - - //Приемы которые используются моментально (в конце хода) - public function priemsRazmenMomentEnd($id, $at) - { - $uid1 = $this->atacks[$id]['uid1']; - $uid2 = $this->atacks[$id]['uid2']; - - $i = 1; - while ($i <= 2) { - if ($i == 1) { - $a = 1; - $b = 2; - $u1 = ${'uid1'}; - $u2 = ${'uid2'}; - } else { - $a = 2; - $b = 1; - $u1 = ${'uid2'}; - $u2 = ${'uid1'}; - } - if (!isset($at['p']['p_cast'])) { - $at['p'] = $at; - $at['p']['p_cast'] = true; - } - //Приемы ухода от удара - if (!isset($this->stats[$this->uids[$u2]]['nopryh']) || $this->stats[$this->uids[$u2]]['nopryh'] == 0) { - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][6] == 1) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - $pr_moment = true; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - $this->stats[$this->uids[$u2]]['nopryh']--; - } - } - $j++; - } - } - //Приемы крита - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][6] == 2) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - $pr_moment = true; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - } - } - $j++; - } - //Приемы атаки - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][6] == 3) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - $pr_moment = true; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - if (isset($fx_priem)) { - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - } - } - } - $j++; - } - //Приемы защиты - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][6] == 4) { - if ($this->testPriemVarTrueZash( - $i, 2, $this->stats[$this->uids[$u1]]['u_priem'][$j][1], $a, $b, - $u1, $u2 - ) && file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - $pr_moment = true; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - } - } - $j++; - } - //Прочие приемы - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][6] == 5) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - $pr_moment = true; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - } - } - $j++; - } - $i++; - } - return $at; - } - - //Используем приемы - public function priemsTestRazmen($id, $at) - { - $uid1 = $this->atacks[$id]['uid1']; - $uid2 = $this->atacks[$id]['uid2']; - - $i = 1; - while ($i <= 2) { - if ($i == 1) { - $a = 1; - $b = 2; - $u1 = ${'uid1'}; - $u2 = ${'uid2'}; - } else { - $a = 2; - $b = 1; - $u1 = ${'uid2'}; - $u2 = ${'uid1'}; - } - - if (!isset($at['p']['p_cast'])) { - $at['p'] = $at; - $at['p']['p_cast'] = true; - } - - //ставка - - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][1] == 220 || $this->stats[$this->uids[$u1]]['u_priem'][$j][1] == 237 - || $this->stats[$this->uids[$u1]]['u_priem'][$j][1] == 286 || $this->stats[$this->uids[$u1]]['u_priem'][$j][1] == 287 || $this->stats[$this->uids[$u1]]['u_priem'][$j][1] == 288 - || $this->stats[$this->uids[$u1]]['u_priem'][$j][1] == 213) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - } - } - $j++; - } - - //Приемы ухода от удара - if (!isset($this->stats[$this->uids[$u2]]['nopryh']) || $this->stats[$this->uids[$u2]]['nopryh'] == 0) { - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 1) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - $this->stats[$this->uids[$u2]]['nopryh']--; - } - } - $j++; - } - } - //Приемы крита - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 2) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - } - } - $j++; - } - - //Приемы атаки - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 3) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - if (isset($fx_priem)) { - $at = $fx_priem($id, $at, $u1, $j); - } - unset(${'fx_priem'}); - } - } - $j++; - } - - //Приемы защиты - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 4) { - if (!$this->testPriemVarTrueZash( - $i, 3, $this->stats[$this->uids[$u1]]['u_priem'][$j][1], $a, $b, - $u1, $u2 - )) { - } elseif (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - if (isset($fx_priem)) { - $at = $fx_priem($id, $at, $u1, $j); - } - unset(${'fx_priem'}); - } - } - $j++; - } - - //Прочие приемы - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 5) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - if (isset($fx_priem)) { - $at = $fx_priem($id, $at, $u1, $j); - } - unset(${'fx_priem'}); - } - } - $j++; - } - $i++; - } - - $i = 1; - while ($i <= 2) { - if ($i == 1) { - $a = 1; - $b = 2; - $u1 = ${'uid1'}; - $u2 = ${'uid2'}; - } else { - $a = 2; - $b = 1; - $u1 = ${'uid2'}; - $u2 = ${'uid1'}; - } - - if (!isset($at['p']['p_cast'])) { - $at['p'] = $at; - $at['p']['p_cast'] = true; - } - - //Прочие приемы - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 8) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - } - } - $j++; - } - - //Прочие приемы - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 9) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_used_this = $u1; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - } - } - $j++; - } - $i++; - } - return $at; - } - - //Повторная проверка приемов - public function priemsRestartRazmen($id, $at) - { - if (isset($at['p'])) { - //Проверка - $uid1 = $this->atacks[$id]['uid1']; - $uid2 = $this->atacks[$id]['uid2']; - /* - Если возникнут проблемы с приемами, придется переписать алгоритм, сейчас он выглядит так: - Цикл 1. Проверяем пользователя - Цикл 2 внутри Цикла 1. Проверяем приемы поторые пользователь использовал - Придется сделать: - Цикл 1. Проверяем пользователя - Цикл 2 внутри Цикла 1. Проверяем приемы уворота - Цикл 3. Проверяем пользователя - Цикл 4 внутри Цикла 3. Проверяем приемы крита - и т.д. - */ - $i = 1; - while ($i <= 2) { - if ($i == 1) { - $a = 1; - $b = 2; - $u1 = ${'uid1'}; - $u2 = ${'uid2'}; - } else { - $a = 2; - $b = 1; - $u1 = ${'uid2'}; - $u2 = ${'uid1'}; - } - - if (!isset($at['p']['p_cast'])) { - $at['p'] = $at; - $at['p']['p_cast'] = true; - } - - //Приемы ухода от удара - if (!isset($this->stats[$this->uids[$u2]]['nopryh']) || $this->stats[$this->uids[$u2]]['nopryh'] == 0) { - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 1) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_tested_this = $u1; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - $this->stats[$this->uids[$u2]]['nopryh']--; - } - } - $j++; - } - } - //Приемы крита - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 2) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_tested_this = $u1; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - } - } - $j++; - } - //Приемы защиты - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 4) { - if ($this->testPriemVarTrueZash( - $i, 4, $this->stats[$this->uids[$u1]]['u_priem'][$j][1], $a, $b, - $u1, $u2 - ) == false) { - } elseif (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_tested_this = $u1; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - } - } - $j++; - } - //Приемы атаки - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 3) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_tested_this = $u1; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - } - } - $j++; - } - //Прочие приемы - $j = 0; - while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 5) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' - )) { - $pr_tested_this = $u1; - require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u1, $j); - unset(${'fx_priem'}); - } - } - $j++; - } - //Прочие приемы - $j = 0; - while ($j <= count($this->stats[$this->uids[$u2]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u2]]['u_priem'][$j][4] == 8) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u2]]['u_priem'][$j][1] . '.php' - )) { - $pr_tested_this = $u2; - require('priem/' . $this->stats[$this->uids[$u2]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u2, $j); - unset(${'fx_priem'}); - } - } - $j++; - } - //Прочие приемы - $j = 0; - while ($j <= count($this->stats[$this->uids[$u2]]['u_priem'])) { - if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u2]]['u_priem'][$j][4] == 9) { - if (file_exists( - '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u2]]['u_priem'][$j][1] . '.php' - )) { - $pr_tested_this = $u2; - require('priem/' . $this->stats[$this->uids[$u2]]['u_priem'][$j][1] . '.php'); - $at = $fx_priem($id, $at, $u2, $j); - unset(${'fx_priem'}); - } - } - $j++; - } - - $i++; - } - $at = $at['p']; - unset($at['p']); - } - return $at; - } - - //Проверка действия приема - - /** - * @param $i - * @param $id - * @param $pid - * @param $a - * @param $b - * @param $u1 - * @param $u2 - * @return bool - * @deprecated always returns true - */ - public function testPriemVarTrueZash($i, $id, $pid, $a, $b, $u1, $u2): bool - { - return true; - } - - //Проверка урона приемов - public $um_priem = []; + //Добавляем статистику /** * Трогать очень осторожно. Этот шайтан как-то проверяет приёмы на враге @@ -6995,8 +4466,8 @@ class Battle } if ($this->stats[$this->uids[$u1]]['u_priem'][$j][1] == 180) { // Переохлаждение (снижает урон на 10%). Пан или пропал. - $x = mysql_fetch_row(mysql_query('select x from eff_users where v2 = 180 and uid = ' . $u1)); - $yron = 0.1 * $x[0]; + $x = Db::getValue('select x from eff_users where v2 = 180 and uid = ?', [$u1]); + $yron = 0.1 * $x; } $j++; } @@ -7040,7 +4511,6 @@ class Battle return $yron; } - //Опыт + набитый урон за удар приемом\магией public function priemYronSave($u1, $u2, $yron, $type) { //$type 0 - урон , 1 - хил @@ -7116,12 +4586,661 @@ class Battle ); } - //Наносим удар между игроками - public $restart_stats_data = []; + //Добавляем статистику ударов - public $import_atack = []; - public $contr = []; - public $import_user = 0; + public function testUserInfoBattle($uid) + { + global $u; + if (!isset($this->uids[$uid])) { + //Заносим данные об игроке снова (видимо он погиб и его стерло с инфо) + if (!isset($this->uids[$uid])) { + $this->uids[$uid] = count($this->users); + } + $this->users[$this->uids[$uid]] = mysql_fetch_array( + mysql_query( + 'SELECT + + `u`.`id`,`u`.`login`,`u`.`login2`,`u`.`online`,`u`.`admin`,`u`.`city`,`u`.`cityreg`,`u`.`align`,`u`.`align_lvl`,`u`.`align_exp`,`u`.`clan`, + `u`.`level`,`u`.`money`,`u`.`money3`,`u`.`money2`,`u`.`money4`,`u`.`battle`,`u`.`sex`,`u`.`obraz`,`u`.`win`,`u`.`win_t`, + `u`.`lose`,`u`.`lose_t`,`u`.`nich`,`u`.`timeMain`,`u`.`invis`,`u`.`bot_id`,`u`.`animal`,`u`.`type_pers`, + `u`.`notrhod`,`u`.`bot_room`,`u`.`inUser`,`u`.`inTurnir`,`u`.`inTurnirnew`,`u`.`stopexp`,`u`.`real`, + + `st`.* + + FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON (`u`.`id` = `st`.`id`) WHERE `u`.`id` = "' . $uid . '" LIMIT 1' + ) + ); + $this->stats[$this->uids[$uid]] = $u->getStats($this->users[$this->uids[$uid]], 0, 0, false, false, true); + } + } + + //Добавляем размены в лог + + public function hpSee($now, $all, $type = 1): string + { + $r = '[' . $now . '/' . $all . ']'; + if ($all > 10000) { + $type = 2; + } + if ($type == 2) { + $p1 = floor($now / $all * 100); + $r = '[' . $p1 . '/100%]'; + } + return $r; + } + + //Добавляем в лог действия приема + + public function lookLog(): string + { + global $c, $u, $log_text; + $hodID = mysql_fetch_array( + mysql_query( + 'SELECT `id`,`id_hod` FROM `battle_logs` WHERE `battle` = "' . $this->info['id'] . '" ORDER BY `time` ASC LIMIT 1' + ) + ); + if ($hodID['id_hod'] <= 1) { + $u->info['alog'] = 0; + } + if (isset($hodID['id']) && $this->info['team_win'] != -1) { + $hodID = mysql_fetch_array( + mysql_query( + 'SELECT `id` FROM `battle_logs_save` WHERE `battle` = "' . $this->info['id'] . '" ORDER BY `time` ASC LIMIT 1' + ) + ); + } + $hodID = $hodID['id'] ?? 0; + + $updt = 0; + $js = ''; + $pll = 0; + if ($_POST['idlog'] < 1) { + $_POST['idlog'] = 0; + } + $talog = mysql_fetch_array( + mysql_query('SELECT `alog` FROM `stats` WHERE `id` = "' . $u->info['id'] . '" LIMIT 1') + ); + $sp = mysql_query( + 'SELECT + `id`,`type`,`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zona2`,`zonb1`,`zonb2` + FROM `battle_logs` + WHERE `battle` = "' . $this->info['id'] . '" AND `id_hod` >= ' . $talog['alog'] . ' ORDER BY `id` DESC' + ); + if (isset($sp) && $this->info['team_win'] != -1) { + $sp = mysql_query( + 'SELECT + `id`,`type`,`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zona2`,`zonb1`,`zonb2` + FROM `battle_logs_save` + WHERE `battle` = "' . $this->info['id'] . '" AND `id_hod` >= ' . $talog['alog'] . ' ORDER BY `id` DESC' + ); + } + $jin = 0; + $forYou2 = 0; + if (is_array($sp)) { + while ($pl = mysql_fetch_array($sp)) { + if ($jin == 0) { + $u->info['alog'] = $pl['id_hod']; + } + $jin++; + + $rt = $pl['text']; + $pl['vars'] = str_replace('^^^^', 'rvnO', $pl['vars']); + $rt = str_replace( + '{tm1}', '' . date('H:i', $pl['time']) . '', + $rt + ); + $rt = str_replace( + '{tm2}', '' . date('H:i', $pl['time']) . '', + $rt + ); + $rt = str_replace( + '{tm3}', + '' . date('d.m.Y H:i', $pl['time']) . '', $rt + ); + $rt = str_replace( + '{tm4}', + '' . date('d.m.Y H:i', $pl['time']) . '', $rt + ); + $pl['text'] = $rt; + + unset($rt); + if ($pll < $pl['id']) { + $pll = $pl['id']; + } + $js = 'add_log(' . $pl['id'] . ',' . $forYou2 . ',"' . $pl['text'] . '",' . $pl['id_hod'] . ',0,0,"' . str_replace( + '"', + '"', $pl['vars'] + ) . '");' . $js; + } + } + mysql_query( + 'UPDATE `stats` SET `alog`="' . $u->info['alog'] . '" WHERE `id` ="' . $u->info['id'] . '" LIMIT 1' + ); + $js .= 'id_log=' . $pll . ';'; + return $js; + } + + //Добавляем в лог действия приема (без атаки) + + public function lookmLog(): string + { + global $c, $u, $log_text; + $js = ''; + $pll = 0; + + if ($this->info['type'] != 9) { + $hodID = mysql_fetch_array( + mysql_query( + 'SELECT `id`,`id_hod` FROM `battle_logs` WHERE `battle` = "' . $this->info['id'] . '" ORDER BY `time` ASC LIMIT 1' + ) + ); + if ($hodID['id_hod'] <= 1) { + $u->info['mlog'] = 0; + } + if (isset($hodID['id']) && $this->info['team_win'] != -1) { + $hodID = mysql_fetch_array( + mysql_query( + 'SELECT `id` FROM `battle_logs_save` WHERE `battle` = "' . $this->info['id'] . '" ORDER BY `time` ASC LIMIT 1' + ) + ); + } + $hodID = $hodID['id'] ?? 0; + $tmlog = mysql_fetch_array( + mysql_query('SELECT `mlog` FROM `stats` WHERE `id` = "' . $u->info['id'] . '" LIMIT 1') + ); + $spm = mysql_query( + 'SELECT + `id`,`type`,`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zona2`,`zonb1`,`zonb2` + FROM `battle_logs` + WHERE `battle` = "' . $this->info['id'] . '" AND `id_hod` >= ' . $tmlog['mlog'] . ' AND `vars` LIKE "%' . $u->info['login'] . '%" ORDER BY `id` DESC' + ); + + if (isset($spm) && $this->info['team_win'] != -1) { + $spm = mysql_query( + 'SELECT + `id`,`type`,`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zona2`,`zonb1`,`zonb2` + FROM `battle_logs_save` + WHERE `battle` = "' . $this->info['id'] . '" AND `id_hod` >= ' . $tmlog['mlog'] . ' AND `vars` LIKE "%' . $u->info['login'] . '%" ORDER BY `id` DESC' + ); + } + + $jin = 0; + $forYou2 = 0; + if (is_array($spm)) { + while ($plm = mysql_fetch_array($spm)) { + if ($jin == 0) { + $u->info['mlog'] = $plm['id_hod']; + } + $jin++; + $rt = $plm['text']; + $plm['vars'] = str_replace('^^^^', 'rvnO', $plm['vars']); + $rt = str_replace( + '{tm1}', '' . date('H:i', $plm['time']) . '', $rt + ); + $rt = str_replace( + '{tm2}', '' . date('H:i', $plm['time']) . '', $rt + ); + $rt = str_replace( + '{tm3}', '' . date('d.m.Y H:i', $plm['time']) . '', + $rt + ); + $rt = str_replace( + '{tm4}', '' . date('d.m.Y H:i', $plm['time']) . '', + $rt + ); + $plm['text'] = $rt; + unset($rt); + if ($pll < $plm['id']) { + $pll = $plm['id']; + } + $js = 'add_mlog(' . $plm['id'] . ',' . $forYou2 . ',"' . $plm['text'] . '",' . $plm['id_hod'] . ',0,0,"' . str_replace( + '"', + '"', $plm['vars'] + ) . '");' . $js; + } + } + $js .= 'id_mlog=' . $pll . ';'; + mysql_query( + 'UPDATE `stats` SET `mlog`="' . $u->info['mlog'] . '" WHERE `id` ="' . $u->info['id'] . '" LIMIT 1' + ); + } + return $js; + } + + //Считаем контру + + public function weaponAt($item, $st, $x): int + { + $tp = 0; + $tp20 = 0; + if (isset($item['id'])) { + $itm = \Core\ConversionHelper::dataStringToArray($item['data']); + //начинаем расчет урона + $min = $itm['sv_yron_min'] + $itm['yron_min'] + $st['minAtack']; + $max = $itm['sv_yron_max'] + $itm['yron_max'] + $st['maxAtack']; + if ($x != 0) { + /* + Колющий - 60% Силы и 40% Ловкости. + Рубящий - 70% Силы 20% Ловкости и 20% Интуиции. + Дробящий - 100% Силы. + Режущий - 60% Силы и 40% Интуиции. + */ + //Тип урона: 0 - нет урона, 1 - колющий, 2 - рубящий, 3 - дробящий, 4 - режущий, 5 - огонь, 6 - воздух, 7 - вода, 8 - земля, 9 - свет, 10 - тьма, 11 - серая + if ($x == 1) { + //колющий + $wst = $st['s2'] * 1; + $min += 5 + (ceil($wst * 1.4) / 1.25) + $st['minAtack']; + $max += 7 + (ceil(0.4 + $min / 0.9) / 1.25) + $st['maxAtack']; + $tp20 = 1; + } elseif ($x == 2) { + //рубящий + $wst = $st['s1'] * 0.75; + $min += 5 + (ceil($wst * 1.4) / 1) + $st['minAtack']; + $max += 7 + (ceil(0.4 + $min / 0.9) / 1.25) + $st['maxAtack']; + $tp20 = 2; + } elseif ($x == 3) { + //дробящий + $wst = $st['s4'] * 1.5; + $min += 5 + (ceil($wst * 1.4) / 1.25) + $st['minAtack']; + $max += 7 + (ceil(0.4 + $min / 0.9) / 1.25) + $st['maxAtack']; + $tp20 = 3; + } elseif ($x == 4) { + //режущий + $wst = $st['s3'] * 1; + $min += 5 + (ceil($wst * 1.4) / 1.25) + $st['minAtack']; + $max += 7 + (ceil(0.4 + $min / 0.9) / 1.25) + $st['maxAtack']; + $tp20 = 4; + } elseif ($x >= 5 && $x <= 22) { + //урон магии и магии стихий + $wst = $st['s1'] * 0.01 + $st['s2'] * 0.01 + $st['s3'] * 0.01 + $st['s5'] * 0.06; + $min += 3 + (ceil($wst * 1.4) / 2.25) + $st['minAtack']; + $max += 5 + (ceil(0.4 + $min / 0.9) / 2.25) + $st['maxAtack']; + $tp20 = 5; + } + + $wst = ($st['s1'] * 0.02 + $st['s2'] * 0.02 + $st['s3'] * 0.05); + $min1 = -2 + ceil($wst * 1.4) / 1.25; + $max1 = 4 + ceil(0.4 + $min1 / 0.9) / 1.25; + + $min = round(($min + $min1)); + } + $tp = rand(($min + $max) / 3.5, (($min + $max) / 3.5 + (($min + $max) / 3.5) / 100 * 7)); + } + return $tp; + } + + + //Расчитываем статы для конкретной зоны атаки + + public function weaponAt22($item, $st): array + { + $min = 0; + $max = 0; + if (isset($item['id'])) { + $itm = \Core\ConversionHelper::dataStringToArray($item['data']); + //начинаем расчет урона + $min = $itm['sv_yron_min'] + $itm['yron_min'] + $st['minAtack']; + $max = $itm['sv_yron_max'] + $itm['yron_max'] + $st['maxAtack']; + } + return [$min, $max]; + } + + //Расчитываем ед. урона + + public function form_mf($u, $au): float + { + $v = $u * 5.1 - $au * 5.1; + if ($v < 0) { + $v = 0; + } + $r = (1 - (pow(99 / 100, (($v) / 100)))) * 100; + return round($r); + } + + //Считаем урон + + public function autoSmena() + { + global $u; + $ms = []; + $ms_all = []; + $ms_ansf = []; + $i = 0; + $j = 0; + $z = 0; + while ($i < count($this->users)) { + if (isset($this->users[$i]) && $this->users[$i]['id'] != $u->info['id'] && $this->users[$i]['team'] != $u->info['team'] && $this->stats[$i]['hpNow'] > 0 && -($u->info['enemy']) != $this->users[$i]['id']) { + if (!isset($this->ga[$u->info['id']][$this->users[$i]['id']])) { + $ms[$j] = $this->users[$i]['id']; + $j++; + } + if (!isset($this->uids[(-($u->info['enemy']))])) { + $ms_all[] = $this->users[$i]['id']; + } + if (isset($this->ga[$this->users[$i]['id']][$u->info['id']])) { + $ms_ansf[$z] = $this->users[$i]['id']; + $z++; + } + } + $i++; + } + $msh = []; + if ($j == 0 && $z == 0) { + $enemydie = 0; + if (isset($this->stats[$this->uids[$u->info['enemy']]])) { + $u->info['enemy'] = 0; + $enemydie = 1; + } + if ((!isset($this->uids[(-($u->info['enemy']))]) || $this->stats[$this->uids[(-($u->info['enemy']))]]['hpNow'] < 1) && ($u->info['enemy'] < 0 || $enemydie == 1)) { + $i = 0; + $j = 0; + while ($i < count($this->users)) { + if (isset($this->users[$i]) && $this->users[$i]['id'] != $u->info['id'] && $this->users[$i]['team'] != $u->info['team'] && $this->stats[$i]['hpNow'] >= 1 && -($u->info['enemy']) != $this->users[$i]['id']) { + $ms[$j] = $this->users[$i]['id']; + $msh[$ms[$j]] = true; + $j++; + } + $i++; + } + } + } + + $ms = $ms[rand(0, $j - 1)]; + $ms_ansf = $ms_ansf[rand(0, $z - 1)]; + if ($z > 0) { + $this->smena($ms_ansf, true); + } elseif ($j > 0) { + if (isset($msh[$ms])) { + $this->smena($ms, true, true); + } else { + $this->smena($ms, true); + } + } else { + if ($u->info['enemy'] < 0) { + $smnr5 = $this->smena(-($u->info['enemy']), true); + unset($smnr5); + } + } + } + + //Обновление здоровья + + public function smena($uid, $auto = false, $lastdie = false) + { + global $u; + if ((!$auto && $u->info['smena'] > 0) || $auto) { + if ($this->stats[$this->uids[$u->info['id']]]['hpNow'] >= 1) { + if (isset($this->uids[$uid]) && $uid != $u->info['id'] && $this->users[$this->uids[$uid]]['team'] != $this->users[$this->uids[$u->info['id']]]['team']) { + if (!isset($this->ga[$u->info['id']][$uid]) || $lastdie) { + if (ceil($this->stats[$this->uids[$uid]]['hpNow']) >= 1) { + //меняем противника + if (!$auto) { + $u->info['smena']--; + } + $upd = mysql_query( + 'UPDATE `stats` SET `enemy` = "' . $uid . '",`smena` = "' . $u->info['smena'] . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1' + ); + $u->info['enemy'] = $uid; + $this->users[$this->uids[$uid]]['smena'] = $u->info['smena']; + $this->users[$this->uids[$u->info['id']]]['enemy'] = $uid; + return 1; + } else { + return 'Нельзя сменить, противник уже мертв'; + } + } else { + return 'Нельзя сменить на выбранную цель!'; + } + } else { + return 'Нельзя сменить на выбранную цель []'; + } + } else { + return 'Для вас поединок закончен, ожидайте пока завершат другие...'; + } + } else { + return 'У вас закончились смены противника'; + } + } + + //Добавляем новую статистику игрока + + public function testActions() + { + //проверяем удары + $m = mysql_query('SELECT * FROM `battle_act` WHERE `battle` = "' . $this->info['id'] . '" ORDER BY `id` ASC'); + $i = 0; + $botA = []; + $botR = []; + while ($pl = mysql_fetch_array($m)) { + $pluids = mysql_fetch_array( + mysql_query( + 'SELECT `hpNow` FROM `stats` WHERE (`id` = "' . $pl['uid1'] . '" AND `hpNow` <= 0) OR (`id` = "' . $pl['uid2'] . '" AND `hpNow` <= 0) LIMIT 1' + ) + ); + $pltest = mysql_fetch_array( + mysql_query('SELECT * FROM `battle_act` WHERE `id` = "' . $pl['id'] . '" LIMIT 1') + ); + if (isset($pltest['id'])) { + if (isset($pluids['hpNow'])) { + mysql_query('DELETE FROM `battle_act` WHERE `id` = "' . $pl['id'] . '" LIMIT 1'); + } elseif ($pl['time'] + $this->info['timeout'] > time()) { + //удар не пропущен по тайму, просто заносим данные + $this->atacks[$pl['id']] = $pl; + $this->ga[$pl['uid1']][$pl['uid2']] = $pl['id']; + $this->ag[$pl['uid2']][$pl['uid1']] = $pl['id']; + if (isset($this->iBots[$pl['uid1']])) { + //ударил бот и нет ответа + $botA[$pl['uid1']] = $pl['id']; + } elseif (isset($this->iBots[$pl['uid2']])) { + //ударили бота и он не ответил + $botR[$pl['uid2']] = $pl['id']; + if ($this->users[$this->uids[$pl['uid2']]]['timeGo'] < time()) { + $this->botAtack($pl['uid1'], $pl, 2); + } + } + } else { + //пропуск по тайму + $pl['time'] = time(); + if ($pl['a1'] == 0 && $pl['a2'] == 0) { + //игрок 1 пропустил по тайму + $pl['out1'] = time(); + $pl['tout1'] = 1; + //игрок 2 пропустил по тайму + $pl['out2'] = time(); + $pl['tout2'] = 1; + } elseif ($pl['a1'] == 0) { + //игрок 1 пропустил по тайму + $pl['out1'] = time(); + $pl['tout1'] = 1; + } elseif ($pl['a2'] == 0) { + //игрок 2 пропустил по тайму + $pl['out2'] = time(); + $pl['tout2'] = 1; + } + //наносим удар по пропуску + $this->atacks[$pl['id']] = $pl; + $this->startAtack($pl['id']); + mysql_query('DELETE FROM `battle_act` WHERE `id` = "' . $pl['id'] . '"'); + } + } + } + //тест удара + if ($this->uAtc['id'] > 0 && $this->na == 1) { + if ($pl['out1'] == 0 && $pl['out2'] == 0) { + //Может разменяться только тот кто бил + if ($pl['uid1'] == $u->info['id'] || $pl['uid2'] == $u->info['id']) { + $this->addNewAtack(); + } + } else { + $this->addNewAtack(); + } + } + //тест, бот делает удары + while ($i < count($this->bots)) { + $bot = $this->bots[$i]; + if (isset($bot) && $this->stats[$this->uids[$bot]]['hpNow'] >= 1 && $this->stats[$this->uids[$bot]]['pass'] != 'saintlucia') { //Тут проверка на бота saintlucia + $j = 0; + while ($j < count($this->users)) { + if ($this->info['razdel'] == 0) { + $tnbot = time() + rand(1, 1); + } else { + $tnbot = time() + rand(1, 2); + } + if ($this->users[$j]['timeGo'] < time() && $this->users[$this->uids[$bot]]['timeGo'] < time()) { + if ($this->users[$j]['hpNow'] >= 1 && $this->users[$this->uids[$bot]]['hpNow'] >= 1 && $this->users[$this->uids[$bot]]['team'] != $this->users[$j]['team']) { + if (isset($this->users[$j]) && $this->stats[$j]['hpNow'] >= 1 && $this->stats[$this->uids[$bot]]['hpNow'] >= 1 && !isset($this->ga[$bot][$this->users[$j]['id']]) && !isset($this->ag[$bot][$this->users[$j]['id']]) && $this->users[$j]['id'] != $bot && $this->users[$j]['team'] != $this->users[$this->uids[$bot]]['team']) { + if ($this->users[$j]['timeGo'] < time() && $this->users[$this->uids[$bot]]['timeGo'] < time()) { + $this->botAtack($this->users[$j]['id'], $bot, 1); + mysql_query( + 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' + ); + } + } elseif (isset($this->users[$i]) && $this->users[$i]['bot'] > 0 && $this->stats[$i]['hpNow'] >= 1 && $this->stats[$this->uids[$bot]]['hpNow'] >= 1 && $this->users[$i]['id'] != $bot && $this->users[$i]['team'] != $this->users[$this->uids[$bot]]['team']) { + if ($this->users[$j]['timeGo'] < time() && $this->users[$this->uids[$bot]]['timeGo'] < time() && $this->botAct($bot)) { + if (!isset($this->ga[$bot][$this->users[$i]['id']]) && $this->users[$this->uids[$bot]]['timeGo'] < time() && !isset($this->ag[$bot][$this->users[$i]['id']])) { + $this->botAtack($this->users[$i]['id'], $bot, 1); + mysql_query( + 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' + ); + } elseif (!isset($this->ag[$bot][$this->users[$i]['id']]) && isset($this->ga[$bot][$this->users[$i]['id']]) && $this->users[$this->uids[$bot]]['timeGo'] < time()) { + $this->botAtack($bot, $this->users[$i]['id'], 1); + mysql_query( + 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' + ); + } + } + } else { + //Удары между ботами + if ($this->users[$j]['timeGo'] < time() && $this->users[$this->uids[$bot]]['timeGo'] < time() && $this->users[$j]['hpNow'] >= 1 && $this->users[$this->uids[$bot]]['hpNow'] >= 1) { + $this->atacks[$this->ga[$bot][$this->users[$j]['id']]]['a1'] = rand( + 1, 5 + ) . '' . rand( + 1, + 5 + ) . rand(1, 5) . rand(1, 5) . rand(1, 5); + $this->atacks[$this->ga[$bot][$this->users[$j]['id']]]['b1'] = rand(1, 5); + $this->atacks[$this->ga[$bot][$this->users[$j]['id']]]['a2'] = rand( + 1, 5 + ) . '' . rand( + 1, + 5 + ) . rand(1, 5) . rand(1, 5) . rand(1, 5); + $this->atacks[$this->ga[$bot][$this->users[$j]['id']]]['b2'] = rand(1, 5); + $this->atacks[$this->ag[$bot][$this->users[$j]['id']]]['a1'] = rand( + 1, 5 + ) . '' . rand( + 1, + 5 + ) . rand(1, 5) . rand(1, 5) . rand(1, 5); + $this->atacks[$this->ag[$bot][$this->users[$j]['id']]]['b1'] = rand(1, 5); + $this->atacks[$this->ag[$bot][$this->users[$j]['id']]]['a2'] = rand( + 1, 5 + ) . '' . rand( + 1, + 5 + ) . rand(1, 5) . rand(1, 5) . rand(1, 5); + $this->atacks[$this->ag[$bot][$this->users[$j]['id']]]['b2'] = rand(1, 5); + if (isset($this->ga[$bot][$this->users[$j]['id']]) && $this->users[$j]['bot'] > 0) { + if ($this->users[$j]['timeGo'] < time() && $this->users[$this->uids[$bot]]['timeGo'] < time()) { + $tnbot = time() + rand(3, 7); + if ($this->info['type'] == 329) { // тестовый бой + $tnbot = time() - 1; + } + $this->startAtack($this->ga[$bot][$this->users[$j]['id']]); + $this->users[$this->uids[$bot]]['timeGo'] = $tnbot; + mysql_query( + 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' + ); + } + } elseif (isset($this->ag[$bot][$this->users[$j]['id']]) && $this->users[$j]['bot'] > 0) { + if ($this->users[$this->uids[$bot]]['timeGo'] < time() && $this->users[$j]['timeGo'] < time()) { + $this->startAtack($this->ag[$bot][$this->users[$j]['id']]); + $tnbot = time() + rand(3, 7); + if ($this->info['type'] == 329) { // тестовый бой + $tnbot = time() - 1; + } + $this->users[$this->uids[$bot]]['timeGo'] = $tnbot; + mysql_query( + 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' + ); + } + } + } + } + } else { + } + } + $j++; + } + } + $i++; + } + } + + //Проверяем приемы + + public function botAtack($uid, $pl, $tp) + { + $test_atack = mysql_fetch_array( + mysql_query( + 'SELECT `id` FROM `battle_act` WHERE `battle` = "' . $this->info['id'] . '" AND (( + `uid1` = "' . $pl . '" AND `uid2` = "' . $uid . '" + ) OR ( + `uid2` = "' . $pl . '" AND `uid1` = "' . $uid . '" + )) LIMIT 1' + ) + ); + + if ($tp == 1 && !isset($test_atack['id'])) { + $test_uid = mysql_fetch_array( + mysql_query('SELECT * FROM `stats` WHERE `id` = "' . $uid . '" AND `hpNow` >= 1 LIMIT 1') + ); + $test_pl = mysql_fetch_array( + mysql_query('SELECT * FROM `stats` WHERE `id` = "' . $pl . '" AND `hpNow` >= 1 LIMIT 1') + ); + if (isset($test_uid['id']) && isset($test_pl['id']) && $test_uid['id'] != $test_pl['id']) { + $a = rand(1, 5) . '' . rand(1, 5) . '' . rand(1, 5) . '' . rand(1, 5) . '' . rand(1, 5); + $b = rand(1, 5); + $d = mysql_query( + 'INSERT INTO `battle_act` (`battle`,`time`,`uid1`,`uid2`,`a1`,`b1`) VALUES ("' . $this->info['id'] . '","' . time() . '","' . $pl . '","' . $uid . '","' . $a . '","' . $b . '")' + ); + } + } elseif ($tp == 2) { + //бот отвечает на удар + $test_uid = mysql_fetch_array( + mysql_query('SELECT * FROM `stats` WHERE `id` = "' . $uid . '" AND `hpNow` >= 1 LIMIT 1') + ); + $test_pl = mysql_fetch_array( + mysql_query('SELECT * FROM `stats` WHERE `id` = "' . $pl['uid2'] . '" AND `hpNow` >= 1 LIMIT 1') + ); + if (isset($test_uid['id']) && isset($test_pl['id']) && $test_uid['id'] != $test_pl['id']) { + $bot = $this->users[$this->uids[$pl['uid2']]]; + $na = ['id' => 0, 'a' => [1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0], 'b' => 0]; + $a222 = rand(1, 5) . '_' . rand(1, 5) . '_' . rand(1, 5) . '_' . rand(1, 5) . '_' . rand(1, 5); + $a = explode('_', $a222); + $i = 1; + $na['id'] = time(); + while ($i <= 5) { + if (isset($a[$i - 1])) { + $a[$i - 1] = intval(round($a[$i - 1])); + if ($a[$i - 1] >= 1 && $a[$i - 1] <= 5) { + $na['a'][$i] = $a[$i - 1]; + } else { + $na['a'][$i] = 0; + } + } + $i++; + } + $na['b'] = rand(1, 5); + //Проводим удар + + $this->atacks[$pl['id']]['a2'] = $a222; + $this->atacks[$pl['id']]['b2'] = $na['b']; + $this->startAtack($pl['id']); + } + } + } + + //Приемы которые используются моментально public function startAtack($id) { @@ -7682,391 +5801,1175 @@ class Battle } } - //Сохранение данные - public function save_stats($uid) + //Приемы которые используются моментально (в конце хода) + + public function testZonb($uid, $uid2) { - mysql_query( - 'UPDATE `stats` SET - - `hpNow` = "' . $this->stats[$this->uids[$uid]]['hpNow'] . '", - `mpNow` = "' . $this->stats[$this->uids[$uid]]['mpNow'] . '", - `tactic1` = "' . $this->users[$this->uids[$uid]]['tactic1'] . '", - `tactic2` = "' . $this->users[$this->uids[$uid]]['tactic2'] . '", - `tactic3` = "' . $this->users[$this->uids[$uid]]['tactic3'] . '", - `tactic4` = "' . $this->users[$this->uids[$uid]]['tactic4'] . '", - `tactic5` = "' . $this->users[$this->uids[$uid]]['tactic5'] . '", - `tactic6` = "' . $this->users[$this->uids[$uid]]['tactic6'] . '", - `tactic7` = "' . $this->users[$this->uids[$uid]]['tactic7'] . '", - - `enemy` = "' . $this->users[$this->uids[$uid]]['enemy'] . '", - `battle_yron` = "' . $this->users[$this->uids[$uid]]['battle_yron'] . '", - `last_hp` = "' . $this->users[$this->uids[$uid]]['last_hp'] . '", - `battle_exp` = "' . $this->users[$this->uids[$uid]]['battle_exp'] . '", - `priems_z` = "' . $this->users[$this->uids[$uid]]['priems_z'] . '" - - WHERE `id` = "' . $uid . '" LIMIT 1' - ); + $zba = []; + + $zba[1] = $this->stats[$this->uids[$uid]]['zonb']; + $zba[2] = $this->stats[$this->uids[$uid2]]['zonb']; + + if ($this->stnZb[$uid] == 0) { + $zba[1] = $this->stats[$this->uids[$uid]]['zonb']; + $this->stnZb[$uid] = $zba[1]; + } else { + $zba[1] = $this->stnZb[$uid]; + } + + if ($this->stnZb[$uid2] == 0) { + $zba[2] = $this->stats[$this->uids[$uid2]]['zonb']; + $this->stnZb[$uid] = $zba[2]; + } else { + $zba[2] = $this->stnZb[$uid2]; + } + + if ($zba[1] > 3) { + $zba[1] = 3; + } + if ($zba[2] > 3) { + $zba[2] = 3; + } + + //Блоки игрока 1 + if ( + ( + $this->stats[$this->uids[$uid2]]['weapon1'] == 1 || + $this->stats[$this->uids[$uid2]]['weapon2'] == 1 + ) && + $this->stats[$this->uids[$uid]]['weapon1'] != 1 && + $this->stats[$this->uids[$uid]]['weapon2'] != 1 + ) { + $zba[1] -= 1; + } + + //Блоки игрока 2 + if ( + ( + $this->stats[$this->uids[$uid]]['weapon1'] == 1 || + $this->stats[$this->uids[$uid]]['weapon2'] == 1 + ) && + $this->stats[$this->uids[$uid2]]['weapon1'] != 1 && + $this->stats[$this->uids[$uid2]]['weapon2'] != 1 + ) { + $zba[2] -= 1; + } + + if ($zba[1] < 1) { + $zba[1] = 1; + } + if ($zba[2] < 1) { + $zba[2] = 1; + } + + $this->stats[$this->uids[$uid]]['zonb'] = $zba[1]; + $this->stats[$this->uids[$uid2]]['zonb'] = $zba[2]; + if ( + $this->stats[$this->uids[$uid]]['min_zonb'] > 0 && + $this->stats[$this->uids[$uid]]['zonb'] < $this->stats[$this->uids[$uid]]['min_zonb'] + ) { + $this->stats[$this->uids[$uid]]['zonb'] = $this->stats[$this->uids[$uid]]['min_zonb']; + } + if ( + $this->stats[$this->uids[$uid2]]['min_zonb'] > 0 && + $this->stats[$this->uids[$uid2]]['zonb'] < $this->stats[$this->uids[$uid2]]['min_zonb'] + ) { + $this->stats[$this->uids[$uid2]]['zonb'] = $this->stats[$this->uids[$uid2]]['min_zonb']; + } } - //Отображение НР - public function hpSee($now, $all, $type = 1): string + //Используем приемы + + public function magicItems($uid1, $uid2, $end) { - $r = '[' . $now . '/' . $all . ']'; - if ($all > 10000) { - $type = 2; + global $u, $priem, $c, $code; + if (!isset($this->stats[$this->uids[$uid1]])) { + return; } - if ($type == 2) { - $p1 = floor($now / $all * 100); - $r = '[' . $p1 . '/100%]'; + $i = 0; + while ($i < count($this->stats[$this->uids[$uid1]]['items'])) { + $itm = $this->stats[$this->uids[$uid1]]['items'][$i]; + if (isset($itm['id'])) { + $e = ConversionHelper::dataStringToArray($itm['data']); + if (isset($e['bm_a1'])) { + if ($end > 0) { + if (file_exists('../../_incl_data/class/priems/' . $e['bm_a1'] . '.end.php')) { + require('../../_incl_data/class/priems/' . $e['bm_a1'] . '.end.php'); + } + } else { + if (file_exists('../../_incl_data/class/priems/' . $e['bm_a1'] . '.php')) { + require('../../_incl_data/class/priems/' . $e['bm_a1'] . '.php'); + } + } + } + } + $i++; + } + unset($itm); + } + + //Повторная проверка приемов + + public function priemsRazmen($id, $at) + { + if ($at == 'fast') { + $uid1 = $id[0]; + $uid2 = $id[1]; + } else { + $uid1 = $this->atacks[$id]['uid1']; + $uid2 = $this->atacks[$id]['uid2']; + } + $i = 1; + while ($i <= 2) { + if ($i == 1) { + $a = 1; + $b = 2; + $u1 = ${'uid1'}; + $u2 = ${'uid2'}; + } else { + $a = 2; + $b = 1; + $u1 = ${'uid2'}; + $u2 = ${'uid1'}; + } + + //Получаем приемы и смотрим когда какой действует + $eff = $this->stats[$this->uids[$u1]]['effects']; + $this->stats[$this->uids[$u1]]['u_priem'] = []; + $j = 0; + while ($j <= count($eff)) { + if (isset($eff[$j]) && $eff[$j]['id_eff'] == 22 && $eff[$j]['v1'] == 'priem' && $eff[$j]['v2'] > 0) { + $this->stats[$this->uids[$u1]]['u_priem'][] = [ + $j, + $eff[$j]['v2'], + $this->prm[$eff[$j]['v2']]['act'], + $eff[$j]['id'], + $this->prm[$eff[$j]['v2']]['type_of'], + $this->prm[$eff[$j]['v2']]['moment'], + $this->prm[$eff[$j]['v2']]['moment_end'], + $this->prm[$eff[$j]['v2']]['type_sec'], + ]; + } + $j++; + } + $i++; + } + } + + //Проверка действия приема + + public function priemsRazmenMoment($id, $at) + { + $uid1 = $this->atacks[$id]['uid1']; + $uid2 = $this->atacks[$id]['uid2']; + + $i = 1; + while ($i <= 2) { + if ($i == 1) { + $a = 1; + $b = 2; + $u1 = ${'uid1'}; + $u2 = ${'uid2'}; + } else { + $a = 2; + $b = 1; + $u1 = ${'uid2'}; + $u2 = ${'uid1'}; + } + if (!isset($at['p']['p_cast'])) { + $at['p'] = $at; + $at['p']['p_cast'] = true; + } + //Приемы ухода от удара + if (!isset($this->stats[$this->uids[$u2]]['nopryh']) || $this->stats[$this->uids[$u2]]['nopryh'] == 0) { + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][5] == 1) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + $pr_moment = true; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + $this->stats[$this->uids[$u2]]['nopryh']--; + } + } + $j++; + } + } + //Приемы крита + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][5] == 2) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + $pr_moment = true; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + } + } + $j++; + } + //Приемы атаки + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][5] == 3) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + $pr_moment = true; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + if (isset($fx_priem)) { + $at = $fx_priem($id, $at, $u1, $j); + } + unset(${'fx_priem'}); + } + } + $j++; + } + //Приемы защиты + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][5] == 4) { + if ($this->testPriemVarTrueZash( + $i, 1, $this->stats[$this->uids[$u1]]['u_priem'][$j][1], $a, $b, + $u1, $u2 + ) == false) { + } elseif (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + $pr_moment = true; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + } + } + $j++; + } + //Прочие приемы + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][5] == 5) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + $pr_moment = true; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + } + } + $j++; + } + $i++; + } + return $at; + } + + //Проверка урона приемов + + /** + * @param $i + * @param $id + * @param $pid + * @param $a + * @param $b + * @param $u1 + * @param $u2 + * @return bool + * @deprecated always returns true + */ + public function testPriemVarTrueZash($i, $id, $pid, $a, $b, $u1, $u2): bool + { + return true; + } + + public function newRazmen($id, $at = null) + { + $uid1 = $this->atacks[$id]['uid1']; + $uid2 = $this->atacks[$id]['uid2']; + + if ($this->atacks[$id]['out1'] == 0) { + $at[1] = $this->usersTestAtack($id, $uid1, $uid2); + } else { + $at[1] = [0]; + } + if ($this->atacks[$id]['out2'] == 0) { + $at[2] = $this->usersTestAtack($id, $uid2, $uid1); + } else { + $at[2] = [0]; + } + + return $at; + } + + //Опыт + набитый урон за удар приемом\магией + + public function usersTestAtack($id, $uid1, $uid2): array + { + $r = []; + $block = [ + 0, + 0, + 0, + 0, + 0, + 0, + ]; + + //Проверка блоков + $i = 1; + if ($uid1 == $this->atacks[$id]['uid1']) { + $a = 2; + $j = $this->atacks[$id]['b2']; + $atack = [ + 0, + $this->atacks[$id]['a1'][0], + $this->atacks[$id]['a1'][1], + $this->atacks[$id]['a1'][2], + $this->atacks[$id]['a1'][3], + $this->atacks[$id]['a1'][4], + ]; + } elseif ($uid2 == $this->atacks[$id]['uid1']) { + $a = 1; + $j = $this->atacks[$id]['b1']; + $atack = [ + 0, + $this->atacks[$id]['a2'][0], + $this->atacks[$id]['a2'][1], + $this->atacks[$id]['a2'][2], + $this->atacks[$id]['a2'][3], + $this->atacks[$id]['a2'][4], + ]; + } + if ($this->atacks[$id]['out' . $a] == 0) { + while ($i <= $this->stats[$this->uids[$uid2]]['zonb']) { + $block[$j] = 1; + $j++; + if ($j > 5 || $j < 1) { + $j = 1; + } + $i++; + } + } + //Проверка ударов + $i = 1; + while ($i <= $this->stats[$this->uids[$uid1]]['zona']) { + if (!isset($atack[$i]) || $atack[$i] == 0) { + $atack[$i] = rand(1, 5); + } + if ($atack[$i] > 0) { + if ($block[$atack[$i]] == 1) { + //удар был заблокирован + // КУДА БИЛ , ТИП УДАРА + $r['atack'][] = [$atack[$i], 3, 0]; + } else { + //Удар прошел + // КУДА БИЛ , ТИП УДАРА + $r['atack'][] = [$atack[$i], 1, 0]; + } + } + $i++; } return $r; } + //Наносим удар между игроками - //Выводим лог боя - public function lookLog(): string + public function mf5Razmen($id, $at, $v, $rjd = 0) { - global $c, $u, $log_text; - $hodID = mysql_fetch_array( - mysql_query( - 'SELECT `id`,`id_hod` FROM `battle_logs` WHERE `battle` = "' . $this->info['id'] . '" ORDER BY `time` ASC LIMIT 1' - ) - ); - if ($hodID['id_hod'] <= 1) { - $u->info['alog'] = 0; - } - if (isset($hodID['id']) && $this->info['team_win'] != -1) { - $hodID = mysql_fetch_array( - mysql_query( - 'SELECT `id` FROM `battle_logs_save` WHERE `battle` = "' . $this->info['id'] . '" ORDER BY `time` ASC LIMIT 1' - ) + global $u; + + $uid1 = $this->atacks[$id]['uid1']; + $uid2 = $this->atacks[$id]['uid2']; + + if ($this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] > 0) { + $uid1 = $this->yhod_user( + $this->atacks[$id]['uid2'], $this->atacks[$id]['uid1'], + $this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] + ); + } elseif ($this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] > 0) { + $uid2 = $this->yhod_user( + $this->atacks[$id]['uid1'], $this->atacks[$id]['uid2'], + $this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] ); } - $hodID = $hodID['id'] ?? 0; - $updt = 0; - $js = ''; - $pll = 0; - if ($_POST['idlog'] < 1) { - $_POST['idlog'] = 0; - } - $talog = mysql_fetch_array( - mysql_query('SELECT `alog` FROM `stats` WHERE `id` = "' . $u->info['id'] . '" LIMIT 1') - ); - $sp = mysql_query( - 'SELECT - `id`,`type`,`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zona2`,`zonb1`,`zonb2` - FROM `battle_logs` - WHERE `battle` = "' . $this->info['id'] . '" AND `id_hod` >= ' . $talog['alog'] . ' ORDER BY `id` DESC' - ); - if (isset($sp) && $this->info['team_win'] != -1) { - $sp = mysql_query( - 'SELECT - `id`,`type`,`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zona2`,`zonb1`,`zonb2` - FROM `battle_logs_save` - WHERE `battle` = "' . $this->info['id'] . '" AND `id_hod` >= ' . $talog['alog'] . ' ORDER BY `id` DESC' - ); - } - $jin = 0; - $forYou2 = 0; - if (is_array($sp)) { - while ($pl = mysql_fetch_array($sp)) { - if ($jin == 0) { - $u->info['alog'] = $pl['id_hod']; + $i = 1; + while ($i <= 2) { + if ($i == 1) { + $a = 1; + $b = 2; + $u1 = ${'uid1'}; + $u2 = ${'uid2'}; + } else { + $a = 2; + $b = 1; + $u1 = ${'uid2'}; + $u2 = ${'uid1'}; + } + + //Расчет контрудара Цели (u2) по Атакующему (u1) + $j = 0; + if ($rjd > 0) { + $j = $rjd - 1; + } + while ($j < count($at[$a]['atack']) && $j < 8) { + // КУДА БИЛ , ТИП УДАРА + if ($at[$a]['atack'][$j][2] == $v) { + if ($at[$a]['atack'][$j][1] == 2) { + if ($this->mfs( + 6, [ + 'u1' => $u1, + 'u2' => $u2, + 'a' => $this->stats[$this->uids[$u2]]['m6'], + 'b' => $this->stats[$this->uids[$u1]]['m6'], + ], $this->users[$this->uids[$u1]]['level'], $this->users[$this->uids[$u2]]['level'] + ) == 1) { + //контрудар, гад :) + $at[$a]['atack'][$j][1] = 8; + $rnd_a = rand(1, 5); + $rjd = count($at[$b]['atack']); + if (!$this->testRazmenblock1($id, $u2, $u1, $rnd_a)) { + $at[$b]['atack'][] = [$rnd_a, 1, 0, 1]; // 3 , 0 , 1 + } else { + $at[$b]['atack'][] = [$rnd_a, 3, 0, 1]; // 3 , 0 , 1 + } + $at = $this->contrRestart($id, $at, 1, $rjd); + } + } } - $jin++; + $j++; + } + $i++; + } + return $at; + } - $rt = $pl['text']; - $pl['vars'] = str_replace('^^^^', 'rvnO', $pl['vars']); - $rt = str_replace( - '{tm1}', '' . date('H:i', $pl['time']) . '', - $rt - ); - $rt = str_replace( - '{tm2}', '' . date('H:i', $pl['time']) . '', - $rt - ); - $rt = str_replace( - '{tm3}', - '' . date('d.m.Y H:i', $pl['time']) . '', $rt - ); - $rt = str_replace( - '{tm4}', - '' . date('d.m.Y H:i', $pl['time']) . '', $rt - ); - $pl['text'] = $rt; - - unset($rt); - if ($pll < $pl['id']) { - $pll = $pl['id']; + public function testRazmenblock1($id, $uid1, $uid2, $atack): bool + { + $r = false; + //Проверка блоков + $i = 1; + if ($uid1 == $this->atacks[$id]['uid1']) { + $j = $this->atacks[$id]['b2']; + } elseif ($uid2 == $this->atacks[$id]['uid1']) { + $j = $this->atacks[$id]['b1']; + } + if ($this->atacks[$id]['out2'] == 0) { + while ($i <= $this->stats[$this->uids[$uid2]]['zonb']) { + $block[$j] = 1; + $j++; + if ($j > 5 || $j < 1) { + $j = 1; } - $js = 'add_log(' . $pl['id'] . ',' . $forYou2 . ',"' . $pl['text'] . '",' . $pl['id_hod'] . ',0,0,"' . str_replace( - '"', - '"', $pl['vars'] - ) . '");' . $js; + $i++; } } - mysql_query( - 'UPDATE `stats` SET `alog`="' . $u->info['alog'] . '" WHERE `id` ="' . $u->info['id'] . '" LIMIT 1' - ); - $js .= 'id_log=' . $pll . ';'; - return $js; + //Проверка ударов + if ($atack > 0) { + $r = $block[$atack] == 1; + } + return $r; + } + + public function contrRestart($id, $at, $v, $rjd = 0) + { + //уворот + $at = $this->mf1Razmen($id, $at, $v, true, $rjd); + //парирование + $at = $this->mf3Razmen($id, $at, $v, true, $rjd); + //контрудар + //$at = $this->mf5Razmen($id,$at,$v,true,$rjd); + //блок щитом (если есть щит, конечно) + $at = $this->mf4Razmen($id, $at, $v, true, $rjd); + //Проверяем урон + //$at = $this->yronRazmen($id,$at); + //крит + $at = $this->mf2Razmen($id, $at, $v, true, $rjd); + $at = $this->yronRazmen($id, $at, true, $rjd); + return $at; + } + + public function mf1Razmen($id, $at, $v, $pat = false, $rjd = 0) + { + global $u; + + if ($pat) { + $pat = $at; + $at = $pat['p']; + } else { + unset($pat); + } + + $uid1 = $this->atacks[$id]['uid1']; + $uid2 = $this->atacks[$id]['uid2']; + + if ($this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] > 0) { + $uid1 = $this->yhod_user( + $this->atacks[$id]['uid2'], $this->atacks[$id]['uid1'], + $this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] + ); + } elseif ($this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] > 0) { + $uid2 = $this->yhod_user( + $this->atacks[$id]['uid1'], $this->atacks[$id]['uid2'], + $this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] + ); + } + + $i = 1; + while ($i <= 2) { + if ($i == 1) { + $a = 1; + $b = 2; + $u1 = ${'uid1'}; + $u2 = ${'uid2'}; + } else { + $a = 2; + $b = 1; + $u1 = ${'uid2'}; + $u2 = ${'uid1'}; + } + + //Расчет уворота Цели (u2) от Атакующего (u1) + $j = 0; + $wp01 = 3; + $k01 = 0; + if ($rjd > 0) { + $j = $rjd - 1; + } + if (is_array($at[$a]['atack'])) { + while ($j < count($at[$a]['atack']) && $j < 8) { + // КУДА БИЛ , ТИП УДАРА + if ($k01 == 0 && isset($this->stats[$this->uids[$u1]]['wp3id'])) { + //Левая рука + $wp01 = 3; + $k01 = 1; + } else { + //Правая рука + if (isset($this->stats[$this->uids[$u1]]['wp14id']) && $this->stats[$this->uids[$u1]]['items'][$this->stats[$this->uids[$u1]]['wp14id']]['type'] != 13) { + $wp01 = 14; + } else { + $wp01 = 3; + } + $k01 = 0; + } + $witm01 = 0; + $witm_type01 = 0; + $witm01 = $this->stats[$this->uids[$u1]]['items'][$this->stats[$this->uids[$u1]]['wp' . $wp01 . 'id']]; + $witm_data01 = ConversionHelper::dataStringToArray($witm01['data']); + if ($at[$a]['atack'][$j][2] == $v) { + $tyv = $this->mfs( + 2, [ + 'u1' => $u1, + 'u2' => $u2, + 'mf' => $this->stats[$this->uids[$u2]]['m4'], + 'amf' => (int)$this->stats[$this->uids[$u2]]['m15'], + 'smf' => ($this->stats[$this->uids[$u1]]['m5'] + $witm_data01['sv_m5']), + 'asmf' => $this->stats[$this->uids[$u1]]['m21'], + ], $this->users[$this->uids[$u1]]['level'], $this->users[$this->uids[$u2]]['level'] + ); + if ($tyv == 1 && $this->atacks[$id]['out' . $b] == 0) { + //увернулся, гад :) + $this->stats[$this->uids[$u1]]['nopryh'] = floor( + 0 + (int)$this->stats[$this->uids[$u1]]['nopryh'] + ); + if (!isset($this->stats[$this->uids[$u1]]['nopryh']) || $this->stats[$this->uids[$u1]]['nopryh'] <= 0) { + $at[$a]['atack'][$j][1] = 2; + } else { + $this->stats[$this->uids[$u1]]['nopryh']--; + $this->stats[$this->uids[$u1]]['nopryh_act']++; + } + } + } + $j++; + } + } + $i++; + } + unset($witm01, $witm_type01, $wp01, $k01); + + if (isset($pat) && $pat) { + $pat['p'] = $at; + $at = $pat; + } + return $at; + } + + public function yhod_user($uid1, $uid2, $type) + { + // 1 - кто бьет . 2 - в кого бьют . тип + //Удал летит прямо в противника + if ($this->import_user == 0) { + $r = $uid1; + $rand_user = false; + if ($type == 2) { + //Случайный персонаж из своей команды (в том числе игрок) + $i = 0; + while ($i < count($this->users)) { + if ($this->users[$i]['team'] == $this->users[$this->uids[$uid2]]['team']) { + $rand_user[] = $this->users[$i]['id']; + } + $i++; + } + } elseif ($type == 4) { + //Случайный персонаж, любой + $i = 0; + while ($i < count($this->users)) { + //if( $this->users[$i]['team'] == $this->users[$this->uids[$uid1]]['team'] ) { + $rand_user[] = $this->users[$i]['id']; + //} + $i++; + } + } elseif ($type == 5) { + //Случайный персонаж, любой (кроме игрока) + $i = 0; + while ($i < count($this->users)) { + if ($this->users[$i]['team'] == $this->users[$this->uids[$uid2]]['team'] && $uid2 != $this->users[$i]['id']) { + $rand_user[] = $this->users[$i]['id']; + } + $i++; + } + } elseif ($type == 6) { + //Случайный персонаж из команды противника + $i = 0; + while ($i < count($this->users)) { + if ($this->users[$i]['team'] != $this->users[$this->uids[$uid2]]['team']) { + $rand_user[] = $this->users[$i]['id']; + } + $i++; + } + } elseif ($type > 100) { + //Удар идет в конкретного игрока + if (!isset($this->users[$this->uids[$type]]) || $this->users[$this->uids[$type]]['id'] != $type) { + $r = $uid2; + } else { + $r = $type; + } + } + if ($rand_user && count($rand_user) > 0) { + $r = $rand_user[rand(0, (count($rand_user) - 1))]; + } + $this->import_user = $r; + } else { + $r = $this->import_user; + } + return $r; + } + + //Сохранение данные + + public function mfs($type, $mf, $lvl1, $lvl2): int + { + $rval = 0; + switch ($type) { + case 1: + //Крит + if ($mf['amf'] < 0) { + $mf['amf'] = 0; + } + if ($mf['mf'] < 0) { + $mf['mf'] = 0; + } + if ($mf['mf'] > $mf['smf']) { + $rval = 100 - floor(((($mf['smf']) / ($mf['mf'] + 1)) * 100)); + } + + if ($rval < 1) { + $rval = 0; + } + if ($rval > 75) { + $rval = 75; + } + if ($mf['amf'] >= 1) { + if ($mf['amf'] > 100) { + $mf['amf'] = 100; + } + if (($mf['amf'] * 100) >= mt_rand(1, 10000)) { + $rval = 100; + } + } + break; + case 2: + if ($mf['mf'] < 0) { + $mf['mf'] = 0; + } + if ($mf['amf'] < 0) { + $mf['amf'] = 0; + } + if ($mf['smf'] < 0) { + $mf['smf'] = 0; + } + if ($mf['asmf'] < 0) { + $mf['asmf'] = 0; + } + if ($mf['mf'] > $mf['smf']) { + $rval = 100 - floor(((($mf['smf']) / ($mf['mf'] + 1)) * 100)); //2.5 + } + if ($rval < 1) { + $rval = 0; + } + if ($rval > 75) { + $rval = 75; + } + if ($mf['asmf'] >= 0) { + if ($mf['asmf'] > 100) { + $mf['asmf'] = 100; + } + if ($mf['asmf'] >= rand(1, 100)) { + $rval = 0; + } + } + if ($mf['amf'] >= 0) { + if ($mf['amf'] > 100) { + $mf['amf'] = 100; + } + if ($mf['amf'] >= rand(1, 100)) { + $rval = 100; + } + } + break; + case 3: + if ($mf[1] < 1) { + $mf[1] = 1; + } + if ($mf[2] < 1) { + $mf[2] = 1; + } + $rval = $mf[1] - $mf[2] / 2; + if ($rval > 75) { + $rval = 75; + } + if ($rval < 1) { + $rval = 1; + } + break; + case 4: + $mf = round($mf * 0.6); + if ($mf < 1) { + $mf = 0; + } + if ($mf > 100) { + $mf = 100; + } + $rval = min($mf, 100); //пробой брони + break; + case 5: + if ($mf < 1) { + $mf = 0; + } + $rval = min($mf, 85); //блок щитом + break; + case 6: + //Контрудар + if ($mf['a'] > 0) { + if ($mf['b'] > 0) { + $rval = round($mf['a'] - ($mf['b'] / 2)); + } else { + $rval = $mf['a']; + } + } + if ($rval < 1) { + $rval = 0; + } + if ($rval > 75) { + $rval = 75; + } + break; + } + return $this->get_chanse($rval) ? 1 : 0; + } + + //Отображение НР + + public function mf3Razmen($id, $at, $v, $pat = false, $rjd = 0) + { + if ($pat) { + $pat = $at; + $at = $pat['p']; + } else { + unset($pat); + } + + $uid1 = $this->atacks[$id]['uid1']; + $uid2 = $this->atacks[$id]['uid2']; + + if ($this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] > 0) { + $uid1 = $this->yhod_user( + $this->atacks[$id]['uid2'], $this->atacks[$id]['uid1'], + $this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] + ); + } elseif ($this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] > 0) { + $uid2 = $this->yhod_user( + $this->atacks[$id]['uid1'], $this->atacks[$id]['uid2'], + $this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] + ); + } + + $i = 1; + while ($i <= 2) { + if ($i == 1) { + $a = 1; + $b = 2; + $u1 = ${'uid1'}; + $u2 = ${'uid2'}; + } else { + $a = 2; + $b = 1; + $u1 = ${'uid2'}; + $u2 = ${'uid1'}; + } + + //Расчет парирования Цели (u2) от Атакующего (u1) + $j = 0; + if ($rjd > 0) { + $j = $rjd - 1; + } + + if (is_array($at[$a]['atack'])) { + while ($j < count($at[$a]['atack']) && $j < 8) { + // КУДА БИЛ , ТИП УДАРА + if ((!isset($this->stats[$this->uids[$u2]]['no_pr1']) || $this->stats[$this->uids[$u2]]['no_pr1'] == 0) && $at[$a]['atack'][$j][2] == $v) { + if ($this->mfs( + 3, [ + 'u1' => $u1, + 'u2' => $u2, + '1' => $this->stats[$this->uids[$u2]]['m7'], + '2' => $this->stats[$this->uids[$u1]]['m7'], + ], $this->users[$this->uids[$u1]]['level'], + $this->users[$this->uids[$u2]]['level'] + ) == 1 && $this->atacks[$id]['out' . $b] == 0) { + //Парировал, гад :) + $this->stats[$this->uids[$u1]]['nopryh'] = floor( + 0 + (int)$this->stats[$this->uids[$u1]]['nopryh'] + ); + if ((!isset($this->stats[$this->uids[$u1]]['nopryh']) || $this->stats[$this->uids[$u1]]['nopryh'] == 0) && $this->stats[$this->uids[$u1]]['nopryh_act'] < 1) { + $at[$a]['atack'][$j][1] = 6; + $this->stats[$this->uids[$u1]]['nopryh']--; + $this->stats[$this->uids[$u1]]['nopryh_act']++; + } + } + } + $j++; + } + } + $i++; + } + + if (isset($pat) && $pat) { + $pat['p'] = $at; + $at = $pat; + } + + return $at; + } + + + //Выводим лог боя + + public function mf4Razmen($id, $at, $v, $pat = false, $rjd = 0) + { + if ($pat) { + $pat = $at; + $at = $pat['p']; + } else { + unset($pat); + } + + $uid1 = $this->atacks[$id]['uid1']; + $uid2 = $this->atacks[$id]['uid2']; + + if ($this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] > 0) { + $uid1 = $this->yhod_user( + $this->atacks[$id]['uid2'], $this->atacks[$id]['uid1'], + $this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] + ); + } elseif ($this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] > 0) { + $uid2 = $this->yhod_user( + $this->atacks[$id]['uid1'], $this->atacks[$id]['uid2'], + $this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] + ); + } + + $i = 1; + while ($i <= 2) { + if ($i == 1) { + $a = 1; + $b = 2; + $u1 = ${'uid1'}; + $u2 = ${'uid2'}; + } else { + $a = 2; + $b = 1; + $u1 = ${'uid2'}; + $u2 = ${'uid1'}; + } + if ($this->stats[$this->uids[$u2]]['sheld1'] > 0) { + //Расчет блока щитом Цели (u2) от Атакующего (u1) + $j = 0; + while ($j < count($at[$a]['atack']) && $j < 8) { + // КУДА БИЛ , ТИП УДАРА + if ($at[$a]['atack'][$j][2] == $v) { + if ($this->mfs( + 5, + ($this->stats[$this->uids[$u2]]['m8'] / 2 + $this->stats[$this->uids[$u2]]['m18']), + $this->users[$this->uids[$u1]]['level'], + $this->users[$this->uids[$u2]]['level'] + ) == 1 && $this->atacks[$id]['out' . $b] == 0) { + //блокировал щитом, гад :) + $at[$a]['atack'][$j][1] = 7; + } + } + $j++; + } + } + $i++; + } + + if (isset($pat) && $pat) { + $pat['p'] = $at; + $at = $pat; + } + + return $at; } //Новый лог Мой Лог - public function lookmLog(): string + + public function mf2Razmen($id, $at, $v, $pat = false, $rjd = 0) { - global $c, $u, $log_text; - $js = ''; - $pll = 0; + global $u; + if ($pat) { + $pat = $at; + $at = $pat['p']; + } else { + unset($pat); + } - if ($this->info['type'] != 9) { - $hodID = mysql_fetch_array( - mysql_query( - 'SELECT `id`,`id_hod` FROM `battle_logs` WHERE `battle` = "' . $this->info['id'] . '" ORDER BY `time` ASC LIMIT 1' - ) - ); - if ($hodID['id_hod'] <= 1) { - $u->info['mlog'] = 0; - } - if (isset($hodID['id']) && $this->info['team_win'] != -1) { - $hodID = mysql_fetch_array( - mysql_query( - 'SELECT `id` FROM `battle_logs_save` WHERE `battle` = "' . $this->info['id'] . '" ORDER BY `time` ASC LIMIT 1' - ) - ); - } - $hodID = $hodID['id'] ?? 0; - $tmlog = mysql_fetch_array( - mysql_query('SELECT `mlog` FROM `stats` WHERE `id` = "' . $u->info['id'] . '" LIMIT 1') - ); - $spm = mysql_query( - 'SELECT - `id`,`type`,`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zona2`,`zonb1`,`zonb2` - FROM `battle_logs` - WHERE `battle` = "' . $this->info['id'] . '" AND `id_hod` >= ' . $tmlog['mlog'] . ' AND `vars` LIKE "%' . $u->info['login'] . '%" ORDER BY `id` DESC' - ); + $uid1 = $this->atacks[$id]['uid1']; + $uid2 = $this->atacks[$id]['uid2']; - if (isset($spm) && $this->info['team_win'] != -1) { - $spm = mysql_query( - 'SELECT - `id`,`type`,`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zona2`,`zonb1`,`zonb2` - FROM `battle_logs_save` - WHERE `battle` = "' . $this->info['id'] . '" AND `id_hod` >= ' . $tmlog['mlog'] . ' AND `vars` LIKE "%' . $u->info['login'] . '%" ORDER BY `id` DESC' - ); - } - - $jin = 0; - $forYou2 = 0; - if (is_array($spm)) { - while ($plm = mysql_fetch_array($spm)) { - if ($jin == 0) { - $u->info['mlog'] = $plm['id_hod']; - } - $jin++; - $rt = $plm['text']; - $plm['vars'] = str_replace('^^^^', 'rvnO', $plm['vars']); - $rt = str_replace( - '{tm1}', '' . date('H:i', $plm['time']) . '', $rt - ); - $rt = str_replace( - '{tm2}', '' . date('H:i', $plm['time']) . '', $rt - ); - $rt = str_replace( - '{tm3}', '' . date('d.m.Y H:i', $plm['time']) . '', - $rt - ); - $rt = str_replace( - '{tm4}', '' . date('d.m.Y H:i', $plm['time']) . '', - $rt - ); - $plm['text'] = $rt; - unset($rt); - if ($pll < $plm['id']) { - $pll = $plm['id']; - } - $js = 'add_mlog(' . $plm['id'] . ',' . $forYou2 . ',"' . $plm['text'] . '",' . $plm['id_hod'] . ',0,0,"' . str_replace( - '"', - '"', $plm['vars'] - ) . '");' . $js; - } - } - $js .= 'id_mlog=' . $pll . ';'; - mysql_query( - 'UPDATE `stats` SET `mlog`="' . $u->info['mlog'] . '" WHERE `id` ="' . $u->info['id'] . '" LIMIT 1' + if ($this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] > 0) { + $uid1 = $this->yhod_user( + $this->atacks[$id]['uid2'], $this->atacks[$id]['uid1'], + $this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] + ); + } elseif ($this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] > 0) { + $uid2 = $this->yhod_user( + $this->atacks[$id]['uid1'], $this->atacks[$id]['uid2'], + $this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] ); } - return $js; + + $i = 1; + while ($i <= 2) { + if ($i == 1) { + $a = 1; + $b = 2; + $u1 = ${'uid1'}; + $u2 = ${'uid2'}; + } else { + $a = 2; + $b = 1; + $u1 = ${'uid2'}; + $u2 = ${'uid1'}; + } + + //Расчет крита Атакующего (u1) по Цели (u2) + $j = 0; + $wp01 = 0; + $k01 = 0; + if ($rjd > 0) { + $j = $rjd - 1; + } + + if (is_array($at[$a]['atack'])) { + while ($j < count($at[$a]['atack']) && $j <= 8) { + // КУДА БИЛ , ТИП УДАРА + if ($k01 == 0 && isset($this->stats[$this->uids[$u1]]['wp3id'])) { + //Левая рука + $wp01 = 3; + $k01 = 1; + } else { + //Правая рука + if (isset($this->stats[$this->uids[$u1]]['wp14id']) && $this->stats[$this->uids[$u1]]['items'][$this->stats[$this->uids[$u1]]['wp14id']]['type'] != 13) { + $wp01 = 14; + } else { + $wp01 = 3; + } + $k01 = 0; + } + $witm01 = 0; + $witm_type01 = 0; + $witm01 = $this->stats[$this->uids[$u1]]['items'][$this->stats[$this->uids[$u1]]['wp' . $wp01 . 'id']]; + $witm_data01 = ConversionHelper::dataStringToArray($witm01['data']); + if ($this->mfs( + 1, [ + 'u1' => $u1, + 'u2' => $u2, + 'mf' => $this->stats[$this->uids[$u1]]['m1'] + $witm_data01['sv_m1'], + 'amf' => $this->stats[$this->uids[$u1]]['m14'], + 'smf' => $this->stats[$this->uids[$u2]]['m2'], + 'aamf1' => (int)$this->stats[$this->uids[$u2]]['enemy_am1'], + ], $this->users[$this->uids[$u1]]['level'], $this->users[$this->uids[$u2]]['level'] + ) == 1) { + //кританул, гад :) + if ($at[$a]['atack'][$j][1] == 3) { + //в блок + $at[$a]['atack'][$j][1] = 4; //Тут тест + } elseif ($at[$a]['atack'][$j][1] != 2 && $at[$a]['atack'][$j][1] != 6 && $at[$a]['atack'][$j][1] != 7 && $at[$a]['atack'][$j][1] != 8) { + //обычный крит + $at[$a]['atack'][$j][1] = 5; + } else { + $at[$a]['atack'][$j][1] = 1; + } + } + $j++; + } + } + $i++; + } + unset($witm01, $witm_type01, $k01, $wp01); + + if (isset($pat) && $pat) { + $pat['p'] = $at; + $at = $pat; + } + + return $at; } //====================== //Добавляем в лог - public function add_log($mass) + + public function yronRazmen($id, $at, $pat = false, $rjd = 0) { - if (empty($mass['text'])) { - return; + if ($pat) { + $pat = $at; + $at = $pat['p']; + } else { + unset($pat); } - mysql_query( - 'INSERT INTO `battle_logs` (`time`,`battle`,`id_hod`,`text`,`vars`,`type`) VALUES (unix_timestamp(), "' . $mass['battle'] . '","' . $mass['id_hod'] . '","' . $mass['text'] . '","' . $mass['vars'] . '","' . $mass['type'] . '")' - ); - if (rand(2, 10) == 10) { - $this->get_comment(); + + $uid1 = $this->atacks[$id]['uid1']; + $uid2 = $this->atacks[$id]['uid2']; + + if ($this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] > 0) { + $yhod = [1 => 1, 2 => 0]; + } elseif ($this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] > 0) { + $yhod = [1 => 0, 2 => 1]; } + + $i = 1; + while ($i <= 2) { + if ($i == 1) { + $a = 1; + $b = 2; + $u1 = ${'uid1'}; + $u2 = ${'uid2'}; + } else { + $a = 2; + $b = 1; + $u1 = ${'uid2'}; + $u2 = ${'uid1'}; + } + + $j = 0; + $k = 0; + $wp = 3; + if ($rjd > 0) { + $j = $rjd - 1; + } + + if (is_array($at[$a]['atack'])) { + while ($j < count($at[$a]['atack']) && $j < 8) { + if ($k == 0 && isset($this->stats[$this->uids[$u1]]['wp3id'])) { + //Левая рука + $wp = 3; + $k = 1; + } else { + //Правая рука + if (isset($this->stats[$this->uids[$u1]]['wp14id']) && $this->stats[$this->uids[$u1]]['items'][$this->stats[$this->uids[$u1]]['wp14id']]['type'] != 13) { + $wp = 14; + } else { + if (isset($this->stats[$this->uids[$u1]]['wp3id'])) { + $wp = 3; + } else { + //нет оружия + $wp = 3; + } + } + $k = 0; + } + $witm = $this->stats[$this->uids[$u1]]['items'][$this->stats[$this->uids[$u1]]['wp' . $wp . 'id']]; + $witm_type = $this->weaponTx($witm); + $at[$a]['atack'][$j]['wt'] = $witm['type']; + $at[$a]['atack'][$j]['yhod'] = $yhod[$a]; + if (!isset($at[$a]['atack'][$j]['yron']) && ( + $at[$a]['atack'][$j][1] == 1 || + $at[$a]['atack'][$j][1] == 4 || + $at[$a]['atack'][$j][1] == 5) + ) { + $at[$a]['atack'][$j]['yron'] = $this->yronGetrazmen( + $u1, $u2, $wp, $at[$a]['atack'][$j][0], + ); + + if ($at[$a]['atack'][$j][1] == 4) { + $at[$a]['atack'][$j]['yron']['y_old'] = $at[$a]['atack'][$j]['yron']['y']; + $at[$a]['atack'][$j]['yron']['y'] = round($at[$a]['atack'][$j]['yron']['k'] / 2); + } elseif ($at[$a]['atack'][$j][1] == 5) { + $at[$a]['atack'][$j]['yron']['y_old'] = $at[$a]['atack'][$j]['yron']['y']; + $at[$a]['atack'][$j]['yron']['y'] = $at[$a]['atack'][$j]['yron']['k']; + } + $at[$a]['atack'][$j]['yron']['2h'] = $witm['2h']; + $at[$a]['atack'][$j]['yron']['w'] = $wp; + if ($at[$a]['atack'][$j]['yron']['y'] < 1) { + $at[$a]['atack'][$j]['yron']['r'] = '--'; + } else { + $at[$a]['atack'][$j]['yron']['r'] = '-' . $at[$a]['atack'][$j]['yron']['y']; + } + } else { + $at[$a]['atack'][$j]['block'] = $this->yronGetrazmen( + $u1, $u2, $wp, $at[$a]['atack'][$j][0], + $yhod[$b] + ); + if ($at[$a]['atack'][$j][1] == 4) { + $at[$a]['atack'][$j]['block']['y_old'] = $at[$a]['atack'][$j]['block']['y']; + $at[$a]['atack'][$j]['block']['y'] = round($at[$a]['atack'][$j]['block']['k'] / 2); + } elseif ($at[$a]['atack'][$j][1] == 5) { + $at[$a]['atack'][$j]['block']['y_old'] = $at[$a]['atack'][$j]['block']['y']; + $at[$a]['atack'][$j]['block']['y'] = $at[$a]['atack'][$j]['block']['k']; + } + $at[$a]['atack'][$j]['block']['2h'] = $witm['2h']; + $at[$a]['atack'][$j]['block']['w'] = $wp; + if ($at[$a]['atack'][$j]['block']['y'] < 1) { + $at[$a]['atack'][$j]['block']['r'] = '--'; + } else { + $at[$a]['atack'][$j]['block']['r'] = '-' . $at[$a]['atack'][$j]['block']['y']; + } + } + $j++; + } + } + $i++; + } + if (isset($pat) && $pat) { + $pat['p'] = $at; + $at = $pat; + } + return $at; } ///Комментатор - public function get_comment() - { - $boycom = [ - 'А танцуешь ты лучше.', - 'А мы что, в прятки тут играем?', - 'А вы разве пингвинов никогда не видели?', - 'А, ведь когда-то, вы были красивыми… А теперь? Ну и рожи! Жуть!', - 'А потом еще труп пинать будут.', - 'А я вчера ночью за соседями подглядывал. Они точно так же кувыркались', - 'А ведь вы живых людей дубасите...', - 'А вот я вчера в зоопарке был...', - 'А вы в стройбате не служили?', - 'А вы видели, чтобы так на улице делали!?', - 'А вы знали что ёжики размножаются в интернете?', - 'А жить-то, как хочется:', - 'А из-за чего вы собственно дерётесь?', - 'А чего ржёте, вы ещё остальных не видели', - 'А что произойдёт если ты испугаешся до полусмерти дважды?!', - 'Больше так не делай. Ты же не садист?', - 'Без комментариев...', - 'Больно ведь!', - 'Быстро ты за монитор спрятался!', - 'Все хотят попасть в рай, но никто не хочет умирать!', - 'Вчера с такой девчонкой познакомился.', - 'Всего 5 минут знакомы, а дерутся, словно супруги с 20-ти летним стажем...', - 'Все. Я так больше не могу.', - 'В конце концов, кто-то победит?', - 'Вы чего, с дерева упали?', - 'Возятся как сонные мухи... давайте я вам лучше анекдот расскажу: ...', - 'Вот видишь, как полезно чистить зубы на ночь?', - 'Вот вы все руками махаете, а за вами уже очередь', - 'Вот попадёте вы в плен и вас там будут долго бить. Но вы ничего не расскажете... и не потому, что вы такой стойкий, просто вы ничего не знаете', - 'Вы бы лучше пошли потренировались!', - 'Вы все еще разминаетесь? Позовите, когда кости в муку друг другу разминать будете.', - 'Вы же бойцы! Имейте совесть!', - 'Гаси недоумка!', - 'Да, если бы я смог это остановить, то получил бы нобелевскую премию `За мир` ', - 'Да куда они бьют?!', - 'Давайте быстрее! За вами уже очередь образовалась.', - 'Давайте обойдемся сегодня таймаутом. А? А то мне уже кошмары скоро будут сниться.', - 'Дерутся как девчонки!', - 'Дети, посмотрите налево... Ой!.. Нет, туда лучше не смотреть.', - 'Если так будет продолжаться, то скоро мы заснем!', - 'Если бы у меня было кресло-качалка, я бы в нём качался...', - 'Если вы что-то сказать хотите, то лучше молчите :)', - 'Жестокость не порок.', - 'Жизнь вне нашего клуба - это пустая трата кислорода!!!', - 'Жми! Дави! Кусай! Царапай!', - 'За такие бои надо в хаос отправлять!', - 'Знаете откуда в комиссионном магазине столько вещей? Это я после ваших гулянок собираю и сдаю туда. Иногда вместе с частями тела, застрявшими в них.', - 'Здесь люди так близки друг к другу. Просто иначе ударить нельзя.', - 'И пролитая кровь еще пульсирует...', - 'Инвалидов развелось...', - 'Какой бой!!!', - 'Кто!? Кто здесь?!', - 'Кто вас этому научил?', - 'Кузнечик, блин...', - 'Куплю импортный проигрыватель грампластинок.', - 'Лошадью ходи!', - 'Лучше враг, чем друг - враг.', - 'Ладно, вы тут пока друг друга за волосы таскайте, а я пойду, пообедаю.', - 'Мне ваш балет уже надоел!', - 'Может, начнется-таки настоящий бой???', - 'Мысли лезут в голову изнутри, а удары снаружи.', - 'Ну и где ваши коронные удары? Где живописные падения я спрашиваю!', - 'Ну, нельзя же так наотмашь лупить!', - 'Надо раньше было думать, теперь смертельно поздно...', - 'На такое зрелище билеты продавать можно. Народ ухохочется!', - 'Нет! Не надо драки! А... ладно деритесь, все равно не умеете.', - 'Нет, ну должен быть повод, должен же быть повод?', - 'Нет, я отказываюсь это комментировать!', - 'Не таких обламывали!', - 'Ну выпили вы рюмку, ну две... ну литр, ну два... так зачем же после этого драку затевать?!', - 'Ну и кто за этот погром платить будет?', - 'Ну и оскал у вас. Из вашей улыбки кастеты делать можно.', - 'Ну, что же ты..? Не печалься. Выше голову, так по ней удобней попасть.', - 'Ничего... Блок тоже удар.', - 'Обернись!!!.... Поздно...', - 'Ого! Научите меня так не делать.', - 'Осторожно! Сделаешь дырочку, уже не запломбируешь!', - 'Оно вам надо???', - 'Обычное дело...там что-то отклеилось.', - 'Ой, и заболтался я с вами...', - 'Он же не промахнётся если ты не отойдёшь!', - 'По-моему, кому-то светит инвалидность.', - 'Подкинь ему грабли, на которые он еще не наступал.', - 'Прав был кот Леопольд, давайте жить дружно?', - 'При ударе в живот нарушается кислотно-щелочной баланс.', - 'Проверь, не торчит ли у тебя нож из живота.', - 'Перестаньте мне орать!', - 'Подкинь ему грабли, на которые он еще не наступал.', - 'Прыгают тут как блохи... Все, я пошел за дихлофосом!', - 'Разбудите меня когда эта порнография закончится...', - 'Ребенок сильнее ударил бы!', - 'Славно вмазал!', - 'Славно они веселятся', - 'Смотрю вот на вас, и слезы наворачиваются.', - 'Сначала учатся ходить, а потом только в драку лезут.', - 'Так они друг другу что-нибудь сломают.', - 'Так ты ему все кости переломаешь!', - 'У меня в подъезде точно так же соседа отмудохали', - 'Убогих развелось...', - 'Ух ты, какой прыткий!', - 'Фашист!! Надо ж, так по больному месту врезать...', - 'Хватит бить его об угол моей кабинки! Мне же потом ее чинить.', - 'Хулиганы, прекратите немедленно!', - 'Хочешь, подскажу, куда он ударит?', - 'Хорошо, что у меня ловкости больше чем у вас всех, а то б вы и меня в инвалидную коляску посадили бы.', - 'Хороший бой!', - 'Хороший удар!', - 'Хиляк-разрядник!', - 'Что ты его за волосы схватил?! Отпусти немедленно!', - 'Щас я вас настигну, вот тогда мы и похохочем', - 'Это была какая-то неизвестная мне техника...', - 'Это же противник, а не глина! Хватит мяться!', - 'Это не бой, это издевательское избиение.', - 'Это поубавит спеси', - 'Это и был твой план `Б` ?', - 'Это была какая-то неизвестная мне техника...', - 'Я же предупреждал, - будет больно.', - 'Я не страдаю безумием. Я наслаждаюсь им каждую минуту :)', - 'Я красивый, я сильный, я умный, я добрый. А вот вы? Вы себя-то видели?!', - 'Я тоже умею драться, но не буду...', - '(тревожно озираясь) я вам по секрету скажу... за вами наблюдают!', - '<вырезано цензурой> после боя я этих <вырезано цензурой> обоих в <вырезано цензурой> и <вырезано цензурой>', - '<вырезано цензурой> каратисты фиговы', - ]; - if (rand(1, 12) === 1) { - $txt = '{tm1} Комментатор: ' . $boycom[rand(0, count($boycom) - 1)] . ''; - $vLog = 'time1=' . time() . ''; - $mas1 = [ - 'time' => time(), - 'battle' => $this->info['id'], - 'id_hod' => $this->hodID, - 'text' => '', - 'vars' => $vLog, - 'zona1' => '', - 'zonb1' => '', - 'zona2' => '', - 'zonb2' => '', - 'type' => '1', - ]; - $mas1['text'] = $txt; - $this->add_log($mas1); - } else { - return false; - } - return true; - } - - //Расчет типа удара от оружия public function weaponTx($item) { global $u; @@ -8151,98 +7054,235 @@ class Battle return $tp; } + //Расчет типа удара от оружия - //Расчет урона от оружия - public function weaponAt($item, $st, $x): int + public function yronGetrazmen($uid1, $uid2, $wp, $zona): array { - $tp = 0; - $tp20 = 0; - if (isset($item['id'])) { - $itm = \Core\ConversionHelper::dataStringToArray($item['data']); - //начинаем расчет урона - $min = $itm['sv_yron_min'] + $itm['yron_min'] + $st['minAtack']; - $max = $itm['sv_yron_max'] + $itm['yron_max'] + $st['maxAtack']; - if ($x != 0) { - /* - Колющий - 60% Силы и 40% Ловкости. - Рубящий - 70% Силы 20% Ловкости и 20% Интуиции. - Дробящий - 100% Силы. - Режущий - 60% Силы и 40% Интуиции. - */ - //Тип урона: 0 - нет урона, 1 - колющий, 2 - рубящий, 3 - дробящий, 4 - режущий, 5 - огонь, 6 - воздух, 7 - вода, 8 - земля, 9 - свет, 10 - тьма, 11 - серая - if ($x == 1) { - //колющий - $wst = $st['s2'] * 1; - $min += 5 + (ceil($wst * 1.4) / 1.25) + $st['minAtack']; - $max += 7 + (ceil(0.4 + $min / 0.9) / 1.25) + $st['maxAtack']; - $tp20 = 1; - } elseif ($x == 2) { - //рубящий - $wst = $st['s1'] * 0.75; - $min += 5 + (ceil($wst * 1.4) / 1) + $st['minAtack']; - $max += 7 + (ceil(0.4 + $min / 0.9) / 1.25) + $st['maxAtack']; - $tp20 = 2; - } elseif ($x == 3) { - //дробящий - $wst = $st['s4'] * 1.5; - $min += 5 + (ceil($wst * 1.4) / 1.25) + $st['minAtack']; - $max += 7 + (ceil(0.4 + $min / 0.9) / 1.25) + $st['maxAtack']; - $tp20 = 3; - } elseif ($x == 4) { - //режущий - $wst = $st['s3'] * 1; - $min += 5 + (ceil($wst * 1.4) / 1.25) + $st['minAtack']; - $max += 7 + (ceil(0.4 + $min / 0.9) / 1.25) + $st['maxAtack']; - $tp20 = 4; - } elseif ($x >= 5 && $x <= 22) { - //урон магии и магии стихий - $wst = $st['s1'] * 0.01 + $st['s2'] * 0.01 + $st['s3'] * 0.01 + $st['s5'] * 0.06; - $min += 3 + (ceil($wst * 1.4) / 2.25) + $st['minAtack']; - $max += 5 + (ceil(0.4 + $min / 0.9) / 2.25) + $st['maxAtack']; - $tp20 = 5; - } + global $u; - $wst = ($st['s1'] * 0.02 + $st['s2'] * 0.02 + $st['s3'] * 0.05); - $min1 = -2 + ceil($wst * 1.4) / 1.25; - $max1 = 4 + ceil(0.4 + $min1 / 0.9) / 1.25; + $r = [ + 'y' => 0, + 'r' => '--', + ]; + //Определяем тип урона + /* + Колющий + Рубящий + Режущий + Дробящий + */ + $witm = 0; + $witm_type = 0; - $min = round(($min + $min1)); + if ($wp > 0) { + $witm = $this->stats[$this->uids[$uid1]]['items'][$this->stats[$this->uids[$uid1]]['wp' . $wp . 'id']]; + $witm_data = ConversionHelper::dataStringToArray($witm['data']); + $witm_type = $this->weaponTx($witm); + } + if ($witm_type == 0 || $witm_type == 12) { + $witm_type2 = ''; + } else { + $witm_type2 = $witm_type; + } + $r['t'] = $witm_type2; + //Расчет брони + /* + голова + грудь + живот + пояс + ноги + */ + $bron = [ + 1 => [$this->stats[$this->uids[$uid2]]['mib1'], $this->stats[$this->uids[$uid2]]['mab1']], + 2 => [$this->stats[$this->uids[$uid2]]['mib2'], $this->stats[$this->uids[$uid2]]['mab2']], + 3 => [$this->stats[$this->uids[$uid2]]['mib2'], $this->stats[$this->uids[$uid2]]['mab2']], + 4 => [$this->stats[$this->uids[$uid2]]['mib3'], $this->stats[$this->uids[$uid2]]['mab3']], + 5 => [$this->stats[$this->uids[$uid2]]['mib4'], $this->stats[$this->uids[$uid2]]['mab4']], + ]; + // + //Увеличиваем параметры от текущего оружия которым бьем + $iii = 1; + while ($iii <= 7) { + if (isset($witm_data['sv_a' . $iii]) && $witm_data['sv_a' . $iii] != 0) { + $this->stats[$this->uids[$uid1]]['a' . $iii] += $witm_data['sv_a' . $iii]; } - $tp = rand(($min + $max) / 3.5, (($min + $max) / 3.5 + (($min + $max) / 3.5) / 100 * 7)); + if (isset($witm_data['sv_mg' . $iii]) && $witm_data['sv_mg' . $iii] != 0) { + $this->stats[$this->uids[$uid1]]['mg' . $iii] += $witm_data['sv_mg' . $iii]; + } + $iii++; } - return $tp; + $iii = 1; + while ($iii <= 4) { + if (isset($witm_data['sv_aall']) && $witm_data['sv_aall'] != 0) { + $this->stats[$this->uids[$uid1]]['a' . $iii] += $witm_data['sv_aall']; + } + $iii++; + } + $iii = 1; + while ($iii <= 4) { + if (isset($witm_data['sv_mall']) && $witm_data['sv_mall'] != 0) { + $this->stats[$this->uids[$uid1]]['mg' . $iii] += $witm_data['sv_mall']; + } + $iii++; + } + $iii = 1; + while ($iii <= 7) { + if (isset($witm_data['sv_m2all']) && $witm_data['sv_m2all'] != 0) { + $this->stats[$this->uids[$uid1]]['mg' . $iii] += $witm_data['sv_m2all']; + } + $iii++; + } + + if (isset($witm_data['sv_m3']) && $witm_data['sv_m3'] != 0) { + $this->stats[$this->uids[$uid1]]['m3'] += $witm_data['sv_m3']; + } + + $iii = 1; + while ($iii <= 7) { + if (isset($witm_data['sv_pa' . $iii]) && $witm_data['sv_pa' . $iii] != 0) { + $this->stats[$this->uids[$uid1]]['pa' . $iii] += $witm_data['sv_pa' . $iii] + $witm_data['sv_m10']; + } + if (isset($witm_data['sv_pm' . $iii]) && $witm_data['sv_pm' . $iii] != 0) { + $this->stats[$this->uids[$uid1]]['pm' . $iii] += $witm_data['sv_pm' . $iii] + $witm_data['sv_m11a']; + if ($iii < 5) { + $this->stats[$this->uids[$uid1]]['pm' . $iii] += $witm_data['sv_m11']; + } + } + $iii++; + } + // + //мощность + подавление мощности противником + $wAp = 0; + $w3p = 0; + $w14p = 0; + + if ($witm_type == 12) { + //удар кулаком + $wAp += $this->stats[$this->uids[$uid1]]['m10']; + if ($this->users[$this->uids[$uid1]]['align'] == 7) { + $wAp += 15; + } + } elseif ($witm_type < 5) { + $wAp += $this->stats[$this->uids[$uid1]]['pa' . $witm_type . '']/* + $this->stats[$this->uids[$uid1]]['m10'] + $witm_data['sv_pa'.$witm_type.'']*/ + ; + $wAp -= $this->stats[$this->uids[$uid2]]['antpa' . $witm_type . '']; + } else { + $wAp += $this->stats[$this->uids[$uid1]]['m10'] + $this->stats[$this->uids[$uid1]]['pm' . ($witm_type - 4) . ''] + $this->stats[$this->uids[$uid1]]['m11a'] + $witm_data['sv_pm' . ($witm_type - 4) . '']; + $wAp -= $this->stats[$this->uids[$uid2]]['antpm' . ($witm_type - 4) . '']; + } + + //Владение данным оружием + $vladenie = 0; + + //Пробой брони + $proboi = 0; + $witm_data['m9'] = $this->stats[$this->uids[$uid1]]['m9']; + if (rand(1, 100) < floor($witm_data['m9'] / 2)) { + $proboi = floor($witm_data['m9'] / 2); + $r['pb'] = 1; + } + + $y = $this->yrn( + $this->stats[$this->uids[$uid1]], + $this->stats[$this->uids[$uid2]], + $this->users[$this->uids[$uid1]], + $this->users[$this->uids[$uid2]], + $this->users[$this->uids[$uid1]]['level'], + $this->users[$this->uids[$uid2]]['level'], + $witm_type, + $this->stats[$this->uids[$uid1]]['minAtack'], //мин. урон (добавочный) + $this->stats[$this->uids[$uid1]]['maxAtack'], //макс. урон + $bron[$zona][0], //броня мин. + $bron[$zona][1], //броня макс + $vladenie, //владения + (($wAp /*+ $w3p + $w14p*/)), //мощность урона + (round($this->stats[$this->uids[$uid1]]['m3'])), //мощность крита + (($this->stats[$this->uids[$uid2]]['za' . $witm_type2]) - $this->stats[$this->uids[$uid1]]['pza']), + //защита от урона + $this->stats[$this->uids[$uid1]]['ozash'], //подавление защиты + $proboi, //пробой брони + 0, //хз + ($witm_data['sv_yron_min'] + $this->stats[$this->uids[$uid1]]['yron_min']), + ($witm_data['sv_yron_max'] + $this->stats[$this->uids[$uid1]]['yron_max']), + $this->stats[$this->uids[$uid2]]['zaproc'], + $this->stats[$this->uids[$uid2]]['zmproc'], + (($this->stats[$this->uids[$uid2]]['zm' . ($witm_type2 - 4)]) - round( + $this->stats[$this->uids[$uid1]]['pzm'] * 0.8 + )), + //защита от урона + $this->stats[$this->uids[$uid1]]['omzash'], //подавление защиты + $witm['type'], + $witm + ); + + $r['y'] = round(rand($y['min'] + $proboi, $y['max'] + round($proboi / 2))); + $r['k'] = round(rand($y['Kmin'] + round($proboi / 4), $y['Kmax'] + round($proboi / 8))); + + $r['m_y'] = $y['max']; + $r['m_k'] = $y['Kmax']; + + $r['bRND'] = $y['bRND']; + + $r['w_type'] = $witm_type; + + //Если второе оружие - урон ниже на 50% + $wp1 = $this->stats[$this->uids[$uid1]]['items'][$this->stats[$this->uids[$uid1]]['wp3id']]; + $wp2 = $this->stats[$this->uids[$uid1]]['items'][$this->stats[$this->uids[$uid1]]['wp14id']]; + + //тип от оружия + if ($witm['type'] == 18) { + $tp = 1; + } elseif ($witm['type'] == 19) { + $tp = 2; + } elseif ($witm['type'] == 20) { + $tp = 3; + } elseif ($witm['type'] == 21) { + $tp = 4; + } else { + $tp = 0; + } + + if ($tp != $witm_type && $wp > 0) // ТУТ + { + (int)$r['y'] = round((int)$r['y'] / 3); + $r['r'] = round($r['r'] / 3); + $r['k'] = round($r['k'] / 3); + $r['m_k'] = round($r['m_k'] / 3); + $r['m_y'] = round($r['m_y'] / 3); + } + + if (isset($this->stats[$this->uids[$uid2]]['zaproc'])) { + $r['y'] = round($r['y'] - $r['y'] * $this->stats[$this->uids[$uid2]]['zaproc'] / 100); + (int)$r['r'] = round((int)$r['r'] - (int)$r['r'] * (int)$this->stats[$this->uids[$uid2]]['zaproc'] / 100); + $r['k'] = round($r['k'] - $r['k'] * $this->stats[$this->uids[$uid2]]['zaproc'] / 100); + $r['m_k'] = round($r['m_k'] - $r['m_k'] * $this->stats[$this->uids[$uid2]]['zaproc'] / 100); + $r['m_y'] = round($r['m_y'] - $r['m_y'] * $this->stats[$this->uids[$uid2]]['zaproc'] / 100); + if ($r['k'] < 1) { + $r['k'] = 2; + } + } + + if ($r['y'] < 1) { + $r['y'] = 1; + } + if ($r['r'] >= 0) { + $r['r'] = -1; + } + if ($r['k'] < 1) { + $r['k'] = 1; + } + if ($r['m_k'] < 1) { + $r['m_k'] = 1; + } + if ($r['m_y'] < 1) { + $r['m_y'] = 1; + } + return $r; } + //Расчет урона от оружия - public function weaponAt22($item, $st): array - { - $min = 0; - $max = 0; - if (isset($item['id'])) { - $itm = \Core\ConversionHelper::dataStringToArray($item['data']); - //начинаем расчет урона - $min = $itm['sv_yron_min'] + $itm['yron_min'] + $st['minAtack']; - $max = $itm['sv_yron_max'] + $itm['yron_max'] + $st['maxAtack']; - } - return [$min, $max]; - } - - - //Расчет защиты - public function zago($v): float - { - if ($v > 1700) { - $v = 1700; - } - return round((1 - (pow(0.5, ($v / 399.51)))) * 100, 2); - } - - //Расчет защиты (магия) - public function zmgo($v) - { - return (1 - (pow(0.5, ($v / 250)))) * 100; - } - public function yrn( $st1, @@ -8271,7 +7311,8 @@ class Battle $ozashitam = null, $wp_type, $witm - ): array { + ): array + { global $u; //Поправка @@ -8477,587 +7518,1775 @@ class Battle return $r; } - public $pr_not_use = [], $pr_reset = [], $pr_yrn = false, $prnt = []; - public $del_val = [], $re_pd = []; + //Расчет урона от оружия - public function delPriem( - $pl, - $u1, - $t = 1, - $u2 = false, - $rznm = 'Очиститься Кровью', - $k2nm = null, - $yrn = null, - $yrnt = null - ) { - global $u, $priem; - if (!isset($pl['priem']['id']) || isset($this->del_val['eff'][$pl['priem']['id']])) { - return; + public function zago($v): float + { + if ($v > 1700) { + $v = 1700; } - if ($pl['x'] > 1) { - $pl['name'] = $pl['name'] . ' x' . $pl['x'] . ''; - } - if ($pl['timeUse'] == 77) { - //завершаем прием - mysql_query('DELETE FROM `eff_users` WHERE `id` = "' . $pl['id'] . '" LIMIT 1'); - } - $vLog = 'time1=' . time() . '||s1=' . $u1['sex'] . '||t1=' . $u1['team'] . '||login1=' . $u1['login'] . ''; - if (isset($u2['id'])) { - $vLog .= '||s2=' . $u2['sex'] . '||t2=' . $u2['team'] . '||login2=' . $u2['login'] . ''; - } - $mas1 = [ - 'time' => time(), - 'battle' => $this->info['id'], - 'id_hod' => $this->hodID, - 'text' => '', - 'vars' => $vLog, - 'zona1' => '', - 'zonb1' => '', - 'zona2' => '', - 'zonb2' => '', - 'type' => '1', - ]; - if ($t == 4) { - $mas1['id_hod']++; - $t = 2; - } - if ($t == 1) { - $mas1['id_hod']++; - if ($pl['priem']['file'] != '0') { - if (file_exists('../../_incl_data/class/priems/' . $pl['priem']['file'] . '.php')) { - require('priems/' . $pl['priem']['file'] . '.php'); - } - } elseif ($pl['priem']['file3'] != '0') { - if (file_exists('../../_incl_data/class/priems/' . $pl['priem']['file3'] . '.php')) { - require('priems/' . $pl['priem']['file3'] . '.php'); - } + return round((1 - (pow(0.5, ($v / 399.51)))) * 100, 2); + } + + + //Расчет защиты + + public function zmgo($v) + { + return (1 - (pow(0.5, ($v / 250)))) * 100; + } + + //Расчет защиты (магия) + + public function priemsTestRazmen($id, $at) + { + $uid1 = $this->atacks[$id]['uid1']; + $uid2 = $this->atacks[$id]['uid2']; + + $i = 1; + while ($i <= 2) { + if ($i == 1) { + $a = 1; + $b = 2; + $u1 = ${'uid1'}; + $u2 = ${'uid2'}; } else { - $mas1['text'] = '{tm1} {u1} {1x16x0} прием "' . $pl['name'] . '".'; - $this->del_val['eff'][$pl['priem']['id']] = true; + $a = 2; + $b = 1; + $u1 = ${'uid2'}; + $u2 = ${'uid1'}; } - } elseif ($t == 2) { - $mas1['text'] = '{tm1} У персонажа {u1} закончилось действие магии "' . $pl['name'] . '".'; - } elseif ($t == 99) { - $mas1['text'] = '{u1} Снял эфект "' . $pl['name'] . '" с помощью ' . $rznm . ' .'; - } else { - if ($t == 100) { - $mas1['id_hod']++; + + if (!isset($at['p']['p_cast'])) { + $at['p'] = $at; + $at['p']['p_cast'] = true; } - $mas1['text'] = '{tm1} Закончилось действие эффекта "' . $pl['name'] . '" для {u1}.'; + + //ставка + + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][1] == 220 || $this->stats[$this->uids[$u1]]['u_priem'][$j][1] == 237 + || $this->stats[$this->uids[$u1]]['u_priem'][$j][1] == 286 || $this->stats[$this->uids[$u1]]['u_priem'][$j][1] == 287 || $this->stats[$this->uids[$u1]]['u_priem'][$j][1] == 288 + || $this->stats[$this->uids[$u1]]['u_priem'][$j][1] == 213) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + } + } + $j++; + } + + //Приемы ухода от удара + if (!isset($this->stats[$this->uids[$u2]]['nopryh']) || $this->stats[$this->uids[$u2]]['nopryh'] == 0) { + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 1) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + $this->stats[$this->uids[$u2]]['nopryh']--; + } + } + $j++; + } + } + //Приемы крита + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 2) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + } + } + $j++; + } + + //Приемы атаки + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 3) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + if (isset($fx_priem)) { + $at = $fx_priem($id, $at, $u1, $j); + } + unset(${'fx_priem'}); + } + } + $j++; + } + + //Приемы защиты + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 4) { + if (!$this->testPriemVarTrueZash( + $i, 3, $this->stats[$this->uids[$u1]]['u_priem'][$j][1], $a, $b, + $u1, $u2 + )) { + } elseif (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + if (isset($fx_priem)) { + $at = $fx_priem($id, $at, $u1, $j); + } + unset(${'fx_priem'}); + } + } + $j++; + } + + //Прочие приемы + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 5) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + if (isset($fx_priem)) { + $at = $fx_priem($id, $at, $u1, $j); + } + unset(${'fx_priem'}); + } + } + $j++; + } + $i++; } - if ($pl['priem']['id'] != 24) { - $this->add_log($mas1); + + $i = 1; + while ($i <= 2) { + if ($i == 1) { + $a = 1; + $b = 2; + $u1 = ${'uid1'}; + $u2 = ${'uid2'}; + } else { + $a = 2; + $b = 1; + $u1 = ${'uid2'}; + $u2 = ${'uid1'}; + } + + if (!isset($at['p']['p_cast'])) { + $at['p'] = $at; + $at['p']['p_cast'] = true; + } + + //Прочие приемы + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 8) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + } + } + $j++; + } + + //Прочие приемы + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 9) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + } + } + $j++; + } + $i++; + } + return $at; + } + + public function priemsRestartRazmen($id, $at) + { + if (isset($at['p'])) { + //Проверка + $uid1 = $this->atacks[$id]['uid1']; + $uid2 = $this->atacks[$id]['uid2']; + /* + Если возникнут проблемы с приемами, придется переписать алгоритм, сейчас он выглядит так: + Цикл 1. Проверяем пользователя + Цикл 2 внутри Цикла 1. Проверяем приемы поторые пользователь использовал + Придется сделать: + Цикл 1. Проверяем пользователя + Цикл 2 внутри Цикла 1. Проверяем приемы уворота + Цикл 3. Проверяем пользователя + Цикл 4 внутри Цикла 3. Проверяем приемы крита + и т.д. + */ + $i = 1; + while ($i <= 2) { + if ($i == 1) { + $a = 1; + $b = 2; + $u1 = ${'uid1'}; + $u2 = ${'uid2'}; + } else { + $a = 2; + $b = 1; + $u1 = ${'uid2'}; + $u2 = ${'uid1'}; + } + + if (!isset($at['p']['p_cast'])) { + $at['p'] = $at; + $at['p']['p_cast'] = true; + } + + //Приемы ухода от удара + if (!isset($this->stats[$this->uids[$u2]]['nopryh']) || $this->stats[$this->uids[$u2]]['nopryh'] == 0) { + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 1) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_tested_this = $u1; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + $this->stats[$this->uids[$u2]]['nopryh']--; + } + } + $j++; + } + } + //Приемы крита + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 2) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_tested_this = $u1; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + } + } + $j++; + } + //Приемы защиты + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 4) { + if ($this->testPriemVarTrueZash( + $i, 4, $this->stats[$this->uids[$u1]]['u_priem'][$j][1], $a, $b, + $u1, $u2 + ) == false) { + } elseif (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_tested_this = $u1; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + } + } + $j++; + } + //Приемы атаки + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 3) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_tested_this = $u1; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + } + } + $j++; + } + //Прочие приемы + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][4] == 5) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_tested_this = $u1; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + } + } + $j++; + } + //Прочие приемы + $j = 0; + while ($j <= count($this->stats[$this->uids[$u2]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u2]]['u_priem'][$j][4] == 8) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u2]]['u_priem'][$j][1] . '.php' + )) { + $pr_tested_this = $u2; + require('priem/' . $this->stats[$this->uids[$u2]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u2, $j); + unset(${'fx_priem'}); + } + } + $j++; + } + //Прочие приемы + $j = 0; + while ($j <= count($this->stats[$this->uids[$u2]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u2]]['u_priem'][$j][4] == 9) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u2]]['u_priem'][$j][1] . '.php' + )) { + $pr_tested_this = $u2; + require('priem/' . $this->stats[$this->uids[$u2]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u2, $j); + unset(${'fx_priem'}); + } + } + $j++; + } + + $i++; + } + $at = $at['p']; + unset($at['p']); + } + return $at; + } + + public function testPogB($uid, $yr, $pliid, $test = 0) + { + $yr2 = $yr; + $checktuman = mysql_fetch_array( + mysql_query( + 'SELECT * FROM `eff_users` WHERE `uid` = "' . $uid . '" + AND (`v2` = 273 OR `v2` = 286 OR `v2` = 287 OR `v2` = 288) + AND `delete` =0 LIMIT 1' + ) + ); //проверка на туманный образ + if ($yr > 0 && !isset($checktuman['id'])) { + $testmana = false; + global $u, $priem; + $i = 0; + $ypg22 = 0; + while ($i < count($this->stats[$this->uids[$uid]]['set_pog2'])) { + $j = $this->stats[$this->uids[$uid]]['set_pog2'][$i]; + if ($this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['id'] == $pliid || $test == 1) { + $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['data'] = str_replace( + 'add_pog2=' . $j['y'], + 'add_pog2=$', $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['data'] + ); + $dt3 = ConversionHelper::dataStringToArray($this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['data']); + $dt30 = 0; + $dt30 = floor($j['y'] / $yr2 * 100); + if ($dt30 < $dt3['add_pog2p']) { + $dt3['add_pog2p'] = $dt30; + } + unset($dt30); + if (isset($dt3['add_pog2mp'])) { + if ((round( + round($yr2 / 100 * (100 - $dt3['add_pog2p'])) * $dt3['add_pog2mp'] + )) > $this->stats[$this->uids[$uid]]['mpNow']) { + //не хватило маны, считаем сколько хватит % от поглощенного урона + $j['yhj'] = $this->stats[$this->uids[$uid]]['mpNow'] / (round( + round($yr2 / 100 * (100 - $dt3['add_pog2p'])) * $dt3['add_pog2mp'] + )) * 100; + $j['yhj'] = floor($j['yhj']); //Сколько % мы можем поглотить + $dt3['add_pog2p'] = floor($dt3['add_pog2p'] / 100 * $j['yhj']); + } + if ($test == 1) { + $priem->minMana($uid, round(round($yr2 / 100 * $dt3['add_pog2p']) * $dt3['add_pog2mp'])); + } + } + if (!isset($this->poglast[$uid])) { + $this->poglast[$uid] = 0; + } + $this->poglast[$uid] += $yr2; + if ($test == 1) { + //$j['y'] -= $this->poglast[$uid]; // осталось для поглощения + $j['y'] -= round($this->poglast[$uid] / 100 * $dt3['add_pog2p']); + $priem->minMana( + $uid, + round(round($this->poglast[$uid] / 100 * $dt3['add_pog2p']) * $dt3['add_pog2mp']) + ); + } + if (isset($dt3['add_pog2p'])) { + $yr2 = round($yr2 / 100 * (100 - $dt3['add_pog2p'])); + } + if ($j['y'] < 0 || ($this->stats[$this->uids[$uid]]['mpNow'] <= 0 && $dt3['add_pog2mp'] > 0)) { + $dt2 = ConversionHelper::dataStringToArray($this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['data']); + if (isset($dt2['endPog']) && $dt2['endPog'] == 1) { + //удаляем прием + //Добавляем в лог + $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['priem'] = mysql_fetch_array( + mysql_query( + 'SELECT * FROM `priems` WHERE `id` = "' . $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['v2'] . '" LIMIT 1' + ) + ); + $this->delPriem( + $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1], + $this->users[$this->uids[$uid]], 4, $uid + ); + $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1] = 'delete'; + } + unset($dt2); + $j['y'] = 0; + } + $this->stats[$this->uids[$uid]]['set_pog'][$i]['y'] = $j['y']; + if (isset($this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['data'])) { + $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['data'] = str_replace( + 'add_pog2=$', + 'add_pog2=' . $j['y'], $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['data'] + ); + $upd = mysql_query( + 'UPDATE `eff_users` SET `data` = "' . $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['data'] . '" WHERE `id` = "' . $this->stats[$this->uids[$uid]]['effects'][$j['id'] - 1]['id'] . '" LIMIT 1' + ); + } + if ($j['y'] - $this->poglast[$uid] + $yr2 < 0) { + $yr -= $yr + ($j['y'] - $this->poglast[$uid] + $yr2); + $yr2 = $yr; + $i = count($this->stats[$this->uids[$uid]]['set_pog2']) + 1; + } + } + $i++; + } + } + unset($checktuman); + return $yr2; + } + + public function updateHealth($id, $at): array + { + $uid1 = $this->atacks[$id]['uid1']; + $uid2 = $this->atacks[$id]['uid2']; + + if ($this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] > 0) { + $uid1 = $this->yhod_user( + $this->atacks[$id]['uid2'], $this->atacks[$id]['uid1'], + $this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] + ); + } elseif ($this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] > 0) { + $uid2 = $this->yhod_user( + $this->atacks[$id]['uid1'], $this->atacks[$id]['uid2'], + $this->stats[$this->uids[$this->atacks[$id]['uid2']]]['yhod'] + ); + } + + $i = 1; + while ($i <= 2) { + if ($i == 1) { + $a = 1; + $b = 2; + $u1 = ${'uid1'}; + $u2 = ${'uid2'}; + } else { + $a = 2; + $b = 1; + $u1 = ${'uid2'}; + $u2 = ${'uid1'}; + } + + //Рассчет дополнительных тактик + if ($this->atacks[$id]['out' . $b] > 0) { + //Игрок ${'u'.$a} получает тактики, возможно + if (rand(0, 100) < min(floor($this->stats[$this->uids[$u1]]['m6'] / 5), 20)) { + //выдаем тактику контрудара + if ($this->stats[$this->uids[$u2]]['this_animal'] == 0) { + $this->users[$this->uids[$u1]]['tactic3']++; + } + } + if (rand(0, 100) < min(floor($this->stats[$this->uids[$u1]]['m8'] / 4), 20)) { + //выдаем тактику щита + if ($this->stats[$this->uids[$u2]]['this_animal'] == 0) { + $this->users[$this->uids[$u1]]['tactic4']++; + } + } + } + + //Расчет удара Цели (u2) по Атакующему (u1) + $j = 0; + $k = 0; + $wp = 3; + while ($j < count($at[$a]['atack']) && $j < 8) { + //Добавляем тактики + if ($at[$a]['atack'][$j][1] == 1) { + //u1 ударил обычным ударом u2 + if ($this->stats[$this->uids[$u2]]['this_animal'] == 0) { + $this->users[$this->uids[$u1]]['tactic1']++; + } + //Двуручка + if ($at[$a]['atack'][$j]['yron']['2h'] == 1 && $this->stats[$this->uids[$u2]]['this_animal'] == 0) { + $this->users[$this->uids[$u1]]['tactic1'] += 2; + } + } elseif ($at[$a]['atack'][$j][1] != 2) { + if ($at[$a]['atack'][$j][1] == 3) { + //u2 заблокировал удар u1 + if ($this->stats[$this->uids[$u2]]['this_animal'] == 0) { + $this->users[$this->uids[$u2]]['tactic4']++; + } + } elseif ($at[$a]['atack'][$j][1] == 4) { + //u1 пробил блок u2 критом + if (!isset($at[$a]['atack'][$j]['notactic2'])) { + if ($this->stats[$this->uids[$u2]]['this_animal'] == 0) { + $this->users[$this->uids[$u1]]['tactic2']++; + } + } + $this->users[$this->uids[$u2]]['tactic4']++; //тактика за пробив блок + } elseif ($at[$a]['atack'][$j][1] == 5) { + //u1 ударил критическим ударом u2 + if (!isset($at[$a]['atack'][$j]['notactic2'])) { + if ($this->stats[$this->uids[$u2]]['this_animal'] == 0) { + $this->users[$this->uids[$u1]]['tactic2'] += 2; + } + //Двуручка + if ($at[$a]['atack'][$j]['yron']['2h'] == 1 && $this->stats[$this->uids[$u2]]['this_animal'] == 0) { + $this->users[$this->uids[$u1]]['tactic2'] += 1; + } + } + } elseif ($at[$a]['atack'][$j][1] == 6) { + //u2 парировал удар u1 + if (!isset($at[$a]['atack'][$j]['notactic5']) && $this->stats[$this->uids[$u1]]['this_animal'] == 0) { + $this->users[$this->uids[$u2]]['tactic5']++; + } + } elseif ($at[$a]['atack'][$j][1] == 7) { + //u2 блокировал щитом удар u1 //ТУТ ЩИТ + if ($this->stats[$this->uids[$u2]]['this_animal'] == 0) { + $this->users[$this->uids[$u2]]['tactic4']++; + } + } elseif ($at[$a]['atack'][$j][1] == 8) { + //u2 увернулся от удара u1 и нанес по нему контрудар + if ($this->stats[$this->uids[$u1]]['this_animal'] == 0) { + $this->users[$this->uids[$u2]]['tactic3']++; + } + } + } + // КУДА БИЛ , ТИП УДАРА + if (isset($at[$a]['atack'][$j]['yron']) && ( + $at[$a]['atack'][$j][1] == 1 || + $at[$a]['atack'][$j][1] == 4 || + $at[$a]['atack'][$j][1] == 5)) { + // + + if ($this->stats[$this->uids[$u2]]['hpNow'] <= $at[$a]['atack'][$j]['yron']['y']) { + $at[$a]['atack'][$j]['yron']['y'] = $this->stats[$this->uids[$u2]]['hpNow']; + } + if ($this->stats[$this->uids[$u2]]['hpNow'] <= $at[$a]['atack'][$j]['yron']['k']) { + $at[$a]['atack'][$j]['yron']['k'] = $this->stats[$this->uids[$u2]]['hpNow']; + } + + if ($at[$a]['atack'][$j]['yron']['y'] < 0) { + $at[$a]['atack'][$j]['yron']['y'] = 1; + $at[$a]['atack'][$j]['yron']['r'] = -1; + $at[$a]['atack'][$j]['yron']['k'] = 1; + } + if ($this->stats[$this->uids[$u2]]['hpNow'] < 1) { + $at[$a]['atack'][$j]['yron']['y'] = 0; + $at[$a]['atack'][$j]['yron']['r'] = -1; + $at[$a]['atack'][$j]['yron']['k'] = 0; + } + + //Добавляем нанесенный урон и опыт + $this->takeExp($u1, $at[$a]['atack'][$j]['yron']['y'], $u1, $u2); + //Отнимаем НР + $this->stats[$this->uids[$u2]]['hpNow'] -= $at[$a]['atack'][$j]['yron']['y']; + $this->users[$this->uids[$u2]]['last_hp'] = -$at[$a]['atack'][$j]['yron']['y']; + $at[$a]['atack'][$j]['yron']['hp'] = $this->stats[$this->uids[$u2]]['hpNow']; + if ($at[$a]['atack'][$j]['yron']['hp'] < 1) { + $at[$a]['atack'][$j]['yron']['hp'] = 0; + } + $at[$a]['atack'][$j]['yron']['hpAll'] = $this->stats[$this->uids[$u2]]['hpAll']; + if ($at[$a]['atack'][$j]['yron']['hp'] > $at[$a]['atack'][$j]['yron']['hpAll']) { + $at[$a]['atack'][$j]['yron']['hp'] = $at[$a]['atack'][$j]['yron']['hpAll']; + } + //Травмирование + if (rand(0, 100) <= 50) { + if ($at[$a]['atack'][$j][1] == 4 || $at[$a]['atack'][$j][1] == 5) { + if (!isset($at[$a]['atack'][$j]['yron']['travma']) && rand( + 0, + 1000 + ) < 500 && $this->users[$this->uids[$u2]]['level'] > 1 && $this->stats[$this->uids[$u1]] > 1) { + $trvm_chns = floor(rand(0, 200) / 10); + if ($trvm_chns > 3 || $trvm_chns < 1) { + $trvm_chns = 0; + } + $at[$a]['atack'][$j]['yron']['travma'] = [$trvm_chns, 'Обыкновенная травма']; + unset($trvm_chns); + } + } + } + } + $j++; + } + $i++; + } + return $at; + } + + /** + * Добавляем опыт \ нанесенный урон. + * Кривовсрато, на переделку. + * @param $id + * @param $y + * @param $id1 + * @param $id2 + * @param $mgregen + * @param $nobattle_uron + * @return void + */ + public function takeExp($id, $y, $id1, $id2, $mgregen = false, $nobattle_uron = false) + { + global $u; + if (isset($this->users[$this->uids[$id]])) { + $s1 = $this->stats[$this->uids[$id1]]; + $s2 = $this->stats[$this->uids[$id2]]; + if ($id1 != $id2) { + $e = $this->testExp($y, $s2); + } else { + $e = 0; + } + + if ((int)$this->users[$this->uids[$id1]]['bot_id'] == 0 && $this->users[$this->uids[$id1]]['dnow'] != 0 && $this->info['dungeon'] != 1) { + $dun_limitForLevel = [ // Максимум для каждого уровня. + 4 => 750, + 5 => 1500, + 6 => 3500, + 7 => 8000, + 8 => 25000, + 9 => 50000, + 10 => 75000, + 11 => 125000, + 12 => 250000, + 13 => 500000, + 14 => 750000, + ]; + $dun_expFactor = [ // Максимум для каждого уровня. + 4 => 5, + 5 => 5, + 6 => 5, + 7 => 5, + 8 => 5, + 9 => 3, + 10 => 1, + 11 => 1, + 12 => 1, + 13 => 1, + 14 => 1, + ]; + + if (isset($dun_expFactor[(int)$this->users[$this->uids[$id1]]['level']])) { + $e = $e * $dun_expFactor[(int)$this->users[$this->uids[$id1]]['level']]; + } + if ($this->info['dungeon'] > 1 && $this->users[$this->uids[$id1]]['battle'] > 0) { // пещерный лимит + $dun_exp = []; // Текущий лимит опыта игрока в подземельях. + $rep = Db::getValue( + 'select dungeonexp from rep where id = ?', [$this->users[$this->uids[$id1]]['id']] + ); + $rep = explode(',', $rep); + foreach ($rep as $key => $val) { + $val = explode('=', $val); + if (isset($val[0]) && isset($val[1]) && $val[0] != '' && $val[1] != 0) { + $dun_exp[(int)$val[0]] = (int)$val[1]; + } // текущий лимит опыта в подземке + } + unset($rep); + + if (!isset($dun_exp[$this->info['dungeon']])) { + $dun_exp[$this->info['dungeon']] = 0; + } + if (!isset($dun_limitForLevel[(int)$this->users[$this->uids[$id1]]['level']])) { // Если лимит не задан, опыт не даем. + $e = 0; + } elseif ( + isset($dun_exp[$this->info['dungeon']]) && + $dun_exp[$this->info['dungeon']] >= $dun_limitForLevel[(int)$this->users[$this->uids[$id1]]['level']] + ) { // Если лимит уже достигнут, опыт не даем. + $e = 0; + } elseif ( + isset($dun_exp[$this->info['dungeon']]) && + $dun_limitForLevel[(int)$this->users[$this->uids[$id1]]['level']] > $dun_exp[$this->info['dungeon']] + ) { // Если текущая репутация не достигла лимита. + if (($dun_exp[$this->info['dungeon']] + $e) > $dun_limitForLevel[(int)$this->users[$this->uids[$id1]]['level']]) { + // Если опыта набрано достаточно, для достижения лимита. + $e = abs( + $e - abs( + $dun_limitForLevel[(int)$this->users[$this->uids[$id1]]['level']] - ($e + $dun_exp[$this->info['dungeon']]) + ) + ); + $dun_exp[$this->info['dungeon']] += $e; + } elseif ($dun_limitForLevel[(int)$this->users[$this->uids[$id1]]['level']] > ($dun_exp[$this->info['dungeon']] + $e)) { + // Если опыта недостаточно, для достижения лимита. + $dun_exp[$this->info['dungeon']] += $e; + } else { + $e = 0; + } + } else { // В любой непонятной ситуцаии. + $e = 0; + } + } + // Опыт в пещерах. + if ($this->info['dungeon'] == 102) { + $e = floor($e * 0.002); + } + } + + $this->users[$this->uids[$id1]]['battle_exp'] += floor($e); + if (!$mgregen && !$nobattle_uron) { + $this->users[$this->uids[$id1]]['battle_yron'] += floor($y); + if ($this->stats[$this->uids[$id1]]['notactic'] != 1) { + if ($s2['hpAll'] <= 1000) { + if ($this->stats[$this->uids[$id2]]['this_animal'] == 0) { + $this->users[$this->uids[$id1]]['tactic6'] += round( + 0.1 * (floor($y) / $s2['hpAll'] * 100), + 10 + ); + } else { + $this->users[$this->uids[$id1]]['tactic6'] += round( + 0.1 * (floor($y) / $s2['hpAll'] * 100), + 10 + ) / 3; + } + } else { + if ($this->stats[$this->uids[$id2]]['this_animal'] == 0) { + $this->users[$this->uids[$id1]]['tactic6'] += round(0.1 * (floor($y) / 1000 * 100), 10); + } else { + $this->users[$this->uids[$id1]]['tactic6'] += round(0.1 * (floor($y) / 1000 * 100), 10) / 3; + } + } + } + } + + Db::sql( + 'update stats set last_hp = ?, tactic6 = ?, battle_yron = ?, battle_exp = ? where id = ?', [ + $this->users[$this->uids[$id1]]['last_hp'], + $this->users[$this->uids[$id1]]['tactic6'], + $this->users[$this->uids[$id1]]['battle_yron'], + $this->users[$this->uids[$id1]]['battle_exp'], + (int)$id1, + ] + ); + + $this->stats[$this->uids[$id1]]['battle_exp'] = $this->users[$this->uids[$id1]]['battle_exp']; + $this->clearСache($id1); + $this->stats[$this->uids[$id1]]['tactic6'] = $this->users[$this->uids[$id1]]['tactic6']; + if ($id1 == $u->info['id']) { + $u->info['tactic6'] = $this->users[$this->uids[$id1]]['tactic6']; + $u->stats['tactic6'] = $this->users[$this->uids[$id1]]['tactic6']; + $u->info['battle_exp'] = $this->users[$this->uids[$id1]]['battle_exp']; + $u->info['battle_yron'] = $this->users[$this->uids[$id1]]['battle_yron']; + $u->info['notactic'] = $this->users[$this->uids[$id1]]['notactic']; + $u->stats['notactic'] = $this->users[$this->uids[$id1]]['notactic']; + } + + } - $this->stats[$this->uids[$pl['uid']]] = $u->getStats($pl['uid'], 0, 0, false, false, true); } //Расчет мф. (новая) - public function form_mf($u, $au): float + + /** + * Расчет опыта + * @param $y + * @param $s2 + * @return int + */ + private function testExp($y, $s2): int { - $v = $u * 5.1 - $au * 5.1; - if ($v < 0) { - $v = 0; + if ($s2['levels'] == 'undefined' || $this->users[$this->uids[$s2['id']]]['pass'] == 'saintlucia') { + return 0; } - $r = (1 - (pow(99 / 100, (($v) / 100)))) * 100; - return round($r); + + $y = max(0, (int)$y); + $expmultiplier = 1; + if ($this->users[$this->uids[$s2['id']]]['level'] >= 8) { + $expmultiplier = $this->users[$this->uids[$s2['id']]]['level'] - 5; + } + + if ($s2['hpNow'] < 0) { + $y = 0; + } + if ($s2['hpNow'] < $y) { + $y = max(0, $s2['hpNow']); + } + $addExp = $y * $expmultiplier; + if ($s2['hpAll'] - $y <= 0) { + $addExp = 100; + } + + if ($this->info['razdel'] != 5 && Config::get('exp_limit_many')) { + $texp = Db::getValue( + 'select count(*) from battle_users as a where uid = ? and battle in (select battle from battle_users where uid = ? and team != a.team and time_enter > unix_timestamp() - 86400)' + ); + // + if ($texp > 5) { + $addExp = 0; + } elseif ($texp > 4) { + $addExp = $addExp * 0.50; + } elseif ($texp > 3) { + $addExp = $addExp * 0.75; + } elseif ($texp > 2) { + $addExp = $addExp * 1.00; + } elseif ($texp > 1) { + $addExp = $addExp * 1.00; + } else { + $addExp = $addExp * 1.00; + } + } + return (int)round($addExp); } //Расчет МФ - public function mfs($type, $mf, $lvl1, $lvl2): int - { - $rval = 0; - switch ($type) { - case 1: - //Крит - if ($mf['amf'] < 0) { - $mf['amf'] = 0; - } - if ($mf['mf'] < 0) { - $mf['mf'] = 0; - } - if ($mf['mf'] > $mf['smf']) { - $rval = 100 - floor(((($mf['smf']) / ($mf['mf'] + 1)) * 100)); - } - if ($rval < 1) { - $rval = 0; - } - if ($rval > 75) { - $rval = 75; - } - if ($mf['amf'] >= 1) { - if ($mf['amf'] > 100) { - $mf['amf'] = 100; - } - if (($mf['amf'] * 100) >= mt_rand(1, 10000)) { - $rval = 100; - } - } - break; - case 2: - if ($mf['mf'] < 0) { - $mf['mf'] = 0; - } - if ($mf['amf'] < 0) { - $mf['amf'] = 0; - } - if ($mf['smf'] < 0) { - $mf['smf'] = 0; - } - if ($mf['asmf'] < 0) { - $mf['asmf'] = 0; - } - if ($mf['mf'] > $mf['smf']) { - $rval = 100 - floor(((($mf['smf']) / ($mf['mf'] + 1)) * 100)); //2.5 - } - if ($rval < 1) { - $rval = 0; - } - if ($rval > 75) { - $rval = 75; - } - if ($mf['asmf'] >= 0) { - if ($mf['asmf'] > 100) { - $mf['asmf'] = 100; - } - if ($mf['asmf'] >= rand(1, 100)) { - $rval = 0; - } - } - if ($mf['amf'] >= 0) { - if ($mf['amf'] > 100) { - $mf['amf'] = 100; - } - if ($mf['amf'] >= rand(1, 100)) { - $rval = 100; - } - } - break; - case 3: - if ($mf[1] < 1) { - $mf[1] = 1; - } - if ($mf[2] < 1) { - $mf[2] = 1; - } - $rval = $mf[1] - $mf[2] / 2; - if ($rval > 75) { - $rval = 75; - } - if ($rval < 1) { - $rval = 1; - } - break; - case 4: - $mf = round($mf * 0.6); - if ($mf < 1) { - $mf = 0; - } - if ($mf > 100) { - $mf = 100; - } - $rval = min($mf, 100); //пробой брони - break; - case 5: - if ($mf < 1) { - $mf = 0; - } - $rval = min($mf, 85); //блок щитом - break; - case 6: - //Контрудар - if ($mf['a'] > 0) { - if ($mf['b'] > 0) { - $rval = round($mf['a'] - ($mf['b'] / 2)); - } else { - $rval = $mf['a']; - } - } - if ($rval < 1) { - $rval = 0; - } - if ($rval > 75) { - $rval = 75; - } - break; + private function clearСache($uid) + { + if ($uid > 0 && !isset($this->uclearc[$uid])) { + $this->uclearc[$uid] = true; + $this->ucleari[] = $uid; } - return $this->get_chanse($rval) ? 1 : 0; } - public function dodge($a, $b): bool + public function addlogRazmen($id, $at): bool { - $i = 0; - $arr = []; //массив для записи уникальных случайных чисел - while ($i < ($b - $a)) { - while (in_array($rand, $arr)) { - $rand = mt_rand(1, 100); + global $u; + + $r = ''; + + $uid1 = $this->atacks[$id]['uid1']; + $uid2 = $this->atacks[$id]['uid2']; + + $this->hodID++; + + $dies = [ + 1 => 0, + 2 => 0, + ]; + + //массив для статистики + $stat = [ + 1 => [ + 'uid1' => 0, + 'uid2' => 0, + 'time' => time(), + 'type' => 0, + 'a' => '00000', + 'b' => '0', + 'type_a' => '', + 'type_b' => '0', + 'yrn' => 0, + 'yrn_krit' => 0, + 'ma' => 0, + 'mb' => 0, + 'tm1' => 0, + 'tm2' => 0, + ], + 2 => [ + 'uid1' => 0, + 'uid2' => 0, + 'time' => time(), + 'type' => 0, + 'a' => '00000', + 'b' => '0', + 'type_a' => '', + 'type_b' => '0', + 'yrn' => 0, + 'yrn_krit' => 0, + 'ma' => 0, + 'mb' => 0, + 'tm1' => 0, + 'tm2' => 0, + ], + ]; + + + $i = 1; + while ($i <= 2) { + if ($i == 1) { + $a = 1; + $b = 2; + $u1 = ${'uid1'}; + $u2 = ${'uid2'}; + } else { + $a = 2; + $b = 1; + $u1 = ${'uid2'}; + $u2 = ${'uid1'}; + } + + if ($this->stats[$this->uids[$u1]]['yhod'] <= 0 && $this->stats[$this->uids[$u2]]['yhod'] > 0) { + $u2 = $this->yhod_user($u1, $u2, $this->stats[$this->uids[$u2]]['yhod']); + } + + $s1 = $this->users[$this->uids[$u1]]['sex']; + $s2 = $this->users[$this->uids[$u2]]['sex']; + + $stat[$a]['uid1'] = $u1; + $stat[$a]['uid2'] = $u2; + $stat[$a]['ma'] = $this->stats[$this->uids[$u1]]['zona']; + $stat[$a]['mb'] = $this->stats[$this->uids[$u1]]['zonb']; + $stat[$a]['tm1'] = $this->users[$this->uids[$u1]]['team']; + $stat[$a]['tm2'] = $this->users[$this->uids[$u2]]['team']; + $stat[$a]['a'] = $this->atacks[$id]['a' . $a]; + $stat[$a]['b'] = $this->atacks[$id]['b' . $a]; + + $vLog = 'at1=00000||at2=00000||zb1=' . $this->stats[$this->uids[$u1]]['zonb'] . '||zb2=' . $this->stats[$this->uids[$u2]]['zonb'] . '||bl1=' . $this->atacks[$id]['b' . $a] . '||bl2=' . $this->atacks[$id]['b' . $b] . '||time1=' . $this->atacks[$id]['time'] . '||time2=' . $this->atacks[$id]['time2'] . '||s' . $a . '=' . $s1 . '||s' . $b . '=' . $s2 . '||t2=' . $this->users[$this->uids[$u2]]['team'] . '||t1=' . $this->users[$this->uids[$u1]]['team'] . '||login1=' . $this->users[$this->uids[$u1]]['login2'] . '||login2=' . $this->users[$this->uids[$u2]]['login2'] . ''; + + $mas = [ + 'text' => '', + 'time' => time(), + 'vars' => '', + 'battle' => $this->info['id'], + 'id_hod' => $this->hodID, + 'vars' => $vLog, + 'type' => 1, + ]; + + if (!isset($at[$a]['atack'])) { //ТУТ тест пропуска + if ($this->atacks[$id]['tpo' . $a] == 2) { + $mas['text'] .= '{u1} потратил свой ход на магию.'; + } else { + // + if ($this->info['razdel'] == 0 && $this->info['dn_id'] == 0 && $this->info['izlom'] == 0) { + mysql_query( + 'INSERT INTO `battle_out` (`battle`,`uid1`,`uid2`,`time`,`out`) VALUES ( + "' . $this->info['id'] . '","' . $u1 . '","' . $u2 . '","' . time() . '","1" + )' + ); + } + // + if (isset($u1)) { + $mas['text'] .= '{u1} пропустил свой ход.'; + //Проверка сброс туманок + mysql_query( + 'UPDATE `eff_users` SET `delete` = "' . time() . '" WHERE `uid` = "' . $u1 . '" AND `delete` = 0 AND `v1` = "priem" AND (`v2`=288 OR `v2`=287 OR `v2`=286 OR `v2`=273) LIMIT 1' + ); + } + } + $mas['text'] = '{tm1} ' . $mas['text']; + $this->add_log($mas); + } else { + $j = 0; + while ($j < count($at[$a]['atack']) && $j < 8) { + // + $mas['text'] = ''; + // + $wt = [ + 21 => 4, + 22 => 5, + 20 => 2, + 28 => 2, + 19 => 3, + 18 => 1, + 26 => 22, + ]; + $par = [ + 'zona' => '{zn2_' . $at[$a]['atack'][$j][0] . '} ', + 'kyda' => $this->lg_zon[$at[$a]['atack'][$j][0]][rand( + 0, + (count($this->lg_zon[$at[$a]['atack'][$j][0]]) - 1) + )], + 'chem' => $this->lg_itm[$wt[$at[$a]['atack'][$j]['wt']]][rand( + 0, + (count($this->lg_itm[$wt[$at[$a]['atack'][$j]['wt']]]) - 1) + )], + ]; + // + $this->atacks[$id]['uid_' . $u1 . '_t' . $at[$a]['atack'][$j][1]]++; + // + // + $this->asr($u1, $u2, $at[$a]['atack'][$j][1]); + // + if ($at[$a]['atack'][$j][1] == 1) { + //u1 ударил обычным ударом u2 + $mas['text'] .= $par['zona'] . '{u2} ' . $this->addlt($b, 1, $s2, null) . '' . $this->addlt( + $b, + 2, $s2, null + ) . '' . $this->addlt($a, 3, $s1, null) . ' {u1} ' . $this->addlt( + $a, 4, + $s1, null + ) . '' . $this->addlt($a, 5, $s1, null) . '' . $this->addlt( + $a, 6, $s1, + null + ) . ' ' . $this->addlt( + 1, 7, $s1, + $at[$a]['atack'][$j]['yron']['t'] + ) . ' ' . $par['chem'] . ' ' . $par['kyda'] . '. '; + } elseif ($at[$a]['atack'][$j][1] == 2) { + //u2 увернулся от u1 + $mas['text'] .= $par['zona'] . '{u1} ' . $this->addlt($a, 8, $s1, null) . '' . $this->addlt( + $a, + 9, $s1, null + ) . ' {u2} ' . $this->addlt( + $b, 11, $s2, + null + ) . ' ' . $par['chem'] . ' ' . $par['kyda'] . '. '; + } elseif ($at[$a]['atack'][$j][1] == 3) { + //u2 заблокировал удар u1 + $mas['text'] .= $par['zona'] . '{u1} ' . $this->addlt($a, 8, $s1, null) . '' . $this->addlt( + $a, + 9, $s1, null + ) . ' {u2} ' . $this->addlt( + $b, 10, $s2, + null + ) . ' ' . $this->addlt( + 1, 7, 0, $s1, + $at[$a]['atack'][$j]['yron']['t'] + ) . ' ' . $par['chem'] . ' ' . $par['kyda'] . '. '; + } elseif ($at[$a]['atack'][$j][1] == 4) { + //u1 пробил блок u2 критом + if (isset($at[$a]['atack'][$j]['yron']['t'])) { + $mas['text'] .= $par['zona'] . '{u2} ' . $this->addlt( + $b, 1, $s2, + null + ) . '' . $this->addlt($b, 2, $s2, null) . '' . $this->addlt( + $a, 3, $s1, + null + ) . ' {u1} ' . $this->addlt($a, 4, $s1, null) . '' . $this->addlt( + $a, 5, $s1, + null + ) . ', пробив блок, ' . $this->addlt( + $a, 6, $s1, + null + ) . ' ' . $this->addlt( + 1, 7, $s1, + $at[$a]['atack'][$j]['yron']['t'] + ) . ' ' . $par['chem'] . ' ' . $par['kyda'] . '. '; + } + } elseif ($at[$a]['atack'][$j][1] == 5) { + //u1 ударил критическим ударом u2 + $mas['text'] .= $par['zona'] . '{u2} ' . $this->addlt($b, 1, $s2, null) . '' . $this->addlt( + $b, + 2, $s2, null + ) . '' . $this->addlt($a, 3, $s1, null) . ' {u1} ' . $this->addlt( + $a, 4, + $s1, null + ) . '' . $this->addlt($a, 5, $s1, null) . '' . $this->addlt( + $a, 6, $s1, + null + ) . ' ' . $this->addlt( + 1, 7, $s1, + $at[$a]['atack'][$j]['yron']['t'] + ) . ' ' . $par['chem'] . ' ' . $par['kyda'] . '. '; + } elseif ($at[$a]['atack'][$j][1] == 6) { + //u2 парировал удар u1 + $mas['text'] .= $par['zona'] . '{u1} ' . $this->addlt($a, 8, $s1, null) . '' . $this->addlt( + $a, + 9, $s1, + null + ) . ' {u2} неожиданно парировал ' . $this->addlt( + 1, + 7, 0, $s1, + $at[$a]['atack'][$j]['yron']['t'] + ) . ' ' . $par['chem'] . ' ' . $par['kyda'] . '. '; + } elseif ($at[$a]['atack'][$j][1] == 7) { + //u2 блокировал щитом удар u1 + $mas['text'] .= $par['zona'] . '{u1} ' . $this->addlt($a, 8, $s1, null) . '' . $this->addlt( + $a, + 9, $s1, + null + ) . ' {u2}, воспользовавшись своим щитом, ' . $this->addlt( + $b, + 10, $s2, null + ) . ' ' . $this->addlt( + 1, 7, 0, $s1, + $at[$a]['atack'][$j]['yron']['t'] + ) . ' ' . $par['chem'] . ' ' . $par['kyda'] . '. '; + } elseif ($at[$a]['atack'][$j][1] == 8) { + //u2 увернулся от удара u1 и нанес по нему контрудар + $mas['text'] .= $par['zona'] . '{u1} ' . $this->addlt($a, 8, $s1, null) . '' . $this->addlt( + $a, + 9, $s1, null + ) . ' {u2} ' . $this->addlt( + $b, 11, $s2, + null + ) . ' ' . $par['chem'] . ' ' . $par['kyda'] . ' и нанес контрудар. '; + } + + $stat[$a]['type_a'] .= '' . $at[$a]['atack'][$j][1] . ''; + if ((!isset($this->stats[$this->uids[$u2]]['notravma']) || $this->stats[$this->uids[$u2]]['notravma'] == 0) && isset($at[$a]['atack'][$j]['yron']['travma']) && $at[$a]['atack'][$j]['yron']['travma'][0] > 0 && floor( + $at[$a]['atack'][$j]['yron']['hp'] + ) <= 0) { + $tr_pl = mysql_fetch_array( + mysql_query( + 'SELECT `id`,`v1` FROM `eff_users` WHERE `id_eff` = 4 AND `uid` = "' . $u2 . '" AND `delete` = "0" ORDER BY `v1` DESC LIMIT 1' + ) + ); + if (!isset($tr_pl['id']) || $tr_pl['v1'] < 3) { + //263 + if (isset($tr_pl['id'])) { + $at[$a]['atack'][$j]['yron']['travma'][0] = rand(($tr_pl['v1'] + 1), 3); + } + $tr_pl2 = mysql_fetch_array( + mysql_query( + 'SELECT `id` FROM `eff_users` WHERE `uid` = "' . $u2 . '" AND `delete` = "0" AND `name` LIKE "%Защита от травм%" LIMIT 1' + ) + ); + if (!isset($tr_pl2['id']) && $at[$a]['atack'][$j]['yron']['travma'][0] <= 3) { + $mas['text'] = rtrim($mas['text'], '. '); + $mas['text'] .= ', нанеся противнику '; + if ($at[$a]['atack'][$j]['yron']['travma'][0] == 1) { + $mas['text'] .= 'Легкую'; + $this->addTravm($u2, 1, rand(3, 5)); + } elseif ($at[$a]['atack'][$j]['yron']['travma'][0] == 2) { + $mas['text'] .= 'Среднюю'; + $this->addTravm($u2, 2, rand(3, 5)); + } elseif ($at[$a]['atack'][$j]['yron']['travma'][0] == 3) { + $mas['text'] .= 'Тяжелую'; + $this->addTravm($u2, 3, rand(3, 5)); + } + $mas['text'] .= ' травму. '; + } + } + unset($tr_pl); + } + if ($at[$a]['atack'][$j]['yron']['pb'] == 1 && isset($at[$a]['atack'][$j]['yron']['hp'])) { + $mas['text'] = rtrim($mas['text'], '. '); + $mas['text'] .= ' пробив броню. '; + } + if ($at[$a]['atack'][$j][3] == 1) { + $mas['text'] .= '(контрудар) '; + } + if (isset($at[$a]['atack'][$j]['yron'])) { + if ($at[$a]['atack'][$j]['yron']['w'] == 3) { + $mas['textWP'] = '(правая рука)'; + } elseif ($at[$a]['atack'][$j]['yron']['w'] == 14) { + $mas['textWP'] = '(левая рука)'; + } else { + $mas['textWP'] = '(непонятно чем)'; + } + if ($at[$a]['atack'][$j][1] == 4 || $at[$a]['atack'][$j][1] == 5 || $at[$a]['atack'][$j][1] == 1) { + if ($at[$a]['atack'][$j]['yron']['y'] < 1) { + $at[$a]['atack'][$j]['yron']['r'] = '--'; + } + } + if ($at[$a]['atack'][$j][1] == 4 || $at[$a]['atack'][$j][1] == 5) { + $stat[$a]['yrn_krit'] += -$at[$a]['atack'][$j]['yron']['r']; + $mas['text'] .= ' ' . $at[$a]['atack'][$j]['yron']['r'] . ''; + } else { + $mas['text'] .= ' ' . $at[$a]['atack'][$j]['yron']['r'] . ''; + } + $stat[$a]['yrn'] += -$at[$a]['atack'][$j]['yron']['r']; + } + if (isset($at[$a]['atack'][$j]['yron']['hp'])) { + if ($this->users[$this->uids[$u2]]['align'] == 9) { + $at[$a]['atack'][$j]['yron']['hp'] = $at[$a]['atack'][$j]['yron']['hp'] / ($at[$a]['atack'][$j]['yron']['hpAll'] / 100); + $at[$a]['atack'][$j]['yron']['hpAll'] = '100%'; + } + $mas['text'] .= ' [' . floor($at[$a]['atack'][$j]['yron']['hp']) . '/' . floor( + $at[$a]['atack'][$j]['yron']['hpAll'] + ) . ']'; + } + if ($mas['text'] != '') { + $mas['text'] = '{tm1} ' . $mas['text']; + } + + if (is_array($at[$a]['atack'][$j]['yron']['plog'])) { + $il = 0; + while ($il <= count($at[$a]['atack'][$j]['yron']['plog'])) { + if (isset($at[$a]['atack'][$j]['yron']['plog'][$il])) { + eval($at[$a]['atack'][$j]['yron']['plog'][$il]); + } + $il++; + } + } + $this->add_log($mas); + $j++; + } } - $arr[] = $rand; $i++; } - $n = mt_rand(1, 100); - return (bool)array_search($n, $arr); + + //Добавляем статистику + записываем в баттл_юзерс НР игроков + $this->addNewStat($stat); + + //Вывод в лог смерти персонажа + if (floor($this->stats[$this->uids[$u1]]['hpNow']) < 1) { + $dies[1] = 1; + } + if (floor($this->stats[$this->uids[$u2]]['hpNow']) < 1) { + $dies[2] = 1; + } + if ($dies[1] > 0 || $dies[2] > 0) { + $s1 = $this->users[$this->uids[$u1]]['sex']; + $s2 = $this->users[$this->uids[$u2]]['sex']; + + $vLog = 'at1=00000||at2=00000||zb1=' . $this->stats[$this->uids[$u1]]['zonb'] . '||zb2=' . $this->stats[$this->uids[$u2]]['zonb'] . '||bl1=' . $this->atacks[$id]['b' . $a] . '||bl2=' . $this->atacks[$id]['b' . $b] . '||time1=' . $this->atacks[$id]['time'] . '||time2=' . $this->atacks[$id]['time2'] . '||s2=' . $this->users[$this->uids[$u2]]['sex'] . '||s1=' . $this->users[$this->uids[$u1]]['sex'] . '||t2=' . $this->users[$this->uids[$u2]]['team'] . '||t1=' . $this->users[$this->uids[$u1]]['team'] . '||login1=' . $this->users[$this->uids[$u1]]['login2'] . '||login2=' . $this->users[$this->uids[$u2]]['login2'] . ''; + + $mas = [ + 'text' => '', + 'time' => time(), + 'vars' => '', + 'battle' => $this->info['id'], + 'id_hod' => $this->hodID, + 'vars' => $vLog, + 'type' => 1, + ]; + + $rtngwin = [1, 2, 3, 5, 10, 20, 40, 80, 160]; + $rtnglos = [0, 0, 0, -1, -2, -5, -10, -20, -40]; + + if ($this->info['typeBattle'] == 99) { + if ($btlstatus[0] == 0) { + //Кровавые бои обычные + $rtngwin = [2, 4, 6, 10, 20, 40, 80, 160, 320]; + if ($this->info['razdel'] == 5) { + //не хаот + $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; + } else { + //хаот + $rtnglos = [0, 0, 0, 0, 0, 0, 0, 0, 0]; + } + } elseif ($btlstatus[0] == 25) { + //Кровавая битва + $rtngwin = [3, 6, 9, 15, 30, 60, 120, 240, 480]; + $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; + } elseif ($btlstatus[0] == 50) { + //Кровавая резня + $rtngwin = [4, 8, 16, 32, 64, 128, 256, 512, 1024]; + $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; + } elseif ($btlstatus[0] == 75) { + //Кровавая сеча + $rtngwin = [5, 10, 20, 40, 80, 160, 320, 640, 1280]; + $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; + } elseif ($btlstatus[0] == 100) { + //Кровавое побоище + $rtngwin = [6, 12, 24, 48, 98, 196, 392, 784, 1568]; + $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; + } elseif ($btlstatus[0] == 150) { + //Судный день + $rtngwin = [7, 14, 28, 56, 112, 224, 448, 896, 1792]; + $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; + } + } else { + if ($btlstatus[0] == 0) { + //Обычный поединок + $rtngwin = [1, 2, 3, 5, 10, 20, 40, 80, 160]; + if ($this->info['razdel'] == 5) { + //не хаот + $rtnglos = [0, 0, 0, -1, -2, -5, -10, -20, -40]; + } else { + //хаот + $rtnglos = [0, 0, 0, 0, 0, 0, 0, 0, 0]; + } + } elseif ($btlstatus[0] == 25) { + //великая битва + $rtngwin = [2, 4, 6, 10, 20, 40, 80, 160, 320]; + $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; + } elseif ($btlstatus[0] == 50) { + //величайшая битва + $rtngwin = [3, 6, 9, 15, 30, 60, 120, 240, 480]; + $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; + } elseif ($btlstatus[0] == 75) { + //историческая битва сеча + $rtngwin = [4, 8, 16, 32, 64, 128, 256, 512, 1024]; + $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; + } elseif ($btlstatus[0] == 100) { + //эпохальная битва + $rtngwin = [5, 10, 20, 40, 80, 160, 320, 640, 1280]; + $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; + } elseif ($btlstatus[0] == 150) { + //судный день + $rtngwin = [7, 14, 28, 56, 112, 224, 448, 896, 1792]; + $rtnglos = [0, 0, 0, -2, -4, -10, -20, -40, -80]; + } + } + + if ($this->info['dn_id'] > 0 || $this->info['izlom'] != 0 || $this->info['turnir'] != 0) { + //Пещерные бои не считаются и Изломы тоже, ну и Турниры + $rtngwin = [0, 0, 0, 0, 0, 0, 0, 0, 0]; + $rtnglos = [0, 0, 0, 0, 0, 0, 0, 0, 0]; + } elseif ($this->info['clan1'] > 0 && $this->info['clan2'] > 0) { + //Клановая война + $rtngwin = [3, 6, 9, 15, 30, 60, 120, 240, 480]; + $rtnglos = [-1, -2, -4, -8, -16, -32, -64, -128, -256]; + } + + + if ($dies[1] == 1) { + if ($this->info['dn_id'] <= 0 && $this->users[$this->uids[$u1]]['level'] >= 4) { + $rtng1 += $rtnglos[$this->users[$this->uids[$u1]]['level'] - 4]; + $rtng2 += $rtngwin[$this->users[$this->uids[$u1]]['level'] - 4]; + } + //Персонаж 1 погиб от рук персонаж 2 + $this->spaCheck($this->users[$this->uids[$u1]]['id']); + } + if ($dies[2] == 1) { + if ($this->info['dn_id'] <= 0 && $this->users[$this->uids[$u1]]['level'] >= 4) { + $rtng1 += $rtnglos[$this->users[$this->uids[$u1]]['level'] - 4]; + $rtng2 += $rtngwin[$this->users[$this->uids[$u1]]['level'] - 4]; + } + //Персонаж 2 погиб от рук персонаж 1 + $this->spaCheck($this->stats[$this->uids[$u2]]['id']); + } + //Записываем рейтинг + // + if ($this->info['type'] != 564 && $this->stats[$this->uids[$u1]]['inTurnir'] == 0 && $this->stats[$this->uids[$u2]]['inTurnir'] == 0 && $this->info['dn_id'] == 0 && $this->info['izlom'] == 0) { + // + if ($this->users[$this->uids[$u2]]['bot'] == 0) { + mysql_query( + 'INSERT INTO `users_reting` (`uid`,`time`,`val`,`align`,`clan`) VALUES ( + "' . $u1 . '","' . time() . '","' . $rtng1 . '","' . $this->users[$this->uids[$u1]]['align'] . '","' . $this->users[$this->uids[$u1]]['clan'] . '")' + ); + } + unset($rtng); + if ($this->users[$this->uids[$u1]]['bot'] == 0) { + mysql_query( + 'INSERT INTO `users_reting` (`uid`,`time`,`val`,`align`,`clan`) VALUES ( + "' . $u2 . '","' . time() . '","' . $rtng2 . '","' . $this->users[$this->uids[$u2]]['align'] . '","' . $this->users[$this->uids[$u2]]['clan'] . '")' + ); + } + } + unset($rtng1, $rtng2); + } + return true; } - public function get_chanse($percent): bool + public function asr($u1, $u2, $type) { - if ($percent >= 100) { - $percent = 100; - } elseif ($percent == 0) { - $percent = 0; - } - return $this->dodge(1, $percent); + mysql_query( + 'INSERT INTO battle_static ( + `uid1`,`uid2`,`hod`,`type`,`time`,`bid` + ) VALUES ( + "' . $u1 . '","' . $u2 . '","' . $this->hodID . '","' . $type . '","' . time() . '","' . $this->info['id'] . '" + )' + ); } //Смена противника - public function smena($uid, $auto = false, $lastdie = false) + + public function addlt($a, $id, $s, $rnd = null): string { - global $u; - if ((!$auto && $u->info['smena'] > 0) || $auto) { - if ($this->stats[$this->uids[$u->info['id']]]['hpNow'] >= 1) { - if (isset($this->uids[$uid]) && $uid != $u->info['id'] && $this->users[$this->uids[$uid]]['team'] != $this->users[$this->uids[$u->info['id']]]['team']) { - if (!isset($this->ga[$u->info['id']][$uid]) || $lastdie) { - if (ceil($this->stats[$this->uids[$uid]]['hpNow']) >= 1) { - //меняем противника - if (!$auto) { - $u->info['smena']--; - } - $upd = mysql_query( - 'UPDATE `stats` SET `enemy` = "' . $uid . '",`smena` = "' . $u->info['smena'] . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1' - ); - $u->info['enemy'] = $uid; - $this->users[$this->uids[$uid]]['smena'] = $u->info['smena']; - $this->users[$this->uids[$u->info['id']]]['enemy'] = $uid; - return 1; - } else { - return 'Нельзя сменить, противник уже мертв'; - } - } else { - return 'Нельзя сменить на выбранную цель!'; - } - } else { - return 'Нельзя сменить на выбранную цель []'; - } - } else { - return 'Для вас поединок закончен, ожидайте пока завершат другие...'; - } - } else { - return 'У вас закончились смены противника'; + global $log_text; + if ($rnd === null) { + $rnd = rand(0, (count($log_text[$s][$id]) - 1)); } + return '{' . $a . 'x' . $id . 'x' . $rnd . '}'; } //авто-смена противника //ТУТ баг выбора - public function autoSmena() - { - global $u; - $ms = []; - $ms_all = []; - $ms_ansf = []; - $i = 0; - $j = 0; - $z = 0; - while ($i < count($this->users)) { - if (isset($this->users[$i]) && $this->users[$i]['id'] != $u->info['id'] && $this->users[$i]['team'] != $u->info['team'] && $this->stats[$i]['hpNow'] > 0 && -($u->info['enemy']) != $this->users[$i]['id']) { - if (!isset($this->ga[$u->info['id']][$this->users[$i]['id']])) { - $ms[$j] = $this->users[$i]['id']; - $j++; - } - if (!isset($this->uids[(-($u->info['enemy']))])) { - $ms_all[] = $this->users[$i]['id']; - } - if (isset($this->ga[$this->users[$i]['id']][$u->info['id']])) { - $ms_ansf[$z] = $this->users[$i]['id']; - $z++; - } - } - $i++; - } - $msh = []; - if ($j == 0 && $z == 0) { - $enemydie = 0; - if (isset($this->stats[$this->uids[$u->info['enemy']]])) { - $u->info['enemy'] = 0; - $enemydie = 1; - } - if ((!isset($this->uids[(-($u->info['enemy']))]) || $this->stats[$this->uids[(-($u->info['enemy']))]]['hpNow'] < 1) && ($u->info['enemy'] < 0 || $enemydie == 1)) { - $i = 0; - $j = 0; - while ($i < count($this->users)) { - if (isset($this->users[$i]) && $this->users[$i]['id'] != $u->info['id'] && $this->users[$i]['team'] != $u->info['team'] && $this->stats[$i]['hpNow'] >= 1 && -($u->info['enemy']) != $this->users[$i]['id']) { - $ms[$j] = $this->users[$i]['id']; - $msh[$ms[$j]] = true; - $j++; - } - $i++; - } - } - } - $ms = $ms[rand(0, $j - 1)]; - $ms_ansf = $ms_ansf[rand(0, $z - 1)]; - if ($z > 0) { - $this->smena($ms_ansf, true); - } elseif ($j > 0) { - if (isset($msh[$ms])) { - $this->smena($ms, true, true); - } else { - $this->smena($ms, true); - } - } else { - if ($u->info['enemy'] < 0) { - $smnr5 = $this->smena(-($u->info['enemy']), true); - unset($smnr5); - } + public function addNewStat($stat) + { + if (isset($stat[1])) { + mysql_query( + 'INSERT INTO `battle_stat` + ( `battle`,`uid1`,`uid2`,`time`,`type`,`a`,`b`,`ma`,`mb`,`type_a`,`type_b`,`yrn`,`yrn_krit`,`tm1`,`tm2` ) VALUES ( + "' . $this->info['id'] . '", + "' . $stat[1]['uid1'] . '", + "' . $stat[1]['uid2'] . '", + "' . $stat[1]['time'] . '", + "' . $stat[1]['type'] . '", + "' . $stat[1]['a'] . '", + "' . $stat[1]['b'] . '", + "' . $stat[1]['ma'] . '", + "' . $stat[1]['mb'] . '", + "' . $stat[1]['type_a'] . '", + "' . $stat[1]['type_b'] . '", + "' . $stat[1]['yrn'] . '", + "' . $stat[1]['yrn_krit'] . '", + "' . $stat[1]['tm1'] . '", + "' . $stat[1]['tm2'] . '" + )' + ); + } + if (isset($stat[2])) { + mysql_query( + 'INSERT INTO `battle_stat` + ( `battle`,`uid1`,`uid2`,`time`,`type`,`a`,`b`,`ma`,`mb`,`type_a`,`type_b`,`yrn`,`yrn_krit`,`tm1`,`tm2` ) VALUES ( + "' . $this->info['id'] . '", + "' . $stat[2]['uid1'] . '", + "' . $stat[2]['uid2'] . '", + "' . $stat[2]['time'] . '", + "' . $stat[2]['type'] . '", + "' . $stat[2]['a'] . '", + "' . $stat[2]['b'] . '", + "' . $stat[1]['ma'] . '", + "' . $stat[2]['mb'] . '", + "' . $stat[2]['type_a'] . '", + "' . $stat[2]['type_b'] . '", + "' . $stat[2]['yrn'] . '", + "' . $stat[2]['yrn_krit'] . '", + "' . $stat[2]['tm1'] . '", + "' . $stat[2]['tm2'] . '" + )' + ); } } //Действия бота (атака) - public function botAtack($uid, $pl, $tp) + + public function spaCheck($u1) { - $test_atack = mysql_fetch_array( - mysql_query( - 'SELECT `id` FROM `battle_act` WHERE `battle` = "' . $this->info['id'] . '" AND (( - `uid1` = "' . $pl . '" AND `uid2` = "' . $uid . '" - ) OR ( - `uid2` = "' . $pl . '" AND `uid1` = "' . $uid . '" - )) LIMIT 1' - ) - ); - - if ($tp == 1 && !isset($test_atack['id'])) { - $test_uid = mysql_fetch_array( - mysql_query('SELECT * FROM `stats` WHERE `id` = "' . $uid . '" AND `hpNow` >= 1 LIMIT 1') - ); - $test_pl = mysql_fetch_array( - mysql_query('SELECT * FROM `stats` WHERE `id` = "' . $pl . '" AND `hpNow` >= 1 LIMIT 1') - ); - if (isset($test_uid['id']) && isset($test_pl['id']) && $test_uid['id'] != $test_pl['id']) { - $a = rand(1, 5) . '' . rand(1, 5) . '' . rand(1, 5) . '' . rand(1, 5) . '' . rand(1, 5); - $b = rand(1, 5); - $d = mysql_query( - 'INSERT INTO `battle_act` (`battle`,`time`,`uid1`,`uid2`,`a1`,`b1`) VALUES ("' . $this->info['id'] . '","' . time( - ) . '","' . $pl . '","' . $uid . '","' . $a . '","' . $b . '")' - ); - } - } elseif ($tp == 2) { - //бот отвечает на удар - $test_uid = mysql_fetch_array( - mysql_query('SELECT * FROM `stats` WHERE `id` = "' . $uid . '" AND `hpNow` >= 1 LIMIT 1') - ); - $test_pl = mysql_fetch_array( - mysql_query('SELECT * FROM `stats` WHERE `id` = "' . $pl['uid2'] . '" AND `hpNow` >= 1 LIMIT 1') - ); - if (isset($test_uid['id']) && isset($test_pl['id']) && $test_uid['id'] != $test_pl['id']) { - $bot = $this->users[$this->uids[$pl['uid2']]]; - $na = ['id' => 0, 'a' => [1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0], 'b' => 0]; - $a222 = rand(1, 5) . '_' . rand(1, 5) . '_' . rand(1, 5) . '_' . rand(1, 5) . '_' . rand(1, 5); - $a = explode('_', $a222); - $i = 1; - $na['id'] = time(); - while ($i <= 5) { - if (isset($a[$i - 1])) { - $a[$i - 1] = intval(round($a[$i - 1])); - if ($a[$i - 1] >= 1 && $a[$i - 1] <= 5) { - $na['a'][$i] = $a[$i - 1]; - } else { - $na['a'][$i] = 0; - } - } - $i++; + if ($this->stats[$this->uids[$u1]]['hpNow'] < 1) { + mysql_query('DELETE FROM `battle_act` WHERE `uid1` = "' . $u1 . '" OR `uid2` = "' . $u1 . '"'); + if ($this->stats[$this->uids[$u1]]['spasenie'] > 0 && $this->users[$this->uids[$u1]]['tactic7'] >= 25) { + //Свиток спасения + if ($this->stats[$this->uids[$u1]]['s7'] > 49 && $this->stats[$this->uids[$u1]]['s7'] < 75) { + //Даем призрачку + mysql_query( + "INSERT INTO `eff_users` + (`id_eff`, `uid`, `name`, `data`, `overType`, `timeUse`, `timeAce`, `user_use`, `delete`, `v1`, `v2`, `img2`, `x`, `hod`, `bj`, `sleeptime`, `no_Ace`, `file_finish`, `tr_life_user`, `deactiveTime`, `deactiveLast`, `mark`, `bs`) VALUES + (22, '" . $u1 . "', 'Призрачная защита', 'add_zmproc=75|add_zaproc=75', 0, 77, 0, '" . $u1 . "', 0, 'priem', 141, 'spirit_block25.gif', 1, 1, '0', 0, 0, '', 0, 0, 0, 0, 0);" + ); + $this->stats[$this->uids[$u1]]['hpNow'] = floor($this->stats[$this->uids[$u1]]['hpAll'] * 0.5); + $this->stats[$this->uids[$u1]]['mpNow'] = floor($this->stats[$this->uids[$u1]]['mpAll'] * 0.5); + } elseif ($this->stats[$this->uids[$u1]]['s7'] > 74 && $this->stats[$this->uids[$u1]]['s7'] < 100) { + //Абсолютная защита + mysql_query( + "INSERT INTO `eff_users` + (`id_eff`, `uid`, `name`, `data`, `overType`, `timeUse`, `timeAce`, `user_use`, `delete`, `v1`, `v2`, `img2`, `x`, `hod`, `bj`, `sleeptime`, `no_Ace`, `file_finish`, `tr_life_user`, `deactiveTime`, `deactiveLast`, `mark`, `bs`) VALUES + (22, '" . $u1 . "', 'Абсолютная защита', 'add_zmproc=100|add_zaproc=100', 0, 77, 0, '" . $u1 . "', 0, 'priem', 358, 'block_absolute.gif', 1, 1, '0', 0, 0, '', 0, 0, 0, 0, 0);" + ); + $this->stats[$this->uids[$u1]]['hpNow'] = floor($this->stats[$this->uids[$u1]]['hpAll'] * 0.75); + $this->stats[$this->uids[$u1]]['mpNow'] = floor($this->stats[$this->uids[$u1]]['mpAll'] * 0.75); + } elseif ($this->stats[$this->uids[$u1]]['s7'] > 99) { + //Абсолютная защита x2 + mysql_query( + "INSERT INTO `eff_users` + (`id_eff`, `uid`, `name`, `data`, `overType`, `timeUse`, `timeAce`, `user_use`, `delete`, `v1`, `v2`, `img2`, `x`, `hod`, `bj`, `sleeptime`, `no_Ace`, `file_finish`, `tr_life_user`, `deactiveTime`, `deactiveLast`, `mark`, `bs`) VALUES + (22, '" . $u1 . "', 'Защита Мироздателя', 'add_zmproc=100|add_zaproc=100', 0, 77, 0, '" . $u1 . "', 0, 'priem', 358, 'wis_white_shield.gif', 1, 2, '0', 0, 0, '', 0, 0, 0, 0, 0);" + ); + $this->stats[$this->uids[$u1]]['hpNow'] = floor($this->stats[$this->uids[$u1]]['hpAll']); + $this->stats[$this->uids[$u1]]['mpNow'] = floor($this->stats[$this->uids[$u1]]['mpAll']); } - $na['b'] = rand(1, 5); - //Проводим удар - $this->atacks[$pl['id']]['a2'] = $a222; - $this->atacks[$pl['id']]['b2'] = $na['b']; - $this->startAtack($pl['id']); + if ($this->stats[$this->uids[$u1]]['hpNow'] < 1) { + $this->stats[$this->uids[$u1]]['hpNow'] = 1; + } + if ($this->stats[$this->uids[$u1]]['mpNow'] < 1) { + $this->stats[$this->uids[$u1]]['mpNow'] = 1; + } + if ($this->stats[$this->uids[$u1]]['hpNow'] > $this->stats[$this->uids[$u1]]['hpAll']) { + $this->stats[$this->uids[$u1]]['hpNow'] = floor($this->stats[$this->uids[$u1]]['hpAll']); + } + if ($this->stats[$this->uids[$u1]]['mpNow'] > $this->stats[$this->uids[$u1]]['mpAll']) { + $this->stats[$this->uids[$u1]]['mpNow'] = floor($this->stats[$this->uids[$u1]]['mpAll']); + } + + mysql_query( + 'DELETE FROM `eff_users` WHERE `uid` = "' . $u1 . '" AND `id_eff` = 22 AND `v1` = "priem" AND `v2` = 324' + ); + mysql_query( + 'UPDATE `stats` SET `hpNow` = "' . $this->stats[$this->uids[$u1]]['hpNow'] . '",`mpNow` = "' . $this->stats[$this->uids[$u1]]['mpNow'] . '", `tactic7` = `tactic7` - 25 WHERE `id` = "' . $u1 . '" LIMIT 1' + ); + $mas['text'] = '{tm1} ' . $this->stats[$this->uids[$u1]]['login'] . ' убит...' . $this->stats[$this->uids[$u1]]['login'] . ' был спасен. '; + $this->priemAddLog( + $id, 1, 2, $u->info['id'], $u1, + ' ', + $mas['text'], + ($this->hodID + 0) + ); + } else { + if (isset($this->stats[$this->uids[$u1]]['login'])) { + mysql_query('UPDATE `stats` SET `hpNow` = "0",`mpNow` = "0" WHERE `id` = "' . $u1 . '" LIMIT 1'); + $this->stats[$this->uids[$u1]]['hpNow'] = 0; + $this->users[$this->uids[$u1]]['hpNow'] = 0; + $mas['text'] = '{tm1} ' . $this->stats[$this->uids[$u1]]['login'] . ' погиб.'; + $this->priemAddLog( + $id, 1, 2, $u->info['id'], $u1, + ' ', + $mas['text'], + ($this->hodID + 1) + //Удаляем размен из базы //ТУТ возможен лаг удаления + ); + mysql_query( + 'DELETE FROM `battle_act` WHERE `uid1` = "' . $this->stats[$this->uids[$u1]]['id'] . '" OR `uid2` = "' . $this->stats[$this->uids[$u1]]['id'] . '" OR `uid2` = "-' . $this->stats[$this->uids[$u1]]['id'] . '"' + ); + mysql_query( + 'DELETE FROM `eff_users` WHERE `uid` = "' . $this->stats[$this->uids[$u1]]['id'] . '" AND `v1` = "priem" AND `delete` =0' + ); + } } } } //Проверяем удары, приемы, свитки, зверей - public function testActions() + + public function priemAddLog($id, $a, $b, $u1, $u2, $prm, $text, $hodID, $tm1 = 0, $tm2 = 0) { - //проверяем удары - $m = mysql_query('SELECT * FROM `battle_act` WHERE `battle` = "' . $this->info['id'] . '" ORDER BY `id` ASC'); - $i = 0; - $botA = []; - $botR = []; - while ($pl = mysql_fetch_array($m)) { - $pluids = mysql_fetch_array( - mysql_query( - 'SELECT `hpNow` FROM `stats` WHERE (`id` = "' . $pl['uid1'] . '" AND `hpNow` <= 0) OR (`id` = "' . $pl['uid2'] . '" AND `hpNow` <= 0) LIMIT 1' - ) - ); - $pltest = mysql_fetch_array( - mysql_query('SELECT * FROM `battle_act` WHERE `id` = "' . $pl['id'] . '" LIMIT 1') - ); - if (isset($pltest['id'])) { - if (isset($pluids['hpNow'])) { - mysql_query('DELETE FROM `battle_act` WHERE `id` = "' . $pl['id'] . '" LIMIT 1'); - } elseif ($pl['time'] + $this->info['timeout'] > time()) { - //удар не пропущен по тайму, просто заносим данные - $this->atacks[$pl['id']] = $pl; - $this->ga[$pl['uid1']][$pl['uid2']] = $pl['id']; - $this->ag[$pl['uid2']][$pl['uid1']] = $pl['id']; - if (isset($this->iBots[$pl['uid1']])) { - //ударил бот и нет ответа - $botA[$pl['uid1']] = $pl['id']; - } elseif (isset($this->iBots[$pl['uid2']])) { - //ударили бота и он не ответил - $botR[$pl['uid2']] = $pl['id']; - if ($this->users[$this->uids[$pl['uid2']]]['timeGo'] < time()) { - $this->botAtack($pl['uid1'], $pl, 2); - } - } - } else { - //пропуск по тайму - $pl['time'] = time(); - if ($pl['a1'] == 0 && $pl['a2'] == 0) { - //игрок 1 пропустил по тайму - $pl['out1'] = time(); - $pl['tout1'] = 1; - //игрок 2 пропустил по тайму - $pl['out2'] = time(); - $pl['tout2'] = 1; - } elseif ($pl['a1'] == 0) { - //игрок 1 пропустил по тайму - $pl['out1'] = time(); - $pl['tout1'] = 1; - } elseif ($pl['a2'] == 0) { - //игрок 2 пропустил по тайму - $pl['out2'] = time(); - $pl['tout2'] = 1; - } - //наносим удар по пропуску - $this->atacks[$pl['id']] = $pl; - $this->startAtack($pl['id']); - mysql_query('DELETE FROM `battle_act` WHERE `id` = "' . $pl['id'] . '"'); - } - } + $time = time(); + if ($tm1 == 0) { + $tm1 = isset($this->atacks[$id]) ? $this->atacks[$id]['time'] : $time; } - //тест удара - if ($this->uAtc['id'] > 0 && $this->na == 1) { - if ($pl['out1'] == 0 && $pl['out2'] == 0) { - //Может разменяться только тот кто бил - if ($pl['uid1'] == $u->info['id'] || $pl['uid2'] == $u->info['id']) { - $this->addNewAtack(); - } + if ($tm2 == 0) { + $tm2 = isset($this->atacks[$id]) ? $this->atacks[$id]['time2'] : $time; + } + $prm = str_replace('=', '^^^^', $prm); + $vLog = + 'prm=' . $prm . + '||at1=00000||at2=00000||zb1=' . $this->stats[$this->uids[$u1]]['zonb'] . + '||zb2=' . $this->stats[$this->uids[$u2]]['zonb'] . + '||bl1=' . $this->atacks[$id]['b' . $a] . + '||bl2=' . $this->atacks[$id]['b' . $b] . + '||time1=' . $tm1 . + '||time2=' . $tm2 . + '||s' . $a . '=' . $this->users[$this->uids[$u1]]['sex'] . + '||s' . $b . '=' . $this->users[$this->uids[$u2]]['sex'] . + '||t2=' . $this->users[$this->uids[$u2]]['team'] . + '||t1=' . $this->users[$this->uids[$u1]]['team'] . + '||login1=' . $this->users[$this->uids[$u1]]['login2'] . + '||login2=' . $this->users[$this->uids[$u2]]['login2']; + + $mas = [ + 'text' => $text, + 'time' => $time, + 'battle' => $this->info['id'], + 'id_hod' => $hodID, + 'vars' => $vLog, + 'type' => 1, + ]; + $this->add_log($mas); + } + + //Действия бота + + public function restZonb($uid1, $uid2) + { + if ($this->stnZbVs[$uid1] > 0) { + $this->stats[$this->uids[$uid1]]['zonb'] = $this->stnZbVs[$uid1]; + } + if ($this->stnZbVs[$uid2] > 0) { + $this->stats[$this->uids[$uid1]]['zonb'] = $this->stnZbVs[$uid2]; + } + } + + //получаем данные о поединке + + public function save_stats($uid) + { + mysql_query( + 'UPDATE `stats` SET + + `hpNow` = "' . $this->stats[$this->uids[$uid]]['hpNow'] . '", + `mpNow` = "' . $this->stats[$this->uids[$uid]]['mpNow'] . '", + `tactic1` = "' . $this->users[$this->uids[$uid]]['tactic1'] . '", + `tactic2` = "' . $this->users[$this->uids[$uid]]['tactic2'] . '", + `tactic3` = "' . $this->users[$this->uids[$uid]]['tactic3'] . '", + `tactic4` = "' . $this->users[$this->uids[$uid]]['tactic4'] . '", + `tactic5` = "' . $this->users[$this->uids[$uid]]['tactic5'] . '", + `tactic6` = "' . $this->users[$this->uids[$uid]]['tactic6'] . '", + `tactic7` = "' . $this->users[$this->uids[$uid]]['tactic7'] . '", + + `enemy` = "' . $this->users[$this->uids[$uid]]['enemy'] . '", + `battle_yron` = "' . $this->users[$this->uids[$uid]]['battle_yron'] . '", + `last_hp` = "' . $this->users[$this->uids[$uid]]['last_hp'] . '", + `battle_exp` = "' . $this->users[$this->uids[$uid]]['battle_exp'] . '", + `priems_z` = "' . $this->users[$this->uids[$uid]]['priems_z'] . '" + + WHERE `id` = "' . $uid . '" LIMIT 1' + ); + } + + //наносим удар противнику + + public function priemsRazmenMomentEnd($id, $at) + { + $uid1 = $this->atacks[$id]['uid1']; + $uid2 = $this->atacks[$id]['uid2']; + + $i = 1; + while ($i <= 2) { + if ($i == 1) { + $a = 1; + $b = 2; + $u1 = ${'uid1'}; + $u2 = ${'uid2'}; } else { - $this->addNewAtack(); + $a = 2; + $b = 1; + $u1 = ${'uid2'}; + $u2 = ${'uid1'}; } - } - //тест, бот делает удары - while ($i < count($this->bots)) { - $bot = $this->bots[$i]; - if (isset($bot) && $this->stats[$this->uids[$bot]]['hpNow'] >= 1 && $this->stats[$this->uids[$bot]]['pass'] != 'saintlucia') { //Тут проверка на бота saintlucia + if (!isset($at['p']['p_cast'])) { + $at['p'] = $at; + $at['p']['p_cast'] = true; + } + //Приемы ухода от удара + if (!isset($this->stats[$this->uids[$u2]]['nopryh']) || $this->stats[$this->uids[$u2]]['nopryh'] == 0) { $j = 0; - while ($j < count($this->users)) { - if ($this->info['razdel'] == 0) { - $tnbot = time() + rand(1, 1); - } else { - $tnbot = time() + rand(1, 2); - } - if ($this->users[$j]['timeGo'] < time() && $this->users[$this->uids[$bot]]['timeGo'] < time()) { - if ($this->users[$j]['hpNow'] >= 1 && $this->users[$this->uids[$bot]]['hpNow'] >= 1 && $this->users[$this->uids[$bot]]['team'] != $this->users[$j]['team']) { - if (isset($this->users[$j]) && $this->stats[$j]['hpNow'] >= 1 && $this->stats[$this->uids[$bot]]['hpNow'] >= 1 && !isset($this->ga[$bot][$this->users[$j]['id']]) && !isset($this->ag[$bot][$this->users[$j]['id']]) && $this->users[$j]['id'] != $bot && $this->users[$j]['team'] != $this->users[$this->uids[$bot]]['team']) { - if ($this->users[$j]['timeGo'] < time( - ) && $this->users[$this->uids[$bot]]['timeGo'] < time()) { - $this->botAtack($this->users[$j]['id'], $bot, 1); - mysql_query( - 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' - ); - } - } elseif (isset($this->users[$i]) && $this->users[$i]['bot'] > 0 && $this->stats[$i]['hpNow'] >= 1 && $this->stats[$this->uids[$bot]]['hpNow'] >= 1 && $this->users[$i]['id'] != $bot && $this->users[$i]['team'] != $this->users[$this->uids[$bot]]['team']) { - if ($this->users[$j]['timeGo'] < time( - ) && $this->users[$this->uids[$bot]]['timeGo'] < time() && $this->botAct($bot)) { - if (!isset($this->ga[$bot][$this->users[$i]['id']]) && $this->users[$this->uids[$bot]]['timeGo'] < time( - ) && !isset($this->ag[$bot][$this->users[$i]['id']])) { - $this->botAtack($this->users[$i]['id'], $bot, 1); - mysql_query( - 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' - ); - } elseif (!isset($this->ag[$bot][$this->users[$i]['id']]) && isset($this->ga[$bot][$this->users[$i]['id']]) && $this->users[$this->uids[$bot]]['timeGo'] < time( - )) { - $this->botAtack($bot, $this->users[$i]['id'], 1); - mysql_query( - 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' - ); - } - } - } else { - //Удары между ботами - if ($this->users[$j]['timeGo'] < time( - ) && $this->users[$this->uids[$bot]]['timeGo'] < time( - ) && $this->users[$j]['hpNow'] >= 1 && $this->users[$this->uids[$bot]]['hpNow'] >= 1) { - $this->atacks[$this->ga[$bot][$this->users[$j]['id']]]['a1'] = rand( - 1, 5 - ) . '' . rand( - 1, - 5 - ) . rand(1, 5) . rand(1, 5) . rand(1, 5); - $this->atacks[$this->ga[$bot][$this->users[$j]['id']]]['b1'] = rand(1, 5); - $this->atacks[$this->ga[$bot][$this->users[$j]['id']]]['a2'] = rand( - 1, 5 - ) . '' . rand( - 1, - 5 - ) . rand(1, 5) . rand(1, 5) . rand(1, 5); - $this->atacks[$this->ga[$bot][$this->users[$j]['id']]]['b2'] = rand(1, 5); - $this->atacks[$this->ag[$bot][$this->users[$j]['id']]]['a1'] = rand( - 1, 5 - ) . '' . rand( - 1, - 5 - ) . rand(1, 5) . rand(1, 5) . rand(1, 5); - $this->atacks[$this->ag[$bot][$this->users[$j]['id']]]['b1'] = rand(1, 5); - $this->atacks[$this->ag[$bot][$this->users[$j]['id']]]['a2'] = rand( - 1, 5 - ) . '' . rand( - 1, - 5 - ) . rand(1, 5) . rand(1, 5) . rand(1, 5); - $this->atacks[$this->ag[$bot][$this->users[$j]['id']]]['b2'] = rand(1, 5); - if (isset($this->ga[$bot][$this->users[$j]['id']]) && $this->users[$j]['bot'] > 0) { - if ($this->users[$j]['timeGo'] < time( - ) && $this->users[$this->uids[$bot]]['timeGo'] < time()) { - $tnbot = time() + rand(3, 7); - if ($this->info['type'] == 329) { // тестовый бой - $tnbot = time() - 1; - } - $this->startAtack($this->ga[$bot][$this->users[$j]['id']]); - $this->users[$this->uids[$bot]]['timeGo'] = $tnbot; - mysql_query( - 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' - ); - } - } elseif (isset($this->ag[$bot][$this->users[$j]['id']]) && $this->users[$j]['bot'] > 0) { - if ($this->users[$this->uids[$bot]]['timeGo'] < time( - ) && $this->users[$j]['timeGo'] < time()) { - $this->startAtack($this->ag[$bot][$this->users[$j]['id']]); - $tnbot = time() + rand(3, 7); - if ($this->info['type'] == 329) { // тестовый бой - $tnbot = time() - 1; - } - $this->users[$this->uids[$bot]]['timeGo'] = $tnbot; - mysql_query( - 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' - ); - } - } - } - } - } else { + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][6] == 1) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + $pr_moment = true; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + $this->stats[$this->uids[$u2]]['nopryh']--; } } $j++; } } + //Приемы крита + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][6] == 2) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + $pr_moment = true; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + } + } + $j++; + } + //Приемы атаки + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][6] == 3) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + $pr_moment = true; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + if (isset($fx_priem)) { + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + } + } + } + $j++; + } + //Приемы защиты + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][6] == 4) { + if ($this->testPriemVarTrueZash( + $i, 2, $this->stats[$this->uids[$u1]]['u_priem'][$j][1], $a, $b, + $u1, $u2 + ) && file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + $pr_moment = true; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + } + } + $j++; + } + //Прочие приемы + $j = 0; + while ($j <= count($this->stats[$this->uids[$u1]]['u_priem'])) { + if ($this->stats[$this->uids[$u1]]['u_priem'][$j][2] > 0 && $this->stats[$this->uids[$u1]]['u_priem'][$j][6] == 5) { + if (file_exists( + '../../_incl_data/class/priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php' + )) { + $pr_used_this = $u1; + $pr_moment = true; + require('priem/' . $this->stats[$this->uids[$u1]]['u_priem'][$j][1] . '.php'); + $at = $fx_priem($id, $at, $u1, $j); + unset(${'fx_priem'}); + } + } + $j++; + } $i++; } + return $at; + } + + //выделяем пользователей + + public function addNewAtack() + { + global $u; + if (!isset($this->ga[$u->info['id']][$u->info['enemy']])) { + if ($this->stats[$this->uids[$u->info['id']]]['hpNow'] > 0) { + + $us = $this->stats[$this->uids[$u->info['id']]]; + $i = 1; + $no = 0; + + while ($i <= $us['zona']) { + if ($this->uAtc['a'][$i] == 0) { + $no = 1; + } + $i++; + } + + if ($this->uAtc['b'] == 0) { + $no = 1; + } + + if ($no == 0) { + //наносим удар + if ($u->info['enemy'] > 0) { + if (!isset($this->ga[$u->info['enemy']][$u->info['id']])) { + if ($this->stats[$this->uids[$u->info['id']]]['hpNow'] >= 1 && $this->stats[$this->uids[$u->info['enemy']]]['hpNow'] >= 1) { + //наносим новый удар + $a = $this->uAtc['a'][1] . $this->uAtc['a'][2] . $this->uAtc['a'][3] . $this->uAtc['a'][4] . $this->uAtc['a'][5]; + $b = $this->uAtc['b']; + mysql_query( + 'DELETE FROM `battle_act` WHERE `battle` = "' . $this->info['id'] . '" AND ((`uid2` = "' . $u->info['id'] . '" AND `uid1` = "' . $u->info['enemy'] . '") OR (`uid1` = "' . $u->info['id'] . '" AND `uid2` = "' . $u->info['enemy'] . '")) LIMIT 2' + ); + $d = mysql_query( + 'INSERT INTO `battle_act` (`battle`,`time`,`uid1`,`uid2`,`a1`,`b1`) VALUES ("' . $this->info['id'] . '","' . time() . '","' . $u->info['id'] . '","' . $u->info['enemy'] . '","' . $a . '","' . $b . '")' + ); + if (!$d) { + $this->e = 'Не удалось нанести удар по противнику...'; + } else { + $this->ga[$u->info['id']][$u->info['enemy']] = mysql_insert_id(); + } + } + } else { + //отвечаем на удар противника + if ($this->stats[$this->uids[$u->info['id']]]['hpNow'] >= 1 && $this->stats[$this->uids[$u->info['enemy']]]['hpNow'] >= 1 && isset($this->atacks[$this->ga[$u->info['enemy']][$u->info['id']]]['id'])) { + $this->atacks[$this->ga[$u->info['enemy']][$u->info['id']]]['a2'] = $this->uAtc['a'][1] . '' . $this->uAtc['a'][2] . '' . $this->uAtc['a'][3] . '' . $this->uAtc['a'][4] . '' . $this->uAtc['a'][5]; + $this->atacks[$this->ga[$u->info['enemy']][$u->info['id']]]['b2'] = $this->uAtc['b']; + $this->startAtack($this->atacks[$this->ga[$u->info['enemy']][$u->info['id']]]['id']); + } + } + } + } else { + $this->e = 'Выберите зоны удара и блока'; + } + } else { + $this->e = 'Для вас поединок закончен, ожидайте пока завершат другие...'; + } + } } - //Действия бота + //Возращаем зоны блока по умолчанию + public function botAct($uid): bool { $r = false; @@ -9073,7 +9302,8 @@ class Battle return $r; } - //получаем данные о поединке + //проверка блока (Визуальная) + public function battleInfo($id) { $b = mysql_fetch_array( @@ -9092,7 +9322,8 @@ class Battle } } - //наносим удар противнику + //проверка блока + public function addAtack() { global $js; @@ -9125,7 +9356,8 @@ class Battle } } - //выделяем пользователей + //генерируем команды + public function teamsTake() { global $u; @@ -9149,8 +9381,7 @@ class Battle ); if (isset($tststrt['id'])) { $upd = mysql_query( - 'UPDATE `battle` SET `start2` = "' . time( - ) . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1' + 'UPDATE `battle` SET `start2` = "' . time() . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1' ); } else { $this->info['start2'] = time(); @@ -9199,8 +9430,7 @@ class Battle if ($this->stats[$i]['s7'] > 49) { mysql_query( - 'UPDATE `eff_users` SET `delete`="' . time( - ) . '" WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `overType` = 101 AND `delete` = 0' + 'UPDATE `eff_users` SET `delete`="' . time() . '" WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `overType` = 101 AND `delete` = 0' ); mysql_query( " @@ -9255,8 +9485,7 @@ class Battle ]; mysql_query( - 'UPDATE `eff_users` SET `delete`="' . time( - ) . '" WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `overType` = 100 AND `delete` = 0' + 'UPDATE `eff_users` SET `delete`="' . time() . '" WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `overType` = 100 AND `delete` = 0' ); mysql_query( 'INSERT INTO `eff_users` (`hod`,`v2`,`img2`,`id_eff`,`uid`,`name`,`data`,`overType`,`timeUse`,`v1`,`user_use`) VALUES ("-1","201","summon_pet_' . $tpa[$a['type']] . '.gif",22,"' . $this->users[$i]['id'] . '","' . $tpa3[$a['type']] . ' [' . $a['level'] . ']","' . $anl . '","100","77","priem","' . $this->users[$i]['id'] . '")' @@ -9281,8 +9510,7 @@ class Battle // $anl = ConversionHelper::dataStringToArray($anl); - $vLog = 'time1=' . time( - ) . '||s1=' . $this->users[$i]['sex'] . '||t1=' . $this->users[$i]['team'] . '||login1=' . $this->users[$i]['login'] . ''; + $vLog = 'time1=' . time() . '||s1=' . $this->users[$i]['sex'] . '||t1=' . $this->users[$i]['team'] . '||login1=' . $this->users[$i]['login'] . ''; $vLog .= '||s2=1||t2=' . $this->users[$i]['team'] . '||login2=' . $a['name'] . ' (Зверь ' . $this->users[$i]['login'] . ')'; $mas1 = [ @@ -9369,8 +9597,7 @@ class Battle ); if (isset($tststrt['id'])) { $upd = mysql_query( - 'UPDATE `battle` SET `start1` = "' . time( - ) . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1' + 'UPDATE `battle` SET `start1` = "' . time() . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1' ); if ($upd) { $i = 0; @@ -9422,18 +9649,31 @@ class Battle } } - //Возращаем зоны блока по умолчанию - public function restZonb($uid1, $uid2) + public function addstatuser($id) { - if ($this->stnZbVs[$uid1] > 0) { - $this->stats[$this->uids[$uid1]]['zonb'] = $this->stnZbVs[$uid1]; - } - if ($this->stnZbVs[$uid2] > 0) { - $this->stats[$this->uids[$uid1]]['zonb'] = $this->stnZbVs[$uid2]; + if ($id > 0) { + $uid = $id; + $id = $this->uids[$uid]; + mysql_query( + 'INSERT INTO `battle_users` + ( `battle`,`uid`,`time_enter`,`login`,`level`,`align`,`clan`,`hpAll`,`hp`,`hpStart`,`team` ) + VALUES + ( + "' . $this->info['id'] . '", + "' . $uid . '", + "' . time() . '","' . $this->users[$id]['login'] . '", + "' . $this->users[$id]['level'] . '", + "' . $this->users[$id]['align'] . '", + "' . $this->users[$id]['clan'] . '", + "' . $this->stats[$id]['hpAll'] . '", + "' . $this->stats[$id]['hp'] . '", + "' . $this->stats[$id]['hpNow'] . '", + "' . $this->users[$id]['team'] . '" + )' + ); } } - //проверка блока (Визуальная) public function testZonbVis() { global $u; @@ -9464,83 +9704,8 @@ class Battle return $zb; } - //проверка блока - public function testZonb($uid, $uid2) - { - $zba = []; + ///----Спасение функция - $zba[1] = $this->stats[$this->uids[$uid]]['zonb']; - $zba[2] = $this->stats[$this->uids[$uid2]]['zonb']; - - if ($this->stnZb[$uid] == 0) { - $zba[1] = $this->stats[$this->uids[$uid]]['zonb']; - $this->stnZb[$uid] = $zba[1]; - } else { - $zba[1] = $this->stnZb[$uid]; - } - - if ($this->stnZb[$uid2] == 0) { - $zba[2] = $this->stats[$this->uids[$uid2]]['zonb']; - $this->stnZb[$uid] = $zba[2]; - } else { - $zba[2] = $this->stnZb[$uid2]; - } - - if ($zba[1] > 3) { - $zba[1] = 3; - } - if ($zba[2] > 3) { - $zba[2] = 3; - } - - //Блоки игрока 1 - if ( - ( - $this->stats[$this->uids[$uid2]]['weapon1'] == 1 || - $this->stats[$this->uids[$uid2]]['weapon2'] == 1 - ) && - $this->stats[$this->uids[$uid]]['weapon1'] != 1 && - $this->stats[$this->uids[$uid]]['weapon2'] != 1 - ) { - $zba[1] -= 1; - } - - //Блоки игрока 2 - if ( - ( - $this->stats[$this->uids[$uid]]['weapon1'] == 1 || - $this->stats[$this->uids[$uid]]['weapon2'] == 1 - ) && - $this->stats[$this->uids[$uid2]]['weapon1'] != 1 && - $this->stats[$this->uids[$uid2]]['weapon2'] != 1 - ) { - $zba[2] -= 1; - } - - if ($zba[1] < 1) { - $zba[1] = 1; - } - if ($zba[2] < 1) { - $zba[2] = 1; - } - - $this->stats[$this->uids[$uid]]['zonb'] = $zba[1]; - $this->stats[$this->uids[$uid2]]['zonb'] = $zba[2]; - if ( - $this->stats[$this->uids[$uid]]['min_zonb'] > 0 && - $this->stats[$this->uids[$uid]]['zonb'] < $this->stats[$this->uids[$uid]]['min_zonb'] - ) { - $this->stats[$this->uids[$uid]]['zonb'] = $this->stats[$this->uids[$uid]]['min_zonb']; - } - if ( - $this->stats[$this->uids[$uid2]]['min_zonb'] > 0 && - $this->stats[$this->uids[$uid2]]['zonb'] < $this->stats[$this->uids[$uid2]]['min_zonb'] - ) { - $this->stats[$this->uids[$uid2]]['zonb'] = $this->stats[$this->uids[$uid2]]['min_zonb']; - } - } - - //генерируем команды public function genTeams($you): string { global $u; @@ -9621,161 +9786,4 @@ class Battle } return 'genteam("' . $ret . '");'; } - - - public function addTravm($uid, $type, $lvl) - { - global $u; - $t = $type; - if ($t == 1) { - $name = 'Легкая травма'; - $stat = rand(1, 3); // пока без духовности - $timeEnd = rand(1, 3);// время травмы от 1.30 до 6 часов - $data = 'add_s' . $stat . '=-' . $lvl; - $img = 'eff_travma1.gif'; - $v1 = 1; - } elseif ($t == 2) { - $name = 'Средняя травма'; - $stat = rand(1, 3); // пока без духовности - $timeEnd = rand(3, 5);// время травмы от 6 до 12 часов - $data = 'add_s' . $stat . '=-' . ($lvl * 2); - $v1 = 2; - $img = 'eff_travma2.gif'; - } elseif ($t == 3) { - $name = 'Тяжелая травма'; - $stat = rand(1, 3); // пока без духовности - $timeEnd = rand(5, 7);// время травмы от 12 до 6 часов - $data = 'add_s' . $stat . '=-' . ($lvl * 3); - $v1 = 3; - $img = 'eff_travma3.gif'; - } elseif ($t == 4) { - $name = 'Неизлечимая травма'; - $stat = rand(1, 3); // пока без духовности - $timeEnd = 24;// время травмы от 24 часа - $data = 'add_s' . $stat . '=-' . ($lvl * 50); - $v1 = 4; - $img = 'eff_travma4.gif'; - } - $timeEnd *= 3600; - $ins = mysql_query( - 'INSERT INTO `eff_users` (`overType`,`timeUse`,`hod`,`name`,`data`,`uid`, `id_eff`, `img2`, `timeAce`, `v1`) VALUES ("0","' . time( - ) . '","-1","' . $name . '","' . $data . '","' . $uid . '", "4", "' . $img . '","' . $timeEnd . '", "' . $v1 . '")' - ); - $ins = mysql_query( - 'INSERT INTO `eff_users` (`overType`,`timeUse`,`hod`,`name`,`data`,`uid`, `id_eff`, `img2`, `timeAce`, `v1`) VALUES ("0","' . time( - ) . '","-1","Иммунитет: Защита от травм","add_notravma=1","' . $uid . '", "263", "cure1.gif","21600", "")' - ); - } - - public function testUserInfoBattle($uid) - { - global $u; - if (!isset($this->uids[$uid])) { - //Заносим данные об игроке снова (видимо он погиб и его стерло с инфо) - if (!isset($this->uids[$uid])) { - $this->uids[$uid] = count($this->users); - } - $this->users[$this->uids[$uid]] = mysql_fetch_array( - mysql_query( - 'SELECT - - `u`.`id`,`u`.`login`,`u`.`login2`,`u`.`online`,`u`.`admin`,`u`.`city`,`u`.`cityreg`,`u`.`align`,`u`.`align_lvl`,`u`.`align_exp`,`u`.`clan`, - `u`.`level`,`u`.`money`,`u`.`money3`,`u`.`money2`,`u`.`money4`,`u`.`battle`,`u`.`sex`,`u`.`obraz`,`u`.`win`,`u`.`win_t`, - `u`.`lose`,`u`.`lose_t`,`u`.`nich`,`u`.`timeMain`,`u`.`invis`,`u`.`bot_id`,`u`.`animal`,`u`.`type_pers`, - `u`.`notrhod`,`u`.`bot_room`,`u`.`inUser`,`u`.`inTurnir`,`u`.`inTurnirnew`,`u`.`stopexp`,`u`.`real`, - - `st`.* - - FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON (`u`.`id` = `st`.`id`) WHERE `u`.`id` = "' . $uid . '" LIMIT 1' - ) - ); - $this->stats[$this->uids[$uid]] = $u->getStats($this->users[$this->uids[$uid]], 0, 0, false, false, true); - } - } - - ///----Спасение функция - public function spaCheck($u1) - { - if ($this->stats[$this->uids[$u1]]['hpNow'] < 1) { - mysql_query('DELETE FROM `battle_act` WHERE `uid1` = "' . $u1 . '" OR `uid2` = "' . $u1 . '"'); - if ($this->stats[$this->uids[$u1]]['spasenie'] > 0 && $this->users[$this->uids[$u1]]['tactic7'] >= 25) { - //Свиток спасения - if ($this->stats[$this->uids[$u1]]['s7'] > 49 && $this->stats[$this->uids[$u1]]['s7'] < 75) { - //Даем призрачку - mysql_query( - "INSERT INTO `eff_users` - (`id_eff`, `uid`, `name`, `data`, `overType`, `timeUse`, `timeAce`, `user_use`, `delete`, `v1`, `v2`, `img2`, `x`, `hod`, `bj`, `sleeptime`, `no_Ace`, `file_finish`, `tr_life_user`, `deactiveTime`, `deactiveLast`, `mark`, `bs`) VALUES - (22, '" . $u1 . "', 'Призрачная защита', 'add_zmproc=75|add_zaproc=75', 0, 77, 0, '" . $u1 . "', 0, 'priem', 141, 'spirit_block25.gif', 1, 1, '0', 0, 0, '', 0, 0, 0, 0, 0);" - ); - $this->stats[$this->uids[$u1]]['hpNow'] = floor($this->stats[$this->uids[$u1]]['hpAll'] * 0.5); - $this->stats[$this->uids[$u1]]['mpNow'] = floor($this->stats[$this->uids[$u1]]['mpAll'] * 0.5); - } elseif ($this->stats[$this->uids[$u1]]['s7'] > 74 && $this->stats[$this->uids[$u1]]['s7'] < 100) { - //Абсолютная защита - mysql_query( - "INSERT INTO `eff_users` - (`id_eff`, `uid`, `name`, `data`, `overType`, `timeUse`, `timeAce`, `user_use`, `delete`, `v1`, `v2`, `img2`, `x`, `hod`, `bj`, `sleeptime`, `no_Ace`, `file_finish`, `tr_life_user`, `deactiveTime`, `deactiveLast`, `mark`, `bs`) VALUES - (22, '" . $u1 . "', 'Абсолютная защита', 'add_zmproc=100|add_zaproc=100', 0, 77, 0, '" . $u1 . "', 0, 'priem', 358, 'block_absolute.gif', 1, 1, '0', 0, 0, '', 0, 0, 0, 0, 0);" - ); - $this->stats[$this->uids[$u1]]['hpNow'] = floor($this->stats[$this->uids[$u1]]['hpAll'] * 0.75); - $this->stats[$this->uids[$u1]]['mpNow'] = floor($this->stats[$this->uids[$u1]]['mpAll'] * 0.75); - } elseif ($this->stats[$this->uids[$u1]]['s7'] > 99) { - //Абсолютная защита x2 - mysql_query( - "INSERT INTO `eff_users` - (`id_eff`, `uid`, `name`, `data`, `overType`, `timeUse`, `timeAce`, `user_use`, `delete`, `v1`, `v2`, `img2`, `x`, `hod`, `bj`, `sleeptime`, `no_Ace`, `file_finish`, `tr_life_user`, `deactiveTime`, `deactiveLast`, `mark`, `bs`) VALUES - (22, '" . $u1 . "', 'Защита Мироздателя', 'add_zmproc=100|add_zaproc=100', 0, 77, 0, '" . $u1 . "', 0, 'priem', 358, 'wis_white_shield.gif', 1, 2, '0', 0, 0, '', 0, 0, 0, 0, 0);" - ); - $this->stats[$this->uids[$u1]]['hpNow'] = floor($this->stats[$this->uids[$u1]]['hpAll']); - $this->stats[$this->uids[$u1]]['mpNow'] = floor($this->stats[$this->uids[$u1]]['mpAll']); - } - - if ($this->stats[$this->uids[$u1]]['hpNow'] < 1) { - $this->stats[$this->uids[$u1]]['hpNow'] = 1; - } - if ($this->stats[$this->uids[$u1]]['mpNow'] < 1) { - $this->stats[$this->uids[$u1]]['mpNow'] = 1; - } - if ($this->stats[$this->uids[$u1]]['hpNow'] > $this->stats[$this->uids[$u1]]['hpAll']) { - $this->stats[$this->uids[$u1]]['hpNow'] = floor($this->stats[$this->uids[$u1]]['hpAll']); - } - if ($this->stats[$this->uids[$u1]]['mpNow'] > $this->stats[$this->uids[$u1]]['mpAll']) { - $this->stats[$this->uids[$u1]]['mpNow'] = floor($this->stats[$this->uids[$u1]]['mpAll']); - } - - mysql_query( - 'DELETE FROM `eff_users` WHERE `uid` = "' . $u1 . '" AND `id_eff` = 22 AND `v1` = "priem" AND `v2` = 324' - ); - mysql_query( - 'UPDATE `stats` SET `hpNow` = "' . $this->stats[$this->uids[$u1]]['hpNow'] . '",`mpNow` = "' . $this->stats[$this->uids[$u1]]['mpNow'] . '", `tactic7` = `tactic7` - 25 WHERE `id` = "' . $u1 . '" LIMIT 1' - ); - $mas['text'] = '{tm1} ' . $this->stats[$this->uids[$u1]]['login'] . ' убит...' . $this->stats[$this->uids[$u1]]['login'] . ' был спасен. '; - $this->priemAddLog( - $id, 1, 2, $u->info['id'], $u1, - ' ', - $mas['text'], - ($this->hodID + 0) - ); - } else { - if (isset($this->stats[$this->uids[$u1]]['login'])) { - mysql_query('UPDATE `stats` SET `hpNow` = "0",`mpNow` = "0" WHERE `id` = "' . $u1 . '" LIMIT 1'); - $this->stats[$this->uids[$u1]]['hpNow'] = 0; - $this->users[$this->uids[$u1]]['hpNow'] = 0; - $mas['text'] = '{tm1} ' . $this->stats[$this->uids[$u1]]['login'] . ' погиб.'; - $this->priemAddLog( - $id, 1, 2, $u->info['id'], $u1, - ' ', - $mas['text'], - ($this->hodID + 1) - //Удаляем размен из базы //ТУТ возможен лаг удаления - ); - mysql_query( - 'DELETE FROM `battle_act` WHERE `uid1` = "' . $this->stats[$this->uids[$u1]]['id'] . '" OR `uid2` = "' . $this->stats[$this->uids[$u1]]['id'] . '" OR `uid2` = "-' . $this->stats[$this->uids[$u1]]['id'] . '"' - ); - mysql_query( - 'DELETE FROM `eff_users` WHERE `uid` = "' . $this->stats[$this->uids[$u1]]['id'] . '" AND `v1` = "priem" AND `delete` =0' - ); - } - } - } - } } diff --git a/_incl_data/class/Quests.php b/_incl_data/class/Quests.php index 76e3258b..08595c18 100644 --- a/_incl_data/class/Quests.php +++ b/_incl_data/class/Quests.php @@ -1,5 +1,6 @@ info['level'] . ' AND `max_lvl` >= ' . $u->info['level'] . ' AND (`align` = "0" OR `align` = "' . floor($u->info['align']) . '") AND `id` = "' . mysql_real_escape_string($id) . '" LIMIT 1')); - $qlst = mysql_fetch_array(mysql_query('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` = "go" ORDER BY `id` DESC LIMIT 1')); - if (isset($qlst['id'])) { - if ($tp == 'end') { - mysql_query('UPDATE `actions` SET `vals` = "end" WHERE `id` = "' . $qlst['id'] . '" LIMIT 1'); - $u->error = 'Вы успешно отказались от задания "' . $pl['name'] . '"'; - } elseif ($tp == 'win') { - mysql_query('UPDATE `actions` SET `vals` = "win" ,`time` = "' . time() . '" WHERE `id` = "' . $qlst['id'] . '" LIMIT 1'); - } - } else { - $u->error = 'Не удалось отказаться от задания '; - } - } - /* Инфо о квесте в пещерах */ + public function infoDng($pl) { global $u; @@ -229,12 +232,12 @@ class Quests $i = 0; while ($i < count($ex)) { $ex2 = explode('=', $ex[$i]); - $x2 = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `items_users` WHERE `item_id` = "' . mysql_real_escape_string($ex2[0]) . '" AND `uid` = "' . $u->info['id'] . '" AND (`delete` = 1000 OR `delete` = 0) AND `inTransfer` = 0 AND `inShop` = 0 LIMIT 1')); - if ($x2[0] >= $ex2[1]) { - $x2[0] = ($ex2[1] + round($ex2[1] * 0.15)); + $x2 = Db::getValue('select count(*) from items_users where item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0', [(int)$ex2[0], $u->info['id']]); + if ($x2 >= $ex2[1]) { + $x2 = ($ex2[1] + round($ex2[1] * 0.15)); } $r += $ex2[1]; - $xrz += $x2[0]; + $xrz += $x2; $i++; } } @@ -245,12 +248,13 @@ class Quests $i = 0; while ($i < count($ex)) { $ex2 = explode('=', $ex[$i]); - $x2 = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `items_users` WHERE `maidin` = "' . $pl['city'] . '" AND `item_id` = "' . mysql_real_escape_string($ex2[0]) . '" AND `uid` = "' . $u->info['id'] . '" AND (`delete` = 1000 OR `delete` = 0) AND `inTransfer` = 0 AND `inShop` = 0 LIMIT 1')); - if ($x2[0] >= $ex2[1]) { - $x2[0] = ($ex2[1] + round($ex2[1] * 0.15)); + $x2 = Db::getValue('select count(*) from items_users where maidin = ? and item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0', + [$pl['city'], (int)$ex2[0], $u->info['id']]); + if ($x2 >= $ex2[1]) { + $x2 = ($ex2[1] + round($ex2[1] * 0.15)); } $r += $ex2[1]; - $xrz += $x2[0]; + $xrz += $x2; $i++; } } @@ -269,7 +273,7 @@ class Quests
-
'; +
'; } return $r; } @@ -530,12 +534,12 @@ class Quests $x = ''; while ($i < count($ex)) { $ex2 = explode('=', $ex[$i]); - $x2 = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `items_users` WHERE `item_id` = "' . mysql_real_escape_string($ex2[0]) . '" AND `uid` = "' . $u->info['id'] . '" AND (`delete` = 1000 OR `delete` = 0) AND `inTransfer` = 0 AND `inShop` = 0 LIMIT 1')); - if ($x2[0] >= $ex2[1]) { - $x2[0] = ($ex2[1] + round($ex2[1] * 0.15)); + $x2 = Db::getValue('select count(*) from items_users where item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0', [(int)$ex2[0], $u->info['id']]); + if ($x2 >= $ex2[1]) { + $x2 = ($ex2[1] + round($ex2[1] * 0.15)); } $bot2 = mysql_fetch_array(mysql_query('SELECT `id`,`name`,`img` FROM `items_main` WHERE `id` = "' . mysql_real_escape_string($ex2[0]) . '" LIMIT 1')); - $x .= '    • ' . $bot2['name'] . ' [' . $x2[0] . '/' . $ex2[1] . ']
'; + $x .= '    • ' . $bot2['name'] . ' [' . $x2 . '/' . $ex2[1] . ']
'; $i++; } if ($x != '') { @@ -551,12 +555,13 @@ class Quests $x = ''; while ($i < count($ex)) { $ex2 = explode('=', $ex[$i]); - $x2 = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `items_users` WHERE `maidin` = "' . $pl['city'] . '" AND `item_id` = "' . mysql_real_escape_string($ex2[0]) . '" AND `uid` = "' . $u->info['id'] . '" AND (`delete` = 1000 OR `delete` = 0) AND `inTransfer` = 0 AND `inShop` = 0 LIMIT 1')); - if ($x2[0] >= $ex2[1]) { - $x2[0] = ($ex2[1] + round($ex2[1] * 0.15)); + $x2 = Db::getValue('select count(*) from items_users where maidin = ? and item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0', + [$pl['city'], (int)$ex2[0], $u->info['id']]); + if ($x2 >= $ex2[1]) { + $x2 = ($ex2[1] + round($ex2[1] * 0.15)); } $bot2 = mysql_fetch_array(mysql_query('SELECT `id`,`name`,`img` FROM `items_main` WHERE `id` = "' . mysql_real_escape_string($ex2[0]) . '" LIMIT 1')); - $x .= '    • ' . $bot2['name'] . ' [' . $x2[0] . '/' . $ex2[1] . ']
'; + $x .= '    • ' . $bot2['name'] . ' [' . $x2 . '/' . $ex2[1] . ']
'; $i++; } if ($x != '') { @@ -649,12 +654,13 @@ class Quests } } - private function collect_01($arr, $u){ // убираю дублирование. хер пойми что проверяем, хз как назвать. + private function collect_01($arr, $u) + { // убираю дублирование. хер пойми что проверяем, хз как назвать. $i = 0; while ($i < count($arr)) { $ex2 = explode('=', $arr[$i]); - $x2 = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `items_users` WHERE `item_id` = ' . (int)$arr[0] . ' AND `uid` = ' . $u->info['id'] . ' AND (`delete` = 1000 OR `delete` = 0) AND `inTransfer` = 0 AND `inShop` = 0 LIMIT 1')); - if ($x2[0] < $ex2[1]) { + $x2 = Db::getValue('select count(*) from items_users where item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0', [(int)$arr[0], $u->info['id']]); + if ($x2 < $ex2[1]) { return 0; } $i++; @@ -662,230 +668,24 @@ class Quests return 1; } - private function collect_02($ex, $u, $pl) { // убираю дублирование. хер пойми что проверяем, хз как назвать. - $i = 0; - while ($i < count($ex)) { - $ex2 = explode('=', $ex[$i]); - $x2 = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `items_users` WHERE `maidin` = "' . $pl['city'] . '" AND `item_id` = "' . mysql_real_escape_string($ex2[0]) . '" AND `uid` = "' . $u->info['id'] . '" AND (`delete` = 1000 OR `delete` = 0) AND `inTransfer` = 0 AND `inShop` = 0 LIMIT 1')); - if ($x2[0] >= $ex2[1]) { - if ($x2[0] <= ($ex2[1] + round($ex2[1] * 0.15))) { - $ex2[1] = $x2[0]; - } else { - $ex2[1] = ($ex2[1] + round($ex2[1] * 0.15)); - } + public function endq($id, $tp) + { + global $u; + $pl = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `delete` = "0" AND `min_lvl` <= ' . $u->info['level'] . ' AND `max_lvl` >= ' . $u->info['level'] . ' AND (`align` = "0" OR `align` = "' . floor($u->info['align']) . '") AND `id` = "' . mysql_real_escape_string($id) . '" LIMIT 1')); + $qlst = mysql_fetch_array(mysql_query('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` = "go" ORDER BY `id` DESC LIMIT 1')); + if (isset($qlst['id'])) { + if ($tp == 'end') { + mysql_query('UPDATE `actions` SET `vals` = "end" WHERE `id` = "' . $qlst['id'] . '" LIMIT 1'); + $u->error = 'Вы успешно отказались от задания "' . $pl['name'] . '"'; + } elseif ($tp == 'win') { + mysql_query('UPDATE `actions` SET `vals` = "win" ,`time` = "' . time() . '" WHERE `id` = "' . $qlst['id'] . '" LIMIT 1'); } - if ($x2[0] < $ex2[1]) { - return 0; - } - $i++; + } else { + $u->error = 'Не удалось отказаться от задания '; } - return 1; } # Функция отвечает за ПРОВЕРКУ на ЗАВЕРШЕНИЕ квестов для ПОДЗЕМОК - public function questCheckEnd($pl) - { - global $u; - $quest = mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" ORDER BY `time` DESC LIMIT 1')); - #Проверяем квест, завершен = 0 нет, 1 да. - $r = 0; - if ($u->info['battle'] == 0 && $u->room['name'] != 'Башня Смерти') { - $g = 1; - # Действия квеста - $d = $this->expl($pl['act_date']); - - # Поговорить с NPS - if (isset($d['dlg_nps'])) { - $g = 0; - unset($x); - } - - # Убить игроков - if (isset($d['kill_user'])) { - $x = 0; - if ($x < $d['kill_user']) { - $g = 0; - } - unset($x); - } - - # Убить ботов - if (isset($d['kill_bot'])) { - $ex = explode(',', $d['kill_bot']); - $i = 0; # Количество циклов для каждого типа бота. - $q = ''; - while ($i < count($ex)) { - $ex2 = explode('=', $ex[$i]); - if ($q != '') { - $q .= ' OR '; - } - $q .= ' (`uid` = "' . $u->info['id'] . '" AND `time` > ' . $quest['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" )'; - $i++; - } - if (isset($d['all_kill']) && (int)$d['all_kill'] > 0) { - $x2 = $u->testAction($q, 2); - if ((int)$d['all_kill'] <= $x2[0]) { - $x2 = (int)$d['all_kill']; - } else { - $x2 = $x2[0]; - } - if ($x2 < (int)$d['all_kill']) { - $g = 0; - } - } else { - $x2 = $u->testAction($q . ' LIMIT ' . $ex2[1], 2); - $x2 = min($ex2[1], $x2[0]); - if ($x2 < $ex2[1]) { - $g = 0; - } - } - unset($x, $ex, $x2, $x3, $bot2, $ex2); - } - - # Собрать ресурсы - if (isset($d['tk_itm'])) { - $g = $this->collect_02(explode(',', $d['tk_itm']), $u, $pl); - } - # Собирание трофеев - if (isset($d['tkill_itm'])) { - $g = $this->collect_02(explode(',', $d['tkill_itm']), $u, $pl); - } - $r = $g == 1 ? 1 : 0; - } - return $r; - } - - /** Выдача наград за пещеры */ - public function questSuccesEnd($quest, $action) - { - global $u, $c, $magic; - $r = ''; - - if (!isset($quest['id'])) { - return ''; - } - $d = $this->expl($quest['act_date']); - $d = array_merge($d, $this->expl($quest['win_date'])); - - // Забираем ресурсы или трофеи - if (isset($d['tk_itm']) || isset($d['tkill_itm'])) { - $ex = []; - if (isset($d['tk_itm'])) { - $ex[0] = explode(',', $d['tk_itm']); - } - if (isset($d['tkill_itm'])) { - $ex[1] = explode(',', $d['tkill_itm']); - } - - $i = 0; - while ($i < count($ex)) { - $ex2 = explode('=', $ex[$i]); - $x2 = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `items_users` WHERE `maidin` = "' . $quest['city'] . '" AND `item_id` = "' . mysql_real_escape_string($ex2[0]) . '" AND `uid` = "' . $u->info['id'] . '" AND (`delete` = 1000 OR `delete` = 0) AND `inTransfer` = 0 AND `inShop` = 0 LIMIT 1')); - if ($x2[0] >= $ex2[1]) { - if ($x2[0] <= ($ex2[1] + round($ex2[1] * 0.15))) { - $ex2[1] = $x2[0]; - } else { - $ex2[1] = ($ex2[1] + round($ex2[1] * 0.15)); - } - } - $d['add_rep'] = (int)$d['add_rep'] * (int)$ex2[1]; - ItemsModel::deleteItemsById($ex2[0], $ex2[1]); - $i++; - } - } - $t = ''; - - # Получаем репутацию за квест, - if (isset($d['add_rep'])) { - # если это убийства ботов. - if (isset($d['kill_bot']) && isset($d['all_kill']) && $d['add_rep'] > 0) { - $ex = explode(',', $d['kill_bot']); - $ii = 0; - if ($quest['kin'] == 0) { - $d['add_rep'] = 0; - while ($ii < count($ex)) { - $i = 0; - $ex2 = explode('=', $ex[$i]); - while ($i < $d['all_kill']) { - $x2 = 0; - $d['add_rep'] = $d['add_rep'] + $ex2[1]; - $x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $action['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $d['all_kill'], 2); - $i++; - } - $ii++; - } - } else { - $d['add_rep'] = 1; - } - } - - unset($x, $i, $ii, $ex, $x2, $bot2, $ex2); - - $rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = ' . $u->info['id'])); - - if ($quest['city'] != '') { - if ($this->stats['more_awards'] >= 0) { - $d['add_rep'] += $d['add_rep'] / 100 * 50; - } - $t .= '' . $d['add_rep'] . ' ед. репутации ' . $u->city_name[$quest['city']] . ', '; - if ( - $rep['rep' . $quest['city']] < 24999 && - $rep['rep' . $quest['city']] + $d['add_rep'] >= 24999 && - $quest['kin'] != 2 - ) { - $rep['rep' . $quest['city']] = 24999; - } else { - $rep['rep' . $quest['city']] += $d['add_rep']; - } - - mysql_query('UPDATE `rep` SET `rep' . $quest['city'] . '` = "' . $rep['rep' . $quest['city']] . '" WHERE `id` = "' . $rep['id'] . '" LIMIT 1'); - } - } - if (isset($d['add_repizlom'])) { - $t .= '' . $d['add_repizlom'] . ' ед. репутации Излома Хаоса, '; - $rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = "' . $u->info['id'] . '" LIMIT 1')); - $rep['repizlom'] += $d['add_repizlom']; - if ($rep['repizlom'] > 24999) { - $rep['repizlom'] = 24999; - } - mysql_query('UPDATE `rep` SET `repizlom` = "' . $rep['repizlom'] . '" WHERE `id` = "' . $rep['id'] . '" LIMIT 1'); - } - if (isset($d['add_eff'])) { - $i = 0; - $j = explode('=', $d['add_eff']); - while ($i < count($j)) { - if ($j[$i] > 0) { - $magic->add_eff($u->info['id'], $j[$i], 1); - } - $i++; - } - } - if (isset($d['add_cr'])) { - $t .= '' . $d['add_cr'] . ' кр., '; - mysql_query('UPDATE `users` SET `money` = `money`+' . $d['add_cr'] . ' WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'); - } - if ($t != '') { - $t = rtrim($t, ', '); - $r = 'Задание ' . $quest['name'] . ' было успешно выполнено! Вы получили награду: ' . $t . '.'; - unset($t); - } else { - $r = 'Задание ' . $quest['name'] . ' было успешно выполнено!'; - } - $r = '' . $r . ''; - //Отправляем сообщение в чат - mysql_query('UPDATE `actions` SET `vals` = "win" , `time` = "' . time() . '" WHERE `id` = "' . $action['id'] . '" AND `vals` = "go" LIMIT 1'); - - - $chatDto = new ChatMessage(); - $chatDto->setCity($u->info['city']); - $chatDto->setRoom($u->info['room']); - $chatDto->setTo($u->info['login']); - $chatDto->setText($r); - $chatDto->setType(5); - (new Chat())->sendMsg($chatDto); - - return $r; - } private function winQuest($pl) { @@ -1008,18 +808,230 @@ class Quests } } - private function expl($d) + public function questCheckEnd($pl) { + global $u; + $quest = mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" ORDER BY `time` DESC LIMIT 1')); + #Проверяем квест, завершен = 0 нет, 1 да. + $r = 0; + if ($u->info['battle'] == 0 && $u->room['name'] != 'Башня Смерти') { + $g = 1; + # Действия квеста + $d = $this->expl($pl['act_date']); + + # Поговорить с NPS + if (isset($d['dlg_nps'])) { + $g = 0; + unset($x); + } + + # Убить игроков + if (isset($d['kill_user'])) { + $x = 0; + if ($x < $d['kill_user']) { + $g = 0; + } + unset($x); + } + + # Убить ботов + if (isset($d['kill_bot'])) { + $ex = explode(',', $d['kill_bot']); + $i = 0; # Количество циклов для каждого типа бота. + $q = ''; + while ($i < count($ex)) { + $ex2 = explode('=', $ex[$i]); + if ($q != '') { + $q .= ' OR '; + } + $q .= ' (`uid` = "' . $u->info['id'] . '" AND `time` > ' . $quest['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" )'; + $i++; + } + if (isset($d['all_kill']) && (int)$d['all_kill'] > 0) { + $x2 = $u->testAction($q, 2); + if ((int)$d['all_kill'] <= $x2[0]) { + $x2 = (int)$d['all_kill']; + } else { + $x2 = $x2[0]; + } + if ($x2 < (int)$d['all_kill']) { + $g = 0; + } + } else { + $x2 = $u->testAction($q . ' LIMIT ' . $ex2[1], 2); + $x2 = min($ex2[1], $x2[0]); + if ($x2 < $ex2[1]) { + $g = 0; + } + } + unset($x, $ex, $x2, $x3, $bot2, $ex2); + } + + # Собрать ресурсы + if (isset($d['tk_itm'])) { + $g = $this->collect_02(explode(',', $d['tk_itm']), $u, $pl); + } + # Собирание трофеев + if (isset($d['tkill_itm'])) { + $g = $this->collect_02(explode(',', $d['tkill_itm']), $u, $pl); + } + $r = $g == 1 ? 1 : 0; + } + return $r; + } + + private function collect_02($ex, $u, $pl) + { // убираю дублирование. хер пойми что проверяем, хз как назвать. $i = 0; - $dr = []; - $e = explode(':|:', $d); - while ($i < count($e)) { - $t = explode(':=:', $e[$i]); - if (isset($t[0])) { - $dr[$t[0]] = $t[1]; + while ($i < count($ex)) { + $ex2 = explode('=', $ex[$i]); + $x2 = Db::getValue('select count(*) from items_users where maidin = ? and item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0', + [$pl['city'], (int)$ex2[0], $u->info['id']]); + if ($x2 >= $ex2[1]) { + if ($x2 <= ($ex2[1] + round($ex2[1] * 0.15))) { + $ex2[1] = $x2; + } else { + $ex2[1] = ($ex2[1] + round($ex2[1] * 0.15)); + } + } + if ($x2 < $ex2[1]) { + return 0; } $i++; } - return $dr; + return 1; + } + + /** Выдача наград за пещеры */ + public function questSuccesEnd($quest, $action) + { + global $u, $c, $magic; + $r = ''; + + if (!isset($quest['id'])) { + return ''; + } + $d = $this->expl($quest['act_date']); + $d = array_merge($d, $this->expl($quest['win_date'])); + + // Забираем ресурсы или трофеи + if (isset($d['tk_itm']) || isset($d['tkill_itm'])) { + $ex = []; + if (isset($d['tk_itm'])) { + $ex[0] = explode(',', $d['tk_itm']); + } + if (isset($d['tkill_itm'])) { + $ex[1] = explode(',', $d['tkill_itm']); + } + + $i = 0; + while ($i < count($ex)) { + $ex2 = explode('=', $ex[$i]); + $x2 = Db::getValue('select count(*) from items_users where maidin = ? and item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0', + [$quest['city'], (int)$ex2[0], $u->info['id']]); + if ($x2 >= $ex2[1]) { + if ($x2 <= ($ex2[1] + round($ex2[1] * 0.15))) { + $ex2[1] = $x2; + } else { + $ex2[1] = ($ex2[1] + round($ex2[1] * 0.15)); + } + } + $d['add_rep'] = (int)$d['add_rep'] * (int)$ex2[1]; + ItemsModel::deleteItemsById($ex2[0], $ex2[1]); + $i++; + } + } + $t = ''; + + # Получаем репутацию за квест, + if (isset($d['add_rep'])) { + # если это убийства ботов. + if (isset($d['kill_bot']) && isset($d['all_kill']) && $d['add_rep'] > 0) { + $ex = explode(',', $d['kill_bot']); + $ii = 0; + if ($quest['kin'] == 0) { + $d['add_rep'] = 0; + while ($ii < count($ex)) { + $i = 0; + $ex2 = explode('=', $ex[$i]); + while ($i < $d['all_kill']) { + $x2 = 0; + $d['add_rep'] = $d['add_rep'] + $ex2[1]; + $x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $action['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $d['all_kill'], 2); + $i++; + } + $ii++; + } + } else { + $d['add_rep'] = 1; + } + } + + unset($x, $i, $ii, $ex, $x2, $bot2, $ex2); + + $rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = ' . $u->info['id'])); + + if ($quest['city'] != '') { + if ($this->stats['more_awards'] >= 0) { + $d['add_rep'] += $d['add_rep'] / 100 * 50; + } + $t .= '' . $d['add_rep'] . ' ед. репутации ' . $u->city_name[$quest['city']] . ', '; + if ( + $rep['rep' . $quest['city']] < 24999 && + $rep['rep' . $quest['city']] + $d['add_rep'] >= 24999 && + $quest['kin'] != 2 + ) { + $rep['rep' . $quest['city']] = 24999; + } else { + $rep['rep' . $quest['city']] += $d['add_rep']; + } + + mysql_query('UPDATE `rep` SET `rep' . $quest['city'] . '` = "' . $rep['rep' . $quest['city']] . '" WHERE `id` = "' . $rep['id'] . '" LIMIT 1'); + } + } + if (isset($d['add_repizlom'])) { + $t .= '' . $d['add_repizlom'] . ' ед. репутации Излома Хаоса, '; + $rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = "' . $u->info['id'] . '" LIMIT 1')); + $rep['repizlom'] += $d['add_repizlom']; + if ($rep['repizlom'] > 24999) { + $rep['repizlom'] = 24999; + } + mysql_query('UPDATE `rep` SET `repizlom` = "' . $rep['repizlom'] . '" WHERE `id` = "' . $rep['id'] . '" LIMIT 1'); + } + if (isset($d['add_eff'])) { + $i = 0; + $j = explode('=', $d['add_eff']); + while ($i < count($j)) { + if ($j[$i] > 0) { + $magic->add_eff($u->info['id'], $j[$i], 1); + } + $i++; + } + } + if (isset($d['add_cr'])) { + $t .= '' . $d['add_cr'] . ' кр., '; + mysql_query('UPDATE `users` SET `money` = `money`+' . $d['add_cr'] . ' WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'); + } + if ($t != '') { + $t = rtrim($t, ', '); + $r = 'Задание ' . $quest['name'] . ' было успешно выполнено! Вы получили награду: ' . $t . '.'; + unset($t); + } else { + $r = 'Задание ' . $quest['name'] . ' было успешно выполнено!'; + } + $r = '' . $r . ''; + //Отправляем сообщение в чат + mysql_query('UPDATE `actions` SET `vals` = "win" , `time` = "' . time() . '" WHERE `id` = "' . $action['id'] . '" AND `vals` = "go" LIMIT 1'); + + + $chatDto = new ChatMessage(); + $chatDto->setCity($u->info['city']); + $chatDto->setRoom($u->info['room']); + $chatDto->setTo($u->info['login']); + $chatDto->setText($r); + $chatDto->setType(5); + (new Chat())->sendMsg($chatDto); + + return $r; } } diff --git a/_incl_data/mysql_override.php b/_incl_data/mysql_override.php index 3b889e4f..ec2b08b8 100644 --- a/_incl_data/mysql_override.php +++ b/_incl_data/mysql_override.php @@ -128,20 +128,6 @@ if (!extension_loaded('mysql') && !function_exists('mysql_connect')) { return $result; } - /** - * @param mysqli_result $result - * @return bool|array - */ - function mysql_fetch_row(mysqli_result $result) - { - $result = $result->fetch_row(); - if ($result === null) { - $result = false; - } - - return $result; - } - /** * @param mysqli_result $result * @param $result_type diff --git a/forum_script/_forum.class.php b/forum_script/_forum.class.php index a9ea1ad9..76ea2439 100644 --- a/forum_script/_forum.class.php +++ b/forum_script/_forum.class.php @@ -11,27 +11,26 @@ class forum public function paginator($t, $pagers = 0) { + $args = []; if (isset($_GET['search'])) { - $where = '( `text` LIKE "%' . mysql_real_escape_string($_GET['search']) . '%" OR `title` LIKE "%' . mysql_real_escape_string($_GET['search']) . '%" OR `login` LIKE "%' . mysql_real_escape_string($_GET['search']) . '%" ) AND `topic` < "0" AND `delete` = "0"'; + $where = '(text like ? or title like ? or login like ?) and topic < 0 and `delete` = 0'; + $args = [$_GET['search'], $_GET['search'], $_GET['search']]; $pre_url = 'search=' . htmlspecialchars($_GET['search'], null) . '&read=' . $pagers . '&'; - $idpaginator = $pagers; } elseif ($pagers != 0) { - $where = '`topic` = "' . $pagers . '" AND `delete` = "0"'; + $where = 'topic = ? and `delete` = 0'; + $args = [$pagers]; $pre_url = 'read=' . $pagers . '&'; - $idpaginator = $pagers; } elseif ($t == 1) { - $where = '`topic` < "0" AND `fid` = "' . $this->r . '" AND `delete` = "0"'; + $where = 'topic < 0 and fid = ? and `delete` = 0'; + $args = [$this->r]; $pre_url = 'r=' . $this->r . '&'; - $idpaginator = $this->r; } elseif ($t == 2) { - $where = '`topic` = "' . $this->see['id'] . '" AND `delete` = "0"'; + $where = 'topic = ? and `delete` = 0'; + $args = [$this->see['id']]; $pre_url = 'read=' . $this->see['id'] . '&'; - $idpaginator = $this->see['id']; } - $q = "SELECT count(*) FROM forum_msg WHERE " . $where; - $res = mysql_query($q); - $row = mysql_fetch_row($res); - $total_rows = $row[0]; + + $total_rows = \Core\Db::getValue("select count(*) from forum_msg where $where", $args); $num_pages = ceil($total_rows / 20); $plist = ''; for ($i = 1; $i <= $num_pages; $i++) { diff --git a/modules_data/_clan.php b/modules_data/_clan.php index 2f2ccecd..d432fe7d 100644 --- a/modules_data/_clan.php +++ b/modules_data/_clan.php @@ -1187,9 +1187,7 @@ if ($u->info['clan_prava'] != 'glava') { ); } } elseif ($_POST['invite'] == "Принять" && $tt[9][0] == 1) { - $is_cl = mysql_fetch_row( - mysql_query("SELECT COUNT(*) FROM `users` WHERE `clan` = '" . $res['id'] . "'") - ); + $is_cl = Db::getValue('select count(*) from users where clan = ?', [$res['id']]); $usr = mysql_fetch_array( mysql_query( 'SELECT * FROM `users` WHERE `login` = "' . mysql_real_escape_string( @@ -1211,7 +1209,7 @@ if ($u->info['clan_prava'] != 'glava') { echo 'У вас не достаточно кр. для приема игрока в клан (Требуется: ' . $c_pr[0] . ' кр.)
'; } elseif ($usr['clan'] != '0' || $usr['align'] != '0') { echo 'Персонаж уже находится в клане, либо имеет склонность
'; - } elseif ($is_cl[0] >= $lvl_prava[$res['level']][0]) { + } elseif ($is_cl >= $lvl_prava[$res['level']][0]) { echo 'Достигнут лимит приглашений. Повысте уровень клана.
'; } else { // `palpro` = "'.(time()+86400*7).'",