コード例 #1
0
        internal static RuneAbstract CreateRune(int wearflags, int specials, int level, int quality, string name)
        {
            int   difficulty = StateHandler.Difficulty;
            float mod;

            mod = (difficulty + 1) * 0.25f;

            mod = (quality + 1) * 0.25f;

            int runeLevel = (int)(level * mod) / 10;

            if (runeLevel < 1)
            {
                runeLevel = 1;
            }

            int max = 2 + ((quality + Globals.Random(0, 3)) / 3);

            if (quality < 1 || level < 1)
            {
                max       = 1;
                runeLevel = 1;
            }

            SpellAbstract[] spells = new SpellAbstract[max];

            int element;

            if (!Globals.IS_SET(specials, Globals.ELEMENT_FIRE) &&
                !Globals.IS_SET(specials, Globals.ELEMENT_WATER) &&
                !Globals.IS_SET(specials, Globals.ELEMENT_NATURE))
            {
                int chance = Globals.Random(0, 100);
                if (chance < 34)
                {
                    element = Globals.ELEMENT_FIRE;
                }
                else if (chance < 67)
                {
                    element = Globals.ELEMENT_NATURE;
                }
                else
                {
                    element = Globals.ELEMENT_WATER;
                }
            }

            if (Globals.IS_SET(specials, Globals.ELEMENT_FIRE))
            {
                element = Globals.ELEMENT_FIRE;
            }
            else if (Globals.IS_SET(specials, Globals.ELEMENT_NATURE))
            {
                element = Globals.ELEMENT_NATURE;
            }
            else if (Globals.IS_SET(specials, Globals.ELEMENT_WATER))
            {
                element = Globals.ELEMENT_WATER;
            }
            else
            {
                int chance = Globals.Random(0, 100);
                if (chance < 34)
                {
                    element = Globals.ELEMENT_FIRE;
                }
                else if (chance < 67)
                {
                    element = Globals.ELEMENT_NATURE;
                }
                else
                {
                    element = Globals.ELEMENT_WATER;
                }
            }

            for (int i = 0; i < spells.Length; i++)
            {
                switch (element)
                {
                case Globals.ELEMENT_NATURE:
                    spells[i] = new SpellNature(i + runeLevel);
                    break;

                case Globals.ELEMENT_FIRE:
                    spells[i] = new SpellFire(i + runeLevel);
                    break;

                case Globals.ELEMENT_WATER:
                default:
                    spells[i] = new SpellWater(i + runeLevel);
                    break;
                }
            }

            int[] cost = new int[max];

            int curCost = runeLevel * 50 + 500;

            for (int i = 0; i < max; i++)
            {
                if (i > 0)
                {
                    cost[i] = cost[i - 1] * 2 + i * curCost;
                }
                else
                {
                    cost[i] = curCost;
                }
            }

            RuneAbstract runeTemp = new RuneAbstract(cost, spells);

            runeTemp.Wearflags = wearflags;

            if (name != null && name.Length > 2)
            {
                runeTemp.Name = name;
            }
            else
            {
                switch (element)
                {
                case Globals.ELEMENT_NATURE:
                    runeTemp.Name = "Nature Rune " + runeLevel;
                    break;

                case Globals.ELEMENT_FIRE:
                    runeTemp.Name = "Fire Rune " + runeLevel;
                    break;

                case Globals.ELEMENT_WATER:
                default:
                    runeTemp.Name = "Water Rune " + runeLevel;
                    break;
                }
            }

            return(runeTemp);
        }
コード例 #2
0
        internal static RuneAbstract CreateRune(int wearflags, int specials, int level, int quality, string name)
        {
            int difficulty = StateHandler.Difficulty;
            float mod;

            mod = (difficulty + 1) * 0.25f;

            mod = (quality + 1) * 0.25f;

            int runeLevel = (int)(level * mod) / 10;

            if (runeLevel < 1)
                runeLevel = 1;

            int max = 2 + ((quality + Globals.Random(0, 3)) / 3);

            if (quality < 1 || level < 1)
            {
                max = 1;
                runeLevel = 1;
            }

            SpellAbstract[] spells = new SpellAbstract[max];

            int element;

            if (!Globals.IS_SET(specials, Globals.ELEMENT_FIRE) &&
                !Globals.IS_SET(specials, Globals.ELEMENT_WATER) &&
                !Globals.IS_SET(specials, Globals.ELEMENT_NATURE))
            {
                int chance = Globals.Random(0, 100);
                if (chance < 34)
                    element = Globals.ELEMENT_FIRE;
                else if (chance < 67)
                    element = Globals.ELEMENT_NATURE;
                else
                    element = Globals.ELEMENT_WATER;
            }

            if (Globals.IS_SET(specials, Globals.ELEMENT_FIRE))
                element = Globals.ELEMENT_FIRE;
            else if (Globals.IS_SET(specials, Globals.ELEMENT_NATURE))
                element = Globals.ELEMENT_NATURE;
            else if (Globals.IS_SET(specials, Globals.ELEMENT_WATER))
                element = Globals.ELEMENT_WATER;
            else
            {
                int chance = Globals.Random(0,100);
                if (chance < 34)
                    element = Globals.ELEMENT_FIRE;
                else if (chance < 67)
                    element = Globals.ELEMENT_NATURE;
                else
                    element = Globals.ELEMENT_WATER;
            }

            for (int i = 0; i < spells.Length; i++)
            {
                switch(element)
                {
                    case Globals.ELEMENT_NATURE:
                        spells[i] = new SpellNature(i+ runeLevel);
                        break;
                    case Globals.ELEMENT_FIRE:
                        spells[i] = new SpellFire(i + runeLevel);
                        break;
                    case Globals.ELEMENT_WATER: default:
                        spells[i] = new SpellWater(i + runeLevel);
                        break;
                }
            }

            int[] cost = new int[max];

            int curCost = runeLevel * 50 + 500;

            for (int i = 0; i < max; i++)
            {
                if (i > 0)
                    cost[i] = cost[i-1]*2 + i * curCost;
                else
                    cost[i] = curCost;
            }

            RuneAbstract runeTemp = new RuneAbstract(cost, spells);

            runeTemp.Wearflags = wearflags;

            if (name != null && name.Length > 2)
                runeTemp.Name = name;
            else
            {
                switch (element)
                {
                    case Globals.ELEMENT_NATURE:
                        runeTemp.Name = "Nature Rune " + runeLevel;
                        break;
                    case Globals.ELEMENT_FIRE:
                        runeTemp.Name = "Fire Rune " + runeLevel;
                        break;
                    case Globals.ELEMENT_WATER: default:
                        runeTemp.Name = "Water Rune " + runeLevel;
                        break;
                }
            }

            return runeTemp;
        }