Skip to content

Ability Lua Tutorial 1: Ability Form

Elfansoer edited this page Aug 1, 2018 · 2 revisions

Hello, DotA World!

Ability Form

I'm pretty sure that you guys are already an expert in designing unique abilities, but how do you explain your abilities to Dota 2 engine?

You can tell the machine about your abilities by using a certain registration form. With this, there'll be more clarity for the machine about the description of your abilities, what they can do and what they cannot do.

Now the form, here you go.

I'll explain them one by one. Just copy it to your editor, and save it as: <heroname>_<abilityname>.txt.
Where to? Anywhere, for now.

Hey, don't just read it. Copy and save it, get your hands dirty.

Now, here's the guide to fill the form. The form above has been filled with an ability by Vera Olivia, named Tutorial Ability. On the back-end, the name turned into vera_tutorial_ability.

General Explanation

You can call the contents of the form as key-value pairs; key name on the left, its value on the right. Enclose both key name and value name with double-quote marks. White-spaces are ignored between key and values.

Ability Techincal Aspect

BaseClass
Don't touch this

ScriptFile
Filepath to the ability's script file. More on technical later.

AbilityTextureName
Filepath to the ability's icon. More on technical later.

FightRecapLevel
Larger the number, higher it will be seen in fight recap. As a reference, all basic abilities in Dota 2 is "1", while (active) ultimates have "2". One exception is Monkey King's Mischief (has "2"), and don't ask me why.

MaxLevel
This is the maximum level allowed for the ability. Value "0" is possible (for empty ability, usually). This key-value is optional; the default max-level is 4.
An ability can have any number of levels, but it is strongly recommended by system that any ability has 0, 1, 3, 4, or 7 levels.

Ability General


AbilityType
Self-explanatory

Possible Values:
DOTA_ABILITY_TYPE_BASIC
DOTA_ABILITY_TYPE_ULTIMATE

AbilityBehavior
This key describes the ability's behavior (duh). Is it unit or point target? Does it has AOE? Can it be cast while stunned? Tag it there.

A pipe (|) designates an "or", which means the ability has both behavior. So,
DOTA_ABILITY_BEHAVIOR_POINT | DOTA_ABILITY_BEHAVIOR_NORMAL_WHEN_STOLEN | DOTA_ABILITY_BEHAVIOR_ROOT_DISABLES
means that the ability is a point-target, use normal cast when stolen, and can't be cast if rooted.

I won't explain them one by one (that's a long list), so just ask later if required.

Possible Values:
DOTA_ABILITY_BEHAVIOR_PASSIVE
Ability is classified as passive, and cannot be pressed.

DOTA_ABILITY_BEHAVIOR_NO_TARGET
Ability fires immediately when pressed.

DOTA_ABILITY_BEHAVIOR_POINT
Ability needs a target point to be cast.

DOTA_ABILITY_BEHAVIOR_UNIT_TARGET
Ability needs a unit target to be cast.

DOTA_ABILITY_BEHAVIOR_RUNE_TARGET
Ability can target runes. (Tiny's Toss)


DOTA_ABILITY_BEHAVIOR_AOE
Ability is considered an AoE ability, respecting AOERadius KV when drawing the AoE overlay.

DOTA_ABILITY_BEHAVIOR_ATTACK
This is like orb effects; use attack animation instead of ability animation. (DR's Frost Arrows)

DOTA_ABILITY_BEHAVIOR_AURA
Ability is considered an aura.

DOTA_ABILITY_BEHAVIOR_AUTOCAST
Ability can be set to auto cast.

DOTA_ABILITY_BEHAVIOR_CHANNELLED
Ability is considered a channeling ability.

DOTA_ABILITY_BEHAVIOR_DIRECTIONAL
Affects visual effect when casting. (Mirana's Sacred Arrow)

DOTA_ABILITY_BEHAVIOR_IMMEDIATE
Ability ignores cast points and is fired as soon as the skill is pressed. (Sven's Warcry)

DOTA_ABILITY_BEHAVIOR_TOGGLE
Ability can be toggled on and off.


DOTA_ABILITY_BEHAVIOR_DONT_ALERT_TARGET
Ability does not give vision of the caster to its target (SB's Charge)

DOTA_ABILITY_BEHAVIOR_DONT_CANCEL_CHANNEL
Ability does not cancel the target's current channel. (Oracle's Fortune End)

DOTA_ABILITY_BEHAVIOR_DONT_CANCEL_MOVEMENT
Ability doesn't stop the caster to be used. (Ursa's Enrage)

DOTA_ABILITY_BEHAVIOR_DONT_RESUME_ATTACK
After using ability, caster won't proceed to attack the nearby enemy (Nyx's Vendetta)

DOTA_ABILITY_BEHAVIOR_DONT_RESUME_MOVEMENT
After casting that ability, the caster won't resume its last order. (TA's Meld)

DOTA_ABILITY_BEHAVIOR_IGNORE_PSEUDO_QUEUE
Abiity can be cast while stunned (Abaddon's Borrowed Time)

DOTA_ABILITY_BEHAVIOR_IGNORE_CHANNEL
Ability can be cast without interrupting caster's channel (Juggernaut's Bladefury)

DOTA_ABILITY_BEHAVIOR_ROOT_DISABLES
Ability cannot be cast while rooted.


DOTA_ABILITY_BEHAVIOR_HIDDEN
Ability doesn't appear on the HUD. (Invoker's hidden spells)

