Exemple #1
0
        public static void ApplyAttributesTo(BaseJewel jewelry, bool playerMade, int luckChance, int attributeCount, int min, int max)
        {
            int delta;

            if (min > max)
            {
                delta = min;
                min   = max;
                max   = delta;
            }

            if (!playerMade && RandomItemGenerator.Enabled)
            {
                RandomItemGenerator.GenerateRandomItem(jewelry, luckChance, attributeCount, min, max);
                return;
            }

            m_PlayerMade = playerMade;
            m_LuckChance = luckChance;

            AosAttributes        primary = jewelry.Attributes;
            AosElementAttributes resists = jewelry.Resistances;
            AosSkillBonuses      skills  = jewelry.SkillBonuses;

            m_Props.SetAll(false);

            for (int i = 0; i < attributeCount; ++i)
            {
                int random = GetUniqueRandom(24);

                if (random == -1)
                {
                    break;
                }

                switch (random)
                {
                case 0:
                    ApplyAttribute(resists, min, max, AosElementAttribute.Physical, 1, 15);
                    break;

                case 1:
                    ApplyAttribute(resists, min, max, AosElementAttribute.Fire, 1, 15);
                    break;

                case 2:
                    ApplyAttribute(resists, min, max, AosElementAttribute.Cold, 1, 15);
                    break;

                case 3:
                    ApplyAttribute(resists, min, max, AosElementAttribute.Poison, 1, 15);
                    break;

                case 4:
                    ApplyAttribute(resists, min, max, AosElementAttribute.Energy, 1, 15);
                    break;

                case 5:
                    ApplyAttribute(primary, min, max, AosAttribute.WeaponDamage, 1, 25);
                    break;

                case 6:
                    ApplyAttribute(primary, min, max, AosAttribute.DefendChance, 1, 15);
                    break;

                case 7:
                    ApplyAttribute(primary, min, max, AosAttribute.AttackChance, 1, 15);
                    break;

                case 8:
                    ApplyAttribute(primary, min, max, AosAttribute.BonusStr, 1, 8);
                    break;

                case 9:
                    ApplyAttribute(primary, min, max, AosAttribute.BonusDex, 1, 8);
                    break;

                case 10:
                    ApplyAttribute(primary, min, max, AosAttribute.BonusInt, 1, 8);
                    break;

                case 11:
                    ApplyAttribute(primary, min, max, AosAttribute.EnhancePotions, 5, 25, 5);
                    break;

                case 12:
                    ApplyAttribute(primary, min, max, AosAttribute.CastSpeed, 1, 1);
                    break;

                case 13:
                    ApplyAttribute(primary, min, max, AosAttribute.CastRecovery, 1, 3);
                    break;

                case 14:
                    ApplyAttribute(primary, min, max, AosAttribute.LowerManaCost, 1, 8);
                    break;

                case 15:
                    ApplyAttribute(primary, min, max, AosAttribute.LowerRegCost, 1, 20);
                    break;

                case 16:
                    ApplyAttribute(primary, min, max, AosAttribute.Luck, 1, 100);
                    break;

                case 17:
                    ApplyAttribute(primary, min, max, AosAttribute.SpellDamage, 1, 12);
                    break;

                case 18:
                    ApplyAttribute(primary, min, max, AosAttribute.NightSight, 1, 1);
                    break;

                case 19:
                    ApplySkillBonus(skills, min, max, 0, 1, 15);
                    break;

                case 20:
                    ApplySkillBonus(skills, min, max, 1, 1, 15);
                    break;

                case 21:
                    ApplySkillBonus(skills, min, max, 2, 1, 15);
                    break;

                case 22:
                    ApplySkillBonus(skills, min, max, 3, 1, 15);
                    break;

                case 23:
                    ApplySkillBonus(skills, min, max, 4, 1, 15);
                    break;
                }
            }
        }
