aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraftedRO <24683355+CraftedRO@users.noreply.github.com>2025-02-16 20:56:32 +0200
committerGitHub <noreply@github.com>2025-02-16 19:56:32 +0100
commitde3ba5229f010c30e4d7af1ad28680afbcad873f (patch)
treeb6df0678ec372b4464378cbc9822b6ff474ac3f4
parent939ca92ac897987adc5ba8454d2a2c10e7d7365c (diff)
Core/GameObject: Activated world chests will now despawn after 5 minutes (#30269)
Co-authored-by: Kaytotes <kaytotes@users.noreply.github.com>
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp12
-rw-r--r--src/server/game/Maps/Map.cpp5
-rw-r--r--src/server/game/Maps/Map.h1
3 files changed, 16 insertions, 2 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index db28b515d04..4713ce9034d 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -2523,8 +2523,16 @@ void GameObject::SetLootState(LootState state, Unit* unit)
AI()->OnLootStateChanged(state, unit);
// Start restock timer if the chest is partially looted or not looted at all
- if (GetGoType() == GAMEOBJECT_TYPE_CHEST && state == GO_ACTIVATED && GetGOInfo()->chest.chestRestockTime > 0 && m_restockTime == 0)
- m_restockTime = GameTime::GetGameTime() + GetGOInfo()->chest.chestRestockTime;
+ if (GetGoType() == GAMEOBJECT_TYPE_CHEST && state == GO_ACTIVATED)
+ {
+ GameObjectTemplate const* goInfo = GetGOInfo();
+ if (goInfo->chest.chestRestockTime > 0 && m_restockTime == 0)
+ m_restockTime = GameTime::GetGameTime() + goInfo->chest.chestRestockTime;
+
+ // If world chests were opened, despawn them after 5 minutes
+ if (goInfo->chest.chestRestockTime == 0 && GetMap()->IsWorldMap())
+ DespawnOrUnsummon(5min);
+ }
if (GetGoType() == GAMEOBJECT_TYPE_DOOR) // only set collision for doors on SetGoState
return;
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index ecc900b41bd..9ab7f63aabd 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -4226,6 +4226,11 @@ bool Map::Instanceable() const
return i_mapEntry && i_mapEntry->Instanceable();
}
+bool Map::IsWorldMap() const
+{
+ return i_mapEntry && i_mapEntry->IsWorldMap();
+}
+
bool Map::IsDungeon() const
{
return i_mapEntry && i_mapEntry->IsDungeon();
diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h
index dfe0ff4a37a..1f8ff20264f 100644
--- a/src/server/game/Maps/Map.h
+++ b/src/server/game/Maps/Map.h
@@ -419,6 +419,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
MapDifficulty const* GetMapDifficulty() const;
bool Instanceable() const;
+ bool IsWorldMap() const;
bool IsDungeon() const;
bool IsNonRaidDungeon() const;
bool IsRaid() const;