From f94ce7954377e4486dae2c2603c0898dc12b2a49 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Sat, 2 Apr 2022 17:03:09 +0200 Subject: [PATCH] Core/Spells: Enraged Regeneration will now render the caster immune to other enrage effects and can no longer be activated via Vengeance --- .../world/4.3.4/2022_04_02_00_world.sql | 3 + src/server/scripts/Spells/spell_warrior.cpp | 64 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 sql/updates/world/4.3.4/2022_04_02_00_world.sql diff --git a/sql/updates/world/4.3.4/2022_04_02_00_world.sql b/sql/updates/world/4.3.4/2022_04_02_00_world.sql new file mode 100644 index 00000000000..32ec6882faa --- /dev/null +++ b/sql/updates/world/4.3.4/2022_04_02_00_world.sql @@ -0,0 +1,3 @@ +DELETE FROM `spell_script_names` WHERE `ScriptName`= 'spell_warr_enraged_regeneration'; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(55694, 'spell_warr_enraged_regeneration'); diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp index acfa6498b0f..4344e88dcc4 100644 --- a/src/server/scripts/Spells/spell_warrior.cpp +++ b/src/server/scripts/Spells/spell_warrior.cpp @@ -1025,6 +1025,69 @@ class spell_warr_heroic_fury : public SpellScript } }; +// 55694 - Enraged Regeneration +class spell_warr_enraged_regeneration : public SpellScript +{ + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_WARRIOR_VENGEANCE }); + } + + SpellCastResult CheckCast() + { + // Vengeance also applies the enrage aurastate but it does not use the enrage mechanic unlike the other enrage effects. So we check for that. + bool hasNonVengeanceEnrage = [&]() + { + for (auto& itr : GetCaster()->GetAppliedAuras()) + { + SpellInfo const* spellInfo = itr.second->GetBase()->GetSpellInfo(); + if (spellInfo->Id == SPELL_WARRIOR_VENGEANCE) + continue; + + if (spellInfo->Mechanic && ((1 << MECHANIC_ENRAGED) & (1 << spellInfo->Mechanic)) != 0) + return true; + + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + if (itr.second->HasEffect(i) && spellInfo->Effects[i].Effect && spellInfo->Effects[i].Mechanic) + if ((1 << MECHANIC_ENRAGED) & (1 << spellInfo->Effects[i].Mechanic)) + return true; + } + + return false; + }(); + + if (!hasNonVengeanceEnrage) + return SPELL_FAILED_CASTER_AURASTATE; + + return SPELL_CAST_OK; + } + + void Register() override + { + OnCheckCast.Register(&spell_warr_enraged_regeneration::CheckCast); + } +}; + + +class spell_warr_enraged_regeneration_AuraScript: public AuraScript +{ + void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + GetCaster()->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_ENRAGED, true); + } + + void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + GetCaster()->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_ENRAGED, false); + } + + void Register() override + { + AfterEffectApply.Register(&spell_warr_enraged_regeneration_AuraScript::HandleApply, EFFECT_0, SPELL_AURA_OBS_MOD_HEALTH, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove.Register(&spell_warr_enraged_regeneration_AuraScript::HandleRemove, EFFECT_0, SPELL_AURA_OBS_MOD_HEALTH, AURA_EFFECT_HANDLE_REAL); + } +}; + void AddSC_warrior_spell_scripts() { RegisterSpellScript(spell_warr_blood_craze); @@ -1035,6 +1098,7 @@ void AddSC_warrior_spell_scripts() RegisterSpellScript(spell_warr_concussion_blow); RegisterSpellScript(spell_warr_deep_wounds); RegisterSpellScript(spell_warr_devastate); + RegisterSpellAndAuraScriptPair(spell_warr_enraged_regeneration, spell_warr_enraged_regeneration_AuraScript); RegisterSpellScript(spell_warr_execute); RegisterSpellScript(spell_warr_glyph_of_sunder_armor); RegisterSpellScript(spell_warr_heroic_fury);