/// Allocate any equipment damage from a strike, and reduce item condition. private static bool DamageEquipment(DaggerfallEntity attacker, DaggerfallEntity target, int damage, DaggerfallUnityItem weapon, int struckBodyPart) { int atkStrength = attacker.Stats.LiveStrength; int tarMatMod = 0; int matDifference = 0; bool bluntWep = false; bool shtbladeWep = false; bool missileWep = false; int wepEqualize = 1; int wepWeight = 1; float wepDamResist = 1f; float armorDamResist = 1f; // If damage was done by a weapon, damage the weapon and armor of the hit body part. if (weapon != null && damage > 0) { int atkMatMod = weapon.GetWeaponMaterialModifier() + 2; int wepDam = damage; wepEqualize = EqualizeMaterialConditions(weapon); wepDam *= wepEqualize; if (weapon.GetWeaponSkillIDAsShort() == 32) // Checks if the weapon being used is in the Blunt Weapon category, then sets a bool value to true. { wepDam += (atkStrength / 10); wepDamResist = (wepEqualize * .20f) + 1; wepDam = (int)Mathf.Ceil(wepDam / wepDamResist); bluntWep = true; wepWeight = (int)Mathf.Ceil(weapon.EffectiveUnitWeightInKg()); ApplyConditionDamageThroughWeaponDamage(weapon, attacker, wepDam, bluntWep, shtbladeWep, missileWep, wepEqualize); // Does condition damage to the attackers weapon. } else if (weapon.GetWeaponSkillIDAsShort() == 28) // Checks if the weapon being used is in the Short Blade category, then sets a bool value to true. { if (weapon.TemplateIndex == (int)Weapons.Dagger || weapon.TemplateIndex == (int)Weapons.Tanto) { wepDam += (atkStrength / 30); wepDamResist = (wepEqualize * .90f) + 1; wepDam = (int)Mathf.Ceil(wepDam / wepDamResist); shtbladeWep = true; } else { wepDam += (atkStrength / 30); wepDamResist = (wepEqualize * .30f) + 1; wepDam = (int)Mathf.Ceil(wepDam / wepDamResist); shtbladeWep = true; } ApplyConditionDamageThroughWeaponDamage(weapon, attacker, wepDam, bluntWep, shtbladeWep, missileWep, wepEqualize); // Does condition damage to the attackers weapon. } else if (weapon.GetWeaponSkillIDAsShort() == 33) // Checks if the weapon being used is in the Missile Weapon category, then sets a bool value to true. { missileWep = true; ApplyConditionDamageThroughWeaponDamage(weapon, attacker, wepDam, bluntWep, shtbladeWep, missileWep, wepEqualize); // Does condition damage to the attackers weapon. } else // If all other weapons categories have not been found, it defaults to this, which currently includes long blades and axes. { wepDam += (atkStrength / 10); wepDamResist = (wepEqualize * .20f) + 1; wepDam = (int)Mathf.Ceil(wepDam / wepDamResist); ApplyConditionDamageThroughWeaponDamage(weapon, attacker, wepDam, bluntWep, shtbladeWep, missileWep, wepEqualize); // Does condition damage to the attackers weapon. } if (attacker == GameManager.Instance.PlayerEntity) { WarningMessagePlayerEquipmentCondition(weapon); } DaggerfallUnityItem shield = target.ItemEquipTable.GetItem(EquipSlots.LeftHand); // Checks if character is using a shield or not. bool shieldTakesDamage = false; if (shield != null) { BodyParts[] protectedBodyParts = shield.GetShieldProtectedBodyParts(); for (int i = 0; (i < protectedBodyParts.Length) && !shieldTakesDamage; i++) { if (protectedBodyParts[i] == (BodyParts)struckBodyPart) { shieldTakesDamage = true; } } } if (shieldTakesDamage) { int shieldEqualize = EqualizeMaterialConditions(shield); damage *= shieldEqualize; tarMatMod = ArmorMaterialModifierFinder(shield); matDifference = tarMatMod - atkMatMod; damage = MaterialDifferenceDamageCalculation(shield, matDifference, atkStrength, damage, bluntWep, wepWeight, shieldTakesDamage); ApplyConditionDamageThroughWeaponDamage(shield, target, damage, bluntWep, shtbladeWep, missileWep, wepEqualize); if (target == GameManager.Instance.PlayerEntity) { WarningMessagePlayerEquipmentCondition(shield); } } else { EquipSlots hitSlot = DaggerfallUnityItem.GetEquipSlotForBodyPart((BodyParts)struckBodyPart); DaggerfallUnityItem armor = target.ItemEquipTable.GetItem(hitSlot); if (armor != null) { int armorEqualize = EqualizeMaterialConditions(armor); damage *= armorEqualize; tarMatMod = ArmorMaterialModifierFinder(armor); matDifference = tarMatMod - atkMatMod; damage = MaterialDifferenceDamageCalculation(armor, matDifference, atkStrength, damage, bluntWep, wepWeight, shieldTakesDamage); ApplyConditionDamageThroughWeaponDamage(armor, target, damage, bluntWep, shtbladeWep, missileWep, wepEqualize); if (target == GameManager.Instance.PlayerEntity) { WarningMessagePlayerEquipmentCondition(armor); } } } return(false); } else if (weapon == null && damage > 0) // Handles Unarmed attacks. { DaggerfallUnityItem shield = target.ItemEquipTable.GetItem(EquipSlots.LeftHand); bool shieldTakesDamage = false; if (shield != null) { BodyParts[] protectedBodyParts = shield.GetShieldProtectedBodyParts(); for (int i = 0; (i < protectedBodyParts.Length) && !shieldTakesDamage; i++) { if (protectedBodyParts[i] == (BodyParts)struckBodyPart) { shieldTakesDamage = true; } } } if (shieldTakesDamage) { int shieldEqualize = EqualizeMaterialConditions(shield); damage *= shieldEqualize; tarMatMod = ArmorMaterialModifierFinder(shield); atkStrength /= 5; armorDamResist = (tarMatMod * .35f) + 1; damage = (int)Mathf.Ceil((damage + atkStrength) / armorDamResist); ApplyConditionDamageThroughUnarmedDamage(shield, target, damage); if (target == GameManager.Instance.PlayerEntity) { WarningMessagePlayerEquipmentCondition(shield); } } else { EquipSlots hitSlot = DaggerfallUnityItem.GetEquipSlotForBodyPart((BodyParts)struckBodyPart); DaggerfallUnityItem armor = target.ItemEquipTable.GetItem(hitSlot); if (armor != null) { int armorEqualize = EqualizeMaterialConditions(armor); damage *= armorEqualize; tarMatMod = ArmorMaterialModifierFinder(armor); atkStrength /= 5; armorDamResist = (tarMatMod * .20f) + 1; damage = (int)Mathf.Ceil((damage + atkStrength) / armorDamResist); ApplyConditionDamageThroughUnarmedDamage(armor, target, damage); if (target == GameManager.Instance.PlayerEntity) { WarningMessagePlayerEquipmentCondition(armor); } } } return(false); } return(false); }