From 989d1999080c82bb5632bb29f1df085d26216b5c Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Mon, 15 Apr 2024 06:06:17 -0400 Subject: [PATCH] [Spells] SPA69 TotalHP can be used in Worn Slot, Fixes/Updates to Max HP related variables. (#4244) * Allow SPA69 to work on worn effects. Update to allow SPA69 to work on worn effects which the client accepts and calculates properly. Updated spell effect related Max HP change variables. 1) We had stat bonuses defined that did same function. Without updating would have had to create another variable for above to work. 2) Negate bonuses spell effect end up negating item HPs. which is not intended since using same variable for items and spells. * HP variable updates fixes * HP variable updates fixes * HP variable updates fixes * Update mob.cpp --- zone/bonuses.cpp | 21 ++++++++++----------- zone/bot.cpp | 4 ++-- zone/client_mods.cpp | 4 ++-- zone/client_packet.cpp | 2 +- zone/common.h | 4 ++-- zone/lua_stat_bonuses.cpp | 10 ++++++++-- zone/lua_stat_bonuses.h | 1 + zone/merc.cpp | 4 ++-- zone/mob.cpp | 10 +++++----- zone/perl_stat_bonuses.cpp | 10 ++++++++-- 10 files changed, 41 insertions(+), 29 deletions(-) diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index 13aa824bc..f796160d0 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -938,7 +938,7 @@ void Mob::ApplyAABonuses(const AA::Rank &rank, StatBonuses *newbon) case SE_IncreaseRange: break; case SE_MaxHPChange: - newbon->MaxHP += base_value; + newbon->PercentMaxHPChange += base_value; break; case SE_Packrat: newbon->Packrat += base_value; @@ -997,7 +997,7 @@ void Mob::ApplyAABonuses(const AA::Rank &rank, StatBonuses *newbon) newbon->BuffSlotIncrease += base_value; break; case SE_TotalHP: - newbon->HP += base_value; + newbon->FlatMaxHPChange += base_value; break; case SE_StunResist: newbon->StunResist += base_value; @@ -2237,7 +2237,7 @@ void Mob::ApplySpellsBonuses(uint16 spell_id, uint8 casterlevel, StatBonuses *ne case SE_TotalHP: { - new_bonus->HP += effect_value; + new_bonus->FlatMaxHPChange += effect_value; break; } @@ -2919,7 +2919,7 @@ void Mob::ApplySpellsBonuses(uint16 spell_id, uint8 casterlevel, StatBonuses *ne } case SE_MaxHPChange: - new_bonus->MaxHPChange += effect_value; + new_bonus->PercentMaxHPChange += effect_value; break; case SE_EndurancePool: @@ -4515,9 +4515,9 @@ void Mob::NegateSpellEffectBonuses(uint16 spell_id) break; case SE_TotalHP: - if (negate_spellbonus) { spellbonuses.HP = effect_value; } - if (negate_aabonus) { aabonuses.HP = effect_value; } - if (negate_itembonus) { itembonuses.HP = effect_value; } + if (negate_spellbonus) { spellbonuses.FlatMaxHPChange = effect_value; } + if (negate_aabonus) { aabonuses.FlatMaxHPChange = effect_value; } + if (negate_itembonus) { itembonuses.FlatMaxHPChange = effect_value; } break; case SE_ManaRegen_v2: @@ -4999,10 +4999,9 @@ void Mob::NegateSpellEffectBonuses(uint16 spell_id) } case SE_MaxHPChange: - if (negate_spellbonus) { spellbonuses.MaxHPChange = effect_value; } - if (negate_aabonus) { aabonuses.MaxHPChange = effect_value; } - if (negate_aabonus) { aabonuses.MaxHP = effect_value; } - if (negate_itembonus) { itembonuses.MaxHPChange = effect_value; } + if (negate_spellbonus) { spellbonuses.PercentMaxHPChange = effect_value; } + if (negate_aabonus) { aabonuses.PercentMaxHPChange = effect_value; } + if (negate_itembonus) { itembonuses.PercentMaxHPChange = effect_value; } break; case SE_EndurancePool: diff --git a/zone/bot.cpp b/zone/bot.cpp index 94f756b49..cf07281ba 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -6235,9 +6235,9 @@ int64 Bot::CalcMaxHP() { uint32 nd = 10000; bot_hp += (GenerateBaseHitPoints() + itembonuses.HP); bot_hp += itembonuses.heroic_max_hp; - nd += aabonuses.MaxHP + spellbonuses.MaxHPChange + itembonuses.MaxHPChange; + nd += aabonuses.PercentMaxHPChange + spellbonuses.PercentMaxHPChange + itembonuses.PercentMaxHPChange; bot_hp = ((float)bot_hp * (float)nd / (float)10000); - bot_hp += (spellbonuses.HP + aabonuses.HP); + bot_hp += (spellbonuses.FlatMaxHPChange + aabonuses.FlatMaxHPChange + itembonuses.FlatMaxHPChange); bot_hp += GroupLeadershipAAHealthEnhancement(); max_hp = bot_hp; if (current_hp > max_hp) diff --git a/zone/client_mods.cpp b/zone/client_mods.cpp index d69f83676..cb4b10eb6 100644 --- a/zone/client_mods.cpp +++ b/zone/client_mods.cpp @@ -323,9 +323,9 @@ int64 Client::CalcMaxHP() //to apply it to (basehp + itemhp).. I will oblige to the client's whims over //the aa description - nd += aabonuses.MaxHP + spellbonuses.MaxHPChange + itembonuses.MaxHPChange; //Natural Durability, Physical Enhancement, Planar Durability (MaxHP and MaxHPChange are SPA214) + nd += aabonuses.PercentMaxHPChange + spellbonuses.PercentMaxHPChange + itembonuses.PercentMaxHPChange; //Natural Durability, Physical Enhancement, Planar Durability max_hp = (float)max_hp * (float)nd / (float)10000; //this is to fix the HP-above-495k issue - max_hp += spellbonuses.HP + aabonuses.HP; + max_hp += spellbonuses.FlatMaxHPChange + aabonuses.FlatMaxHPChange + itembonuses.FlatMaxHPChange; max_hp += GroupLeadershipAAHealthEnhancement(); if (current_hp > max_hp) { diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index db7e8c669..6a95dae5e 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -16780,7 +16780,7 @@ void Client::RecordStats() r.level = GetLevel(); r.class_ = GetBaseClass(); r.race = GetBaseRace(); - r.hp = GetMaxHP() - GetSpellBonuses().HP; + r.hp = GetMaxHP() - GetSpellBonuses().FlatMaxHPChange; r.mana = GetMaxMana() - GetSpellBonuses().Mana; r.endurance = GetMaxEndurance() - GetSpellBonuses().Endurance; r.ac = GetDisplayAC() - GetSpellBonuses().AC; diff --git a/zone/common.h b/zone/common.h index 89514bac3..a139dfb13 100644 --- a/zone/common.h +++ b/zone/common.h @@ -278,7 +278,6 @@ struct StatBonuses { int32 AC; int64 HP; int64 HPRegen; - int64 MaxHP; //same bonus as MaxHPChange when applied to spells and item bonuses int64 ManaRegen; int64 EnduranceRegen; int64 Mana; @@ -404,7 +403,7 @@ struct StatBonuses { int32 MeleeLifetap; //i int32 Vampirism; //i int32 HealRate; // Spell effect that influences effectiveness of heals - int32 MaxHPChange; // percent change in hit points (aabonuses use variable MaxHP) + int64 PercentMaxHPChange; // base: Max HP change by percentage value from spell effect/item worn effect/aa int16 SkillDmgTaken[EQ::skills::HIGHEST_SKILL + 2]; // All Skills + -1 int32 HealAmt; // Item Effect int32 SpellDmg; // Item Effect @@ -504,6 +503,7 @@ struct StatBonuses { uint8 invisibility_verse_undead; // IVU level uint8 invisibility_verse_animal; // IVA level int32 ShieldTargetSpa[2]; // [0] base = % mitigation amount, [1] buff slot + int64 FlatMaxHPChange; // base: Max HP change by a flat amount value from spell effect/item worn effect/aa // AAs int32 TrapCircumvention; // reduce chance to trigger a trap. diff --git a/zone/lua_stat_bonuses.cpp b/zone/lua_stat_bonuses.cpp index d5bd43094..78374fdef 100644 --- a/zone/lua_stat_bonuses.cpp +++ b/zone/lua_stat_bonuses.cpp @@ -16,6 +16,11 @@ int64 Lua_StatBonuses::GetHP() const { return self->HP; } +int64 Lua_StatBonuses::GetFlatMaxHPChange() const { + Lua_Safe_Call_Int(); + return self->FlatMaxHPChange; +} + int64 Lua_StatBonuses::GetHPRegen() const { Lua_Safe_Call_Int(); return self->HPRegen; @@ -23,7 +28,7 @@ int64 Lua_StatBonuses::GetHPRegen() const { int64 Lua_StatBonuses::GetMaxHP() const { Lua_Safe_Call_Int(); - return self->MaxHP; + return self->PercentMaxHPChange; } int64 Lua_StatBonuses::GetManaRegen() const { @@ -608,7 +613,7 @@ int32 Lua_StatBonuses::GetHealRate() const { int32 Lua_StatBonuses::GetMaxHPChange() const { Lua_Safe_Call_Int(); - return self->MaxHPChange; + return self->PercentMaxHPChange; } int32 Lua_StatBonuses::GetHealAmt() const { @@ -1381,6 +1386,7 @@ luabind::scope lua_register_stat_bonuses() { .def("FeignedCastOnChance", &Lua_StatBonuses::GetFeignedCastOnChance) .def("FinishingBlow", &Lua_StatBonuses::GetFinishingBlow) .def("FinishingBlowLvl", &Lua_StatBonuses::GetFinishingBlowLvl) + .def("FlatMaxHPChange", &Lua_StatBonuses::GetFlatMaxHPChange) .def("FlurryChance", &Lua_StatBonuses::GetFlurryChance) .def("FocusEffects", &Lua_StatBonuses::GetFocusEffects) .def("FocusEffectsWorn", &Lua_StatBonuses::GetFocusEffectsWorn) diff --git a/zone/lua_stat_bonuses.h b/zone/lua_stat_bonuses.h index 8f83f1c25..ff4e9f932 100644 --- a/zone/lua_stat_bonuses.h +++ b/zone/lua_stat_bonuses.h @@ -27,6 +27,7 @@ public: int32 GetAC() const; int64 GetHP() const; + int64 GetFlatMaxHPChange() const; int64 GetHPRegen() const; int64 GetMaxHP() const; int64 GetManaRegen() const; diff --git a/zone/merc.cpp b/zone/merc.cpp index 93d90d66c..6006cc6a1 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -461,10 +461,10 @@ int64 Merc::CalcMaxHP() { //but the actual effect sent on live causes the client //to apply it to (basehp + itemhp).. I will oblige to the client's whims over //the aa description - nd += aabonuses.MaxHP + spellbonuses.MaxHPChange + itembonuses.MaxHPChange; //Natural Durability, Physical Enhancement, Planar Durability + nd += aabonuses.PercentMaxHPChange + spellbonuses.PercentMaxHPChange + itembonuses.PercentMaxHPChange; //Natural Durability, Physical Enhancement, Planar Durability max_hp = (float)max_hp * (float)nd / (float)10000; //this is to fix the HP-above-495k issue - max_hp += spellbonuses.HP + aabonuses.HP; + max_hp += spellbonuses.FlatMaxHPChange + aabonuses.FlatMaxHPChange + itembonuses.FlatMaxHPChange; max_hp += GroupLeadershipAAHealthEnhancement(); diff --git a/zone/mob.cpp b/zone/mob.cpp index 0cc88860d..fcbbea9a7 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -967,8 +967,9 @@ int64 Mob::CalcMaxMana() } int64 Mob::CalcMaxHP() { - max_hp = (base_hp + itembonuses.HP + spellbonuses.HP); - max_hp += max_hp * ((aabonuses.MaxHPChange + spellbonuses.MaxHPChange + itembonuses.MaxHPChange) / 10000.0f); + max_hp = (base_hp + itembonuses.HP); + max_hp += max_hp * ((aabonuses.PercentMaxHPChange + spellbonuses.PercentMaxHPChange + itembonuses.PercentMaxHPChange) / 10000.0f); + max_hp += spellbonuses.FlatMaxHPChange + itembonuses.FlatMaxHPChange + aabonuses.FlatMaxHPChange; return max_hp; } @@ -976,14 +977,13 @@ int64 Mob::CalcMaxHP() { int64 Mob::GetItemHPBonuses() { int64 item_hp = 0; item_hp = itembonuses.HP; - item_hp += item_hp * itembonuses.MaxHPChange / 10000; + item_hp += item_hp * ((itembonuses.PercentMaxHPChange + spellbonuses.FlatMaxHPChange + aabonuses.FlatMaxHPChange) / 10000.0f); return item_hp; } int64 Mob::GetSpellHPBonuses() { int64 spell_hp = 0; - spell_hp = spellbonuses.HP; - spell_hp += spell_hp * spellbonuses.MaxHPChange / 10000; + spell_hp += spellbonuses.FlatMaxHPChange; return spell_hp; } diff --git a/zone/perl_stat_bonuses.cpp b/zone/perl_stat_bonuses.cpp index 398abf487..2d232b898 100644 --- a/zone/perl_stat_bonuses.cpp +++ b/zone/perl_stat_bonuses.cpp @@ -16,6 +16,11 @@ int64 Perl_StatBonuses_GetHP(StatBonuses* self) return self->HP; } +int64 Perl_StatBonuses_GetFlatMaxHPChange(StatBonuses* self) +{ + return self->FlatMaxHPChange; +} + int64 Perl_StatBonuses_GetHPRegen(StatBonuses* self) { return self->HPRegen; @@ -23,7 +28,7 @@ int64 Perl_StatBonuses_GetHPRegen(StatBonuses* self) int64 Perl_StatBonuses_GetMaxHP(StatBonuses* self) { - return self->MaxHP; + return self->PercentMaxHPChange; } int64 Perl_StatBonuses_GetManaRegen(StatBonuses* self) @@ -608,7 +613,7 @@ int32 Perl_StatBonuses_GetHealRate(StatBonuses* self) int32 Perl_StatBonuses_GetMaxHPChange(StatBonuses* self) { - return self->MaxHPChange; + return self->PercentMaxHPChange; } int32 Perl_StatBonuses_GetHealAmt(StatBonuses* self) @@ -1532,6 +1537,7 @@ void perl_register_stat_bonuses() package.add("GetStringedModifier", &Perl_StatBonuses_GetStringedModifier); package.add("GetStunBashChance", &Perl_StatBonuses_GetStunBashChance); package.add("GetStunResist", &Perl_StatBonuses_GetStunResist); + package.add("GetFlatMaxHPChange", &Perl_StatBonuses_GetFlatMaxHPChange); package.add("GetTradeSkillMastery", &Perl_StatBonuses_GetTradeSkillMastery); package.add("GetTriggerMeleeThreshold", &Perl_StatBonuses_GetTriggerMeleeThreshold); package.add("GetTriggerOnValueAmount", &Perl_StatBonuses_GetTriggerOnValueAmount);