From a2be73295b3c2c8540b38db746ff609df171c5ef Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 16 Jun 2017 13:33:42 +0400 Subject: [PATCH] Combat AI: take in account enemy weapon resistance --- apps/openmw/mwmechanics/aicombataction.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/openmw/mwmechanics/aicombataction.cpp b/apps/openmw/mwmechanics/aicombataction.cpp index e55ceaeac..d07e4dd0a 100644 --- a/apps/openmw/mwmechanics/aicombataction.cpp +++ b/apps/openmw/mwmechanics/aicombataction.cpp @@ -135,6 +135,9 @@ namespace MWMechanics if (weapon->mData.mType >= ESM::Weapon::MarksmanBow) { rating = (weapon->mData.mChop[0] + weapon->mData.mChop[1]) / 2.f; + + if (weapon->mData.mType >= ESM::Weapon::MarksmanThrown) + MWMechanics::resistNormalWeapon(enemy, actor, item, rating); } else { @@ -145,6 +148,8 @@ namespace MWMechanics rating += weapon->mData.mChop[i]; } rating /= 6.f; + + MWMechanics::resistNormalWeapon(enemy, actor, item, rating); } if (item.getClass().hasItemHealth(item)) @@ -182,6 +187,10 @@ namespace MWMechanics if (skill != -1) rating *= actor.getClass().getSkill(actor, skill) / 100.f; + // There is no need to apply bonus if weapon rating == 0 + if (rating == 0.f) + return 0.f; + return rating + bonus; }