Core/Loot: Initial support for personal loot in gameobjects (non-instanced content)

Port From (https://github.com/TrinityCore/TrinityCore/commit/641390dca2329041a6ef513c2c9f7b28d42d2762)
This commit is contained in:
hondacrx
2022-10-18 14:22:16 -04:00
parent 80009bfa8d
commit e78c71784c
6 changed files with 103 additions and 32 deletions
+1 -1
View File
@@ -694,7 +694,7 @@ namespace Game.Loots
}
}
public bool AutoStore(Player player, byte bag, byte slot, bool broadcast, bool createdByPlayer = false)
public bool AutoStore(Player player, byte bag, byte slot, bool broadcast = false, bool createdByPlayer = false)
{
bool allLooted = true;
for (uint i = 0; i < items.Count; ++i)
+18 -6
View File
@@ -165,17 +165,29 @@ namespace Game.Loots
List<uint> lootIdSet, lootIdSetUsed = new();
uint count = Gameobject.LoadAndCollectLootIds(out lootIdSet);
void checkLootId(uint lootId, uint gameObjectId)
{
if (!lootIdSet.Contains(lootId))
Gameobject.ReportNonExistingId(lootId, gameObjectId);
else
lootIdSetUsed.Add(lootId);
}
// remove real entries and check existence loot
var gotc = Global.ObjectMgr.GetGameObjectTemplates();
foreach (var go in gotc)
foreach (var (gameObjectId, gameObjectTemplate) in gotc)
{
uint lootid = go.Value.GetLootId();
uint lootid = gameObjectTemplate.GetLootId();
if (lootid != 0)
checkLootId(lootid, gameObjectId);
if (gameObjectTemplate.type == GameObjectTypes.Chest)
{
if (!lootIdSet.Contains(lootid))
Gameobject.ReportNonExistingId(lootid, go.Value.entry);
else
lootIdSetUsed.Add(lootid);
if (gameObjectTemplate.Chest.chestPersonalLoot != 0)
checkLootId(gameObjectTemplate.Chest.chestPersonalLoot, gameObjectId);
if (gameObjectTemplate.Chest.chestPushLoot != 0)
checkLootId(gameObjectTemplate.Chest.chestPushLoot, gameObjectId);
}
}