Exemplo n.º 1
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);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public LootItem LootItemInSlot(uint lootSlot, Player player, out NotNormalLootItem qitem, out NotNormalLootItem ffaitem, out NotNormalLootItem conditem)
        {
            qitem    = null;
            ffaitem  = null;
            conditem = null;

            LootItem item      = null;
            bool     is_looted = true;

            if (lootSlot >= items.Count)
            {
                uint questSlot  = (uint)(lootSlot - items.Count);
                var  questItems = PlayerQuestItems.LookupByKey(player.GetGUID());
                if (!questItems.Empty())
                {
                    NotNormalLootItem qitem2 = questItems.Find(p => p.index == questSlot);
                    if (qitem2 != null)
                    {
                        qitem     = qitem2;
                        item      = quest_items[qitem2.index];
                        is_looted = qitem2.is_looted;
                    }
                }
            }
            else
            {
                item      = items[(int)lootSlot];
                is_looted = item.is_looted;
                if (item.freeforall)
                {
                    var questItemList = PlayerFFAItems.LookupByKey(player.GetGUID());
                    if (!questItemList.Empty())
                    {
                        foreach (var c in questItemList)
                        {
                            if (c.index == lootSlot)
                            {
                                NotNormalLootItem ffaitem2 = c;
                                ffaitem   = ffaitem2;
                                is_looted = ffaitem2.is_looted;
                                break;
                            }
                        }
                    }
                }
                else if (!item.conditions.Empty())
                {
                    var questItemList = PlayerNonQuestNonFFAConditionalItems.LookupByKey(player.GetGUID());
                    if (!questItemList.Empty())
                    {
                        foreach (var iter in questItemList)
                        {
                            if (iter.index == lootSlot)
                            {
                                NotNormalLootItem conditem2 = iter;
                                conditem  = conditem2;
                                is_looted = conditem2.is_looted;
                                break;
                            }
                        }
                    }
                }
            }

            if (is_looted)
            {
                return(null);
            }

            return(item);
        }