Spell Tutorial - dredmor-com/dungeons-of-dredmor GitHub Wiki
Spells are stored in spellDB.xml. They are actually used for several things in Dungeons of Dredmor:
- Actual magical spells
- Any activated abilities gained from Skills
- Special monster attacks
- Special effects of items, wands and weapons
- Sub-effects of the spells themselves
Quite the handful! Because of this, the syntax for spells can be quite inconsistent at times. Let's try a few examples.
Firstly, you'll need to setup a directory and mod.xml file. Afterwards, make a 'spellDB.xml' file. Make sure it starts with <spellDB>
and ends with </spellDB>
, or the XML bears will come get you. Now, you'll add one or more spells to this file. In keeping with the Holy Writ of XML, they each have to start with <spell>
and end with </spell>
. Pretty much nothing in the spells will be magically given away to your adventurer unless it's tied to an item, ability or monster, so look up those tutorials if needed.
This is the Obvious Fireball spell from Promethean Magic:
<spell name="Obvious Fireball" type="missile" icon="skills/spells/fireball32.png" wand="1" >
<requirements mp="18" savvyBonus="0.15" mincost="8"/>
<effect type="damage" blasting="4" blastingF="0.2" affectscaster="1" />
<anim sprite="sprites/sfx/flame_buff_loop/flame_buff_loop" frames="6" framerate="50" sfx="flame" />
<impact sprite="sprites/sfx/fireball/fireball" frames="7" firstframe="0" framerate="90" centerEffect="1" sfx="explosion" />
<effect type="trigger" spell="Flamefield 1" amount="0" />
<effect type="trigger" spell="Fireball Effect" amount="0" />
<description text="It's a giant fireball. It goes BOOM. Then with the burning. Oh god, the burning. What more do you want?" />
</spell>
Which isn't too obvious by itself. Let's take it one step at a time.
Tag | Attribute | Description |
---|---|---|
spell | name="Obvious Fireball" | The name of the spell. Other XML files will use this to call it. |
type="missile" | This defines both what this spell can target and how it behaves once it's used. 'missile' targets any floor tile and shoots a missile at the target. | |
icon="skills/spells/fireball32.png" | Only used if the player has this spell as an ability. This icon appears on the Ability Bar. | |
wand="1" | Does absolutely nothing. This is why you keep your code tidy, children. | |
requirements | mp="18" | MP (Mana) cost for this spell if it's an ability. |
savvyBonus="0.15" | Each point of user's Savvy will reduce the MP cost by this much. In this case, 20 Savvy will reduce the MP cost to 18. 18 + ( 20 * 0.15 ) = 18 - 3 = 15 |
|
mincost="8" | Minimum MP cost of this spell, no matter how much Savvy the user has. | |
effect | type="damage" | Effect is the most common tag in spells, being used for a variety of... effects. In this case, the effect is to deal direct damage to whatever it hits. More effects can be found on the Spell Effects page. |
blasting="4" | Each type of damage is described by its own name, so this does 4 Blasting damage. | |
blastingF="0.2" | Each point of the users Magic Power will add 0.2 damage to the effect. | |
affectscaster="1" | If the caster is dimwitted enough to target their own tile with this, they will take damage. | |
anim | sprite="..." | The directory with the images that will make up the animation for this spell. |
frames="6" | There are 6 images in the used directory. To use another number would call madness. | |
framerate="50" | Just how fast these images will be cycling around. | |
sfx="flame" | One of the items from soundfx.xml, defines the sound this spell makes. | |
impact | sprite="..." | 'impact' is only used for missile spells. In this case, 'anim' will play while the missile is flying through the air, and 'impact' will play when the spell actually hits. |
firstframe="0" | The first frame for this animation. In most tidily ordered animations, the starting frame is zero, so it's actually unclear why this attribute was implemented. | |
centerEffect="1" | For sizable animations, center the graphics on the targt square. | |
effect | type="trigger" | The "trigger" effect is the programmer's friend. It lets you call another spell from within this spell. |
spell="Flamefield 1" | The spell that will be called, in this case, Flamefield 1: a "spell mine" that blankets the area around the target in flames. | |
amount="0" | 'amount' means different things for each effect tag. For 'trigger' effects, it means to wait a given amount of turns before triggering the spell or, in this case, it will take immediate effect. | |
description | text="..." | This also only appears if the player were to equip this as an ability. Describes the spell when you mouse over it on the Ability bar. |
Buffs have their own special syntax inside the spells. We'll review a monster attack that grants a debuff, the alarming Diggle Plague.
<spell name="Diggle Plague" type="target" icon="skills/diggle_plague32.png" >
<buff useTimer="1" time="24" allowstacking="0" stacksize="1" self="0" icon="skills/diggle_plague64.png" smallicon="skills/diggle_plague32.png" bad="1" >
<primarybuff id="0" amount="-3"/> <!-- Burliness -->
<primarybuff id="1" amount="-3"/> <!-- Sagacity -->
<primarybuff id="2" amount="-3"/> <!-- Nimbleness -->
<secondarybuff id="0" amount="-5"/> <!-- hp -->
<secondarybuff id="6" amount="-5"/> <!-- dodge -->
<resistbuff crushing="-1" hyperborean="-1" toxic="-1" />
<!-- oh yes, it'll get nasty -->
<targetHitEffectBuff percentage="10" name="Diggle Plague" />
<playerHitEffectBuff percentage="5" name="Diggle Plague" />
</buff>
<description text="It's the dreaded Diggle Plague! Run away and blast it with fireballs: it's the only way to be sure." />
</spell>
This one is used as a monster ability (and sometimes triggered by being hit), so it doesn't have an ability icon or MP cost. It does not have effects other than the buff, otherwise they'd be either before or after the <buff></buff>
block. Let's look at the structure of the buff bit.
Spell mines are used for magical "traps" that lay waiting until an enemy steps on them, an Area of Effect spells that hits everything in a given radius, or both - traps that explode into a huge area when stepped on! Some of these effects are also achievable with templates, so pick your poison.
Spells with the type "template" will take in a predefined 'manual template' from the manTemplates.xml file, triggering once for each marked square in the template. This is mainly used for 'spherical' and 'conical' spells in the original game, but nothing stops you from making insanely shaped spells.
<spell name="Dragon's Breath" type="template" templateID="30" anchored="1" icon="skills/spells/dragons_breath32.png" wand="1">
<requirements mp="10" savvyBonus="0.26" mincost="3" />
<effect burn="1" type="damage" conflagratory="4" conflagratoryF="0.20" blasting="2" blastingF="0.1" />
<effect type="trigger" spell="Dragon's Breath 1" amount="0" />
<effect type="trigger" spell="Dragon's Breath 2" amount="0" />
<anim sprite="sprites/sfx/combust_hit/combust_hit" frames="7" firstframe="2" framerate="35" sfx="flame" centerEffect="1"/>
<description text="You can belch forth a jet of flame, not unlike that incident with the wager involving an entire barrel of Dwarven Rum. It sets anything in the way, including the floor, on fire."/>
</spell>
Tag | Attribute | Description |
---|---|---|
spell | type="template" | This spell will use a given template and trigger effects based on that template's tiles. |
templateID="30" | Template ID 30, for instance, is a tile in front fo the player, later triggering spells with templates 31 and 32 on the same turn for a "moving wave of fire" effect. | |
anchored="1" | Centers the spell on the player and rotates it to the player's direction. The original templates are always drawn facing "north", or upwards on the screen. |
An ability on a cooldown is mostly the same as a spell, except it loses the <requirements>
portion and gets the downtime
attribute. As an example, here is the Obvious Fireball spell if it was an ability that cost no MP and took 32 turns to be usable again:
<spell name="Obvious Fireball" type="missile" icon="skills/spells/fireball32.png" downtime="32" >
<effect type="damage" blasting="4" blastingF="0.2" affectscaster="1" />
<anim sprite="sprites/sfx/flame_buff_loop/flame_buff_loop" frames="6" framerate="50" sfx="flame" />
<impact sprite="sprites/sfx/fireball/fireball" frames="7" firstframe="0" framerate="90" centerEffect="1" sfx="explosion" />
<effect type="trigger" spell="Flamefield 1" amount="0" />
<effect type="trigger" spell="Fireball Effect" amount="0" />
<description text="It's a giant fireball. It goes BOOM. Then with the burning. Oh god, the burning. What more do you want?" />
</spell>
Spells usable by monsters typicalle have no mana cost or downtime, since monsters just use them randomly, and a couple of extra fields.
<spell name="Corrupt Equipment" type="target" icon="skills/spells/radiant_aura32.png" wand="0">
<anim sprite="sprites/sfx/acid_bolt/acid_bolt" frames="3" framerate="80" sfx="missile" />
<effect type="corrupt" amount="1"/>
<description text="Used by blobbies to grind your equipment to dust." monsterText="corrupts your equipment!"/>
<ai hint="target"/>
</spell>
Tag | Attribute | Description |
---|---|---|
description | mosnterText="corrupts your equipment!" | This text will appear on the text log at the top of the screen (known as a Ticker) when this spell is used. |
ai | hint="target" | A hint to the monster AI on how to use this spell. The available values are 'target', 'ally' or 'self'. |