From 7535cc657aed30755e90db80462321cde13c0fa8 Mon Sep 17 00:00:00 2001 From: Ivor Barhansky Date: Sat, 30 Sep 2023 17:53:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=BC=D0=BE=D0=BD=D1=82=20=D0=B2?= =?UTF-8?q?=D1=85=D0=BE=D0=B4=D0=B0=20=D0=B1=D0=BE=D1=82=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=B2=20=D0=B1=D0=BE=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _incl_data/class/Dungeon.php | 194 +++++++++++------------------- modules_data/location/dungeon.php | 58 ++++----- 2 files changed, 100 insertions(+), 152 deletions(-) diff --git a/_incl_data/class/Dungeon.php b/_incl_data/class/Dungeon.php index a9f3ec82..b874dfc3 100644 --- a/_incl_data/class/Dungeon.php +++ b/_incl_data/class/Dungeon.php @@ -815,7 +815,7 @@ class Dungeon if (isset($obj['id'])) { $tbot = mysql_fetch_assoc( mysql_query( - 'SELECT * FROM `dungeon_bots` WHERE `x` = "' . $obj['x'] . '" AND `y` = "' . $obj['y'] . '" AND `dn` = "' . $this->info['id'] . '" AND `for_dn` = "0" AND `delete` = "0" LIMIT 1' + 'SELECT id2 FROM `dungeon_bots` WHERE `x` = "' . $obj['x'] . '" AND `y` = "' . $obj['y'] . '" AND `dn` = "' . $this->info['id'] . '" AND `for_dn` = "0" AND `delete` = "0" LIMIT 1' ) ); @@ -888,9 +888,9 @@ class Dungeon //Проверяем кого нужно убить и убили-ли $j = 1; $jn = 0; - $tuz = mysql_fetch_assoc( + mysql_fetch_assoc( mysql_query( - 'SELECT `x`,`y`,`id`,`hpNow` FROM `stats` WHERE `dnow` = "' . $this->info['id'] . '" AND ( (`x` = ' . ($pl['x'] + 1) . ' AND `y` = ' . ($pl['y']) . ') OR (`x` = ' . ($pl['x'] - 1) . ' AND `y` = ' . ($pl['y']) . ') OR (`x` = ' . ($pl['x']) . ' AND `y` = ' . ($pl['y'] + 1) . ') OR (`x` = ' . ($pl['x']) . ' AND `y` = ' . ($pl['y'] - 1) . ') ) LIMIT 1' + 'SELECT `x`,`y`,`id`,`hpNow` FROM `stats` WHERE `dnow` = "' . $this->info['id'] . '" AND ( (`x` = ' . ($obj['x'] + 1) . ' AND `y` = ' . ($obj['y']) . ') OR (`x` = ' . ($obj['x'] - 1) . ' AND `y` = ' . ($obj['y']) . ') OR (`x` = ' . ($obj['x']) . ' AND `y` = ' . ($obj['y'] + 1) . ') OR (`x` = ' . ($obj['x']) . ' AND `y` = ' . ($obj['y'] - 1) . ') ) LIMIT 1' ) ); while ($j < count($t)) { @@ -931,7 +931,8 @@ class Dungeon mysql_query('SELECT `name` FROM `items_main` WHERE `id` = "' . $itm[0] . '" LIMIT 1') ); mysql_query( - 'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `item_id` = "' . $itm[0] . '" AND `uid` = "' . $u->info['id'] . '" AND (`delete` = 0 OR `delete` = 100) AND `inShop` = 0 AND `inTransfer` = 0 AND `inOdet` = 0 LIMIT ' . $itm[1] + 'UPDATE `items_users` SET `delete` = "' . time( + ) . '" WHERE `item_id` = "' . $itm[0] . '" AND `uid` = "' . $u->info['id'] . '" AND (`delete` = 0 OR `delete` = 100) AND `inShop` = 0 AND `inTransfer` = 0 AND `inOdet` = 0 LIMIT ' . $itm[1] ); $r .= 'Предмет "' . $uitm['name'] . '" (x' . $itm[1] . ') был утрачен...
'; $j++; @@ -1272,125 +1273,68 @@ class Dungeon } } - public function botAtack($bot, $uid, $bs) + public function botAtack($bot, $uid, $bs): void { - global $u, $c, $code; - $user = mysql_fetch_assoc( - mysql_query('SELECT `id`,`battle` FROM `users` WHERE `id` = "' . $uid['id'] . '" LIMIT 1') - ); + ### FIXME ВОЗМОЖНО тут потерялись [dungeon_bots.bot_group], ячейка отвечающая за группу разных ботов. Не вижу где это ипользуется. Тут только однотипные боты. + global $u; - if ($user['battle'] > 0) { - $btli = mysql_fetch_assoc( - mysql_query( - 'SELECT `id` FROM `battle` WHERE `id` = "' . $user['battle'] . '" AND `team_win` = "-1" LIMIT 1' - ) - ); - } + $battleId = Db::getValue('select users.battle from users left join battle on users.battle = battle.id where users.id = ? and team_win = -1', [$uid['id']]); - if (!isset($btli['id'])) { //Создаем поединок - $btl_id = 0; - $expB = 0; - $btl = ['players' => '', 'timeout' => 120, 'type' => 0, 'invis' => 0, 'noinc' => 0, 'travmChance' => 0, 'typeBattle' => 0, 'addExp' => $expB, 'money' => 0]; + if (empty($battleId)) { //Создаем поединок + Db::sql('insert into battle (dungeon, dn_id, x, y, time_start, type) values (?,?,?,?,unix_timestamp(), 0)', [$this->info['id2'], $this->info['id'], $bot['x'], $bot['y']]); + $battleId = Db::lastInsertId(); - mysql_query( - 'INSERT INTO `battle` (`dungeon`,`dn_id`,`x`,`y`,`city`,`time_start`,`players`,`timeout`,`type`,`invis`,`noinc`,`travmChance`,`typeBattle`,`addExp`,`money`) VALUES ("' . $this->info['id2'] . '", "' . $this->info['id'] . '", "' . $bot['x'] . '", "' . $bot['y'] . '", "' . $u->info['city'] . '", "' . time() . '", "' . $btl['players'] . '", "' . $btl['timeout'] . '", "' . $btl['type'] . '", "' . $btl['invis'] . '", "' . $btl['noinc'] . '", "' . $btl['travmChance'] . '", "' . $btl['typeBattle'] . '", "' . $btl['addExp'] . '", "' . $btl['money'] . '")' - ); - - $btl_id = mysql_insert_id(); - - if ($btl_id > 0) { //Добавляем ботов - $sp = mysql_query( - 'SELECT * FROM `dungeon_bots` WHERE `for_dn` = "0" AND `delete` = "0" AND `dn` = "' . $this->info['id'] . '" AND `id2` = "' . $bot['id2'] . '" LIMIT 1' - ); // Только тот, который напал и жив ли он? - $j = 0; - $logins_bot = []; - while ($pl = mysql_fetch_assoc($sp)) { - mysql_query( - 'UPDATE `dungeon_bots` SET `inBattle` = "' . $btl_id . '" WHERE `id2` = "' . $bot['id2'] . '" LIMIT 1' - ); - $jui = 1; - while ($jui <= $pl['colvo']) { - $k = $u->addNewbot($pl['id_bot'], null, null, $logins_bot); - $logins_bot = $k['logins_bot']; - if ($k) { - $upd = mysql_query( - 'UPDATE `users` SET `battle` = "' . $btl_id . '" WHERE `id` = "' . $k['id'] . '" LIMIT 1' - ); - if ($upd) { - $upd = mysql_query( - 'UPDATE `stats` SET `team` = "2" WHERE `id` = "' . $k['id'] . '" LIMIT 1' - ); - if ($upd) { - $j++; - } - } - } - $jui++; + if ($battleId > 0) { //Добавляем ботов + $addBotQuantity = 0; + $dungeonBots = Db::getRow('select id_bot, colvo from dungeon_bots where for_dn = 0 and dn = ? and id2 = ?', [$this->info['id'], $bot['id2']]); //Только тот, который напал и жив ли он? + Db::sql('update dungeon_bots set inBattle = ? where id2 = ?', [$battleId, $bot['id2']]); + for ($i = 1; $i <= $dungeonBots['colvo']; $i++) { + $k = $u->addNewbot($dungeonBots['id_bot'], null, null); + if (!$k) { + continue; } + + Db::sql('update users left join stats on users.id = stats.id set battle = ?, team = 2 where users.id = ?', [$battleId, $k['id']]); + $addBotQuantity++; } - unset($logins_bot); - if ($j > 0) { - mysql_query( - 'UPDATE `users` SET `battle` = "' . $btl_id . '" WHERE `id` = "' . $user['id'] . '" LIMIT 1' - ); - mysql_query('UPDATE `stats` SET `team` = "1" WHERE `id` = "' . $user['id'] . '" LIMIT 1'); + + if ($addBotQuantity > 0) { + Db::sql('update users left join stats on users.id = stats.id set battle = ?, team = 1 where users.id = ?', [$battleId, $uid['id']]); } } + } else { - $btl_id = $btli['id']; //Добавляем ботов - $sp = mysql_query( - 'SELECT * FROM `dungeon_bots` WHERE `for_dn` = "0" AND `delete` = "0" AND `dn` = "' . $this->info['id'] . '" AND `id2` = "' . $bot['id2'] . '" LIMIT 1' - ); - $j = 0; - $logins_bot = []; - $logins_bot_text = []; - $logins_bot_vars = ['time1=' . time() . '']; - while ($pl = mysql_fetch_assoc($sp)) { - mysql_query( - 'UPDATE `dungeon_bots` SET `inBattle` = "' . $btl_id . '" WHERE `id2` = "' . $bot['id2'] . '" LIMIT 1' - ); - $jui = 1; - while ($jui <= $pl['colvo']) { - $k = $u->addNewbot($pl['id_bot'], null, null, $logins_bot); - $logins_bot = $k['logins_bot']; - $logins_bot_text[] = ' ' . $k['login'] . ''; - if ($k != false) { - $upd = mysql_query( - 'UPDATE `users` SET `battle` = "' . $btl_id . '" WHERE `id` = "' . $k['id'] . '" LIMIT 1' - ); - if ($upd) { - $upd = mysql_query( - 'UPDATE `stats` SET `team` = "2" WHERE `id` = "' . $k['id'] . '" LIMIT 1' - ); - if ($upd) { - $j++; - } - } - } - $jui++; - } - if ($j > 0) { - $logins_bot_text = '{tm1} В поединок вмешались: ' . implode(', ', $logins_bot_text) . '.'; - $logins_bot_vars = implode('||', $logins_bot_vars); - $battle_log = mysql_fetch_assoc( - mysql_query( - 'SELECT * FROM `battle_logs` WHERE `battle`=' . $btl_id . ' ORDER BY `id_hod` DESC LIMIT 1' - ) - ); - if ($battle_log['id_hod'] > 0) { - mysql_query( - 'INSERT INTO `battle_logs` (`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zonb1`,`zona2`,`zonb2`,`type`) VALUES ("' . time() . '","' . $btl_id . '","' . ($battle_log['id_hod'] + 1) . '","' . $logins_bot_text . '","' . $logins_bot_vars . '","","","","",1)' - ); - } + $dungeonBots = Db::getRow('select id_bot, colvo from dungeon_bots where for_dn = 0 and dn = ? and id2 = ?', [$this->info['id'], $bot['id2']]); + Db::sql('update dungeon_bots set inBattle = ? where id2 = ?', [$battleId, $bot['id2']]); + + $addBotQuantity = 0; + $botNamesArray = []; + for ($i = 1; $i <= $dungeonBots['colvo']; $i++) { + $k = $u->addNewbot($dungeonBots['id_bot'], null, null); + if (!$k) { + continue; } + + $botNamesArray[] = $k['login']; + Db::sql('update users left join stats on users.id = stats.id set battle = ?, team = 2 where users.id = ?', [$battleId, $k['id']]); + $addBotQuantity++; } - unset($logins_bot); - if ($j > 0) { - mysql_query( - 'UPDATE `users` SET `battle` = "' . $btl_id . '" WHERE `id` = "' . $user['id'] . '" LIMIT 1' - ); - mysql_query('UPDATE `stats` SET `team` = "1" WHERE `id` = "' . $user['id'] . '" LIMIT 1'); + + if ($addBotQuantity > 0) { + $turnId = Db::getValue('select id_hod from battle_logs where battle = ? order by id_hod desc limit 1', [$battleId]); + if ($turnId > 0) { + Db::sql( + "insert into battle_logs (time, battle, id_hod, text, vars, zona1, zona2, zonb1, zonb2, type) values (unix_timestamp(),?,?,?,concat('time1=', unix_timestamp()),'','','','',1)", + [ + $battleId, + $turnId + 1, + '{tm1} В поединок вмешались: ' . implode(', ', $botNamesArray) . '.', + ] + ); + } + + Db::sql('update users left join stats on users.id = stats.id set battle = ?, team = 1 where users.id = ?', [$battleId, $uid['id']]); } } } @@ -2083,7 +2027,7 @@ class Dungeon $pos = []; while ($pl = mysql_fetch_assoc($sp)) { if (!isset($this->cord[$pl['y'] . '_' . $pl['x']])) { - continue; + continue; } if ( @@ -2304,18 +2248,22 @@ class Dungeon } - $botsArr = Db::getRows('select * from dungeon_bots left join test_bot on dungeon_bots.id_bot = test_bot.id where dn = ? and x <= ? and x >= ? and y <= ? and y >= ? limit 50',[ - $u->info['dnow'], $whrVals[$this->gs][0], $whrVals[$this->gs][1], $whrVals[$this->gs][2], $whrVals[$this->gs][3], - ]); + $botsArr = Db::getRows( + 'select * from dungeon_bots left join test_bot on dungeon_bots.id_bot = test_bot.id where dn = ? and x <= ? and x >= ? and y <= ? and y >= ? limit 50', [ + $u->info['dnow'], $whrVals[$this->gs][0], $whrVals[$this->gs][1], $whrVals[$this->gs][2], $whrVals[$this->gs][3], + ] + ); foreach ($botsArr as $pl) { - -// } -// -// $sp = mysql_query( -// 'SELECT `u`.*,`st`.* FROM `dungeon_bots` AS `u` LEFT JOIN `test_bot` AS `st` ON (`u`.`id_bot` = `st`.`id`) WHERE `u`.`dn` = "' . $u->info['dnow'] . '" AND ' . $whr[$this->gs] . ' AND `u`.`delete` = "0" LIMIT 50' -// ); -// while ($pl = mysql_fetch_assoc($sp)) { + if (!isset($this->cord[$pl['y'] . '_' . $pl['x']])) { + continue; + } + // } + // + // $sp = mysql_query( + // 'SELECT `u`.*,`st`.* FROM `dungeon_bots` AS `u` LEFT JOIN `test_bot` AS `st` ON (`u`.`id_bot` = `st`.`id`) WHERE `u`.`dn` = "' . $u->info['dnow'] . '" AND ' . $whr[$this->gs] . ' AND `u`.`delete` = "0" LIMIT 50' + // ); + // while ($pl = mysql_fetch_assoc($sp)) { $i++; if (!isset($pos[$this->cord[$pl['y'] . '_' . $pl['x']]])) { $pos[$this->cord[$pl['y'] . '_' . $pl['x']]] = 0; @@ -2329,7 +2277,7 @@ class Dungeon if ($pl['noatack'] == 1 && $this->info['bsid'] == 0) { $noat = 0; } - $r .= ',' . ($i - 1) . ':{9:0,0:' . $pl['id2'] . ',1:\'' . $pl['login'] . '\',2:' . (0 + $this->cord[$pl['y'] . '_' . $pl['x']]) . ',3:' . $pl['sex'] . ',4:\'' . str_replace( + $r .= ',' . ($i - 1) . ':{9:0,0:' . $pl['id2'] . ',1:\'' . $pl['login'] . '\',2:' . ((int)$this->cord[$pl['y'] . '_' . $pl['x']]) . ',3:' . $pl['sex'] . ',4:\'' . str_replace( '.gif', '', $pl['obraz'] ) . '\',5:\'bot\',6:' . $pos[$this->cord[$pl['y'] . '_' . $pl['x']]] . ',7:' . $dlg . ',8:' . $noat . '}'; } diff --git a/modules_data/location/dungeon.php b/modules_data/location/dungeon.php index a871d583..24c0840d 100644 --- a/modules_data/location/dungeon.php +++ b/modules_data/location/dungeon.php @@ -549,11 +549,11 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! } } - zfloor0[rz] = '' + zfloor0[rz]; + zfloor0[rz] = '' + zfloor0[rz]; } else { - zfloor0[rz] = '' + zfloor0[rz]; + zfloor0[rz] = '' + zfloor0[rz]; } - r = ''; + r = ''; } return r; } @@ -613,11 +613,11 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! if (v[5] == 'bot' || info['bsid'];?> > 0) { action = 'dialogMenu(' + v[0] + ',' + v[8] + ',' + v[7] + ',0,0,event,' + v[9] + ');'; } - zfloor0[rz] += ''; + zfloor0[rz] += ''; } else { - zfloor0[rz] += ''; + zfloor0[rz] += ''; } - r = ''; + r = ''; } return r; } @@ -764,9 +764,9 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! } $r = '
' . $xrz . '/' . $r . '
-
-
-
+
+
+

