From 31b31115af8223a31b52dea48a49eb7a66dec648 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 6 Sep 2014 04:07:05 +0200 Subject: [PATCH] Fix AI not using Restore Health effect when it is complemented by unnecessary restore magicka/fatigue effects (e.g. in sc_purityofbody) --- apps/openmw/mwmechanics/aicombataction.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/aicombataction.cpp b/apps/openmw/mwmechanics/aicombataction.cpp index b61e5a121..1c18dd028 100644 --- a/apps/openmw/mwmechanics/aicombataction.cpp +++ b/apps/openmw/mwmechanics/aicombataction.cpp @@ -269,15 +269,18 @@ namespace MWMechanics case ESM::MagicEffect::RestoreFatigue: if (effect.mRange == ESM::RT_Self) { + int priority = 1; + if (effect.mEffectID == ESM::MagicEffect::RestoreHealth) + priority = 10; const DynamicStat& current = actor.getClass().getCreatureStats(actor). getDynamic(effect.mEffectID - ESM::MagicEffect::RestoreHealth); float toHeal = (effect.mMagnMin + effect.mMagnMax)/2.f * effect.mDuration; // Effect doesn't heal more than we need, *or* we are below 1/2 health if (current.getModified() - current.getCurrent() > toHeal || current.getCurrent() < current.getModified()*0.5) - return 10000.f; + return 10000.f * priority; else - return -10000.f; // Save for later + return -10000.f * priority; // Save for later } break;