From 05799b4f92084fd6aa8a30c4938cce4ca68ebccb Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 17 Mar 2021 16:59:30 -0400 Subject: [PATCH] Core/Scripts: fix drink auras Port From (https://github.com/TrinityCore/TrinityCore/commit/33fbd7c7736bfe061a10e529a73e243074c90fa8) --- Source/Scripts/Spells/Generic.cs | 38 +++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/Source/Scripts/Spells/Generic.cs b/Source/Scripts/Spells/Generic.cs index a0ff33e23..414f6b639 100644 --- a/Source/Scripts/Spells/Generic.cs +++ b/Source/Scripts/Spells/Generic.cs @@ -521,6 +521,17 @@ namespace Scripts.Spells.Generic return GetCaster() && GetCaster().IsTypeId(TypeId.Player); } + public override bool Validate(SpellInfo spellInfo) + { + if (!spellInfo.GetEffect(0).IsAura() || spellInfo.GetEffect(0).ApplyAuraName != AuraType.ModPowerRegen) + { + Log.outError(LogFilter.Spells, "Aura {GetId()} structure has been changed - first aura is no longer SPELL_AURA_MOD_POWER_REGEN"); + return false; + } + + return true; + } + void CalcPeriodic(AuraEffect aurEff, ref bool isPeriodic, ref int amplitude) { // Get SPELL_AURA_MOD_POWER_REGEN aura from spell @@ -528,20 +539,20 @@ namespace Scripts.Spells.Generic if (regen == null) return; - if (regen.GetAuraType() != AuraType.ModPowerRegen) - { + // default case - not in arena + if (!GetCaster().ToPlayer().InArena()) isPeriodic = false; - Log.outError(LogFilter.Spells, $"Aura {GetId()} structure has been changed - first aura is no longer SPELL_AURA_MOD_POWER_REGEN"); - } - else - { - // default case - not in arena - if (!GetCaster().ToPlayer().InArena()) - { - regen.ChangeAmount(aurEff.GetAmount()); - isPeriodic = false; - } - } + } + + void CalcAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + AuraEffect regen = GetAura().GetEffect(0); + if (regen == null) + return; + + // default case - not in arena + if (!GetCaster().ToPlayer().InArena()) + regen.ChangeAmount(amount); } void UpdatePeriodic(AuraEffect aurEff) @@ -581,6 +592,7 @@ namespace Scripts.Spells.Generic public override void Register() { DoEffectCalcPeriodic.Add(new EffectCalcPeriodicHandler(CalcPeriodic, 1, AuraType.PeriodicDummy)); + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalcAmount, 1, AuraType.PeriodicDummy)); OnEffectUpdatePeriodic.Add(new EffectUpdatePeriodicHandler(UpdatePeriodic, 1, AuraType.PeriodicDummy)); } }