Construct() public static method

public static Construct ( ) : Item
return Item
Example #1
0
        public static void CheckRecipeDrop(CreatureDeathEventArgs e)
        {
            BaseCreature bc     = e.Creature as BaseCreature;
            Container    c      = e.Corpse;
            Mobile       killer = e.Killer;

            if (SpellHelper.IsEodon(c.Map, c.Location))
            {
                double chance = (double)bc.Fame / 1000000;
                int    luck   = 0;

                if (killer != null)
                {
                    luck = Math.Min(1800, killer is PlayerMobile ? ((PlayerMobile)killer).RealLuck : killer.Luck);
                }

                if (luck > 0)
                {
                    chance += (double)luck / 152000;
                }

                if (chance > Utility.RandomDouble())
                {
                    if (0.33 > Utility.RandomDouble())
                    {
                        Item item = Loot.Construct(_ArmorDropTypes[Utility.Random(_ArmorDropTypes.Length)]);

                        if (item != null)
                        {
                            c.DropItem(item);
                        }
                    }
                    else
                    {
                        Item scroll = new RecipeScroll(_RecipeTypes[Utility.Random(_RecipeTypes.Length)]);

                        if (scroll != null)
                        {
                            c.DropItem(scroll);
                        }
                    }
                }
            }
        }
Example #2
0
        public static Item RandomScroll(int index, int minCircle, int maxCircle)
        {
            --minCircle;
            --maxCircle;

            int scrollCount = ((maxCircle - minCircle) + 1) * 8;

            if (index == 0)
            {
                scrollCount += m_BlankTypes.Length;
            }

            int rnd = Utility.Random(scrollCount);

            if (index == 0 && rnd < m_BlankTypes.Length)
            {
                return(Loot.Construct(m_BlankTypes));
            }

            return(Loot.RandomScroll(minCircle * 8, (maxCircle * 8) + 7, SpellbookType.Regular));
        }
Example #3
0
        public Item Construct(bool inTokuno, bool isMondain, Expansion e)
        {
            try
            {
                Item item;

                if (m_Type == typeof(BaseRanged))
                {
                    item = Loot.RandomRangedWeapon();
                }
                else if (m_Type == typeof(BaseWeapon))
                {
                    item = Loot.RandomWeapon();
                }
                else if (m_Type == typeof(BaseArmor))
                {
                    item = Loot.RandomArmorOrHat();
                }
                else if (m_Type == typeof(BaseShield))
                {
                    item = Loot.RandomShield();
                }
                else if (m_Type == typeof(BaseJewel))
                {
                    item = e >= Expansion.AOS ? Loot.RandomJewelry() : Loot.RandomArmorOrShieldOrWeapon();
                }
                else if (m_Type == typeof(BaseInstrument))
                {
                    item = Loot.RandomInstrument(e >= Expansion.SE);
                }
                else if (m_Type == typeof(BaseWand))
                {
                    item = Loot.RandomWand();
                }
                else if (m_Type == typeof(Amber))                 // gem
                {
                    item = Loot.RandomGem();
                }
                else if (m_Type == typeof(ClumsyScroll))                 // low scroll
                {
                    item = RandomScroll(0, 1, 3);
                }
                else if (m_Type == typeof(ArchCureScroll))                 // med scroll
                {
                    item = RandomScroll(1, 4, 7);
                }
                else if (m_Type == typeof(SummonAirElementalScroll))                 // high scroll
                {
                    item = RandomScroll(2, 8, 8);
                }
                else if (m_Type == typeof(Ribs))                 //meats
                {
                    item = Loot.Construct(BaseCreature.FoodTypeFromPreference(FoodType.Meat));
                }
                else if (m_Type == typeof(Apple))                 //fruits/vegies
                {
                    item = Loot.Construct(BaseCreature.FoodTypeFromPreference(FoodType.FruitsAndVeggies));
                }
                else if (m_Type == typeof(SheafOfHay))                 //Hay
                {
                    item = Loot.Construct(BaseCreature.FoodTypeFromPreference(FoodType.GrainsAndHay));
                }
                else if (m_Type == typeof(RawFishSteak))                 //Fish
                {
                    item = Loot.Construct(BaseCreature.FoodTypeFromPreference(FoodType.Fish));
                }
                else if (m_Type == typeof(Eggs))                 //Eggs
                {
                    item = Loot.Construct(BaseCreature.FoodTypeFromPreference(FoodType.Eggs));
                }
                else if (m_Type == typeof(Food))                 //Food items
                {
                    item = Loot.RandomFood();
                }
                else if (m_Type == typeof(Candle))                 //Provisions
                {
                    item = Loot.RandomProvision();
                }
                else
                {
                    item = m_Type.CreateInstance <Item>();
                }

                return(item);
            }
            catch
            { }

            return(null);
        }