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:
@@ -709,9 +709,6 @@ namespace Game.Entities
|
|||||||
case GameObjectTypes.Chest:
|
case GameObjectTypes.Chest:
|
||||||
loot?.Update();
|
loot?.Update();
|
||||||
|
|
||||||
foreach (var (_, loot) in m_personalLoot)
|
|
||||||
loot.Update();
|
|
||||||
|
|
||||||
// Non-consumable chest was partially looted and restock time passed, restock all loot now
|
// 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)
|
if (GetGoInfo().Chest.consumable == 0 && GetGoInfo().Chest.chestRestockTime != 0 && GameTime.GetGameTime() >= m_restockTime)
|
||||||
{
|
{
|
||||||
@@ -720,6 +717,10 @@ namespace Game.Entities
|
|||||||
ClearLoot();
|
ClearLoot();
|
||||||
UpdateDynamicFlagsForNearbyPlayers();
|
UpdateDynamicFlagsForNearbyPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var (_, loot) in m_personalLoot)
|
||||||
|
loot.Update();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case GameObjectTypes.Trap:
|
case GameObjectTypes.Trap:
|
||||||
{
|
{
|
||||||
@@ -2897,7 +2898,7 @@ namespace Game.Entities
|
|||||||
GetAI().OnLootStateChanged((uint)state, unit);
|
GetAI().OnLootStateChanged((uint)state, unit);
|
||||||
|
|
||||||
// Start restock timer if the chest is partially looted or not looted at all
|
// 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;
|
m_restockTime = GameTime.GetGameTime() + GetGoInfo().Chest.chestRestockTime;
|
||||||
|
|
||||||
// only set collision for doors on SetGoState
|
// only set collision for doors on SetGoState
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ namespace Game
|
|||||||
Player player = GetPlayer();
|
Player player = GetPlayer();
|
||||||
AELootResult aeResult = player.GetAELootView().Count > 1 ? new AELootResult() : null;
|
AELootResult aeResult = player.GetAELootView().Count > 1 ? new AELootResult() : null;
|
||||||
|
|
||||||
// @todo Implement looting by LootObject guid
|
|
||||||
foreach (LootRequest req in packet.Loot)
|
foreach (LootRequest req in packet.Loot)
|
||||||
{
|
{
|
||||||
Loot loot = player.GetAELootView().LookupByKey(req.Object);
|
Loot loot = player.GetAELootView().LookupByKey(req.Object);
|
||||||
@@ -143,7 +142,7 @@ namespace Game
|
|||||||
SendPacket(packet);
|
SendPacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
loot.gold = 0;
|
loot.LootMoney();
|
||||||
|
|
||||||
// Delete the money loot record from the DB
|
// Delete the money loot record from the DB
|
||||||
if (loot.loot_type == LootType.Item)
|
if (loot.loot_type == LootType.Item)
|
||||||
|
|||||||
@@ -728,6 +728,12 @@ namespace Game.Loots
|
|||||||
return allLooted;
|
return allLooted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LootMoney()
|
||||||
|
{
|
||||||
|
gold = 0;
|
||||||
|
_changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
public LootItem GetItemInSlot(uint lootListId)
|
public LootItem GetItemInSlot(uint lootListId)
|
||||||
{
|
{
|
||||||
if (lootListId < items.Count)
|
if (lootListId < items.Count)
|
||||||
@@ -902,6 +908,9 @@ namespace Game.Loots
|
|||||||
if (!lootRoll.TryToStart(map, this, lootListId, maxEnchantingSkill))
|
if (!lootRoll.TryToStart(map, this, lootListId, maxEnchantingSkill))
|
||||||
_rolls.Remove(lootListId);
|
_rolls.Remove(lootListId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_rolls.Empty())
|
||||||
|
_changed = true;
|
||||||
}
|
}
|
||||||
else if (_lootMethod == LootMethod.MasterLoot)
|
else if (_lootMethod == LootMethod.MasterLoot)
|
||||||
{
|
{
|
||||||
@@ -973,6 +982,7 @@ namespace Game.Loots
|
|||||||
if (is_looted)
|
if (is_looted)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
_changed = true;
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1064,6 +1074,7 @@ namespace Game.Loots
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool IsLooted() { return gold == 0 && unlootedCount == 0; }
|
public bool IsLooted() { return gold == 0 && unlootedCount == 0; }
|
||||||
|
public bool IsChanged() { return _changed; }
|
||||||
|
|
||||||
public void AddLooter(ObjectGuid guid) { PlayersLooting.Add(guid); }
|
public void AddLooter(ObjectGuid guid) { PlayersLooting.Add(guid); }
|
||||||
public void RemoveLooter(ObjectGuid guid) { PlayersLooting.Remove(guid); }
|
public void RemoveLooter(ObjectGuid guid) { PlayersLooting.Remove(guid); }
|
||||||
@@ -1099,6 +1110,7 @@ namespace Game.Loots
|
|||||||
ObjectGuid _lootMaster;
|
ObjectGuid _lootMaster;
|
||||||
List<ObjectGuid> _allowedLooters = new();
|
List<ObjectGuid> _allowedLooters = new();
|
||||||
bool _wasOpened; // true if at least one player received the loot content
|
bool _wasOpened; // true if at least one player received the loot content
|
||||||
|
bool _changed;
|
||||||
uint _dungeonEncounterId;
|
uint _dungeonEncounterId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user