From 8906a6bb5c2f1caca99203876ed2657a1e818437 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Thu, 5 Nov 2009 16:12:18 -0600 Subject: In is_evil(), mark monsters with explicitly evil spells. Unify checks for monsters with chaotic spells, and do the same for them. --- crawl-ref/source/monster.cc | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'crawl-ref/source/monster.cc') diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc index 2bb73f9683..21b8efb4db 100644 --- a/crawl-ref/source/monster.cc +++ b/crawl-ref/source/monster.cc @@ -2702,6 +2702,24 @@ bool monsters::has_spells() const return (false); } +bool monsters::has_evil_spells() const +{ + for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; ++i) + if (is_evil_spell(spells[i])) + return (true); + + return (false); +} + +bool monsters::has_chaotic_spells() const +{ + for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; ++i) + if (is_chaotic_spell(spells[i])) + return (true); + + return (false); +} + bool monsters::has_spell(spell_type spell) const { for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; ++i) @@ -2858,6 +2876,9 @@ bool monsters::is_evil() const if (is_priest() && (is_evil_god(god) || god == GOD_NAMELESS)) return (true); + if (has_evil_spells()) + return (true); + if (mons_class_flag(type, M_EVIL)) return (true); @@ -2883,12 +2904,8 @@ bool monsters::is_chaotic() const if (is_priest() && is_chaotic_god(god)) return (true); - if (has_spell(SPELL_POLYMORPH_OTHER) - || has_spell(SPELL_SUMMON_UGLY_THING) - || has_spell(SPELL_PORKALATOR)) - { + if (has_chaotic_spells()) return (true); - } if (has_attack_flavour(AF_MUTATE) || has_attack_flavour(AF_ROT) -- cgit v1.2.3-54-g00ecf