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

public static NewWeapon ( CLRScriptBase script, int maxValue ) : int
script CLRScriptFramework.CLRScriptBase
maxValue int
Результат int
Пример #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;
                }
            }
        }