From 23a88fae6faf649a36b2a364d400351c41c2b7ef Mon Sep 17 00:00:00 2001 From: ariel- Date: Mon, 12 Feb 2018 18:34:22 -0300 Subject: Core/Scripts: remove Tenacity hack, implemented with proper aura (cherry picked from commit 404240fb6820ab997b65740b234305c4c654c543) --- src/server/scripts/Northrend/zone_wintergrasp.cpp | 34 +++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/server/scripts') diff --git a/src/server/scripts/Northrend/zone_wintergrasp.cpp b/src/server/scripts/Northrend/zone_wintergrasp.cpp index 14834ce8b1c..550b6fa3f28 100644 --- a/src/server/scripts/Northrend/zone_wintergrasp.cpp +++ b/src/server/scripts/Northrend/zone_wintergrasp.cpp @@ -29,6 +29,7 @@ #include "ScriptedGossip.h" #include "ScriptSystem.h" #include "SpellAuras.h" +#include "SpellAuraEffects.h" #include "SpellScript.h" #include "Vehicle.h" #include "WorldSession.h" @@ -587,14 +588,43 @@ class spell_wintergrasp_tenacity_refresh : public AuraScript { PrepareAuraScript(spell_wintergrasp_tenacity_refresh); - void Refresh(AuraEffect* /*aurEff*/) + bool Validate(SpellInfo const* spellInfo) override { - GetAura()->RefreshDuration(); + SpellEffectInfo const* effect2 = spellInfo->GetEffect(EFFECT_2); + if (!effect2) + return false; + uint32 triggeredSpellId = effect2->CalcValue(); + return !triggeredSpellId || ValidateSpellInfo({ triggeredSpellId }); + } + + void Refresh(AuraEffect* aurEff) + { + if (uint32 triggeredSpellId = aurEff->GetAmount()) + { + int32 bp = 0; + if (AuraEffect const* healEffect = GetEffect(EFFECT_0)) + bp = healEffect->GetAmount(); + + CastSpellExtraArgs args(aurEff); + args + .AddSpellMod(SPELLVALUE_BASE_POINT0, bp) + .AddSpellMod(SPELLVALUE_BASE_POINT1, bp); + GetTarget()->CastSpell(nullptr, triggeredSpellId, args); + } + + RefreshDuration(); + } + + void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + if (uint32 triggeredSpellId = aurEff->GetAmount()) + GetTarget()->RemoveAurasDueToSpell(triggeredSpellId); } void Register() override { OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_wintergrasp_tenacity_refresh::Refresh, EFFECT_2, SPELL_AURA_PERIODIC_DUMMY); + AfterEffectRemove += AuraEffectRemoveFn(spell_wintergrasp_tenacity_refresh::OnRemove, EFFECT_2, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); } }; -- cgit v1.2.3