UDN
Search public documentation:

MOBAKitSpells
日本語訳
中国翻译
한국어

Interested in the Unreal Engine?
Visit the Unreal Technology site.

Looking for jobs and company info?
Check out the Epic games site.

Questions about support via UDN?
Contact the UDN Staff

UE3 Home > Unreal Development Kit Gems > MOBA Starter Kit > Spells

MOBA Starter Kit - Spells


Last tested against UDK May, 2012

Overview


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.

What's a aiming spell?


MOBAKitAimingSpell.jpg

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.

What's a passive spell?


MOBAKitPassiveSpell.jpg

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.

What's a simple spell?


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.

What's a toggle spell?


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


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.

  1. Player decides to use a spell.
  2. Player optionally aims the spell.
  3. The spell activates, effects spawn, animations start.
  4. An activation time passes. If the spell is channeling, this is 0 seconds.
  5. The spell casts, damage is deal, particles are spawned, reverse animations.
  6. A cast time passes. If the spell is channeling, this can be interrupted.

Functions

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

Variables

  • Spell
    • 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.
  • Aim
    • 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.
  • Active
    • 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.

How do I make a new spell?


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.

MOBAKitSpellCreateArchetype.jpg

After you've created the new spell class, you then create an archetype for it using Unreal Editor.

MOBAKitSpellSetupArchetype.jpg

Once created, you can tweak the variables that are exposed to the Editor.

MOBAKitSpellAssignSpell.jpg

Finally, you assign the spell archetype to the UDKMOBAHero archetype so that the hero starts with that spell.