コード例 #1
0
ファイル: Asda2LootMgr.cs プロジェクト: uvbs/Asda2-Server
        public static IList <Asda2LooterEntry> FindLooters(IAsda2Lootable lootable, Character initialLooter)
        {
            List <Asda2LooterEntry> asda2LooterEntryList = new List <Asda2LooterEntry>();

            Asda2LootMgr.FindLooters(lootable, initialLooter, (IList <Asda2LooterEntry>)asda2LooterEntryList);
            return((IList <Asda2LooterEntry>)asda2LooterEntryList);
        }
コード例 #2
0
 protected static void AddItems <T>(Asda2LootEntryType t, List <T> all) where T : Asda2LootItemEntry
 {
     foreach (List <Asda2LootItemEntry> entry in Asda2LootMgr.GetEntries(t))
     {
         if (entry != null)
         {
             foreach (Asda2LootItemEntry asda2LootItemEntry in entry)
             {
                 all.Add((T)asda2LootItemEntry);
             }
         }
     }
 }
コード例 #3
0
 public void FinalizeDataHolder()
 {
     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;
     }
     Asda2LootMgr.AddEntry(this);
 }
コード例 #4
0
        protected static void AddItems <T>(Asda2LootEntryType t, List <T> all)
            where T : Asda2LootItemEntry
        {
            var entries = Asda2LootMgr.GetEntries(t);

            foreach (var list in entries)
            {
                if (list != null)
                {
                    foreach (var entry in list)
                    {
                        all.Add((T)entry);
                    }
                }
            }
        }
コード例 #5
0
        public void FinalizeDataHolder()
        {
            if (MinAmount < 1)
            {
                MinAmount = 1;
            }

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

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

            Asda2LootMgr.AddEntry(this);
        }
コード例 #6
0
ファイル: Asda2LootMgr.cs プロジェクト: uvbs/Asda2-Server
        /// <summary>
        /// Generates normal loot (usually for dead mob-corpses).
        /// Returns null, if the loot is empty.
        /// </summary>
        /// <param name="lootable">The Object or Unit that is being looted</param>
        public static Asda2Loot GetOrCreateLoot(IAsda2Lootable lootable, Character triggerChar, Asda2LootEntryType type)
        {
            Asda2Loot loot = lootable.Loot;

            if (loot != null)
            {
                if (loot.IsMoneyLooted && loot.RemainingCount == 0)
                {
                    return((Asda2Loot)null);
                }
                loot.Looters.Clear();
            }
            else
            {
                lootable.Loot = loot =
                    (Asda2Loot)Asda2LootMgr.CreateLoot <Asda2NPCLoot>(lootable, triggerChar, type, MapId.Silaris);
            }

            return(loot);
        }
コード例 #7
0
ファイル: Asda2LootMgr.cs プロジェクト: uvbs/Asda2-Server
        /// <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 Asda2ObjectLoot CreateAndSendObjectLoot(IAsda2Lootable lootable, Character initialLooter,
                                                              Asda2LootEntryType type)
        {
            Asda2Loot loot1 = initialLooter.LooterEntry.Loot;

            if (loot1 != null)
            {
                loot1.ForceDispose();
            }
            IList <Asda2LooterEntry> looters = Asda2LootMgr.FindLooters(lootable, initialLooter);
            Asda2ObjectLoot          loot2   =
                Asda2LootMgr.CreateLoot <Asda2ObjectLoot>(lootable, initialLooter, type, MapId.Silaris);

            if (loot2 != null)
            {
                initialLooter.LooterEntry.Loot = (Asda2Loot)loot2;
                loot2.Initialize(initialLooter, looters, MapId.Silaris);
            }

            return(loot2);
        }
コード例 #8
0
ファイル: Asda2LootMgr.cs プロジェクト: uvbs/Asda2-Server
        /// <summary>
        /// Creates a new Loot object and returns it or null, if there is nothing to be looted.
        /// </summary>
        /// <typeparam name="T"><see cref="T:WCell.RealmServer.Looting.ObjectLoot" /> or <see cref="T:WCell.RealmServer.Looting.NPCLoot" /></typeparam>
        /// <param name="lootable"></param>
        /// <param name="initialLooter"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static T CreateLoot <T>(IAsda2Lootable lootable, Character initialLooter, Asda2LootEntryType type,
                                       MapId mapid) where T : Asda2Loot, new()
        {
            IList <Asda2LooterEntry> looters = Asda2LootMgr.FindLooters(lootable, initialLooter);
            float dropChanceBoost            = 0.0f;
            float num1 = 0.0f;

            foreach (Asda2LooterEntry asda2LooterEntry in (IEnumerable <Asda2LooterEntry>)looters)
            {
                dropChanceBoost += asda2LooterEntry.Owner.Asda2DropChance - 1f;
                num1            += (float)((double)num1 + (double)asda2LooterEntry.Owner.Asda2GoldAmountBoost - 1.0);
            }

            Asda2LootItem[] lootItems =
                Asda2LootMgr.CreateLootItems(lootable.GetLootId(type), type, looters, dropChanceBoost);
            float num2 = (float)lootable.LootMoney * ((float)Asda2LootMgr.DefaultMoneyDropFactor + num1);

            if (lootItems.Length == 0 && (double)num2 == 0.0 && lootable is GameObject)
            {
                num2 = 1f;
            }
            if (lootItems.Length <= 0 && (double)num2 <= 0.0)
            {
                return(default(T));
            }
            T instance = Activator.CreateInstance <T>();

            instance.Lootable = lootable;
            instance.Money    = (double)num2 > 4294967296.0 ? 1U : (uint)num2;
            instance.Items    = lootItems;
            T obj = instance;

            foreach (Asda2LootItem asda2LootItem in lootItems)
            {
                asda2LootItem.Loot = (Asda2Loot)obj;
            }
            obj.Initialize(initialLooter, looters, mapid);
            return(obj);
        }
コード例 #9
0
ファイル: Asda2LootMgr.cs プロジェクト: uvbs/Asda2-Server
        /// <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);
        }
コード例 #10
0
ファイル: Asda2LootMgr.cs プロジェクト: uvbs/Asda2-Server
 public static List <Asda2LootItemEntry> GetEntries(this IAsda2Lootable lootable, Asda2LootEntryType type)
 {
     return(Asda2LootMgr.GetEntries(type, lootable.GetLootId(type)));
 }