Core/BattleGrounds: update Gameobject hook to support multiple destructable building events.

little cleanup in GameObject.cpp
This commit is contained in:
Supabad
2011-04-10 20:55:17 +02:00
parent 9bed8e49db
commit 3771798a2e
6 changed files with 32 additions and 49 deletions
@@ -1698,7 +1698,6 @@ void GameObject::TakenDamage(uint32 damage, Unit *who)
if (HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED)) // from damaged to destroyed
{
uint8 hitType = BG_OBJECT_DMG_HIT_TYPE_HIGH_DAMAGED;
if (!m_goValue->building.health)
{
RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED);
@@ -1713,19 +1712,19 @@ void GameObject::TakenDamage(uint32 damage, Unit *who)
EventInform(m_goInfo->building.destroyedEvent);
if (pwho)
if (Battleground* bg = pwho->GetBattleground())
{
bg->EventPlayerDamagedGO(pwho, this, m_goInfo->building.destroyedEvent);
bg->DestroyGate(pwho, this, m_goInfo->building.destroyedEvent);
hitType = BG_OBJECT_DMG_HIT_TYPE_JUST_DESTROYED;
}
sScriptMgr->OnGameObjectDestroyed(this, pwho, m_goInfo->building.destroyedEvent);
}
if (pwho)
if (Battleground* bg = pwho->GetBattleground())
bg->EventPlayerDamagedGO(pwho, this, hitType, m_goInfo->building.destroyedEvent);
}
else // from intact to damaged
{
uint8 hitType = BG_OBJECT_DMG_HIT_TYPE_JUST_DAMAGED;
if (m_goValue->building.health + damage < m_goInfo->building.intactNumHits + m_goInfo->building.damagedNumHits)
hitType = BG_OBJECT_DMG_HIT_TYPE_DAMAGED;
if (m_goValue->building.health + damage >= m_goInfo->building.intactNumHits + m_goInfo->building.damagedNumHits)
if (pwho)
if (Battleground* bg = pwho->GetBattleground())
bg->EventPlayerDamagedGO(pwho, this, m_goInfo->building.damageEvent);
if (m_goValue->building.health <= m_goInfo->building.damagedNumHits)
{
@@ -1744,11 +1743,10 @@ void GameObject::TakenDamage(uint32 damage, Unit *who)
EventInform(m_goInfo->building.damagedEvent);
sScriptMgr->OnGameObjectDamaged(this, pwho, m_goInfo->building.damagedEvent);
hitType = BG_OBJECT_DMG_HIT_TYPE_JUST_HIGH_DAMAGED;
if (pwho)
if (Battleground* bg = pwho->GetBattleground())
bg->EventPlayerDamagedGO(pwho, this, m_goInfo->building.damagedEvent);
}
if (pwho)
if (Battleground* bg = pwho->GetBattleground())
bg->EventPlayerDamagedGO(pwho, this, hitType, m_goInfo->building.destroyedEvent);
}
SetGoAnimProgress(m_goValue->building.health*255/(m_goInfo->building.intactNumHits + m_goInfo->building.damagedNumHits));
}