From 45c7e4590578b982e70b6bc253e49f35b19b3725 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Wed, 7 Aug 2024 22:49:23 +0200 Subject: [PATCH] Prevent spell priority skyrocketing in useless cases --- apps/openmw/mwmechanics/spellpriority.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwmechanics/spellpriority.cpp b/apps/openmw/mwmechanics/spellpriority.cpp index d1407c4cbd3..7041254c4e9 100644 --- a/apps/openmw/mwmechanics/spellpriority.cpp +++ b/apps/openmw/mwmechanics/spellpriority.cpp @@ -440,12 +440,12 @@ namespace MWMechanics // NB: this currently assumes the hardcoded magic effect flags are used const float magnitude = (effect.mMagnMin + effect.mMagnMax) / 2.f; const float toHeal = magnitude * std::max(1, effect.mDuration); - const float damage = current.getModified() - current.getCurrent(); + const float damage = std::max(current.getModified() - current.getCurrent(), 0.f); float priority = 0.f; if (effect.mEffectID == ESM::MagicEffect::RestoreHealth) priority = 4.f; else if (effect.mEffectID == ESM::MagicEffect::RestoreMagicka) - priority = std::max(0.1f, getRestoreMagickaPriority(actor)); + priority = getRestoreMagickaPriority(actor); else if (effect.mEffectID == ESM::MagicEffect::RestoreFatigue) priority = 2.f; float overheal = 0.f; @@ -456,9 +456,8 @@ namespace MWMechanics heal = damage; } - priority = (std::pow(priority + heal / current.getModified(), damage * 4.f / current.getModified()) - - priority - overheal / current.getModified()) - / priority; + priority = (priority - 1.f) / 2.f * std::pow((damage / current.getModified() + 0.6f), priority * 2) + + priority * (heal - 2.f * overheal) / current.getModified() - 0.5f; rating = priority; } break;