Skip to content

Events

Event manager

To use events in your plugin, you need to add one of them.

General template to add event

event_handler< events::name >::add_callback( callback );

General template to remove event

event_handler< events::name >::remove_handler( callback );

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

void on_update()
{

}

Trigger

  • Everytime when the game does an update

OnPreUpdate

events::on_preupdate

void on_pre_update()
{

}

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

void on_draw()
{

}
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

// Block process event
//
*process = false;

Trigger

  • When the user orders to move/attack
  • When the script orders to move/attack

OnProcessSpellCast

events::on_process_spell_cast

Function declaration

void on_process_spell_cast(game_object_script sender, spell_instance_script spell)
{

}

Trigger

  • When the entity does spell cast
  • When the entity does auto attack

OnDoCast

events::on_do_cast

Function declaration

void on_do_cast(game_object_script sender, spell_instance_script spell)
{

}

Trigger

  • When the entity spell/attack went to execute state

OnStopCast

events::on_stop_cast

Function declaration

void on_stop_cast(game_object_script sender, spell_instance_script spell)
{

}

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

void on_create_object(game_object_script sender)
{

}

Trigger

  • When the game assigns network it to the object

OnDeleteObject

events::on_delete_object

Function declaration

void on_delete_object(game_object_script sender)
{

}
Trigger

When the game deletes object

OnObjectDead

events::on_object_dead

Function declaration

void on_object_dead(game_object_script sender)
{

}
Trigger

  • When the entity dies

OnObjectRespawn

events::on_object_respawn Function declaration

void on_object_respawn(game_object_script sender)
{

}
Trigger

  • 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)
{

}
You can block execute cast spell by

// Block process event
//
*process = false;

Trigger

  • When the script casts spell

OnBuffGain

events::on_buff_gain

Function declaration

void on_buff_gain(game_object_script sender, buff_instance_script buff)
{

}

Trigger

  • When the entity gains a new buff

OnBuffLose

events::on_buff_lose

Function declaration

void on_buff_lose(game_object_script sender, buff_instance_script buff)
{

}

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

void on_play_animation(game_object_script sender, const char* name)
{

}
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.

event_handler< events::on_after_attack_orbwalker >::invoke( target );
events::on_after_attack_orbwalker

Function declaration

void on_after_attack_orbwalker(game_object_script target)
{

}

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

void on_before_attack_orbwalker(game_object_script target, bool* process)
{

}

You can block execute attack command by

// Block process event
//
*process = false;

Trigger

  • Before orbwalker executes attack command