From 23ef33b08fd399efbb48dc22f56b20dc8d463e8e Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Sun, 24 Aug 2025 23:10:47 +0300 Subject: [PATCH] Properly detect overencumbrance for zero capacity again --- apps/openmw/mwclass/npc.cpp | 5 +++-- apps/openmw/mwworld/class.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index f56ce35b26..0016371b93 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -953,7 +953,8 @@ namespace MWClass float Npc::getJump(const MWWorld::Ptr& ptr) const { - if (getEncumbrance(ptr) > getCapacity(ptr)) + const float normalizedEncumbrance = getNormalizedEncumbrance(ptr); + if (normalizedEncumbrance > 1.0f) return 0.f; const MWMechanics::NpcStats& stats = getNpcStats(ptr); @@ -963,7 +964,7 @@ namespace MWClass const GMST& gmst = getGmst(); const MWMechanics::MagicEffects& mageffects = stats.getMagicEffects(); const float encumbranceTerm = gmst.fJumpEncumbranceBase->mValue.getFloat() - + gmst.fJumpEncumbranceMultiplier->mValue.getFloat() * (1.0f - Npc::getNormalizedEncumbrance(ptr)); + + gmst.fJumpEncumbranceMultiplier->mValue.getFloat() * (1.0f - normalizedEncumbrance); float a = getSkill(ptr, ESM::Skill::Acrobatics); float b = 0.0f; diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index fc862f302f..a6138179ef 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -481,11 +481,16 @@ namespace MWWorld float capacity = getCapacity(ptr); float encumbrance = getEncumbrance(ptr); + // Intentional deviation: Morrowind doesn't do this + // but handling (0 / 0) as 1.0 encumbrance feels like a clear oversight if (encumbrance == 0) return 0.f; + // Another deviation: handle (non-zero encumbrance / zero capacity) as "overencumbered" + // Morrowind uses 1, but this means that for zero capacity, + // normalized encumbrance cannot be used to detect overencumbrance if (capacity == 0) - return 1.f; + return 1.f + 1e-6f; return encumbrance / capacity; }