Ремонт входа ботов в бой.
This commit is contained in:
+71
-123
@@ -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 .= 'Предмет "<b>' . $uitm['name'] . '</b>" (x' . $itm[1] . ') был утрачен...<br>';
|
||||
$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[] = ' <strong>' . $k['login'] . '</strong>';
|
||||
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} В поединок вмешались: <strong>' . implode(', ', $botNamesArray) . '</strong>.',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
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 . '}';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user