diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/GameObject.cpp | 50 | ||||
-rw-r--r-- | src/game/GameObject.h | 5 | ||||
-rw-r--r-- | src/game/Wintergrasp.cpp | 12 |
3 files changed, 40 insertions, 27 deletions
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 7c328e81145..574563edcf7 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -175,7 +175,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa m_charges = goinfo->spellcaster.charges; break; case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING: - m_goValue->destructibleBuilding.health = goinfo->destructibleBuilding.damagedHealth; + m_goValue->building.health = goinfo->building.damagedHealth + goinfo->building.destroyedHealth; break; } @@ -1431,38 +1431,38 @@ bool GameObject::IsInRange(float x, float y, float z, float radius) const void GameObject::TakenDamage(uint32 damage) { - if(!m_goValue->destructibleBuilding.health) + if(!m_goValue->building.health) return; - if(m_goValue->destructibleBuilding.health > damage) - { - m_goValue->destructibleBuilding.health -= damage; - return; - } - - m_goValue->destructibleBuilding.health = 0; + if(m_goValue->building.health > damage) + m_goValue->building.health -= damage; + else + m_goValue->building.health = 0; if(HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED)) // from damaged to destroyed { - RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED); - SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DESTROYED); - SetUInt32Value(GAMEOBJECT_DISPLAYID, m_goInfo->destructibleBuilding.destroyedDisplayId); - m_goValue->destructibleBuilding.health = 0; - EventInform(m_goInfo->destructibleBuilding.destroyedEventId); + if(!m_goValue->building.health) + { + RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED); + + SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DESTROYED); + SetUInt32Value(GAMEOBJECT_DISPLAYID, m_goInfo->building.destroyedDisplayId); + EventInform(m_goInfo->building.destroyedEventId); + } } - else // from undamaged to damaged + else // from intact to damaged { - SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED); - SetUInt32Value(GAMEOBJECT_DISPLAYID, m_goInfo->destructibleBuilding.damagedDisplayId); - if(m_goInfo->destructibleBuilding.destroyedDisplayId) + if(m_goValue->building.health <= m_goInfo->building.destroyedHealth) { - m_goValue->destructibleBuilding.health = m_goInfo->destructibleBuilding.destroyedHealth; - if(!m_goValue->destructibleBuilding.health) - m_goValue->destructibleBuilding.health = 1; + if(!m_goInfo->building.destroyedDisplayId) + m_goValue->building.health = 0; + else if(!m_goValue->building.health) + m_goValue->building.health = 1; + + SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED); + SetUInt32Value(GAMEOBJECT_DISPLAYID, m_goInfo->building.damagedDisplayId); + EventInform(m_goInfo->building.damagedEventId); } - else - m_goValue->destructibleBuilding.health = 0; - EventInform(m_goInfo->destructibleBuilding.damagedEventId); } } @@ -1470,7 +1470,7 @@ void GameObject::Rebuild() { RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED + GO_FLAG_DESTROYED); SetUInt32Value(GAMEOBJECT_DISPLAYID, m_goInfo->displayId); - m_goValue->destructibleBuilding.health = m_goInfo->destructibleBuilding.damagedHealth; + m_goValue->building.health = m_goInfo->building.damagedHealth + m_goInfo->building.destroyedHealth; } void GameObject::EventInform(uint32 eventId) diff --git a/src/game/GameObject.h b/src/game/GameObject.h index b365c7494ac..33c9fa63f9e 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -361,7 +361,7 @@ struct GameObjectInfo uint32 unk8; uint32 destroyedEventId; //9 uint32 destroyedDisplayId; //10 - } destructibleBuilding; + } building; //34 GAMEOBJECT_TYPE_GUILDBANK - empty //35 GAMEOBJECT_TYPE_TRAPDOOR struct @@ -393,7 +393,7 @@ union GameObjectValue struct { uint32 health; - }destructibleBuilding; + }building; }; // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform @@ -473,6 +473,7 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject static GameObject* GetGameObject(WorldObject& object, uint64 guid); GameObjectInfo const* GetGOInfo() const { return m_goInfo; } GameObjectData const* GetGOData() const { return m_goData; } + GameObjectValue * GetGOValue() const { return m_goValue; } bool IsTransport() const; diff --git a/src/game/Wintergrasp.cpp b/src/game/Wintergrasp.cpp index 78c27dab9fe..c295529aef0 100644 --- a/src/game/Wintergrasp.cpp +++ b/src/game/Wintergrasp.cpp @@ -193,7 +193,19 @@ void OPvPWintergrasp::OnGameObjectCreate(GameObject *go, bool add) { BuildingStateMap::const_iterator itr = m_buildingStates.find(go->GetDBTableGUIDLow()); if(itr != m_buildingStates.end()) + { itr->second->building = add ? go : NULL; + if(!add || itr->second->damageState == DAMAGE_INTACT && !itr->second->health) + itr->second->health = go->GetGOValue()->building.health; + else + { + go->GetGOValue()->building.health = itr->second->health; + if(itr->second->damageState == DAMAGE_DAMAGED) + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED); + else if(itr->second->damageState == DAMAGE_DESTROYED) + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DESTROYED); + } + } } } |