Exemple #2
0
        public static void ApplyAttributesTo(BaseArmor armor, bool playerMade, int luckChance, int attributeCount, int min, int max)
        {
            int delta;

            if (min > max)
            {
                delta = min;
                min   = max;
                max   = delta;
            }

            if (!playerMade && RandomItemGenerator.Enabled)
            {
                RandomItemGenerator.GenerateRandomItem(armor, luckChance, attributeCount, min, max);
                return;
            }

            m_PlayerMade = playerMade;
            m_LuckChance = luckChance;

            AosAttributes      primary   = armor.Attributes;
            AosArmorAttributes secondary = armor.ArmorAttributes;

            m_Props.SetAll(false);

            bool isShield   = (armor is BaseShield);
            int  baseCount  = (isShield ? 7 : 20);
            int  baseOffset = (isShield ? 0 : 4);

            if (!isShield && armor.MeditationAllowance == ArmorMeditationAllowance.All)
            {
                m_Props.Set(3, true); // remove mage armor from possible properties
            }
            if (armor.Resource >= CraftResource.RegularLeather && armor.Resource <= CraftResource.BarbedLeather)
            {
                m_Props.Set(0, true); // remove lower requirements from possible properties for leather armor
                m_Props.Set(2, true); // remove durability bonus from possible properties
            }
            if (armor.RequiredRace == Race.Elf)
            {
                m_Props.Set(7, true); // elves inherently have night sight and elf only armor doesn't get night sight as a mod
            }
            for (int i = 0; i < attributeCount; ++i)
            {
                int random = GetUniqueRandom(baseCount);

                if (random == -1)
                {
                    break;
                }

                random += baseOffset;

                switch (random)
                {
                /* Begin Sheilds */
                case 0:
                    ApplyAttribute(primary, min, max, AosAttribute.SpellChanneling, 1, 1);
                    break;

                case 1:
                    ApplyAttribute(primary, min, max, AosAttribute.DefendChance, 1, 15);
                    break;

                case 2:
                    if (Core.ML)
                    {
                        ApplyAttribute(primary, min, max, AosAttribute.ReflectPhysical, 1, 15);
                    }
                    else
                    {
                        ApplyAttribute(primary, min, max, AosAttribute.AttackChance, 1, 15);
                    }
                    break;

                case 3:
                    ApplyAttribute(primary, min, max, AosAttribute.CastSpeed, 1, 1);
                    break;

                /* Begin Armor */
                case 4:
                    ApplyAttribute(secondary, min, max, AosArmorAttribute.LowerStatReq, 10, 100, 10);
                    break;

                case 5:
                    ApplyAttribute(secondary, min, max, AosArmorAttribute.SelfRepair, 1, 5);
                    break;

                case 6:
                    ApplyAttribute(secondary, min, max, AosArmorAttribute.DurabilityBonus, 10, 100, 10);
                    break;

                /* End Shields */
                case 7:
                    ApplyAttribute(secondary, min, max, AosArmorAttribute.MageArmor, 1, 1);
                    break;

                case 8:
                    ApplyAttribute(primary, min, max, AosAttribute.RegenHits, 1, 2);
                    break;

                case 9:
                    ApplyAttribute(primary, min, max, AosAttribute.RegenStam, 1, 3);
                    break;

                case 10:
                    ApplyAttribute(primary, min, max, AosAttribute.RegenMana, 1, 2);
                    break;

                case 11:
                    ApplyAttribute(primary, min, max, AosAttribute.NightSight, 1, 1);
                    break;

                case 12:
                    ApplyAttribute(primary, min, max, AosAttribute.BonusHits, 1, 5);
                    break;

                case 13:
                    ApplyAttribute(primary, min, max, AosAttribute.BonusStam, 1, 8);
                    break;

                case 14:
                    ApplyAttribute(primary, min, max, AosAttribute.BonusMana, 1, 8);
                    break;

                case 15:
                    ApplyAttribute(primary, min, max, AosAttribute.LowerManaCost, 1, 8);
                    break;

                case 16:
                    ApplyAttribute(primary, min, max, AosAttribute.LowerRegCost, 1, 20);
                    break;

                case 17:
                    ApplyAttribute(primary, min, max, AosAttribute.Luck, 1, 100);
                    break;

                case 18:
                    ApplyAttribute(primary, min, max, AosAttribute.ReflectPhysical, 1, 15);
                    break;

                case 19:
                    ApplyResistance(armor, min, max, ResistanceType.Physical, 1, 15);
                    break;

                case 20:
                    ApplyResistance(armor, min, max, ResistanceType.Fire, 1, 15);
                    break;

                case 21:
                    ApplyResistance(armor, min, max, ResistanceType.Cold, 1, 15);
                    break;

                case 22:
                    ApplyResistance(armor, min, max, ResistanceType.Poison, 1, 15);
                    break;

                case 23:
                    ApplyResistance(armor, min, max, ResistanceType.Energy, 1, 15);
                    break;
                    /* End Armor */
                }
            }
        }
