From 3b1cbcc423f4d5bf475ce83cde8971bffb351abb Mon Sep 17 00:00:00 2001 From: zelgadis Date: Wed, 2 Jul 2008 01:43:29 +0000 Subject: When laying down Sanctuary make all pets inside it stop attacking and move towards you. You can get them to attack while inside Sanctuary by giving them an order to attack a specific monster, and if they do attack and violate Sanctuary then it will be removed. Attempting to give such an order will give a warning that it might violate Sanctuary. Prevent confused and berserking pets from violating Sanctuary, since you can't order them not to. Prevent monsters fleeing Sanctuary from attacking monsters which are blocking their flight path. The player attacking him/her-self because of confusion no longer vilates Sanctuary. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6312 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/monstuff.cc | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'crawl-ref/source/monstuff.cc') diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 7b79da8b2f..4ad21c1801 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -2058,7 +2058,10 @@ void behaviour_event(monsters *mon, int event, int src, // Stationary monsters can't flee, even from sanctuary. if (mons_is_stationary(mon)) + { + mon->del_ench(ENCH_FEAR, true, true); break; + } // Berserking monsters don't flee, unless it's from sanctuary. if (mon->has_ench(ENCH_BERSERK) && !flee_sanct) @@ -2084,12 +2087,13 @@ void behaviour_event(monsters *mon, int event, int src, } case ME_CORNERED: - // Plants or nonliving monsters cannot flee. - if (mons_class_holiness(mon->type) == MH_PLANT - || mons_class_holiness(mon->type) == MH_NONLIVING) - { + // Some monsters can't flee. + if (mon->behaviour != BEH_FLEE && !mon->has_ench(ENCH_FEAR)) + break; + + // Don't stop fleeing from sanctuary + if (!mons_wont_attack(mon) && is_sanctuary(mon->x, mon->y)) break; - } // Just set behaviour... foe doesn't change. if (!mons_is_cornered(mon)) @@ -3414,6 +3418,13 @@ static void _handle_behaviour(monsters *mon) mon->foe = new_foe; } + + if (is_sanctuary(mon->target_x, mon->target_y) && mon->foe != MHITNOT + && !isFriendly && !mons_is_pacified(mon) && mon->behaviour != BEH_FLEE + && mon->target_pos() != mon->pos()) + { + mon->foe = MHITNOT; + } } static bool _mons_check_set_foe(monsters *mon, int x, int y, @@ -3423,7 +3434,7 @@ static bool _mons_check_set_foe(monsters *mon, int x, int y, return (false); if (!friendly && !neutral && x == you.x_pos && y == you.y_pos - && mons_player_visible(mon)) + && mons_player_visible(mon) && !is_sanctuary(x, y)) { mon->foe = MHITYOU; return (true); @@ -3435,6 +3446,7 @@ static bool _mons_check_set_foe(monsters *mon, int x, int y, if (foe != mon && mon_can_see_monster(mon, foe) + && (friendly || !is_sanctuary(x, y)) && (mons_friendly(foe) != friendly || (neutral && !mons_neutral(foe)))) { -- cgit v1.2.3-54-g00ecf