Exemple #1
0
 public void Process(ref LootObject Loot, byte GroupID)
 {
     if (GroupID > 0)
     {
         if (Groups.ContainsKey(GroupID))
         {
             Groups[GroupID].Process(ref Loot);
         }
         return;
     }
     checked
     {
         int num = Items.Count - 1;
         for (int i = 0; i <= num; i++)
         {
             if (!Items[i].Roll())
             {
                 continue;
             }
             if (Items[i].MinCountOrRef < 0)
             {
                 LootTemplate Referenced = WorldServiceLocator._WS_Loot.LootTemplates_Reference.GetLoot(-Items[i].MinCountOrRef);
                 if (Referenced != null)
                 {
                     int maxCount = Items[i].MaxCount;
                     for (int j = 1; j <= maxCount; j++)
                     {
                         Referenced.Process(ref Loot, Items[i].Group);
                     }
                 }
             }
             else
             {
                 List <LootItem>      items = Loot.Items;
                 List <LootStoreItem> items2;
                 int           index;
                 LootStoreItem Item = (items2 = Items)[index = i];
                 LootItem      item = new LootItem(ref Item);
                 items2[index] = Item;
                 items.Add(item);
             }
         }
         foreach (KeyValuePair <byte, LootGroup> group in Groups)
         {
             group.Value.Process(ref Loot);
         }
     }
 }
Exemple #2
0
        // Calls processor of corresponding LootTemplate (which handles everything including references)
        public bool FillLoot(uint lootId, LootStore store, Player lootOwner, bool personal, bool noEmptyError = false, LootModes lootMode = LootModes.Default, ItemContext context = 0)
        {
            // Must be provided
            if (lootOwner == null)
            {
                return(false);
            }

            LootTemplate tab = store.GetLootFor(lootId);

            if (tab == null)
            {
                if (!noEmptyError)
                {
                    Log.outError(LogFilter.Sql, "Table '{0}' loot id #{1} used but it doesn't have records.", store.GetName(), lootId);
                }
                return(false);
            }

            _itemContext = context;

            tab.Process(this, store.IsRatesAllowed(), (byte)lootMode);          // Processing is done there, callback via Loot.AddItem()

            // Setting access rights for group loot case
            Group group = lootOwner.GetGroup();

            if (!personal && group != null)
            {
                roundRobinPlayer = lootOwner.GetGUID();

                for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.Next())
                {
                    Player player = refe.GetSource();
                    if (player)   // should actually be looted object instead of lootOwner but looter has to be really close so doesnt really matter
                    {
                        if (player.IsInMap(lootOwner))
                        {
                            FillNotNormalLootFor(player, player.IsAtGroupRewardDistance(lootOwner));
                        }
                    }
                }

                for (byte i = 0; i < items.Count; ++i)
                {
                    ItemTemplate proto = Global.ObjectMgr.GetItemTemplate(items[i].itemid);
                    if (proto != null)
                    {
                        if (proto.GetQuality() < group.GetLootThreshold())
                        {
                            items[i].is_underthreshold = true;
                        }
                    }
                }
            }
            // ... for personal loot
            else
            {
                FillNotNormalLootFor(lootOwner, true);
            }

            return(true);
        }