From 59b053efd22ccd197d042ed5731b117e4846599b Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Tue, 4 Nov 2008 13:14:08 +0000 Subject: Apply the first part of the labyrinth tweaks: * labyrinths are bordered by (undiggable) metal walls * teleporting inside a labyrinth will always send you away from the centre (as the crow flies: you'll end somewhere in the stone or rock area) Also make sure melded equipment cannot corrode. (I'm still undecided about whether curses should affect melded items.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7383 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/spells3.cc | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'crawl-ref/source/spells3.cc') diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index a368510a34..af2330a23a 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -1350,6 +1350,33 @@ static bool _teleport_player( bool allow_control, bool new_abyss_area ) { coord_def newpos; + // If in a labyrinth, always teleport well away from the centre. + // (Check done for the straight line, no pathfinding involved.) + bool need_distance_check = false; + coord_def centre; + if (you.level_type == LEVEL_LABYRINTH) + { + bool success = false; + for (int xpos = 0; xpos < GXM; xpos++) + { + for (int ypos = 0; ypos < GYM; ypos++) + { + centre = coord_def(xpos, ypos); + if (!in_bounds(centre)) + continue; + + if (grd(centre) == DNGN_ESCAPE_HATCH_UP) + { + success = true; + break; + } + } + if (success) + break; + } + need_distance_check = success; + } + do { newpos.set( random_range(X_BOUND_1 + 1, X_BOUND_2 - 1), @@ -1358,7 +1385,8 @@ static bool _teleport_player( bool allow_control, bool new_abyss_area ) while (grd(newpos) != DNGN_FLOOR && grd(newpos) != DNGN_SHALLOW_WATER || mgrd(newpos) != NON_MONSTER - || env.cgrid(newpos) != EMPTY_CLOUD); + || env.cgrid(newpos) != EMPTY_CLOUD + || need_distance_check && (newpos - centre).abs() < 34*34); // no longer held in net if (newpos != you.pos()) -- cgit v1.2.3-54-g00ecf