Beispiel #1
0
        List <NotNormalLootItem> FillNonQuestNonFFAConditionalLoot(Player player, bool presentAtLooting)
        {
            List <NotNormalLootItem> ql = new();

            for (byte i = 0; i < items.Count; ++i)
            {
                LootItem item = items[i];
                if (!item.is_looted && !item.freeforall && item.AllowedForPlayer(player))
                {
                    if (presentAtLooting)
                    {
                        item.AddAllowedLooter(player);
                    }
                    if (!item.conditions.Empty())
                    {
                        ql.Add(new NotNormalLootItem(i));
                        if (!item.is_counted)
                        {
                            ++unlootedCount;
                            item.is_counted = true;
                        }
                    }
                }
            }
            if (ql.Empty())
            {
                return(null);
            }

            PlayerNonQuestNonFFAConditionalItems[player.GetGUID()] = ql;
            return(ql);
        }
Beispiel #2
0
        void FillNotNormalLootFor(Player player, bool presentAtLooting)
        {
            ObjectGuid plguid = player.GetGUID();

            var questItemList = PlayerQuestItems.LookupByKey(plguid);

            if (questItemList.Empty())
            {
                FillQuestLoot(player);
            }

            questItemList = PlayerFFAItems.LookupByKey(plguid);
            if (questItemList.Empty())
            {
                FillFFALoot(player);
            }

            questItemList = PlayerNonQuestNonFFAConditionalItems.LookupByKey(plguid);
            if (questItemList.Empty())
            {
                FillNonQuestNonFFAConditionalLoot(player, presentAtLooting);
            }

            // if not auto-processed player will have to come and pick it up manually
            if (!presentAtLooting)
            {
                return;
            }

            // Process currency items
            uint     max_slot  = GetMaxSlotInLootFor(player);
            LootItem item      = null;
            int      itemsSize = items.Count;

            for (byte i = 0; i < max_slot; ++i)
            {
                if (i < items.Count)
                {
                    item = items[i];
                }
                else
                {
                    item = quest_items[i - itemsSize];
                }

                if (!item.is_looted && item.freeforall && item.AllowedForPlayer(player))
                {
                    ItemTemplate proto = Global.ObjectMgr.GetItemTemplate(item.itemid);
                    if (proto != null)
                    {
                        if (proto.IsCurrencyToken())
                        {
                            player.StoreLootItem(i, this);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        List <NotNormalLootItem> FillQuestLoot(Player player)
        {
            if (items.Count == SharedConst.MaxNRLootItems)
            {
                return(null);
            }

            List <NotNormalLootItem> ql = new();

            for (byte i = 0; i < quest_items.Count; ++i)
            {
                LootItem item = quest_items[i];

                if (!item.is_looted && (item.AllowedForPlayer(player) || (item.follow_loot_rules && player.GetGroup() && ((player.GetGroup().GetLootMethod() == LootMethod.MasterLoot &&
                                                                                                                           player.GetGroup().GetMasterLooterGuid() == player.GetGUID()) || player.GetGroup().GetLootMethod() != LootMethod.MasterLoot))))
                {
                    ql.Add(new NotNormalLootItem(i));

                    // quest items get blocked when they first appear in a
                    // player's quest vector
                    //
                    // increase once if one looter only, looter-times if free for all
                    if (item.freeforall || !item.is_blocked)
                    {
                        ++unlootedCount;
                    }
                    if (!player.GetGroup() || player.GetGroup().GetLootMethod() != LootMethod.GroupLoot)
                    {
                        item.is_blocked = true;
                    }

                    if (items.Count + ql.Count == SharedConst.MaxNRLootItems)
                    {
                        break;
                    }
                }
            }
            if (ql.Empty())
            {
                return(null);
            }

            PlayerQuestItems[player.GetGUID()] = ql;
            return(ql);
        }
Beispiel #4
0
        List <NotNormalLootItem> FillFFALoot(Player player)
        {
            List <NotNormalLootItem> ql = new();

            for (byte i = 0; i < items.Count; ++i)
            {
                LootItem item = items[i];
                if (!item.is_looted && item.freeforall && item.AllowedForPlayer(player))
                {
                    ql.Add(new NotNormalLootItem(i));
                    ++unlootedCount;
                }
            }
            if (ql.Empty())
            {
                return(null);
            }


            PlayerFFAItems[player.GetGUID()] = ql;
            return(ql);
        }
Beispiel #5
0
        //[WorldPacketHandler(ClientOpcodes.MasterLootItem)]
        void HandleLootMasterGive(WorldPacket packet)
        {
            ObjectGuid lootguid          = packet.ReadPackedGuid();
            byte       slotid            = packet.ReadUInt8();
            ObjectGuid target_playerguid = packet.ReadPackedGuid();

            if (GetPlayer().GetGroup() == null || GetPlayer().GetGroup().GetLooterGuid() != GetPlayer().GetGUID() || GetPlayer().GetGroup().GetLootMethod() != LootMethod.MasterLoot)
            {
                GetPlayer().SendLootError(lootguid, ObjectGuid.Empty, LootError.DidntKill);
                return;
            }

            // player on other map
            Player target = Global.ObjAccessor.GetPlayer(_player, target_playerguid);

            if (!target)
            {
                GetPlayer().SendLootError(lootguid, ObjectGuid.Empty, LootError.PlayerNotFound);
                return;
            }

            Log.outDebug(LogFilter.Network, "HandleLootMasterGive (CMSG_LOOT_MASTER_GIVE, 0x02A3) Target = [{0}].", target.GetName());

            if (GetPlayer().GetLootGUID() != lootguid)
            {
                GetPlayer().SendLootError(lootguid, ObjectGuid.Empty, LootError.DidntKill);
                return;
            }

            if (!GetPlayer().IsInRaidWith(target) || !GetPlayer().IsInMap(target))
            {
                GetPlayer().SendLootError(lootguid, ObjectGuid.Empty, LootError.MasterOther);
                Log.outInfo(LogFilter.Loot, "MasterLootItem: Player {0} tried to give an item to ineligible player {1}!", GetPlayer().GetName(), target.GetName());
                return;
            }

            Loot loot = null;

            if (GetPlayer().GetLootGUID().IsCreatureOrVehicle())
            {
                Creature creature = GetPlayer().GetMap().GetCreature(lootguid);
                if (creature == null)
                {
                    return;
                }

                loot = creature.loot;
            }
            else if (GetPlayer().GetLootGUID().IsGameObject())
            {
                GameObject pGO = GetPlayer().GetMap().GetGameObject(lootguid);
                if (pGO == null)
                {
                    return;
                }

                loot = pGO.loot;
            }

            if (loot == null)
            {
                return;
            }

            if (slotid >= loot.items.Count + loot.quest_items.Count)
            {
                Log.outDebug(LogFilter.Loot, "MasterLootItem: Player {0} might be using a hack! (slot {1}, size {2})",
                             GetPlayer().GetName(), slotid, 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)
                {
                    GetPlayer().SendLootError(lootguid, ObjectGuid.Empty, LootError.MasterUniqueItem);
                }
                else if (msg == InventoryResult.InvFull)
                {
                    GetPlayer().SendLootError(lootguid, ObjectGuid.Empty, LootError.MasterInvFull);
                }
                else
                {
                    GetPlayer().SendLootError(lootguid, ObjectGuid.Empty, LootError.MasterOther);
                }

                target.SendEquipError(msg, null, null, item.itemid);
                return;
            }

            // not move item from loot to target inventory
            Item newitem = target.StoreNewItem(dest, item.itemid, true, item.randomBonusListId, item.GetAllowedLooters(), item.context, item.BonusListIDs);

            target.SendNewItem(newitem, item.count, false, false, true);
            target.UpdateCriteria(CriteriaTypes.LootItem, item.itemid, item.count);
            target.UpdateCriteria(CriteriaTypes.LootType, item.itemid, item.count, (ulong)loot.loot_type);
            target.UpdateCriteria(CriteriaTypes.LootEpicItem, item.itemid, item.count);

            // mark as looted
            item.count     = 0;
            item.is_looted = true;

            loot.NotifyItemRemoved(slotid);
            --loot.unlootedCount;
        }
Beispiel #6
0
        void HandleLootMasterGive(MasterLootItem masterLootItem)
        {
            AELootResult aeResult = new();

            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();
                InventoryResult     msg  = target.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, item.itemid, item.count);
                if (!item.AllowedForPlayer(target, true))
                {
                    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);
                    }

                    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(CriteriaType.LootItem, resultValue.item.GetEntry(), resultValue.count);
                target.UpdateCriteria(CriteriaType.GetLootByType, resultValue.item.GetEntry(), resultValue.count, (ulong)resultValue.lootType);
                target.UpdateCriteria(CriteriaType.LootAnyItem, resultValue.item.GetEntry(), resultValue.count);
            }
        }