From 04b39d34b1eaffd6223743966efab334caf08e8c Mon Sep 17 00:00:00 2001 From: zelgadis Date: Sun, 29 Jun 2008 08:19:15 +0000 Subject: Force berserking and non-living monsters to flee sanctuary. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6212 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/monstuff.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'crawl-ref/source/monstuff.cc') diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index c40052035e..ffb6f30b3e 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -2053,14 +2053,20 @@ void behaviour_event(monsters *mon, int event, int src, break; case ME_SCARE: - // Berserking monsters don't flee. - if (mon->has_ench(ENCH_BERSERK)) + { + const bool flee_sanct = !mons_wont_attack(mon) + && is_sanctuary(mon->x, mon->y); + + // Berserking monsters don't flee, unless it's from sanctuary. + if (mon->has_ench(ENCH_BERSERK) && !flee_sanct) break; - // Neither do plants or nonliving beings. + // Neither do plants or nonliving beings, and sanctuary doesn't + // affect plants. if (mons_class_holiness(mon->type) == MH_PLANT - || mons_class_holiness(mon->type) == MH_NONLIVING) + || (mons_class_holiness(mon->type) == MH_NONLIVING && !flee_sanct)) { + mon->del_ench(ENCH_FEAR, true, true); break; } @@ -2072,6 +2078,7 @@ void behaviour_event(monsters *mon, int event, int src, if (see_grid(mon->x, mon->y)) learned_something_new(TUT_FLEEING_MONSTER); break; + } case ME_CORNERED: // Plants or nonliving monsters cannot flee. -- cgit v1.2.3-54-g00ecf