Battle Ability Mechanism --- A Deep Theorycrafting

This is a deep analysis and an extension to the theorycrafting video: https://www.youtube.com/watch?v=Ss1Qo-LI30k

If you are a hardcore player, this will help you understand casting mechanisms of abilities and perform better in top tournament where the micro-controls are important.

## Types of Abilities

Instead of the 3 ability types explained in the video, Aura type ability will be further separated to the "ordinary aura" and "trigger" type ability.

### Actives

Spells that are controlled by players. They can be further divided into Location Actives (that need player to select a location) and Simple Actives (that don't need a location).

### Passives

Spells that are cast by units automatically, if certain conditions are met. They can be roughly categorized to 3 types.

* Melee Passives: Spells that can be used only in melee (engaged) mode. Such as the basic melee attacks from heroes, Sethos' Envenom and Sand Storm, Leif's Sunder Ground, etc.

* Ranged Passives: Spells that can be used only in ranged (nonengaged) mode. Such as the basic ranged attacks from ranged heroes, Efrigid's all passive spells, Obsidian all passive spells, etc.
* General Passives: Spells that can be used in both melee and ranged mode. Such as Lancelot's Healing Cry and Fist of Judgement, Koizuul's Overflow. Their two versions (melee and ranged) may share one cooldown, or have separate cooldowns (the only example for now is Koizuul's Overflow).

A common misunderstanding is that the basic melee and ranged attack are different from other passives. In fact they are intrinsically the same --- they all have cooldowns and are affected by haste and slow. They are defined as basic attack only because they occur much more frequently than other abilities.

### Auras

Things that affect the surroundings or mapwise consistently. This kind of abilities are controlled by (constant) delays rather than cooldowns, so not affected by hastes and slows. Examples are Narlax's Void Orbs, Caldera's Burning Aura, Lancelot's rank 6 Heaven’s Fist.

### Triggers (Event)

The abilities that only happen when certain conditions are met. For example, Hogan gets hasted only when engaged; Sethos has chance to reflect damage when damaged by an enemy; Some enemies get raged when their HP is dropped to some point.

## Passive Trigger Mechanism

Players are able to control the actives when needed; Auras and triggers take effect automatically no matter how the hero is controlled; The only question is, how are passives triggered? Below is the general process of a unit's behavior:

### Spell Filtering (Trigger)

As explained in the video, the two following process happen during spell filtering:

#### Condition Check

1. A passive spell can be cast if it is cooled down.
2. A passive melee spell can only be cast when in melee combat.
	* The condition to switch to melee mode: A unit will not engage in a melee combat if it has a ranged spell available to cast. This means the unit will cast all its ranged spells and only engage in melee if all of them are in cooldown. It also happens if a cloaked unit comes closer to a range hero. Since the range hero cannot target the cloaked enemy by ranged attack, so he/she will only engaged in melee even their ranged spells are cooled down.
3. A passive ranged spell can only be cast when not in melee combat, and there is at least one unit in range which can trigger the spell.
	* The spell trigger can be the same as or different from the targets actually affected. Eg. Efrigid's Absolute Zero can be triggered by ground enemies in very close range, but it can affect the enemies in much lager range; Obsidian's Shake and Break is the same.
	* Most of the ranged spells cannot be casted when moving, the only exceptions for now are Raida's Tengu Shockwave, Cyra's Lodestar, Bolton's Static Shockwave.

#### Passive Order

There is an internal “priority of spells” (which can be found by tests). A spell will be cast if

1. It passes the condition check.
2. All spells with higher priority are not available.

The detailed example of Efrigid is show below.

### Animations and Effects

After the spell is selected, its cooldown will be set immediately and the unit plays the cast animation. The animation is separated to foreswing animation and backswing animation, and the actual effects happen right after foreswing animation. Using Fee's basic ranged attack as an example:

1. Lifting up her bow is the foreswing animation.
2. The arrow is shot out and damages the target, as the actual effect of the spell.
3. She puts down her bow, this is the backswing animation, and it happens in the meanwhile of her flying arrow.

Note:

* If the spell is interrupted during foreswing animation, actual effects will not occur.
* If the spell is interrupted during backswing animation, actual effects will still occur.
	+ You actually cut the backswing animation and let the hero have more time to use other spells. This can be useful to heroes with long animations such as Koi. And it will be explained more in Fee's case study and Koi's case study below.
* What can be hasted: the animation can be hasted (left part in the figure), and the cooldown will be set faster under haste; But the effects are most likely unaffected by haste, since they are mostly timed effects.
	+ So under haste heroes will be able to finish the animation faster and have the spell cooled down faster, at the same rate. So usually the behavior (sequence of spells) of the heroes will not change, and also the spell effects will not change. Eg. Efrigid's Blizzard and Ice Trap will not disappear faster; The speed of the projectiles will not be faster.

Based on the above, spell cast of mostly depends on two things: cooldown and animation speed. Consider a hero with only one passive ability, if the cooldown is longer than animation time, the hero will finish the attack animation and until the ability cools down he will stop and do nothing. If the cooldown is shorter than animation time, he will perform a new attack right after the animation is finished. So the actual attack rate is determined by cooldown and animation time --- whichever is longer. But in most of the cases the animation time is shorter, making hero be able to use other spells --- and this mainly meets the design purpose.

~~Although the new Beastmaster Hogan is a counter-example. His melee attack has very longer animations than cooldown, making the cooldown reduction from Rank 5 not useful.~~
(Fixed)

## Case Study

### Efrigid - General Case

This is mostly explained in the video. The key points are:

1. The order of Efrigid spell is Ranged → Absolute Zero → Ice Trap → Blizzard.
2. After Efrigid's ranged spell, she finishes the animation before the cooldown is completed, thus she will be able to use other spells in that period.
3. The final cast spells are Ranged → Absolute Zero → Ranged → Ice Trap → Ranged → Blizzard.

### Cold Koizzul - Corner Case

Note: this example is no longer true in latest version of game. Cold effect is changed to affect both cast speed and animation speed so affected heroes can have their original spell order.

Some players found Koi not helpful in some World 5 levels, this is mainly due to the cold debuff from blue slimes. Cold is actually a very special debuff in game. It reduces the animation speed without affecting the cast speed (speed of cooldowns):

```
Cold: A debuff which reduces the move speed by 50% and the animation speed by 25% (no longer true in latest version)

```
Cooldown of Koi's ranged attack is 1.7s. Assume the animation time of ranged attack is 1.4s (this may not be accurate, just for explanation). Then under cold debuff the animation will take 1.4/0.75=1.87s. This means Koi will do ranged attack, and at the time the animation finishes his cooldown is ready again. Thus he will repeatedly do ranged attack which hits one enemy only and will not be able to use water fall which has lower priority or engage in melee.

How to avoid that:

* Option 1: Quickly move Koi to interrupt his basic attack so he will have basic attack in cooldown and thus use waterfall. This works well when ranged waterfall is ready, while melee water fall is more difficult to control.
* Option 2: Kill those blue slimes before they reach Koi, or move Koi away from them when they explode.

### Fee - Explanation to Animations

Fee's Rapid Fire ability can be interrupted by slightly moving her. After that It can clearly be seen that her rest of Rapid Fire arrows are shot out (white arrows) and at the same time she uses other spells (yellow arrow from Kill Shot), as shown in the below GIF:

Below is an explanation of Fee's Rapic Fire ability:

```
Rapid Fire: 20s cooldown, Fee targets an enemy, in 2s shoots 10 arrows to random enemies within range 2 of the target

```
So this spell cast can be split into:

* Foreswing animation as lifting up the bow.
* Backswing animation as putting up and down the bow several times.
	+ Note that the whole animation after lifting up the bow is backswing animation because even it is interrupted the rest of arrows still come out.
* Actual effects as 10 arrows being shot out.
	+ This is simply a timed effect. With the animation of Fee putting up and down the bow it makes you feel Fee is shooting, but actually the two events are not linked with each other.
	+ Another proof is, under haste Fee's animation will finish faster than arrows effects, so you can still see the white arrows together with other arrows.

That's an example that we are able to cancel the long backswing animation of Rapid Fire and increase Fee's DPS.