From 744859f32715a1244930f049b9d4933e27f2b34f Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Thu, 7 Dec 2017 22:43:32 +0400 Subject: [PATCH] Take in account armor condition in the armor rating calculation (bug #4246) --- apps/openmw/mwclass/npc.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index e7085bfbc..134bbf943 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -1129,6 +1129,15 @@ namespace MWClass else { ratings[i] = it->getClass().getEffectiveArmorRating(*it, ptr); + + // Take in account armor condition + const bool hasHealth = it->getClass().hasItemHealth(*it); + if (hasHealth) + { + int armorHealth = it->getClass().getItemHealth(*it); + int armorMaxHealth = it->getClass().getItemMaxHealth(*it); + ratings[i] *= (float(armorHealth) / armorMaxHealth); + } } }