From 9ad85435681ad82c7ef07d2083e40e525e2b0f55 Mon Sep 17 00:00:00 2001 From: Darshan Shaligram Date: Wed, 4 Nov 2009 20:09:46 +0530 Subject: Allow vaults to override monster spells with spells: Vaults can now override monster spell sets, or give non-casting monsters spells, and mark monsters as wizard or priest types. The M_ACTUAL_SPELLS, M_SPELLCASTER and M_PRIEST monster class flags are converted into MF_* flags at monster creation/polymorph time, and only the per-monster flags are checked when determining wizard/priestliness. See caveats in level_design.txt. --- crawl-ref/source/monster.cc | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'crawl-ref/source/monster.cc') diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc index 4770e2fe9b..66c38c3277 100644 --- a/crawl-ref/source/monster.cc +++ b/crawl-ref/source/monster.cc @@ -658,6 +658,18 @@ bool monsters::has_spell_of_type(unsigned disciplines) const return (false); } +void monsters::bind_spell_flags() +{ + // Bind spellcaster / priest flags from the base type. These may be + // overridden by vault defs for individual monsters. + if (mons_class_flag(type, M_SPELLCASTER)) + flags |= MF_SPELLCASTER; + if (mons_class_flag(type, M_ACTUAL_SPELLS)) + flags |= MF_ACTUAL_SPELLS; + if (mons_class_flag(type, M_PRIEST)) + flags |= MF_PRIEST; +} + static bool _needs_ranged_attack(const monsters *mon) { // Prevent monsters that have conjurations from grabbing missiles. @@ -2680,6 +2692,15 @@ void monsters::banish(const std::string &) monster_die(this, KILL_RESET, NON_MONSTER); } +bool monsters::has_spells() const +{ + for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; ++i) + if (spells[i] != SPELL_NO_SPELL) + return (true); + + return (false); +} + bool monsters::has_spell(spell_type spell) const { for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; ++i) @@ -3597,6 +3618,21 @@ bool monsters::has_multitargeting() const || type == MONS_ELECTRIC_GOLEM); } +bool monsters::can_use_spells() const +{ + return (flags & MF_SPELLCASTER); +} + +bool monsters::is_priest() const +{ + return (flags & MF_PRIEST); +} + +bool monsters::is_actual_spellcaster() const +{ + return (flags & MF_ACTUAL_SPELLS); +} + bool monsters::has_ench(enchant_type ench) const { return (enchantments.find(ench) != enchantments.end()); @@ -5705,5 +5741,3 @@ void mon_enchant::set_duration(const monsters *mons, const mon_enchant *added) if (duration > maxduration) maxduration = duration; } - - -- cgit v1.2.3-54-g00ecf