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.

  1. Previous Setup
  2. Magic Spell
  3. Buffs
  4. Spell Mines
  5. Templates
  6. Cooldown Ability
  7. Monster Spells
  8. See Also

Previous Setup

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.

Magic Spell

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

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.

Tag Attribute Description
buff useTimer="1" A boolean indicating if the debuff fades away after some time. In this case, it will disappear after the 'time' attribute tells it to.
time="24" When 'useTimer' is set to '1', this is the amount of turns it will take to disappear. Right here, it indicates the debuff will run out after 24 turns.
allowstacking="0" A boolean to determine if this debuff has stacking effects or not. In here, we're telling it not to stack.
stackSize="1" When 'allowstacking' is '1', this determines how big the stack can be before it stops increasing. Here, we're saying the maximum allowed stack size is '1', although it doesn't do much when we already said we don't want to stack this debuff.
icon="skills/diggle_plague64.png" The icon the player sees when they're affected by this buff.
smallicon="skills/diggle_plague32.png" The icon that appears on a monster's description when affected by this buff.
bad="1" A boolean to say whether this is a buff or a debuff. It's important for items that remove debuffs, like Potions of Purity or Zodiac Wands. In this case, it's a debuff and these rules will apply.
primarybuff id="0" This specific tag can only appear inside 'buff' tags. It denotes a buff to one of the six primary stats by a given amount. In this case, a 3 point decrease to the P. Stat. with id '0' (Burliness).
amount="-3"
secondarybuff id="0" Much like the latter, only for the 'buff' tag section. This time, it's for the secondary stats, given an specific id and amount. For this case, a 5 point decrease to the S. Stat. with id '0' (Maximum HP).
amount="-5"
resistbuff crushing="-1" Buffs/debuffs defenses. 'damagebuff' has exactly the same syntax, but affects damage instead. It uses keywords for typing, like 'crushing'. In our case, it reduces Crushing Resistance by 1. There's more values with an easily discernible similarity.
targetHitEffectBuff percentage="10" This was also mentioned in the

Spell Mines

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.

Templates

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.

Cooldown Ability

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>

Monster Spells

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'.

See Also:

Spell Effects

⚠️ **GitHub.com Fallback** ⚠️