From 8f24c82944f9240d2f477be85de54f544cd9261e Mon Sep 17 00:00:00 2001 From: hondacrx Date: Fri, 17 Dec 2021 19:36:36 -0500 Subject: [PATCH] Core/Loot: make Loot::AddItem() honor LootItem::AllowedForPlayer() so that items that cannot be looted don't prevent skinning. Port From (https://github.com/TrinityCore/TrinityCore/commit/ef4d4e3d98eeb1edb2e0eb5dc92ba40aea9996f7) --- Source/Game/Loot/Loot.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Source/Game/Loot/Loot.cs b/Source/Game/Loot/Loot.cs index c1ebb5eb8..4b6ad1df9 100644 --- a/Source/Game/Loot/Loot.cs +++ b/Source/Game/Loot/Loot.cs @@ -205,6 +205,29 @@ namespace Game.Loots lootItems.Add(generatedLoot); count -= proto.GetMaxStackSize(); + // In some cases, a dropped item should be visible/lootable only for some players in group + bool canSeeItemInLootWindow = false; + Player player = Global.ObjAccessor.FindPlayer(lootOwnerGUID); + if (player != null) + { + Group group = player.GetGroup(); + if (group != null) + { + for (GroupReference itr = group.GetFirstMember(); itr != null; itr = itr.Next()) + { + Player member = itr.GetSource(); + if (member != null) + if (generatedLoot.AllowedForPlayer(member)) + canSeeItemInLootWindow = true; + } + } + else if (generatedLoot.AllowedForPlayer(player)) + canSeeItemInLootWindow = true; + } + + if (!canSeeItemInLootWindow) + continue; + // non-conditional one-player only items are counted here, // free for all items are counted in FillFFALoot(), // non-ffa conditionals are counted in FillNonQuestNonFFAConditionalLoot() @@ -232,6 +255,8 @@ namespace Game.Loots if (lootOwner == null) return false; + lootOwnerGUID = lootOwner.GetGUID(); + LootTemplate tab = store.GetLootFor(lootId); if (tab == null) { @@ -851,6 +876,7 @@ namespace Game.Loots public uint gold; public byte unlootedCount; public ObjectGuid roundRobinPlayer; // GUID of the player having the Round-Robin ownership for the loot. If 0, round robin owner has released. + ObjectGuid lootOwnerGUID; public LootType loot_type; // required for achievement system public byte maxDuplicates; // Max amount of items with the same entry that can drop (default is 1; on 25 man raid mode 3)