diff options
author | David Lawrence Ramsey <dolorous@users.sourceforge.net> | 2009-11-14 10:04:03 -0600 |
---|---|---|
committer | David Lawrence Ramsey <dolorous@users.sourceforge.net> | 2009-11-14 10:04:47 -0600 |
commit | 5a6c75973796faca8161de9893d62cef5798fd1a (patch) | |
tree | 9a178a9937fe03298119f2d23f7fb78cfb2af55d /crawl-ref/source/mon-util.cc | |
parent | 2320627550dde210319cec662928dfb6849026fb (diff) | |
download | crawl-ref-5a6c75973796faca8161de9893d62cef5798fd1a.tar.gz crawl-ref-5a6c75973796faca8161de9893d62cef5798fd1a.zip |
Move general initialization of monster spells into its own function.
Diffstat (limited to 'crawl-ref/source/mon-util.cc')
-rw-r--r-- | crawl-ref/source/mon-util.cc | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index cd4bbfe45a..3d07524355 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -1443,9 +1443,31 @@ static bool _get_spellbook_list(mon_spellbook_type book[6], return (retval); } -void define_monster(int index) +static void _get_spells(mon_spellbook_type& book, monsters *mon) { - define_monster(menv[index]); + if (book == MST_NO_SPELLS && mons_class_flag(mon->type, M_SPELLCASTER)) + { + mon_spellbook_type multi_book[6]; + if (_get_spellbook_list(multi_book, mon->type)) + { + do + book = multi_book[random2(6)]; + while (book == MST_NO_SPELLS); + } + } + + mon->load_spells(book); + + // (Dumb) special casing to give ogre mages Haste Other. -cao + if (mon->type == MONS_OGRE_MAGE) + mon->spells[0] = SPELL_HASTE_OTHER; + + mon->bind_spell_flags(); +} + +void define_monster(int midx) +{ + define_monster(menv[midx]); } // Generate a shiny new and unscarred monster. @@ -1562,19 +1584,6 @@ void define_monster(monsters &mons) if (col == BLACK) col = random_colour(); - if (m->sec == MST_NO_SPELLS && mons_class_flag(mons.type, M_SPELLCASTER)) - { - mon_spellbook_type book[6]; - if (_get_spellbook_list(book, mons.type)) - { - do - spells = book[random2(6)]; - while (spells == MST_NO_SPELLS); - } - } - else - spells = m->sec; - // Some calculations. hp = hit_points(hd, m->hpdice[1], m->hpdice[2]); hp += m->hpdice[3]; @@ -1599,13 +1608,8 @@ void define_monster(monsters &mons) mons.experience = 0L; mons.colour = col; - mons.load_spells(spells); - - // (Dumb) special casing to give ogre mages Haste Other. -cao - if (mons.type == MONS_OGRE_MAGE) - mons.spells[0] = SPELL_HASTE_OTHER; - - mons.bind_spell_flags(); + spells = m->sec; + _get_spells(spells, &mons); // Reset monster enchantments. mons.enchantments.clear(); |