Events
Event manager
To use events in your plugin, you need to add one of them.
General template to add event
General template to remove event
Best option is to add events when on_sdk_load function is called.
You don't have to remove all callbacks while unloading plugin, because we handle it in core but we recommend you to do that.
Here is a example for OnUpdate event
void on_update( )
{
}
PLUGIN_API bool on_sdk_load( plugin_sdk_core* plugin_sdk_good )
{
DECLARE_GLOBALS( plugin_sdk_good );
event_handler< events::on_update >::add_callback( on_update );
return true;
}
PLUGIN_API void on_sdk_unload( )
{
event_handler< events::on_update >::remove_handler( on_update );
}
Event list
OnUpdate
events::on_update
Function declaration
Trigger
- Everytime when the game does an update
OnPreUpdate
events::on_preupdate
Trigger
- Everytime when the game does an update but triggers before on_update
OnDraw
Warning
This callback is used ONLY for drawings. Do not call the game functions like IssueOrder/CastSpell inside OnDraw.
events::on_draw
Function declaration
Trigger- Everytime when the game draws a frame
OnNetworkPacket
events::on_network_packet
Function declaration
void on_network_packet(game_object_script sender, std::uint32_t network_id, pkttype_e type, void* args)
{
}
Sender can be null only when it's not created by game yet, it means that object was never seen before
Network id - sender network_id
Currently we support only two types of packet
- PKT_S2C_PlayAnimation_s
-
PKT_S2C_ForceCreateMissile_s Depends on type, args can be
-
PKT_S2C_PlayAnimation_s -
PKT_S2C_PlayAnimationArgs
- PKT_S2C_ForceCreateMissile_s -
nullptr
Trigger
- When the game receives packet
OnIssueOrder
events::on_issue_order
Function declaration
void on_issue_order(game_object_script& target, vector& pos, _issue_order_type& type, bool* process)
{
}
Target can be null.
You can block execute issue order by
Trigger
- When the user orders to move/attack
- When the script orders to move/attack
OnProcessSpellCast
events::on_process_spell_cast
Function declaration
Trigger
- When the entity does spell cast
- When the entity does auto attack
OnDoCast
events::on_do_cast
Function declaration
Trigger
- When the entity spell/attack went to execute state
OnStopCast
events::on_stop_cast
Function declaration
Trigger
- When the entity spell/attack has been canceled
OnCreateObject
Some of object property like owner are not assigned in create object callback, to check it you need to save that object and checks in OnUpdate callback if property is assigned
events::on_create_object
Function declaration
Trigger
- When the game assigns network it to the object
OnDeleteObject
events::on_delete_object
Function declaration
TriggerWhen the game deletes object
OnObjectDead
events::on_object_dead
Function declaration
Trigger- When the entity dies
OnObjectRespawn
events::on_object_respawn
Function declaration
- When the entity respawns
- Including from (FoW)
OnTeleport
events::on_teleport
Function declaration
void on_teleport(game_object_script sender, teleport_type type, teleport_status status, float duration)
{
}
Trigger
- When the entity teleport state changes (start/cancel/finish)
OnCastSpell
events::on_cast_spell
Function declaration
void on_cast_spell(spellslot spell_slot, game_object_script target, vector& pos, vector& pos2, bool is_charge, bool* process)
{
}
Trigger
- When the script casts spell
OnBuffGain
events::on_buff_gain
Function declaration
Trigger
- When the entity gains a new buff
OnBuffLose
events::on_buff_lose
Function declaration
Trigger
- When the entity loses a buff
OnNewPath
events::on_new_path
Function declaration
void on_new_path(game_object_script sender, const std::vector<vector>& path, bool is_dash, float dash_speed)
{
}
Trigger
- When the entity gets a new path
OnPlayAnimation
events::on_play_animation
Function declaration
Trigger- When the entity starts to play animation
OnAfterAttackOrbwalker
Is one of two events which can be triggered by plugin, only if plugin is registered as orbwalker.
events::on_after_attack_orbwalker
Function declaration
Trigger
- After successful orbwalker attack command
OnBeforeAttackOrbwalker
Is one of two events which can be triggered by plugin, only if plugin is registered as orbwalker.
bool process = true;
event_handler< events::on_before_attack_orbwalker >::invoke( target, &process );
events::on_before_attack_orbwalker
Function declaration
You can block execute attack command by
Trigger
- Before orbwalker executes attack command