예제 #1
0
        public float GetEffectiveArmorVsType(DamageType damageType, List <WorldObject> armorLayers, WorldObject damageSource, float armorRendingMod = 1.0f)
        {
            var ignoreMagicArmor  = damageSource != null ? damageSource.IgnoreMagicArmor : false;
            var ignoreMagicResist = damageSource != null ? damageSource.IgnoreMagicResist : false;

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

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

            // handle armor rending mod here?
            //if (baseArmorMod > 0)
            //baseArmorMod *= armorRendingMod;

            // 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, damageSource, damageType);
            }

            // Armor Rending reduces physical armor too?
            if (effectiveAL > 0)
            {
                effectiveAL *= armorRendingMod;
            }

            return(effectiveAL);
        }