summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-11-22 10:58:06 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-11-22 10:58:06 +0000
commitddfbd2a60be7ce857997097f6bc03eac22f55be1 (patch)
tree2eb4615de3c17148dbdfdbc9f9eb276895330d1f
parent30e689a7f01417ccf37b188dbaf135349e7f04bb (diff)
downloadcrawl-ref-ddfbd2a60be7ce857997097f6bc03eac22f55be1.tar.gz
crawl-ref-ddfbd2a60be7ce857997097f6bc03eac22f55be1.zip
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
-rw-r--r--crawl-ref/source/monstuff.cc33
1 files 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;