Esempio n. 1
0
        public int GetArmorVsType(DamageType damageType, int armorVsType)
        {
            // TODO: refactor this class
            var preScaled = (float)BaseArmorMod / Biota.BaseArmor;

            //var resistance = (float)armorVsType / Biota.BaseArmor;
            var resistance = (float)armorVsType / Biota.BaseArmor * preScaled;

            if (double.IsNaN(resistance))
            {
                resistance = 1.0f;
            }

            float mod;
            var   spellVuln = IgnoreMagicResist ? 1.0f : EnchantmentManager.GetVulnerabilityResistanceMod(damageType);
            var   spellProt = IgnoreMagicResist ? 1.0f : EnchantmentManager.GetProtectionResistanceMod(damageType);

            if (WeaponResistanceMod > spellVuln)
            {
                mod = WeaponResistanceMod * spellProt;
            }
            else
            {
                mod = spellVuln * spellProt;
            }

            var baseArmorMod = BaseArmorMod;

            var resistanceMod = resistance / mod;

            if (baseArmorMod < 0)
            {
                resistanceMod = 1.0f + (1.0f - resistanceMod);
            }

            /*Console.WriteLine("BaseArmor: " + Biota.BaseArmor);
             * Console.WriteLine("BaseArmorMod: " + baseArmorMod);
             * Console.WriteLine("Resistance: " + resistance);
             * Console.WriteLine("ResistanceMod: " + resistanceMod);*/

            return((int)Math.Round(baseArmorMod * resistanceMod));
        }