|
|
|
@ -773,22 +773,24 @@ namespace MWClass
|
|
|
|
|
float x = damage / (damage + getArmorRating(ptr));
|
|
|
|
|
damage *= std::max(gmst.fCombatArmorMinMult->getFloat(), x);
|
|
|
|
|
int damageDiff = static_cast<int>(unmitigatedDamage - damage);
|
|
|
|
|
if (damage < 1)
|
|
|
|
|
damage = 1;
|
|
|
|
|
damage = std::max(1.f, damage);
|
|
|
|
|
damageDiff = std::max(1, damageDiff);
|
|
|
|
|
|
|
|
|
|
MWWorld::InventoryStore &inv = getInventoryStore(ptr);
|
|
|
|
|
MWWorld::ContainerStoreIterator armorslot = inv.getSlot(hitslot);
|
|
|
|
|
MWWorld::Ptr armor = ((armorslot != inv.end()) ? *armorslot : MWWorld::Ptr());
|
|
|
|
|
if(!armor.isEmpty() && armor.getTypeName() == typeid(ESM::Armor).name())
|
|
|
|
|
{
|
|
|
|
|
int armorhealth = armor.getClass().getItemHealth(armor);
|
|
|
|
|
armorhealth -= std::min(std::max(1, damageDiff),
|
|
|
|
|
armorhealth);
|
|
|
|
|
armor.getCellRef().setCharge(armorhealth);
|
|
|
|
|
|
|
|
|
|
// Armor broken? unequip it
|
|
|
|
|
if (armorhealth == 0)
|
|
|
|
|
armor = *inv.unequipItem(armor, ptr);
|
|
|
|
|
if (attacker.isEmpty() || (!attacker.isEmpty() && !(object.isEmpty() && !attacker.getClass().isNpc()))) // Unarmed creature attacks don't affect armor condition
|
|
|
|
|
{
|
|
|
|
|
int armorhealth = armor.getClass().getItemHealth(armor);
|
|
|
|
|
armorhealth -= std::min(damageDiff, armorhealth);
|
|
|
|
|
armor.getCellRef().setCharge(armorhealth);
|
|
|
|
|
|
|
|
|
|
// Armor broken? unequip it
|
|
|
|
|
if (armorhealth == 0)
|
|
|
|
|
armor = *inv.unequipItem(armor, ptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ptr == MWMechanics::getPlayer())
|
|
|
|
|
skillUsageSucceeded(ptr, armor.getClass().getEquipmentSkill(armor), 0);
|
|
|
|
|