summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/monster.cc
diff options
context:
space:
mode:
authorDarshan Shaligram <dshaligram@users.sourceforge.net>2009-11-04 20:09:46 +0530
committerDarshan Shaligram <dshaligram@users.sourceforge.net>2009-11-04 20:15:34 +0530
commit9ad85435681ad82c7ef07d2083e40e525e2b0f55 (patch)
tree3b16cb1129c004ad90cce5c81486373557d5f272 /crawl-ref/source/monster.cc
parentf7c29d55ca91d539d64de5e120a5b2c301ccb938 (diff)
downloadcrawl-ref-9ad85435681ad82c7ef07d2083e40e525e2b0f55.tar.gz
crawl-ref-9ad85435681ad82c7ef07d2083e40e525e2b0f55.zip
Allow vaults to override monster spells with spells:<xyz>
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.
Diffstat (limited to 'crawl-ref/source/monster.cc')
-rw-r--r--crawl-ref/source/monster.cc38
1 files changed, 36 insertions, 2 deletions
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;
}
-
-