Search public documentation:
Last tested against UDK May, 2012
Spells are a way for players to interact with creeps, heroes, tower and the world. They often can perform a multitude of things and can be set up in many different ways. Spells can be aimings, passives, simples and toggles. These four usually represent the majority of spell types in most games. Spells are synonymous with abilities and skills.
An aiming spell is a spell which requires further input from the player. An aiming spell is often used when the spell required a target or an area defined. This allows game designers to make spells which only affect creeps, heroes, towers or an area within the world.
A passive spell is a spell which is always active when conditions are met. This is often used for creating a radial buff or debuff.
A simple spell is a spell which is activated by the player and it does something. It can be used as a single shot weapon for example.
A toggle spell is a spell which can be activated or deactivated by the player. It can trigger something when the spell is being activated, deactivated or currently active. This could be used to create a temporary buff for other players but a debuff for the hero that owns the spell for example.
UDKMOBASpell is mostly a utility class to handle aspects such as cool down, a generic interface to use the spells and to store data about the spells. Note that we 'activate' a spell, which causes animations to start. After an 'activation time', we then 'cast' the spell, which actually deals damage/spawns a projectile/whatever. There can then be return animations, although once the 'cast' is made, other commands can be queued.
- Player decides to use a spell.
- Player optionally aims the spell.
- The spell activates, effects spawn, animations start.
- An activation time passes. If the spell is channeling, this is 0 seconds.
- The spell casts, damage is deal, particles are spawned, reverse animations.
- A cast time passes. If the spell is channeling, this can be interrupted.
- ReplicatedEvent() - This is called when a variable flagged as RepNotify has been replicated to the client. This is used for catching when clients should initialize the spell, play effects when the spell is activated or casted.
- ClientSetOwner() - This is a remote procedure call from the server to the client which passes the Owner.
- Initialize() - This is called when the spell should be initialized. This function caches the pawn that owns this spell, and allows subclasses to cache other things as well.
- SendPlayerMessage() - This is called when the spell should send the local player a message of some sort. This can range from telling the player that there isn't enough mana to cast or that the spell isn't ready.
- CanCast() - This returns true if the spell can be cast or not.
- GetManaCost() - This returns the current mana cost of the spell.
- GetActivationTime() - This returns the current activation time of the spell.
- GetCooldownTime() - This returns the current cool down time of the spell.
- Activate() - This activates the spell.
- SetTargetsFromAim() - This sets the target based on the input aim location, aim direction and how the spell targets.
- ActivateEffects() - This is called when the spell has been activated.
- Cast() - This casts the spell.
- PerformCast() - This handles the spell's interaction logic. Spells should sub class this to do make their thing.
- CastEffects() - This is called when the spell has been casted.
- CooldownTimer() - This is called when the cool down timer has triggered.
- AdjustDamage() - This adjusts the damage before applying it to the pawn owner. This iterates over all of the spells and items to allow them to adjust damage.
- IconName - Name of the texture to use for the spell icon in the UI. This should match the name of the frame within the icon GFx movie clip.
- MaxLevel - The maximum level that the spell can be upgraded to.
- ManaCost - Mana cost to use the active ability of this spell. The level of the spell is used to index this array.
- HasActive - Whether this spell has an active ability at all. This is usually set false for passive spells.
- AimingType - Whether this spell needs the user to choose where to fire it.
- DecalMaterial - Decal material to use, only on PC. This is used to represents where the player is currently aiming this spell.
- DecalSize - This is the size that the decal should be when it is used as a visual targeting marker.
- ActivatingSoundCue - Sound to play when activating the spell.
- ActivatingParticleTemplate - Particle effect to instance when activating the spell.
- CastingSoundCue - Sound to play when casting the spell.
- CastingParticleTemplate - Particle effect to instance when casting the spell.
- CooldownTime - Cooldown time. Time it takes for this spell to refresh after it has been cast. The level of the spell is used to index this array.
- ActivationTime - How long (in seconds) from triggering the ability before damage/etc is actually dealt. The level of the spell is used to index this array.
- AttackType - What sort of attack type a projectile or damage given uses.
New spells are created by first making a new class which derives from UDKMOBASpell. From here, the usual point of entry that you will be using is PerformCast(). If your spell is quite different, then it may be a good idea to have a look at the Cathode and DemoGuy examples for further modifications. After you've created the new spell class, you then create an archetype for it using Unreal Editor. Once created, you can tweak the variables that are exposed to the Editor. Finally, you assign the spell archetype to the UDKMOBAHero archetype so that the hero starts with that spell.