Skip to content

Commit

Permalink
Fix IPL_MANATOLIFE and IPL_LIFETOMANA
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 committed Feb 7, 2023
1 parent 98294e0 commit 537ccd6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
4 changes: 3 additions & 1 deletion Source/itemdat.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,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,
Expand All @@ -370,6 +370,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);
Expand Down
33 changes: 21 additions & 12 deletions Source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,16 +1010,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;
}
Expand Down Expand Up @@ -2375,8 +2371,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;
Expand Down

0 comments on commit 537ccd6

Please sign in to comment.