aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSnapper <snapperryen@gmail.com>2016-10-30 11:20:58 +0100
committerjoschiwald <joschiwald.trinity@gmail.com>2017-11-11 21:06:58 +0100
commitd25a8d42a381345c7fb86760049be70006a65e9d (patch)
treee0f7e3c9460bf9a872c61419f3c6ebe75462052e
parentc6881bd8a46b8ebd6a845b471668a630deb6da30 (diff)
Core/GameObjects: Handle despawning and respawning of nearby linked traps on gameobject despawn and respawn
Closes #12139 Closes #17553 (cherry picked from commit 5d9d25d5960a29d098035f9382a7b022e5294229)
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp13
-rw-r--r--src/server/game/Entities/GameObject/GameObject.h6
-rw-r--r--src/server/game/Spells/SpellEffects.cpp4
3 files changed, 23 insertions, 0 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 6025f822c78..f2e756bf80c 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -511,6 +511,10 @@ void GameObject::Update(uint32 diff)
m_SkillupList.clear();
m_usetimes = 0;
+ // If nearby linked trap exists, respawn it
+ if (GameObject* linkedTrap = GetLinkedTrap())
+ linkedTrap->SetLootState(GO_READY);
+
switch (GetGoType())
{
case GAMEOBJECT_TYPE_FISHINGNODE: // can't fish now
@@ -695,6 +699,10 @@ void GameObject::Update(uint32 diff)
}
case GO_JUST_DEACTIVATED:
{
+ // If nearby linked trap exists, despawn it
+ if (GameObject* linkedTrap = GetLinkedTrap())
+ linkedTrap->SetLootState(GO_JUST_DEACTIVATED);
+
//if Gameobject should cast spell, then this, but some GOs (type = 10) should be destroyed
if (GetGoType() == GAMEOBJECT_TYPE_GOOBER)
{
@@ -2382,6 +2390,11 @@ bool GameObject::IsLootAllowedFor(Player const* player) const
return true;
}
+GameObject* GameObject::GetLinkedTrap()
+{
+ return ObjectAccessor::GetGameObject(*this, m_linkedTrap);
+}
+
void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) const
{
if (!target)
diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h
index 5aa46577ccb..97887634931 100644
--- a/src/server/game/Entities/GameObject/GameObject.h
+++ b/src/server/game/Entities/GameObject/GameObject.h
@@ -221,6 +221,9 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
uint32 m_groupLootTimer; // (msecs)timer used for group loot
ObjectGuid lootingGroupLowGUID; // used to find group which is looting
+ GameObject* GetLinkedTrap();
+ void SetLinkedTrap(GameObject* linkedTrap) { m_linkedTrap = linkedTrap->GetGUID(); }
+
bool hasQuest(uint32 quest_id) const override;
bool hasInvolvedQuest(uint32 quest_id) const override;
bool ActivateToQuest(Player* target) const;
@@ -327,6 +330,9 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
ObjectGuid m_lootRecipient;
ObjectGuid m_lootRecipientGroup;
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
+
+ ObjectGuid m_linkedTrap;
+
private:
void RemoveFromOwner();
void SwitchDoorOrButton(bool activate, bool alternative = false);
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 7ed906c3247..d210a4c44f9 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -3139,6 +3139,8 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex)
GameObject* linkedGO = new GameObject();
if (linkedGO->Create(linkedEntry, map, m_caster->GetPhaseMask(), Position(x, y, z, target->GetOrientation()), rot, 255, GO_STATE_READY))
{
+ pGameObj->SetLinkedTrap(linkedGO);
+
linkedGO->CopyPhaseFrom(m_caster);
linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0);
@@ -4777,6 +4779,8 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex)
GameObject* linkedGO = new GameObject;
if (linkedGO->Create(linkedEntry, cMap, m_caster->GetPhaseMask(), pos, rot, 255, GO_STATE_READY))
{
+ pGameObj->SetLinkedTrap(linkedGO);
+
linkedGO->CopyPhaseFrom(m_caster);
linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0);