Skip to content

Commit

Permalink
Fix Life/Mana bugs (#5777)
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 authored Oct 6, 2024
1 parent 63fd721 commit 0fd4a7b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Source/engine/render/scrollrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,9 @@ void DrawAndBlit()
if (*sgOptions.Gameplay.showHealthValues)
DrawFlaskValues(out, { mainPanel.position.x + 134, mainPanel.position.y + 28 }, MyPlayer->_pHitPoints >> 6, MyPlayer->_pMaxHP >> 6);
if (*sgOptions.Gameplay.showManaValues)
DrawFlaskValues(out, { mainPanel.position.x + mainPanel.size.width - 138, mainPanel.position.y + 28 }, HasAnyOf(InspectPlayer->_pIFlags, ItemSpecialEffect::NoMana) ? 0 : MyPlayer->_pMana >> 6, HasAnyOf(InspectPlayer->_pIFlags, ItemSpecialEffect::NoMana) ? 0 : MyPlayer->_pMaxMana >> 6);
DrawFlaskValues(out, { mainPanel.position.x + mainPanel.size.width - 138, mainPanel.position.y + 28 },
(HasAnyOf(InspectPlayer->_pIFlags, ItemSpecialEffect::NoMana) || (MyPlayer->_pMana >> 6) <= 0) ? 0 : MyPlayer->_pMana >> 6,
HasAnyOf(InspectPlayer->_pIFlags, ItemSpecialEffect::NoMana) ? 0 : MyPlayer->_pMaxMana >> 6);

DrawCursor(out);

Expand Down
4 changes: 2 additions & 2 deletions Source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2629,14 +2629,14 @@ void CalcPlrLifeMana(Player &player, int vitality, int magic, int life, int mana
magic = (magic * playerClassAttributes.itmMana) >> 6;
mana += (magic << 6);

player._pMaxHP = life + player._pMaxHPBase;
player._pMaxHP = std::clamp(life + player._pMaxHPBase, 1 << 6, 2000 << 6);
player._pHitPoints = std::min(life + player._pHPBase, player._pMaxHP);

if (&player == MyPlayer && (player._pHitPoints >> 6) <= 0) {
SetPlayerHitPoints(player, 0);
}

player._pMaxMana = mana + player._pMaxManaBase;
player._pMaxMana = std::clamp(mana + player._pMaxManaBase, 0, 2000 << 6);
player._pMana = std::min(mana + player._pManaBase, player._pMaxMana);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/panels/charpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ PanelEntry panelEntries[] = {
{ N_("Mana"), { LeftColumnLabelX, 312 }, 45, LeftColumnLabelWidth,
[]() { return StyledText { GetMaxManaColor(), StrCat(HasAnyOf(InspectPlayer->_pIFlags, ItemSpecialEffect::NoMana) ? 0 : InspectPlayer->_pMaxMana >> 6) }; } },
{ "", { 135, 312 }, 45, 0,
[]() { return StyledText { (InspectPlayer->_pMana != InspectPlayer->_pMaxMana ? UiFlags::ColorRed : GetMaxManaColor()), StrCat(HasAnyOf(InspectPlayer->_pIFlags, ItemSpecialEffect::NoMana) ? 0 : InspectPlayer->_pMana >> 6) }; } },
[]() { return StyledText { (InspectPlayer->_pMana != InspectPlayer->_pMaxMana ? UiFlags::ColorRed : GetMaxManaColor()), StrCat((HasAnyOf(InspectPlayer->_pIFlags, ItemSpecialEffect::NoMana) || (InspectPlayer->_pMana >> 6) <= 0) ? 0 : InspectPlayer->_pMana >> 6) }; } },

{ N_("Resist magic"), { RightColumnLabelX, 256 }, 57, RightColumnLabelWidth,
[]() { return GetResistInfo(InspectPlayer->_pMagResist); } },
Expand Down

0 comments on commit 0fd4a7b

Please sign in to comment.