I wanted to review a very old thread which was posted almost one year ago but still isn’t completely well documented anywhere:

“Target” is one bitch of a key.

And yet, it’s arguably the most important KV to understand, as its found in almost every datadriven Action.

Having a wrong "Target" block is the number one reason of having to relaunch the game, testing with many combinations until you finally get the right context.

Quoting the wiki on this:

Note: These names mean different things in different events. It may require some experimentation to discover exactly what in each case.

This thread intends to compile every Target-related decision.

To test everything and get results, I used some simple scrips to test which parameters are seen in each event context. The KV and Lua Scripts are found in the second post, which also contains all the debug data.

After running many tests with different ability behaviors, here’s what I got:

ABILITY EVENT CONTEXTS

Behavior: DOTA_ABILITY_BEHAVIOR_NO_TARGET

Event Target
OnSpellStart CASTER, UNIT, ATTACKER
OnAbilityPhaseStart CASTER, UNIT, ATTACKER

DOTA_ABILITY_BEHAVIOR_UNIT_TARGET

This behavior adds TARGET as a possible value for the Target key:

Event Target
OnSpellStart CASTER, TARGET, UNIT, ATTACKER
OnAbilityPhaseStart CASTER, TARGET, UNIT, ATTACKER

AbilityChannelTime > 0

DOTA_ABILITY_BEHAVIOR_CHANNELLED only purpose is to change the ability Tooltip to “Channeled”. In fact, the BEHAVIOR_CHANNELED isn’t even needed, "AbilityChannelTime" is all that matters for the actual ability behavior.

Event Target
OnChannelFinish CASTER, TARGET, UNIT, ATTACKER
OnChannelInterrupted CASTER, TARGET, UNIT, ATTACKER
OnChannelSucceeded CASTER, TARGET, UNIT, ATTACKER

With Linear and Tracking Projectile Actions

Event Target
OnProjectileFinish CASTER, TARGET, PROJECTILE
OnProjectileHitUnit CASTER, TARGET, PROJECTILE

DOTA_ABILITY_BEHAVIOR_TOGGLE

Event Target
OnToggleOff CASTER
OnToggleOn CASTER

Item pickup and drop

Event Target
OnEquip CASTER
OnUnequip CASTER

Any Behavior

Event Target
OnOwnerDied CASTER
OnOwnerSpawned CASTER
OnUpgrade CASTER

MODIFER EVENT CONTEXTS

Caster-Target

Target always refers to the owner of the modifier.

Event Target
OnCreated CASTER, TARGET
OnDestroy CASTER, TARGET
OnIntervalThink CASTER, TARGET
OnProjectileDodge CASTER, TARGET

Damage

In these events we can send an extra parameter, referenced as %attack_damage

Note that this is not a value taken from an AbilitySpecial, instead it is generated by the system to be used in very particular events.

Event Target %attack_damage value
OnTakeDamage CASTER, UNIT, ATTACKER post reduction
OnDealDamage CASTER, UNIT, ATTACKER post reduction

Attacks

In some of the attack events we can also use the %attack_damage

Event Target %attack_damage value
OnAttack CASTER, TARGET, ATTACKER 0
OnAttackStart CASTER, TARGET, ATTACKER 0
OnAttackAllied CASTER, TARGET, ATTACKER 0
OnAttacked CASTER, TARGET, ATTACKER post reduction
OnAttackLanded CASTER, TARGET, ATTACKER before reduction, the real attack value
OnAttackFailed CASTER, TARGET, ATTACKER before reduction, the real attack value

Killing

Event Target
OnDeath CASTER, UNIT, ATTACKER
OnKill CASTER, UNIT, ATTACKER
OnHeroKilled CASTER, TARGET, ATTACKER

Caster-Unit

Event Target Extra
OnAbilityEndChannel CASTER, UNIT TARGET if the ability isn’t NO_TARGET
OnAbilityExecuted CASTER, UNIT TARGET if the ability isn’t NO_TARGET
OnOrder CASTER, UNIT TARGET if the Order is an ability with target
OnRespawn CASTER, UNIT needs “Attributes” “PERMANENT” on its modifier
OnManaGained CASTER, UNIT  
OnSpentMana CASTER, UNIT  
OnStateChanged CASTER, UNIT  
OnTeleporting CASTER, UNIT  
OnTeleported CASTER, UNIT  
OnUnitMoved CASTER, UNIT  
OnHealReceived CASTER, UNIT  
OnHealthGained CASTER, UNIT  

Never Triggered

OnAbilityStart - Broken?


Please report if you find any inconsistencies.


On the next post you’ll find the random rambling analyzed to get the results.

Then we’ll move to Multiple Targets, acting over different entities, Flags, etc.