Allows adding event handlers to an Ability script. Available as the global variable script in each ability script.
You can assign event handlers as follows:
script:on_perform(function(holder: AbilityHolder, ability: Ability) -- Your code hereend)Handlers can only be set when the script is first loaded. Setting handlers inside the function of a handler is not allowed.
For example:
script:on_insert(function() -- error script:on_perform(function() end)end)Events will be processed in the order of the AbilityHolder's ability list. When mutating an event, abilities processed later will see the new value.
Summary
Section titled “Summary”Methods
- on_perform
(handler: (holder: AbilityHolder, ability: Ability) -> ())@handler Ability Called when an ability is performed. […]
- on_insert
(handler: (holder: AbilityHolder, ability: Ability) -> ())@handler Ability Called when an ability is first added or inserted into an AbilityHolder. […]
- on_stack
(handler: (stack: number, holder: AbilityHolder, ability: Ability) -> ())@handler Ability Called when an ability's stack changes. […]
- on_animation_event
(handler: (event: string, holder: AbilityHolder, ability: Ability) -> ())@handler Ability Called when the animation of the AbilityHolder reaches a specific event. […]
- on_animation_finish
(handler: (animation: string, holder: AbilityHolder, ability: Ability) -> ())@handler Ability Called when the animation of the AbilityHolder finishes. […]
- on_deal_damage
(handler: (unit: { Unit }, holder: AbilityHolder, ability: Ability) -> ())@handler Ability Called when the AbilityHolder deals damage to a unit. […]
- on_receive_damage
(handler: (event: ReceiveDamageEvent, holder: AbilityHolder, ability: Ability) -> ())@handler Ability Called when the AbilityHolder receives damage. […]
- on_die
(handler: (event: DieEvent, holder: AbilityHolder, ability: Ability) -> ())@handler Ability Called when the AbilityHolder dies. […]
- on_projectile_unit_collided
(handler: (unit: Unit, holder: AbilityHolder, ability: Ability) -> ())@handler Ability Called when the AbilityHolder is a projectile, and it collides with a Unit. […]
- on_projectile_target_reached
(handler: (target: Unit?, holder: AbilityHolder, ability: Ability) -> ())@handler Ability Called when the AbilityHolder is a projectile, and it reaches its target. […]
- on_enter_area
(handler: (unit: Unit, holder: AbilityHolder, ability: Ability) -> ())@handler Ability Called when a Unit enters the area of effect of the ability. […]
- on_exit_area
(handler: (unit: Unit?, holder: AbilityHolder, ability: Ability) -> ())@handler Ability Called when a Unit exits the area of effect of the ability. […]
Methods
Section titled “Methods”on_perform
Section titled “on_perform”AbilityScript:on_perform(handler: (holder: AbilityHolder, ability: Ability) -> ())
@handler Ability Called when an ability is performed.
An ability is performed when its trigger is Perform and its conditions are met.
holder: The AbilityHolder this ability belongs to.ability: The Ability itself.
Parameters
on_insert
Section titled “on_insert”AbilityScript:on_insert(handler: (holder: AbilityHolder, ability: Ability) -> ())
@handler Ability Called when an ability is first added or inserted into an AbilityHolder.
holder: The AbilityHolder this ability belongs to.ability: The Ability itself.
Parameters
on_stack
Section titled “on_stack”AbilityScript:on_stack(handler: (stack: number, holder: AbilityHolder, ability: Ability) -> ())
@handler Ability Called when an ability's stack changes.
stack: The new stack count.holder: The AbilityHolder this ability belongs to.ability: The Ability itself.
Parameters
on_animation_event
Section titled “on_animation_event”AbilityScript:on_animation_event(handler: (event: string, holder: AbilityHolder, ability: Ability) -> ())
@handler Ability Called when the animation of the AbilityHolder reaches a specific event.
event: The event name.holder: The AbilityHolder this ability belongs to.ability: The Ability itself.
Parameters
on_animation_finish
Section titled “on_animation_finish”AbilityScript:on_animation_finish(handler: (animation: string, holder: AbilityHolder, ability: Ability) -> ())
@handler Ability Called when the animation of the AbilityHolder finishes.
animation: The animation name that finished.holder: The AbilityHolder this ability belongs to.ability: The Ability itself.
Parameters
on_deal_damage
Section titled “on_deal_damage”AbilityScript:on_deal_damage(handler: (unit: { Unit }, holder: AbilityHolder, ability: Ability) -> ())
@handler Ability Called when the AbilityHolder deals damage to a unit.
unit: The Units that received the damage.holder: The AbilityHolder this ability belongs to.ability: The Ability itself.
Parameters
on_receive_damage
Section titled “on_receive_damage”AbilityScript:on_receive_damage(handler: (event: ReceiveDamageEvent, holder: AbilityHolder, ability: Ability) -> ())
@handler Ability Called when the AbilityHolder receives damage.
event: The [ReceiveDamageEvent] that triggered the callback.holder: The AbilityHolder this ability belongs to.ability: The Ability itself.
Parameters
on_die
Section titled “on_die”AbilityScript:on_die(handler: (event: DieEvent, holder: AbilityHolder, ability: Ability) -> ())
@handler Ability Called when the AbilityHolder dies.
event: The [DieEvent] that triggered the callback.holder: The AbilityHolder this ability belongs to.ability: The Ability itself.
Parameters
on_projectile_unit_collided
Section titled “on_projectile_unit_collided”AbilityScript:on_projectile_unit_collided(handler: (unit: Unit, holder: AbilityHolder, ability: Ability) -> ())
@handler Ability Called when the AbilityHolder is a projectile, and it collides with a Unit.
Note that projectiles without a collider will not trigger this callback.
unit: The Unit that the projectile collided with.holder: The AbilityHolder this ability belongs to.ability: The Ability itself.
Parameters
on_projectile_target_reached
Section titled “on_projectile_target_reached”AbilityScript:on_projectile_target_reached(handler: (target: Unit?, holder: AbilityHolder, ability: Ability) -> ())
@handler Ability Called when the AbilityHolder is a projectile, and it reaches its target.
Note that projectiles without a target will not trigger this callback.
target: The Unit that the projectile reached.holder: The AbilityHolder this ability belongs to.ability: The Ability itself.
Parameters
on_enter_area
Section titled “on_enter_area”AbilityScript:on_enter_area(handler: (unit: Unit, holder: AbilityHolder, ability: Ability) -> ())
@handler Ability Called when a Unit enters the area of effect of the ability.
Note that only abilities with an Area trigger will trigger this callback.
unit: The Unit that entered the area.holder: The AbilityHolder this ability belongs to.ability: The Ability itself.
Parameters
on_exit_area
Section titled “on_exit_area”AbilityScript:on_exit_area(handler: (unit: Unit?, holder: AbilityHolder, ability: Ability) -> ())
@handler Ability Called when a Unit exits the area of effect of the ability.
If a unit exited the area due to being despawned, this callback will still be triggered but unit will be nil.
Note that only abilities with an Area trigger will trigger this callback.
unit: The Unit that exited the area.nilif the unit was despawned.holder: The AbilityHolder this ability belongs to.ability: The Ability itself.