From 76cf7eda1e78548dcb3b3e417e8aeb92e2cf1b1e Mon Sep 17 00:00:00 2001 From: dolorous Date: Wed, 18 Jun 2008 06:29:14 +0000 Subject: Take good neutrals into account when checking if a monster's enemies are around, and have a monster leaving the level cast spells like a fleeing monster, for the sake of getting out of the way. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5936 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/monstuff.cc | 18 ++++++++++-------- crawl-ref/source/view.cc | 6 +++--- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index f84d4c9037..59d9c02e79 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -5110,10 +5110,10 @@ static bool _handle_spell(monsters *monster, bolt &beem) SPELL_GREATER_HEALING : SPELL_LESSER_HEALING; finalAnswer = true; } - else if (mons_is_fleeing(monster)) + else if (mons_is_fleeing(monster) || mons_is_leaving(monster)) { // Since the player isn't around, we'll extend the monster's - // normal fleeing choices to include the self-enchant slot. + // normal choices to include the self-enchant slot. int foundcount = 0; for (int i = NUM_MONSTER_SPELL_SLOTS - 1; i >= 0; --i) { @@ -5154,7 +5154,7 @@ static bool _handle_spell(monsters *monster, bolt &beem) // get here... even if the monster is on its last HP. That // way we don't have to worry about monsters infinitely casting // Healing on themselves (e.g. orc high priests). - if (mons_is_fleeing(monster) + if ((mons_is_fleeing(monster) || mons_is_leaving(monster)) && ms_low_hitpoint_cast(monster, hspell_pass[5])) { spell_cast = hspell_pass[5]; @@ -5178,8 +5178,9 @@ static bool _handle_spell(monsters *monster, bolt &beem) if (!finalAnswer) { - // If nothing found by now, safe friendlies will rarely cast. - if (mons_friendly(monster) && !mon_enemies_around(monster) + // If nothing found by now, safe friendlies and good + // neutrals will rarely cast. + if (mons_wont_attack(monster) && !mon_enemies_around(monster) && !one_chance_in(10)) { return (false); @@ -5214,9 +5215,10 @@ static bool _handle_spell(monsters *monster, bolt &beem) { bool spellOK = false; - // Setup spell - fleeing monsters will always try to - // choose their emergency spell. - if (mons_is_fleeing(monster)) + // Setup spell - monsters that are fleeing or leaving + // the level will always try to choose their emergency + // spell. + if (mons_is_fleeing(monster) || mons_is_leaving(monster)) { spell_cast = (one_chance_in(5) ? SPELL_NO_SPELL : hspell_pass[5]); diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index b55698383d..0eff2a9b85 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -3660,10 +3660,10 @@ bool mon_enemies_around(const monsters *monster) if (monster->foe != MHITNOT && monster->foe != MHITYOU) return (true); - if (mons_friendly(monster)) + if (mons_wont_attack(monster)) { - // Additionally, if an ally is nearby and *you* have a foe, consider - // it as the ally's enemy too. + // Additionally, if an ally is nearby and *you* have a foe, + // consider it as the ally's enemy too. return (mons_near(monster) && !i_feel_safe()); } else -- cgit v1.2.3-54-g00ecf