*Save/load wintergrasp building health when grid loaded/unloaded.
--HG-- branch : trunk
This commit is contained in:
+23
-23
@@ -175,7 +175,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa
|
|||||||
m_charges = goinfo->spellcaster.charges;
|
m_charges = goinfo->spellcaster.charges;
|
||||||
break;
|
break;
|
||||||
case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING:
|
case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING:
|
||||||
m_goValue->destructibleBuilding.health = goinfo->destructibleBuilding.damagedHealth;
|
m_goValue->building.health = goinfo->building.damagedHealth + goinfo->building.destroyedHealth;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1431,38 +1431,38 @@ bool GameObject::IsInRange(float x, float y, float z, float radius) const
|
|||||||
|
|
||||||
void GameObject::TakenDamage(uint32 damage)
|
void GameObject::TakenDamage(uint32 damage)
|
||||||
{
|
{
|
||||||
if(!m_goValue->destructibleBuilding.health)
|
if(!m_goValue->building.health)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(m_goValue->destructibleBuilding.health > damage)
|
if(m_goValue->building.health > damage)
|
||||||
{
|
m_goValue->building.health -= damage;
|
||||||
m_goValue->destructibleBuilding.health -= damage;
|
else
|
||||||
return;
|
m_goValue->building.health = 0;
|
||||||
}
|
|
||||||
|
|
||||||
m_goValue->destructibleBuilding.health = 0;
|
|
||||||
|
|
||||||
if(HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED)) // from damaged to destroyed
|
if(HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED)) // from damaged to destroyed
|
||||||
|
{
|
||||||
|
if(!m_goValue->building.health)
|
||||||
{
|
{
|
||||||
RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED);
|
RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED);
|
||||||
|
|
||||||
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DESTROYED);
|
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DESTROYED);
|
||||||
SetUInt32Value(GAMEOBJECT_DISPLAYID, m_goInfo->destructibleBuilding.destroyedDisplayId);
|
SetUInt32Value(GAMEOBJECT_DISPLAYID, m_goInfo->building.destroyedDisplayId);
|
||||||
m_goValue->destructibleBuilding.health = 0;
|
EventInform(m_goInfo->building.destroyedEventId);
|
||||||
EventInform(m_goInfo->destructibleBuilding.destroyedEventId);
|
|
||||||
}
|
}
|
||||||
else // from undamaged to damaged
|
}
|
||||||
|
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);
|
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED);
|
||||||
SetUInt32Value(GAMEOBJECT_DISPLAYID, m_goInfo->destructibleBuilding.damagedDisplayId);
|
SetUInt32Value(GAMEOBJECT_DISPLAYID, m_goInfo->building.damagedDisplayId);
|
||||||
if(m_goInfo->destructibleBuilding.destroyedDisplayId)
|
EventInform(m_goInfo->building.damagedEventId);
|
||||||
{
|
|
||||||
m_goValue->destructibleBuilding.health = m_goInfo->destructibleBuilding.destroyedHealth;
|
|
||||||
if(!m_goValue->destructibleBuilding.health)
|
|
||||||
m_goValue->destructibleBuilding.health = 1;
|
|
||||||
}
|
}
|
||||||
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);
|
RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED + GO_FLAG_DESTROYED);
|
||||||
SetUInt32Value(GAMEOBJECT_DISPLAYID, m_goInfo->displayId);
|
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)
|
void GameObject::EventInform(uint32 eventId)
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ struct GameObjectInfo
|
|||||||
uint32 unk8;
|
uint32 unk8;
|
||||||
uint32 destroyedEventId; //9
|
uint32 destroyedEventId; //9
|
||||||
uint32 destroyedDisplayId; //10
|
uint32 destroyedDisplayId; //10
|
||||||
} destructibleBuilding;
|
} building;
|
||||||
//34 GAMEOBJECT_TYPE_GUILDBANK - empty
|
//34 GAMEOBJECT_TYPE_GUILDBANK - empty
|
||||||
//35 GAMEOBJECT_TYPE_TRAPDOOR
|
//35 GAMEOBJECT_TYPE_TRAPDOOR
|
||||||
struct
|
struct
|
||||||
@@ -393,7 +393,7 @@ union GameObjectValue
|
|||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint32 health;
|
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
|
// 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);
|
static GameObject* GetGameObject(WorldObject& object, uint64 guid);
|
||||||
GameObjectInfo const* GetGOInfo() const { return m_goInfo; }
|
GameObjectInfo const* GetGOInfo() const { return m_goInfo; }
|
||||||
GameObjectData const* GetGOData() const { return m_goData; }
|
GameObjectData const* GetGOData() const { return m_goData; }
|
||||||
|
GameObjectValue * GetGOValue() const { return m_goValue; }
|
||||||
|
|
||||||
bool IsTransport() const;
|
bool IsTransport() const;
|
||||||
|
|
||||||
|
|||||||
@@ -193,7 +193,19 @@ void OPvPWintergrasp::OnGameObjectCreate(GameObject *go, bool add)
|
|||||||
{
|
{
|
||||||
BuildingStateMap::const_iterator itr = m_buildingStates.find(go->GetDBTableGUIDLow());
|
BuildingStateMap::const_iterator itr = m_buildingStates.find(go->GetDBTableGUIDLow());
|
||||||
if(itr != m_buildingStates.end())
|
if(itr != m_buildingStates.end())
|
||||||
|
{
|
||||||
itr->second->building = add ? go : NULL;
|
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