Core/Scripting: add the ability to access loot/go state changed events for gameobjects from cpp scripting. (malcrom's idea)
This commit is contained in:
@@ -1910,6 +1910,7 @@ void GameObject::SetLootState(LootState state, Unit* unit)
|
||||
{
|
||||
m_lootState = state;
|
||||
AI()->OnStateChanged(state, unit);
|
||||
sScriptMgr->OnGameObjectLootStateChanged(this, state, unit);
|
||||
if (m_model)
|
||||
{
|
||||
// startOpen determines whether we are going to add or remove the LoS on activation
|
||||
@@ -1929,6 +1930,7 @@ void GameObject::SetLootState(LootState state, Unit* unit)
|
||||
void GameObject::SetGoState(GOState state)
|
||||
{
|
||||
SetByteValue(GAMEOBJECT_BYTES_1, 0, state);
|
||||
sScriptMgr->OnGameObjectStateChanged(this, state);
|
||||
if (m_model)
|
||||
{
|
||||
if (!IsInWorld())
|
||||
|
||||
@@ -937,6 +937,22 @@ void ScriptMgr::OnGameObjectDamaged(GameObject* go, Player* player)
|
||||
tmpscript->OnDamaged(go, player);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGameObjectLootStateChanged(GameObject* go, uint32 state, Unit* unit)
|
||||
{
|
||||
ASSERT(go);
|
||||
|
||||
GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript);
|
||||
tmpscript->OnLootStateChanged(go, state, unit);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGameObjectStateChanged(GameObject* go, uint32 state)
|
||||
{
|
||||
ASSERT(go);
|
||||
|
||||
GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript);
|
||||
tmpscript->OnGameObjectStateChanged(go, state);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGameObjectUpdate(GameObject* go, uint32 diff)
|
||||
{
|
||||
ASSERT(go);
|
||||
|
||||
@@ -473,6 +473,12 @@ class GameObjectScript : public ScriptObject, public UpdatableScript<GameObject>
|
||||
// Called when the game object is damaged (destructible buildings only).
|
||||
virtual void OnDamaged(GameObject* /*go*/, Player* /*player*/) { }
|
||||
|
||||
// Called when the game object loot state is changed.
|
||||
virtual void OnLootStateChanged(GameObject* /*go*/, uint32 /*state*/, Unit* /*unit*/) { }
|
||||
|
||||
// Called when the game object state is changed.
|
||||
virtual void OnGameObjectStateChanged(GameObject* /*go*/, uint32 /*state*/) { }
|
||||
|
||||
// Called when a GameObjectAI object is needed for the gameobject.
|
||||
virtual GameObjectAI* GetAI(GameObject* /*go*/) const { return NULL; }
|
||||
};
|
||||
@@ -914,6 +920,8 @@ class ScriptMgr
|
||||
uint32 GetDialogStatus(Player* player, GameObject* go);
|
||||
void OnGameObjectDestroyed(GameObject* go, Player* player);
|
||||
void OnGameObjectDamaged(GameObject* go, Player* player);
|
||||
void OnGameObjectLootStateChanged(GameObject* go, uint32 state, Unit* unit);
|
||||
void OnGameObjectStateChanged(GameObject* go, uint32 state);
|
||||
void OnGameObjectUpdate(GameObject* go, uint32 diff);
|
||||
GameObjectAI* GetGameObjectAI(GameObject* go);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user