Skip to content

Commit de3ba52

Browse files
CraftedROkaytotes
andauthored
Core/GameObject: Activated world chests will now despawn after 5 minutes (#30269)
Co-authored-by: Kaytotes <[email protected]>
1 parent 939ca92 commit de3ba52

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/server/game/Entities/GameObject/GameObject.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,8 +2523,16 @@ void GameObject::SetLootState(LootState state, Unit* unit)
25232523
AI()->OnLootStateChanged(state, unit);
25242524

25252525
// Start restock timer if the chest is partially looted or not looted at all
2526-
if (GetGoType() == GAMEOBJECT_TYPE_CHEST && state == GO_ACTIVATED && GetGOInfo()->chest.chestRestockTime > 0 && m_restockTime == 0)
2527-
m_restockTime = GameTime::GetGameTime() + GetGOInfo()->chest.chestRestockTime;
2526+
if (GetGoType() == GAMEOBJECT_TYPE_CHEST && state == GO_ACTIVATED)
2527+
{
2528+
GameObjectTemplate const* goInfo = GetGOInfo();
2529+
if (goInfo->chest.chestRestockTime > 0 && m_restockTime == 0)
2530+
m_restockTime = GameTime::GetGameTime() + goInfo->chest.chestRestockTime;
2531+
2532+
// If world chests were opened, despawn them after 5 minutes
2533+
if (goInfo->chest.chestRestockTime == 0 && GetMap()->IsWorldMap())
2534+
DespawnOrUnsummon(5min);
2535+
}
25282536

25292537
if (GetGoType() == GAMEOBJECT_TYPE_DOOR) // only set collision for doors on SetGoState
25302538
return;

src/server/game/Maps/Map.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4226,6 +4226,11 @@ bool Map::Instanceable() const
42264226
return i_mapEntry && i_mapEntry->Instanceable();
42274227
}
42284228

4229+
bool Map::IsWorldMap() const
4230+
{
4231+
return i_mapEntry && i_mapEntry->IsWorldMap();
4232+
}
4233+
42294234
bool Map::IsDungeon() const
42304235
{
42314236
return i_mapEntry && i_mapEntry->IsDungeon();

src/server/game/Maps/Map.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
419419
MapDifficulty const* GetMapDifficulty() const;
420420

421421
bool Instanceable() const;
422+
bool IsWorldMap() const;
422423
bool IsDungeon() const;
423424
bool IsNonRaidDungeon() const;
424425
bool IsRaid() const;

0 commit comments

Comments
 (0)