ACR_Items.GenerateRing.NewRing C# (CSharp) Метод

NewRing() публичный статический Метод

public static NewRing ( CLRScriptBase script, int maxValue ) : int
script CLRScriptBase
maxValue int
Результат int
        public static int NewRing(CLRScriptBase script, int maxValue)
        {
            List<int> potentialAbilities = new List<int>();
            foreach (KeyValuePair<int, int> ability in AvailableAbilities)
            {
                if (ability.Value <= maxValue)
                {
                    potentialAbilities.Add(ability.Key);
                }
            }
            if (potentialAbilities.Count == 0)
            {
                return 0;
            }
            int selectedAbility = potentialAbilities[Generation.rand.Next(potentialAbilities.Count)];
            uint ring = script.CreateItemOnObject("nw_it_mring021", script.OBJECT_SELF, 1, "", FALSE);
            switch (selectedAbility)
            {
                #region Rings of Deflection
                case ITEM_PROPERTY_AC_BONUS:
                    {
                        string name = AbilityNames[selectedAbility];
                        if (maxValue >= 50000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyACBonus(5), ring, 0.0f);
                            script.SetFirstName(ring, name + " +5");
                            Pricing.CalculatePrice(script, ring);
                            return 50000;
                        }
                        else if (maxValue >= 32000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyACBonus(4), ring, 0.0f);
                            script.SetFirstName(ring, name + " +4");
                            Pricing.CalculatePrice(script, ring);
                            return 32000;
                        }
                        else if (maxValue >= 18000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyACBonus(3), ring, 0.0f);
                            script.SetFirstName(ring, name + " +3");
                            Pricing.CalculatePrice(script, ring);
                            return 18000;
                        }
                        else if (maxValue >= 8000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyACBonus(2), ring, 0.0f);
                            script.SetFirstName(ring, name + " +2");
                            Pricing.CalculatePrice(script, ring);
                            return 8000;
                        }
                        else if (maxValue >= 2000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyACBonus(1), ring, 0.0f);
                            script.SetFirstName(ring, name + " +1");
                            Pricing.CalculatePrice(script, ring);
                            return 2000;
                        }
                        else
                        {
                            return 0;
                        }
                    }
                #endregion
                #region Rings of Ability Scores
                case ITEM_PROPERTY_ABILITY_BONUS:
                    {
                        int abilityScore = AvailableAbilityScores[Generation.rand.Next(AvailableAbilityScores.Count)];
                        string name = AbilityScoreNames[abilityScore];
                        if (maxValue >= 36000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyAbilityBonus(abilityScore, 6), ring, 0.0f);
                            script.SetFirstName(ring, name + " +6");
                            Pricing.CalculatePrice(script, ring);
                            return 36000;
                        }
                        else if (maxValue >= 25000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyAbilityBonus(abilityScore, 5), ring, 0.0f);
                            script.SetFirstName(ring, name + " +5");
                            Pricing.CalculatePrice(script, ring);
                            return 25000;
                        }
                        else if (maxValue >= 16000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyAbilityBonus(abilityScore, 4), ring, 0.0f);
                            script.SetFirstName(ring, name + " +4");
                            Pricing.CalculatePrice(script, ring);
                            return 16000;
                        }
                        else if (maxValue >= 9000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyAbilityBonus(abilityScore, 3), ring, 0.0f);
                            script.SetFirstName(ring, name + " +3");
                            Pricing.CalculatePrice(script, ring);
                            return 9000;
                        }
                        else if (maxValue >= 4000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyAbilityBonus(abilityScore, 2), ring, 0.0f);
                            script.SetFirstName(ring, name + " +2");
                            Pricing.CalculatePrice(script, ring);
                            return 4000;
                        }
                        else if (maxValue >= 1000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyAbilityBonus(abilityScore, 1), ring, 0.0f);
                            script.SetFirstName(ring, name + " +1");
                            Pricing.CalculatePrice(script, ring);
                            return 1000;
                        }
                        else
                        {
                            return 0;
                        }
                    }
                #endregion
                #region Rings with Bonus Feats
                case ITEM_PROPERTY_BONUS_FEAT:
                    {
                        List<int> possibleFeats = new List<int>();
                        foreach (KeyValuePair<int, int> feat in AvailableFeats)
                        {
                            if (feat.Value <= maxValue)
                            {
                                possibleFeats.Add(feat.Key);
                            }
                        }
                        if (possibleFeats.Count == 0)
                        {
                            return 0;
                        }
                        int selectedFeat = possibleFeats[Generation.rand.Next(possibleFeats.Count)];
                        script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusFeat(selectedFeat), ring, 0.0f);
                        script.SetFirstName(ring, FeatNames[selectedFeat]);
                        Pricing.CalculatePrice(script, ring);
                        return AvailableFeats[selectedFeat];
                    }
                #endregion
                #region Bonus Spell Slots
                case ITEM_PROPERTY_BONUS_SPELL_SLOT_OF_LEVEL_N:
                    {
                        int bonusType = AvailableBonusSpells[Generation.rand.Next(AvailableBonusSpells.Count)];
                        string name = BonusSpellNames[bonusType];
                        if (maxValue >= 81000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusLevelSpell(bonusType, IP_CONST_SPELLLEVEL_9), ring, 0.0f);
                            script.SetFirstName(ring, name + " IX");
                            Pricing.CalculatePrice(script, ring);
                            return 81000;
                        }
                        else if (maxValue >= 64000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusLevelSpell(bonusType, IP_CONST_SPELLLEVEL_8), ring, 0.0f);
                            script.SetFirstName(ring, name + " VIII");
                            Pricing.CalculatePrice(script, ring);
                            return 64000;
                        }
                        else if (maxValue >= 49000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusLevelSpell(bonusType, IP_CONST_SPELLLEVEL_7), ring, 0.0f);
                            script.SetFirstName(ring, name + " VII");
                            Pricing.CalculatePrice(script, ring);
                            return 49000;
                        }
                        else if (maxValue >= 36000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusLevelSpell(bonusType, IP_CONST_SPELLLEVEL_6), ring, 0.0f);
                            script.SetFirstName(ring, name + " VI");
                            Pricing.CalculatePrice(script, ring);
                            return 36000;
                        }
                        else if (maxValue >= 25000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusLevelSpell(bonusType, IP_CONST_SPELLLEVEL_5), ring, 0.0f);
                            script.SetFirstName(ring, name + " V");
                            Pricing.CalculatePrice(script, ring);
                            return 25000;
                        }
                        else if (maxValue >= 16000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusLevelSpell(bonusType, IP_CONST_SPELLLEVEL_4), ring, 0.0f);
                            script.SetFirstName(ring, name + " IV");
                            Pricing.CalculatePrice(script, ring);
                            return 16000;
                        }
                        else if (maxValue >= 9000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusLevelSpell(bonusType, IP_CONST_SPELLLEVEL_3), ring, 0.0f);
                            script.SetFirstName(ring, name + " III");
                            Pricing.CalculatePrice(script, ring);
                            return 9000;
                        }
                        else if (maxValue >= 4000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusLevelSpell(bonusType, IP_CONST_SPELLLEVEL_2), ring, 0.0f);
                            script.SetFirstName(ring, name + " II");
                            Pricing.CalculatePrice(script, ring);
                            return 4000;
                        }
                        else if (maxValue >= 1000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusLevelSpell(bonusType, IP_CONST_SPELLLEVEL_1), ring, 0.0f);
                            script.SetFirstName(ring, name + " I");
                            Pricing.CalculatePrice(script, ring);
                            return 1000;
                        }
                        else if (maxValue >= 500)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusLevelSpell(bonusType, IP_CONST_SPELLLEVEL_0), ring, 0.0f);
                            script.SetFirstName(ring, name + " 0");
                            Pricing.CalculatePrice(script, ring);
                            return 500;
                        }
                        else
                        {
                            return 0;
                        }
                    }
                #endregion
                #region Damage Resistance
                case ITEM_PROPERTY_DAMAGE_RESISTANCE:
                    {
                        int damageResistType = DamageResistances[Generation.rand.Next(DamageResistances.Count)];
                        if (damageResistType == IP_CONST_DAMAGETYPE_NEGATIVE &&
                            maxValue < 6000)
                        {
                            int attempts = 0;
                            while (damageResistType == IP_CONST_DAMAGETYPE_NEGATIVE)
                            {
                                damageResistType = DamageResistances[Generation.rand.Next(DamageResistances.Count)];
                                attempts++;
                                if (attempts == 10)
                                {
                                    // something is wrong. Break out and just go with fire or something.
                                    damageResistType = IP_CONST_DAMAGETYPE_FIRE;
                                    break;
                                }
                            }
                        }
                        if (damageResistType == IP_CONST_DAMAGETYPE_NEGATIVE)
                        {
                            if (maxValue >= 66000)
                            {
                                script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyDamageResistance(damageResistType, IP_CONST_DAMAGERESIST_30), ring, 0.0f);
                                script.SetFirstName(ring, DamageResistanceNames[damageResistType] + ", 30");
                                Pricing.CalculatePrice(script, ring);
                                return 66000;
                            }
                            else if (maxValue >= 54000)
                            {
                                script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyDamageResistance(damageResistType, IP_CONST_DAMAGERESIST_25), ring, 0.0f);
                                script.SetFirstName(ring, DamageResistanceNames[damageResistType] + ", 25");
                                Pricing.CalculatePrice(script, ring);
                                return 54000;
                            }
                            else if (maxValue >= 42000)
                            {
                                script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyDamageResistance(damageResistType, IP_CONST_DAMAGERESIST_20), ring, 0.0f);
                                script.SetFirstName(ring, DamageResistanceNames[damageResistType] + ", 20");
                                Pricing.CalculatePrice(script, ring);
                                return 42000;
                            }
                            else if (maxValue >= 30000)
                            {
                                script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyDamageResistance(damageResistType, IP_CONST_DAMAGERESIST_15), ring, 0.0f);
                                script.SetFirstName(ring, DamageResistanceNames[damageResistType] + ", 15");
                                Pricing.CalculatePrice(script, ring);
                                return 30000;
                            }
                            else if (maxValue >= 18000)
                            {
                                script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyDamageResistance(damageResistType, IP_CONST_DAMAGERESIST_10), ring, 0.0f);
                                script.SetFirstName(ring, DamageResistanceNames[damageResistType] + ", 10");
                                Pricing.CalculatePrice(script, ring);
                                return 18000;
                            }
                            else if (maxValue >= 6000)
                            {
                                script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyDamageResistance(damageResistType, IP_CONST_DAMAGERESIST_5), ring, 0.0f);
                                script.SetFirstName(ring, DamageResistanceNames[damageResistType] + ", 5");
                                Pricing.CalculatePrice(script, ring);
                                return 6000;
                            }
                        }
                        else
                        {
                            if (maxValue >= 44000)
                            {
                                script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyDamageResistance(damageResistType, IP_CONST_DAMAGERESIST_30), ring, 0.0f);
                                script.SetFirstName(ring, DamageResistanceNames[damageResistType] + ", 30");
                                Pricing.CalculatePrice(script, ring);
                                return 44000;
                            }
                            else if (maxValue >= 36000)
                            {
                                script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyDamageResistance(damageResistType, IP_CONST_DAMAGERESIST_25), ring, 0.0f);
                                script.SetFirstName(ring, DamageResistanceNames[damageResistType] + ", 25");
                                Pricing.CalculatePrice(script, ring);
                                return 36000;
                            }
                            else if (maxValue >= 28000)
                            {
                                script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyDamageResistance(damageResistType, IP_CONST_DAMAGERESIST_20), ring, 0.0f);
                                script.SetFirstName(ring, DamageResistanceNames[damageResistType] + ", 20");
                                Pricing.CalculatePrice(script, ring);
                                return 28000;
                            }
                            else if (maxValue >= 20000)
                            {
                                script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyDamageResistance(damageResistType, IP_CONST_DAMAGERESIST_15), ring, 0.0f);
                                script.SetFirstName(ring, DamageResistanceNames[damageResistType] + ", 15");
                                Pricing.CalculatePrice(script, ring);
                                return 20000;
                            }
                            else if (maxValue >= 12000)
                            {
                                script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyDamageResistance(damageResistType, IP_CONST_DAMAGERESIST_10), ring, 0.0f);
                                script.SetFirstName(ring, DamageResistanceNames[damageResistType] + ", 10");
                                Pricing.CalculatePrice(script, ring);
                                return 12000;
                            }
                            else if (maxValue >= 4000)
                            {
                                script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyDamageResistance(damageResistType, IP_CONST_DAMAGERESIST_5), ring, 0.0f);
                                script.SetFirstName(ring, DamageResistanceNames[damageResistType] + ", 5");
                                Pricing.CalculatePrice(script, ring);
                                return 4000;
                            }
                        }
                        break;
                    }
                #endregion
                #region Freedom of Movement
                case ITEM_PROPERTY_FREEDOM_OF_MOVEMENT:
                    {
                        script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyFreeAction(), ring, 0.0f);
                        script.SetFirstName(ring, "Ring of Freedom");
                        Pricing.CalculatePrice(script, ring);
                        return 40000;
                    }
                #endregion
                #region Immunities
                case ITEM_PROPERTY_IMMUNITY_MISCELLANEOUS:
                    {
                        List<int> possibleImmunities = new List<int>();
                        foreach (KeyValuePair<int, int> immunity in AvailableImmunities)
                        {
                            if (immunity.Value <= maxValue)
                            {
                                possibleImmunities.Add(immunity.Key);
                            }
                        }
                        if (possibleImmunities.Count == 0)
                        {
                            return 0;
                        }
                        int selectedImmunity = possibleImmunities[Generation.rand.Next(possibleImmunities.Count)];
                        script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyImmunityMisc(selectedImmunity), ring, 0.0f);
                        script.SetFirstName(ring, ImmunityNames[selectedImmunity]);
                        Pricing.CalculatePrice(script, ring);
                        return AvailableImmunities[selectedImmunity];
                    }
                #endregion
                #region Light
                case ITEM_PROPERTY_LIGHT:
                    {
                        int lightColor = LightColors[Generation.rand.Next(LightColors.Count)]; ;
                        script.SetFirstName(ring, AbilityNames[selectedAbility]);
                        if (maxValue >= 400)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyLight(IP_CONST_LIGHTBRIGHTNESS_BRIGHT, lightColor), ring, 0.0f);
                            Pricing.CalculatePrice(script, ring);
                            return 400;
                        }
                        else if (maxValue >= 300)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyLight(IP_CONST_LIGHTBRIGHTNESS_NORMAL, lightColor), ring, 0.0f);
                            Pricing.CalculatePrice(script, ring);
                            return 300;
                        }
                        else if (maxValue >= 200)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyLight(IP_CONST_LIGHTBRIGHTNESS_LOW, lightColor), ring, 0.0f);
                            Pricing.CalculatePrice(script, ring);
                            return 200;
                        }
                        else if (maxValue >= 100)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyLight(IP_CONST_LIGHTBRIGHTNESS_DIM, lightColor), ring, 0.0f);
                            Pricing.CalculatePrice(script, ring);
                            return 100;
                        }
                        else
                        {
                            return 0;
                        }
                    }
                #endregion
                #region Saving Throws
                case ITEM_PROPERTY_SAVING_THROW_BONUS:
                    {
                        if (maxValue >= 25000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSavingThrowVsX(IP_CONST_SAVEVS_UNIVERSAL, 5), ring, 0.0f);
                            script.SetFirstName(ring, "Ring of Resistance +5");
                            Pricing.CalculatePrice(script, ring);
                            return 25000;
                        }
                        else if (maxValue >= 16000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSavingThrowVsX(IP_CONST_SAVEVS_UNIVERSAL, 4), ring, 0.0f);
                            script.SetFirstName(ring, "Ring of Resistance +4");
                            Pricing.CalculatePrice(script, ring);
                            return 16000;
                        }
                        else if (maxValue >= 9000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSavingThrowVsX(IP_CONST_SAVEVS_UNIVERSAL, 3), ring, 0.0f);
                            script.SetFirstName(ring, "Ring of Resistance +3");
                            Pricing.CalculatePrice(script, ring);
                            return 9000;
                        }
                        else if (maxValue >= 4000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSavingThrowVsX(IP_CONST_SAVEVS_UNIVERSAL, 2), ring, 0.0f);
                            script.SetFirstName(ring, "Ring of Resistance +2");
                            Pricing.CalculatePrice(script, ring);
                            return 4000;
                        }
                        else if (maxValue >= 1000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSavingThrowVsX(IP_CONST_SAVEVS_UNIVERSAL, 1), ring, 0.0f);
                            script.SetFirstName(ring, "Ring of Resistance +1");
                            Pricing.CalculatePrice(script, ring);
                            return 1000;
                        }
                        else
                        {
                            return 0;
                        }
                    }
                #endregion
                #region Saving Throws vs. Specific
                case ITEM_PROPERTY_SAVING_THROW_BONUS_SPECIFIC:
                    {
                        int saveType = AvailableSaveTypes[Generation.rand.Next(AvailableSaveTypes.Count)];
                        script.SetFirstName(ring, SaveTypeNames[saveType]);
                        if (maxValue >= 6250)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSavingThrowVsX(saveType, 5), ring, 0.0f);
                            script.SetFirstName(ring, String.Format("{0} +5", script.GetName(ring)));
                            Pricing.CalculatePrice(script, ring);
                            return 6250;
                        }
                        else if (maxValue >= 4000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSavingThrowVsX(saveType, 4), ring, 0.0f);
                            script.SetFirstName(ring, String.Format("{0} +4", script.GetName(ring)));
                            Pricing.CalculatePrice(script, ring);
                            return 4000;
                        }
                        else if (maxValue >= 2250)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSavingThrowVsX(saveType, 3), ring, 0.0f);
                            script.SetFirstName(ring, String.Format("{0} +3", script.GetName(ring)));
                            Pricing.CalculatePrice(script, ring);
                            return 2250;
                        }
                        else if (maxValue >= 1000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSavingThrowVsX(saveType, 2), ring, 0.0f);
                            script.SetFirstName(ring, String.Format("{0} +2", script.GetName(ring)));
                            Pricing.CalculatePrice(script, ring);
                            return 1000;
                        }
                        else if (maxValue >= 250)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSavingThrowVsX(saveType, 1), ring, 0.0f);
                            script.SetFirstName(ring, String.Format("{0} +1", script.GetName(ring)));
                            Pricing.CalculatePrice(script, ring);
                            return 250;
                        }
                        break;
                    }
                #endregion
                #region Skill Bonus
                case ITEM_PROPERTY_SKILL_BONUS:
                    {
                        int skillBonus = AvailableSkills[Generation.rand.Next(AvailableSkills.Count)];
                        script.SetFirstName(ring, SkillNames[skillBonus]);
                        if (maxValue >= 10000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 10), ring, 0.0f);
                            script.SetFirstName(ring, script.GetName(ring) + " +10");
                            Pricing.CalculatePrice(script, ring);
                            return 10000;
                        }
                        else if (maxValue >= 8100)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 9), ring, 0.0f);
                            script.SetFirstName(ring, script.GetName(ring) + " +9");
                            Pricing.CalculatePrice(script, ring);
                            return 8100;
                        }
                        else if (maxValue >= 6400)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 8), ring, 0.0f);
                            script.SetFirstName(ring, script.GetName(ring) + " +8");
                            Pricing.CalculatePrice(script, ring);
                            return 6400;
                        }
                        else if (maxValue >= 4900)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 7), ring, 0.0f);
                            script.SetFirstName(ring, script.GetName(ring) + " +7");
                            Pricing.CalculatePrice(script, ring);
                            return 4900;
                        }
                        else if (maxValue >= 3600)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 6), ring, 0.0f);
                            script.SetFirstName(ring, script.GetName(ring) + " +6");
                            Pricing.CalculatePrice(script, ring);
                            return 3600;
                        }
                        else if (maxValue >= 2500)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 5), ring, 0.0f);
                            script.SetFirstName(ring, script.GetName(ring) + " +5");
                            Pricing.CalculatePrice(script, ring);
                            return 2500;
                        }
                        else if (maxValue >= 1600)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 4), ring, 0.0f);
                            script.SetFirstName(ring, script.GetName(ring) + " +4");
                            Pricing.CalculatePrice(script, ring);
                            return 1600;
                        }
                        else if (maxValue >= 900)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 3), ring, 0.0f);
                            script.SetFirstName(ring, script.GetName(ring) + " +3");
                            Pricing.CalculatePrice(script, ring);
                            return 900;
                        }
                        else if (maxValue >= 400)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 2), ring, 0.0f);
                            script.SetFirstName(ring, script.GetName(ring) + " +2");
                            Pricing.CalculatePrice(script, ring);
                            return 400;
                        }
                        else if (maxValue >= 100)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 1), ring, 0.0f);
                            script.SetFirstName(ring, script.GetName(ring) + " +1");
                            Pricing.CalculatePrice(script, ring);
                            return 100;
                        }
                        else
                        {
                            return 0;
                        }
                    }
                #endregion
                #region Spell Resistance
                case ITEM_PROPERTY_SPELL_RESISTANCE:
                    {
                        if (maxValue >= 140000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_26), ring, 0.0f);
                            script.SetFirstName(ring, "Ring of Spell Resistance, 26");
                            Pricing.CalculatePrice(script, ring);
                            return 140000;
                        }
                        else if (maxValue >= 120000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_24), ring, 0.0f);
                            script.SetFirstName(ring, "Ring of Spell Resistance, 24");
                            Pricing.CalculatePrice(script, ring);
                            return 120000;
                        }
                        else if (maxValue >= 100000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_22), ring, 0.0f);
                            script.SetFirstName(ring, "Ring of Spell Resistance, 22");
                            Pricing.CalculatePrice(script, ring);
                            return 100000;
                        }
                        else if (maxValue >= 80000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_20), ring, 0.0f);
                            script.SetFirstName(ring, "Ring of Spell Resistance, 20");
                            Pricing.CalculatePrice(script, ring);
                            return 80000;
                        }
                        else if (maxValue >= 60000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_18), ring, 0.0f);
                            script.SetFirstName(ring, "Ring of Spell Resistance, 18");
                            Pricing.CalculatePrice(script, ring);
                            return 60000;
                        }
                        else if (maxValue >= 40000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_16), ring, 0.0f);
                            script.SetFirstName(ring, "Ring of Spell Resistance, 16");
                            Pricing.CalculatePrice(script, ring);
                            return 40000;
                        }
                        else if (maxValue >= 20000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_14), ring, 0.0f);
                            script.SetFirstName(ring, "Ring of Spell Resistance, 14");
                            Pricing.CalculatePrice(script, ring);
                            return 20000;
                        }
                        else if (maxValue >= 10000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_12), ring, 0.0f);
                            script.SetFirstName(ring, "Ring of Spell Resistance, 12");
                            Pricing.CalculatePrice(script, ring);
                            return 10000;
                        }
                        else if (maxValue >= 6000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_10), ring, 0.0f);
                            script.SetFirstName(ring, "Ring of Spell Resistance, 10");
                            Pricing.CalculatePrice(script, ring);
                            return 6000;
                        }
                        else
                        {
                            return 0;
                        }
                    }
                #endregion
            }
            script.DestroyObject(ring, 0.0f, FALSE);
            return 0;
        }

