ACR_Items.GenerateBelt.NewBelt C# (CSharp) Метод

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

public static NewBelt ( CLRScriptBase script, int maxValue ) : int
script CLRScriptFramework.CLRScriptBase
maxValue int
Результат int
        public static int NewBelt(CLRScriptBase script, int maxValue)
        {
            List<int> selectableAbilities = new List<int>();
            foreach (KeyValuePair<int, int> prop in PrimaryAmuletAbility)
            {
                if (prop.Value <= maxValue)
                {
                    selectableAbilities.Add(prop.Key);
                }
            }
            if (selectableAbilities.Count == 0)
            {
                return 0;
            }
            int selectedAbility = selectableAbilities[Generation.rand.Next(selectableAbilities.Count)];
            uint belt = script.CreateItemOnObject("zitem_belt", script.OBJECT_SELF, 1, "", FALSE);
            switch (selectedAbility)
            {
                #region Belt of Shielding
                case ITEM_PROPERTY_AC_BONUS:
                    {
                        if (maxValue >= 50000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyACBonus(5), belt, 0.0f);
                            script.SetFirstName(belt, "Belt of Shielding +5");
                            Pricing.CalculatePrice(script, belt);
                            return 50000;
                        }
                        else if (maxValue >= 32000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyACBonus(4), belt, 0.0f);
                            script.SetFirstName(belt, "Belt of Shielding +4");
                            Pricing.CalculatePrice(script, belt);
                            return 32000;
                        }
                        else if (maxValue >= 18000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyACBonus(3), belt, 0.0f);
                            script.SetFirstName(belt, "Belt of Shielding +3");
                            Pricing.CalculatePrice(script, belt);
                            return 18000;
                        }
                        else if (maxValue >= 8000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyACBonus(2), belt, 0.0f);
                            script.SetFirstName(belt, "Belt of Shielding +2");
                            Pricing.CalculatePrice(script, belt);
                            return 8000;
                        }
                        else if (maxValue >= 2000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyACBonus(1), belt, 0.0f);
                            script.SetFirstName(belt, "Belt of Shielding +1");
                            Pricing.CalculatePrice(script, belt);
                            return 2000;
                        }
                        else
                        {
                            return 0;
                        }
                    }
                #endregion
                #region Ability Bonus
                case ITEM_PROPERTY_ABILITY_BONUS:
                    {
                        int ability = AbilityScores[Generation.rand.Next(AbilityScores.Count)];
                        if (maxValue >= 36000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyAbilityBonus(ability, 6), belt, 0.0f);
                            script.SetFirstName(belt, AbilityScoreNames[ability] + " +6");
                            Pricing.CalculatePrice(script, belt);
                            return 36000;
                        }
                        else if (maxValue >= 25000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyAbilityBonus(ability, 5), belt, 0.0f);
                            script.SetFirstName(belt, AbilityScoreNames[ability] + " +5");
                            Pricing.CalculatePrice(script, belt);
                            return 25000;
                        }
                        else if (maxValue >= 16000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyAbilityBonus(ability, 4), belt, 0.0f);
                            script.SetFirstName(belt, AbilityScoreNames[ability] + " +4");
                            Pricing.CalculatePrice(script, belt);
                            return 16000;
                        }
                        else if (maxValue >= 9000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyAbilityBonus(ability, 3), belt, 0.0f);
                            script.SetFirstName(belt, AbilityScoreNames[ability] + " +3");
                            Pricing.CalculatePrice(script, belt);
                            return 9000;
                        }
                        else if (maxValue >= 4000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyAbilityBonus(ability, 2), belt, 0.0f);
                            script.SetFirstName(belt, AbilityScoreNames[ability] + " +2");
                            Pricing.CalculatePrice(script, belt);
                            return 4000;
                        }
                        else if (maxValue >= 1000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertyAbilityBonus(ability, 1), belt, 0.0f);
                            script.SetFirstName(belt, AbilityScoreNames[ability] + " +1");
                            Pricing.CalculatePrice(script, belt);
                            return 1000;
                        }
                        else
                        {
                            return 0;
                        }
                    }
                #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), belt, 0.0f);
                        script.SetFirstName(belt, ImmunityNames[selectedImmunity]);
                        Pricing.CalculatePrice(script, belt);
                        return AvailableImmunities[selectedImmunity];
                    }
                #endregion
                #region Skill Bonuses
                case ITEM_PROPERTY_SKILL_BONUS:
                    {
                        int skillBonus = AvailableSkills[Generation.rand.Next(AvailableSkills.Count)];
                        script.SetFirstName(belt, SkillNames[skillBonus]);
                        if (maxValue >= 10000)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 10), belt, 0.0f);
                            script.SetFirstName(belt, script.GetName(belt) + " +10");
                            Pricing.CalculatePrice(script, belt);
                            return 10000;
                        }
                        else if (maxValue >= 8100)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 9), belt, 0.0f);
                            script.SetFirstName(belt, script.GetName(belt) + " +9");
                            Pricing.CalculatePrice(script, belt);
                            return 8100;
                        }
                        else if (maxValue >= 6400)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 8), belt, 0.0f);
                            script.SetFirstName(belt, script.GetName(belt) + " +8");
                            Pricing.CalculatePrice(script, belt);
                            return 6400;
                        }
                        else if (maxValue >= 4900)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 7), belt, 0.0f);
                            script.SetFirstName(belt, script.GetName(belt) + " +7");
                            Pricing.CalculatePrice(script, belt);
                            return 4900;
                        }
                        else if (maxValue >= 3600)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 6), belt, 0.0f);
                            script.SetFirstName(belt, script.GetName(belt) + " +6");
                            Pricing.CalculatePrice(script, belt);
                            return 3600;
                        }
                        else if (maxValue >= 2500)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 5), belt, 0.0f);
                            script.SetFirstName(belt, script.GetName(belt) + " +5");
                            Pricing.CalculatePrice(script, belt);
                            return 2500;
                        }
                        else if (maxValue >= 1600)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 4), belt, 0.0f);
                            script.SetFirstName(belt, script.GetName(belt) + " +4");
                            Pricing.CalculatePrice(script, belt);
                            return 1600;
                        }
                        else if (maxValue >= 900)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 3), belt, 0.0f);
                            script.SetFirstName(belt, script.GetName(belt) + " +3");
                            Pricing.CalculatePrice(script, belt);
                            return 900;
                        }
                        else if (maxValue >= 400)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 2), belt, 0.0f);
                            script.SetFirstName(belt, script.GetName(belt) + " +2");
                            Pricing.CalculatePrice(script, belt);
                            return 400;
                        }
                        else if (maxValue >= 100)
                        {
                            script.AddItemProperty(DURATION_TYPE_PERMANENT, script.ItemPropertySkillBonus(skillBonus, 1), belt, 0.0f);
                            script.SetFirstName(belt, script.GetName(belt) + " +1");
                            Pricing.CalculatePrice(script, belt);
                            return 100;
                        }
                        break;
                    }
                #endregion
            }
            script.DestroyObject(belt, 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;
                }
            }
        }
GenerateBelt