Core/GameObjects: Only start loot restock timer if loot contents were modified and ignore it for personal loot

Port From (https://github.com/TrinityCore/TrinityCore/commit/a3ef01f87bd56e553972277a38cf9a98a3397495)
This commit is contained in:
hondacrx
2023-07-18 07:43:30 -04:00
parent 7de6a839fa
commit a700760b88
3 changed files with 19 additions and 7 deletions
@@ -709,9 +709,6 @@ namespace Game.Entities
case GameObjectTypes.Chest:
loot?.Update();
foreach (var (_, loot) in m_personalLoot)
loot.Update();
// Non-consumable chest was partially looted and restock time passed, restock all loot now
if (GetGoInfo().Chest.consumable == 0 && GetGoInfo().Chest.chestRestockTime != 0 && GameTime.GetGameTime() >= m_restockTime)
{
@@ -720,6 +717,10 @@ namespace Game.Entities
ClearLoot();
UpdateDynamicFlagsForNearbyPlayers();
}
foreach (var (_, loot) in m_personalLoot)
loot.Update();
break;
case GameObjectTypes.Trap:
{
@@ -2897,7 +2898,7 @@ namespace Game.Entities
GetAI().OnLootStateChanged((uint)state, unit);
// Start restock timer if the chest is partially looted or not looted at all
if (GetGoType() == GameObjectTypes.Chest && state == LootState.Activated && GetGoInfo().Chest.chestRestockTime > 0 && m_restockTime == 0)
if (GetGoType() == GameObjectTypes.Chest && state == LootState.Activated && GetGoInfo().Chest.chestRestockTime > 0 && m_restockTime == 0 && loot != null && loot.IsChanged())
m_restockTime = GameTime.GetGameTime() + GetGoInfo().Chest.chestRestockTime;
// only set collision for doors on SetGoState