From d3d2bb1fc5dfa688e83c24a35fcfcb5fc047dc1b Mon Sep 17 00:00:00 2001 From: haranp Date: Thu, 8 Nov 2007 10:51:46 +0000 Subject: Merge r2804 (enslaved fleeing behaviour). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.3@2805 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/beam.cc | 3 --- crawl-ref/source/mon-util.cc | 7 +++++++ crawl-ref/source/monstuff.cc | 12 ++++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 157c288499..d842cdca0e 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -2034,9 +2034,6 @@ int mons_ench_f2(monsters *monster, bolt &pbolt) case BEAM_CHARM: /* 9 = charm */ if (monster->add_ench(ENCH_CHARM)) { - // break fleeing and suchlike - monster->behaviour = BEH_SEEK; - // put in an exception for fungi, plants and other things you won't // notice becoming charmed. if (simple_monster_message(monster, " is charmed.")) diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 8c1ba895b1..237a2eaa5c 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -3783,6 +3783,13 @@ void monsters::add_enchantment_effect(const mon_enchant &ench, bool) speed /= 2; break; + case ENCH_CHARM: + behaviour = BEH_SEEK; + target_x = you.x_pos; + target_y = you.y_pos; + foe = MHITYOU; + break; + default: break; } diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 79bbab27f1..affd188b41 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -1995,7 +1995,13 @@ static void handle_behaviour(monsters *mon) // we can jump back to WANDER if the foe // isn't present. - if (proxFoe) + if (isFriendly) + { + // Special-cased below so that it will flee *towards* you + mon->target_x = you.x_pos; + mon->target_y = you.y_pos; + } + else if (proxFoe) { // try to flee _from_ the correct position mon->target_x = foe_x; @@ -2173,7 +2179,9 @@ static void handle_movement(monsters *monster) mmov_x = (dx > 0) ? 1 : ((dx < 0) ? -1 : 0); mmov_y = (dy > 0) ? 1 : ((dy < 0) ? -1 : 0); - if (monster->behaviour == BEH_FLEE) + if (monster->behaviour == BEH_FLEE && + (!mons_friendly(monster) || + monster->target_x != you.x_pos || monster->target_y != you.y_pos)) { mmov_x *= -1; mmov_y *= -1; -- cgit v1.2.3-54-g00ecf