Esempio n. 1
0
    // calculate price. calculate effects based on native effects + magic effects.
    public void UpdateItem()
    {
        if (Class == null || Class.IsMoney)
        {
            return;
        }

        // concat native and magic effects
        Effects.Clear();
        Effects.AddRange(NativeEffects);
        Effects.AddRange(MagicEffects);

        // base price.
        Price = Class.Price;

        /*
         * if (!Class.IsSpecial)
         * {
         *  Price = (int)(Price * Class.Class.Price);
         *  Price = (int)(Price * Class.Material.Price);
         * }
         */

        int manaUsage = 0;

        for (int i = 0; i < Effects.Count; i++)
        {
            Templates.TplModifier modifier = TemplateLoader.GetModifierById((int)Effects[i].Type1);
            if (modifier == null)
            {
                continue; // wtf was that lol.
            }
            manaUsage += modifier.ManaCost;
        }

        Price = Math.Max(Price, (int)(Price * ((float)manaUsage / 10)));

        // search for override price effect
        for (int i = 0; i < Effects.Count; i++)
        {
            if (Effects[i].Type1 == ItemEffect.Effects.Price)
            {
                Price = Effects[i].Value1;
            }
        }

        if (Price < 2)
        {
            Price = 2; // min price
        }
    }
Esempio n. 2
0
    // calculate price. calculate effects based on native effects + magic effects.
    public void UpdateItem()
    {
        if (Class == null || Class.IsMoney)
        {
            return;
        }

        // concat native and magic effects
        Effects.Clear();
        Effects.AddRange(NativeEffects);
        Effects.AddRange(MagicEffects);

        // base price.
        Price = Class.Price;

        /*
         * if (!Class.IsSpecial)
         * {
         *  Price = (int)(Price * Class.Class.Price);
         *  Price = (int)(Price * Class.Material.Price);
         * }
         */

        ManaUsage = 0;
        for (int i = 0; i < MagicEffects.Count; i++)
        {
            Templates.TplModifier modifier = TemplateLoader.GetModifierById((int)Effects[i].Type1);
            if (modifier == null)
            {
                continue; // wtf was that lol.
            }
            switch (Effects[i].Type1)
            {
            case ItemEffect.Effects.CastSpell:
                ManaUsage += modifier.ManaCost * Effects[i].Value2;
                break;

            case ItemEffect.Effects.DamageFire:
            case ItemEffect.Effects.DamageWater:
            case ItemEffect.Effects.DamageAir:
            case ItemEffect.Effects.DamageEarth:
            case ItemEffect.Effects.DamageAstral:
                ManaUsage += modifier.ManaCost * (Effects[i].Value1 + Effects[i].Value2);
                break;

            default:
                ManaUsage += modifier.ManaCost * Effects[i].Value1;
                break;
            }
        }

        Price = Math.Max(Price, (int)(Price * ((float)ManaUsage / 10)));

        // search for override price effect
        for (int i = 0; i < Effects.Count; i++)
        {
            if (Effects[i].Type1 == ItemEffect.Effects.Price)
            {
                Price = Effects[i].Value1;
            }
        }

        if (Price < 2)
        {
            Price = 2; // min price
        }
    }