From ddfbd2a60be7ce857997097f6bc03eac22f55be1 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Wed, 22 Nov 2006 10:58:06 +0000 Subject: Improve monster AI for monsters with both spells and special abilities (draconians). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@458 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/monstuff.cc | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index df7f5184b5..170f5bcef4 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -3546,6 +3546,19 @@ static bool handle_throw(struct monsters *monster, bolt & beem) return (false); } // end handle_throw() +static bool handle_monster_spell(monsters *monster, bolt &beem) +{ + // shapeshifters don't get spells + if (!mons_has_ench( monster, ENCH_GLOWING_SHAPESHIFTER, + ENCH_SHAPESHIFTER ) + || !mons_class_flag( monster->type, M_ACTUAL_SPELLS )) + { + if (handle_spell(monster, beem)) + return (true); + } + return (false); +} + static void handle_monster_move(int i, monsters *monster) { bool brkk = false; @@ -3738,8 +3751,17 @@ static void handle_monster_move(int i, monsters *monster) // How nice! if (mons_friendly(monster) || mons_near(monster)) { - if (handle_special_ability(monster, beem)) + // [ds] Special abilities shouldn't overwhelm spellcasting + // in monsters that have both. This aims to give them both + // roughly the same weight. + if (coinflip()? + handle_special_ability(monster, beem) + || handle_monster_spell(monster, beem) + : handle_monster_spell(monster, beem) + || handle_special_ability(monster, beem)) + { continue; + } if (handle_potion(monster, beem)) continue; @@ -3747,15 +3769,6 @@ static void handle_monster_move(int i, monsters *monster) if (handle_scroll(monster)) continue; - // shapeshifters don't get spells - if (!mons_has_ench( monster, ENCH_GLOWING_SHAPESHIFTER, - ENCH_SHAPESHIFTER ) - || !mons_class_flag( monster->type, M_ACTUAL_SPELLS )) - { - if (handle_spell(monster, beem)) - continue; - } - if (handle_wand(monster, beem)) continue; -- cgit v1.2.3-54-g00ecf