Core/Loot: Prevent looting bosses by players that have already completed that encounter

Port From (https://github.com/TrinityCore/TrinityCore/commit/9ce47e6809eecc891904e272b368596fdc55e6a4)
This commit is contained in:
hondacrx
2022-10-06 20:50:10 -04:00
parent 2bba8aeb99
commit 39e9e73277
6 changed files with 57 additions and 14 deletions
+15 -6
View File
@@ -119,6 +119,9 @@ namespace Game
if (!member)
continue;
if (!loot.HasAllowedLooter(member.GetGUID()))
continue;
if (player.IsAtGroupRewardDistance(member))
playersNear.Add(member);
}
@@ -406,15 +409,21 @@ namespace Game
{
Loot loot = _player.GetAELootView().LookupByKey(req.Object);
if (loot == null || loot.GetLootMethod() != LootMethod.MasterLoot)
return;
if (!_player.IsInRaidWith(target) || !_player.IsInMap(target))
{
_player.SendLootError(req.Object, ObjectGuid.Empty, LootError.MasterOther);
_player.SendLootError(req.Object, loot.GetOwnerGUID(), LootError.MasterOther);
Log.outInfo(LogFilter.Cheat, $"MasterLootItem: Player {GetPlayer().GetName()} tried to give an item to ineligible player {target.GetName()} !");
return;
}
if (loot == null || loot.GetLootMethod() != LootMethod.MasterLoot)
if (!loot.HasAllowedLooter(masterLootItem.Target))
{
_player.SendLootError(req.Object, loot.GetOwnerGUID(), LootError.MasterOther);
return;
}
if (req.LootListID >= loot.items.Count)
{
@@ -426,16 +435,16 @@ namespace Game
List<ItemPosCount> dest = new();
InventoryResult msg = target.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, item.itemid, item.count);
if (!item.AllowedForPlayer(target, true))
if (!item.HasAllowedLooter(target.GetGUID()))
msg = InventoryResult.CantEquipEver;
if (msg != InventoryResult.Ok)
{
if (msg == InventoryResult.ItemMaxCount)
_player.SendLootError(req.Object, ObjectGuid.Empty, LootError.MasterUniqueItem);
_player.SendLootError(req.Object, loot.GetOwnerGUID(), LootError.MasterUniqueItem);
else if (msg == InventoryResult.InvFull)
_player.SendLootError(req.Object, ObjectGuid.Empty, LootError.MasterInvFull);
_player.SendLootError(req.Object, loot.GetOwnerGUID(), LootError.MasterInvFull);
else
_player.SendLootError(req.Object, ObjectGuid.Empty, LootError.MasterOther);
_player.SendLootError(req.Object, loot.GetOwnerGUID(), LootError.MasterOther);
return;
}