From 0521a314b5b504873e93191a8e2de8374b1f8940 Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Sat, 21 Mar 2020 22:29:52 +0100 Subject: [PATCH] Fix(Core/Gameobjects): non-consumable goobers no longer despawn on use (#2750) Taken from https://github.com/TrinityCore/TrinityCore/commit/50c5d30d13fe12af2a2028baf845fb6eab329a57 & https://github.com/TrinityCore/TrinityCore/commit/2b1e8d135bd3f3a3ddf7f29471cf6116da223175 Co-authored-by: Wyrserth --- .../game/Entities/GameObject/GameObject.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 280815504..97177bafa 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -702,13 +702,21 @@ void GameObject::Update(uint32 diff) loot.clear(); - //! If this is summoned by a spell with ie. SPELL_EFFECT_SUMMON_OBJECT_WILD, with or without owner, we check respawn criteria based on spell - //! The GetOwnerGUID() check is mostly for compatibility with hacky scripts - 99% of the time summoning should be done trough spells. - if (GetSpellId() || GetOwnerGUID()) + // Do not delete gameobjects that are not consumed on loot, while still allowing them to despawn when they expire if summoned + bool isSummonedAndExpired = (GetOwner() || GetSpellId()) && m_respawnTime == 0; + bool isPermanentSpawn = m_respawnDelayTime == 0; + if (!GetGOInfo()->IsDespawnAtAction() && + ((GetGoType() == GAMEOBJECT_TYPE_GOOBER && (!isSummonedAndExpired || isPermanentSpawn)) || + (GetGoType() == GAMEOBJECT_TYPE_CHEST && !isSummonedAndExpired && GetGOInfo()->chest.chestRestockTime == 0))) // ToDo: chests with data2 (chestRestockTime) > 0 and data3 (consumable) = 0 should not despawn on loot + { + SetLootState(GO_READY); + UpdateObjectVisibility(); + return; + } + else { SetRespawnTime(0); Delete(); - return; } SetLootState(GO_READY);