Core/GameObjects: add script hook when destructable building is damaged.

This commit is contained in:
Supabad
2011-04-09 19:28:36 +02:00
parent 9efac6fe9f
commit a5a545a403
4 changed files with 18 additions and 6 deletions
@@ -1710,7 +1710,7 @@ void GameObject::TakenDamage(uint32 damage, Unit *who)
if (Battleground* bg = pwho->GetBattleground())
bg->DestroyGate(pwho, this, m_goInfo->building.destroyedEvent);
hitType = BG_OBJECT_DMG_HIT_TYPE_JUST_DESTROYED;
sScriptMgr->OnGameObjectDestroyed(pwho, this, m_goInfo->building.destroyedEvent);
sScriptMgr->OnGameObjectDestroyed(this, pwho, m_goInfo->building.destroyedEvent);
}
if (pwho)
if (Battleground* bg = pwho->GetBattleground())
@@ -1732,6 +1732,7 @@ void GameObject::TakenDamage(uint32 damage, Unit *who)
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED);
SetUInt32Value(GAMEOBJECT_DISPLAYID, m_goInfo->building.damagedDisplayId);
EventInform(m_goInfo->building.damagedEvent);
sScriptMgr->OnGameObjectDamaged(this, pwho, m_goInfo->building.damagedEvent);
hitType = BG_OBJECT_DMG_HIT_TYPE_JUST_HIGH_DAMAGED;
}
if (pwho)
+10 -2
View File
@@ -823,12 +823,20 @@ uint32 ScriptMgr::GetDialogStatus(Player* player, GameObject* go)
return tmpscript->GetDialogStatus(player, go);
}
void ScriptMgr::OnGameObjectDestroyed(Player* player, GameObject* go, uint32 eventId)
void ScriptMgr::OnGameObjectDestroyed(GameObject* go, Player* player, uint32 eventId)
{
ASSERT(go);
GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript);
tmpscript->OnDestroyed(player, go, eventId);
tmpscript->OnDestroyed(go, player, eventId);
}
void ScriptMgr::OnGameObjectDamaged(GameObject* go, Player* player, uint32 eventId)
{
ASSERT(go);
GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript);
tmpscript->OnDamaged(go, player, eventId);
}
void ScriptMgr::OnGameObjectUpdate(GameObject* go, uint32 diff)
+5 -2
View File
@@ -464,7 +464,9 @@ class GameObjectScript : public ScriptObject, public UpdatableScript<GameObject>
virtual uint32 GetDialogStatus(Player* /*player*/, GameObject* /*go*/) { return 100; }
// Called when the gameobject is destroyed (destructible buildings only).
virtual void OnDestroyed(Player* /*player*/, GameObject* /*go*/, uint32 /*eventId*/) { }
virtual void OnDestroyed(GameObject* /*go*/, Player* /*player*/, uint32 /*eventId*/) { }
// Called when the gameobject is damaged (destructible buildings only).
virtual void OnDamaged(GameObject* /*go*/, Player* /*player*/, uint32 /*eventId*/) { }
};
class AreaTriggerScript : public ScriptObject
@@ -859,7 +861,8 @@ class ScriptMgr
bool OnQuestAccept(Player* player, GameObject* go, Quest const* quest);
bool OnQuestReward(Player* player, GameObject* go, Quest const* quest, uint32 opt);
uint32 GetDialogStatus(Player* player, GameObject* go);
void OnGameObjectDestroyed(Player* player, GameObject* go, uint32 eventId);
void OnGameObjectDestroyed(GameObject* go, Player* player, uint32 eventId);
void OnGameObjectDamaged(GameObject* go, Player* player, uint32 eventId);
void OnGameObjectUpdate(GameObject* go, uint32 diff);
public: /* AreaTriggerScript */