mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-25 03:12:09 +01:00
*Save/load wintergrasp building health when grid loaded/unloaded.
--HG-- branch : trunk
This commit is contained in:
@@ -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);
|
||||
}
|
||||
else // from undamaged 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_goValue->destructibleBuilding.health = m_goInfo->destructibleBuilding.destroyedHealth;
|
||||
if(!m_goValue->destructibleBuilding.health)
|
||||
m_goValue->destructibleBuilding.health = 1;
|
||||
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 intact to damaged
|
||||
{
|
||||
if(m_goValue->building.health <= m_goInfo->building.destroyedHealth)
|
||||
{
|
||||
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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user