room['file'] != 'dungeon_enter_all') { return; } $error = ''; // Собираем ошибки. $dungeonGroupList = ''; // Сюда помещаем список Групп. $dungeonGo = 1; // По умолчанию, мы идем в пещеру. $dungeon = mysql_fetch_assoc(mysql_query('SELECT `id` as room, city, `dungeon_room` as d_room, city, `shop`, `dungeon_id` as id, `dungeon_name` as name, quest FROM `dungeon_room` WHERE `id`="' . $u->room['id'] . '" LIMIT 1')); // $dungeon['quest'] = 1; // $dunname = [ 12 => ['capitalcity', 'Пещера Тысячи Проклятий'], 3 => ['demonscity', 'Катакомбы'], 101 => ['angelscity', 'Бездна'], 16 => ['sandcity', 'Пещеры Мглы'], 9 => ['emeraldscity', 'Потерянный вход'], //108 10 => ['suncity', 'Грибница'], 1 => ['dreamscity', 'Водосток'], 13 => ['abandonedplain', 'Гора Легиона'], 31 => ['devilscity', 'Туманные Низины'], 109 => ['izlom16', 'Излом Хаоса'], 444 => ['eastcity', 'Тропа Инквизиции'], ]; if ($u->isAdmin()) { $dunname[999] = ['capitalcity', 'Тестовая локация']; } $roomSection = isset($_GET['rz']) && $dungeon['quest'] == 1 ? 1 : 0; // Собираем группу для похода $all_dungeon = mysql_query('SELECT `city` FROM `dungeon_room` WHERE `city` IS NOT NULL AND `active`=1 '); while ($t = mysql_fetch_array($all_dungeon)) { $dungeon['list'][] = $t['city']; } unset($all_dungeon); if ($u->info['dn'] > 0) { $zv = mysql_fetch_array(mysql_query('SELECT * FROM `dungeon_zv` WHERE `id`="' . $u->info['dn'] . '" AND `delete` = "0" LIMIT 1')); if (!isset($zv['id'])) { mysql_query('UPDATE `stats` SET `dn` = "0" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'); $u->info['dn'] = 0; } } $dungeon_timeout = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `vars` = "psh0" AND `time` > ' . (time() - 60 * 60 * 2) . ' LIMIT 1', 1); if ($u->info['admin'] > 0) unset($dungeon_timeout); // $dungeon_timeout - задержка на посещение пещеры. if (isset($dungeon_timeout['id'])) // Кто-то передумал и не пойдет в пещеру, так-как уже там был. { $dungeonGo = 0; if (isset($_GET['start'])) { $error = 'До следующего похода осталось еще: ' . $u->timeOut(60 * 60 * 2 - time() + $dungeon_timeout['time']); } } if (isset($_GET['start']) && $zv['uid'] == $u->info['id'] && $dungeonGo == 1) { $ig = 1; if ($ig > 0) { //перемещаем игроков в пещеру $dungeon['room'] = 321; $dungeon['id'] = $zv['dun']; // $ins = mysql_query('INSERT INTO `dungeon_now` (`city`,`uid`,`id2`,`name`,`time_start`) VALUES ("' . $zv['city'] . '","' . $zv['uid'] . '","' . $zv['dun'] . '","' . $dunname[$zv['dun']][1] . '","' . time() . '")'); if ($ins) { $zid = mysql_insert_id(); mysql_query('UPDATE `dungeon_zv` SET `delete` = "' . time() . '" WHERE `id` = "' . $zv['id'] . '" LIMIT 1'); //обновляем пользователей $su = mysql_query('SELECT `u`.`id`,`st`.`dn` FROM `stats` AS `st` LEFT JOIN `users` AS `u` ON (`st`.`id` = `u`.`id`) WHERE `st`.`dn`="' . $zv['id'] . '" /*LIMIT ' . ($zv['team_max'] + 1) . '*/'); $ids = ''; $map_locs = []; $spm2 = mysql_query('SELECT `id`,`x`,`y` FROM `dungeon_map` WHERE `id_dng` = "' . $zv['dun'] . '"'); while ($plm2 = mysql_fetch_array($spm2)) { $map_locs[] = [$plm2['x'], $plm2['y']]; } unset($spm2, $plm2); $pxd = 0; while ($pu = mysql_fetch_array($su)) { $pxd++; $ids .= ' `id` = "' . $pu['id'] . '" OR'; if ($u->stats['silver'] >= 3) { $u->addAction((time() - ((60 * 60 * 2) / 100 * 30)), 'psh0', $pu['id'], $pu['id']); } else { $u->addAction(time(), 'psh0', $pu['id'], $pu['id']); } if (date('w') == 0 || date('w') == 6 || date('w') == 1) { StatsModel::addRepexpById($pu['id'], 5); //Репутация +5 } //Добавляем квестовые обьекты для персонажей $sp = mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `room` = ' . $dungeon['room'] . ' AND `vars` LIKE "%start_quest%" AND `vals` = "go" LIMIT 100'); while ($pl2 = mysql_fetch_array($sp)) { $pl = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `id` = "' . (str_replace('start_quest', '', $pl2['vars'])) . '" AND `line` = "' . $dungeon['id'] . '" LIMIT 1')); if (isset($pl['id'])) { $act = explode(',', $pl['act_date']); $i = 0; while ($i < count($act)) { $act_date = explode(':|:', $act[$i]); foreach ($act_date as $key => $val) { $val = explode(':=:', $val); $actdate[$val[0]] = $val[1]; } //Сбор ресурсов if (isset($actdate['tk_itm']) && $actdate['tk_itm'] != '') { $xr2 = explode('=', $actdate['tk_itm']); if ($xr2[2] == 0) { if (isset($actdate['tk_itm_fromY']) && isset($actdate['tk_itm_toY'])) { $actdate['tk_itm_fromY'] = (integer)$actdate['tk_itm_fromY']; $actdate['tk_itm_toY'] = (integer)$actdate['tk_itm_toY']; } $ml_arr = []; foreach ($map_locs as $ml) { // tk_itm_fromY tk_itm_toY - отсеиваем позицию для дропа предметов. if ((isset($actdate['tk_itm_fromY']) && isset($actdate['tk_itm_toY'])) or (!isset($actdate['tk_itm_fromY']) && isset($actdate['tk_itm_toY']))) { if ($ml[1] > $actdate['tk_itm_fromY'] && $actdate['tk_itm_toY'] > $ml[1]) $ml_arr[] = $ml; elseif (!isset($actdate['tk_itm_fromY']) && $actdate['tk_itm_toY'] > $ml[1]) $ml_arr[] = $ml; } else $ml_arr[] = $ml; } if (isset($ml_arr) && count($ml_arr) == 0) $ml_arr = $map_locs; //Добавляем обьект для юзера $j = 0; while ($j < $xr2[1]) { $cord = $ml_arr[rand(0, count($ml_arr) - 1)]; if ($cord[0] != 0 || $cord[1] != 0) { mysql_query('INSERT INTO `dungeon_items` (`dn`,`user`,`item_id`,`time`,`x`,`y`,`onlyfor`,`quest`) VALUES ( "' . $zid . '","' . $u->info['id'] . '","' . $xr2[0] . '","' . time() . '","' . $cord[0] . '","' . $cord[1] . '","' . $u->info['id'] . '","' . $pl['id'] . '" )'); } $j++; } } else { //Предмет находится в конкретном месте mysql_query('INSERT INTO `dungeon_items` (`dn`,`user`,`item_id`,`time`,`x`,`y`,`onlyfor`,`quest`) VALUES ( "' . $zid . '","' . $u->info['id'] . '","' . $xr2[0] . '","' . time() . '","' . $xr2[2] . '","' . $xr2[3] . '","' . $u->info['id'] . '","' . $pl['id'] . '" )'); } } $i++; } } } } $ids = rtrim($ids, 'OR'); $snew = 1; $upd1 = mysql_query('UPDATE `stats` SET `s`="' . $snew . '",`res_s`="1",`x`="0",`y`="0",`res_x`="0",`res_y`="0",`dn` = "0",`dnow` = "' . $zid . '" WHERE ' . $ids . ' LIMIT ' . ($zv['team_max'] + 1) . ''); if ($upd1) { $upd2 = mysql_query('UPDATE `users` SET `room` = "405" WHERE ' . $ids . ' LIMIT ' . ($zv['team_max'] + 1) . ''); //Добавляем ботов и обьекты в пещеру $zid с for_dn = $dungeon['id'] //Добавляем ботов $vls = ''; $sp = mysql_query('SELECT * FROM `dungeon_bots` WHERE `for_dn` = "' . $zv['dun'] . '"'); while ($pl = mysql_fetch_array($sp)) { if ($pl['id_bot'] == 0 && $pl['bot_group'] != '') { $bots = explode(',', $pl['bot_group']); $pl['id_bot'] = (int)$bots[rand(0, count($bots) - 1)]; } if ($pl['id_bot'] > 0) $vls .= '("' . $zid . '","' . $pl['id_bot'] . '","' . $pl['colvo'] . '","' . $pl['items'] . '","' . $pl['x'] . '","' . $pl['y'] . '","' . $pl['dialog'] . '","' . $pl['items'] . '","' . $pl['go_bot'] . '","' . $pl['noatack'] . '"),'; unset($bots); } $vls = rtrim($vls, ','); $ins1 = mysql_query('INSERT INTO `dungeon_bots` (`dn`,`id_bot`,`colvo`,`items`,`x`,`y`,`dialog`,`atack`,`go_bot`,`noatack`) VALUES ' . $vls . ''); //Добавляем обьекты $vls = ''; $sp = mysql_query('SELECT * FROM `dungeon_obj` WHERE `for_dn` = "' . $zv['dun'] . '"'); while ($pl = mysql_fetch_array($sp)) { $vls .= '("' . $zid . '","' . $pl['name'] . '","' . $pl['img'] . '","' . $pl['x'] . '","' . $pl['y'] . '","' . $pl['action'] . '","' . $pl['type'] . '","' . $pl['w'] . '","' . $pl['h'] . '","' . $pl['s'] . '","' . $pl['s2'] . '","' . $pl['os1'] . '","' . $pl['os2'] . '","' . $pl['os3'] . '","' . $pl['os4'] . '","' . $pl['type2'] . '","' . $pl['top'] . '","' . $pl['left'] . '","' . $pl['date'] . '"),'; } //Добавление обьектов (день святого валентина) if (floor(date('m')) == 2 && floor(date('d')) >= 7 && floor(date('d')) <= 20) { if (floor(date('m')) == 2 && floor(date('d')) >= 14 && floor(date('d')) <= 20) { //Появляются мобы которые принимают цветы $vlsbts = ''; $ins1bts = null; if ($zv['dun'] == 1) { //4 уровня (КАНАЛИЗАЦИЯ) $vlsbts .= '("' . $zid . '","410","1","","-5","3","8","0","0"),'; //4-7 уровня $vlsbts .= '("' . $zid . '","413","1","","8","46","9","0","0"),'; } elseif ($zv['dun'] == 12) { //(ПТП) //4-7 уровня $vlsbts .= '("' . $zid . '","413","1","","-3","18","9","0","0"),'; //4-9 уровня $vlsbts .= '("' . $zid . '","414","1","","-2","29","10","0","0"),'; } elseif ($zv['dun'] == 3) { //(КАТАКОМБЫ) //4-7 уровня $vlsbts .= '("' . $zid . '","413","1","","15","8","9","0","0"),'; //4-9 уровня $vlsbts .= '("' . $zid . '","414","1","","3","35","10","0","0"),'; } elseif ($zv['dun'] == 101) { //(бездна) //4-7 уровня $vlsbts .= '("' . $zid . '","413","1","","-2","21","9","0","0"),'; //4-9 уровня $vlsbts .= '("' . $zid . '","414","1","","2","43","10","0","0"),'; } if ($vlsbts != '') { $vlsbts = rtrim($vlsbts, ','); $ins1bts = mysql_query('INSERT INTO `dungeon_bots` (`dn`,`id_bot`,`colvo`,`items`,`x`,`y`,`dialog`,`atack`,`go_bot`) VALUES ' . $vlsbts . ''); } unset($vlsbts, $ins1bts); } //Раскидываем предметы по пещере (Блёклый подземник) $dcords = []; $c_sp = mysql_query('SELECT * FROM `dungeon_map` WHERE `id_dng` = "' . $zv['dun'] . '"'); while ($c_pl = mysql_fetch_array($c_sp)) { $dcords[] = [$c_pl['x'], $c_pl['y']]; } $fcords = []; $i = 1; while ($i <= $pxd) { $j = rand(1, 10); while ($j >= 0) { $rndxy = rand(0, count($dcords) - 1); $rndx = $dcords[$rndxy][0]; $rndy = $dcords[$rndxy][1]; $fcords[$rndx][$rndy] = true; unset($dcords[$rndxy]); $vls .= '("' . $zid . '","Блеклый подземник","vbig1.gif","' . $rndx . '","' . $rndy . '","fileact:vbig1","0","81","81","0","0","5","8","12","0","0","0","0","{use:\'takeit\',rt2:154,rl2:146,rt3:139,rl3:154,rt4:125,rl4:161}"),'; $j--; } $i++; } //Раскидываем предметы по пещере (Черепичный подземник) $sp = mysql_query('SELECT * FROM `dungeon_bots` WHERE `for_dn` = "' . $zv['dun'] . '"'); $test = []; $dcords2 = []; $dcords3 = []; while ($pl = mysql_fetch_array($sp)) { if (!isset($test[$pl['id_bot']])) { $test[$pl['id_bot']] = mysql_fetch_array(mysql_query('SELECT * FROM `test_bot` WHERE `id` = "' . $pl['id_bot'] . '" LIMIT 1')); } if (isset($test[$pl['id_bot']]['id']) && $test[$pl['id_bot']] != 2) { if ($test[$pl['id_bot']]['level'] > 6) { $dcords2[] = [$pl['x'], $pl['y']]; } if ($test[$pl['id_bot']]['level'] >= 8 && $test[$pl['id_bot']]['align'] == 9) { $dcords3[] = [$pl['x'], $pl['y']]; } } else { $test[$pl['id_bot']] = 2; } } $i = 1; while ($i <= $pxd) { $j = rand(1, 5); while ($j >= 0) { $rndxy = rand(0, count($dcords2) - 1); $rndx = $dcords2[$rndxy][0]; $rndy = $dcords2[$rndxy][1]; if (!isset($fcords[$rndx][$rndy]) && isset($dcords2[$rndxy][0])) { $fcords[$rndx][$rndy] = true; unset($dcords2[$rndxy]); $vls .= '("' . $zid . '","Черепичный подземник","vbig2.gif","' . $rndx . '","' . $rndy . '","fileact:vbig2","0","81","81","0","0","5","8","12","0","0","0","0","{use:\'takeit\',rt2:154,rl2:146,rt3:139,rl3:154,rt4:125,rl4:161}"),'; } $j--; } $i++; } $i = 1; while ($i <= $pxd) { $j = rand(1, 2); while ($j >= 0) { $rndxy = rand(0, count($dcords3) - 1); $rndx = $dcords3[$rndxy][0]; $rndy = $dcords3[$rndxy][1]; if (!isset($fcords[$rndx][$rndy]) && isset($dcords3[$rndxy][0])) { $fcords[$rndx][$rndy] = true; unset($dcords3[$rndxy]); $vls .= '("' . $zid . '","Кровавый подземник","vbig3.gif","' . $rndx . '","' . $rndy . '","fileact:vbig3","0","81","81","0","0","5","8","12","0","0","0","0","{use:\'takeit\',rt2:154,rl2:146,rt3:139,rl3:154,rt4:125,rl4:161}"),'; } $j--; } $i++; } unset($test); } // $vls = rtrim($vls, ','); if ($vls != '') { $ins2 = mysql_query('INSERT INTO `dungeon_obj` (`dn`,`name`,`img`,`x`,`y`,`action`,`type`,`w`,`h`,`s`,`s2`,`os1`,`os2`,`os3`,`os4`,`type2`,`top`,`left`,`date`) VALUES ' . $vls . ''); } else { $ins2 = true; } if ($upd2 && $ins1 && $ins2) { die(''); } else { $error = 'Ошибка перехода в подземелье...'; } } else { $error = 'Ошибка перехода в подземелье...'; } } else { $error = 'Ошибка перехода в подземелье...'; } } } elseif (isset($_POST['go'], $_POST['goid']) && $dungeonGo == 1) { if (!isset($zv['id'])) { $zv = mysql_fetch_array(mysql_query('SELECT * FROM `dungeon_zv` WHERE `city` = "all" AND `id`="' . mysql_real_escape_string($_POST['goid']) . '" AND `delete` = "0" LIMIT 1')); if (isset($zv['id']) && $u->info['dn'] == 0) { if ($zv['pass'] != '' && $_POST['pass_com'] != $zv['pass']) { $error = 'Вы ввели неправильный пароль'; } elseif ($u->info['level'] > 7 && $zv['dun'] != 1) { $row = 0; if (5 > $row) { $upd = mysql_query('UPDATE `stats` SET `dn` = "' . $zv['id'] . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'); if (!$upd) { $error = 'Не удалось вступить в эту группу'; unset($zv); } else { $u->info['dn'] = $zv['id']; } } else { $error = 'В группе нет места'; unset($zv); } } elseif ($zv['dun'] == 1) { //Канализация $row_max = 5; if ($u->info['level'] == 4) { $row_max = 4; } elseif ($u->info['level'] == 5) { $row_max = 3; } elseif ($u->info['level'] == 6) { $row_max = 2; } elseif ($u->info['level'] >= 7) { $row_max = 1; } $row = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `stats` WHERE `dn` = "' . $zv['id'] . '" LIMIT 1')); $row1 = mysql_fetch_array(mysql_query('SELECT * FROM `stats` WHERE `dn` = "' . $zv['id'] . '" LIMIT 1')); $row2 = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "' . $row1['id'] . '" LIMIT 1')); $row = $row[0]; if ($row2['level'] != $u->info['level']) { $error = 'Вы не подходите по уровню'; } elseif ($row_max > $row) { $upd = mysql_query('UPDATE `stats` SET `dn` = "' . $zv['id'] . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'); if (!$upd) { $error = 'Не удалось вступить в эту группу'; unset($zv); } else { $u->info['dn'] = $zv['id']; } } else { $error = 'В группе нет места'; unset($zv); } } elseif ($u->info['level'] < 4 && $zv['dun'] == 104) { //Шахты $row_max = 3; if ($u->info['level'] > 3) { $row_max = 1; } $row = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `stats` WHERE `dn` = "' . $zv['id'] . '" LIMIT 1')); $row1 = mysql_fetch_array(mysql_query('SELECT * FROM `stats` WHERE `dn` = "' . $zv['id'] . '" LIMIT 1')); $row2 = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "' . $row1['id'] . '" LIMIT 1')); $row = $row[0]; if ($row2['level'] != $u->info['level'] && $u->info['level'] > 3) { $error = 'Вы не подходите по уровню'; } elseif ($row_max > $row) { $upd = mysql_query('UPDATE `stats` SET `dn` = "' . $zv['id'] . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'); if (!$upd) { $error = 'Не удалось вступить в эту группу'; unset($zv); } else { $u->info['dn'] = $zv['id']; } } else { $error = 'В группе для вас нет места'; unset($zv); } } else { $error = 'Вы не подходите по уровню'; unset($zv); } } else { $error = 'Заявка не найдена'; } } else { $error = 'Вы уже находитесь в группе'; } } elseif (isset($_POST['leave']) && isset($zv['id']) && $dungeonGo == 1) { if ($zv['uid'] == $u->info['id']) { //ставим в группу нового руководителя $ld = mysql_fetch_array(mysql_query('SELECT `id` FROM `stats` WHERE `dn` = "' . $zv['id'] . '" AND `id` != "' . $u->info['id'] . '" LIMIT 1')); if (isset($ld['id'])) { $zv['uid'] = $ld['id']; mysql_query('UPDATE `dungeon_zv` SET `uid` = "' . $zv['uid'] . '" WHERE `id` = "' . $zv['id'] . '" LIMIT 1'); mysql_query('UPDATE `stats` SET `dn` = "0" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'); $u->info['dn'] = 0; unset($zv); } else { //удаляем группу целиком mysql_query('UPDATE `dungeon_zv` SET `delete` = "' . time() . '" WHERE `id` = "' . $zv['id'] . '" LIMIT 1'); mysql_query('UPDATE `stats` SET `dn` = "0" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'); $u->info['dn'] = 0; unset($zv); } } else { //просто выходим с группы mysql_query('UPDATE `stats` SET `dn` = "0" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'); $u->info['dn'] = 0; unset($zv); } } elseif (isset($_POST['add']) && $u->info['level'] > 1 && $dungeonGo == 1) { if ($u->info['dn'] == 0) { $dun5 = $dungeon['id']; // if (isset($_POST['rpmg1'])) { if ($_POST['rpmg1'] == 2) { $dun5 = 101; //Бездна } elseif ($_POST['rpmg1'] == 8) { $dun5 = 12; //ПТП } elseif ($_POST['rpmg1'] == 10) { $dun5 = 1; //Водосток } elseif ($_POST['rpmg1'] == 16) { $dun5 = 16; //Пещера Мглы } elseif ($_POST['rpmg1'] == 4) { $dun5 = 3; //Катакомбы } elseif ($_POST['rpmg1'] == 5) { $dun5 = 9; //Потерянный вход } elseif ($_POST['rpmg1'] == 444) { $dun5 = 444; //Тропа Инквизиции } elseif ($_POST['rpmg1'] == 6) { $dun5 = 10; //Грибница } elseif ($_POST['rpmg1'] == 11) { $dun5 = 13; //Гора легиона } elseif ($_POST['rpmg1'] == 106) { $dun5 = 31; //Низины } elseif ($_POST['rpmg1'] == 999) { $dun5 = 999; //Тестовая локация } elseif ($_POST['rpmg1'] == 9) { $dun5 = 9; //Потеряный вход } else { $dun5 = 12; //ПТП } } else { $dun5 = 12; //ПТП } // $ins = mysql_query('INSERT INTO `dungeon_zv` (`city`,`time`,`uid`,`dun`,`pass`,`com`,`lvlmin`,`lvlmax`,`team_max`) VALUES ("all","' . time() . '","' . $u->info['id'] . '","' . $dun5 . '", "' . mysql_real_escape_string($_POST['pass']) . '", "' . mysql_real_escape_string($_POST['text']) . '", "8", "21", "5")'); if ($ins) { $u->info['dn'] = mysql_insert_id(); $zv['id'] = $u->info['dn']; $zv['uid'] = $u->info['id']; mysql_query('UPDATE `stats` SET `dn` = "' . $u->info['dn'] . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'); $error = 'Вы успешно создали группу'; } else { $error = 'Не удалось создать группу'; } } else { $error = 'Вы уже находитесь в группе'; } } //Генерируем список групп $sp = mysql_query('SELECT * FROM `dungeon_zv` WHERE `city` = "all" AND `delete` = "0" AND `time` > "' . (time() - 60 * 60 * 2) . '"'); while ($pl = mysql_fetch_array($sp)) { $dungeonGroupList .= '
Вход в подземелье |