Created on by Noya

All about the Target

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

EventTarget
OnSpellStartCASTER, UNIT, ATTACKER
OnAbilityPhaseStartCASTER, UNIT, ATTACKER

DOTA_ABILITY_BEHAVIOR_UNIT_TARGET

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

EventTarget
OnSpellStartCASTER, TARGET, UNIT, ATTACKER
OnAbilityPhaseStartCASTER, 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.

EventTarget
OnChannelFinishCASTER, TARGET, UNIT, ATTACKER
OnChannelInterruptedCASTER, TARGET, UNIT, ATTACKER
OnChannelSucceededCASTER, TARGET, UNIT, ATTACKER

With Linear and Tracking Projectile Actions

EventTarget
OnProjectileFinishCASTER, TARGET, PROJECTILE
OnProjectileHitUnitCASTER, TARGET, PROJECTILE

DOTA_ABILITY_BEHAVIOR_TOGGLE

EventTarget
OnToggleOffCASTER
OnToggleOnCASTER

Item pickup and drop

EventTarget
OnEquipCASTER
OnUnequipCASTER

Any Behavior

EventTarget
OnOwnerDiedCASTER
OnOwnerSpawnedCASTER
OnUpgradeCASTER

MODIFER EVENT CONTEXTS

Caster-Target

Target always refers to the owner of the modifier.

EventTarget
OnCreatedCASTER, TARGET
OnDestroyCASTER, TARGET
OnIntervalThinkCASTER, TARGET
OnProjectileDodgeCASTER, 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.

EventTarget%attack_damage value
OnTakeDamageCASTER, UNIT, ATTACKERpost reduction
OnDealDamageCASTER, UNIT, ATTACKERpost reduction

Attacks

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

EventTarget%attack_damage value
OnAttackCASTER, TARGET, ATTACKER0
OnAttackStartCASTER, TARGET, ATTACKER0
OnAttackAlliedCASTER, TARGET, ATTACKER0
OnAttackedCASTER, TARGET, ATTACKERpost reduction
OnAttackLandedCASTER, TARGET, ATTACKERbefore reduction, the real attack value
OnAttackFailedCASTER, TARGET, ATTACKERbefore reduction, the real attack value

Killing

EventTarget
OnDeathCASTER, UNIT, ATTACKER
OnKillCASTER, UNIT, ATTACKER
OnHeroKilledCASTER, TARGET, ATTACKER

Caster-Unit

EventTargetExtra
OnAbilityEndChannelCASTER, UNITTARGET if the ability isn't NO_TARGET
OnAbilityExecutedCASTER, UNITTARGET if the ability isn't NO_TARGET
OnOrderCASTER, UNITTARGET if the Order is an ability with target
OnRespawnCASTER, UNITneeds "Attributes" "PERMANENT" on its modifier
OnManaGainedCASTER, UNIT
OnSpentManaCASTER, UNIT
OnStateChangedCASTER, UNIT
OnTeleportingCASTER, UNIT
OnTeleportedCASTER, UNIT
OnUnitMovedCASTER, UNIT
OnHealReceivedCASTER, UNIT
OnHealthGainedCASTER, 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.