Gameobject events

From ArcEmu-Wiki
Jump to: navigation, search

Description:


Create a callback function for a specified gameobject event type.
The function will be called if the conditions are given (event started).

Parameter:


GameObjectID(Found in DBs)

A specific gameobject ID located in your database.

Event Numbers

   GAMEOBJECT_EVENT_ON_CREATE            = 1, // Fired when a gameobject is created.
   GAMEOBJECT_EVENT_ON_SPAWN            = 2, // Fired when a gameobject is pushed to world
   GAMEOBJECT_EVENT_ON_LOOT_TAKEN        = 3, // When a player loots the gameobject(chests)
   GAMEOBJECT_EVENT_ON_USE                = 4, // When a player activates/uses the gameobject(doors,levers, etc)
   GAMEOBJECT_EVENT_AIUPDATE            = 5, //An update event only fired if there was a previous call to gameobject:RegisterAIUpdateEvent(updateinterval)
   GAMEOBJECT_EVENT_ON_DESPAWN            = 6, // When a gameobject is removed from world.

Event Argument Details (What arguments get passed to Lua during a certain event.

All of these events push the gameobject whos events are fired upon, you use this value to invoke gameobject related methods to define its behavior.
GAMEOBJECT_EVENT_ON_CREATE - pushes the go_object and event number(1) ex: it would call a lua function as pcall(func,go_obj,1)
GAMEOBJECT_EVENT_ON_SPAWN - pushes the go_object and event number(2)
GAMEOBJECT_EVENT_ON_LOOT_TAKEN - pushes the go_object,event number(3),the player looter, and the item id of the looted item.
GAMEOBJECT_EVENT_ON_USE - pushes the go_object, event number(4) and the player who activated/used.
GAMEOBJECT_EVENT_AIUPDATE - pushes go_object and event number(5)
GAMEOBJECT_EVENT_ON_DESPAWN - pushes go_object and event number(6)

Example Code:


function GameObject_OnUse(go,_,player)
 print(player:GetName().." has activated game_object :"..tostring(go)
end
or
GameObject_Methods  = {}
function GameObject_Methods.OnSpawn(pGameObject)
 -- execute lua code here--
end


RegisterGameObjectEvent(ENTRYID, 4, GameObject_OnUse)
or
RegisterGameObjectEvent(ENTRYID,2, GameObject_Methods.OnSpawn)

Personal tools