Usage Example

Пример #1
0
        public static void GenerateLoot(CLRScriptBase script, int lootValue, int maxItemValue)
        {
            if (lootValue < 1)
            {
                return;
            }

            if (maxItemValue < 1)
            {
                maxItemValue = lootValue;
            }

            // For expensive caches, favor magic that is going to be most-commonly crafted.
            while (lootValue > 1000)
            {
                if (maxItemValue > lootValue)
                {
                    maxItemValue = lootValue;
                }
                switch (script.d10(1))
                {
                case 1:
                {
                    lootValue -= GenerateArt(script, maxItemValue);
                    break;
                }

                default:
                {
                    int roll     = script.d100(1);
                    int decrease = 0;
                    if (roll > 82)
                    {
                        decrease   = GenerateScroll.NewScroll(script, maxItemValue);       // 81-100
                        lootValue -= decrease;
                    }
                    else if (roll > 65)
                    {
                        decrease   = GeneratePotion.NewPotion(script, maxItemValue);       // 66-80
                        lootValue -= decrease;
                    }
                    else if (roll > 55)
                    {
                        decrease   = GenerateWand.NewWand(script, maxItemValue);       // 56-65
                        lootValue -= decrease;
                    }
                    else if (roll > 52)
                    {
                        decrease   = GenerateStaff.NewStaff(script, maxItemValue);       // 53-55
                        lootValue -= decrease;
                    }
                    else if (roll > 50)
                    {
                        decrease   = GenerateRod.NewRod(script, maxItemValue);       // 51-52
                        lootValue -= decrease;
                    }
                    else if (roll > 42)
                    {
                        decrease   = GenerateArmor.NewArmor(script, maxItemValue);       // 43-50
                        lootValue -= decrease;
                    }
                    else if (roll > 35)
                    {
                        decrease   = GenerateWeapon.NewWeapon(script, maxItemValue);       // 36-42
                        lootValue -= decrease;
                    }
                    else if (roll > 30)
                    {
                        decrease   = GenerateAmulet.NewAmulet(script, maxItemValue);       // 31-35
                        lootValue -= decrease;
                    }
                    else if (roll > 25)
                    {
                        decrease   = GenerateBelt.NewBelt(script, maxItemValue);       // 26-30
                        lootValue -= decrease;
                    }
                    else if (roll > 20)
                    {
                        decrease   = GenerateBoots.NewBoots(script, maxItemValue);       // 21-25
                        lootValue -= decrease;
                    }
                    else if (roll > 15)
                    {
                        decrease   = GenerateCloak.NewCloak(script, maxItemValue);       // 16-20
                        lootValue -= decrease;
                    }
                    else if (roll > 10)
                    {
                        decrease   = GenerateHelmet.NewHelmet(script, maxItemValue);       // 11-15
                        lootValue -= decrease;
                    }
                    else if (roll > 5)
                    {
                        decrease   = GenerateRing.NewRing(script, maxItemValue);       // 6-10
                        lootValue -= decrease;
                    }
                    else
                    {
                        decrease   = GenerateGloves.NewGloves(script, maxItemValue);       // 1-5
                        lootValue -= decrease;
                    }
                    break;
                }
                }
                if (lootValue < 10)
                {
                    script.CreateItemOnObject("nw_it_gold001", script.OBJECT_SELF, lootValue, "", FALSE);
                    return;
                }
                if (script.d100(1) > 95)
                {
                    script.CreateItemOnObject("nw_it_gold001", script.OBJECT_SELF, maxItemValue / 10, "", FALSE);
                    lootValue -= maxItemValue / 10;
                }
            }

            // For cheap loot or to clean up big caches, use more weapons and armor.
            while (lootValue > 0)
            {
                if (maxItemValue > lootValue)
                {
                    maxItemValue = lootValue;
                }
                switch (script.d10(1))
                {
                case 1:
                {
                    lootValue -= GenerateArt(script, maxItemValue);
                    break;
                }

                default:
                {
                    int roll     = script.d100(1);
                    int decrease = 0;
                    if (roll > 91)
                    {
                        decrease   = GenerateScroll.NewScroll(script, maxItemValue);       // 83-100
                        lootValue -= decrease;
                    }
                    else if (roll > 82)
                    {
                        decrease   = GeneratePotion.NewPotion(script, maxItemValue);       // 61-82
                        lootValue -= decrease;
                    }
                    else if (roll > 60)
                    {
                        decrease   = GenerateArmor.NewArmor(script, maxItemValue);       // 61-82
                        lootValue -= decrease;
                    }
                    else if (roll > 21)
                    {
                        decrease   = GenerateWeapon.NewWeapon(script, maxItemValue);       // 22-59
                        lootValue -= decrease;
                    }
                    else if (roll > 18)
                    {
                        decrease   = GenerateAmulet.NewAmulet(script, maxItemValue);       // 19-21
                        lootValue -= decrease;
                    }
                    else if (roll > 15)
                    {
                        decrease   = GenerateBelt.NewBelt(script, maxItemValue);       // 16-18
                        lootValue -= decrease;
                    }
                    else if (roll > 12)
                    {
                        decrease   = GenerateBoots.NewBoots(script, maxItemValue);       // 13-15
                        lootValue -= decrease;
                    }
                    else if (roll > 9)
                    {
                        decrease   = GenerateCloak.NewCloak(script, maxItemValue);       // 10-12
                        lootValue -= decrease;
                    }
                    else if (roll > 6)
                    {
                        decrease   = GenerateHelmet.NewHelmet(script, maxItemValue);       // 7-9
                        lootValue -= decrease;
                    }
                    else if (roll > 3)
                    {
                        decrease   = GenerateRing.NewRing(script, maxItemValue);       // 4-6
                        lootValue -= decrease;
                    }
                    else
                    {
                        decrease   = GenerateGloves.NewGloves(script, maxItemValue);       // 1-3
                        lootValue -= decrease;
                    }
                    break;
                }
                }
                if (lootValue < 10)
                {
                    script.CreateItemOnObject("nw_it_gold001", script.OBJECT_SELF, lootValue, "", FALSE);
                    return;
                }
                if (script.d100(1) > 95)
                {
                    script.CreateItemOnObject("nw_it_gold001", script.OBJECT_SELF, maxItemValue / 10, "", FALSE);
                    lootValue -= maxItemValue / 10;
                }
            }
        }
GenerateRing