summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-12 03:05:08 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-12 03:05:08 +0000
commitff8b9f619758f46c52b23fe73138f6ab8ed2353e (patch)
tree46a3d94933e0ca99b8a04d1a7df4e30a81303c5a
parentf2dadb170e53ea704a03718b1d322a927cd9ff43 (diff)
downloadcrawl-ref-ff8b9f619758f46c52b23fe73138f6ab8ed2353e.tar.gz
crawl-ref-ff8b9f619758f46c52b23fe73138f6ab8ed2353e.zip
Fix bug #2499021: during arena mode, make monster_random_space() only pick
spaces inside the arena viewport. Since rock worms can be teleported into non-permanent rock walls, and the entire level outside the arena is filled with non-permanent rock walls, this prevents rock worms from being teleported outside the arena. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8419 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/mstuff2.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc
index e97db6a7b4..663068428b 100644
--- a/crawl-ref/source/mstuff2.cc
+++ b/crawl-ref/source/mstuff2.cc
@@ -1068,8 +1068,20 @@ bool monster_random_space(const monsters *monster, coord_def& target,
int tries = 0;
while (tries++ < 1000)
{
- target.x = 10 + random2(GXM - 20);
- target.y = 10 + random2(GYM - 20);
+
+ if (crawl_state.arena)
+ {
+ const coord_def &ul = crawl_view.glos1; // Upper left
+ const coord_def &lr = crawl_view.glos2; // Lower right
+
+ target.x = ul.x + random2(lr.x - ul.x);
+ target.y = ul.y + random2(lr.y - ul.y);
+ }
+ else
+ {
+ target.x = 10 + random2(GXM - 20);
+ target.y = 10 + random2(GYM - 20);
+ }
// Don't land on top of another monster.
if (mgrd(target) != NON_MONSTER || target == you.pos())