Skip to content

[Engine] Refactor Mana Shield damage handling#8395

Open
kphoenix137 wants to merge 2 commits intodiasurgical:masterfrom
kphoenix137:refactor-manashield
Open

[Engine] Refactor Mana Shield damage handling#8395
kphoenix137 wants to merge 2 commits intodiasurgical:masterfrom
kphoenix137:refactor-manashield

Conversation

@kphoenix137
Copy link
Copy Markdown
Collaborator

Moves reduction to Mana while Mana Shield is active into a Player member function ApplyManaShieldToDamage(), and removes GetManaShieldDamageReduction().

ApplyManaShieldToDamage() takes totalDamage as an argument and reduces the Player's Mana (if applicable), and returns the remaining amount of damage to be dealt to the Player's Life.

@kphoenix137 kphoenix137 changed the title Refactor Mana Shield damage handling [Engine] Refactor Mana Shield damage handling Jan 8, 2026
@morfidon
Copy link
Copy Markdown

morfidon commented Mar 8, 2026

I think the removal condition should use the internal fixed-point mana value, not >> 6. In this engine, damage and mana are both handled in 1/64 units, so whole-mana checks are only a UI-level approximation. The old behavior effectively removed the shield when mana was actually exhausted. Using player._pMana == 0 would be safer and more faithful to how the engine works.

if (&player == MyPlayer) {
    RedrawComponent(PanelDrawComponent::Mana);
    if (manaBefore > 0 && player._pMana == 0)
        NetSendCmd(true, CMD_REMSHIELD);
}

@qndel
Copy link
Copy Markdown
Member

qndel commented Mar 8, 2026

morfidon

if your comment is about certain lines of code, it's best to actually add the comment to them

@StephenCWills
Copy link
Copy Markdown
Member

In this engine, damage and mana are both handled in 1/64 units, so whole-mana checks are only a UI-level approximation.

The thing is, that assessment is actually wrong. Blizzard used (hp >> 6) == 0 checks all over the place inside the game engine so they clearly thought that honoring the UI-level approximation was more important than refunding a few 64ths of a hitpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants