From dace6ebe47736792bcd16bfde19c6398c9efe6d0 Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Fri, 9 Jul 2021 13:37:38 -0400 Subject: [PATCH] Implemented SPA Instant Mana/End pct Fixes for SPA 524-526 Implemented SE_Instant_Mana_Pct 522 SE_Instant_Endurance_Pct 523 Extracts 'base1' percent of your maximum mana/endurance, or 'max', whichever is lower. --- common/spdat.h | 4 +-- zone/spell_effects.cpp | 56 +++++++++++++++++++++++++++++++++--------- 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/common/spdat.h b/common/spdat.h index 42e2d0d4c..32ed30ce2 100644 --- a/common/spdat.h +++ b/common/spdat.h @@ -862,8 +862,8 @@ typedef enum { //#define SE_Luck_Amount 519 // //#define SE_Luck_Percent 520 // //#define SE_Endurance_Absorb_Pct_Damage 521 // -//#define SE_Instant_Mana_Pct 522 // -//#define SE_Instant_Endurance_Pct 523 // +#define SE_Instant_Mana_Pct 522 // +#define SE_Instant_Endurance_Pct 523 // #define SE_Duration_HP_Pct 524 // #define SE_Duration_Mana_Pct 525 // #define SE_Duration_Endurance_Pct 526 // diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 0229afddc..a64fe854a 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -2828,6 +2828,39 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove break; } + + case SE_Instant_Mana_Pct: { + effect_value = spells[spell_id].base[i]; + int32 amt = abs(GetMaxMana() * effect_value / 10000); + if (spells[spell_id].max[i] && amt > spells[spell_id].max[i]) + amt = spells[spell_id].max[i]; + + if (effect_value < 0) { + SetMana(GetMana() - amt); + } + else { + SetMana(GetMana() + amt); + } + break; + } + + case SE_Instant_Endurance_Pct: { + effect_value = spells[spell_id].base[i]; + if (IsClient()) { + int32 amt = abs(CastToClient()->GetMaxEndurance() * effect_value / 10000); + if (spells[spell_id].max[i] && amt > spells[spell_id].max[i]) + amt = spells[spell_id].max[i]; + + if (effect_value < 0) { + CastToClient()->SetEndurance(CastToClient()->GetEndurance() - amt); + } + else { + CastToClient()->SetEndurance(CastToClient()->GetEndurance() + amt); + } + } + break; + } + case SE_PersistentEffect: MakeAura(spell_id); break; @@ -3071,6 +3104,9 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove case SE_SkillProc: case SE_SkillProcSuccess: case SE_SpellResistReduction: + case SE_Duration_HP_Pct: + case SE_Duration_Mana_Pct: + case SE_Duration_Endurance_Pct: { break; } @@ -3778,10 +3814,9 @@ void Mob::DoBuffTic(const Buffs_Struct &buff, int slot, Mob *caster) } case SE_Duration_HP_Pct: { - effect_value = spells[buff.spellid].base[i]; int32 amt = abs(GetMaxHP() * effect_value / 100); - if (amt > spells[buff.spellid].max[i]) + if (spells[buff.spellid].max[i] && amt > spells[buff.spellid].max[i]) amt = spells[buff.spellid].max[i]; if (effect_value < 0) { @@ -3794,10 +3829,9 @@ void Mob::DoBuffTic(const Buffs_Struct &buff, int slot, Mob *caster) } case SE_Duration_Mana_Pct: { - effect_value = spells[buff.spellid].base[i]; - int32 amt = abs(GetMaxHP() * effect_value / 100); - if (amt > spells[buff.spellid].max[i]) + int32 amt = abs(GetMaxMana() * effect_value / 100); + if (spells[buff.spellid].max[i] && amt > spells[buff.spellid].max[i]) amt = spells[buff.spellid].max[i]; if (effect_value < 0) { @@ -3811,19 +3845,17 @@ void Mob::DoBuffTic(const Buffs_Struct &buff, int slot, Mob *caster) } case SE_Duration_Endurance_Pct: { - effect_value = spells[buff.spellid].base[i]; - int32 amt = abs(GetMaxHP() * effect_value / 100); - if (amt > spells[buff.spellid].max[i]) - amt = spells[buff.spellid].max[i]; - if (IsClient()) - { + if (IsClient()) { + int32 amt = abs(CastToClient()->GetMaxEndurance() * effect_value / 100); + if (spells[buff.spellid].max[i] && amt > spells[buff.spellid].max[i]) + amt = spells[buff.spellid].max[i]; + if (effect_value < 0) { CastToClient()->SetEndurance(CastToClient()->GetEndurance() - amt); } else { - HealDamage(amt); CastToClient()->SetEndurance(CastToClient()->GetEndurance() + amt); } }