summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-behv.cc
diff options
context:
space:
mode:
authorShmuale Mark <shm.mark@gmail.com>2014-04-08 20:43:00 -0400
committerShmuale Mark <shm.mark@gmail.com>2014-04-12 20:51:15 -0400
commit766729b656dec57abae4f0d41367a2f00e5b4ec4 (patch)
tree65c5f86f3a245549667627e151e81195cd43dcdb /crawl-ref/source/mon-behv.cc
parent53eb3cf6e3870b5bbce99d3221f34cd08e16d034 (diff)
downloadcrawl-ref-766729b656dec57abae4f0d41367a2f00e5b4ec4.tar.gz
crawl-ref-766729b656dec57abae4f0d41367a2f00e5b4ec4.zip
Move mon death stuff from mon-stuff.cc to mon-death.cc.
Touches a lot of files since their #includes have to be edited. (Pushing now since it shouldn't break anything and keeping it updated is nasty.)
Diffstat (limited to 'crawl-ref/source/mon-behv.cc')
-rw-r--r--crawl-ref/source/mon-behv.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/crawl-ref/source/mon-behv.cc b/crawl-ref/source/mon-behv.cc
index 79e76d1518..a400ab2bd7 100644
--- a/crawl-ref/source/mon-behv.cc
+++ b/crawl-ref/source/mon-behv.cc
@@ -14,10 +14,12 @@
#include "coord.h"
#include "coordit.h"
#include "database.h"
+#include "dgn-overview.h"
#include "dungeon.h"
#include "env.h"
#include "fprop.h"
#include "exclude.h"
+#include "libutil.h"
#include "losglobal.h"
#include "macro.h"
#include "mon-act.h"
@@ -1650,3 +1652,49 @@ void shake_off_monsters(const actor* target)
}
}
}
+
+// If _mons_find_level_exits() is ever expanded to handle more grid
+// types, this should be expanded along with it.
+static void _mons_indicate_level_exit(const monster* mon)
+{
+ const dungeon_feature_type feat = grd(mon->pos());
+ const bool is_shaft = (get_trap_type(mon->pos()) == TRAP_SHAFT);
+
+ if (feat_is_gate(feat))
+ simple_monster_message(mon, " passes through the gate.");
+ else if (feat_is_travelable_stair(feat))
+ {
+ command_type dir = feat_stair_direction(feat);
+ simple_monster_message(mon,
+ make_stringf(" %s the %s.",
+ dir == CMD_GO_UPSTAIRS ? "goes up" :
+ dir == CMD_GO_DOWNSTAIRS ? "goes down"
+ : "takes",
+ feat_is_escape_hatch(feat) ? "escape hatch"
+ : "stairs").c_str());
+ }
+ else if (is_shaft)
+ {
+ simple_monster_message(mon,
+ make_stringf(" %s the shaft.",
+ mons_flies(mon) ? "goes down"
+ : "jumps into").c_str());
+ }
+}
+
+void make_mons_leave_level(monster* mon)
+{
+ if (mon->pacified())
+ {
+ if (you.can_see(mon))
+ {
+ _mons_indicate_level_exit(mon);
+ remove_unique_annotation(mon);
+ }
+
+ // Pacified monsters leaving the level take their stuff with
+ // them.
+ mon->flags |= MF_HARD_RESET;
+ monster_die(mon, KILL_DISMISSED, NON_MONSTER);
+ }
+}