diff --git a/Source/player.cpp b/Source/player.cpp index 68a89ea20..7a006c603 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -2104,6 +2104,12 @@ void Player::Reset() *this = std::move(*emptyPlayer); } +int Player::GetManaShieldDamageReduction() +{ + constexpr int8_t Max = 7; + return 24 - std::min(_pSplLvl[SPL_MANASHIELD], Max) * 3; +} + void Player::RestorePartialLife() { int wholeHitpoints = _pMaxHP >> 6; @@ -3229,7 +3235,7 @@ void ApplyPlrDamage(int pnum, int dam, int minHP /*= 0*/, int frac /*= 0*/, int if (totalDamage > 0 && player.pManaShield) { int8_t manaShieldLevel = player._pSplLvl[SPL_MANASHIELD]; if (manaShieldLevel > 0) { - totalDamage += totalDamage / -3; + totalDamage += totalDamage / -player.GetManaShieldDamageReduction(); } if (pnum == MyPlayerId) drawmanaflag = true; @@ -3240,7 +3246,7 @@ void ApplyPlrDamage(int pnum, int dam, int minHP /*= 0*/, int frac /*= 0*/, int } else { totalDamage -= player._pMana; if (manaShieldLevel > 0) { - totalDamage += totalDamage / 2; + totalDamage += totalDamage / (player.GetManaShieldDamageReduction() - 1); } player._pMana = 0; player._pManaBase = player._pMaxManaBase - player._pMaxMana; diff --git a/Source/player.h b/Source/player.h index 9c97ba68c..bbe6c3650 100644 --- a/Source/player.h +++ b/Source/player.h @@ -527,6 +527,13 @@ struct Player { return blkper; } + /** + * @brief Return reciprocal of the factor for calculating damage reduction due to Mana Shield. + * + * Valid only for players with Mana Shield spell level greater than zero. + */ + int GetManaShieldDamageReduction(); + /** * @brief Return monster armor value after including player's armor piercing % (hellfire only) * @param monsterArmor - monster armor before applying % armor pierce