Exemple #1
0
        public float GetEffectiveArmorVsType(DamageType damageType, List <WorldObject> armorLayers, Creature attacker, WorldObject weapon, float armorRendingMod = 1.0f)
        {
            var ignoreMagicArmor  = (weapon?.IgnoreMagicArmor ?? false) || (attacker?.IgnoreMagicArmor ?? false);
            var ignoreMagicResist = (weapon?.IgnoreMagicResist ?? false) || (attacker?.IgnoreMagicResist ?? false);

            // get base AL / RL
            var armorVsType = Biota.BaseArmor * (float)Creature.GetArmorVsType(damageType);

            // additive enchantments:
            // imperil / armor
            var enchantmentMod = ignoreMagicResist ? 0 : EnchantmentManager.GetBodyArmorMod();

            var effectiveAL = armorVsType + enchantmentMod;

            // handle monsters w/ multiple layers of armor
            foreach (var armorLayer in armorLayers)
            {
                effectiveAL += GetArmorMod(armorLayer, damageType, ignoreMagicArmor);
            }

            // armor rending reduces base armor + all physical armor too?
            if (effectiveAL > 0)
            {
                effectiveAL *= armorRendingMod;
            }

            return(effectiveAL);
        }
        public float GetEffectiveArmorVsType(DamageType damageType, List <WorldObject> armorLayers, WorldObject weapon, float armorRendingMod = 1.0f)
        {
            var ignoreMagicArmor  = weapon != null ? weapon.IgnoreMagicArmor : false;
            var ignoreMagicResist = weapon != null ? weapon.IgnoreMagicResist : false;

            // get base AL / RL
            var enchantmentMod = ignoreMagicResist ? 0 : EnchantmentManager.GetBodyArmorMod();

            var baseArmorMod = (float)(Biota.BaseArmor + enchantmentMod);

            // for creatures, can this be modified via enchantments?
            var armorVsType = Creature.GetArmorVsType(damageType);

            // handle negative baseArmorMod?
            if (baseArmorMod < 0)
            {
                armorVsType = 1.0f + (1.0f - armorVsType);
            }

            var effectiveAL = (float)(baseArmorMod * armorVsType);

            // handle monsters w/ multiple layers of armor
            foreach (var armorLayer in armorLayers)
            {
                effectiveAL += GetArmorMod(armorLayer, damageType, ignoreMagicArmor);
            }

            // armor rending reduces base armor + all physical armor too?
            if (effectiveAL > 0)
            {
                effectiveAL *= armorRendingMod;
            }

            return(effectiveAL);
        }