summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spells3.cc
diff options
context:
space:
mode:
authorJude Brown <bookofjude@users.sourceforge.net>2009-12-03 20:48:58 +1000
committerJude Brown <bookofjude@users.sourceforge.net>2009-12-03 20:48:58 +1000
commit9dc6a97ec5369d54c9c46c6bdced240ee56b1763 (patch)
tree8b37fbfeffd48125bcae1e69ce226ca19cb57a8c /crawl-ref/source/spells3.cc
parent1621cc868eac53bb4f239b056cc49068b56f52c9 (diff)
downloadcrawl-ref-9dc6a97ec5369d54c9c46c6bdced240ee56b1763.tar.gz
crawl-ref-9dc6a97ec5369d54c9c46c6bdced240ee56b1763.zip
Don't assume a square is safe if there are a monster there.
Could be a lava snake, swamp worm, etc.
Diffstat (limited to 'crawl-ref/source/spells3.cc')
-rw-r--r--crawl-ref/source/spells3.cc21
1 files changed, 16 insertions, 5 deletions
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index e0b1ca50de..1c25a5ee72 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -1411,10 +1411,10 @@ void you_teleport(void)
}
// Should return true if we don't want anyone to teleport here.
-bool _cell_vetoes_teleport (const coord_def cell)
+bool _cell_vetoes_teleport (const coord_def cell, bool check_monsters = true)
{
// Monsters always veto teleport.
- if (monster_at(cell))
+ if (monster_at(cell) && check_monsters)
return (true);
// As do all clouds; this may change.
@@ -1431,9 +1431,19 @@ bool _cell_vetoes_teleport (const coord_def cell)
case DNGN_DEEP_WATER:
if (you.species == SP_MERFOLK)
return (false);
+ else
+ return (true);
- default:
+ case DNGN_LAVA:
return (true);
+
+ default:
+ // Lava is really the only non-solid glyph above DNGN_MAXSOLID that is
+ // not a safe teleport location, and that's handled above.
+ if (cell_is_solid(cell))
+ return (true);
+
+ return (false);
}
}
@@ -1714,7 +1724,7 @@ bool you_teleport_to (const coord_def where_to, bool move_monsters)
if (_cell_vetoes_teleport(where))
{
- if (monster_at(where) && move_monsters)
+ if (monster_at(where) && move_monsters && !_cell_vetoes_teleport(where, false))
{
monsters *mons = monster_at(where);
mons->teleport(true);
@@ -1729,7 +1739,8 @@ bool you_teleport_to (const coord_def where_to, bool move_monsters)
}
else
{
- if (monster_at(*ai) && move_monsters)
+ if (monster_at(*ai) && move_monsters
+ && !_cell_vetoes_teleport(*ai, false))
{
monsters *mons = monster_at(*ai);
mons->teleport(true);