This tutorial will show you how to create a new spell. It will only use effects and graphics that you already have; the focus in this tutorial is on the XML files, though I’m not actually going to really cover how XML works – you’d be better off asking Google for some tutorials on that instead.
We’ll create the spell in two stages. I’ve given descriptions for each version below.
Breath of Fire (v0.5): Enchanted unit gains +2 Attack.
Breath of Fire (v1.0): Enchanted unit gains +2 Attack and a short range Fire Breath ability.
Before writing anything, it’s important to understand a few key points:
Make sure you've enabled Mods in your game options. This should be the first thing you do - after updates, it seems like this gets reset to FALSE.
Where are the original files you mention? On a 32 bit machine, they’re located in C:\Program Files\Stardock Games\Elemental\data\English. On a 64 bit machine, they’re in C:\Program Files (x86)\Stardock Games\Elemental\data\English. Don’t overwrite the originals – make copies instead.
Where do my new/copied XML files go? I put mine in …\Documents\My Games\Elemental\Units. If there is an actual …\Mod folder somewhere, I’ve yet to see it.
What files will I need to copy/add? For this tutorial, we’re going to need:
- A copy of CoreSpellBooks.xml. I named my copy Gnilbert_SpellBooks.xml
- A new, empty XML file. I named mine Gnilbert_Spells.xml.
Now we get started. Update your Gnilbert_Spells.xml as follows (you don’t have to include the comments, obviously, but they’ll help you remember what’s what):
Code: xml
- <!-- Your Spell Definitions must all be children of a Spells element. Here, it’s the root element of the file. -->
- <Spells>
- <!-- Not really sure what this element is for, but it’s in the Core spell files, so let’s keep it. -->
- <DataChecksum NoParse="1">
- <Ignore>DisplayName,Description,IconFG,IconBG,IconColor,SoundFX,ParticleEffect,EffectScale</Ignore>
- <Translate>DisplayName,Description</Translate>
- </DataChecksum>
- <!-- *This is the element that will define the spell. The InternalName is basically its global name. Using a custom prefix helps avoid naming conflicts. -->
- <SpellDef InternalName="Gnilbert_FireBreath">
- <!-- *This is the name that will show up in the Spell book or as a tooltip when you’re using this spell, so keep it short and pithy -->
- <DisplayName>Breath of Fire</DisplayName>
- <!-- *The longer description that is shown to the user to describe the spell’s effects. -->
- <Description> Enchanted unit gains +2 Attack.</Description>
- <!-- *This is the large image displayed on the right hand side of the spell book when you have the spell selected. -->
- <Image>FireCrystal_Medallion.png</Image>
- <!-- *This is the small icon that shows up in the action bar or as the spell icon on the left page of the spell book. -->
- <IconFG>Fire_Breath.png</IconFG>
- <!-- *Not really sure. -->
- <IconColor>68,128,32</IconColor>
- <!-- *The sound effect that plays when the spell is cast. -->
- <SoundFX>Spell_Enchant_01</SoundFX>
- <!-- *How much mana this spell costs to cast. NOTE: I set this to 1 to make testing easier. -->
- <ManaCost>1</ManaCost>
- <!-- *The level of the spell. NOTE: I set this to 1 to make testing easier. -->
- <SpellLevel>1</SpellLevel>
- <!-- *How far away can the target be? Special Values: -1 = unlimited distance, 0 = caster’s square only, 1 = adjacent squares -->
- <Range>1</Range>
- <SpellType>Strategic</SpellType>
- <SpellClass>Enchantment</SpellClass>
- <!-- *What types of things can this spell target? Other options include: Self, EnemyUnit, (Enemy/Friendly)City, (Enemy/Friendly)Territory, etc -->
- <SpellTargetType>FriendlyUnit</SpellTargetType>
- <!-- *Defines a special effect that plays when the spell is cast. I chose to use an existing effect that seemed appropriate. -->
- <SpellDefEffect>
- <EffectName>Protection_from_Fire</EffectName>
- <LocalPosition>0,0,0</LocalPosition>
- <EffectScale>1.5</EffectScale>
- <EffectDelay>0.0</EffectDelay>
- <SnapToTerrain>1</SnapToTerrain>
- </SpellDefEffect>
- <!-- *Here’s where we describe what the spell actually DOES. -->
- <GameModifier InternalName="Gnilbert_FireBreathAttackBonus">
- <!-- *There are lots of GameModifiers based on (ModType, Attribute) pairs. Most of the modifiers that affect units without specifically affecting only units in Tactical mode, have ModType=Unit. -->
- <ModType>Unit</ModType>
- <!-- *This is the type of Unit modification you’re making. You want to add a specific number (specified by Value, below) to the unit’s stat. If you’d set Attribute=SetUnitStat instead, it would ignore the current value and set the stat to Value. -->
- <Attribute>AdjustUnitStat</Attribute>
- <!-- *The stat on the unit you actually want to change. Look in CoreUnitStats.xml for more stats you could change! -->
- <StrVal>UnitStat_HealthRegen</StrVal>
- <!-- *The amount we’re adjusting his Attack: +2. You could have weakened his attack with a -2 instead. -->
- <Value>2</Value>
- <!-- *How many turns the effect lasts. When you set it to -1, it lasts until the caster cancels the enchantment. Then, it neatly removes the effect. -->
- <Duration>-1</Duration>
- </GameModifier>
- </SpellDef>
- </Spells>
Woohoo!! We have a new spell! Let's fire the game up and test it, shall we? Not quite. The spell exists, but there's no way for your sovereign to actually
use it. That's where our copy of the Core_SpellBooks comes into play. The Spellbook defines which spells are part of its collection. For our spell, we want to add it to the FireSpellbook, so scroll down to that section in your copy (mine's called Gnilbert_SpellBooks), and add the following code:
Code: xml
- <!-- ******************** -->
- <!-- ** Fire Spellbook ** -->
- <!-- ******************** -->
- <Spellbook InternalName="FireSpellbook">
- <DisplayName>Fire</DisplayName>
- <Icon>Fire_Dot.png</Icon>
- <Cost>3</Cost>
- <SpellbookNode InternalName="Node00">
- <NodeID>0</NodeID>
- <SpellDef>SummonFireGiant</SpellDef>
- <StartingResearch>1</StartingResearch>
- </SpellbookNode>
- <!-- NOTE: Node02 through Node03 are omitted for brevity. DON'T DELETE THEM -->
- <SpellbookNode InternalName="Node09">
- <NodeID>9</NodeID>
- <SpellDef>ShieldOfFire</SpellDef>
- <StartingResearch>1</StartingResearch>
- </SpellbookNode>
- <!-- NEW CODE BELOW -->
- <!-- Create a new node for your spell in this book. Set both the node's InternalName -->
- <SpellbookNode InternalName="Node10">
- <!-- And NodeID to use the next available index -->
- <NodeID>10</NodeID>
- <!-- This is the InternalName for the spell we defined above -->
- <SpellDef>Gnilbert_FireBreath</SpellDef>
- <StartingResearch>1</StartingResearch>
- <!-- Setting StartingKnown to 1 gives the spell to your sovereign when you start a new game (if he has the Fire spellbook). I set this to 1 to make testing easier! -->
- <StartingKnown>1</StartingKnown>
- </SpellbookNode>
- <!-- NEW CODE ABOVE -->
- </Spellbook>
There we go. Now, to test the spell, you'll need to create a new game with a sovereign who has the Fire spellbook. After the game starts up, deselect the sovereign, then reselect him (otherwise there's a bug that won't show the "Cast Spell" option). Now open his spell book and cast the spell on yourself.
In part 2, I'll cover how to make the spell even better by giving the target a Fire Breath attack.