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