summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-chimera.cc
diff options
context:
space:
mode:
authorPete Hurst <pete@streamuniverse.tv>2013-06-21 19:19:00 +0100
committerPete Hurst <pete@streamuniverse.tv>2013-06-21 19:19:10 +0100
commit834c2522949fbaa1b8f7468f1e32a01d4d7127a5 (patch)
treef8bf894e0be51634fd12e3aa7d23b6baeba2654d /crawl-ref/source/mon-chimera.cc
parent11fb7f4099dd147e1757a2d4d2b3ea18aa791333 (diff)
downloadcrawl-ref-834c2522949fbaa1b8f7468f1e32a01d4d7127a5.tar.gz
crawl-ref-834c2522949fbaa1b8f7468f1e32a01d4d7127a5.zip
Construct chimera spell books more sensibly
Rather than filling any available slots with any old spells, this uses the misc slots for potential bolt spells, and correctly copies spells from special slots (enchant, self-ench, emergency). This provides for situations like bear chimera using berserk properly as an escape spell.
Diffstat (limited to 'crawl-ref/source/mon-chimera.cc')
-rw-r--r--crawl-ref/source/mon-chimera.cc42
1 files changed, 24 insertions, 18 deletions
diff --git a/crawl-ref/source/mon-chimera.cc b/crawl-ref/source/mon-chimera.cc
index 9342bbd9df..2d0c4aa3cf 100644
--- a/crawl-ref/source/mon-chimera.cc
+++ b/crawl-ref/source/mon-chimera.cc
@@ -58,24 +58,30 @@ static void apply_chimera_part(monster* mon, monster_type part, int partnum)
// Apply spells but only for 2nd and 3rd parts since 1st part is
// already supported by the original define_monster call
- if (partnum > 1)
- {
- // Check monster's spells
- for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; ++i)
- {
- if (dummy.spells[i] != SPELL_NO_SPELL)
- continue;
- // Find a free spell slot on the chimera
- for (int j = 0; j < NUM_MONSTER_SPELL_SLOTS; ++j)
- {
- if (mon->spells[j] == SPELL_NO_SPELL)
- {
- mon->spells[j] = dummy.spells[i];
- break;
- }
- }
- }
- }
+ if (partnum == 1)
+ return;
+
+ // XXX: It'd be nice to flood fill all available spell slots with spells
+ // from parts 2 and 3. But since this would conflict with special
+ // slots (emergency, enchantment, etc.) some juggling is needed, until
+ // spell slots can be made more sensible.
+
+ // Use misc slots (3+4) for the primary spells of parts 1 & 2
+ const int boltslot = partnum + 1;
+ // Overwrite the base monster's misc spells if they had any
+ if (dummy.spells[0] != SPELL_NO_SPELL)
+ mon->spells[boltslot] = dummy.spells[0];
+
+ // Other spell slots overwrite if the base monster(s) didn't have one
+ // Enchantment
+ if (mon->spells[1] == SPELL_NO_SPELL && dummy.spells[1] != SPELL_NO_SPELL)
+ mon->spells[1] = dummy.spells[1];
+ // Self-enchantment
+ if (mon->spells[2] == SPELL_NO_SPELL && dummy.spells[2] != SPELL_NO_SPELL)
+ mon->spells[2] = dummy.spells[2];
+ // Emergency
+ if (mon->spells[5] == SPELL_NO_SPELL && dummy.spells[5] != SPELL_NO_SPELL)
+ mon->spells[5] = dummy.spells[5];
}
monster_type get_chimera_part(const monster* mon, int partnum)