From 8d693507ae48b4234f2b8338dbe3bac6c5e95ad8 Mon Sep 17 00:00:00 2001 From: Eric Robinson <68359262+kphoenix137@users.noreply.github.com> Date: Sat, 3 Jan 2026 16:57:29 -0500 Subject: [PATCH] Fix OperateShrineCostOfWisdom (#8398) --- Source/objects.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 859c7374b..f4c89389f 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -2524,24 +2524,22 @@ void OperateShrineCostOfWisdom(Player &player, SpellID spellId, diablo_message m } } - const uint32_t t = player._pMaxManaBase / 10; - const int v1 = player._pMana - player._pManaBase; - const int v2 = player._pMaxMana - player._pMaxManaBase; - player._pManaBase -= t; - player._pMana -= t; - player._pMaxMana -= t; - player._pMaxManaBase -= t; - if (player.hasNoMana()) { - player._pMana = v1; - player._pManaBase = 0; - } - if (player._pMaxMana >> 6 <= 0) { - player._pMaxMana = v2; + int maxBase = player._pMaxManaBase; + + if (maxBase < 0) { + // Fix bugged state; do not turn this into a "negative penalty" mana boost. player._pMaxManaBase = 0; + maxBase = 0; } - RedrawEverything(); + const int penalty = maxBase / 10; // 10% of max base mana (>= 0) + player._pMaxManaBase -= penalty; // will remain >= 0 + player._pManaBase -= penalty; // may go negative, allowed + player._pMaxMana -= penalty; // may go negative, allowed + player._pMana -= penalty; // may go negative, allowed + + RedrawEverything(); InitDiabloMsg(message); }