Пещеры заселились живностью.

This commit is contained in:
2023-09-30 04:31:32 +03:00
parent 3b4bbf3a6a
commit eb971fbc65
3 changed files with 526 additions and 694 deletions
+190 -144
View File
@@ -28,6 +28,18 @@ class Dungeon
4 => [1 => 4, 2 => 1, 3 => 2, 4 => 3],
];
/**
* 1-9: передняя стенка, в 2-х шагах;<br>
* 10-23: растояние: 1 шаг;<br>
* 24: стена прямо слева от персонажа;<br>
* 25: стена прямо справа от персонажа;<br>
* 26: стена прямо перед персонажем;<br>
* 27: стена слева от персонажа;<br>
* 28: стена справа от персонажа;
* @var array
*/
public readonly array $walls;
public function __construct(User $user = null)
{
if (!$user) {
@@ -1522,7 +1534,7 @@ class Dungeon
//Розыгрыш предмета
public function genMatix()
public function genMatix(): array
{
$r = [];
if ($this->gs == 1) {
@@ -1619,101 +1631,109 @@ class Dungeon
global $u;
$this->cord['x']++;
$this->cord[($u->info['y'] + $y) . '_' . ($u->info['x'] + $x)] = $this->cord['x'];
return $this->map[0][($u->info['y'] + $y) . '_' . ($u->info['x'] + $x)];
return $this->map[0][($u->info['y'] + $y) . '_' . ($u->info['x'] + $x)] ?? [];
}
public function lookDungeon()
private function lookDungeon()
{
global $u, $c, $code, $pd;
/* Генерируем изображение карты */ /* LEVEL 1 */
$pd = array_fill(1, 28, 0);
// Исправления от 29/10/2014 относительно D5, 2 этаж, ПТП. Покрутиться и все гуд. и от 22/11/2014 для обратных стен. Если стена к нам задницей, мы её не видим.
if ($this->testSt(2, 4) > 0 /* || $this->testSt(3,2)>0 */) {
global $pd;
/* Генерируем изображение карты */
/* LEVEL 1 */
if ($this->testSt(2, 4)) {
$pd[28] = 1;
}
if (/*$this->testSt(1,4)>0 ||*/ $this->testSt(2, 2) > 0) {
if ($this->testSt(2, 2)) {
$pd[27] = 1;
}
if ($this->testSt(2, 1) > 0 /*|| $this->testSt(5,3)>0*/) {
if ($this->testSt(2, 1)) {
$pd[26] = 1;
}
if ($this->testSt(3, 1) > 0/* || $this->testSt(6,3)>0*/) {
if ($this->testSt(3, 1)) {
$pd[25] = 1;
}
if ($this->testSt(1, 1) > 0 /*|| $this->testSt(4,3)>0*/) {
if ($this->testSt(1, 1)) {
$pd[24] = 1;
}
/* LEVEL 2 */
if ($this->testSt(5, 4) > 0 /*|| $this->testSt(6,2)>0*/) {
if ($this->testSt(5, 4)) {
$pd[23] = 1;
}
if (/*$this->testSt(4,4)>0 || */ $this->testSt(5, 2) > 0) {
if ($this->testSt(5, 2)) {
$pd[22] = 1;
}
if ($this->testSt(5, 1) > 0 /*|| $this->testSt(8,3)>0*/) {
if ($this->testSt(5, 1)) {
$pd[21] = 1;
}
if ($this->testSt(6, 1) > 0 /*|| $this->testSt(7,3)>0*/) {
if ($this->testSt(6, 1)) {
$pd[20] = 1;
}
if ($this->testSt(4, 1) > 0/* || $this->testSt(9,3)>0*/) {
if ($this->testSt(4, 1)) {
$pd[19] = 1;
}
/* LEVEL 3 */
if ($this->testSt(8, 4) > 0 /*|| $this->testSt(7,2)>0*/) {
if ($this->testSt(8, 4)) {
$pd[18] = 1;
}
if (/*$this->testSt(9,4)>0 || */ $this->testSt(8, 2) > 0) {
if ($this->testSt(8, 2)) {
$pd[17] = 1;
}
if ($this->testSt(8, 1) > 0 /* || $this->testSt(12,3)>0*/) {
if ($this->testSt(8, 1)) {
$pd[16] = 1;
}
if ($this->testSt(7, 1) > 0 /* || $this->testSt(13,3)>0*/) {
if ($this->testSt(7, 1)) {
$pd[15] = 1;
}
if ($this->testSt(9, 1) > 0 /*|| $this->testSt(11,3)>0*/) {
if ($this->testSt(9, 1)) {
$pd[14] = 1;
}
/* LEVEL 4 */
if ($this->testSt(12, 4) > 0 || $this->testSt(13, 2) > 0) {
if ($this->testSt(12, 4) || $this->testSt(13, 2)) {
$pd[13] = 1;
}
if ($this->testSt(12, 2) > 0 || $this->testSt(11, 4) > 0) {
if ($this->testSt(12, 2) || $this->testSt(11, 4)) {
$pd[12] = 1;
}
if ($this->testSt(13, 1) > 0 || $this->testSt(17, 3) > 0) {
if ($this->testSt(13, 1) || $this->testSt(17, 3)) {
$pd[11] = 1;
} //8
if ($this->testSt(11, 1) > 0 || $this->testSt(16, 3) > 0) {
if ($this->testSt(11, 1) || $this->testSt(16, 3)) {
$pd[10] = 1;
} //7
if ($this->testSt(12, 1) > 0/* || $this->testSt(15,3)>0*/) {
if ($this->testSt(12, 1)) {
$pd[9] = 1;
}
if ($this->testSt(14, 1) > 0 || $this->testSt(18, 3) > 0) {
if ($this->testSt(14, 1) || $this->testSt(18, 3)) {
$pd[6] = 1;
} //2
if ($this->testSt(10, 1) > 0 || $this->testSt(19, 3) > 0) {
if ($this->testSt(10, 1) || $this->testSt(19, 3)) {
$pd[5] = 1;
} //1
if ($this->testSt(16, 4) > 0 || $this->testSt(15, 2) > 0) {
if ($this->testSt(16, 4) || $this->testSt(15, 2)) {
$pd[4] = 1;
}
if ($this->testSt(15, 4) > 0 || $this->testSt(17, 2) > 0) {
if ($this->testSt(15, 4) || $this->testSt(17, 2)) {
$pd[3] = 1;
}
$this->walls = $pd;
/* Генерируем предметы на карте */
/* Генерируем персонажей и ботов на карте */
}
public function testSt($id, $s)
/** Видим ли мы стену?
* @param int $id
* @param int $s в какую сторону смотрим
* @return bool
*/
private function testSt(int $id, int $s): bool
{
$r = 0;
//заменяем отображение стен в зависимости от угла обзора
@@ -1721,7 +1741,7 @@ class Dungeon
if (isset($this->map[1][$id]['id'])) {
$r = $this->map[1][$id]['st'][($s - 1)];
}
return $r;
return $r > 0;
}
public function initPoint(int $x, int $y): void
@@ -1740,8 +1760,6 @@ class Dungeon
}
$tou = 0; //какому юзеру предназначено
/* выделяем случайного юзера из команды */
$itmnm = mysql_fetch_assoc(mysql_query('SELECT `name` FROM `items_main` WHERE `id` = "' . $itm . '" LIMIT 1'));
$itmnm = $itmnm['name'];
$asex = '';
if ($u->info['sex'] == 1) {
$asex = 'а';
@@ -1773,17 +1791,11 @@ class Dungeon
return true;
}
public function n_lead($who, $lead)
public function n_lead(string $who, int $lead): void
{
global $u, $c, $code;
global $u;
$to = mysql_fetch_assoc(
mysql_query(
'SELECT `u`.`id`, `u`.`login`, `st`.`id`, `st`.`dnow` FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON (`u`.`id` = `st`.`id`) WHERE `u`.`login` = "' . mysql_real_escape_string(
$who
) . '" LIMIT 1'
)
);
$to = Db::getRow('select stats.id, dnow from users left join stats on users.id = stats.id where login = ?', [$who]);
if ($this->info['uid'] != $lead) {
$this->error = '<b>Вы не лидер...</b>';
@@ -1799,29 +1811,23 @@ class Dungeon
);
if ($u->info['sex'] == 0) {
$this->sys_chat(
'<b>' . $u->info['login'] . '</b> передал лидерство в группе персонажу <b>' . $to['login'] . '</b>'
'<b>' . $u->info['login'] . '</b> передал лидерство в группе персонажу <b>' . $who . '</b>'
);
} else {
$this->sys_chat(
'<b>' . $u->info['login'] . '</b> передала лидерство в группе персонажу <b>' . $to['login'] . '</b>'
'<b>' . $u->info['login'] . '</b> передала лидерство в группе персонажу <b>' . $who . '</b>'
);
}
//header('Location: main.php');
die('<script>top.frames[\'main\'].location = "main.php";</script>');
exit("<script>top.frames['main'].location = 'main.php'</script>");
}
}
public function go_to_hell($who, $lead)
public function go_to_hell(string $who, int $lead): void
{
global $u, $c, $code;
global $u;
$to = mysql_fetch_assoc(
mysql_query(
'SELECT `u`.`id`, `u`.`login`, `st`.`id`, `st`.`dnow` FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON (`u`.`id` = `st`.`id`) WHERE `u`.`login` = "' . mysql_real_escape_string(
$who
) . '" LIMIT 1'
)
);
$to = Db::getRow('select stats.id, dnow from users left join stats on users.id = stats.id where login = ?', [$who]);
if ($this->info['uid'] != $lead) {
$this->error = '<b>Вы не лидер...</b>';
@@ -1837,8 +1843,6 @@ class Dungeon
$rb = 209; // Вход в ледяную пещеру
} elseif ($u->info['room'] == 396) {
$rb = 395; // Канализация (Ангелс)
} elseif ($u->info['room'] == 398) {
$rb = 321; // Все пещеры
} elseif ($this->info['id2'] == 3) {
$rb = 293; // Вход в Катакомбы
} elseif ($this->info['id2'] == 1) {
@@ -1847,15 +1851,9 @@ class Dungeon
$rb = 275; // Гора Легиона
} elseif ($this->info['id2'] == 12) {
$rb = 372; // Вход в Пещеру Тысячи Проклятий
} elseif ($this->info['id2'] == 444) {
$rb = 321; // Вход в пещеру инкв
} elseif ($this->info['id2'] == 31) {
$rb = 321; // Вход в пещеру инкв
} elseif ($this->info['id2'] == 101) {
$rb = 321; // Вход в Бездну
}
$sp = mysql_query('SELECT * FROM `dungeon_now` WHERE `time_finish` = "0" LIMIT 50');
while ($pl = mysql_fetch_assoc($sp)) {
$cn = mysql_fetch_assoc(
@@ -1891,14 +1889,15 @@ class Dungeon
if ($u->info['sex'] == 0) {
$this->sys_chat(
'<b>' . $u->info['login'] . '</b> выгнал из похода персонажа <b>' . $to['login'] . '</b>'
'<b>' . $u->info['login'] . '</b> выгнал из похода персонажа <b>' . $who . '</b>'
);
} else {
$this->sys_chat(
'<b>' . $u->info['login'] . '</b> выгнала из похода персонажа <b>' . $to['login'] . '</b>'
'<b>' . $u->info['login'] . '</b> выгнала из похода персонажа <b>' . $who . '</b>'
);
}
header('Location: /main.php');
exit("<script>top.frames['main'].location = 'main.php'</script>");
}
}
@@ -2067,7 +2066,7 @@ class Dungeon
public function genObjects()
{
global $u, $c, $code;
global $u;
////i:{id,name,mapPoint,action,img,type},
//'count':1,0:{0:1234,1:'Сундук',2:5,3:'',4:'test.gif',5:0,6:position,7:width,8:heigh,9:left,10:top},
//psition 0 - по центру , 1- сверху, 2- слева, 3- снизу, 4- справа
@@ -2083,74 +2082,103 @@ class Dungeon
$i = 0;
$pos = [];
while ($pl = mysql_fetch_assoc($sp)) {
if ($pl['fix_x_y'] == 0 || ($pl['fix_x_y'] == 1 && $pl['x'] == $u->info['x']) || ($pl['fix_x_y'] == 2 && $pl['y'] == $u->info['y']) || ($pl['fix_x_y'] == 3 && $pl['x'] == $u->info['x'] && $pl['y'] == $u->info['y'])) {
if (($pl['os1'] == 0 && $pl['os2'] == 0 && $pl['os3'] == 0 && $pl['os4'] == 0) || ($this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os1'] || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os2'] || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os3'] || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os4'])) {
$i++;
if (!isset($pos[$this->cord[$pl['y'] . '_' . $pl['x']]])) {
$pos[$this->cord[$pl['y'] . '_' . $pl['x']]] = 0;
}
$pos[$this->cord[$pl['y'] . '_' . $pl['x']]]++;
$r .= ',' . ($i - 1) . ':{0:' . $pl['id'] . ',1:\'' . $pl['name'] . '\',2:' . (0 + $this->cord[$pl['y'] . '_' . $pl['x']]) . ',3:\'action\',4:\'' . $pl['img'] . '\',5:' . $pl['type'] . ',6:0,7:' . $pl['w'] . ',8:' . $pl['h'] . ',9:' . $pl['left'] . ',10:' . $pl['top'] . ',11:' . $pl['date'] . '}';
} elseif ($this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os1'] - 1 || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os2'] - 1 || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os3'] - 1 || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os4'] - 1) {
$dt2 = explode(',', ltrim(rtrim($pl['date'], '\}'), '\{'));
$da = [];
$is = 0;
while ($is < count($dt2)) {
$dt2[$is] = explode(':', $dt2[$is]);
$da[$dt2[$is][0]] = $dt2[$is][1];
$is++;
}
if (isset($da['use'])) {
unset($da['use']);
} // Справа
if (isset($da['rl2'])) {
$da['rl2'] = -round((int)$da['rl2'] * 1.55);
} // Слева
if (isset($da['rl3'])) {
$da['rl3'] = round((int)$da['rl3'] + 160);
}
if (isset($da['rl4'])) {
$da['rl4'] = round((int)$da['rl4'] - 120);
}
$pl['date'] = str_replace('"', '', json_encode($da));
if (!isset($this->cord[$pl['y'] . '_' . $pl['x']])) {
continue;
}
if (
$pl['fix_x_y'] != 0 &&
($pl['fix_x_y'] != 1 || $pl['x'] != $u->info['x']) &&
($pl['fix_x_y'] != 2 || $pl['y'] != $u->info['y']) &&
($pl['fix_x_y'] != 3 || $pl['x'] != $u->info['x'] || $pl['y'] != $u->info['y'])
) {
continue;
}
$i++;
if (!isset($pos[$this->cord[$pl['y'] . '_' . $pl['x']]])) {
$pos[$this->cord[$pl['y'] . '_' . $pl['x']]] = 0;
}
$pos[$this->cord[$pl['y'] . '_' . $pl['x']]]++;
$r .= ',' . ($i - 1) . ':{0:' . $pl['id'] . ',1:\'' . $pl['name'] . '\',2:' . (0 + $this->cord[$pl['y'] . '_' . $pl['x']]) . ',3:\'\',4:\'' . $pl['img'] . '\',5:' . $pl['type'] . ',6:0,7:' . $pl['w'] . ',8:' . $pl['h'] . ',9:' . $pl['left'] . ',10:' . $pl['top'] . ',11:' . $pl['date'] . '}';
} elseif ($this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os1'] + 1 || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os2'] + 1 || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os3'] + 1 || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os4'] + 1) {
$dt2 = explode(',', ltrim(rtrim($pl['date'], '\}'), '\{'));
$da = [];
$is = 0;
while ($is < count($dt2)) {
$dt2[$is] = explode(':', $dt2[$is]);
$da[$dt2[$is][0]] = $dt2[$is][1];
$is++;
}
if (isset($da['use'])) {
unset($da['use']);
} // Справа
if (isset($da['rl2'])) {
$da['rl2'] = 355 - round((int)$da['rl2'] * 0.30);
} // Справа
if (isset($da['rl3'])) {
$da['rl3'] = round((int)$da['rl3'] - 160);
}
if (isset($da['rl4'])) {
$da['rl4'] = round((int)$da['rl4'] + 120);
}
$pl['date'] = str_replace('"', '', json_encode($da));
$i++;
if (!isset($pos[$this->cord[$pl['y'] . '_' . $pl['x']]])) {
$pos[$this->cord[$pl['y'] . '_' . $pl['x']]] = 0;
}
$pos[$this->cord[$pl['y'] . '_' . $pl['x']]]++;
$r .= ',' . ($i - 1) . ':{0:' . $pl['id'] . ',1:\'' . $pl['name'] . '\',2:' . (0 + $this->cord[$pl['y'] . '_' . $pl['x']]) . ',3:\'\',4:\'' . $pl['img'] . '\',5:' . $pl['type'] . ',6:0,7:' . $pl['w'] . ',8:' . $pl['h'] . ',9:' . $pl['left'] . ',10:' . $pl['top'] . ',11:' . $pl['date'] . '}';
if (
($pl['os1'] == 0 && $pl['os2'] == 0 && $pl['os3'] == 0 && $pl['os4'] == 0) ||
(
$this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os1'] ||
$this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os2'] ||
$this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os3'] ||
$this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os4']
)
) {
$i++;
if (!isset($pos[$this->cord[$pl['y'] . '_' . $pl['x']]])) {
$pos[$this->cord[$pl['y'] . '_' . $pl['x']]] = 0;
}
$pos[$this->cord[$pl['y'] . '_' . $pl['x']]]++;
$r .= ',' . ($i - 1) . ':{0:' . $pl['id'] . ',1:\'' . $pl['name'] . '\',2:' . (0 + $this->cord[$pl['y'] . '_' . $pl['x']]) . ',3:\'action\',4:\'' . $pl['img'] . '\',5:' . $pl['type'] . ',6:0,7:' . $pl['w'] . ',8:' . $pl['h'] . ',9:' . $pl['left'] . ',10:' . $pl['top'] . ',11:' . $pl['date'] . '}';
} elseif (
$this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os1'] - 1 ||
$this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os2'] - 1 ||
$this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os3'] - 1 ||
$this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os4'] - 1
) {
$dt2 = explode(',', ltrim(rtrim($pl['date'], '\}'), '\{'));
$da = [];
$is = 0;
while ($is < count($dt2)) {
$dt2[$is] = explode(':', $dt2[$is]);
$da[$dt2[$is][0]] = $dt2[$is][1];
$is++;
}
if (isset($da['use'])) {
unset($da['use']);
} // Справа
if (isset($da['rl2'])) {
$da['rl2'] = -round((int)$da['rl2'] * 1.55);
} // Слева
if (isset($da['rl3'])) {
$da['rl3'] = round((int)$da['rl3'] + 160);
}
if (isset($da['rl4'])) {
$da['rl4'] = round((int)$da['rl4'] - 120);
}
$pl['date'] = str_replace('"', '', json_encode($da));
$i++;
if (!isset($pos[$this->cord[$pl['y'] . '_' . $pl['x']]])) {
$pos[$this->cord[$pl['y'] . '_' . $pl['x']]] = 0;
}
$pos[$this->cord[$pl['y'] . '_' . $pl['x']]]++;
$r .= ',' . ($i - 1) . ':{0:' . $pl['id'] . ',1:\'' . $pl['name'] . '\',2:' . (0 + $this->cord[$pl['y'] . '_' . $pl['x']]) . ',3:\'\',4:\'' . $pl['img'] . '\',5:' . $pl['type'] . ',6:0,7:' . $pl['w'] . ',8:' . $pl['h'] . ',9:' . $pl['left'] . ',10:' . $pl['top'] . ',11:' . $pl['date'] . '}';
} elseif (
$this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os1'] + 1 ||
$this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os2'] + 1 ||
$this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os3'] + 1 ||
$this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os4'] + 1
) {
$dt2 = explode(',', ltrim(rtrim($pl['date'], '\}'), '\{'));
$da = [];
$is = 0;
while ($is < count($dt2)) {
$dt2[$is] = explode(':', $dt2[$is]);
$da[$dt2[$is][0]] = $dt2[$is][1];
$is++;
}
if (isset($da['use'])) {
unset($da['use']);
} // Справа
if (isset($da['rl2'])) {
$da['rl2'] = 355 - round((int)$da['rl2'] * 0.30);
} // Справа
if (isset($da['rl3'])) {
$da['rl3'] = round((int)$da['rl3'] - 160);
}
if (isset($da['rl4'])) {
$da['rl4'] = round((int)$da['rl4'] + 120);
}
$pl['date'] = str_replace('"', '', json_encode($da));
$i++;
if (!isset($pos[$this->cord[$pl['y'] . '_' . $pl['x']]])) {
$pos[$this->cord[$pl['y'] . '_' . $pl['x']]] = 0;
}
$pos[$this->cord[$pl['y'] . '_' . $pl['x']]]++;
$r .= ',' . ($i - 1) . ':{0:' . $pl['id'] . ',1:\'' . $pl['name'] . '\',2:' . (0 + $this->cord[$pl['y'] . '_' . $pl['x']]) . ',3:\'\',4:\'' . $pl['img'] . '\',5:' . $pl['type'] . ',6:0,7:' . $pl['w'] . ',8:' . $pl['h'] . ',9:' . $pl['left'] . ',10:' . $pl['top'] . ',11:' . $pl['date'] . '}';
}
}
return 'count:' . $i . $r;
@@ -2158,15 +2186,24 @@ class Dungeon
public function genUsers()
{
global $u, $c, $code;
global $u;
////i:{id,login,mapPoint,sex,obraz,type,users_p},
//'count':1,0:{0:1015,1:'Test1',2:5,3:0,4:'1',5:'user',6:1},
$r = '';
$whr = [1 => ' ((`u`.`x` <= ' . ($u->info['x'] + 2) . ' && `u`.`x` >= ' . ($u->info['x'] - 2) . ') && (`u`.`y` >= ' . $u->info['y'] . ' && `u`.`y` <= ' . ($u->info['y'] + 4) . ')) ', //прямо
3 => ' ((`u`.`x` <= ' . ($u->info['x'] + 2) . ' && `u`.`x` >= ' . ($u->info['x'] - 2) . ') && (`u`.`y` <= ' . $u->info['y'] . ' && `u`.`y` >= ' . ($u->info['y'] - 4) . ')) ', //вниз
2 => ' ((`u`.`x` <= ' . $u->info['x'] . ' && `u`.`x` >= ' . ($u->info['x'] - 4) . ') && (`u`.`y` <= ' . ($u->info['y'] + 2) . ' && `u`.`y` >= ' . ($u->info['y'] - 2) . ')) ', //лево
4 => ' ((`u`.`x` >= ' . $u->info['x'] . ' && `u`.`x` <= ' . ($u->info['x'] + 4) . ') && (`u`.`y` <= ' . ($u->info['y'] + 2) . ' && `u`.`y` >= ' . ($u->info['y'] - 2) . ')) ', //право
$whr = [
1 => ' ((x <= ' . ($u->info['x'] + 2) . ' && x >= ' . ($u->info['x'] - 2) . ') && (y >= ' . $u->info['y'] . ' && y <= ' . ($u->info['y'] + 4) . ')) ', //прямо
2 => ' ((x <= ' . $u->info['x'] . ' && x >= ' . ($u->info['x'] - 4) . ') && (y <= ' . ($u->info['y'] + 2) . ' && y >= ' . ($u->info['y'] - 2) . ')) ', //лево
3 => ' ((x <= ' . ($u->info['x'] + 2) . ' && x >= ' . ($u->info['x'] - 2) . ') && (y <= ' . $u->info['y'] . ' && y >= ' . ($u->info['y'] - 4) . ')) ', //вниз
4 => ' ((x >= ' . $u->info['x'] . ' && x <= ' . ($u->info['x'] + 4) . ') && (y <= ' . ($u->info['y'] + 2) . ' && y >= ' . ($u->info['y'] - 2) . ')) ', //право
];
$whrVals = [ // x <= ? && x >= ? && y <= ? && y >= ?
1 => [$u->info['x'] + 2, $u->info['x'] - 2, $u->info['y'] + 4, $u->info['y'],], // прямо x< x> y< y>
2 => [$u->info['x'], $u->info['x'] - 4, $u->info['y'] + 2, $u->info['y'] - 2,], // лево x< x> y< y>
3 => [$u->info['x'] + 2, $u->info['x'] - 2, $u->info['y'], $u->info['y'] - 4,], // низ x< x> y< y>
4 => [$u->info['x'] + 4, $u->info['x'], $u->info['y'] + 2, $u->info['y'] - 2,], // право x< x> y< y>
];
//
$tmsu = mysql_fetch_assoc(
mysql_query('SELECT * FROM `katok_now` WHERE `clone` = "' . $u->info['id'] . '" LIMIT 1')
@@ -2266,10 +2303,19 @@ class Dungeon
}
}
$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)) {
$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)) {
$i++;
if (!isset($pos[$this->cord[$pl['y'] . '_' . $pl['x']]])) {
$pos[$this->cord[$pl['y'] . '_' . $pl['x']]] = 0;