コード例 #1
0
        public Item Mutate(IEntity from, int luckChance, Item item)
        {
            if (item != null)
            {
                if (item is BaseWeapon && 1 > Utility.Random(100))
                {
                    item.Delete();
                    item = new FireHorn();
                    return(item);
                }

                if (StandardLootItem && (item is BaseWeapon || item is BaseArmor || item is BaseJewel || item is BaseHat))
                {
                    // Try to generate a random item based on the creature killed
                    if (from is BaseCreature creature)
                    {
                        if (RandomItemGenerator.GenerateRandomItem(item, creature.LastKiller, creature))
                        {
                            return(item);
                        }
                    }
                }
                else if (item is BaseInstrument instr)
                {
                    SlayerName slayer = SlayerName.None;

                    slayer = BaseRunicTool.GetRandomSlayer();

                    if (slayer == SlayerName.None)
                    {
                        instr.Delete();
                        return(null);
                    }

                    instr.Quality = ItemQuality.Normal;
                    instr.Slayer  = slayer;
                }

                if (item.Stackable)
                {
                    item.Amount = Quantity.Roll();
                }
            }

            return(item);
        }
コード例 #2
0
ファイル: LootPack.cs プロジェクト: bsenyuva/ServUO
        public Item Mutate(Mobile from, int luckChance, Item item)
        {
            if (item != null)
            {
                if (item is BaseWeapon && 1 > Utility.Random(100))
                {
                    item.Delete();
                    item = new FireHorn();
                    return(item);
                }

                if (item is BaseWeapon || item is BaseArmor || item is BaseJewel || item is BaseHat)
                {
                    if (Core.AOS)
                    {
                        int bonusProps = GetBonusProperties();
                        int min        = m_MinIntensity;
                        int max        = m_MaxIntensity;

                        if (bonusProps < m_MaxProps && LootPack.CheckLuck(luckChance))
                        {
                            ++bonusProps;
                        }

                        int props = 1 + bonusProps;

                        // Make sure we're not spawning items with 6 properties.
                        if (props > m_MaxProps)
                        {
                            props = m_MaxProps;
                        }

                        // Try to generate a new random item
                        if (from is BaseCreature)
                        {
                            if (RandomItemGenerator.GenerateRandomItem(item, ((BaseCreature)from).LastKiller, (BaseCreature)from))
                            {
                                return(item);
                            }
                        }
                        else if (RandomItemGenerator.GenerateRandomItem(item, null, null))
                        {
                            return(item);
                        }

                        // Otherwise use the older style random generation
                        if (item is BaseWeapon)
                        {
                            BaseRunicTool.ApplyAttributesTo((BaseWeapon)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
                        }
                        else if (item is BaseArmor)
                        {
                            BaseRunicTool.ApplyAttributesTo((BaseArmor)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
                        }
                        else if (item is BaseJewel)
                        {
                            BaseRunicTool.ApplyAttributesTo((BaseJewel)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
                        }
                        else if (item is BaseHat)
                        {
                            BaseRunicTool.ApplyAttributesTo((BaseHat)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
                        }
                    }
                    else                     // not aos
                    {
                        if (item is BaseWeapon)
                        {
                            BaseWeapon weapon = (BaseWeapon)item;

                            if (80 > Utility.Random(100))
                            {
                                weapon.AccuracyLevel = (WeaponAccuracyLevel)GetRandomOldBonus();
                            }

                            if (60 > Utility.Random(100))
                            {
                                weapon.DamageLevel = (WeaponDamageLevel)GetRandomOldBonus();
                            }

                            if (40 > Utility.Random(100))
                            {
                                weapon.DurabilityLevel = (WeaponDurabilityLevel)GetRandomOldBonus();
                            }

                            if (5 > Utility.Random(100))
                            {
                                weapon.Slayer = SlayerName.Silver;
                            }

                            if (from != null && weapon.AccuracyLevel == 0 && weapon.DamageLevel == 0 && weapon.DurabilityLevel == 0 &&
                                weapon.Slayer == SlayerName.None && 5 > Utility.Random(100))
                            {
                                weapon.Slayer = SlayerGroup.GetLootSlayerType(from.GetType());
                            }
                        }
                        else if (item is BaseArmor)
                        {
                            BaseArmor armor = (BaseArmor)item;

                            if (80 > Utility.Random(100))
                            {
                                armor.ProtectionLevel = (ArmorProtectionLevel)GetRandomOldBonus();
                            }

                            if (40 > Utility.Random(100))
                            {
                                armor.Durability = (ArmorDurabilityLevel)GetRandomOldBonus();
                            }
                        }
                    }
                }
                else if (item is BaseInstrument)
                {
                    SlayerName slayer = SlayerName.None;

                    if (Core.AOS)
                    {
                        slayer = BaseRunicTool.GetRandomSlayer();
                    }
                    else
                    {
                        slayer = SlayerGroup.GetLootSlayerType(from.GetType());
                    }

                    if (slayer == SlayerName.None)
                    {
                        item.Delete();
                        return(null);
                    }

                    BaseInstrument instr = (BaseInstrument)item;

                    instr.Quality = InstrumentQuality.Regular;
                    instr.Slayer  = slayer;
                }

                if (item.Stackable)
                {
                    item.Amount = m_Quantity.Roll();
                }
            }

            return(item);
        }
コード例 #3
0
ファイル: LootPack.cs プロジェクト: vsemchenkov/ServUO
        public Item Mutate(Mobile from, int luckChance, Item item)
        {
            if (item != null)
            {
                if (item is BaseWeapon && 1 > Utility.Random(100))
                {
                    item.Delete();
                    item = new FireHorn();
                    return(item);
                }

                if (item is BaseWeapon || item is BaseArmor || item is BaseJewel || item is BaseHat)
                {
                    // Try to generate a new random item based on the creature killed
                    if (RandomItemGenerator.Enabled && from is BaseCreature)
                    {
                        if (RandomItemGenerator.GenerateRandomItem(item, ((BaseCreature)from).LastKiller, (BaseCreature)from))
                        {
                            return(item);
                        }
                    }

                    int bonusProps = GetBonusProperties();
                    int min        = m_MinIntensity;
                    int max        = m_MaxIntensity;

                    if (bonusProps < m_MaxProps && LootPack.CheckLuck(luckChance))
                    {
                        ++bonusProps;
                    }

                    int props = 1 + bonusProps;

                    // Make sure we're not spawning items with 6 properties.
                    if (props > m_MaxProps)
                    {
                        props = m_MaxProps;
                    }

                    // Use the older style random generation
                    if (item is BaseWeapon)
                    {
                        BaseRunicTool.ApplyAttributesTo((BaseWeapon)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
                    }
                    else if (item is BaseArmor)
                    {
                        BaseRunicTool.ApplyAttributesTo((BaseArmor)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
                    }
                    else if (item is BaseJewel)
                    {
                        BaseRunicTool.ApplyAttributesTo((BaseJewel)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
                    }
                    else if (item is BaseHat)
                    {
                        BaseRunicTool.ApplyAttributesTo((BaseHat)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
                    }
                }
                else if (item is BaseInstrument)
                {
                    SlayerName slayer = SlayerName.None;

                    slayer = BaseRunicTool.GetRandomSlayer();

                    if (slayer == SlayerName.None)
                    {
                        item.Delete();
                        return(null);
                    }

                    BaseInstrument instr = (BaseInstrument)item;

                    instr.Quality = ItemQuality.Normal;
                    instr.Slayer  = slayer;
                }

                if (item.Stackable)
                {
                    item.Amount = m_Quantity.Roll();
                }
            }

            return(item);
        }