"Рудник"); if($user["login"] == "Rallo Tabs") { if(isset($_GET['goto'])) { mysql_query("UPDATE `caveparties` SET `x` = '$_GET[x]', `y` = '$_GET[y]', `floor` = '$_GET[floor]' WHERE `caveparties`.`user` = $user[id] LIMIT 1"); header('Location: cave.php'); exit(); } header("Content-Type: text/html; charset=utf-8"); } if($user['battle'] > 0) { header("location: fbattle.php"); die(); } $objsizes = array(0 => array(0, 0), 1 => array(120, 60), 2 => array(120, 60), 3 => array(120, 60), 4 => array(110, 72), 5 => array(120, 120)); $objdata[3][0] = array("wd"=>1.44, "ht"=>1.44, "y"=>1, "x"=>176); $objdata[3][1] = array("coef"=>1, "y"=>202, "x"=>176); $objdata[1][1] = array("coef"=>1, "y"=>202, "x"=>-65); $objdata[5][1] = array("coef"=>1, "y"=>202, "x"=>435); $objdata[3][2] = array("coef"=>0.67, "y"=>162, "x"=>176); $objdata[1][2] = array("coef"=>0.67, "y"=>162, "x"=>18); $objdata[5][2] = array("coef"=>0.67, "y"=>162, "x"=>342); $objdata[3][3] = array("coef"=>0.50, "y"=>141, "x"=>176); $objdata[1][3] = array("coef"=>0.50, "y"=>141, "x"=>50); $objdata[5][3] = array("coef"=>0.50, "y"=>141, "x"=>300); $imgdata[3][0] = array("wd"=>173, "ht"=>317, "y"=>1, "x"=>array(-37, 89, 215)); $imgdata[3][1] = array("wd"=>87, "ht"=>161, "y"=>41, "x"=>array(68, 132, 196)); $imgdata[1][1] = array("wd"=>87, "ht"=>161, "y"=>41, "x"=>array(-171, -44, -44)); $imgdata[5][1] = array("wd"=>87, "ht"=>161, "y"=>41, "x"=>array(308, 308, 435)); $imgdata[3][2] = array("wd"=>58, "ht"=>107, "y"=>55, "x"=>array(104, 147, 189)); $imgdata[1][2] = array("wd"=>58, "ht"=>107, "y"=>55, "x"=>array(-56, 29, 29)); $imgdata[5][2] = array("wd"=>58, "ht"=>107, "y"=>55, "x"=>array(264, 264, 350)); $imgdata[3][3] = array("wd"=>44, "ht"=>81, "y"=>61, "x"=>array(122, 154, 186)); $imgdata[1][3] = array("wd"=>44, "ht"=>81, "y"=>61, "x"=>array(1, 65, 65)); $imgdata[5][3] = array("wd"=>44, "ht"=>81, "y"=>61, "x"=>array(242, 242, 306)); $eventdata[3][1] = array("x" => 176, "y" => 200, "q" => 1); $eventdata[3][2] = array("x" => 176, "y" => 149, "q" => 0.66); $eventdata[1][2] = array("x" => 16, "y" => 149, "q" => 0.66); $eventdata[5][2] = array("x" => 335, "y" => 149, "q" => 0.66); $eventdata[3][3] = array("x" => 176, "y" => 133, "q" => 0.5); $eventdata[1][3] = array("x" => 56, "y" => 133, "q" => 0.5); $eventdata[5][3] = array("x" => 296, "y" => 133, "q" => 0.5); $objects = array(1 => "Спуск", 2 => "Спуск", 3 => "Спуск", 4 => "Сундук", 5 => "Спуск"); $events = array(); $dialogs = array(); $noautoexit = 0; function usagesleft($x, $y) { global $map; $cell = explode("/", $map[$y*2][$x*2]); return $cell[3]; } function takeusage($x, $y) { global $map; $cell = explode("/", $map[$y*2][$x*2]); $cell[3]--; $map[$y*2][$x*2] = implode("/", $cell); updmap(); } function makedeath() { global $user, $floor, $loses, $x, $y, $dir; include("cavedata.php"); if(!isset($cavedata[$user['room']]['x'.$floor])) { $floor = 1; loadmap(); } mysql_query("UPDATE `caveparties` SET `floor` = $floor, `x` = '".$cavedata[$user['room']]['x'.$floor]."', `y` = '".$cavedata[$user['room']]['y'.$floor]."', `dir` = '".$cavedata[$user['room']]['dir'.$floor]."', `loses` = (`loses`+1) WHERE `user` = '$user[id]' LIMIT 1"); mysql_query('UPDATE `users` SET `hp` = 1 WHERE `id` = "'.$user['id'].'" LIMIT 1'); $x = $cavedata[$user['room']]['x'.$floor]; $y = $cavedata[$user['room']]['y'.$floor]; $dir = $cavedata[$user['room']]['dir'.$floor]; updparties(); $loses++; } function pickupitem($item, $foronetrip, $notmore1, $incave = 0, $podzem = 1, $destiny = 0) { global $user; if($notmore1) { $i = mysql_fetch_assoc(mysql_query("SELECT `id` FROM `inventory` WHERE `prototype` = '$item' AND `owner` = '$user[id]' LIMIT 1")); if(isset($i['id'])) { return "Вы уже получили здесь всё необходимое."; } } $flds = array('podzem' => 1, 'podzem' => $podzem); if($incave) { $flds['incave'] = 1; } $taken = takeshopitem($item, 'shop', '', $foronetrip, $destiny, $flds); return "Вы получили $taken[name]"; } function itemtofloor($item, $foronetrip, $incave = 0, $podzem = 1, $from = 'shop', $small = 0) { global $user, $x, $y, $floor; $rec = mysql_fetch_array(mysql_query("SELECT `name`, `img` FROM `$from` WHERE `id` = '$item' LIMIT 1")); mysql_query("INSERT INTO `caveitems` SET `leader` = '$user[caveleader]', `name` = '$rec[name]', `img` = '$rec[img]', `small` = '$small', `x` = '".($x*2)."', `y` = '".($y*2)."', `floor` = '$floor', `item` = '$item', `foronetrip` = '$foronetrip', `incave` = '$incave', `podzem` = '$podzem'"); return "Вы нашли $rec[name]."; } function makeinjury() { global $user, $floor, $noautoexit, $loses, $x, $y, $dir; settravma($user['id'], 20, rand(1, 600), 1, 1); makedeath(); $noautoexit = 1; } function cavewall($w) { if($w < 100) { return floor($w/10); } else { return floor($w/1000)+100; } } function passablewall($n) { if($n == 0 || $n == 31) { return true; } return false; } function canmoveto($cell, $freecell = 0, $passing = 0) { if(!passablewall($passing)) { return false; } $obj = substr($cell, 0, 1); if($obj == "e" || $obj == "u" || $obj == "s" || $obj == "p") { return true; } if(!$freecell && $cell) { return false; } if($cell == $freecell) { return true; } return false; } function gotoxy($tox, $toy, $tofloor = 0, $msg = '') { global $map, $x, $y, $floor, $user; $floor1 = $floor; $upd = ""; if($tox) { $tox = $tox/2; if($upd) { $upd .= ", "; } $upd .= " `x` = '$tox'"; $x = $tox; } if($toy) { $toy = $toy/2; if($upd) { $upd .= ", "; } $upd .= " `y` = '$toy'"; $y = $toy; } if($tofloor && $tofloor != $floor) { if($upd) { $upd .= ", "; } $upd .= " `floor` = '$tofloor'"; $floor = $tofloor; } mysql_query("UPDATE `caveparties` SET $upd WHERE `user` = '$user[id]' LIMIT 1"); if($tofloor && $tofloor != $floor1) { $map = mysql_fetch_assoc(mysql_query("SELECT `map` FROM `caves` WHERE `leader` = '$user[caveleader]' AND `floor` = '$floor' LIMIT 1")); $map = unserialize($map); } updparties(); if($msg) { header("Location: ".$_SERVER['PHP_SELF'].($msg ? '?msg='.$msg : '' )); exit(); } } function updparties() { global $user, $x, $y, $floor, $dir, $party; foreach ($party as $k => $v) { if($v['user'] == $user['id']) { $party[$k]['dir'] = $dir; $party[$k]['x'] = $x; $party[$k]['y'] = $y; $party[$k]['floor'] = $floor; } } } function loadmap() { global $user, $map, $floor; $map = mysql_fetch_array(mysql_query("SELECT `map` FROM `caves` WHERE `leader` = '$user[caveleader]' AND `floor` = '$floor' LIMIT 1")); $map = unserialize($map['map']); } if(!in_array($user['room'], $caverooms)) { header("Location: main.php"); die('Not in this life ...'); } if(isset($_GET['direction'])) { $dir = (int)$_GET['direction']; if($dir >= 0 && $dir <= 3) { mysql_query("UPDATE `caveparties` SET `dir` = '$dir' WHERE `user` = '$user[id]' LIMIT 1"); } } $party = array(); $r = mysql_query("SELECT `user`, `x`, `y`, `dir`, `login`, `shadow`, `floor`, `loses` FROM `caveparties` WHERE `leader` = '$user[caveleader]' ORDER BY `id` DESC"); while($rec = mysql_fetch_assoc($r)) { if($rec['user'] == $user['id']) { $x = $rec['x']; $y = $rec['y']; $dir = $rec['dir']; $floor = $rec['floor']; $loses = $rec['loses']; } $party[] = $rec; } if($user['room'] == 621) { $base = "/underdesigns/alchcave"; } $maxloses = 3; if($loses >= $maxloses && !$noautoexit) { $_GET['exit'] = 1; } if(@$_GET['kill'] && $user['id'] == $user['caveleader'] && $_GET['kill'] != $user['login']) { foreach($party as $k => $v) { if($v['login'] == $_GET['kill']) { mysql_query("DELETE FROM `caveparties` WHERE `user` = '$v[user]'"); mysql_query("UPDATE `users` SET `room` = (`room`-1), `caveleader` = 0 WHERE `id` = '$v[user]' LIMIT 1"); $r = mysql_query("SELECT `id`, `dressed` FROM `inventory` WHERE `owner` = '$v[user]' AND `dressed` = 1 AND `foronetrip` = 1"); if(mysql_num_rows($r) > 0) { $usr = mysql_fetch_array(mysql_query("SELECT ".implode(",", $userslots)." FROM `users` WHERE `id` = '$v[user]'")); } while($rec = mysql_fetch_assoc($r)) { $slot = getslot($rec['id'], $usr); if($slot) { dropitemid(0, $v['user'], $slot); } } mysql_query("DELETE FROM `inventory` WHERE `owner` = '$v[user]' AND `foronetrip` = 1"); unset($party[$k]); $report = "Персонаж $v[login] исключён из похода."; break; } } if(!@$report) { $report="Персонаж $_GET[kill] не найден."; } } if($_GET['change'] && $user['id'] == $user['caveleader'] && $_GET['change'] != $user['login']) { foreach($party as $k => $v) { if($v['login'] == $_GET['change']) { mysql_query("LOCK TABLES `users` WRITE, `caveparties` WRITE, `cavebots` WRITE, `caves` WRITE, `caveitems` WRITE"); mysql_query("UPDATE `users` SET `caveleader` = '$v[user]' WHERE `caveleader` = '$user[id]'"); mysql_query("UPDATE `cavebots` SET `leader` = '$v[user]' WHERE `leader` = '$user[id]'"); mysql_query("UPDATE `caves` SET `leader` = '$v[user]' WHERE `leader` = '$user[id]'"); mysql_query("UPDATE `caveparties` SET `leader` = '$v[user]' WHERE `leader` = '$user[id]'"); mysql_query("UPDATE `caveitems` SET `leader` = '$v[user]' WHERE `leader` = '$user[id]'"); $user['caveleader'] = $v['user']; $report = "Персонажу $v[login] присвоено лидерство."; mysql_query("UNLOCK TABLES"); break; } } if(!@$report) { $report = "Персонаж $_GET[change] не найден."; } } if(@$_GET['useitem'] || @$_GET['usewallitem']) { mysql_query("LOCK TABLES `effects` WRITE, `cavebots` WRITE, `battle` WRITE, `users` WRITE, `caveparties` WRITE, `caves` WRITE, `shop` WRITE, `inventory` WRITE, `bots` WRITE, `caveitems` WRITE"); } loadmap(); if(@$_GET['useitem']) { if($dir == 0) { $tx = $x-1; $ty = $y; } if($dir == 1) { $tx = $x; $ty = $y-1; } if($dir == 2) { $tx = $x+1; $ty = $y; } if($dir == 3) { $tx = $x; $ty = $y+1; } if(@$_GET['useitem']) { if(file_exists("underground/objects/$user[room].php")) { include "underground/objects/$user[room].php"; } } list($t, $obj) = explode("/", $map[$ty*2][$tx*2]); if($t == "o") { if($obj == 500) { $report="В этот сундук уже кто-то заглядывал"; } } mysql_query("UNLOCK TABLES"); } function updmap() { global $map, $user, $floor; mysql_query("UPDATE `caves` SET `map` = '".serialize($map)."' WHERE `leader` = '$user[caveleader]' AND `floor` = '$floor' LIMIT 1"); } if(@$_GET['usewallitem']) { if($dir == 0) { $tx = $x*2-1; $ty = $y*2; } if($dir == 1) { $tx = $x*2; $ty = $y*2-1; } if($dir == 2) { $tx = $x*2+1; $ty = $y*2; } if($dir == 3) { $tx = $x*2; $ty = $y*2+1; } $obj = $map[$ty][$tx]; if($obj == 18) { $report = "Вы не обнаружили ничего интересного."; } if($obj == 19) { $report = "Уже проверено, сюда лучше не лазить."; } mysql_query("UNLOCK TABLES"); } $r = mysql_query("SELECT `id`, `bot`, `x`, `y`, `cnt`, `type`, `battle` FROM `cavebots` WHERE `leader` = '$user[caveleader]' AND `floor` = '$floor'"); $mapbots = array(); $ambushes = array(); $cavedata = getcavedata($user['caveleader'], $floor); if(time()-$cavedata['wander'] > 21) { $wander = 1; } else { $wander = 0; } $wanderers = array(); while($rec = mysql_fetch_assoc($r)) { if($rec['type'] == 1 && $wander && $rec['battle'] == 0) { $wanderers[] = $rec; continue; } if(!@$mapbots[$rec['y']][$rec['x']]) { $mapbots[$rec['y']][$rec['x']] = "b"; } if(($rec['type'] == 1 || $rec['type'] == 2) && $rec['battle'] == 0) { $ambushes[$rec['y']][$rec['x']] = 1; } $mapbots[$rec['y']][$rec['x']] .= "/$rec[bot]/$rec[cnt]"; } if($wander && !isset($_GET['attack'])) { foreach($wanderers as $k => $v) { $d = rand(0, 3); for($i = 0; $i < 4; $i++) { if($d == 0) { $tx = $v['x']-2; $ty = $v['y'];} if($d == 1) { $tx = $v['x']; $ty = $v['y']-2;} if($d == 2) { $tx = $v['x']+2; $ty = $v['y'];} if($d == 3) { $tx = $v['x']; $ty = $v['y']+2;} if($user['room'] == 74 || $user['room'] == 76) { if(strpos($map[$ty][$tx], 's/') !== false && !@$mapbots[$ty][$tx]) { break; } } else { if($map[$ty][$tx] == 2 && !@$mapbots[$ty][$tx]) { break; } } $d++; if($d > 3) { $d = 0; } } if($i < 4) { mysql_query("UDPATE `cavebots` set `x` = '$tx', `y` = '$ty' WHERE `id` = '$v[id]' LIMIT 1"); $v['x'] = $tx; $v['y'] = $ty; } if(!@$mapbots[$v['y']][$v['x']]) { $mapbots[$v['y']][$v['x']] = "b"; } $ambushes[$v['y']][$v['x']] = 1; $mapbots[$v['y']][$v['x']] .= "/$v[bot]/$v[cnt]"; } $cavedata['wander'] = time(); savecavedata($cavedata, $user['caveleader'], $floor); } foreach($mapbots as $k => $v) { foreach($v as $k2 => $v2) { $map[$k][$k2] = $v2; } } $moved = 0; if(@$_GET['move'] && $_SESSION['movetime'] < time()) { if($_GET['move'] == "x1" && canmoveto($map[$y*2][$x*2+2], 2, $map[$y*2][$x*2+1],2)) { mysql_query("UPDATE `caveparties` SET `x` = (`x`+1) WHERE `user` = '$user[id]' LIMIT 1"); $x++; $moved=1; } if($_GET['move'] == "x2" && canmoveto($map[$y*2][$x*2-2], 2, $map[$y*2][$x*2-1])) { mysql_query("UPDATE `caveparties` SET `x` = (`x`-1) WHERE `user` = '$user[id]' LIMIT 1"); $x--; $moved=1; } if($_GET['move'] == "y1" && canmoveto($map[$y*2+2][$x*2], 2, $map[$y*2+1][$x*2])) { mysql_query("UPDATE `caveparties` SET `y` = (`y`+1) WHERE `user` = '$user[id]' LIMIT 1"); $y++; $moved=1; } if($_GET['move'] == "y2" && canmoveto($map[$y*2-2][$x*2], 2, $map[$y*2-1][$x*2])) { mysql_query("UPDATE `caveparties` SET `y` = (`y`-1) WHERE `user` = '$user[id]' LIMIT 1"); $y--; $moved=1; } updparties(); #$_SESSION['movetime'] = time()+5; $_SESSION['movetime'] = time(); } if($moved && (substr($map[$y*2][$x*2], 0, 1) === "e" || substr($map[$y*2][$x*2], 0, 1) === "p")) { $tx = $x; $ty = $y; $tmp = explode("/", $map[$y*2][$x*2]); if(file_exists("underground/events/$user[room].php")) { include("underground/events/$user[room].php"); } } $ax = 0; $ay = 0; if($ambushes[$y*2+2][$x*2] && $map[$y*2+1][$x*2] == 0) { $ax = $x; $ay = $y+1; } if($ambushes[$y*2-2][$x*2] && $map[$y*2-1][$x*2] == 0) { $ax = $x; $ay = $y-1; } if($ambushes[$y*2][$x*2+2] && $map[$y*2][$x*2+1] == 0) { $ax = $x+1; $ay = $y; } if($ambushes[$y*2][$x*2-2] && $map[$y*2][$x*2-1] == 0) { $ax = $x-1; $ay = $y; } if($ax && $ay && $user['hp'] > 0) { include_once("cavedata.php"); if(!($cavedata[$user['room']]['x'.$floor] == $x && $cavedata[$user['room']]['y'.$floor] == $y)) { if($ax < $x) { $dir1 = 0; } elseif($ax > $x) { $dir1 = 2; } elseif($ay < $y) { $dir1 = 1; } elseif($ay > $y) { $dir1 = 3; } if($dir != $dir1) { $dir = $dir1; mysql_query("UPDATE `caveparties` SET `dir` = '$dir' WHERE `user` = '$user[id]' LIMIT 1"); foreach($party as $k => $v) { if($v['user'] == $user['id']) { $party[$k]['dir'] = $dir1; } } } $_GET['attack'] = 1; } } if(!$_SESSION['movetime']) { #$_SESSION['movetime'] = time()+5; $_SESSION['movetime'] = time(); } if(@$_GET['takeitem']) { $_GET['takeitem'] = (int)$_GET['takeitem']; $it = mysql_fetch_array(mysql_query("SELECT `item`, `foronetrip`, `incave`, `podzem` FROM `caveitems` WHERE `leader` = '$user[caveleader]' AND `x` = '".($x*2)."' AND `y` = '".($y*2)."' AND `floor` = '$floor' AND `id` = '$_GET[takeitem]' LIMIT 1")); if(isset($it['item'])) { $ms = mysql_fetch_assoc(mysql_query("SELECT `massa` AS `mass` FROM $shop WHERE `id` = '$it[item]' LIMIT 1")); $shop = 'shop'; if(!placeinbackpack(1, $user['id'])) { $report = "У вас в рюкзаке слишком много предметов."; } elseif(!cancarry($ms['mass'], $user)) { $report = "Ваш рюкзак перегружен."; } else { $destiny = 0; $taken = takeshopitem($it['item'], "$shop", "", $it['foronetrip'], $destiny, array("podzem" => $it["podzem"], "incave" => $it['incave']), 0, 1, "Нашёл в пещере"); if(@$taken['error']) { $report = $taken['error']; } else { mysql_query("DELETE FROM `caveitems` WHERE `leader` = '$user[caveleader]' AND `x` = '".($x*2)."' AND `y` ='".($y*2)."' AND `floor` = '$floor' AND `id` = '$_GET[takeitem]' LIMIT 1"); $report = "Вы нашли $taken[name]."; } } } else { $report = "Кто-то оказался быстрее..."; } } if(@$_GET['speak']) { if($dir == 0) { $x1 = $x*2-2; } elseif($dir == 2) { $x1 = $x*2+2; } else { $x1 = $x*2; } if($dir == 1) { $y1 = $y*2-2; } elseif($dir == 3) { $y1 = $y*2+2; } else { $y1 = $y*2; } $cell = $map[$y1][$x1]; $tmp = explode("/", $cell); if($tmp[0] == "d") { header("location: dialog.php?char=$tmp[2]"); die(); } if($tmp[0] == "b" && isset($dialogs[$bots[$tmp[1]]])) { header("location: dialog.php?char=".$bots[$tmp[1]]); die(); } } if(@$_GET['attack']) { if($dir == 0) { $by = $y*2; $bx = ($x-1)*2; } if($dir == 1) { $by = ($y-1)*2; $bx = $x*2; } if($dir == 2) { $by = $y*2; $bx = ($x+1)*2; } if($dir == 3) { $by = ($y+1)*2; $bx = $x*2; } $r = mysql_query("SELECT `bot`, `cnt`, `battle` FROM `cavebots` WHERE `leader` = '$user[caveleader]' AND `x` = $bx AND `y` = $by AND `floor` = '$floor'"); $rec = mysql_fetch_assoc($r); if($user['hp'] <= $user['maxhp']*0.33) { $report = 'Вы слишком ослаблены для поединка'; } elseif(isset($rec['bot'])) { $btl = $rec['battle']; if($btl > 0) { battlewithbot($bots[$rec['bot']], "", "", 10, 0, 0, $btl); } else { $firstbot = $bots[$rec['bot']]; $otherbots = array(); $rec['cnt']--; while($rec['cnt'] > 0) { $otherbots[] = array('id' => $bots[$rec['bot']], 'name' => $botnames[$rec['bot']]); $rec["cnt"]--; } while($rec = mysql_fetch_assoc($r)) { while($rec['cnt'] > 0) { $otherbots[] = array('id' => $bots[$rec['bot']], 'name' => $botnames[$rec['bot']]); $rec['cnt']--; } } $btl = battlewithbot($firstbot, "", "", 10, 0, 0, 0, $otherbots); mysql_query("UPDATE `cavebots` SET `battle` = '$btl' WHERE `leader` = '$user[caveleader]' AND `x` = '$bx' AND `y` = $by AND `floor` = '$floor'"); } } } if(@$_GET['exit']) { if(count($party) == 1) { mysql_query("DELETE FROM `cavebots` WHERE `leader` = '$user[id]'"); mysql_query("DELETE FROM `caves` WHERE `leader` = '$user[id]'"); mysql_query("DELETE FROM `caveparties` WHERE `leader` = '$user[id]'"); mysql_query("DELETE FROM `caveitems` WHERE `leader` = '$user[id]'"); mysql_query("UPDATE `users` SET `caveleader` = 0 WHERE `id` = '$user[id]' LIMIT 1"); } else { mysql_query("LOCK TABLES `users` WRITE, `caveparties` WRITE, `cavebots` WRITE, `caves` WRITE, `caveitems` WRITE, `diseases` WRITE, `caveeffects` WRITE"); mysql_query("DELETE FROM `caveparties` WHERE `user` = '$user[id]'"); mysql_query("UPDATE `users` SET `caveleader` = 0 WHERE `id` = '$user[id]' LIMIT 1"); if($user['caveleader'] == $user['id']) { foreach($party as $k => $v) { if($v['user'] != $user['id']) { mysql_query("UPDATE `users` SET `caveleader` = '$v[user]' WHERE `caveleader` = '$user[id]'"); mysql_query("UPDATE `cavebots` SET `leader` = '$v[user]' WHERE `leader` = '$user[id]'"); mysql_query("UPDATE `caves` SET `leader` = '$v[user]' WHERE `leader` = '$user[id]'"); mysql_query("UPDATE `caveparties` SET `leader` = '$v[user]' WHERE `leader` = '$user[id]'"); mysql_query("UPDATE `caveitems` SET `leader` = '$v[user]' WHERE `leader` = '$user[id]'"); } } } mysql_query("UNLOCK TABLES"); } $r = mysql_query("SELECT `id`, `dressed` FROM `inventory` WHERE `owner` = '$user[id]' AND `dressed` = 1 AND `foronetrip` = 1"); while($rec = mysql_fetch_assoc($r)) { $slot = getslot($rec['id']); if($slot) { dropitemid(0, $user['id'], $slot); } } mysql_query("DELETE FROM `inventory` WHERE `owner` = '$user[id]' AND `foronetrip` = 1"); gotoroom($user['room']-1); } $standingon = $map[$y*2][$x*2]; foreach($party as $k => $v) { $map[$v['y']*2][$v['x']*2] = "u/".$v['user']; } ?>
if($user['hp'] <= 0) { makedeath(); } function drawmap($map1, $players, $x, $y, $direction) { global $base, $user, $botnames, $imgdata; $startx = max($x*2-8, 0); $starty = max($y*2-8, 0); if($direction == 0) { $x1 = $x*2+2; $x2 = $x*2-8; $y1 = $y*2+3; $y2 = $y*2-4; } if($direction == 1) { $x1 = $x*2-3; $x2 = $x*2+4; $y1 = $y*2+2; $y2 = $y*2-8; } if($direction == 2) { $x1 = $x*2-2; $x2 = $x*2+8; $y1 = $y*2-3; $y2 = $y*2+4; } if($direction == 3) { $x1 = $x*2+3; $x2 = $x*2-4; $y1 = $y*2-2; $y2 = $y*2+8; } if($x1 < $x2) { $dx = 1; } else { $dx = -1; } if($y1 < $y2) { $dy = 1; } else { $dy = -1; } $x0 = 0; if($direction%2 == 1) { $sy1 = $y1; while($x1 != $x2) { $y1 = $sy1; $y0 = -2; while($y1 != $y2) { if($map1[$y1][$x1] == 2) { $sq = 0; } elseif(isset($map1[$y1][$x1])) { $sq = $map1[$y1][$x1]; } else { $sq = 0; } $map[$x0][$y0] = $sq; $y1 += $dy; $y0++; } $x0++; $x1 += $dx; } } else { $sx1 = $x1; while($y1 != $y2) { $x1 = $sx1; $x0 = -2; while($x1 != $x2) { if($map1[$y1][$x1] == 2) { $sq = 0; } elseif(isset($map1[$y1][$x1])) { $sq = $map1[$y1][$x1]; } else { $sq = 0; } $map[$y0][$x0] = $sq; $x1 += $dx; $x0++; } $y0++; $y1 += $dy; } } $ret = "";
$i = 7;
$centerwall = 8;
while($i > 0) {
if($map[3][$i]) {
$centerwall = $i;
}
$i -= 2;
}
$i = 4;
function drawbot($cell, $x, $y) {
global $botnames, $imgdata, $bots, $dialogs, $user, $floor;
$data = explode("/", $cell);
$i = 1;
$bc = (count($data)-1)/2;
while($data[$i]) {
$bot = $data[$i];
$botname = $botnames[$bot];
$cnt = $data[$i+1];
if($i == 1) {
if($bc == 1) {
$bn = 1;
} else {
$bn = 0;
}
} elseif($i == 3) {
if($bc == 2) {
$bn = 2;
} else {
$bn = 1;
}
} else {
$bn = 2;
}
$aMap = unserialize(mysql_result(mysql_query("SELECT `map` FROM `caves` WHERE `leader` = '$user[caveleader]' AND `floor` = '$floor'"), 0, 0));
if(!$GLOBALS['dir']) {
$xx = ($GLOBALS['x']*2) - ($y*2);
$yy = ($GLOBALS['y']*2) - ($x - 3);
} elseif($GLOBALS['dir'] == 1) {
$xx = ($GLOBALS['x']*2) + ($x - 3);
$yy = ($GLOBALS['y']*2) - ($y*2);
} elseif($GLOBALS['dir'] == 2) {
$xx = ($GLOBALS['x']*2) + ($y * 2);
$yy = ($GLOBALS['y']*2) + ($x - 3);
} else {
$xx = ($GLOBALS['x']*2) - ($x - 3);
$yy = ($GLOBALS['y']*2) + ($y * 2);
}
if(strpos($aMap[$yy][$xx], 'o/') !== false || strpos($aMap[$yy][$xx], 'p/') !== false) {
$ret .= drawobject2($aMap[$yy][$xx], $x, $y);
}
$rrm = $user['room'];
if(isset($dialogs[$bots[$data[1]]]) && ($bots[$data[1]] == 11147 && $user['room'] == 74)) {
$ret .= " 1?" ($cnt)":"")."\" ".($y == 1 && $x == 3?"onclick=\"speakattackmenu(event);\"":"")." width=\"".$imgdata[$x][$y]["wd"]."\" height=\"".$imgdata[$x][$y]["ht"]."\" src=\"/i/dungeon/mobs/$rrm/$bot.gif\" style=\"position: absolute; left: ".$imgdata[$x][$y]["x"][$bn]."px; top: ".$imgdata[$x][$y]["y"]."px;".($x == 3 && $y == 1?"cursor: pointer;":"").($x == 3?"z-index: ".(99-($y*5)).";":"")."\" />";
} else {
$ret .= " 1?" ($cnt)":"")."\" ".($y == 1 && $x == 3?" onclick=\"document.location.href='cave.php?attack=1';\"":"")." width=\"".$imgdata[$x][$y]["wd"]."\" height=\"".$imgdata[$x][$y]["ht"]."\" src=\"/i/dungeon/mobs/$rrm/$bot.gif\" style=\"position: absolute; left: ".$imgdata[$x][$y]["x"][$bn]."px; top: ".$imgdata[$x][$y]["y"]."px;".($x == 3 && $y == 1?"cursor: pointer;":"").($x == 3?"z-index: ".(99-($y*5)).";":"")."\" />";
}#onclick=\"attackmenu(event);\"
$i += 2;
}
return $ret;
}
function drawdialog($cell, $x, $y) {
global $dialogs, $imgdata;
$data = explode("/", $cell);
$i = 1;
$d = $data[2];
$bot = $data[$i];
$botname = $botnames[$bot];
$cnt = $data[$i+1];
$ret = "";
return $ret;
}
function drawuser($cell, $x, $y) {
global $botnames, $imgdata, $party;
$data = explode("/", $cell);
$i = 1;
$bc = (count($data)-1);
while($data[$i]) {
$u = $data[$i];
if($i == 1) {
if($bc == 1) {
$bn = 1;
} else {
$bn = 0;
}
} elseif($i == 3) {
if($bc == 2) {
$bn = 2;
} else {
$bn = 1;
}
} else {
$bn = 2;
}
foreach($party as $k => $v) {
if($v['user'] == $u) {
$udata = $v;
break;
}
}
$ret .= "";
$i++;
}
return $ret;
}
function drawobject($cell, $x, $y) {
global $objects, $imgdata, $user, $objdata, $objsizes, $imgmap;
$tmp = explode("/", $cell);
$obj = $tmp[1];
$ht = round($imgdata[$x][$y]["ht"]/2);
if($objsizes[$obj]) {
$coef=$objdata[$x][$y]["coef"];
$wd=$objsizes[$obj][0]*$coef;
$ht=$objsizes[$obj][1]*$coef;
$left=round($objdata[$x][$y]["x"]-($wd/2));
$top=$objdata[$x][$y]["y"]-$ht;
} elseif($obj == 510) {
$wd=round($imgdata[$x][$y]["wd"]*2.5);
$ht=$imgdata[$x][$y]["ht"];
$left=$imgdata[$x][$y]["x"][1]-round(($wd-$imgdata[$x][$y]["wd"])/2);
$top=$imgdata[$x][$y]["y"];
} elseif ($obj > 600 && $obj < 700) {
$wd=round($imgdata[$x][$y]["wd"]*1.26);
$left=$imgdata[$x][$y]["x"][1]-round(($wd-$imgdata[$x][$y]["wd"])/2);
$top=$imgdata[$x][$y]["y"]+$ht;
} elseif($obj >= 700 && $obj < 800) {
$wd=round($imgdata[$x][$y]["wd"]*1.24);
$ht=$imgdata[$x][$y]["ht"];
$left=$imgdata[$x][$y]["x"][1]-round(($wd-$imgdata[$x][$y]["wd"])/2);
$top=$imgdata[$x][$y]["y"];
} else {
$wd=$imgdata[$x][$y]["wd"];
$left=$imgdata[$x][$y]["x"][1];
$top=$imgdata[$x][$y]["y"]+$ht;
}
$rrm = $user['room'];
if (!isset($imgmap[$obj])) {
$ret .= "
".($y == 1 && $x == 3?"":"")."
".($y == 1 && $x == 3?"":"");
} else {
$ret .= "";
$ret .= $imgmap[$obj]['code'];
}
return $ret;
}
function drawobject2($cell, $x, $y) {
global $objects, $imgdata, $user, $objdata, $objsizes, $imgmap;
$tmp=explode("/", $cell);
$obj=$tmp[1];
$ht=round($imgdata[$x][$y]["ht"]/2);
if($objsizes[$obj]) {
$coef=$objdata[$x][$y]["coef"];
$wd=$objsizes[$obj][0]*$coef;
$ht=$objsizes[$obj][1]*$coef;
$left=round($objdata[$x][$y]["x"]-($wd/2));
$top=$objdata[$x][$y]["y"]-$ht;
} elseif($obj==510) {
$wd=round($imgdata[$x][$y]["wd"]*2.5);
$ht=$imgdata[$x][$y]["ht"];
$left=$imgdata[$x][$y]["x"][1]-round(($wd-$imgdata[$x][$y]["wd"])/2);
$top=$imgdata[$x][$y]["y"];
} elseif($obj>600 && $obj<700) {
$wd=round($imgdata[$x][$y]["wd"]*1.26);
$left=$imgdata[$x][$y]["x"][1]-round(($wd-$imgdata[$x][$y]["wd"])/2);
$top=$imgdata[$x][$y]["y"]+$ht;
} elseif($obj>=700 && $obj<800) {
$wd=round($imgdata[$x][$y]["wd"]*1.24);
$ht=$imgdata[$x][$y]["ht"];
$left=$imgdata[$x][$y]["x"][1]-round(($wd-$imgdata[$x][$y]["wd"])/2);
$top=$imgdata[$x][$y]["y"];
} else {
$wd=$imgdata[$x][$y]["wd"];
$left=$imgdata[$x][$y]["x"][1];
$top=$imgdata[$x][$y]["y"]+$ht;
}
$rrm = $user['room'];
if(!isset($imgmap[$obj])) {
$ret.="
".($y == 1 && $x == 3?"":"")."
".($y == 1 && $x == 3?"":"");
} else {
$ret .= "";
$ret .= $imgmap[$obj]['code'];
}
return $ret;
}
function drawevent($cell, $x, $y) {
global $events, $eventdata;
$tmp = explode("/", $cell);
$obj = $tmp[1];
if($obj == 1) { return ""; }
$wd = round($eventdata[$x][$y]["q"]*$events[$obj]["w"]);
$ht = round($eventdata[$x][$y]["q"]*$events[$obj]["h"]);
$left = round(-$events[$obj]["h"]/2+$eventdata[$x][$y]["x"]);
$top = round($eventdata[$x][$y]["y"]-$events[$obj]["h"]);
$ret .= "";
return $ret;
}
while($i >= 0) {
if($i == 4) {
if($map[0][7]) {
$ret .= "";
}
if($map[0][6]) {
$ret .= "";
}
if($map[-1][6]) {
$ret .= "";
}
}
$wall = $i*2-1;
$sidewall = $i*2;
if($map[1][$sidewall] && $i > 0) {
$obj = substr($map[1][$sidewall], 0, 1);
if($obj == "b") {
$ret .= drawbot($map[1][$sidewall], 1, $i);
} elseif ($obj == "u") {
$ret .= drawuser($map[1][$sidewall], 1, $i, $players);
} elseif ($obj == "o" || $obj=="p") {
$ret .= drawobject($map[1][$sidewall], 1, $i);
} elseif ($obj == "e") {
$ret .= drawevent($map[1][$sidewall], 1, $i);
} elseif ($obj == "d") {
$ret .= drawdialog($map[1][$sidewall], 1, $i);
} elseif ($obj != "s") {
$o = $map[1][$sidewall]-10000;
if($o == 4) {
if($i == 1) {
$ret .= "";
}
if($i == 2) {
$ret .= "";
}
if($i == 3) {
$ret .= "";
}
} else {
if($i== 1) {
$ret .= "";
}
if($i== 2) {
$ret .= "";
}
if($i== 3) {
$ret .= "";
}
}
}
}
if ($map[5][$sidewall] && $i>0) {
$obj=substr($map[5][$sidewall],0,1);
if ($obj=="b") {
$ret.=drawbot($map[5][$sidewall], 5, $i);
} elseif ($obj=="u") {
$ret.=drawuser($map[5][$sidewall], 5, $i, $players);
} elseif ($obj=="o" || $obj=="p") {
$ret.=drawobject($map[5][$sidewall], 5, $i);
} elseif ($obj=="e") {
$ret.=drawevent($map[5][$sidewall], 5, $i);
} elseif ($obj=="d") {
$ret.=drawdialog($map[5][$sidewall], 5, $i);
} elseif ($obj!="s") {
$o=$map[5][$sidewall]-10000;
if ($o==4) {
if ($i==1) $ret.="";
if ($i==2) $ret.="";
if ($i==3) $ret.="";
} else {
if ($i==1) $ret.="";
if ($i==2) $ret.="";
if ($i==3) $ret.="";
}
}
}
if ($i>0 && $map[1][$wall]) $ret.="";
$objInWall = explode('/', $map[4][$sidewall]);
if ($objInWall[1] == 'o') {
if(!passablewall($map[4][$sidewall])) $ret.="";
} else {
if(!passablewall($map[4][$sidewall])) $ret.="";
}
$objInWall = explode('/', $map[2][$sidewall]);
if ($objInWall[1] == 'o') {
if(!passablewall($map[2][$sidewall])) $ret.="";
} else {
if(!passablewall($map[2][$sidewall])) $ret.="";
}
if ($i>0 && $map[5][$wall]) $ret.="";
if ($map[3][$sidewall] && $i>0 && $sidewall<$centerwall) {
$obj=substr($map[3][$sidewall],0,1);
if ($obj=="b") {
$ret.=drawbot($map[3][$sidewall], 3, $i);
} elseif ($obj=="u") {
$ret.=drawuser($map[3][$sidewall], 3, $i, $players);
} elseif ($obj=="o" || $obj=="p") {
$ret.=drawobject($map[3][$sidewall], 3, $i);
} elseif ($obj=="e") {
$ret.=drawevent($map[3][$sidewall], 3, $i);
} elseif ($obj=="d") {
$ret.=drawdialog($map[3][$sidewall], 3, $i);
} elseif ($obj!="s") {
$o=$map[3][$sidewall]-10000;
if ($o==4) {
if ($i==1) $ret.="";
if ($i==2) $ret.="";
if ($i==3) $ret.="";
} else {
if ($i==1) $ret.="";
if ($i==2) $ret.="";
if ($i==3) $ret.="";
}
}
}
if ($map[3][$wall]) {
if ($i>0) $ret.="
2?"style=\"background-image:url('$base/cw$i".cavewall($map[3][$wall]).".gif')\"":"")."> ";
if ($i==1 && $map[3][$wall]>2) {
if ($map[3][$wall]>1000) {
$ret.="";
} elseif ($map[3][$wall]>100) {
$ret.="";
} else $ret.="";
}
$objInWall = explode('/', $map[3][$wall]);
if ($objInWall[1] == "o") {
if ($user['room'] == 83 && !(!$direction && (($x == 13 && $y == 4) || ($x == 12 && $y == 4)))) { // исключение 2-ух клеток в комнате 82
$ret.=drawobject('//' . $objInWall[2], 3, $i);
}
}
$nocenter=1;
}
if ($i==4) {
if ($map[7][6]) $ret.="";
}
$i--;
}
$ret.=" |
";
foreach ($players as $k=>$v) {
if ($v["x"]-($startx/2)>=0 && $v["x"]-($startx/2)<=8 && $v["y"]-($starty/2)>=0 && $v["y"]-($starty/2)<=8) {
$ret.="";
}
}
$ret.="
|
=@$report?>
if ($loses>=3) echo " Вернуться "; if ($loses) echo " Количество смертей: $loses ";
?>
|
$dMap = unserialize(mysql_result(mysql_query("SELECT `map` FROM `cavemaps` WHERE `floor` = $floor AND `room` = ".($user['room'] - 1)), 0, 0));
$cPlace = $dMap[$y*2][$x*2];
$tmp=explode("/", $cPlace);
if($user['room'] == 621) { if($floor == 1) { echo 'Проклятый Рудник, 1 этаж'; } elseif($floor == 2) { echo 'Проклятый Рудник, 2 этаж'; } }
elseif (@$roomnames[$tmp[1]]) echo $roomnames[$tmp[1]];
else echo $rooms[$user["room"]];
?>
Выйти
echo drawmap($map, $party, $x, $y, $dir);
?>
|