'; $qsee .= 'Задание:   ' . $pl['info'] . ' ' . $r . '
'; @@ -782,14 +782,14 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! + style="background-image:url(/maze_layer.jpg); background-repeat:no-repeat;">
- +
@@ -846,7 +846,7 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! position: absolute; top: -8px; left: -6px; - / / background-image: url("//img.new-combats.tech/drgn/bg/r.gif"); + / / background-image: url("/drgn/bg/r.gif"); } @@ -889,7 +889,7 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! $sb1 = Db::getRow('select x, y from dungeon_obj where name like ? and dn = ? limit 1', ['%Шайба%', $d->info['id']]); while($pl = mysql_fetch_array($sp)) { - $css = '"background-image":"url(//img.new-combats.tech/fon555.png)",'; + $css = '"background-image":"url('. Config::img() .'/fon555.png)",'; $j = 0; while ($j < 4) { @@ -902,7 +902,7 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! } if(!empty($sb1) && $sb1['x'] == $pl['x'] && $sb1['y'] == $pl['y'] ) { - echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("info['s'] . '\" title=\"Шайба!\" style=\"margin:2px 3px 3px 2px;background-image:url(//img.new-combats.tech/i/move/shb.gif)\" src=\"//img.new-combats.tech/1x1.gif\" width=\"7\" height=\"7\">");'; + echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("info['s'] . '\" title=\"Шайба!\" style=\"margin:2px 3px 3px 2px;background-image:url('. Config::img() .'/i/move/shb.gif)\" src=\"'. Config::img() .'/1x1.gif\" width=\"7\" height=\"7\">");'; }elseif ($u->info['x'] == $pl['x'] && $u->info['y'] == $pl['y']) { if ($d->info['id2'] == 15) { $tmbth = 4; @@ -912,9 +912,9 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! } elseif ($tm['team'] == 2) { $tmbth = 2; } - echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("info['s'] . '\" title=\"Это Вы\" style=\"margin:2px 3px 3px 2px;background-image:url(//img.new-combats.tech/i/move/p' . $tmbth . '/d0.gif)\" src=\"//img.new-combats.tech/1x1.gif\" width=\"7\" height=\"7\">");'; + echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("info['s'] . '\" title=\"Это Вы\" style=\"margin:2px 3px 3px 2px;background-image:url('. Config::img() .'/i/move/p' . $tmbth . '/d0.gif)\" src=\"'. Config::img() .'/1x1.gif\" width=\"7\" height=\"7\">");'; } else { - echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("info['s'] . '\" title=\"Это Вы\" style=\"margin:2px 3px 3px 2px;background-image:url(//img.new-combats.tech/i/move/p1/d0.gif)\" src=\"//img.new-combats.tech/1x1.gif\" width=\"7\" height=\"7\">");'; + echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("info['s'] . '\" title=\"Это Вы\" style=\"margin:2px 3px 3px 2px;background-image:url('. Config::img() .'/i/move/p1/d0.gif)\" src=\"'. Config::img() .'/1x1.gif\" width=\"7\" height=\"7\">");'; } } elseif ($d->info['id2'] == 15) { $tmbth = 4; @@ -930,12 +930,12 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! ) ); if (isset($tbshin['id'])) { - echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("info['s'] . '\" title=\"Шайба!\" style=\"margin:2px 3px 3px 2px;background-image:url(//img.new-combats.tech/i/move/shb.gif)\" src=\"//img.new-combats.tech/1x1.gif\" width=\"7\" height=\"7\">");'; + echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("info['s'] . '\" title=\"Шайба!\" style=\"margin:2px 3px 3px 2px;background-image:url('. Config::img() .'/i/move/shb.gif)\" src=\"'. Config::img() .'/1x1.gif\" width=\"7\" height=\"7\">");'; } else { - echo '$("#min_' . $uxy[$pl['x'] . '_' . $pl['y']]['x'] . '_' . $uxy[$pl['x'] . '_' . $pl['y']]['y'] . '").html("");'; + echo '$("#min_' . $uxy[$pl['x'] . '_' . $pl['y']]['x'] . '_' . $uxy[$pl['x'] . '_' . $pl['y']]['y'] . '").html("");'; } }elseif (isset($uxy[$pl['x'] . '_' . $pl['y']])) { - echo '$("#min_' . $uxy[$pl['x'] . '_' . $pl['y']]['x'] . '_' . $uxy[$pl['x'] . '_' . $pl['y']]['y'] . '").html("");'; + echo '$("#min_' . $uxy[$pl['x'] . '_' . $pl['y']]['x'] . '_' . $uxy[$pl['x'] . '_' . $pl['y']]['y'] . '").html("");'; } elseif( isset($bxy[$pl['x'] . '_' . $pl['y']]) ) { $bobrz = $bxy[$pl['x'] . '_' . $pl['y']]['obraz']; @@ -947,7 +947,7 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! } ?> - $("#min__").html("
' src='//img.new-combats.tech/chars//'>
"); + $("#min__").html("
' src='/chars//'>
"); point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] !
- +
- + testGone(3) > 0) { ?> - + testGone(4) > 0) { ?> - + testGone(2) > 0) { ?> - + testGone(1) > 0) { ?> - + - - + +
@@ -1032,7 +1032,7 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! 28 => 'RightSide0_0', ]; foreach ($map as $k => $v) { - if ($d->walls[$k] === 1) { + if (isset($d->walls[$k]) && $d->walls[$k] === 1) { continue; } $map[$k] = '';