Ejemplo n.º 1
0
        public void NotifyQuestItemRemoved(byte questIndex)
        {
            // when a free for all questitem is looted
            // all players will get notified of it being removed
            // (other questitems can be looted by each group member)
            // bit inefficient but isn't called often
            for (var i = 0; i < PlayersLooting.Count; ++i)
            {
                Player player = Global.ObjAccessor.FindPlayer(PlayersLooting[i]);
                if (player)
                {
                    var pql = PlayerQuestItems.LookupByKey(player.GetGUID());
                    if (!pql.Empty())
                    {
                        byte j;
                        for (j = 0; j < pql.Count; ++j)
                        {
                            if (pql[j].index == questIndex)
                            {
                                break;
                            }
                        }

                        if (j < pql.Count)
                        {
                            player.SendNotifyLootItemRemoved(GetGUID(), (byte)(items.Count + j));
                        }
                    }
                }
                else
                {
                    PlayersLooting.RemoveAt(i);
                }
            }
        }
Ejemplo n.º 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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void clear()
        {
            PlayerQuestItems.Clear();

            PlayerFFAItems.Clear();

            PlayerNonQuestNonFFAConditionalItems.Clear();

            PlayersLooting.Clear();
            items.Clear();
            quest_items.Clear();
            gold             = 0;
            unlootedCount    = 0;
            roundRobinPlayer = ObjectGuid.Empty;
            i_LootValidatorRefManager.clearReferences();
            _itemContext = 0;
        }
Ejemplo n.º 4
0
        public uint GetMaxSlotInLootFor(Player player)
        {
            var questItemList = PlayerQuestItems.LookupByKey(player.GetGUID());

            return((uint)(items.Count + questItemList.Count));
        }
Ejemplo n.º 5
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);
        }