From 64de342e49144b7b8c2829f87d6b2a9fd019f8c6 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 9 Jan 2022 14:09:24 -0500 Subject: [PATCH] Scripts/Spells: Fix shaman talent Downpour Port From (https://github.com/TrinityCore/TrinityCore/commit/f230af918b3b41c5a2209d4be48c24857028efd1) --- Source/Scripts/Spells/Shaman.cs | 45 +++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/Source/Scripts/Spells/Shaman.cs b/Source/Scripts/Spells/Shaman.cs index a86f351c3..659f109fe 100644 --- a/Source/Scripts/Spells/Shaman.cs +++ b/Source/Scripts/Spells/Shaman.cs @@ -115,10 +115,10 @@ namespace Scripts.Spells.Shaman void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) { Spell procSpell = eventInfo.GetProcSpell(); - int energize = *procSpell.GetPowerTypeCostAmount(PowerType.Maelstrom); + int? energize = procSpell.GetPowerTypeCostAmount(PowerType.Maelstrom); eventInfo.GetActor().CastSpell(eventInfo.GetActor(), SpellIds.AftershockEnergize, new CastSpellExtraArgs(energize != 0) - .AddSpellMod(SpellValueMod.BasePoint0, energize)); + .AddSpellMod(SpellValueMod.BasePoint0, energize.Value)); } public override void Register() @@ -293,6 +293,47 @@ namespace Scripts.Spells.Shaman int _targetsHit; } + [Script] // 207778 - Downpour + class spell_sha_downpour : SpellScript + { + int _healedTargets = 0; + + public override bool Validate(SpellInfo spellInfo) + { + return spellInfo.GetEffects().Count > 1; + } + + void FilterTargets(List targets) + { + uint maxTargets = 6; + if (targets.Count > maxTargets) + { + targets.Sort(new HealthPctOrderPred()); + targets.Resize(maxTargets); + } + } + + void CountEffectivelyHealedTarget() + { + // Cooldown increased for each target effectively healed + if (GetHitHeal() != 0) + ++_healedTargets; + } + + void HandleCooldown() + { + var cooldown = TimeSpan.FromMilliseconds(GetSpellInfo().RecoveryTime) + TimeSpan.FromSeconds(GetEffectInfo(1).CalcValue() * _healedTargets); + GetCaster().GetSpellHistory().StartCooldown(GetSpellInfo(), 0, GetSpell(), false, cooldown); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); + AfterHit.Add(new HitHandler(CountEffectivelyHealedTarget)); + AfterCast.Add(new CastHandler(HandleCooldown)); + } + } + [Script] // 204288 - Earth Shield class spell_sha_earth_shield : AuraScript {