/// <summary> /// Returns the effective AL for 1 piece of armor/clothing /// </summary> /// <param name="armor">A piece of armor or clothing</param> public float GetArmorMod(WorldObject armor, DamageType damageType, bool ignoreMagicArmor) { // get base armor/resistance level var baseArmor = armor.GetProperty(PropertyInt.ArmorLevel) ?? 0; var armorType = armor.GetProperty(PropertyInt.ArmorType) ?? 0; var resistance = Creature.GetResistance(armor, damageType); /*Console.WriteLine(armor.Name); * Console.WriteLine("--"); * Console.WriteLine("Base AL: " + baseArmor); * Console.WriteLine("Base RL: " + resistance);*/ // armor level additives var armorMod = ignoreMagicArmor ? 0 : armor.EnchantmentManager.GetArmorMod(); // Console.WriteLine("Impen: " + armorMod); var effectiveAL = baseArmor + armorMod; // resistance additives var armorBane = ignoreMagicArmor ? 0 : armor.EnchantmentManager.GetArmorModVsType(damageType); // Console.WriteLine("Bane: " + armorBane); var effectiveRL = (float)(resistance + armorBane); // resistance clamp effectiveRL = Math.Clamp(effectiveRL, -2.0f, 2.0f); // TODO: could brittlemail / lures send a piece of armor or clothing's AL into the negatives? //if (effectiveAL < 0) //effectiveRL = 1.0f / effectiveRL; /*Console.WriteLine("Effective AL: " + effectiveAL); * Console.WriteLine("Effective RL: " + effectiveRL); * Console.WriteLine();*/ return(effectiveAL * effectiveRL); }