Exemplo n.º 1
0
        /// <summary>
        /// Returns all Items that can be looted off the given lootable
        /// </summary>
        public static Asda2LootItem[] CreateLootItems(uint lootId, Asda2LootEntryType type, IList <Asda2LooterEntry> looters, float dropChanceBoost)
        {
#if DEBUG
            if (!Asda2ItemMgr.Loaded)
            {
                return(Asda2LootItem.EmptyArray);
            }
#endif
            var entries = GetEntries(type, lootId);
            if (entries == null)
            {
                return(Asda2LootItem.EmptyArray);
            }
            var items = new Asda2LootItem[Math.Min(CharacterFormulas.MaxLootCount, entries.Count)];
            //var i = max;
            var i = 0;
            foreach (var entry in entries)
            {
                var chance = entry.DropChance * (LootItemDropFactor + dropChanceBoost);
                if ((100 * Utility.RandomFloat()) >= chance)
                {
                    continue;
                }

                var template = entry.ItemTemplate;
                if (template == null)
                {
                    // weird
                    continue;
                }

                /*if (!looters.Any(looter => template.CheckLootConstraints(looter.Owner)))
                 * {
                 *  continue;
                 * }*/

                items[i] = new Asda2LootItem(template,
                                             Utility.Random(entry.MinAmount, entry.MaxAmount),
                                             (uint)i);
                i++;

                if (i == CharacterFormulas.MaxLootCount)
                {
                    break;
                }
            }

            if (i == 0)
            {
                return(Asda2LootItem.EmptyArray);
            }

            Array.Resize(ref items, i);
            return(items);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns all Items that can be looted off the given lootable
        /// </summary>
        public static Asda2LootItem[] CreateLootItems(uint lootId, Asda2LootEntryType type,
                                                      IList <Asda2LooterEntry> looters, float dropChanceBoost)
        {
            List <Asda2LootItemEntry> entries = Asda2LootMgr.GetEntries(type, lootId);

            if (entries == null)
            {
                return(Asda2LootItem.EmptyArray);
            }
            Asda2LootItem[] array   = new Asda2LootItem[Math.Min(CharacterFormulas.MaxLootCount, entries.Count)];
            int             newSize = 0;

            foreach (Asda2LootItemEntry asda2LootItemEntry in entries)
            {
                if (100.0 * (double)Utility.RandomFloat() <
                    (double)(asda2LootItemEntry.DropChance * (Asda2LootMgr.LootItemDropFactor + dropChanceBoost)))
                {
                    Asda2ItemTemplate itemTemplate = asda2LootItemEntry.ItemTemplate;
                    if (itemTemplate != null)
                    {
                        array[newSize] = new Asda2LootItem(itemTemplate,
                                                           Utility.Random(asda2LootItemEntry.MinAmount, asda2LootItemEntry.MaxAmount), (uint)newSize);
                        ++newSize;
                        if (newSize == CharacterFormulas.MaxLootCount)
                        {
                            break;
                        }
                    }
                }
            }

            if (newSize == 0)
            {
                return(Asda2LootItem.EmptyArray);
            }
            Array.Resize <Asda2LootItem>(ref array, newSize);
            return(array);
        }