Exemple #3
0
        public static void ApplyAttributesTo(BaseHat hat, bool playerMade, int luckChance, int attributeCount, int min, int max)
        {
            int delta;

            if (min > max)
            {
                delta = min;
                min   = max;
                max   = delta;
            }

            if (!playerMade && RandomItemGenerator.Enabled)
            {
                RandomItemGenerator.GenerateRandomItem(hat, luckChance, attributeCount, min, max);
                return;
            }

            m_PlayerMade = playerMade;
            m_LuckChance = luckChance;

            AosAttributes        primary   = hat.Attributes;
            AosArmorAttributes   secondary = hat.ClothingAttributes;
            AosElementAttributes resists   = hat.Resistances;

            m_Props.SetAll(false);

            for (int i = 0; i < attributeCount; ++i)
            {
                int random = GetUniqueRandom(19);

                if (random == -1)
                {
                    break;
                }

                switch (random)
                {
                case 0:
                    ApplyAttribute(primary, min, max, AosAttribute.ReflectPhysical, 1, 15);
                    break;

                case 1:
                    ApplyAttribute(primary, min, max, AosAttribute.RegenHits, 1, 2);
                    break;

                case 2:
                    ApplyAttribute(primary, min, max, AosAttribute.RegenStam, 1, 3);
                    break;

                case 3:
                    ApplyAttribute(primary, min, max, AosAttribute.RegenMana, 1, 2);
                    break;

                case 4:
                    ApplyAttribute(primary, min, max, AosAttribute.NightSight, 1, 1);
                    break;

                case 5:
                    ApplyAttribute(primary, min, max, AosAttribute.BonusHits, 1, 5);
                    break;

                case 6:
                    ApplyAttribute(primary, min, max, AosAttribute.BonusStam, 1, 8);
                    break;

                case 7:
                    ApplyAttribute(primary, min, max, AosAttribute.BonusMana, 1, 8);
                    break;

                case 8:
                    ApplyAttribute(primary, min, max, AosAttribute.LowerManaCost, 1, 8);
                    break;

                case 9:
                    ApplyAttribute(primary, min, max, AosAttribute.LowerRegCost, 1, 20);
                    break;

                case 10:
                    ApplyAttribute(primary, min, max, AosAttribute.Luck, 1, 100);
                    break;

                case 11:
                    ApplyAttribute(secondary, min, max, AosArmorAttribute.LowerStatReq, 10, 100, 10);
                    break;

                case 12:
                    ApplyAttribute(secondary, min, max, AosArmorAttribute.SelfRepair, 1, 5);
                    break;

                case 13:
                    ApplyAttribute(secondary, min, max, AosArmorAttribute.DurabilityBonus, 10, 100, 10);
                    break;

                case 14:
                    ApplyAttribute(resists, min, max, AosElementAttribute.Physical, 1, 15);
                    break;

                case 15:
                    ApplyAttribute(resists, min, max, AosElementAttribute.Fire, 1, 15);
                    break;

                case 16:
                    ApplyAttribute(resists, min, max, AosElementAttribute.Cold, 1, 15);
                    break;

                case 17:
                    ApplyAttribute(resists, min, max, AosElementAttribute.Poison, 1, 15);
                    break;

                case 18:
                    ApplyAttribute(resists, min, max, AosElementAttribute.Energy, 1, 15);
                    break;
                }
            }
        }
