Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Hellfire "Life to mana" and "Mana to life" #5771

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion Source/itemdat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down
23 changes: 21 additions & 2 deletions Source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1035,11 +1035,15 @@ int SaveItemPower(const Player &player, Item &item, ItemPower &power)
item._iDamAcFlags |= ItemSpecialEffectHf::ACAgainstUndead;
break;
case IPL_MANATOLIFE: {
item._iDamAcFlags |= ItemSpecialEffectHf::ManaToLife;
// Calculate for reverse compatibility
int portion = ((player._pMaxManaBase >> 6) * 50 / 100) << 6;
item._iPLMana -= portion;
item._iPLHP += portion;
} break;
case IPL_LIFETOMANA: {
item._iDamAcFlags |= ItemSpecialEffectHf::LifeToMana;
// Calculate for reverse compatibility
int portion = ((player._pMaxHPBase >> 6) * 40 / 100) << 6;
item._iPLHP -= portion;
item._iPLMana += portion;
Expand Down Expand Up @@ -2633,8 +2637,23 @@ 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 (HasAnyOf(pDamAcFlags, ItemSpecialEffectHf::ManaToLife)) {
int portion = ((player._pMaxManaBase >> 6) * 50 / 100) << 6;
imana -= portion;
ihp += portion;
}
if (HasAnyOf(pDamAcFlags, ItemSpecialEffectHf::LifeToMana)) {
int portion = ((player._pMaxHPBase >> 6) * 40 / 100) << 6;
ihp -= portion;
imana += portion;
}
if (HasNoneOf(pDamAcFlags, ItemSpecialEffectHf::ManaToLife | ItemSpecialEffectHf::LifeToMana)) {
ihp += item._iPLHP;
imana += item._iPLMana;
}

spllvladd += item._iSplLvlAdd;
enac += item._iPLEnAc;
fmin += item._iFMinDam;
Expand Down