From 6a4da2697718db5497d17b552c11448ee47ef52a Mon Sep 17 00:00:00 2001 From: dshaligram Date: Thu, 14 Jun 2007 17:20:52 +0000 Subject: Fixed mass confusion working only on natural creatures (cbus). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1586 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/beam.cc | 76 +++++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 33 deletions(-) (limited to 'crawl-ref/source/beam.cc') diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 55ca88cd97..0b214cf884 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -1797,9 +1797,47 @@ int mons_adjust_flavoured( monsters *monster, bolt &pbolt, return (hurted); } // end mons_adjust_flavoured() +static bool monster_resists_mass_enchantment(monsters *monster, + enchant_type wh_enchant, + int pow) +{ + // assuming that the only mass charm is control undead: + if (wh_enchant == ENCH_CHARM) + { + if (mons_friendly(monster)) + return (true); + + if (mons_class_holiness(monster->type) != MH_UNDEAD) + return (true); + + if (check_mons_resist_magic( monster, pow )) + { + simple_monster_message(monster, mons_immune_magic(monster) ? + " is unaffected." : " resists."); + return (true); + } + } + else if (wh_enchant == ENCH_CONFUSION + || mons_holiness(monster) == MH_NATURAL) + { + if (check_mons_resist_magic( monster, pow )) + { + simple_monster_message(monster, mons_immune_magic(monster) ? + " is unaffected." : " resists."); + return (true); + } + } + else // trying to enchant an unnatural creature doesn't work + { + simple_monster_message(monster, " is unaffected."); + return (true); + } + + return (false); +} // Enchants all monsters in player's sight. -bool mass_enchantment( int wh_enchant, int pow, int origin ) +bool mass_enchantment( enchant_type wh_enchant, int pow, int origin ) { int i; // loop variable {dlb} bool msg_generated = false; @@ -1817,41 +1855,13 @@ bool mass_enchantment( int wh_enchant, int pow, int origin ) if (monster->type == -1 || !mons_near(monster)) continue; - // assuming that the only mass charm is control undead: - if (wh_enchant == ENCH_CHARM) - { - if (mons_friendly(monster)) - continue; - - if (mons_class_holiness(monster->type) != MH_UNDEAD) - continue; - - if (check_mons_resist_magic( monster, pow )) - { - simple_monster_message(monster, mons_immune_magic(monster) ? - " is unaffected." : " resists."); - continue; - } - } - else if (mons_holiness(monster) == MH_NATURAL) - { - if (check_mons_resist_magic( monster, pow )) - { - simple_monster_message(monster, mons_immune_magic(monster) ? - " is unaffected." : " resists."); - continue; - } - } - else // trying to enchant an unnatural creature doesn't work - { - simple_monster_message(monster, " is unaffected."); + if (monster->has_ench(wh_enchant)) continue; - } - if (monster->has_ench(static_cast(wh_enchant))) - continue; + if (monster_resists_mass_enchantment(monster, wh_enchant, pow)) + continue; - if (monster->add_ench(static_cast(wh_enchant))) + if (monster->add_ench(wh_enchant)) { if (player_monster_visible( monster )) { -- cgit v1.2.3-54-g00ecf