DOTA_ABILITY_BEHAVIOR_IGNORE_BACKSWING
Ability ignores backswing animation. (Pudge's Rot)

DOTA_ABILITY_BEHAVIOR_NORMAL_WHEN_STOLEN
Rubick must use initial cast points. (Sniper's Assassinate)

DOTA_ABILITY_BEHAVIOR_NOT_LEARNABLE
Ability cannot be skilled. (Monkey King's Mischief)

DOTA_ABILITY_BEHAVIOR_UNRESTRICTED
Ability can be cast at any condition. (Techies' Focused Detonate)

AbilityUnitTargetTeam
Determines which team should be the target of this ability. No need further explanations for the values, I think.

Possible Values:
DOTA_UNIT_TARGET_TEAM_FRIENDLY
Targets all those that are in the same team as the team that was declared the source.

DOTA_UNIT_TARGET_TEAM_ENEMY
Targets all those that are not in the same team as the team that was declared the source.

DOTA_UNIT_TARGET_TEAM_BOTH
Targets all entities from every team.

DOTA_UNIT_TARGET_TEAM_CUSTOM
Targets all those who have a certain custom conditions (Lifestealer's Infest)

AbilityUnitTargetType
Determines the type of target is allowed for this ability. Most abilities uses HERO, BASIC, and BUILDINGS (or combination of them), but be creative.

Possible Values:
DOTA_UNIT_TARGET_HERO
Targets heroes.

DOTA_UNIT_TARGET_BASIC
Targets units. (not necessarily creeps)

DOTA_UNIT_TARGET_CREEP
Targets creeps.


DOTA_UNIT_TARGET_BUILDING
Targets buildings.

DOTA_UNIT_TARGET_COURIER
Targets couriers.

DOTA_UNIT_TARGET_TREE
Targets trees.

DOTA_UNIT_TARGET_ALL
Targets everything (including buildings, couriers, Shrines etc)

DOTA_UNIT_TARGET_CUSTOM
Targets those under specific conditions (Enigma's Demonic Conversion)

AbilityUnitTargetFlags
Determines any specific conditions of the target is allowed for this ability. This and above 2 keys determines an error/success when selecting target unit during casting.

Possible Values:
DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES
Targets magic immune enemies as well.

DOTA_UNIT_TARGET_FLAG_NOT_MAGIC_IMMUNE_ALLIES
Targets non-magic immune allies as well.

DOTA_UNIT_TARGET_FLAG_MELEE_ONLY
Targets only melee units and heroes.

DOTA_UNIT_TARGET_FLAG_RANGED_ONLY
Targets only ranged units and heroes.

DOTA_UNIT_TARGET_FLAG_INVULNERABLE
Targets invulnerable units/heroes as well.


DOTA_UNIT_TARGET_FLAG_MANA_ONLY
Targets only those that has a mana bar.

DOTA_UNIT_TARGET_FLAG_NOT_ANCIENTS
Targets only those that are not considered ancients.

DOTA_UNIT_TARGET_FLAG_NOT_CREEP_HERO
Targets only those that are not considered creep heroes.

DOTA_UNIT_TARGET_FLAG_NOT_DOMINATED
Targets only those that are not being dominated.

DOTA_UNIT_TARGET_FLAG_NOT_ILLUSIONS
Targets only those that are not illusions.

DOTA_UNIT_TARGET_FLAG_NOT_SUMMONED
Targets only those that are not summoned creatures.

DOTA_UNIT_TARGET_FLAG_PLAYER_CONTROLLED
Targets player controlled units (ignores the rest of basic units).


DOTA_UNIT_TARGET_FLAG_NOT_ATTACK_IMMUNE
Targets only those that are not immune to attacks.

DOTA_UNIT_TARGET_FLAG_DEAD
Targets dead units and heroes as well.

DOTA_UNIT_TARGET_FLAG_FOW_VISIBLE
Targets only those that are visible through the fog of war.

DOTA_UNIT_TARGET_FLAG_NO_INVIS
Targets only those that are not invisible.

DOTA_UNIT_TARGET_FLAG_CHECK_DISABLE_HELP
Targets only allied player who isn't disable help from its caster's player

DOTA_UNIT_TARGET_FLAG_OUT_OF_WORLD
Targets units/heroes that are hidden as well.

DOTA_UNIT_TARGET_FLAG_NOT_NIGHTMARED
Targets only those that are not nightmared.

These three values will be shown in the HUD

AbilityUnitDamageType
Self-explanatory.

Possible Values:
DAMAGE_TYPE_PHYSICAL
DAMAGE_TYPE_MAGICAL
DAMAGE_TYPE_PURE

SpellDispellableType
Self-explanatory.

Possible Values:
SPELL_DISPELLABLE_YES
SPELL_DISPELLABLE_YES_STRONG
SPELL_DISPELLABLE_NO

SpellImmunityType
Determines whether the spell pierces spell immunity.

Possible Values:
SPELL_IMMUNITY_ALLIES_YES
SPELL_IMMUNITY_ALLIES_NO
SPELL_IMMUNITY_ENEMIES_YES
SPELL_IMMUNITY_ENEMIES_NO

So.... what if my ability can sometimes be AOE and sometimes not based on buffs? What if my ability can target only allies when night, and only enemies at day? What if--

Hold up! You need to learn to walk before you sprint, okay. If you already know how to walk, please explore yourself. I'm helping those who still can't. Don't worry, we'll eventually go for those things, as they are completely possible.

Ability Casting, Resource and Damage

I think these are pretty explanatory (you can read about Cast Buffer on dota2 gamepedia).

One note, however, If you think a certain key does not fit, you can always omit them. Like, when it is a passive ability, there's no need for cast point, and you can just delete both the key and value. Or when your ability does not require mana, then just erase it. Erase both key and value(s), okay?

Here's the tips:

  • "500" is integer value, while "14.0" is float.
  • If a key has different values for each level, write values like this: "10 20 30 40".
  • Be consistent! If your ability has 3 levels, then you have to write either 1 or 3 values for all keys.
  • Be consistent! Don't write like "20 30 40.0 50". Please.

Ability Special

There's a thing that this is called key-value pairs. This form holds all important values for the ability, like damage multiplier, blink range, projectile speed, or perhaps numbers that are important to your ability, but goes unnoticed by the player.

When you tweak and balance it, you generally edit these numbers, as opposed to go to the script file. Make sure you store important values here, but only when necessary, as long list tends to get ugly.

To fill it, go with the pattern.

  • The number above is a counter. Theoretically you may have 99 key-values, but please don't.
  • The var_type key has either FIELD_INTEGER or FIELD_FLOAT as its value. This determines the type of value the main key would be.
  • You can name the main key anything you want. Generally you want a descriptive but short names.
  • You must write number without a dot if it is an integer as described above.
  • You can write values for each level in similar fashion as above key-value pairs, but always with the same type!

Conclusion

You can find a lot of examples in this repository, go see them.

Okay, that's all for now. I hope this wall of text helps you understand how ability works on the back-end. Make sure you converted your beautifully designed abilities into the ability form before we go on, okay?

Next on, I'll explain how to integrate these into Dota 2 engine, and play it. Stay tuned!