summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-util.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-14 08:29:33 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-14 08:29:33 +0000
commitc2e225e37b6fd61253cb5804c719462fb29bb136 (patch)
tree360714dacc9f90aacba2300c0e877d7e7f8d487f /crawl-ref/source/mon-util.cc
parent07cd5056664cc32435043eb78282a5831eda545e (diff)
downloadcrawl-ref-c2e225e37b6fd61253cb5804c719462fb29bb136.tar.gz
crawl-ref-c2e225e37b6fd61253cb5804c719462fb29bb136.zip
Added to classes actor, monsters and player the method can_pass_through(),
which returns true for a grid that the monster or player can pass trhough. Also added new monster type "rock worm" to demonstrate a monster which can pass through solid walls. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2459 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mon-util.cc')
-rw-r--r--crawl-ref/source/mon-util.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index ed5f52174d..f2396cda5b 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -2391,6 +2391,36 @@ bool monsters::floundering() const
&& !mons_flies(this));
}
+bool mons_class_can_pass(const int mclass, const dungeon_feature_type grid)
+{
+ // Permanent walls can't be passed through.
+ if (grid == DNGN_CLEAR_PERMAROCK_WALL || grid == DNGN_PERMAROCK_WALL)
+ return false;
+
+ switch (mclass)
+ {
+ case MONS_ROCK_WORM:
+ return (grid >= DNGN_ROCK_WALL && grid <= DNGN_CLEAR_PERMAROCK_WALL);
+ }
+
+ return !grid_is_solid(grid);
+}
+
+bool monsters::can_pass_through(const dungeon_feature_type grid) const
+{
+ return mons_class_can_pass(type, grid);
+}
+
+bool monsters::can_pass_through(const int _x, const int _y) const
+{
+ return can_pass_through(grd[_x][_y]);
+}
+
+bool monsters::can_pass_through(const coord_def &c) const
+{
+ return can_pass_through(grd(c));
+}
+
bool monsters::can_drown() const
{
// Mummies can fall apart in water; ghouls and demons can drown in