I have seen several posts on this subject, but I have not seen a good tutorial on this topic. This reason for this tutorial is simple, give a good example of how to make an item with a special ability, and explain some of the general pitfalls associated.
For this part of the tutorial, we are going to make a club which adds an additional attack we will call Club Smash, which does 125%-175% normal dmg and causes the target to lose their counterattacks for a round.
To start let's take the code for the Gnarled Club and rename it to "A Better Club". Remember to change the Internal Name unless you want to override the current gnarled club.
Code: xml
- <?xml version="1.0" encoding="ISO-8859-1"?>
- <GameItemTypes>
- <GameItemType InternalName="A_Better_Club">
- <!-- Equipment Display Name/Description -->
- <DisplayName>A Better Club</DisplayName>
- <Description>Gnarled root of pine, ripped from the ground and fashioned into a club.</Description>
- <!-- Data -->
- <Type>Weapon</Type>
- <WeaponType>Blunt</WeaponType>
- <CanBeEquipped>1</CanBeEquipped>
- <CustomizationPointCost>5</CustomizationPointCost>
- <EquipSFX>Equip_WoodenItem_01</EquipSFX>
- <EquipSFX>Equip_WoodenItem_02</EquipSFX>
- <EquipSFX>Equip_WoodenItem_03</EquipSFX>
- <EquipSFX>Equip_WoodenItem_04</EquipSFX>
- <AttackSFX>Hit_Club1</AttackSFX>
- <AttackSFX>Hit_Club2</AttackSFX>
- <ShopValue>
- </ShopValue>
- <!-- Equipment Graphics -->
- <IconFile>Earth_Club_Icon.png</IconFile>
- <TintR>0</TintR>
- <TintG>0</TintG>
- <TintB>0</TintB>
- <!-- Particles -->
- <OnHitParticleName>Club_Attack</OnHitParticleName>
- <GameItemTypeModel>
- <ModelFile>gfx/hkb/Weapons/K_Club_01.hkb</ModelFile>
- <Texture_All>K_Weapons_Basic_Texture_01.png</Texture_All>
- <Attachment>hand_right_Lcf</Attachment>
- </GameItemTypeModel>
- <!-- Equipment Production Requirements -->
- <ProductionRequirement>
- <Type>Resource</Type>
- <Attribute>Gold</Attribute>
- <Value>2</Value>
- </ProductionRequirement>
- <ProductionRequirement>
- <Type>Resource</Type>
- <Attribute>Materials</Attribute>
- <Value>3</Value>
- </ProductionRequirement>
- <!-- Equipment Prerequisites -->
- <!-- Equipment Modifiers -->
- <GameModifier>
- <ModType>Unit</ModType>
- <Attribute>AdjustUnitStat</Attribute>
- <StrVal>UnitStat_Attack</StrVal>
- <Value>2.0</Value>
- </GameModifier>
- <GameModifier>
- <ModType>Unit</ModType>
- <Attribute>AdjustUnitStat</Attribute>
- <StrVal>UnitStat_BluntDamage</StrVal>
- </GameModifier>
- <GameModifier>
- <ModType>Unit</ModType>
- <Attribute>UnlockCombatAbility</Attribute>
- <StrVal>Club_Smash</StrVal>
- </GameModifier>
- </GameItemType>
- </GameItemTypes>
We are not going to worry about most of this code, as we are probably ok with the look of this particular weapon. Remember the trick to easily making new weapons is always to select one that looks close enough to what you want. Our focus here will be on the last GameModifier.
Code: xml
- <GameModifier>
- <ModType>Unit</ModType>
- <Attribute>UnlockCombatAbility</Attribute>
- <StrVal>Club_Smash</StrVal>
- </GameModifier>
This modifier gives the equipped unit access to a spell during tactical combat. If you try and put a strategic spell here, it will not show up outside of tactical combat. Now, you can add as many of these abilities as you wish to an item, though each requires its own gamemodifier.
*NOTE: Placement of these modifiers is very important. If you intend to put more than one ability on an item place the game modifier tags above the modifier for UnitStat_Attack. I have found that if you place them after a modifier without a value, it will only add the first ability.
So we have given told the game to unlock the Club Smash ability for our better club, now it is time to look at the ability itself.
Code: xml
- <?xml version="1.0" encoding="iso-8859-1"?>
- <Spells>
- <SpellDef InternalName="Club_Smash">
- <DisplayName>Club Smash</DisplayName>
- <Description>Target enemy receives 125%-175% damage and can not counter for rest of it's turn.</Description>
- <Image>WaterCrystal_Medallion.png</Image>
- <IconFG>Crushing_Blow.png</IconFG>
- <IconColor>32,45,243</IconColor>
- <Range>1</Range>
- <SoundFX>Hit_Hammer1</SoundFX>
- <ManaCost>0</ManaCost>
- <Cooldown>-1</Cooldown>
- <SpellLevel>1</SpellLevel>
- <SpellType>Tactical</SpellType>
- <SpellClass>Offensive</SpellClass>
- <SpellTargetType>EnemyUnit</SpellTargetType>
- <IsSpecialAbility>1</IsSpecialAbility>
- <GameModifier>
- <ModType>Unit</ModType>
- <Attribute>DefendableDamage</Attribute>
- <Calculate InternalName="AttackerAttack" ValueOwner="CastingUnit">
- <Expression><![CDATA[[UnitStat_Attack]]]></Expression>
- </Calculate>
- <Calculate InternalName="MinValue">
- <Expression><![CDATA[[AttackerAttack] * -1.25]]></Expression>
- </Calculate>
- <Calculate InternalName="MaxValue">
- <Expression><![CDATA[[AttackerAttack] * -1.75]]></Expression>
- </Calculate>
- </GameModifier>
- <GameModifier>
- <ModType>Unit</ModType>
- <Attribute>DoesNotCounterAttack</Attribute>
- <Duration>1</Duration>
- </GameModifier>
- </SpellDef>
- </Spells>
This is this club smash spell. This is a melee spell, with no spell effect, so it will look like just a normal attack. If you wish to add a spell effect, you can simply take the code for spell you like and append it like any other spell.
When looking at the code for the club smash spell, we will note the normal additions of descriptions,icons, colors, and sounds. For this spell, we have choosen to use the crushing blow icons and the hammer hit sound fx for flavor.
Our first point is the range of the spell, which we have set to 1, indicating it as a melee type spell, and spell radius, which is unshown. You can use any unsigned integer for the range if you wish, though to make it have unlimited range, use -1. If you use a 1 range and a 1 radius, your effect will take place in the three squares in front of the unit.
Next, we will talk about ManaCost as it is very important for our purposes. If you specify a non-zero mana cost, only units which have some mana will be capable of using your ability. While it will show up as available, it will always be marked as unusable by any unit which has no mana.
You have several options as to how to handle this particular issue.
The first which I do not recommend is to add a game modifier to your item which give essence to the unit. This could work, but unless you specify the item as not usable by champions and sovereigns, any champion who gets the item will immediately get essence and be capable of adding level up points to it.
The Second, which is shown here, is to make the ability cost 0 mana. Now a 0 mana spell can be cast as often as a normal attack. Since this spell is fairly powerful, we want to limit how often it can be used. To this end, we can either increase the movement cost associated with using the ability using a form of the tag, <MoveCost>10</MoveCost>, right under mana cost or we can add some kind of cool down to the spell. A Move cost of 10 is the same as using 1.0 combat speed for a normal unit.
*NOTE: Adding a tactical cooldown is currently broken as of v1.08 and will cause a CTD if you use the tag <cooldown> with an unsigned integer. However, if you set cooldown to -1, as we have done above, the ability becomes one time use.
After you have modified the frequency of the spell, you will want to add the tag <IsSpecialAbility>1</IsSpecialAbility>.
Once you have finished all of this, you can add in any game modifiers you would like. More than likely you will probably just take whatever spell you are trying to emulate and toss that code into this section. For Club Smash, we have set it to do a defendable hit ( a normal style hit) and then remove the targets counter attack for a turn. There are any number of things your items can be made to do, as it is as simple as making a spell to do them.
*NOTE: From my tests, defendable damage requires that you use a negative value for the damage. If you look at the calculations, you will see we have set them to be -1.25 and -1.50 which are 125% and 150% respectively.
Now that we have our spell completed and our item completed. Simply take your files containing these two things, throw them into your my games\elemental\Items Folder and you should see the new item in the design screen to make a new unit with them. If you did everything right, your new club man should have the club smash ability shown, and once used, a notice of the spell should be shown above the target to indicate the application of the counterattack debuff.
*Advanced: In the course of making my own mod, I wanted to make some abilities which did percentage buffs and debuffs. I found when calculating a value with these amounts that the results would be moderately unreliable. The problem it seemed was that the value would be calculated based on the final stat, but then added to the base with all other bonuses then taking effect. Instead of using a calculation for value, use the multiplier tag, as it will ensure that your changes take place after the other bonuses are applied.
<?xml version="1.0" encoding="ISO-8859-1"?>
<GameItemTypes>
<GameItemType InternalName="GnarledClub">
<!-- Equipment Display Name/Description -->
<DisplayName>Gnarled Club</DisplayName>
<Description>Gnarled root of pine, ripped from the ground and fashioned into a club.</Description>
<!-- Data -->
<Type>Weapon</Type>
<WeaponType>Blunt</WeaponType>
<CanBeEquipped>1</CanBeEquipped>
<CustomizationPointCost>5</CustomizationPointCost>
<EquipSFX>Equip_WoodenItem_01</EquipSFX>
<EquipSFX>Equip_WoodenItem_02</EquipSFX>
<EquipSFX>Equip_WoodenItem_03</EquipSFX>
<EquipSFX>Equip_WoodenItem_04</EquipSFX>
<AttackSFX>Hit_Club1</AttackSFX>
<AttackSFX>Hit_Club2</AttackSFX>
<ShopValue>
</ShopValue>
<!-- Equipment Graphics -->
<IconFile>Earth_Club_Icon.png</IconFile>
<TintR>0</TintR>
<TintG>0</TintG>
<TintB>0</TintB>
<!-- Particles -->
<OnHitParticleName>Club_Attack</OnHitParticleName>
<GameItemTypeModel>
<ModelFile>gfx/hkb/Weapons/K_Club_01.hkb</ModelFile>
<Texture_All>K_Weapons_Basic_Texture_01.png</Texture_All>
<Attachment>hand_right_Lcf</Attachment>
</GameItemTypeModel>
<!-- Equipment Production Requirements -->
<ProductionRequirement>
<Type>Resource</Type>
<Attribute>Gold</Attribute>
<Value>2</Value>
</ProductionRequirement>
<ProductionRequirement>
<Type>Resource</Type>
<Attribute>Materials</Attribute>
<Value>3</Value>
</ProductionRequirement>
<!-- Equipment Prerequisites -->
<!-- Equipment Modifiers -->
<GameModifier>
<ModType>Unit</ModType>
<Attribute>AdjustUnitStat</Attribute>
<StrVal>UnitStat_Attack</StrVal>
<Value>2.0</Value>
</GameModifier>
<GameModifier>
<ModType>Unit</ModType>
<Attribute>AdjustUnitStat</Attribute>
<StrVal>UnitStat_BluntDamage</StrVal>
</GameModifier>
<GameModifier>
<ModType>Unit</ModType>
<Attribute>UnlockCombatAbility</Attribute>
<StrVal>Club_Smash</StrVal>
</GameModifier>
</GameItemType>
</GameItemTypes>