Exemple #4
0
        public static void ApplyAttributesTo(BaseWeapon weapon, bool playerMade, int luckChance, int attributeCount, int min, int max)
        {
            int delta;

            if (min > max)
            {
                delta = min;
                min   = max;
                max   = delta;
            }

            if (!playerMade && RandomItemGenerator.Enabled)
            {
                RandomItemGenerator.GenerateRandomItem(weapon, luckChance, attributeCount, min, max);
                return;
            }

            m_PlayerMade = playerMade;
            m_LuckChance = luckChance;

            AosAttributes       primary   = weapon.Attributes;
            AosWeaponAttributes secondary = weapon.WeaponAttributes;

            m_Props.SetAll(false);

            if (weapon is BaseRanged)
            {
                m_Props.Set(2, true); // ranged weapons cannot be ubws or mageweapon
            }
            else
            {
                m_Props.Set(25, true); // Only bows can be Balanced
                m_Props.Set(26, true); // Only bows have Velocity
            }

            for (int i = 0; i < attributeCount; ++i)
            {
                int random = GetUniqueRandom(27);

                if (random == -1)
                {
                    break;
                }

                switch (random)
                {
                case 0:
                {
                    switch (Utility.Random(5))
                    {
                    case 0:
                        ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitPhysicalArea, 2, 50, 2);
                        break;

                    case 1:
                        ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitFireArea, 2, 50, 2);
                        break;

                    case 2:
                        ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitColdArea, 2, 50, 2);
                        break;

                    case 3:
                        ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitPoisonArea, 2, 50, 2);
                        break;

                    case 4:
                        ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitEnergyArea, 2, 50, 2);
                        break;
                    }

                    break;
                }

                case 1:
                {
                    switch (Utility.Random(4))
                    {
                    case 0:
                        ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitMagicArrow, 2, 50, 2);
                        break;

                    case 1:
                        ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitHarm, 2, 50, 2);
                        break;

                    case 2:
                        ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitFireball, 2, 50, 2);
                        break;

                    case 3:
                        ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitLightning, 2, 50, 2);
                        break;
                    }

                    break;
                }

                case 2:
                {
                    switch (Utility.Random(2))
                    {
                    case 0:
                        ApplyAttribute(secondary, min, max, AosWeaponAttribute.UseBestSkill, 1, 1);
                        break;

                    case 1:
                        ApplyAttribute(secondary, min, max, AosWeaponAttribute.MageWeapon, 1, 10);
                        break;
                    }

                    break;
                }

                case 3:
                    int dmgMin = primary.WeaponDamage;
                    int dmgMax = Math.Max(dmgMin, 50);
                    primary.WeaponDamage = 0;
                    ApplyAttribute(primary, min, max, AosAttribute.WeaponDamage, dmgMin, dmgMax);
                    break;

                case 4:
                    ApplyAttribute(primary, min, max, AosAttribute.DefendChance, 1, 15);
                    break;

                case 5:
                    ApplyAttribute(primary, min, max, AosAttribute.CastSpeed, 1, 1);
                    break;

                case 6:
                    ApplyAttribute(primary, min, max, AosAttribute.AttackChance, 1, 15);
                    break;

                case 7:
                    ApplyAttribute(primary, min, max, AosAttribute.Luck, 1, 100);
                    break;

                case 8:
                    ApplyAttribute(primary, min, max, AosAttribute.WeaponSpeed, 5, 30, 5);
                    break;

                case 9:
                    ApplyAttribute(primary, min, max, AosAttribute.SpellChanneling, 1, 1);
                    break;

                case 10:
                    ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitDispel, 2, 50, 2);
                    break;

                case 11:
                    ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitLeechHits, 2, ItemPropertyInfo.GetMaxIntensity(weapon, AosWeaponAttribute.HitLeechHits), 2);
                    break;

                case 12:
                    ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitLowerAttack, 2, 50, 2);
                    break;

                case 13:
                    ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitLowerDefend, 2, 50, 2);
                    break;

                case 14:
                    ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitLeechMana, 2, ItemPropertyInfo.GetMaxIntensity(weapon, AosWeaponAttribute.HitLeechMana), 2);
                    break;

                case 15:
                    ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitLeechStam, 2, 50, 2);
                    break;

                case 16:
                    ApplyAttribute(secondary, min, max, AosWeaponAttribute.LowerStatReq, 10, 100, 10);
                    break;

                case 17:
                    ApplyAttribute(secondary, min, max, AosWeaponAttribute.ResistPhysicalBonus, 1, 15);
                    break;

                case 18:
                    ApplyAttribute(secondary, min, max, AosWeaponAttribute.ResistFireBonus, 1, 15);
                    break;

                case 19:
                    ApplyAttribute(secondary, min, max, AosWeaponAttribute.ResistColdBonus, 1, 15);
                    break;

                case 20:
                    ApplyAttribute(secondary, min, max, AosWeaponAttribute.ResistPoisonBonus, 1, 15);
                    break;

                case 21:
                    ApplyAttribute(secondary, min, max, AosWeaponAttribute.ResistEnergyBonus, 1, 15);
                    break;

                case 22:
                    ApplyAttribute(secondary, min, max, AosWeaponAttribute.DurabilityBonus, 10, 100, 10);
                    break;

                case 23:
                    weapon.Slayer = GetRandomSlayer();
                    break;

                case 24:
                    ApplyElementalDamage(weapon, min, max);
                    break;

                case 25:
                    ((BaseRanged)weapon).Balanced = true;
                    break;

                case 26:
                    ApplyVelocityAttribute((BaseRanged)weapon, min, max, 2, 50, 2);
                    break;
                }
            }
        }