void HandleAutostoreLootItem(LootItemPkt packet) { Player player = GetPlayer(); AELootResult aeResult = player.GetAELootView().Count > 1 ? new AELootResult() : null; // @todo Implement looting by LootObject guid foreach (LootRequest req in packet.Loot) { Loot loot = null; ObjectGuid lguid = player.GetLootWorldObjectGUID(req.Object); if (lguid.IsGameObject()) { GameObject go = player.GetMap().GetGameObject(lguid); // not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO if (!go || ((go.GetOwnerGUID() != player.GetGUID() && go.GetGoType() != GameObjectTypes.FishingHole) && !go.IsWithinDistInMap(player, SharedConst.InteractionDistance))) { player.SendLootRelease(lguid); continue; } loot = go.loot; } else if (lguid.IsItem()) { Item pItem = player.GetItemByGuid(lguid); if (!pItem) { player.SendLootRelease(lguid); continue; } loot = pItem.loot; } else if (lguid.IsCorpse()) { Corpse bones = ObjectAccessor.GetCorpse(player, lguid); if (!bones) { player.SendLootRelease(lguid); continue; } loot = bones.loot; } else { Creature creature = player.GetMap().GetCreature(lguid); bool lootAllowed = creature && creature.IsAlive() == (player.GetClass() == Class.Rogue && creature.loot.loot_type == LootType.Pickpocketing); if (!lootAllowed || !creature.IsWithinDistInMap(player, AELootCreatureCheck.LootDistance)) { player.SendLootError(req.Object, lguid, lootAllowed ? LootError.TooFar : LootError.DidntKill); continue; } loot = creature.loot; } player.StoreLootItem((byte)(req.LootListID - 1), loot, aeResult); // If player is removing the last LootItem, delete the empty container. if (loot.isLooted() && lguid.IsItem()) { player.GetSession().DoLootRelease(lguid); } } if (aeResult != null) { foreach (var resultValue in aeResult.GetByOrder()) { player.SendNewItem(resultValue.item, resultValue.count, false, false, true); player.UpdateCriteria(CriteriaTypes.LootItem, resultValue.item.GetEntry(), resultValue.count); player.UpdateCriteria(CriteriaTypes.LootType, resultValue.item.GetEntry(), resultValue.count, (ulong)resultValue.lootType); player.UpdateCriteria(CriteriaTypes.LootEpicItem, resultValue.item.GetEntry(), resultValue.count); } } }
void HandleLootMasterGive(MasterLootItem masterLootItem) { AELootResult aeResult = new AELootResult(); if (GetPlayer().GetGroup() == null || GetPlayer().GetGroup().GetLooterGuid() != GetPlayer().GetGUID() || GetPlayer().GetGroup().GetLootMethod() != LootMethod.MasterLoot) { GetPlayer().SendLootError(ObjectGuid.Empty, ObjectGuid.Empty, LootError.DidntKill); return; } // player on other map Player target = Global.ObjAccessor.GetPlayer(_player, masterLootItem.Target); if (!target) { GetPlayer().SendLootError(ObjectGuid.Empty, ObjectGuid.Empty, LootError.PlayerNotFound); return; } foreach (LootRequest req in masterLootItem.Loot) { Loot loot = null; ObjectGuid lootguid = _player.GetLootWorldObjectGUID(req.Object); if (!_player.IsInRaidWith(target) || !_player.IsInMap(target)) { _player.SendLootError(req.Object, ObjectGuid.Empty, LootError.MasterOther); Log.outInfo(LogFilter.Cheat, $"MasterLootItem: Player {GetPlayer().GetName()} tried to give an item to ineligible player {target.GetName()} !"); return; } if (GetPlayer().GetLootGUID().IsCreatureOrVehicle()) { Creature creature = GetPlayer().GetMap().GetCreature(lootguid); if (!creature) { return; } loot = creature.loot; } else if (GetPlayer().GetLootGUID().IsGameObject()) { GameObject pGO = GetPlayer().GetMap().GetGameObject(lootguid); if (!pGO) { return; } loot = pGO.loot; } if (loot == null) { return; } byte slotid = (byte)(req.LootListID - 1); if (slotid >= loot.items.Count + loot.quest_items.Count) { Log.outDebug(LogFilter.Loot, $"MasterLootItem: Player {GetPlayer().GetName()} might be using a hack! (slot {slotid}, size {loot.items.Count})"); return; } LootItem item = slotid >= loot.items.Count ? loot.quest_items[slotid - loot.items.Count] : loot.items[slotid]; List <ItemPosCount> dest = new List <ItemPosCount>(); InventoryResult msg = target.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, item.itemid, item.count); if (item.follow_loot_rules && !item.AllowedForPlayer(target)) { msg = InventoryResult.CantEquipEver; } if (msg != InventoryResult.Ok) { if (msg == InventoryResult.ItemMaxCount) { _player.SendLootError(req.Object, ObjectGuid.Empty, LootError.MasterUniqueItem); } else if (msg == InventoryResult.InvFull) { _player.SendLootError(req.Object, ObjectGuid.Empty, LootError.MasterInvFull); } else { _player.SendLootError(req.Object, ObjectGuid.Empty, LootError.MasterOther); } target.SendEquipError(msg, null, null, item.itemid); return; } // now move item from loot to target inventory Item newitem = target.StoreNewItem(dest, item.itemid, true, item.randomBonusListId, item.GetAllowedLooters(), item.context, item.BonusListIDs); aeResult.Add(newitem, item.count, loot.loot_type); // mark as looted item.count = 0; item.is_looted = true; loot.NotifyItemRemoved(slotid); --loot.unlootedCount; } foreach (var resultValue in aeResult.GetByOrder()) { target.SendNewItem(resultValue.item, resultValue.count, false, false, true); target.UpdateCriteria(CriteriaTypes.LootItem, resultValue.item.GetEntry(), resultValue.count); target.UpdateCriteria(CriteriaTypes.LootType, resultValue.item.GetEntry(), resultValue.count, (ulong)resultValue.lootType); target.UpdateCriteria(CriteriaTypes.LootEpicItem, resultValue.item.GetEntry(), resultValue.count); } }