Beispiel #1
0
        public void FinalizeDataHolder()
        {
            if (MinAmountOrRef < 0)
            {
                ReferencedEntryId = (uint)(-MinAmountOrRef);
            }
            else
            {
                MinAmount = MinAmountOrRef;
            }

            if (MinAmount < 1)
            {
                MinAmount = 1;
            }

            if (MinAmount > MaxAmount)
            {
                MaxAmount = MinAmount;
            }

            if (DropChance < 0)
            {
                DropChance = -DropChance;
            }

            LootMgr.AddEntry(this);
        }
Beispiel #2
0
        public static IList <LooterEntry> FindLooters(ILootable lootable, Character initialLooter)
        {
            List <LooterEntry> looterEntryList = new List <LooterEntry>();

            LootMgr.FindLooters(lootable, initialLooter, (IList <LooterEntry>)looterEntryList);
            return((IList <LooterEntry>)looterEntryList);
        }
Beispiel #3
0
        /// <summary>Generates loot for Items and GOs.</summary>
        /// <param name="lootable">The Object or Unit that is being looted</param>
        /// <returns>The object's loot or null if there is nothing to get or the given Character can't access the loot.</returns>
        public static ObjectLoot CreateAndSendObjectLoot(ILootable lootable, Character initialLooter,
                                                         LootEntryType type, bool heroic)
        {
            Asda2Loot loot = initialLooter.LooterEntry.Loot;

            if (loot != null)
            {
                loot.ForceDispose();
            }
            LootMgr.FindLooters(lootable, initialLooter);
            return(LootMgr.CreateLoot <ObjectLoot>(lootable, initialLooter, type, heroic, MapId.Silaris));
        }
Beispiel #4
0
 protected static void AddItems <T>(LootEntryType t, List <T> all) where T : LootItemEntry
 {
     foreach (ResolvedLootItemList entry in LootMgr.GetEntries(t))
     {
         if (entry != null)
         {
             foreach (LootEntity lootEntity in (List <LootEntity>)entry)
             {
                 all.Add((T)lootEntity);
             }
         }
     }
 }
Beispiel #5
0
        protected static void AddItems <T>(LootEntryType t, List <T> all)
            where T : LootItemEntry
        {
            var entries = LootMgr.GetEntries(t);

            foreach (var list in entries)
            {
                if (list != null)
                {
                    foreach (var entry in list)
                    {
                        all.Add((T)entry);
                    }
                }
            }
        }
Beispiel #6
0
        private static void LookupRef(ResolvedLootItemList list, LootItemEntry entry)
        {
            ResolvedLootItemList entries = LootMgr.GetEntries(LootEntryType.Reference, entry.ReferencedEntryId);

            if (entries == null)
            {
                return;
            }
            if (entries.ResolveStatus < (byte)1)
            {
                entries.ResolveStatus = (byte)1;
                foreach (LootEntity ent in (List <LootEntity>)entries)
                {
                    if (ent is LootItemEntry)
                    {
                        LootItemEntry entry1 = (LootItemEntry)ent;
                        if (entry1.ReferencedEntryId > 0U)
                        {
                            LootMgr.LookupRef(list, entry1);
                            continue;
                        }
                    }

                    LootMgr.AddRef(list, ent);
                }

                entries.ResolveStatus = (byte)2;
            }
            else if (list.ResolveStatus == (byte)1)
            {
                LogManager.GetCurrentClassLogger()
                .Warn("Infinite loop in Loot references detected in: " + (object)entry);
            }
            else
            {
                foreach (LootEntity ent in (List <LootEntity>)entries)
                {
                    LootMgr.AddRef(list, ent);
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Returns all Items that can be looted off the given lootable
        /// </summary>
        public static LootItem[] CreateLootItems(uint lootId, LootEntryType type, bool heroic,
                                                 IList <LooterEntry> looters)
        {
            ResolvedLootItemList entries = LootMgr.GetEntries(type, lootId);

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

            foreach (LootEntity lootEntity in (List <LootEntity>)entries)
            {
                if (100.0 * (double)Utility.RandomFloat() < (double)lootEntity.DropChance)
                {
                    ItemTemplate template = lootEntity.ItemTemplate;
                    if (template != null &&
                        looters.Any <LooterEntry>((Func <LooterEntry, bool>)(looter =>
                                                                             template.CheckLootConstraints(looter.Owner))))
                    {
                        array[newSize] = new LootItem(template,
                                                      Utility.Random(lootEntity.MinAmount, lootEntity.MaxAmount), (uint)newSize,
                                                      template.RandomPropertiesId);
                        ++newSize;
                        if (newSize == 15)
                        {
                            break;
                        }
                    }
                }
            }

            if (newSize == 0)
            {
                return(LootItem.EmptyArray);
            }
            Array.Resize <LootItem>(ref array, newSize);
            return(array);
        }
Beispiel #8
0
        public static void LoadAll()
        {
            if (LootMgr.Loaded)
            {
                return;
            }
            ContentMgr.Load <NPCLootItemEntry>();
            ContentMgr.Load <ItemLootItemEntry>();
            ContentMgr.Load <GOLootItemEntry>();
            ContentMgr.Load <FishingLootItemEntry>();
            ContentMgr.Load <MillingLootItemEntry>();
            ContentMgr.Load <PickPocketLootItemEntry>();
            ContentMgr.Load <ProspectingLootItemEntry>();
            ContentMgr.Load <DisenchantingLootItemEntry>();
            ContentMgr.Load <ReferenceLootItemEntry>();
            for (int index = LootMgr.ReferenceEntries.Count - 1; index >= 0; --index)
            {
                KeyValuePair <ResolvedLootItemList, LootItemEntry> referenceEntry = LootMgr.ReferenceEntries[index];
                referenceEntry.Key.Remove((LootEntity)referenceEntry.Value);
                LootMgr.LookupRef(referenceEntry.Key, referenceEntry.Value);
            }

            LootMgr.Loaded = true;
        }
Beispiel #9
0
 public void FinalizeDataHolder()
 {
     if (this.MinAmountOrRef < 0)
     {
         this.ReferencedEntryId = (uint)-this.MinAmountOrRef;
     }
     else
     {
         this.MinAmount = this.MinAmountOrRef;
     }
     if (this.MinAmount < 1)
     {
         this.MinAmount = 1;
     }
     if (this.MinAmount > this.MaxAmount)
     {
         this.MaxAmount = this.MinAmount;
     }
     if ((double)this.DropChance < 0.0)
     {
         this.DropChance = -this.DropChance;
     }
     LootMgr.AddEntry(this);
 }