diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-06 19:49:41 -0800 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-06 19:50:29 -0800 |
commit | 3807330ab546425a7f2fc63cb3f731ade3684011 (patch) | |
tree | 3578a12831052cf52cd4c549eeca27f440e54efc | |
parent | e665413aeb03054dccc48104ee4bbeb73e4fffc1 (diff) | |
download | crawl-ref-3807330ab546425a7f2fc63cb3f731ade3684011.tar.gz crawl-ref-3807330ab546425a7f2fc63cb3f731ade3684011.zip |
mon-cast: fix is_valid_mon_spell()
is_valid_mon_spell() should now correctly return true for non-targetted
monster spells.
-rw-r--r-- | crawl-ref/source/mon-cast.cc | 21 | ||||
-rw-r--r-- | crawl-ref/source/mon-cast.h | 3 |
2 files changed, 16 insertions, 8 deletions
diff --git a/crawl-ref/source/mon-cast.cc b/crawl-ref/source/mon-cast.cc index 9742cb7aa5..0e36894d11 100644 --- a/crawl-ref/source/mon-cast.cc +++ b/crawl-ref/source/mon-cast.cc @@ -42,6 +42,8 @@ void init_mons_spells() fake_mon.type = MONS_BLACK_DRACONIAN; fake_mon.hit_points = 1; + bolt pbolt; + for (int i = 0; i < NUM_SPELLS; i++) { spell_type spell = (spell_type) i; @@ -51,9 +53,7 @@ void init_mons_spells() if (!is_valid_spell(spell)) continue; - bolt beam = mons_spells(&fake_mon, spell, 1, true); - - if (beam.flavour != NUM_BEAMS) + if (setup_mons_cast(&fake_mon, pbolt, spell, true)) _valid_mon_spells[i] = true; } } @@ -718,7 +718,8 @@ static bool _los_free_spell(spell_type spell_cast) } // Set up bolt structure for monster spell casting. -void setup_mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast) +bool setup_mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast, + bool check_validity) { // always set these -- used by things other than fire_beam() @@ -745,11 +746,11 @@ void setup_mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast) { case SPELL_BRAIN_FEED: pbolt.type = DMNBM_BRAIN_FEED; - return; + return (true); case SPELL_SMITING: case SPELL_AIRSTRIKE: pbolt.type = DMNBM_SMITING; - return; + return (true); default: // Other spells get normal setup: break; @@ -793,8 +794,13 @@ void setup_mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast) case SPELL_TOMB_OF_DOROKLOHE: case SPELL_CHAIN_LIGHTNING: // the only user is reckless case SPELL_SUMMON_EYEBALLS: - return; + return (true); default: + if (check_validity) + { + bolt beam = mons_spells(monster, spell_cast, 1, true); + return (beam.flavour != NUM_BEAMS); + } break; } @@ -876,6 +882,7 @@ void setup_mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast) } // else target remains as specified } + return (true); } // Returns a suitable breath weapon for the draconian; does not handle all diff --git a/crawl-ref/source/mon-cast.h b/crawl-ref/source/mon-cast.h index 6d7d023abc..390f563875 100644 --- a/crawl-ref/source/mon-cast.h +++ b/crawl-ref/source/mon-cast.h @@ -22,7 +22,8 @@ bolt mons_spells(monsters *mons, spell_type spell_cast, int power, void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast, bool do_noise = true); void mons_cast_noise(monsters *monster, bolt &pbolt, spell_type spell_cast); -void setup_mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast); +bool setup_mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast, + bool check_validity = false); void mons_cast_haunt(monsters *monster); |