From d0f750acdf17768dc99c35ca991779be3acfd099 Mon Sep 17 00:00:00 2001 From: KPhoenix Date: Tue, 7 Feb 2023 18:12:48 -0500 Subject: [PATCH] Fix IPL_MANATOLIFE and IPL_LIFETOMANA --- Source/itemdat.h | 4 +++- Source/items.cpp | 33 +++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/Source/itemdat.h b/Source/itemdat.h index 8df87122acc1..1c6941d4ee8b 100644 --- a/Source/itemdat.h +++ b/Source/itemdat.h @@ -364,7 +364,7 @@ enum class ItemSpecialEffect : uint32_t { }; use_enum_as_flags(ItemSpecialEffect); -enum class ItemSpecialEffectHf : uint8_t { +enum class ItemSpecialEffectHf : uint16_t { // clang-format off None = 0, Devastation = 1 << 0, @@ -374,6 +374,8 @@ enum class ItemSpecialEffectHf : uint8_t { Doppelganger = 1 << 4, ACAgainstDemons = 1 << 5, ACAgainstUndead = 1 << 6, + ManaToLife = 1 << 7, + LifeToMana = 1 << 8, // clang-format on }; use_enum_as_flags(ItemSpecialEffectHf); diff --git a/Source/items.cpp b/Source/items.cpp index 29d216fdd7be..88485958fe8c 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1034,16 +1034,12 @@ int SaveItemPower(const Player &player, Item &item, ItemPower &power) case IPL_ACUNDEAD: item._iDamAcFlags |= ItemSpecialEffectHf::ACAgainstUndead; break; - case IPL_MANATOLIFE: { - int portion = ((player._pMaxManaBase >> 6) * 50 / 100) << 6; - item._iPLMana -= portion; - item._iPLHP += portion; - } break; - case IPL_LIFETOMANA: { - int portion = ((player._pMaxHPBase >> 6) * 40 / 100) << 6; - item._iPLHP -= portion; - item._iPLMana += portion; - } break; + case IPL_MANATOLIFE: + item._iDamAcFlags |= ItemSpecialEffectHf::ManaToLife; + break; + case IPL_LIFETOMANA: + item._iDamAcFlags |= ItemSpecialEffectHf::LifeToMana; + break; default: break; } @@ -2633,8 +2629,21 @@ void CalcPlrItemVals(Player &player, bool loadgfx) dmod += item._iPLDamMod; ghit += item._iPLGetHit; lrad += item._iPLLight; - ihp += item._iPLHP; - imana += item._iPLMana; + + // Check for Acolyte's Amulet and Gladiator Ring to apply bonuses as life and mana changes, rather than getting static bonuses from the item data + if (IsAnyOf(item._iDamAcFlags, ItemSpecialEffectHf::ManaToLife)) { + int portion = ((player._pMaxManaBase >> 6) * 50 / 100) << 6; + imana -= portion; + ihp += portion; + } else if (IsAnyOf(item._iDamAcFlags, ItemSpecialEffectHf::LifeToMana)) { + int portion = ((player._pMaxHPBase >> 6) * 40 / 100) << 6; + ihp -= portion; + imana += portion; + } else { + ihp += item._iPLHP; + imana += item._iPLMana; + } + spllvladd += item._iSplLvlAdd; enac += item._iPLEnAc; fmin += item._iFMinDam;