From fa10b981bdc917ee95ce7a6164e5e5e05e2387ed Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sat, 7 Oct 2023 14:04:50 -0400 Subject: [PATCH] Updated all spell scripts. --- Source/Scripts/Spells/Azerite.cs | 240 +- Source/Scripts/Spells/DeathKnight.cs | 251 +- Source/Scripts/Spells/DemonHunter.cs | 109 +- Source/Scripts/Spells/Druid.cs | 852 ++++-- Source/Scripts/Spells/Evoker.cs | 71 +- Source/Scripts/Spells/Generic.cs | 2934 +++++++++---------- Source/Scripts/Spells/Hunter.cs | 308 +- Source/Scripts/Spells/{Items.cs => Item.cs} | 2495 ++++++++-------- Source/Scripts/Spells/Mage.cs | 521 ++-- Source/Scripts/Spells/Monk.cs | 218 +- Source/Scripts/Spells/Paladin.cs | 468 +-- Source/Scripts/Spells/Pet.cs | 1466 +++++++++ Source/Scripts/Spells/Priest.cs | 1626 +++++++--- Source/Scripts/Spells/Quest.cs | 1805 ++++++------ Source/Scripts/Spells/Rogue.cs | 555 ++-- Source/Scripts/Spells/Shaman.cs | 670 +++-- Source/Scripts/Spells/Warlock.cs | 260 +- Source/Scripts/Spells/Warrior.cs | 223 +- 18 files changed, 9427 insertions(+), 5645 deletions(-) rename Source/Scripts/Spells/{Items.cs => Item.cs} (51%) create mode 100644 Source/Scripts/Spells/Pet.cs diff --git a/Source/Scripts/Spells/Azerite.cs b/Source/Scripts/Spells/Azerite.cs index dc6652473..70e6464ad 100644 --- a/Source/Scripts/Spells/Azerite.cs +++ b/Source/Scripts/Spells/Azerite.cs @@ -1,4 +1,4 @@ -// Copyright (c) CypherCore All rights reserved. +// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; @@ -8,54 +8,16 @@ using Game.Scripting; using Game.Spells; using System; using System.Collections.Generic; +using System.Linq; namespace Scripts.Spells.Azerite { - struct SpellIds - { - // Strengthinnumbers - public const uint StrengthInNumbersTrait = 271546; - public const uint StrengthInNumbersBuff = 271550; - - // Blessedportents - public const uint BlessedPortentsTrait = 267889; - public const uint BlessedPortentsHeal = 280052; - - // Concentratedmending - public const uint ConcentratedMendingTrait = 267882; - - // Bracingchill - public const uint BracingChillTrait = 267884; - public const uint BracingChill = 272276; - public const uint BracingChillHeal = 272428; - public const uint BracingChillSearchJumpTarget = 272436; - - // Orbitalprecision - public const uint MageFrozenOrb = 84714; - - // Bluroftalons - public const uint HunterCoordinatedAssault = 266779; - - // Tradewinds - public const uint TradewindsAllyBuff = 281844; - - // Bastion of Might - public const uint WarriorIgnorePain = 190456; - - // Echoing Blades - public const uint EchoingBladesTrait = 287649; - - // Hour of Reaping - - public const uint DHSoulBarrier = 263648; - } - [Script] class spell_azerite_gen_aura_calc_from_2nd_effect_triggered_spell : AuraScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 1) && ValidateSpellInfo(spellInfo.GetEffect(1).TriggerSpell); + return ValidateSpellEffect((spellInfo.Id, 1)) && ValidateSpellInfo(spellInfo.GetEffect(1).TriggerSpell); } void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) @@ -63,18 +25,17 @@ namespace Scripts.Spells.Azerite Unit caster = GetCaster(); if (caster != null) { - AuraEffect trait = caster.GetAuraEffect(GetEffectInfo(1).TriggerSpell, 0); - if (trait != null) - { - amount = trait.GetAmount(); - canBeRecalculated = false; - } + amount = 0; + canBeRecalculated = false; + foreach (var (_, aurApp) in caster.GetAppliedAuras().Where(pair => pair.Key == GetEffectInfo(1).TriggerSpell)) + if (aurApp.HasEffect(0)) + amount += aurApp.GetBase().GetEffect(0).GetAmount(); } } public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModRating)); + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.ModRating)); } } @@ -95,26 +56,29 @@ namespace Scripts.Spells.Azerite public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckProc, 0, AuraType.ProcTriggerSpell)); + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.ProcTriggerSpell)); } } [Script] // 271548 - Strength in Numbers class spell_item_strength_in_numbers : SpellScript { + const uint SpellStrengthInNumbersTrait = 271546; + const uint SpellStrengthInNumbersBuff = 271550; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.StrengthInNumbersTrait, SpellIds.StrengthInNumbersBuff); + return ValidateSpellInfo(SpellStrengthInNumbersTrait, SpellStrengthInNumbersBuff); } void TriggerHealthBuff() { - AuraEffect trait = GetCaster().GetAuraEffect(SpellIds.StrengthInNumbersTrait, 0, GetCaster().GetGUID()); + AuraEffect trait = GetCaster().GetAuraEffect(SpellStrengthInNumbersTrait, 0, GetCaster().GetGUID()); if (trait != null) { long enemies = GetUnitTargetCountForEffect(0); if (enemies != 0) - GetCaster().CastSpell(GetCaster(), SpellIds.StrengthInNumbersBuff, new CastSpellExtraArgs(TriggerCastFlags.FullMask) + GetCaster().CastSpell(GetCaster(), SpellStrengthInNumbersBuff, new CastSpellExtraArgs(TriggerCastFlags.FullMask) .AddSpellMod(SpellValueMod.BasePoint0, trait.GetAmount()) .AddSpellMod(SpellValueMod.AuraStack, (int)enemies)); } @@ -122,16 +86,19 @@ namespace Scripts.Spells.Azerite public override void Register() { - AfterHit.Add(new HitHandler(TriggerHealthBuff)); + AfterHit.Add(new(TriggerHealthBuff)); } } [Script] // 271843 - Blessed Portents class spell_item_blessed_portents : AuraScript { + const uint SpellBlessedPortentsTrait = 267889; + const uint SpellBlessedPortentsHeal = 280052; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.BlessedPortentsTrait, SpellIds.BlessedPortentsHeal); + return ValidateSpellInfo(SpellBlessedPortentsTrait, SpellBlessedPortentsHeal); } void CheckProc(AuraEffect aurEff, DamageInfo dmgInfo, ref uint absorbAmount) @@ -141,10 +108,10 @@ namespace Scripts.Spells.Azerite Unit caster = GetCaster(); if (caster != null) { - AuraEffect trait = caster.GetAuraEffect(SpellIds.BlessedPortentsTrait, 0, caster.GetGUID()); + AuraEffect trait = caster.GetAuraEffect(SpellBlessedPortentsTrait, 0, caster.GetGUID()); if (trait != null) - caster.CastSpell(GetTarget(), SpellIds.BlessedPortentsHeal, new CastSpellExtraArgs(TriggerCastFlags.FullMask) - .AddSpellMod(SpellValueMod.BasePoint0, trait.GetAmount())); + caster.CastSpell(GetTarget(), SpellBlessedPortentsHeal, new CastSpellExtraArgs(TriggerCastFlags.FullMask) + .AddSpellMod(SpellValueMod.BasePoint0, trait.GetAmount())); } } else @@ -153,16 +120,18 @@ namespace Scripts.Spells.Azerite public override void Register() { - OnEffectAbsorb.Add(new EffectAbsorbHandler(CheckProc, 0)); + OnEffectAbsorb.Add(new(CheckProc, 0)); } } [Script] // 272260 - Concentrated Mending class spell_item_concentrated_mending : AuraScript { + const uint SpellConcentratedMendingTrait = 267882; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.ConcentratedMendingTrait); + return ValidateSpellInfo(SpellConcentratedMendingTrait); } void RecalculateHealAmount(AuraEffect aurEff) @@ -170,7 +139,7 @@ namespace Scripts.Spells.Azerite Unit caster = GetCaster(); if (caster != null) { - AuraEffect trait = caster.GetAuraEffect(SpellIds.ConcentratedMendingTrait, 0, caster.GetGUID()); + AuraEffect trait = caster.GetAuraEffect(SpellConcentratedMendingTrait, 0, caster.GetGUID()); if (trait != null) aurEff.ChangeAmount((int)(trait.GetAmount() * aurEff.GetTickNumber())); } @@ -178,16 +147,20 @@ namespace Scripts.Spells.Azerite public override void Register() { - OnEffectUpdatePeriodic.Add(new EffectUpdatePeriodicHandler(RecalculateHealAmount, 0, AuraType.PeriodicHeal)); + OnEffectUpdatePeriodic.Add(new(RecalculateHealAmount, 0, AuraType.PeriodicHeal)); } } [Script] // 272276 - Bracing Chill class spell_item_bracing_chill_proc : AuraScript { + const uint SpellBracingChillTrait = 267884; + const uint SpellBracingChillHeal = 272428; + const uint SpellBracingChillSearchJumpTarget = 272436; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.BracingChillTrait, SpellIds.BracingChillHeal, SpellIds.BracingChillSearchJumpTarget); + return ValidateSpellInfo(SpellBracingChillTrait, SpellBracingChillHeal, SpellBracingChillSearchJumpTarget); } bool CheckHealCaster(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -198,16 +171,16 @@ namespace Scripts.Spells.Azerite void HandleProc(AuraEffect aurEff, ProcEventInfo procInfo) { Unit caster = procInfo.GetActor(); - if (!caster) + if (caster == null) return; - AuraEffect trait = caster.GetAuraEffect(SpellIds.BracingChillTrait, 0, caster.GetGUID()); + AuraEffect trait = caster.GetAuraEffect(SpellBracingChillTrait, 0, caster.GetGUID()); if (trait != null) - caster.CastSpell(procInfo.GetProcTarget(), SpellIds.BracingChillHeal, + caster.CastSpell(procInfo.GetProcTarget(), SpellBracingChillHeal, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, trait.GetAmount())); if (GetStackAmount() > 1) - caster.CastSpell((WorldObject)null, SpellIds.BracingChillSearchJumpTarget, + caster.CastSpell(null, SpellBracingChillSearchJumpTarget, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.AuraStack, GetStackAmount() - 1)); Remove(); @@ -215,24 +188,23 @@ namespace Scripts.Spells.Azerite public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckHealCaster, 0, AuraType.Dummy)); - AfterEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckEffectProc.Add(new(CheckHealCaster, 0, AuraType.Dummy)); + AfterEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } [Script] // 272436 - Bracing Chill class spell_item_bracing_chill_search_jump_target : SpellScript { + const uint SpellBracingChill = 272276; + void FilterTarget(List targets) { if (targets.Empty()) return; List copy = new(targets); - copy.RandomResize(target => - { - return target.IsUnit() && !target.ToUnit().HasAura(SpellIds.BracingChill, GetCaster().GetGUID()); - }, 1); + copy.RandomResize(target => target.IsUnit() && !target.ToUnit().HasAura(SpellBracingChill, GetCaster().GetGUID()), 1); if (!copy.Empty()) { @@ -248,14 +220,14 @@ namespace Scripts.Spells.Azerite void MoveAura(uint effIndex) { - GetCaster().CastSpell(GetHitUnit(), SpellIds.BracingChill, + GetCaster().CastSpell(GetHitUnit(), SpellBracingChill, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.AuraStack, GetSpellValue().AuraStackAmount)); } public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTarget, 0, Targets.UnitDestAreaAlly)); - OnEffectHitTarget.Add(new EffectHandler(MoveAura, 0, SpellEffectName.Dummy)); + OnObjectAreaTargetSelect.Add(new(FilterTarget, 0, Targets.UnitDestAreaAlly)); + OnEffectHitTarget.Add(new(MoveAura, 0, SpellEffectName.Dummy)); } } @@ -269,45 +241,80 @@ namespace Scripts.Spells.Azerite public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckHealthPct, 0, AuraType.ProcTriggerSpell)); + DoCheckEffectProc.Add(new(CheckHealthPct, 0, AuraType.ProcTriggerSpell)); + } + } + + [Script] // 272892 - Wracking Brilliance + class spell_item_wracking_brilliance : AuraScript + { + const uint SpellAgonySoulShardGain = 210067; + + bool _canTrigger = true; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellAgonySoulShardGain); + } + + bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + SpellInfo spellInfo = eventInfo.GetSpellInfo(); + if (spellInfo == null) + return false; + + if (spellInfo.Id != SpellAgonySoulShardGain) + return false; + + _canTrigger = !_canTrigger; // every other soul shard gain + return _canTrigger; + } + + public override void Register() + { + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.ProcTriggerSpell)); } } [Script] // 275514 - Orbital Precision class spell_item_orbital_precision : AuraScript { + const uint SpellMageFrozenOrb = 84714; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.MageFrozenOrb); + return ValidateSpellInfo(SpellMageFrozenOrb); } bool CheckFrozenOrbActive(AuraEffect aurEff, ProcEventInfo eventInfo) { - return eventInfo.GetActor().GetAreaTrigger(SpellIds.MageFrozenOrb) != null; + return eventInfo.GetActor().GetAreaTrigger(SpellMageFrozenOrb) != null; } public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckFrozenOrbActive, 0, AuraType.ProcTriggerSpell)); + DoCheckEffectProc.Add(new(CheckFrozenOrbActive, 0, AuraType.ProcTriggerSpell)); } } [Script] // 277966 - Blur of Talons class spell_item_blur_of_talons : AuraScript { + const uint SpellHunterCoordinatedAssault = 266779; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.HunterCoordinatedAssault); + return ValidateSpellInfo(SpellHunterCoordinatedAssault); } bool CheckCoordinatedAssaultActive(AuraEffect aurEff, ProcEventInfo eventInfo) { - return eventInfo.GetActor().HasAura(SpellIds.HunterCoordinatedAssault, eventInfo.GetActor().GetGUID()); + return eventInfo.GetActor().HasAura(SpellHunterCoordinatedAssault, eventInfo.GetActor().GetGUID()); } public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckCoordinatedAssaultActive, 0, AuraType.ProcTriggerSpell)); + DoCheckEffectProc.Add(new(CheckCoordinatedAssaultActive, 0, AuraType.ProcTriggerSpell)); } } @@ -321,7 +328,7 @@ namespace Scripts.Spells.Azerite public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckHealthPct, 0, AuraType.ProcTriggerSpell)); + DoCheckEffectProc.Add(new(CheckHealthPct, 0, AuraType.ProcTriggerSpell)); } } @@ -335,57 +342,63 @@ namespace Scripts.Spells.Azerite public override void Register() { - AfterEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); + AfterEffectProc.Add(new(HandleProc, 1, AuraType.Dummy)); } } [Script] // 281843 - Tradewinds class spell_item_tradewinds : AuraScript { + const uint SpellTradewindsAllyBuff = 281844; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.TradewindsAllyBuff); + return ValidateSpellInfo(SpellTradewindsAllyBuff); } void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { AuraEffect trait = GetTarget().GetAuraEffect(GetEffectInfo(1).TriggerSpell, 1); if (trait != null) - GetTarget().CastSpell((WorldObject)null, SpellIds.TradewindsAllyBuff, + GetTarget().CastSpell(null, SpellTradewindsAllyBuff, new CastSpellExtraArgs(aurEff).AddSpellMod(SpellValueMod.BasePoint0, trait.GetAmount())); } public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.ModRating, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(HandleRemove, 0, AuraType.ModRating, AuraEffectHandleModes.Real)); } } [Script] // 287379 - Bastion of Might class spell_item_bastion_of_might : SpellScript { + const uint SpellWarriorIgnorePain = 190456; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.WarriorIgnorePain); + return ValidateSpellInfo(SpellWarriorIgnorePain); } void TriggerIgnorePain() { - GetCaster().CastSpell(GetCaster(), SpellIds.WarriorIgnorePain, GetSpell()); + GetCaster().CastSpell(GetCaster(), SpellWarriorIgnorePain, GetSpell()); } public override void Register() { - AfterHit.Add(new HitHandler(TriggerIgnorePain)); + AfterHit.Add(new(TriggerIgnorePain)); } } [Script] // 287650 - Echoing Blades class spell_item_echoing_blades : AuraScript { + ObjectGuid _lastFanOfKnives; + void PrepareProc(ProcEventInfo eventInfo) { - if (eventInfo.GetProcSpell()) + if (eventInfo.GetProcSpell() != null) { if (eventInfo.GetProcSpell().m_castId != _lastFanOfKnives) GetEffect(0).RecalculateAmount(); @@ -406,26 +419,25 @@ namespace Scripts.Spells.Azerite public override void Register() { - DoPrepareProc.Add(new AuraProcHandler(PrepareProc)); - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckFanOfKnivesCounter, 0, AuraType.ProcTriggerSpell)); - AfterEffectProc.Add(new EffectProcHandler(ReduceCounter, 0, AuraType.ProcTriggerSpell)); + DoPrepareProc.Add(new(PrepareProc)); + DoCheckEffectProc.Add(new(CheckFanOfKnivesCounter, 0, AuraType.ProcTriggerSpell)); + AfterEffectProc.Add(new(ReduceCounter, 0, AuraType.ProcTriggerSpell)); } - - ObjectGuid _lastFanOfKnives; } [Script] // 287653 - Echoing Blades class spell_item_echoing_blades_damage : SpellScript { + const uint SpellEchoingBladesTrait = 287649; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.EchoingBladesTrait) - && ValidateSpellEffect(SpellIds.EchoingBladesTrait, 2); + return ValidateSpellEffect((SpellEchoingBladesTrait, 2)); } void CalculateDamage(Unit victim, ref int damage, ref int flatMod, ref float pctMod) { - AuraEffect trait = GetCaster().GetAuraEffect(SpellIds.EchoingBladesTrait, 2); + AuraEffect trait = GetCaster().GetAuraEffect(SpellEchoingBladesTrait, 2); if (trait != null) damage = trait.GetAmount() * 2; } @@ -437,17 +449,19 @@ namespace Scripts.Spells.Azerite public override void Register() { - CalcDamage.Add(new DamageAndHealingCalcHandler(CalculateDamage)); - OnCalcCritChance.Add(new OnCalcCritChanceHandler(ForceCritical)); + CalcDamage.Add(new(CalculateDamage)); + OnCalcCritChance.Add(new(ForceCritical)); } } [Script] // 288882 - Hour of Reaping class spell_item_hour_of_reaping : AuraScript { + const uint SpellDhSoulBarrier = 263648; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.DHSoulBarrier); + return ValidateSpellInfo(SpellDhSoulBarrier); } bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -457,13 +471,13 @@ namespace Scripts.Spells.Azerite void TriggerSoulBarrier(AuraEffect aurEff, ProcEventInfo procInfo) { - GetTarget().CastSpell(GetTarget(), SpellIds.DHSoulBarrier, new CastSpellExtraArgs(aurEff)); + GetTarget().CastSpell(GetTarget(), SpellDhSoulBarrier, new CastSpellExtraArgs(aurEff)); } public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckProc, 0, AuraType.Dummy)); - AfterEffectProc.Add(new EffectProcHandler(TriggerSoulBarrier, 0, AuraType.Dummy)); + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.Dummy)); + AfterEffectProc.Add(new(TriggerSoulBarrier, 0, AuraType.Dummy)); } } @@ -482,7 +496,7 @@ namespace Scripts.Spells.Azerite public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckProc, 0, AuraType.ProcTriggerSpell)); + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.ProcTriggerSpell)); } } @@ -495,7 +509,7 @@ namespace Scripts.Spells.Azerite return true; Spell procSpell = eventInfo.GetProcSpell(); - if (!procSpell) + if (procSpell == null) return false; bool isCrowdControl = procSpell.GetSpellInfo().HasAura(AuraType.ModConfuse) @@ -515,7 +529,7 @@ namespace Scripts.Spells.Azerite public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); + DoCheckProc.Add(new(CheckProc)); } } @@ -547,8 +561,8 @@ namespace Scripts.Spells.Azerite public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(SetEquippedFlag, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(ClearEquippedFlag, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(SetEquippedFlag, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(ClearEquippedFlag, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -563,13 +577,13 @@ namespace Scripts.Spells.Azerite void CalcAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { Player player = GetUnitOwner().ToPlayer(); - amount = (int)Math.Clamp(10.0f + player.GetRatingBonusValue(CombatRating.Corruption) - player.GetRatingBonusValue(CombatRating.CorruptionResistance), 0.0f, 99.0f); + amount = (int)MathFunctions.Clamp(10.0f + player.GetRatingBonusValue(CombatRating.Corruption) - player.GetRatingBonusValue(CombatRating.CorruptionResistance), 0.0f, 99.0f); canBeRecalculated = false; } public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalcAmount, 0, AuraType.ModDecreaseSpeed)); + DoEffectCalcAmount.Add(new(CalcAmount, 0, AuraType.ModDecreaseSpeed)); } } -} +} \ No newline at end of file diff --git a/Source/Scripts/Spells/DeathKnight.cs b/Source/Scripts/Spells/DeathKnight.cs index 0eda7a9e4..1be415369 100644 --- a/Source/Scripts/Spells/DeathKnight.cs +++ b/Source/Scripts/Spells/DeathKnight.cs @@ -1,4 +1,4 @@ -// Copyright (c) CypherCore All rights reserved. +// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; @@ -9,6 +9,7 @@ using Game.Spells; using System; using System.Collections.Generic; using System.Linq; +using static Global; namespace Scripts.Spells.DeathKnight { @@ -24,13 +25,13 @@ namespace Scripts.Spells.DeathKnight public const uint BloodPlague = 55078; public const uint BloodShieldAbsorb = 77535; public const uint BloodShieldMastery = 77513; + public const uint BreathOfSindragosa = 152279; public const uint CorpseExplosionTriggered = 43999; public const uint DeathAndDecayDamage = 52212; public const uint DeathCoilDamage = 47632; public const uint DeathGripDummy = 243912; public const uint DeathGripJump = 49575; public const uint DeathGripTaunt = 51399; - public const uint DeathStrikeEnabler = 89832; //Server Side public const uint DeathStrikeHeal = 45470; public const uint DeathStrikeOffhand = 66188; public const uint FesteringWound = 194310; @@ -45,33 +46,20 @@ namespace Scripts.Spells.DeathKnight public const uint NecrosisEffect = 216974; public const uint Obliteration = 281238; public const uint ObliterationRuneEnergize = 281327; + public const uint PillarOfFrost = 51271; public const uint RaiseDeadSummon = 52150; public const uint RecentlyUsedDeathStrike = 180612; public const uint RunicPowerEnergize = 49088; public const uint RunicReturn = 61258; public const uint SludgeBelcher = 207313; public const uint SludgeBelcherSummon = 212027; + public const uint DeathStrikeEnabler = 89832; // Server Side public const uint TighteningGrasp = 206970; public const uint TighteningGraspSlow = 143375; public const uint Unholy = 137007; public const uint UnholyVigor = 196263; public const uint VolatileShielding = 207188; public const uint VolatileShieldingDamage = 207194; - - public static uint[] ArmyTransforms = - { - ArmyFleshBeastTransform, - ArmyGeistTransform, - ArmyNorthrendSkeletonTransform, - ArmySkeletonTransform, - ArmySpikedGhoulTransform, - ArmySuperZombieTransform - }; - } - - struct CreatureIds - { - public const uint DancingRuneWeapon = 27893; } [Script] // 70656 - Advantage (T10 4P Melee Bonus) @@ -80,10 +68,10 @@ namespace Scripts.Spells.DeathKnight bool CheckProc(ProcEventInfo eventInfo) { Unit caster = eventInfo.GetActor(); - if (caster) + if (caster != null) { Player player = caster.ToPlayer(); - if (!player || caster.GetClass() != Class.Deathknight) + if (player == null || caster.GetClass() != Class.Deathknight) return false; for (byte i = 0; i < player.GetMaxPower(PowerType.Runes); ++i) @@ -98,7 +86,7 @@ namespace Scripts.Spells.DeathKnight public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); + DoCheckProc.Add(new(CheckProc)); } } @@ -118,7 +106,8 @@ namespace Scripts.Spells.DeathKnight public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.RunicPowerEnergize, SpellIds.VolatileShielding) && ValidateSpellEffect(spellInfo.Id, 1); + return ValidateSpellInfo(SpellIds.RunicPowerEnergize, SpellIds.VolatileShielding) + && ValidateSpellEffect((spellInfo.Id, 1)); } public override bool Load() @@ -153,21 +142,32 @@ namespace Scripts.Spells.DeathKnight { CastSpellExtraArgs args = new(volatileShielding); args.AddSpellMod(SpellValueMod.BasePoint0, (int)MathFunctions.CalculatePct(absorbedAmount, volatileShielding.GetAmount())); - GetTarget().CastSpell((Unit)null, SpellIds.VolatileShieldingDamage, args); + GetTarget().CastSpell(null, SpellIds.VolatileShieldingDamage, args); } } public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); - AfterEffectAbsorb.Add(new EffectAbsorbHandler(Trigger, 0)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.SchoolAbsorb, AuraEffectHandleModes.Real)); + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.SchoolAbsorb)); + AfterEffectAbsorb.Add(new(Trigger, 0)); + AfterEffectRemove.Add(new(HandleEffectRemove, 0, AuraType.SchoolAbsorb, AuraEffectHandleModes.Real)); } } - [Script] // 127517 - Army Transform + // 127517 - Army Transform + [Script] /// 6.x, does this belong here or in spell_generic? where do we cast this? sniffs say this is only cast when caster has glyph of foul menagerie. class spell_dk_army_transform : SpellScript { + uint[] ArmyTransforms = + { + SpellIds.ArmyFleshBeastTransform, + SpellIds.ArmyGeistTransform, + SpellIds. ArmyNorthrendSkeletonTransform, + SpellIds.ArmySkeletonTransform, + SpellIds.ArmySpikedGhoulTransform, + SpellIds. ArmySuperZombieTransform, + }; + public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.GlyphOfFoulMenagerie); @@ -181,7 +181,7 @@ namespace Scripts.Spells.DeathKnight SpellCastResult CheckCast() { Unit owner = GetCaster().GetOwner(); - if (owner) + if (owner != null) if (owner.HasAura(SpellIds.GlyphOfFoulMenagerie)) return SpellCastResult.SpellCastOk; @@ -190,13 +190,13 @@ namespace Scripts.Spells.DeathKnight void HandleDummy(uint effIndex) { - GetCaster().CastSpell(GetCaster(), SpellIds.ArmyTransforms.SelectRandom(), true); + GetCaster().CastSpell(GetCaster(), ArmyTransforms.SelectRandom(), true); } public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnCheckCast.Add(new(CheckCast)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -215,16 +215,19 @@ namespace Scripts.Spells.DeathKnight public override void Register() { - OnHit.Add(new HitHandler(HandleEffect)); + OnHit.Add(new(HandleEffect)); } } - [Script] // 49028 - Dancing Rune Weapon + // 49028 - Dancing Rune Weapon + [Script] /// 7.1.5 class spell_dk_dancing_rune_weapon : AuraScript { + const uint NpcDkDancingRuneWeapon = 27893; + public override bool Validate(SpellInfo spellInfo) { - if (Global.ObjectMgr.GetCreatureTemplate(CreatureIds.DancingRuneWeapon) == null) + if (ObjectMgr.GetCreatureTemplate(NpcDkDancingRuneWeapon) == null) return false; return true; } @@ -234,20 +237,20 @@ namespace Scripts.Spells.DeathKnight { PreventDefaultAction(); Unit caster = GetCaster(); - if (!caster) + if (caster == null) return; Unit drw = null; foreach (Unit controlled in caster.m_Controlled) { - if (controlled.GetEntry() == CreatureIds.DancingRuneWeapon) + if (controlled.GetEntry() == NpcDkDancingRuneWeapon) { drw = controlled; break; } } - if (!drw || !drw.GetVictim()) + if (drw == null || drw.GetVictim() == null) return; SpellInfo spellInfo = eventInfo.GetSpellInfo(); @@ -267,12 +270,12 @@ namespace Scripts.Spells.DeathKnight public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 1, AuraType.Dummy)); } } [Script] // 43265 - Death and Decay - class spell_dk_death_and_decay_SpellScript : SpellScript + class spell_dk_death_and_decay : SpellScript { public override bool Validate(SpellInfo spellInfo) { @@ -285,29 +288,29 @@ namespace Scripts.Spells.DeathKnight { WorldLocation pos = GetExplTargetDest(); if (pos != null) - GetCaster().CastSpell(pos, SpellIds.TighteningGraspSlow, new CastSpellExtraArgs(true)); + GetCaster().CastSpell(pos, SpellIds.TighteningGraspSlow, true); } } public override void Register() { - OnCast.Add(new CastHandler(HandleDummy)); + OnCast.Add(new(HandleDummy)); } } - [Script] // 43265 - Death and Decay + [Script] // 43265 - Death and Decay (Aura) class spell_dk_death_and_decay_AuraScript : AuraScript { void HandleDummyTick(AuraEffect aurEff) { Unit caster = GetCaster(); - if (caster) - caster.CastSpell(GetTarget(), SpellIds.DeathAndDecayDamage, new CastSpellExtraArgs(aurEff)); + if (caster != null) + caster.CastSpell(GetTarget(), SpellIds.DeathAndDecayDamage, aurEff); } public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleDummyTick, 2, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandleDummyTick, 2, AuraType.PeriodicDummy)); } } @@ -324,13 +327,13 @@ namespace Scripts.Spells.DeathKnight Unit caster = GetCaster(); caster.CastSpell(GetHitUnit(), SpellIds.DeathCoilDamage, true); AuraEffect unholyAura = caster.GetAuraEffect(SpellIds.Unholy, 6); - if (unholyAura != null) // can be any effect, just here to send SpellFailedDontReport on failure - caster.CastSpell(caster, SpellIds.UnholyVigor, new CastSpellExtraArgs(unholyAura)); + if (unholyAura != null) // can be any effect, just here to send SpellCastResult.DontReport on failure + caster.CastSpell(caster, SpellIds.UnholyVigor, unholyAura); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -352,14 +355,14 @@ namespace Scripts.Spells.DeathKnight { PreventHitDefaultEffect(effIndex); Unit target = GetHitUnit(); - if (target) + if (target != null) target.CastSpell(target, (uint)GetEffectValue(), false); } public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckClass)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnCheckCast.Add(new(CheckClass)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -368,7 +371,7 @@ namespace Scripts.Spells.DeathKnight { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.DeathGripDummy, SpellIds.DeathGripJump, SpellIds.Blood, SpellIds.DeathGripTaunt); + return ValidateSpellInfo(SpellIds.DeathGripDummy, SpellIds.DeathGripJump, SpellIds.DeathGripTaunt, SpellIds.Blood); } SpellCastResult CheckCast() @@ -391,8 +394,8 @@ namespace Scripts.Spells.DeathKnight public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ScriptEffect)); + OnCheckCast.Add(new(CheckCast)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.ScriptEffect)); } } @@ -403,17 +406,17 @@ namespace Scripts.Spells.DeathKnight { return ValidateSpellEffect((spellInfo.Id, 2)); } - + void HandleCalcAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { Unit caster = GetCaster(); - if (caster) + if (caster != null) amount = (int)caster.CountPctFromMaxHealth(GetEffectInfo(2).CalcValue(caster)); } public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(HandleCalcAmount, 1, AuraType.SchoolHealAbsorb)); + DoEffectCalcAmount.Add(new(HandleCalcAmount, 1, AuraType.SchoolHealAbsorb)); } } @@ -422,8 +425,8 @@ namespace Scripts.Spells.DeathKnight { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.DeathStrikeEnabler, SpellIds.DeathStrikeHeal, SpellIds.BloodShieldMastery, SpellIds.BloodShieldAbsorb, SpellIds.RecentlyUsedDeathStrike, SpellIds.Frost, SpellIds.DeathStrikeOffhand) - && ValidateSpellEffect(spellInfo.Id, 2); + return ValidateSpellInfo(SpellIds.DeathStrikeEnabler, SpellIds.DeathStrikeHeal, SpellIds.BloodShieldMastery, SpellIds.BloodShieldAbsorb, SpellIds.Frost, SpellIds.DeathStrikeOffhand) + && ValidateSpellEffect((spellInfo.Id, 2)); } void HandleDummy(uint effIndex) @@ -457,16 +460,18 @@ namespace Scripts.Spells.DeathKnight public override void Register() { - OnEffectLaunch.Add(new EffectHandler(HandleDummy, 1, SpellEffectName.Dummy)); - AfterCast.Add(new CastHandler(TriggerRecentlyUsedDeathStrike)); + OnEffectLaunch.Add(new(HandleDummy, 1, SpellEffectName.Dummy)); + AfterCast.Add(new(TriggerRecentlyUsedDeathStrike)); } } - [Script] // 89832 - Death Strike Enabler - SPELL_DK_DEATH_STRIKE_ENABLER + [Script] // 89832 - Death Strike Enabler - SpellDeathStrikeEnabler class spell_dk_death_strike_enabler : AuraScript { // Amount of seconds we calculate damage over - uint[] _damagePerSecond = new uint[5]; + const byte LastSeconds = 5; + + uint[] _damagePerSecond = new uint[LastSeconds]; bool CheckProc(ProcEventInfo eventInfo) { @@ -493,13 +498,13 @@ namespace Scripts.Spells.DeathKnight public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicDummy)); - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(HandleCalcAmount, 0, AuraType.PeriodicDummy)); - OnEffectUpdatePeriodic.Add(new EffectUpdatePeriodicHandler(Update, 0, AuraType.PeriodicDummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.PeriodicDummy)); + DoEffectCalcAmount.Add(new(HandleCalcAmount, 0, AuraType.PeriodicDummy)); + OnEffectUpdatePeriodic.Add(new(Update, 0, AuraType.PeriodicDummy)); } } - + [Script] // 85948 - Festering Strike class spell_dk_festering_strike : SpellScript { @@ -515,7 +520,7 @@ namespace Scripts.Spells.DeathKnight public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 1, SpellEffectName.Dummy)); } } @@ -524,7 +529,7 @@ namespace Scripts.Spells.DeathKnight { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.CorpseExplosionTriggered) && ValidateSpellEffect(spellInfo.Id, 2); + return ValidateSpellInfo(SpellIds.CorpseExplosionTriggered) && ValidateSpellEffect((spellInfo.Id, 2)); } void HandleDamage(uint effIndex) @@ -535,7 +540,7 @@ namespace Scripts.Spells.DeathKnight void Suicide(uint effIndex) { Unit unitTarget = GetHitUnit(); - if (unitTarget) + if (unitTarget != null) { // Corpse Explosion (Suicide) unitTarget.CastSpell(unitTarget, SpellIds.CorpseExplosionTriggered, true); @@ -544,8 +549,8 @@ namespace Scripts.Spells.DeathKnight public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDamage, 0, SpellEffectName.SchoolDamage)); - OnEffectHitTarget.Add(new EffectHandler(Suicide, 1, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new(HandleDamage, 0, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new(Suicide, 1, SpellEffectName.SchoolDamage)); } } @@ -562,7 +567,7 @@ namespace Scripts.Spells.DeathKnight { SpellInfo spellInfo = aurEff.GetSpellInfo(); // search our Blood Plague and Frost Fever on target - if (spellInfo.SpellFamilyName == SpellFamilyNames.Deathknight && spellInfo.SpellFamilyFlags[2].HasAnyFlag(0x2u) && + if (spellInfo.SpellFamilyName == SpellFamilyNames.Deathknight && (spellInfo.SpellFamilyFlags[2] & 0x2) != 0 && aurEff.GetCasterGUID() == caster.GetGUID()) { int countMin = aurEff.GetBase().GetMaxDuration(); @@ -582,7 +587,7 @@ namespace Scripts.Spells.DeathKnight public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } @@ -601,10 +606,10 @@ namespace Scripts.Spells.DeathKnight public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleFrostFever, 0, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new(HandleFrostFever, 0, SpellEffectName.SchoolDamage)); } } - + [Script] // 206940 - Mark of Blood class spell_dk_mark_of_blood : AuraScript { @@ -617,13 +622,13 @@ namespace Scripts.Spells.DeathKnight { PreventDefaultAction(); Unit caster = GetCaster(); - if (caster) + if (caster != null) caster.CastSpell(eventInfo.GetProcTarget(), SpellIds.MarkOfBloodHeal, true); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -643,7 +648,7 @@ namespace Scripts.Spells.DeathKnight public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -653,27 +658,28 @@ namespace Scripts.Spells.DeathKnight public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.Obliteration, SpellIds.ObliterationRuneEnergize, SpellIds.KillingMachineProc) - && ValidateSpellEffect(SpellIds.Obliteration, 1); + && ValidateSpellEffect((SpellIds.Obliteration, 1)); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { Unit target = GetTarget(); - target.CastSpell(target, SpellIds.KillingMachineProc, new CastSpellExtraArgs(aurEff)); + target.CastSpell(target, SpellIds.KillingMachineProc, aurEff); AuraEffect oblitaration = target.GetAuraEffect(SpellIds.Obliteration, 1); if (oblitaration != null) if (RandomHelper.randChance(oblitaration.GetAmount())) - target.CastSpell(target, SpellIds.ObliterationRuneEnergize, new CastSpellExtraArgs(aurEff)); + target.CastSpell(target, SpellIds.ObliterationRuneEnergize, aurEff); } public override void Register() { - AfterEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + AfterEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } - - [Script] // 121916 - Glyph of the Geist (Unholy) + + // 121916 - Glyph of the Geist (Unholy) + [Script] /// 6.x, does this belong here or in spell_generic? apply this in creature_template_addon? sniffs say this is always cast on raise dead. class spell_dk_pet_geist_transform : SpellScript { public override bool Validate(SpellInfo spellInfo) @@ -689,7 +695,7 @@ namespace Scripts.Spells.DeathKnight SpellCastResult CheckCast() { Unit owner = GetCaster().GetOwner(); - if (owner) + if (owner != null) if (owner.HasAura(SpellIds.GlyphOfTheGeist)) return SpellCastResult.SpellCastOk; @@ -698,11 +704,12 @@ namespace Scripts.Spells.DeathKnight public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); + OnCheckCast.Add(new(CheckCast)); } } - [Script] // 147157 Glyph of the Skeleton (Unholy) + // 147157 Glyph of the Skeleton (Unholy) + [Script] /// 6.x, does this belong here or in spell_generic? apply this in creature_template_addon? sniffs say this is always cast on raise dead. class spell_dk_pet_skeleton_transform : SpellScript { public override bool Validate(SpellInfo spellInfo) @@ -713,7 +720,7 @@ namespace Scripts.Spells.DeathKnight SpellCastResult CheckCast() { Unit owner = GetCaster().GetOwner(); - if (owner) + if (owner != null) if (owner.HasAura(SpellIds.GlyphOfTheSkeleton)) return SpellCastResult.SpellCastOk; @@ -722,11 +729,12 @@ namespace Scripts.Spells.DeathKnight public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); + OnCheckCast.Add(new(CheckCast)); } } - [Script] // 61257 - Runic Power Back on Snare/Root + // 61257 - Runic Power Back on Snare/Root + [Script] /// 7.1.5 class spell_dk_pvp_4p_bonus : AuraScript { public override bool Validate(SpellInfo spellInfo) @@ -746,13 +754,13 @@ namespace Scripts.Spells.DeathKnight void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - eventInfo.GetActionTarget().CastSpell((Unit)null, SpellIds.RunicReturn, true); + eventInfo.GetActionTarget().CastSpell(null, SpellIds.RunicReturn, true); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -770,12 +778,12 @@ namespace Scripts.Spells.DeathKnight if (GetCaster().HasAura(SpellIds.SludgeBelcher)) spellId = SpellIds.SludgeBelcherSummon; - GetCaster().CastSpell((Unit)null, spellId, true); + GetCaster().CastSpell(null, spellId, true); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -784,7 +792,7 @@ namespace Scripts.Spells.DeathKnight { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 1) && ValidateSpellInfo(SpellIds.FrostScythe); + return ValidateSpellEffect((spellInfo.Id, 1)) && ValidateSpellInfo(SpellIds.FrostScythe); } bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -798,10 +806,53 @@ namespace Scripts.Spells.DeathKnight public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckProc, 0, AuraType.ProcTriggerSpell)); + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.ProcTriggerSpell)); } } - + + [Script] // 242057 - Rune Empowered + class spell_dk_t20_2p_rune_empowered : AuraScript + { + int _runicPowerSpent; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.PillarOfFrost, SpellIds.BreathOfSindragosa); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo procInfo) + { + Spell procSpell = procInfo.GetProcSpell(); + if (procSpell == null) + return; + + Aura pillarOfFrost = GetTarget().GetAura(SpellIds.PillarOfFrost); + if (pillarOfFrost == null) + return; + + _runicPowerSpent += procSpell.GetPowerTypeCostAmount(PowerType.RunicPower).GetValueOrDefault(0); + // Breath of Math.Sindragosa special case + SpellInfo breathOfSindragosa = SpellMgr.GetSpellInfo(SpellIds.BreathOfSindragosa, Difficulty.None); + if (procSpell.IsTriggeredByAura(breathOfSindragosa)) + { + var powerRecord = breathOfSindragosa.PowerCosts.ToList().Find(power => power.PowerType == PowerType.RunicPower && power.PowerPctPerSecond > 0.0f); + if (powerRecord != null) + _runicPowerSpent += MathFunctions.CalculatePct(GetTarget().GetMaxPower(PowerType.RunicPower), powerRecord.PowerPctPerSecond); + } + + if (_runicPowerSpent >= 600) + { + pillarOfFrost.SetDuration(pillarOfFrost.GetDuration() + 1000); + _runicPowerSpent -= 600; + } + } + + public override void Register() + { + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); + } + } + [Script] // 55233 - Vampiric Blood class spell_dk_vampiric_blood : AuraScript { @@ -812,7 +863,7 @@ namespace Scripts.Spells.DeathKnight public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 1, AuraType.ModIncreaseHealth2)); + DoEffectCalcAmount.Add(new(CalculateAmount, 1, AuraType.ModIncreaseHealth2)); } } } \ No newline at end of file diff --git a/Source/Scripts/Spells/DemonHunter.cs b/Source/Scripts/Spells/DemonHunter.cs index a3c178927..4bd41940d 100644 --- a/Source/Scripts/Spells/DemonHunter.cs +++ b/Source/Scripts/Spells/DemonHunter.cs @@ -1,13 +1,17 @@ -// Copyright (c) CypherCore All rights reserved. +// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; +using Framework.Dynamic; using Game.AI; using Game.Entities; using Game.Scripting; using Game.Spells; using System; using System.Collections.Generic; +using System.Linq; + +using static Global; namespace Scripts.Spells.DemonHunter { @@ -133,6 +137,7 @@ namespace Scripts.Spells.DemonHunter public const uint SoulCleave = 228477; public const uint SoulCleaveDmg = 228478; public const uint SoulFragmentCounter = 203981; + public const uint SoulFurnaceDamageBuff = 391172; public const uint SoulRending = 204909; public const uint SpiritBombDamage = 218677; public const uint SpiritBombHeal = 227255; @@ -143,16 +148,6 @@ namespace Scripts.Spells.DemonHunter public const uint VengefulRetreatTrigger = 198793; } - struct AreaTriggerIds - { - public const uint ShatteredSoulsHavoc = 8352; - public const uint ShatteredSoulsHavocDemon = 11231; - public const uint ShatteredSoulsVengeance = 11266; - public const uint ShatteredSoulsVengeanceDemon = 10693; - public const uint SoulFragmentHavoc = 12929; - public const uint SoulFragmentVengeance = 10665; - } - [Script] // 197125 - Chaos Strike class spell_dh_chaos_strike : AuraScript { @@ -172,7 +167,7 @@ namespace Scripts.Spells.DemonHunter public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.ProcTriggerSpell)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.ProcTriggerSpell)); } } @@ -182,6 +177,7 @@ namespace Scripts.Spells.DemonHunter ObjectGuid _firstTargetGUID; public ObjectGuid GetFirstTarget() { return _firstTargetGUID; } + public void SetFirstTarget(ObjectGuid targetGuid) { _firstTargetGUID = targetGuid; } public override void Register() { } @@ -211,9 +207,9 @@ namespace Scripts.Spells.DemonHunter // Prefer the selected target if he is one of the enemies if (targetList.Count > 1 && !selectedTarget.IsEmpty()) { - var foundObj = targetList.Find(obj => obj.GetGUID() == selectedTarget); - if (foundObj != null) - firstTargetGUID = foundObj.GetGUID(); + var obj = targetList.Find(obj => obj.GetGUID() == selectedTarget); + if (obj != null) + firstTargetGUID = obj.GetGUID(); } if (firstTargetGUID.IsEmpty()) @@ -226,7 +222,7 @@ namespace Scripts.Spells.DemonHunter public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(DecideFirstTarget, 0, Targets.UnitSrcAreaEnemy)); + OnObjectAreaTargetSelect.Add(new(DecideFirstTarget, 0, Targets.UnitSrcAreaEnemy)); } } @@ -259,13 +255,10 @@ namespace Scripts.Spells.DemonHunter public override void Register() { - OnHit.Add(new HitHandler(HandleHitTarget)); + OnHit.Add(new(HandleHitTarget)); } } - // 204596 - Sigil of Flame - // 207684 - Sigil of Misery - // 202137 - Sigil of Silence [Script("areatrigger_dh_sigil_of_silence", SpellIds.SigilOfSilenceAoe)] [Script("areatrigger_dh_sigil_of_misery", SpellIds.SigilOfMiseryAoe)] [Script("areatrigger_dh_sigil_of_flame", SpellIds.SigilOfFlameAoe)] @@ -282,7 +275,7 @@ namespace Scripts.Spells.DemonHunter { Unit caster = at.GetCaster(); if (caster != null) - caster.CastSpell(at.GetPosition(), _trigger, new CastSpellExtraArgs()); + caster.CastSpell(at.GetPosition(), _trigger); } } @@ -299,14 +292,14 @@ namespace Scripts.Spells.DemonHunter WorldLocation loc = GetExplTargetDest(); if (loc != null) { - GetCaster().CastSpell(GetHitUnit(), SpellIds.SigilOfChainsSlow, new CastSpellExtraArgs(true)); - GetHitUnit().CastSpell(loc.GetPosition(), SpellIds.SigilOfChainsGrip, new CastSpellExtraArgs(true)); + GetCaster().CastSpell(GetHitUnit(), SpellIds.SigilOfChainsSlow, true); + GetHitUnit().CastSpell(loc.GetPosition(), SpellIds.SigilOfChainsGrip, true); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleEffectHitTarget, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleEffectHitTarget, 0, SpellEffectName.Dummy)); } } @@ -320,8 +313,8 @@ namespace Scripts.Spells.DemonHunter Unit caster = at.GetCaster(); if (caster != null) { - caster.CastSpell(at.GetPosition(), SpellIds.SigilOfChainsVisual, new CastSpellExtraArgs()); - caster.CastSpell(at.GetPosition(), SpellIds.SigilOfChainsTargetSelect, new CastSpellExtraArgs()); + caster.CastSpell(at.GetPosition(), SpellIds.SigilOfChainsVisual); + caster.CastSpell(at.GetPosition(), SpellIds.SigilOfChainsTargetSelect); } } } @@ -349,20 +342,20 @@ namespace Scripts.Spells.DemonHunter void HandleCast() { Player caster = GetCaster().ToPlayer(); - if (!caster) + if (caster == null) return; caster.CastSpell(caster, SpellIds.GlideKnockback, true); caster.CastSpell(caster, SpellIds.GlideDuration, true); - caster.GetSpellHistory().StartCooldown(Global.SpellMgr.GetSpellInfo(SpellIds.VengefulRetreatTrigger, GetCastDifficulty()), 0, null, false, TimeSpan.FromMilliseconds(250)); - caster.GetSpellHistory().StartCooldown(Global.SpellMgr.GetSpellInfo(SpellIds.FelRush, GetCastDifficulty()), 0, null, false, TimeSpan.FromMilliseconds(250)); + caster.GetSpellHistory().StartCooldown(SpellMgr.GetSpellInfo(SpellIds.VengefulRetreatTrigger, GetCastDifficulty()), 0, null, false, TimeSpan.FromMilliseconds(250)); + caster.GetSpellHistory().StartCooldown(SpellMgr.GetSpellInfo(SpellIds.FelRush, GetCastDifficulty()), 0, null, false, TimeSpan.FromMilliseconds(250)); } public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - BeforeCast.Add(new CastHandler(HandleCast)); + OnCheckCast.Add(new(CheckCast)); + BeforeCast.Add(new(HandleCast)); } } @@ -381,7 +374,7 @@ namespace Scripts.Spells.DemonHunter public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.FeatherFall, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(OnRemove, 0, AuraType.FeatherFall, AuraEffectHandleModes.Real)); } } @@ -400,7 +393,55 @@ namespace Scripts.Spells.DemonHunter public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } -} + + [Script] // 391166 - Soul Furnace + class spell_dh_soul_furnace : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.SoulFurnaceDamageBuff); + } + + void CalculateSpellMod(AuraEffect aurEff, AuraEffectHandleModes mode) + { + if (GetStackAmount() == GetAura().CalcMaxStackAmount()) + { + GetTarget().CastSpell(GetTarget(), SpellIds.SoulFurnaceDamageBuff, true); + Remove(); + } + } + + public override void Register() + { + AfterEffectApply.Add(new(CalculateSpellMod, 0, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); + } + } + + [Script] // 339424 - Soul Furnace + class spell_dh_soul_furnace_conduit : AuraScript + { + void CalculateSpellMod(AuraEffect aurEff, ref SpellModifier spellMod) + { + if (aurEff.GetAmount() == 10) + { + if (spellMod == null) + { + spellMod = new SpellModifierByClassMask(GetAura()); + spellMod.op = SpellModOp.HealingAndDamage; + spellMod.type = SpellModType.Pct; + spellMod.spellId = GetId(); + (spellMod as SpellModifierByClassMask).mask = new FlagArray128(0x80000000); + (spellMod as SpellModifierByClassMask).value = GetEffect(1).GetAmount() + 1; + } + } + } + + public override void Register() + { + DoEffectCalcSpellMod.Add(new(CalculateSpellMod, 0, AuraType.Dummy)); + } + } +} \ No newline at end of file diff --git a/Source/Scripts/Spells/Druid.cs b/Source/Scripts/Spells/Druid.cs index e961d635e..7992cf687 100644 --- a/Source/Scripts/Spells/Druid.cs +++ b/Source/Scripts/Spells/Druid.cs @@ -1,20 +1,22 @@ -// Copyright (c) CypherCore All rights reserved. +// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; using Framework.Dynamic; -using Game.DataStorage; using Game.Entities; +using Game.Maps; using Game.Scripting; using Game.Spells; using System; using System.Collections.Generic; -using System.Linq; +using static Global; namespace Scripts.Spells.Druid { struct SpellIds { + public const uint Abundance = 207383; + public const uint AbundanceEffect = 207640; public const uint BalanceT10Bonus = 70718; public const uint BalanceT10BonusProc = 70721; public const uint BearForm = 5487; @@ -26,9 +28,11 @@ namespace Scripts.Spells.Druid public const uint BloodFrenzyRageGain = 203961; public const uint BramblesDamageAura = 213709; public const uint BramblesPassive = 203953; - public const uint BramblesRelect = 203958; + public const uint BramblesReflect = 203958; public const uint BristlingFurGainRage = 204031; public const uint CatForm = 768; + public const uint Cultivation = 200390; + public const uint CultivationHeal = 200389; public const uint CuriousBramblepatch = 330670; public const uint EarthwardenAura = 203975; public const uint EclipseDummy = 79577; @@ -37,6 +41,10 @@ namespace Scripts.Spells.Druid public const uint EclipseOoc = 329910; public const uint EclipseSolarAura = 48517; public const uint EclipseSolarSpellCnt = 326053; + public const uint EfflorescenceAura = 81262; + public const uint EfflorescenceHeal = 81269; + public const uint EmbraceOfTheDreamEffect = 392146; + public const uint EmbraceOfTheDreamHeal = 392147; public const uint EntanglingRoots = 339; public const uint Exhilarate = 28742; public const uint FormAquaticPassive = 276012; @@ -50,12 +58,17 @@ namespace Scripts.Spells.Druid public const uint FormsTrinketNone = 37344; public const uint FormsTrinketTree = 37342; public const uint GalacticGuardianAura = 213708; + public const uint Germination = 155675; public const uint GlyphOfStars = 114301; public const uint GlyphOfStarsVisual = 114302; public const uint GoreProc = 93622; + public const uint Growl = 6795; public const uint IdolOfFeralShadows = 34241; public const uint IdolOfWorship = 60774; + public const uint Incarnation = 117679; public const uint IncarnationKingOfTheJungle = 102543; + public const uint IncarnationTreeOfLife = 33891; + public const uint InnerPeace = 197073; public const uint Innervate = 29166; public const uint InnervateRank2 = 326228; public const uint Infusion = 37238; @@ -65,7 +78,11 @@ namespace Scripts.Spells.Druid public const uint Mangle = 33917; public const uint MassEntanglement = 102359; public const uint MoonfireDamage = 164812; + public const uint PowerOfTheArchdruid = 392302; public const uint Prowl = 5215; + public const uint Regrowth = 8936; + public const uint Rejuvenation = 774; + public const uint RejuvenationGermination = 155777; public const uint RejuvenationT10Proc = 70691; public const uint RestorationT102PBonus = 70658; public const uint SavageRoar = 62071; @@ -73,9 +90,12 @@ namespace Scripts.Spells.Druid public const uint ShootingStarsDamage = 202497; public const uint SkullBashCharge = 221514; public const uint SkullBashInterrupt = 93985; + public const uint SpringBlossoms = 207385; + public const uint SpringBlossomsHeal = 207386; public const uint SunfireDamage = 164815; public const uint SurvivalInstincts = 50322; public const uint TravelForm = 783; + public const uint TreeOfLife = 33891; public const uint ThrashBear = 77758; public const uint ThrashBearAura = 192090; public const uint ThrashCat = 106830; @@ -83,6 +103,50 @@ namespace Scripts.Spells.Druid public const uint YserasGiftHealSelf = 145109; } + // 774 - Rejuvenation + [Script] // 155777 - Rejuvenation (Germination) + class spell_dru_abundance : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.Abundance, SpellIds.AbundanceEffect); + } + + void HandleOnApplyOrReapply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit caster = GetCaster(); + if (caster == null || !caster.HasAura(SpellIds.Abundance)) + return; + + // Note: caster only casts Abundance when first applied on the target, otherwise that given stack is refreshed. + if (mode.HasFlag(AuraEffectHandleModes.Real)) + caster.CastSpell(caster, SpellIds.AbundanceEffect, new CastSpellExtraArgs().SetTriggeringAura(aurEff)); + else + { + Aura abundanceAura = caster.GetAura(SpellIds.AbundanceEffect); + if (abundanceAura != null) + abundanceAura.RefreshDuration(); + } + } + + void HandleOnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit caster = GetCaster(); + if (caster == null) + return; + + Aura abundanceEffect = caster.GetAura(SpellIds.AbundanceEffect); + if (abundanceEffect != null) + abundanceEffect.ModStackAmount(-1); + } + + public override void Register() + { + AfterEffectApply.Add(new(HandleOnApplyOrReapply, 0, AuraType.PeriodicHeal, AuraEffectHandleModes.RealOrReapplyMask)); + AfterEffectRemove.Add(new(HandleOnRemove, 0, AuraType.PeriodicHeal, AuraEffectHandleModes.Real)); + } + } + [Script] // 22812 - Barkskin class spell_dru_barkskin : AuraScript { @@ -100,16 +164,16 @@ namespace Scripts.Spells.Druid public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodic, 2, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandlePeriodic, 2, AuraType.PeriodicDummy)); } } - [Script] // 77758 - Berserk + [Script] // 50334 - Berserk class spell_dru_berserk : SpellScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.BearForm); + return ValidateSpellInfo(SpellIds.BearForm, SpellIds.Mangle, SpellIds.ThrashBear, SpellIds.Growl); } void HandleOnCast() @@ -119,18 +183,26 @@ namespace Scripts.Spells.Druid GetCaster().CastSpell(GetCaster(), SpellIds.BearForm, true); } + void ResetCooldowns() + { + GetCaster().GetSpellHistory().ResetCooldown(SpellIds.Mangle); + GetCaster().GetSpellHistory().ResetCooldown(SpellIds.ThrashBear); + GetCaster().GetSpellHistory().ResetCooldown(SpellIds.Growl); + } + public override void Register() { - BeforeCast.Add(new CastHandler(HandleOnCast)); + BeforeCast.Add(new(HandleOnCast)); + AfterCast.Add(new(ResetCooldowns)); } } - [Script] // 203953 - Brambles - SPELL_DRUID_BRAMBLES_PASSIVE + [Script] // 203953 - Brambles - SpellBramblesPassive class spell_dru_brambles : AuraScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.BramblesRelect, SpellIds.BramblesDamageAura); + return ValidateSpellInfo(SpellIds.BramblesReflect, SpellIds.BramblesDamageAura); } void HandleAbsorb(AuraEffect aurEff, DamageInfo dmgInfo, ref uint absorbAmount) @@ -145,13 +217,13 @@ namespace Scripts.Spells.Druid Unit target = GetTarget(); Unit attacker = dmgInfo.GetAttacker(); if (attacker != null) - target.CastSpell(attacker, SpellIds.BramblesRelect, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, (int)absorbAmount)); + target.CastSpell(attacker, SpellIds.BramblesReflect, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, (int)absorbAmount)); } public override void Register() { - OnEffectAbsorb.Add(new EffectAbsorbHandler(HandleAbsorb, 0)); - AfterEffectAbsorb.Add(new EffectAbsorbHandler(HandleAfterAbsorb, 0)); + OnEffectAbsorb.Add(new(HandleAbsorb, 0)); + AfterEffectAbsorb.Add(new(HandleAfterAbsorb, 0)); } } @@ -178,11 +250,11 @@ namespace Scripts.Spells.Druid public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } - [Script] // 768 - CatForm - SPELL_DRUID_CAT_FORM + [Script] // 768 - CatForm - SpellCatForm class spell_dru_cat_form : AuraScript { public override bool Validate(SpellInfo spellInfo) @@ -197,12 +269,40 @@ namespace Scripts.Spells.Druid public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(HandleAfterRemove, 0, AuraType.ModShapeshift, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(HandleAfterRemove, 0, AuraType.ModShapeshift, AuraEffectHandleModes.Real)); + } + } + + // 774 - Rejuvenation + [Script] // 155777 - Rejuventation (Germination) + class spell_dru_cultivation : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.CultivationHeal) && ValidateSpellEffect((SpellIds.Cultivation, 0)); + } + + void HandleOnTick(AuraEffect aurEff) + { + Unit caster = GetCaster(); + if (caster == null) + return; + + Unit target = GetTarget(); + AuraEffect cultivationEffect = caster.GetAuraEffect(SpellIds.Cultivation, 0); + if (cultivationEffect != null) + if (target.HealthBelowPct(cultivationEffect.GetAmount())) + caster.CastSpell(target, SpellIds.CultivationHeal, new CastSpellExtraArgs().SetTriggeringAura(aurEff)); + } + + public override void Register() + { + OnEffectPeriodic.Add(new(HandleOnTick, 0, AuraType.PeriodicHeal)); } } [Script] // 1850 - Dash - public class spell_dru_dash : AuraScript + class spell_dru_dash : AuraScript { void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { @@ -213,7 +313,27 @@ namespace Scripts.Spells.Druid public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModIncreaseSpeed)); + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.ModIncreaseSpeed)); + } + } + + [Script] // 203974 - Earthwarden + class spell_dru_earthwarden : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.ThrashCat, SpellIds.ThrashBear, SpellIds.EarthwardenAura); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + Unit target = GetTarget(); + target.CastSpell(target, SpellIds.EarthwardenAura, true); + } + + public override void Register() + { + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -230,7 +350,7 @@ namespace Scripts.Spells.Druid } [Script] // 48517 Eclipse (Solar) + 48518 Eclipse (Lunar) - class spell_dru_eclipse_aura : AuraScript + class spell_dru_eclipse_AuraScript : AuraScript { public override bool Validate(SpellInfo spellInfo) { @@ -249,11 +369,11 @@ namespace Scripts.Spells.Druid public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(HandleRemoved, 0, AuraType.AddPctModifier, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(HandleRemoved, 0, AuraType.AddPctModifier, AuraEffectHandleModes.Real)); } } - [Script] // 79577 - Eclipse - SPELL_DRUID_ECLIPSE_DUMMY + [Script] // 79577 - Eclipse - SpellEclipseDummy class spell_dru_eclipse_dummy : AuraScript { class InitializeEclipseCountersEvent : BasicEvent @@ -307,15 +427,15 @@ namespace Scripts.Spells.Druid void OnOwnerOutOfCombat(bool isNowInCombat) { if (!isNowInCombat) - GetTarget().CastSpell(GetTarget(), SpellIds.EclipseOoc, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + GetTarget().CastSpell(GetTarget(), SpellIds.EclipseOoc, TriggerCastFlags.FullMask); } public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - OnProc.Add(new AuraProcHandler(HandleProc)); - OnEnterLeaveCombat.Add(new EnterLeaveCombatHandler(OnOwnerOutOfCombat)); + AfterEffectApply.Add(new(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(HandleRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnProc.Add(new(HandleProc)); + OnEnterLeaveCombat.Add(new(OnOwnerOutOfCombat)); } void OnSpellCast(uint cntSpellId, uint otherCntSpellId, uint eclipseAuraSpellId) @@ -333,7 +453,7 @@ namespace Scripts.Spells.Druid else { // cast eclipse - target.CastSpell(target, eclipseAuraSpellId, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + target.CastSpell(target, eclipseAuraSpellId, TriggerCastFlags.FullMask); // Remove stacks from other one as well // reset remaining power on other spellId @@ -344,7 +464,7 @@ namespace Scripts.Spells.Druid } } - [Script] // 329910 - Eclipse out of combat - SPELL_DRUID_ECLIPSE_OOC + [Script] // 329910 - Eclipse out of combat - SpellEclipseOoc class spell_dru_eclipse_ooc : AuraScript { public override bool Validate(SpellInfo spellInfo) @@ -369,27 +489,129 @@ namespace Scripts.Spells.Druid public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(Tick, 0, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(Tick, 0, AuraType.PeriodicDummy)); } } - [Script] // 203974 - Earthwarden - class spell_dru_earthwarden : AuraScript + [Script] // 145205 - Efflorescence + class spell_dru_efflorescence : SpellScript { - public override bool Validate(SpellInfo spellInfo) + void RemoveOldAreaTrigger(uint effIndex) { - return ValidateSpellInfo(SpellIds.ThrashCat, SpellIds.ThrashBear, SpellIds.EarthwardenAura); + // if caster has any Efflorescence areatrigger, we Remove it. + GetCaster().RemoveAreaTrigger(GetSpellInfo().Id); } - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + void InitSummon() { - Unit target = GetTarget(); - target.CastSpell(target, SpellIds.EarthwardenAura, true); + foreach (var summonedObject in GetSpell().GetExecuteLogEffect(SpellEffectName.Summon).GenericVictimTargets) + { + Unit summon = ObjectAccessor.GetCreature(GetCaster(), summonedObject.Victim); + if (summon != null) + summon.CastSpell(summon, SpellIds.EfflorescenceAura, + new CastSpellExtraArgs().SetTriggeringSpell(GetSpell())); + } } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectLaunch.Add(new(RemoveOldAreaTrigger, 2, SpellEffectName.CreateAreaTrigger)); + AfterCast.Add(new(InitSummon)); + } + } + + [Script] // 81262 - Efflorescence (Dummy) + class spell_dru_efflorescence_dummy : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.EfflorescenceHeal); + } + + void HandlePeriodicDummy(AuraEffect aurEff) + { + Unit target = GetTarget(); + Unit summoner = target.GetOwner(); + if (summoner == null) + return; + + summoner.CastSpell(target, SpellIds.EfflorescenceHeal, TriggerCastFlags.DontReportCastError); + } + + public override void Register() + { + OnEffectPeriodic.Add(new(HandlePeriodicDummy, 0, AuraType.PeriodicDummy)); + } + } + + [Script] // 81269 - Efflorescence (Heal) + class spell_dru_efflorescence_heal : SpellScript + { + void FilterTargets(List targets) + { + // Efflorescence became a smart heal which prioritizes players and their pets in their group before any unit outside their group. + SelectRandomInjuredTargets(targets, 3, true, GetCaster()); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitDestAreaAlly)); + } + } + + [Script] // 392124 - Embrace of the Dream + class spell_dru_embrace_of_the_dream : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.EmbraceOfTheDreamEffect) + && ValidateSpellEffect((spellInfo.Id, 2)); + } + + bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + return RandomHelper.randChance(GetEffectInfo(2).CalcValue(GetCaster())); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + GetTarget().CastSpell(GetTarget(), SpellIds.EmbraceOfTheDreamEffect, + new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress | TriggerCastFlags.DontReportCastError) + .SetTriggeringAura(aurEff) + .SetTriggeringSpell(eventInfo.GetProcSpell())); + } + + public override void Register() + { + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); + } + } + + [Script] // 392146 - Embrace of the Dream (Selector) + class spell_dru_embrace_of_the_dream_effect : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.EmbraceOfTheDreamHeal, SpellIds.Regrowth, SpellIds.Rejuvenation, SpellIds.RejuvenationGermination); + } + + void FilterTargets(List targets) + { + targets.RemoveAll(target => target.ToUnit()?.GetAuraEffect(AuraType.PeriodicHeal, SpellFamilyNames.Druid, new FlagArray128(0x50, 0, 0, 0), GetCaster().GetGUID()) == null); + } + + void HandleEffect(uint effIndex) + { + GetCaster().CastSpell(GetHitUnit(), SpellIds.EmbraceOfTheDreamHeal, + new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress | TriggerCastFlags.DontReportCastError) + .SetTriggeringSpell(GetSpell())); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitDestAreaAlly)); + OnEffectHitTarget.Add(new(HandleEffect, 0, SpellEffectName.Dummy)); } } @@ -416,14 +638,14 @@ namespace Scripts.Spells.Druid public override void Register() { - OnObjectTargetSelect.Add(new ObjectTargetSelectHandler(HandleCuriousBramblepatch, 1, Targets.UnitTargetEnemy)); + OnObjectTargetSelect.Add(new(HandleCuriousBramblepatch, 1, Targets.UnitTargetEnemy)); if (m_scriptSpellId == SpellIds.MassEntanglement) - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(HandleCuriousBramblepatchAOE, 1, Targets.UnitDestAreaEnemy)); + OnObjectAreaTargetSelect.Add(new(HandleCuriousBramblepatchAOE, 1, Targets.UnitDestAreaEnemy)); } } [Script] - class spell_dru_entangling_roots_aura : AuraScript + class spell_dru_entangling_roots_AuraScript : AuraScript { public override bool Validate(SpellInfo spellInfo) { @@ -444,30 +666,29 @@ namespace Scripts.Spells.Druid public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); + DoCheckProc.Add(new(CheckProc)); } } - + [Script] // 22568 - Ferocious Bite class spell_dru_ferocious_bite : SpellScript { - float _damageMultiplier = 0.0f; + float _damageMultiplier; public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.IncarnationKingOfTheJungle) - && ValidateSpellEffect(SpellIds.IncarnationKingOfTheJungle, 1); + return ValidateSpellEffect((SpellIds.IncarnationKingOfTheJungle, 1)); } void HandleHitTargetBurn(uint effIndex) { - int newValue = (int)((float)GetEffectValue() * _damageMultiplier); + int newValue = (int)((float)(GetEffectValue()) * _damageMultiplier); SetEffectValue(newValue); } void HandleHitTargetDmg(uint effIndex) { - int newValue = (int)((float)GetHitDamage() * (1.0f + _damageMultiplier)); + int newValue = (int)((float)(GetHitDamage()) * (1.0f + _damageMultiplier)); SetHitDamage(newValue); } @@ -480,8 +701,8 @@ namespace Scripts.Spells.Druid AuraEffect auraEffect = caster.GetAuraEffect(SpellIds.IncarnationKingOfTheJungle, 1); if (auraEffect != null) { - float multiplier = 1.0f + (float)auraEffect.GetAmount() / 100.0f; - maxExtraConsumedPower = (int)((float)maxExtraConsumedPower * multiplier); + float multiplier = 1.0f + (float)(auraEffect.GetAmount()) / 100.0f; + maxExtraConsumedPower = (int)((float)(maxExtraConsumedPower) * multiplier); SetEffectValue(maxExtraConsumedPower); } @@ -490,9 +711,9 @@ namespace Scripts.Spells.Druid public override void Register() { - OnEffectLaunchTarget.Add(new EffectHandler(HandleLaunchTarget, 1, SpellEffectName.PowerBurn)); - OnEffectHitTarget.Add(new EffectHandler(HandleHitTargetBurn, 1, SpellEffectName.PowerBurn)); - OnEffectHitTarget.Add(new EffectHandler(HandleHitTargetDmg, 0, SpellEffectName.SchoolDamage)); + OnEffectLaunchTarget.Add(new(HandleLaunchTarget, 1, SpellEffectName.PowerBurn)); + OnEffectHitTarget.Add(new(HandleHitTargetBurn, 1, SpellEffectName.PowerBurn)); + OnEffectHitTarget.Add(new(HandleHitTargetDmg, 0, SpellEffectName.SchoolDamage)); } } @@ -508,57 +729,36 @@ namespace Scripts.Spells.Druid { Unit target = eventInfo.GetActor(); - switch (target.GetShapeshiftForm()) + return target.GetShapeshiftForm() switch { - case ShapeShiftForm.BearForm: - case ShapeShiftForm.DireBearForm: - case ShapeShiftForm.CatForm: - case ShapeShiftForm.MoonkinForm: - case ShapeShiftForm.None: - case ShapeShiftForm.TreeOfLife: - return true; - default: - break; - } - - return false; + ShapeShiftForm.BearForm or ShapeShiftForm.DireBearForm or ShapeShiftForm.CatForm or ShapeShiftForm.MoonkinForm or ShapeShiftForm.None or ShapeShiftForm.TreeOfLife => true, + _ => false + }; } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); Unit target = eventInfo.GetActor(); - uint triggerspell; - switch (target.GetShapeshiftForm()) + uint triggerspell = target.GetShapeshiftForm() switch { - case ShapeShiftForm.BearForm: - case ShapeShiftForm.DireBearForm: - triggerspell = SpellIds.FormsTrinketBear; - break; - case ShapeShiftForm.CatForm: - triggerspell = SpellIds.FormsTrinketCat; - break; - case ShapeShiftForm.MoonkinForm: - triggerspell = SpellIds.FormsTrinketMoonkin; - break; - case ShapeShiftForm.None: - triggerspell = SpellIds.FormsTrinketNone; - break; - case ShapeShiftForm.TreeOfLife: - triggerspell = SpellIds.FormsTrinketTree; - break; - default: - return; - } + ShapeShiftForm.BearForm or ShapeShiftForm.DireBearForm => SpellIds.FormsTrinketBear, + ShapeShiftForm.CatForm => SpellIds.FormsTrinketCat, + ShapeShiftForm.MoonkinForm => SpellIds.FormsTrinketMoonkin, + ShapeShiftForm.None => SpellIds.FormsTrinketNone, + ShapeShiftForm.TreeOfLife => SpellIds.FormsTrinketTree, + _ => 0 + }; - target.CastSpell(target, triggerspell, new CastSpellExtraArgs(aurEff)); + if (triggerspell != 0) + target.CastSpell(target, triggerspell, aurEff); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); } } @@ -587,7 +787,49 @@ namespace Scripts.Spells.Druid public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); + } + } + + [Script] // 774 - Rejuvenation + class spell_dru_germination : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.Rejuvenation, SpellIds.Germination, SpellIds.RejuvenationGermination); + } + + void PickRejuvenationVariant(ref WorldObject target) + { + Unit caster = GetCaster(); + + // Germination talent. + if (caster.HasAura(SpellIds.Germination)) + { + Unit unitTarget = target.ToUnit(); + Aura rejuvenationAura = unitTarget.GetAura(SpellIds.Rejuvenation, caster.GetGUID()); + Aura germinationAura = unitTarget.GetAura(SpellIds.RejuvenationGermination, caster.GetGUID()); + + // if target doesn't have Rejuventation, cast passes through. + if (rejuvenationAura == null) + return; + + // if target has Rejuvenation, but not Germination, or Germination has lower remaining duration than Rejuvenation, then cast Germination + if (germinationAura != null && germinationAura.GetDuration() >= rejuvenationAura.GetDuration()) + return; + + caster.CastSpell(target, SpellIds.RejuvenationGermination, + new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress | TriggerCastFlags.DontReportCastError) + .SetTriggeringSpell(GetSpell())); + + // prevent aura refresh (but cast must still happen to consume mana) + target = null; + } + } + + public override void Register() + { + OnObjectTargetSelect.Add(new(PickRejuvenationVariant, 0, Targets.UnitTargetAlly)); } } @@ -613,8 +855,8 @@ namespace Scripts.Spells.Druid public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(OnApply, 1, AuraType.ModShapeshift, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 1, AuraType.ModShapeshift, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(OnApply, 1, AuraType.ModShapeshift, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(OnRemove, 1, AuraType.ModShapeshift, AuraEffectHandleModes.Real)); } } @@ -640,8 +882,8 @@ namespace Scripts.Spells.Druid public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckEffectProc, 0, AuraType.Dummy)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckEffectProc.Add(new(CheckEffectProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -655,14 +897,13 @@ namespace Scripts.Spells.Druid void HandleOnCast() { - // Change into cat form if (GetCaster().GetShapeshiftForm() != ShapeShiftForm.BearForm) GetCaster().CastSpell(GetCaster(), SpellIds.BearForm, true); } public override void Register() { - BeforeCast.Add(new CastHandler(HandleOnCast)); + BeforeCast.Add(new(HandleOnCast)); } } @@ -675,7 +916,7 @@ namespace Scripts.Spells.Druid if (target == null) return SpellCastResult.BadTargets; - ChrSpecializationRecord spec = CliDB.ChrSpecializationStorage.LookupByKey(target.GetPrimarySpecialization()); + var spec = target.GetPrimarySpecializationEntry(); if (spec == null || spec.GetRole() != ChrSpecializationRole.Healer) return SpellCastResult.BadTargets; @@ -694,12 +935,77 @@ namespace Scripts.Spells.Druid .SetTriggeringSpell(GetSpell()) .AddSpellMod(SpellValueMod.BasePoint0, -innervateR2.GetAmount())); } + } public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnHit.Add(new HitHandler(HandleRank2)); + OnCheckCast.Add(new(CheckCast)); + OnHit.Add(new(HandleRank2)); + } + } + + [Script] // 117679 - Incarnation (Passive) + class spell_dru_incarnation : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.IncarnationTreeOfLife); + } + + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + GetTarget().RemoveAurasDueToSpell(SpellIds.IncarnationTreeOfLife); + } + + public override void Register() + { + AfterEffectRemove.Add(new(OnRemove, 0, AuraType.IgnoreSpellCooldown, AuraEffectHandleModes.Real)); + } + } + + [Script] // 33891 - Incarnation: Tree of Life (Talent, Shapeshift) + class spell_dru_incarnation_tree_of_life : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.Incarnation); + } + + void AfterApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + if (!GetTarget().HasAura(SpellIds.Incarnation)) + GetTarget().CastSpell(GetTarget(), SpellIds.Incarnation, true); + } + + public override void Register() + { + AfterEffectApply.Add(new(AfterApply, 2, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); + } + } + + [Script] // 740 - Tranquility + class spell_dru_inner_peace : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.InnerPeace) + && ValidateSpellEffect((spellInfo.Id, 4)) + && spellInfo.GetEffect(3).IsAura(AuraType.MechanicImmunityMask) + && spellInfo.GetEffect(4).IsAura(AuraType.ModDamagePercentTaken); + } + + void PreventEffect(ref WorldObject target) + { + // Note: Inner Peace talent. + if (!GetCaster().HasAura(SpellIds.InnerPeace)) + target = null; + } + + public override void Register() + { + OnObjectTargetSelect.Add(new(PreventEffect, 3, Targets.UnitCaster)); + OnObjectTargetSelect.Add(new(PreventEffect, 4, Targets.UnitCaster)); } } @@ -743,12 +1049,12 @@ namespace Scripts.Spells.Druid return; if (RandomHelper.randChance(chance)) - eventInfo.GetActor().CastSpell((Unit)null, spellId, new CastSpellExtraArgs(aurEff)); + eventInfo.GetActor().CastSpell(null, spellId, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -769,7 +1075,7 @@ namespace Scripts.Spells.Druid public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 0, AuraType.PeriodicHeal, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(AfterRemove, 0, AuraType.PeriodicHeal, AuraEffectHandleModes.Real)); } } @@ -793,8 +1099,46 @@ namespace Scripts.Spells.Druid public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(AfterApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectApply.Add(new(AfterApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(AfterRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + } + } + + [Script] // 392315 - Luxuriant Soil + class spell_dru_luxuriant_soil : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.Rejuvenation); + } + + static bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + return RandomHelper.randChance(aurEff.GetAmount()); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + Unit rejuvCaster = GetTarget(); + + // let's use the ProcSpell's max. range. + float spellRange = eventInfo.GetSpellInfo().GetMaxRange(); + + List targetList = new(); + WorldObjectSpellAreaTargetCheck check = new(spellRange, rejuvCaster, rejuvCaster, rejuvCaster, eventInfo.GetSpellInfo(), SpellTargetCheckTypes.Ally, null, SpellTargetObjectTypes.Unit); + UnitListSearcher searcher = new(rejuvCaster, targetList, check); + Cell.VisitAllObjects(rejuvCaster, searcher, spellRange); + + if (targetList.Empty()) + return; + + rejuvCaster.CastSpell(targetList.SelectRandom(), SpellIds.Rejuvenation, TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnorePowerAndReagentCost | TriggerCastFlags.IgnoreCastInProgress); + } + + public override void Register() + { + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -813,7 +1157,7 @@ namespace Scripts.Spells.Druid public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleOnHit, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleOnHit, 0, SpellEffectName.Dummy)); } } @@ -834,7 +1178,55 @@ namespace Scripts.Spells.Druid public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); + } + } + + [Script] // 392303 - Power of the Archdruid + class spell_dru_power_of_the_archdruid : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellEffect((SpellIds.PowerOfTheArchdruid, 0)); + } + + static bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + return eventInfo.GetActor().HasAuraEffect(SpellIds.PowerOfTheArchdruid, 0); + } + + static void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + Unit druid = eventInfo.GetActor(); + Unit procTarget = eventInfo.GetActionTarget(); + + // range is 0's BasePoints. + float spellRange = aurEff.GetAmount(); + + List targetList = new(); + WorldObjectSpellAreaTargetCheck checker = new(spellRange, procTarget, druid, druid, eventInfo.GetSpellInfo(), SpellTargetCheckTypes.Ally, null, SpellTargetObjectTypes.Unit); + UnitListSearcher searcher = new(procTarget, targetList, checker); + Cell.VisitAllObjects(procTarget, searcher, spellRange); + targetList.Remove(procTarget); + + if (targetList.Empty()) + return; + + AuraEffect powerOfTheArchdruidEffect = druid.GetAuraEffect(SpellIds.PowerOfTheArchdruid, 0); + + // max. targets is SpellPowerOfTheArchdruid's 0 BasePoints. + int maxTargets = powerOfTheArchdruidEffect.GetAmount(); + + targetList.RandomResize((uint)maxTargets); + + foreach (Unit chosenTarget in targetList) + druid.CastSpell(chosenTarget, eventInfo.GetProcSpell().GetSpellInfo().Id, aurEff); + } + + public override void Register() + { + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -848,14 +1240,13 @@ namespace Scripts.Spells.Druid void HandleOnCast() { - // Change into cat form if (GetCaster().GetShapeshiftForm() != ShapeShiftForm.CatForm) GetCaster().CastSpell(GetCaster(), SpellIds.CatForm, true); } public override void Register() { - BeforeCast.Add(new CastHandler(HandleOnCast)); + BeforeCast.Add(new(HandleOnCast)); } } @@ -865,7 +1256,7 @@ namespace Scripts.Spells.Druid public override bool Load() { Unit caster = GetCaster(); - return caster != null && caster.IsTypeId(TypeId.Player); + return caster != null && caster.IsPlayer(); } void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) @@ -875,16 +1266,20 @@ namespace Scripts.Spells.Druid Unit caster = GetCaster(); if (caster != null) { - // 0.01 * $AP * cp + // 0.01 * $Ap * cp int cp = caster.GetPower(PowerType.ComboPoints); // Idol of Feral Shadows. Can't be handled as SpellMod due its dependency from CPs - AuraEffect idol = caster.GetAuraEffect(SpellIds.IdolOfFeralShadows, 0); - if (idol != null) - amount += cp * idol.GetAmount(); + AuraEffect auraEffIdolOfFeralShadows = caster.GetAuraEffect(SpellIds.IdolOfFeralShadows, 0); + if (auraEffIdolOfFeralShadows != null) + amount += cp * auraEffIdolOfFeralShadows.GetAmount(); // Idol of Worship. Can't be handled as SpellMod due its dependency from CPs - else if ((idol = caster.GetAuraEffect(SpellIds.IdolOfWorship, 0)) != null) - amount += cp * idol.GetAmount(); + else + { + AuraEffect auraEffIdolOfWorship = caster.GetAuraEffect(SpellIds.IdolOfWorship, 0); + if (auraEffIdolOfWorship != null) + amount += cp * auraEffIdolOfWorship.GetAmount(); + } amount += (int)MathFunctions.CalculatePct(caster.GetTotalAttackPowerValue(WeaponAttackType.BaseAttack), cp); } @@ -892,7 +1287,7 @@ namespace Scripts.Spells.Druid public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.PeriodicDamage)); + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.PeriodicDamage)); } } @@ -910,14 +1305,14 @@ namespace Scripts.Spells.Druid public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); + OnCheckCast.Add(new(CheckCast)); } } [Script] class spell_dru_savage_roar_AuraScript : AuraScript { - public override bool Validate(SpellInfo spellInfo) + public override bool Validate(SpellInfo spell) { return ValidateSpellInfo(SpellIds.SavageRoar); } @@ -925,7 +1320,8 @@ namespace Scripts.Spells.Druid void AfterApply(AuraEffect aurEff, AuraEffectHandleModes mode) { Unit target = GetTarget(); - target.CastSpell(target, SpellIds.SavageRoar, new CastSpellExtraArgs(aurEff).SetOriginalCaster(GetCasterGUID())); + target.CastSpell(target, SpellIds.SavageRoar, new CastSpellExtraArgs(aurEff) + .SetOriginalCaster(GetCasterGUID())); } void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) @@ -935,8 +1331,8 @@ namespace Scripts.Spells.Druid public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(AfterApply, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectApply.Add(new(AfterApply, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(AfterRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -963,7 +1359,7 @@ namespace Scripts.Spells.Druid public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(OnTick, 1, AuraType.PeriodicDamage)); + OnEffectPeriodic.Add(new(OnTick, 1, AuraType.PeriodicDamage)); } } @@ -983,7 +1379,27 @@ namespace Scripts.Spells.Druid public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] // 81269 - Efflorescence (Heal) + class spell_dru_spring_blossoms : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.SpringBlossoms, SpellIds.SpringBlossomsHeal); + } + + void HandleOnHit(uint effIndex) + { + if (GetCaster().HasAura(SpellIds.SpringBlossoms)) + GetCaster().CastSpell(GetHitUnit(), SpellIds.SpringBlossomsHeal, TriggerCastFlags.DontReportCastError); + } + + public override void Register() + { + OnEffectHitTarget.Add(new(HandleOnHit, 0, SpellEffectName.Heal)); } } @@ -997,14 +1413,13 @@ namespace Scripts.Spells.Druid void HandleOnCast() { - // Change into cat form if (GetCaster().GetShapeshiftForm() != ShapeShiftForm.BearForm) GetCaster().CastSpell(GetCaster(), SpellIds.BearForm, true); } public override void Register() { - BeforeCast.Add(new CastHandler(HandleOnCast)); + BeforeCast.Add(new(HandleOnCast)); } } @@ -1013,7 +1428,7 @@ namespace Scripts.Spells.Druid { void FilterTargets(List targets) { - targets.Resize(2); + targets.RandomResize(2); } void HandleDummy(uint effIndex) @@ -1037,8 +1452,31 @@ namespace Scripts.Spells.Druid public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitDestAreaEnemy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + // 340694 - Sudden Ambush + [Script] // 384667 - Sudden Ambush + class spell_dru_sudden_ambush : AuraScript + { + bool CheckProc(AuraEffect aurEff, ProcEventInfo procInfo) + { + Spell procSpell = procInfo.GetProcSpell(); + if (procSpell == null) + return false; + + int? comboPoints = procSpell.GetPowerTypeCostAmount(PowerType.ComboPoints); + if (!comboPoints.HasValue) + return false; + + return RandomHelper.randChance(comboPoints.Value * aurEff.GetAmount()); + } + + public override void Register() + { + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.ProcTriggerSpell)); } } @@ -1052,12 +1490,12 @@ namespace Scripts.Spells.Druid public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleOnHit, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleOnHit, 0, SpellEffectName.Dummy)); } } [Script] // 61336 - Survival Instincts - class spell_dru_survival_instincts_AuraScript : AuraScript + class spell_dru_survival_instincts : AuraScript { public override bool Validate(SpellInfo spell) { @@ -1076,8 +1514,8 @@ namespace Scripts.Spells.Druid public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(AfterApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectApply.Add(new(AfterApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(AfterRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -1086,7 +1524,7 @@ namespace Scripts.Spells.Druid { public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) @@ -1099,7 +1537,7 @@ namespace Scripts.Spells.Druid public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 1, AuraType.ModIncreaseVehicleFlightSpeed)); + DoEffectCalcAmount.Add(new(CalculateAmount, 1, AuraType.ModIncreaseVehicleFlightSpeed)); } } @@ -1114,12 +1552,12 @@ namespace Scripts.Spells.Druid void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.BlessingOfTheClaw, new CastSpellExtraArgs(aurEff)); + eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.BlessingOfTheClaw, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.OverrideClassScripts)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.OverrideClassScripts)); } } @@ -1139,20 +1577,20 @@ namespace Scripts.Spells.Druid return; Unit caster = eventInfo.GetActor(); - var spellPowerCostList = spell.GetPowerCost(); - var spellPowerCost = spellPowerCostList.First(cost => cost.Power == PowerType.Mana); - if (spellPowerCost == null) + List costs = spell.GetPowerCost(); + var m = costs.Find(cost => cost.Power == PowerType.Mana); + if (m == null) return; - int amount = MathFunctions.CalculatePct(spellPowerCost.Amount, aurEff.GetAmount()); + int amount = MathFunctions.CalculatePct(m.Amount, aurEff.GetAmount()); CastSpellExtraArgs args = new(aurEff); args.AddSpellMod(SpellValueMod.BasePoint0, amount); - caster.CastSpell((Unit)null, SpellIds.Exhilarate, args); + caster.CastSpell(null, SpellIds.Exhilarate, args); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1168,12 +1606,12 @@ namespace Scripts.Spells.Druid void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - eventInfo.GetActor().CastSpell((Unit)null, SpellIds.Infusion, new CastSpellExtraArgs(aurEff)); + eventInfo.GetActor().CastSpell(null, SpellIds.Infusion, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1196,8 +1634,10 @@ namespace Scripts.Spells.Druid Unit caster = eventInfo.GetActor(); Unit target = eventInfo.GetProcTarget(); - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.Languish, GetCastDifficulty()); + SpellInfo spellInfo = SpellMgr.GetSpellInfo(SpellIds.Languish, GetCastDifficulty()); int amount = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); + + Cypher.Assert(spellInfo.GetMaxTicks() > 0); amount /= (int)spellInfo.GetMaxTicks(); CastSpellExtraArgs args = new(aurEff); @@ -1207,7 +1647,7 @@ namespace Scripts.Spells.Druid public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1216,7 +1656,7 @@ namespace Scripts.Spells.Druid { public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } void FilterTargets(List targets) @@ -1231,7 +1671,7 @@ namespace Scripts.Spells.Druid targets.Remove(GetExplTargetUnit()); List tempTargets = new(); foreach (var obj in targets) - if (obj.IsTypeId(TypeId.Player) && GetCaster().IsInRaidWith(obj.ToUnit())) + if (obj.IsPlayer() && GetCaster().IsInRaidWith(obj.ToUnit())) tempTargets.Add(obj.ToUnit()); if (tempTargets.Empty()) @@ -1249,7 +1689,7 @@ namespace Scripts.Spells.Druid public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitDestAreaAlly)); } } @@ -1272,7 +1712,7 @@ namespace Scripts.Spells.Druid return false; Player caster = eventInfo.GetActor().ToPlayer(); - if (!caster) + if (caster == null) return false; return caster.GetGroup() || caster != eventInfo.GetProcTarget(); @@ -1282,16 +1722,15 @@ namespace Scripts.Spells.Druid { PreventDefaultAction(); - int amount = (int)eventInfo.GetHealInfo().GetHeal(); CastSpellExtraArgs args = new(aurEff); args.AddSpellMod(SpellValueMod.BasePoint0, (int)eventInfo.GetHealInfo().GetHeal()); - eventInfo.GetActor().CastSpell((Unit)null, SpellIds.RejuvenationT10Proc, args); + eventInfo.GetActor().CastSpell(null, SpellIds.RejuvenationT10Proc, args); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1307,20 +1746,16 @@ namespace Scripts.Spells.Druid { Unit hitUnit = GetHitUnit(); if (hitUnit != null) - { - Unit caster = GetCaster(); - - caster.CastSpell(hitUnit, SpellIds.ThrashBearAura, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); - } + GetCaster().CastSpell(hitUnit, SpellIds.ThrashBearAura, TriggerCastFlags.FullMask); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleOnHitTarget, 0, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new(HandleOnHitTarget, 0, SpellEffectName.SchoolDamage)); } } - [Script] // 192090 - Thrash (Aura) - SPELL_DRUID_THRASH_BEAR_AURA + [Script] // 192090 - Thrash (Aura) - SpellThrashBearAura class spell_dru_thrash_AuraScript : AuraScript { public override bool Validate(SpellInfo spellInfo) @@ -1338,7 +1773,7 @@ namespace Scripts.Spells.Druid public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodic, 0, AuraType.PeriodicDamage)); + OnEffectPeriodic.Add(new(HandlePeriodic, 0, AuraType.PeriodicDamage)); } } @@ -1346,7 +1781,7 @@ namespace Scripts.Spells.Druid // 33943 - Flight Form // 40120 - Swift Flight Form [Script] // 165961 - Stag Form - class spell_dru_travel_form_AuraScript : AuraScript + class spell_dru_travel_form : AuraScript { uint triggeredSpellId; @@ -1357,12 +1792,12 @@ namespace Scripts.Spells.Druid public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - // If it stays 0, it removes Travel Form dummy in AfterRemove. + // If it stays 0, it Removes Travel Form dummy in AfterRemove. triggeredSpellId = 0; // We should only handle aura interrupts. @@ -1372,7 +1807,7 @@ namespace Scripts.Spells.Druid // Check what form is appropriate triggeredSpellId = GetFormSpellId(GetTarget().ToPlayer(), GetCastDifficulty(), true); - // If chosen form is current aura, just don't remove it. + // If chosen form is current aura, just don't Remove it. if (triggeredSpellId == m_scriptSpellId) PreventDefaultAction(); } @@ -1385,15 +1820,15 @@ namespace Scripts.Spells.Druid Player player = GetTarget().ToPlayer(); if (triggeredSpellId != 0) // Apply new form - player.CastSpell(player, triggeredSpellId, new CastSpellExtraArgs(aurEff)); - else // If not set, simply remove Travel Form dummy + player.CastSpell(player, triggeredSpellId, aurEff); + else // If not set, simply Remove Travel Form dummy player.RemoveAura(SpellIds.TravelForm); } public override void Register() { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ModShapeshift, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 0, AuraType.ModShapeshift, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(OnRemove, 0, AuraType.ModShapeshift, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(AfterRemove, 0, AuraType.ModShapeshift, AuraEffectHandleModes.Real)); } public static uint GetFormSpellId(Player player, Difficulty difficulty, bool requiresOutdoor) @@ -1411,9 +1846,9 @@ namespace Scripts.Spells.Druid return 0; } - static SpellCastResult CheckLocationForForm(Player targetPlayer, Difficulty difficulty, bool requireOutdoors, uint spell_id) + static SpellCastResult CheckLocationForForm(Player targetPlayer, Difficulty difficulty, bool requireOutdoors, uint spellId) { - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spell_id, difficulty); + SpellInfo spellInfo = SpellMgr.GetSpellInfo(spellId, difficulty); if (requireOutdoors && !targetPlayer.IsOutdoors()) return SpellCastResult.OnlyOutdoors; @@ -1425,7 +1860,7 @@ namespace Scripts.Spells.Druid [Script] // 783 - Travel Form (dummy) class spell_dru_travel_form_dummy : SpellScript { - public override bool Validate(SpellInfo spellEntry) + public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.FormAquaticPassive, SpellIds.FormAquatic, SpellIds.FormStag); } @@ -1433,18 +1868,18 @@ namespace Scripts.Spells.Druid SpellCastResult CheckCast() { Player player = GetCaster().ToPlayer(); - if (!player) + if (player == null) return SpellCastResult.CustomError; uint spellId = (player.HasSpell(SpellIds.FormAquaticPassive) && player.IsInWater()) ? SpellIds.FormAquatic : SpellIds.FormStag; - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, GetCastDifficulty()); + SpellInfo spellInfo = SpellMgr.GetSpellInfo(spellId, GetCastDifficulty()); return spellInfo.CheckLocation(player.GetMapId(), player.GetZoneId(), player.GetAreaId(), player); } public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); + OnCheckCast.Add(new(CheckCast)); } } @@ -1458,22 +1893,22 @@ namespace Scripts.Spells.Druid public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) { Player player = GetTarget().ToPlayer(); - // Outdoor check already passed - Travel Form (dummy) has SPELL_ATTR0_OUTDOORS_ONLY attribute. - uint triggeredSpellId = spell_dru_travel_form_AuraScript.GetFormSpellId(player, GetCastDifficulty(), false); + // Outdoor check already passed - Travel Form (dummy) has SpellAttr0OutdoorsOnly attribute. + uint triggeredSpellId = spell_dru_travel_form.GetFormSpellId(player, GetCastDifficulty(), false); - player.CastSpell(player, triggeredSpellId, new CastSpellExtraArgs(aurEff)); + player.CastSpell(player, triggeredSpellId, aurEff); } void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - // No need to check remove mode, it's safe for auras to remove each other in AfterRemove hook. + // No need to check Remove mode, it's safe for auras to Remove each other in AfterRemove hook. GetTarget().RemoveAura(SpellIds.FormStag); GetTarget().RemoveAura(SpellIds.FormAquatic); GetTarget().RemoveAura(SpellIds.FormFlight); @@ -1482,8 +1917,8 @@ namespace Scripts.Spells.Druid public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(OnApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(AfterRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -1497,14 +1932,13 @@ namespace Scripts.Spells.Druid void HandleOnCast() { - // Change into cat form if (GetCaster().GetShapeshiftForm() != ShapeShiftForm.CatForm) GetCaster().CastSpell(GetCaster(), SpellIds.CatForm, true); } public override void Register() { - BeforeCast.Add(new CastHandler(HandleOnCast)); + BeforeCast.Add(new(HandleOnCast)); } } @@ -1523,54 +1957,34 @@ namespace Scripts.Spells.Druid public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodic, 1, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandlePeriodic, 1, AuraType.PeriodicDummy)); } } [Script] // 48438 - Wild Growth class spell_dru_wild_growth : SpellScript { - List _targets; - public override bool Validate(SpellInfo spellInfo) { - if (!ValidateSpellEffect(spellInfo.Id, 2) || spellInfo.GetEffect(2).IsEffect() || spellInfo.GetEffect(2).CalcValue() <= 0) - return false; - return true; + return ValidateSpellEffect((spellInfo.Id, 1), (SpellIds.TreeOfLife, 2)); } void FilterTargets(List targets) { - targets.RemoveAll(obj => - { - Unit target = obj.ToUnit(); - if (target) - return !GetCaster().IsInRaidWith(target); + Unit caster = GetCaster(); + int maxTargets = GetEffectInfo(1).CalcValue(caster); - return true; - }); + AuraEffect treeOfLife = caster.GetAuraEffect(SpellIds.TreeOfLife, 2); + if (treeOfLife != null) + maxTargets += treeOfLife.GetAmount(); - int maxTargets = GetEffectInfo(2).CalcValue(GetCaster()); - - if (targets.Count > maxTargets) - { - targets.Sort(new HealthPctOrderPred()); - targets.RemoveRange(maxTargets, targets.Count - maxTargets); - } - - _targets = targets; - } - - void SetTargets(List targets) - { - targets.Clear(); - targets.AddRange(_targets); + // Note: Wild Growth became a smart heal which prioritizes players and their pets in their group before any unit outside their group. + SelectRandomInjuredTargets(targets, (uint)maxTargets, true, caster); } public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(SetTargets, 1, Targets.UnitDestAreaAlly)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitDestAreaAlly)); } } @@ -1585,7 +1999,7 @@ namespace Scripts.Spells.Druid void HandleTickUpdate(AuraEffect aurEff) { Unit caster = GetCaster(); - if (!caster) + if (caster == null) return; // calculate from base damage, not from aurEff.GetAmount() (already modified) @@ -1604,7 +2018,7 @@ namespace Scripts.Spells.Druid public override void Register() { - OnEffectUpdatePeriodic.Add(new EffectUpdatePeriodicHandler(HandleTickUpdate, 0, AuraType.PeriodicHeal)); + OnEffectUpdatePeriodic.Add(new(HandleTickUpdate, 0, AuraType.PeriodicHeal)); } } @@ -1628,7 +2042,7 @@ namespace Scripts.Spells.Druid public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); } } @@ -1642,7 +2056,7 @@ namespace Scripts.Spells.Druid public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(SelectTargets, 0, Targets.UnitCasterAreaRaid)); + OnObjectAreaTargetSelect.Add(new(SelectTargets, 0, Targets.UnitCasterAreaRaid)); } } } \ No newline at end of file diff --git a/Source/Scripts/Spells/Evoker.cs b/Source/Scripts/Spells/Evoker.cs index f1ce42c0d..a8ef2d7fe 100644 --- a/Source/Scripts/Spells/Evoker.cs +++ b/Source/Scripts/Spells/Evoker.cs @@ -1,12 +1,14 @@ -// Copyright (c) CypherCore All rights reserved. +// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; +using Framework.Dynamic; using Game.Entities; using Game.Scripting; using Game.Spells; using System; using System.Collections.Generic; +using static Global; namespace Scripts.Spells.Evoker { @@ -18,8 +20,11 @@ namespace Scripts.Spells.Evoker public const uint LivingFlame = 361469; public const uint LivingFlameDamage = 361500; public const uint LivingFlameHeal = 361509; + public const uint PermeatingChillTalent = 370897; public const uint PyreDamage = 357212; public const uint SoarRacial = 369536; + + public const uint LabelEvokerBlue = 1465; } [Script] // 362969 - Azure Strike (blue) @@ -34,7 +39,21 @@ namespace Scripts.Spells.Evoker public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitDestAreaEnemy)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 1, Targets.UnitDestAreaEnemy)); + } + } + + [Script] // 370455 - Charged Blast + class spell_evo_charged_blast : AuraScript + { + bool CheckProc(ProcEventInfo procInfo) + { + return procInfo.GetSpellInfo() != null && procInfo.GetSpellInfo().HasLabel(SpellIds.LabelEvokerBlue); + } + + public override void Register() + { + DoCheckProc.Add(new(CheckProc)); } } @@ -64,14 +83,14 @@ namespace Scripts.Spells.Evoker caster.CastSpell(caster, SpellIds.GlideKnockback, true); - caster.GetSpellHistory().StartCooldown(Global.SpellMgr.GetSpellInfo(SpellIds.Hover, GetCastDifficulty()), 0, null, false, TimeSpan.FromMilliseconds(250)); - caster.GetSpellHistory().StartCooldown(Global.SpellMgr.GetSpellInfo(SpellIds.SoarRacial, GetCastDifficulty()), 0, null, false, TimeSpan.FromMilliseconds(250)); + caster.GetSpellHistory().StartCooldown(SpellMgr.GetSpellInfo(SpellIds.Hover, GetCastDifficulty()), 0, null, false, TimeSpan.FromMilliseconds(250)); + caster.GetSpellHistory().StartCooldown(SpellMgr.GetSpellInfo(SpellIds.SoarRacial, GetCastDifficulty()), 0, null, false, TimeSpan.FromMilliseconds(250)); } public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnCast.Add(new CastHandler(HandleCast)); + OnCheckCast.Add(new(CheckCast)); + OnCast.Add(new(HandleCast)); } } @@ -110,8 +129,38 @@ namespace Scripts.Spells.Evoker public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleHitTarget, 0, SpellEffectName.Dummy)); - OnEffectLaunchTarget.Add(new EffectHandler(HandleLaunchTarget, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleHitTarget, 0, SpellEffectName.Dummy)); + OnEffectLaunchTarget.Add(new(HandleLaunchTarget, 0, SpellEffectName.Dummy)); + } + } + + [Script] // 381773 - Permeating Chill + class spell_evo_permeating_chill : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.PermeatingChillTalent); + } + + bool CheckProc(ProcEventInfo procInfo) + { + SpellInfo spellInfo = procInfo.GetSpellInfo(); + if (spellInfo == null) + return false; + + if (spellInfo.HasLabel(SpellIds.LabelEvokerBlue)) + return false; + + if (!procInfo.GetActor().HasAura(SpellIds.PermeatingChillTalent)) + if (spellInfo.IsAffected(SpellFamilyNames.Evoker, new FlagArray128(0x40, 0, 0, 0))) // disintegrate + return false; + + return true; + } + + public override void Register() + { + DoCheckProc.Add(new(CheckProc)); } } @@ -125,12 +174,12 @@ namespace Scripts.Spells.Evoker void HandleDamage(uint effIndex) { - GetCaster().CastSpell(GetHitUnit().GetPosition(), SpellIds.PyreDamage, new CastSpellExtraArgs(true)); + GetCaster().CastSpell(GetHitUnit().GetPosition(), SpellIds.PyreDamage, true); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDamage, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDamage, 0, SpellEffectName.Dummy)); } } -} +} \ No newline at end of file diff --git a/Source/Scripts/Spells/Generic.cs b/Source/Scripts/Spells/Generic.cs index b0e5364f3..e7664dbff 100644 --- a/Source/Scripts/Spells/Generic.cs +++ b/Source/Scripts/Spells/Generic.cs @@ -1,4 +1,4 @@ -// Copyright (c) CypherCore All rights reserved. +// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; @@ -12,485 +12,45 @@ using Game.Spells; using System; using System.Collections.Generic; using System.Linq; +using static Global; namespace Scripts.Spells.Generic { - struct SpellIds - { - // Adaptivewarding - public const uint GenAdaptiveWardingFire = 28765; - public const uint GenAdaptiveWardingNature = 28768; - public const uint GenAdaptiveWardingFrost = 28766; - public const uint GenAdaptiveWardingShadow = 28769; - public const uint GenAdaptiveWardingArcane = 28770; - - // Animalbloodpoolspell - public const uint AnimalBlood = 46221; - public const uint SpawnBloodPool = 63471; - - // Serviceuniform - public const uint ServiceUniform = 71450; - - // Genericbandage - public const uint RecentlyBandaged = 11196; - - // Bloodreserve - public const uint BloodReserveAura = 64568; - public const uint BloodReserveHeal = 64569; - - // Bonked - public const uint Bonked = 62991; - public const uint FormSwordDefeat = 62994; - public const uint Onguard = 62972; - - // Breakshieldspells - public const uint BreakShieldDamage2k = 62626; - public const uint BreakShieldDamage10k = 64590; - public const uint BreakShieldTriggerFactionMounts = 62575; // Also On Toc5 Mounts - public const uint BreakShieldTriggerCampaingWarhorse = 64595; - public const uint BreakShieldTriggerUnk = 66480; - - // Cannibalizespells - public const uint CannibalizeTriggered = 20578; - - // Chaosblast - public const uint ChaosBlast = 37675; - - // Clone - public const uint NightmareFigmentMirrorImage = 57528; - - // Cloneweaponspells - public const uint WeaponAura = 41054; - public const uint Weapon2Aura = 63418; - public const uint Weapon3Aura = 69893; - - public const uint OffhandAura = 45205; - public const uint Offhand2Aura = 69896; - - public const uint RangedAura = 57594; - - // Createlancespells - public const uint CreateLanceAlliance = 63914; - public const uint CreateLanceHorde = 63919; - - // Dalarandisguisespells - public const uint SunreaverTrigger = 69672; - public const uint SunreaverFemale = 70973; - public const uint SunreaverMale = 70974; - - public const uint SilverCovenantTrigger = 69673; - public const uint SilverCovenantFemale = 70971; - public const uint SilverCovenantMale = 70972; - - // Defendvisuals - public const uint VisualShield1 = 63130; - public const uint VisualShield2 = 63131; - public const uint VisualShield3 = 63132; - - // Divinestormspell - public const uint DivineStorm = 53385; - - // Elunecandle - public const uint OmenHead = 26622; - public const uint OmenChest = 26624; - public const uint OmenHandR = 26625; - public const uint OmenHandL = 26649; - public const uint Normal = 26636; - - // EtherealPet - public const uint ProcTriggerOnKillAura = 50051; - public const uint EtherealPetAura = 50055; - public const uint CreateToken = 50063; - public const uint StealEssenceVisual = 50101; - - // Feast - public const uint GreatFeast = 57337; - public const uint FishFeast = 57397; - public const uint GiganticFeast = 58466; - public const uint SmallFeast = 58475; - public const uint BountifulFeast = 66477; - - public const uint FeastFood = 45548; - public const uint FeastDrink = 57073; - public const uint BountifulFeastDrink = 66041; - public const uint BountifulFeastFood = 66478; - - public const uint GreatFeastRefreshment = 57338; - public const uint FishFeastRefreshment = 57398; - public const uint GiganticFeastRefreshment = 58467; - public const uint SmallFeastRefreshment = 58477; - public const uint BountifulFeastRefreshment = 66622; - - //FuriousRage - public const uint Exhaustion = 35492; - - // Fishingspells - public const uint FishingNoFishingPole = 131476; - public const uint FishingWithPole = 131490; - - // Transporterbackfires - public const uint TransporterMalfunctionPolymorph = 23444; - public const uint TransporterEviltwin = 23445; - public const uint TransporterMalfunctionMiss = 36902; - - // Gnomishtransporter - public const uint TransporterSuccess = 23441; - public const uint TransporterFailure = 23446; - - // Interrupt - public const uint GenThrowInterrupt = 32747; - - // Genericlifebloomspells - public const uint HexlordMalacrass = 43422; - public const uint TurragePaw = 52552; - public const uint CenarionScout = 53692; - public const uint TwistedVisage = 57763; - public const uint FactionChampionsDru = 66094; - - // Chargespells - public const uint Damage8k5 = 62874; - public const uint Damage20k = 68498; - public const uint Damage45k = 64591; - - public const uint ChargingEffect8k5 = 63661; - public const uint Charging20k1 = 68284; - public const uint Charging20k2 = 68501; - public const uint ChargingEffect45k1 = 62563; - public const uint ChargingEffect45k2 = 66481; - - public const uint TriggerFactionMounts = 62960; - public const uint TriggerTrialChampion = 68282; - - public const uint MissEffect = 62977; - - // MossCoveredFeet - public const uint FallDown = 6869; - - // Netherbloom - public const uint NetherBloomPollen1 = 28703; - - // Nightmarevine - public const uint NightmarePollen = 28721; - - // Obsidianarmorspells - public const uint Holy = 27536; - public const uint Fire = 27533; - public const uint Nature = 27538; - public const uint Frost = 27534; - public const uint Shadow = 27535; - public const uint Arcane = 27540; - - // Tournamentpennantspells - public const uint StormwindAspirant = 62595; - public const uint StormwindValiant = 62596; - public const uint StormwindChampion = 62594; - public const uint GnomereganAspirant = 63394; - public const uint GnomereganValiant = 63395; - public const uint GnomereganChampion = 63396; - public const uint SenjinAspirant = 63397; - public const uint SenjinValiant = 63398; - public const uint SenjinChampion = 63399; - public const uint SilvermoonAspirant = 63401; - public const uint SilvermoonValiant = 63402; - public const uint SilvermoonChampion = 63403; - public const uint DarnassusAspirant = 63404; - public const uint DarnassusValiant = 63405; - public const uint DarnassusChampion = 63406; - public const uint ExodarAspirant = 63421; - public const uint ExodarValiant = 63422; - public const uint ExodarChampion = 63423; - public const uint IronforgeAspirant = 63425; - public const uint IronforgeValiant = 63426; - public const uint IronforgeChampion = 63427; - public const uint UndercityAspirant = 63428; - public const uint UndercityValiant = 63429; - public const uint UndercityChampion = 63430; - public const uint OrgrimmarAspirant = 63431; - public const uint OrgrimmarValiant = 63432; - public const uint OrgrimmarChampion = 63433; - public const uint ThunderbluffAspirant = 63434; - public const uint ThunderbluffValiant = 63435; - public const uint ThunderbluffChampion = 63436; - public const uint ArgentcrusadeAspirant = 63606; - public const uint ArgentcrusadeValiant = 63500; - public const uint ArgentcrusadeChampion = 63501; - public const uint EbonbladeAspirant = 63607; - public const uint EbonbladeValiant = 63608; - public const uint EbonbladeChampion = 63609; - - // Orcdisguisespells - public const uint OrcDisguiseTrigger = 45759; - public const uint OrcDisguiseMale = 45760; - public const uint OrcDisguiseFemale = 45762; - - // Paralytic Poison - public const uint Paralysis = 35202; - - // Parachutespells - public const uint Parachute = 45472; - public const uint ParachuteBuff = 44795; - - // ProfessionResearch - public const uint NorthrendInscriptionResearch = 61177; - - // Trinketspells - public const uint PvpTrinketAlliance = 97403; - public const uint PvpTrinketHorde = 97404; - - // Replenishment - public const uint Replenishment = 57669; - public const uint InfiniteReplenishment = 61782; - - // Runningwild - public const uint AlteredForm = 97709; - - // Seaforiumspells - public const uint PlantChargesCreditAchievement = 60937; - - // Summonelemental - public const uint SummonFireElemental = 8985; - public const uint SummonEarthElemental = 19704; - - // Tournamentmountsspells - public const uint LanceEquipped = 62853; - - // Mountedduelspells - public const uint OnTournamentMount = 63034; - public const uint MountedDuel = 62875; - - // Teleporting - public const uint TeleportSpireDown = 59316; - public const uint TeleportSpireUp = 59314; - - // Pvptrinkettriggeredspells - public const uint WillOfTheForsakenCooldownTrigger = 72752; - public const uint WillOfTheForsakenCooldownTriggerWotf = 72757; - - // Friendorfowl - public const uint TurkeyVengeance = 25285; - - // Vampirictouch - public const uint VampiricTouchHeal = 52724; - - // Vehiclescaling - public const uint GearScaling = 66668; - - // Whispergulchyoggsaronwhisper - public const uint YoggSaronWhisperDummy = 29072; - - // Gmfreeze - public const uint GmFreeze = 9454; - - // Landmineknockbackachievement - public const uint LandmineKnockbackAchievement = 57064; - - // Ponyspells - public const uint AchievementPonyup = 3736; - public const uint MountPony = 29736; - - // CorruptinPlagueEntrys - public const uint CorruptingPlague = 40350; - - // StasisFieldEntrys - public const uint StasisField = 40307; - - // SiegeTankControl - public const uint SiegeTankControl = 47963; - - // CannonBlast - public const uint CannonBlast = 42578; - public const uint CannonBlastDamage = 42576; - - // FreezingCircleMisc - public const uint FreezingCirclePitOfSaronNormal = 69574; - public const uint FreezingCirclePitOfSaronHeroic = 70276; - public const uint FreezingCircle = 34787; - public const uint FreezingCircleScenario = 141383; - - // Kazrogalhellfiremark - public const uint MarkOfKazrogalHellfire = 189512; - public const uint MarkOfKazrogalDamageHellfire = 189515; - - // AuraprocRemovespells - public const uint FaceRage = 99947; - public const uint ImpatientMind = 187213; - - // DefenderOfAzerothData - public const uint DeathGateTeleportStormwind = 316999; - public const uint DeathGateTeleportOrgrimmar = 317000; - - // AncestralCallSpells - public const uint RictusOfTheLaughingSkull = 274739; - public const uint ZealOfTheBurningBlade = 274740; - public const uint FerocityOfTheFrostwolf = 274741; - public const uint MightOfTheBlackrock = 274742; - - // BloodlustExhaustionSpell - public const uint ShamanSated = 57724; // Bloodlust - public const uint ShamanExhaustion = 57723; // Heroism, Drums - public const uint MageTemporalDisplacement = 80354; - public const uint HunterFatigued = 264689; - public const uint EvokerExhaustion = 390435; - } - - struct CreatureIds - { - // EluneCandle - public const uint Omen = 15467; - - // EtherealPet - public const uint EtherealSoulTrader = 27914; - - // TournamentMounts - public const uint StormwindSteed = 33217; - public const uint IronforgeRam = 33316; - public const uint GnomereganMechanostrider = 33317; - public const uint ExodarElekk = 33318; - public const uint DarnassianNightsaber = 33319; - public const uint OrgrimmarWolf = 33320; - public const uint DarkSpearRaptor = 33321; - public const uint ThunderBluffKodo = 33322; - public const uint SilvermoonHawkstrider = 33323; - public const uint ForsakenWarhorse = 33324; - public const uint ArgentWarhorse = 33782; - public const uint ArgentSteedAspirant = 33845; - public const uint ArgentHawkstriderAspirant = 33844; - - // PetSummoned - public const uint Doomguard = 11859; - public const uint Infernal = 89; - public const uint Imp = 416; - - // VendorBarkTrigger - public const uint AmphitheaterVendor = 30098; - - //CorruptinPlagueEntrys - public const uint ApexisFlayer = 22175; - public const uint ShardHideBoar = 22180; - public const uint AetherRay = 22181; - - // StasisFieldEntrys - public const uint DaggertailLizard = 22255; - - // DefenderOfAzerothData - public const uint Nazgrim = 161706; - public const uint Trollbane = 161707; - public const uint Whitemane = 161708; - public const uint Morgaine = 161709; - } - - struct ModelIds - { - //ServiceUniform - public const uint GoblinMale = 31002; - public const uint GoblinFemale = 31003; - } - - struct TextIds - { - //EtherealPet - public const uint SayStealEssence = 1; - public const uint SayCreateToken = 2; - - //VendorBarkTrigger - public const uint SayAmphitheaterVendor = 0; - } - - struct EmoteIds - { - //FuriousRage - public const uint FuriousRage = 19415; - public const uint Exhausted = 18368; - } - - struct AchievementIds - { - //TournamentAchievements - public const uint ChampionStormwind = 2781; - public const uint ChampionDarnassus = 2777; - public const uint ChampionIronforge = 2780; - public const uint ChampionGnomeregan = 2779; - public const uint ChampionTheExodar = 2778; - public const uint ChampionOrgrimmar = 2783; - public const uint ChampionSenJin = 2784; - public const uint ChampionThunderBluff = 2786; - public const uint ChampionUndercity = 2787; - public const uint ChampionSilvermoon = 2785; - public const uint ArgentValor = 2758; - public const uint ChampionAlliance = 2782; - public const uint ChampionHorde = 2788; - } - - struct QuestIds - { - //TournamentQuests - public const uint ValiantOfStormwind = 13593; - public const uint A_ValiantOfStormwind = 13684; - public const uint ValiantOfDarnassus = 13706; - public const uint A_ValiantOfDarnassus = 13689; - public const uint ValiantOfIronforge = 13703; - public const uint A_ValiantOfIronforge = 13685; - public const uint ValiantOfGnomeregan = 13704; - public const uint A_ValiantOfGnomeregan = 13688; - public const uint ValiantOfTheExodar = 13705; - public const uint A_ValiantOfTheExodar = 13690; - public const uint ValiantOfOrgrimmar = 13707; - public const uint A_ValiantOfOrgrimmar = 13691; - public const uint ValiantOfSenJin = 13708; - public const uint A_ValiantOfSenJin = 13693; - public const uint ValiantOfThunderBluff = 13709; - public const uint A_ValiantOfThunderBluff = 13694; - public const uint ValiantOfUndercity = 13710; - public const uint A_ValiantOfUndercity = 13695; - public const uint ValiantOfSilvermoon = 13711; - public const uint A_ValiantOfSilvermoon = 13696; - - //DefenderOfAzerothData - public const uint DefenderOfAzerothAlliance = 58902; - public const uint DefenderOfAzerothHorde = 58903; - } - - struct Misc - { - // FungalDecay - public const int AuraDuration = 12600; // found in sniffs, there is no duration entry we can possibly use - - // FreezingCircleMisc - public const uint MapIdBloodInTheSnowScenario = 1130; - - // Teleporting - public const uint AreaVioletCitadelSpire = 4637; - } - [Script] class spell_gen_absorb0_hitlimit1 : AuraScript { - int limit; + uint limit; public override bool Load() { // Max absorb stored in 1 dummy effect - limit = GetSpellInfo().GetEffect(1).CalcValue(); + limit = (uint)GetSpellInfo().GetEffect(1).CalcValue(); return true; } void Absorb(AuraEffect aurEff, DamageInfo dmgInfo, ref uint absorbAmount) { - absorbAmount = (uint)Math.Min(limit, absorbAmount); + absorbAmount = Math.Min(limit, absorbAmount); } public override void Register() { - OnEffectAbsorb.Add(new EffectAbsorbHandler(Absorb, 0)); + OnEffectAbsorb.Add(new(Absorb, 0)); } } [Script] // 28764 - Adaptive Warding (Frostfire Regalia Set) class spell_gen_adaptive_warding : AuraScript { + const uint SpellGenAdaptiveWardingFire = 28765; + const uint SpellGenAdaptiveWardingNature = 28768; + const uint SpellGenAdaptiveWardingFrost = 28766; + const uint SpellGenAdaptiveWardingShadow = 28769; + const uint SpellGenAdaptiveWardingArcane = 28770; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.GenAdaptiveWardingFire, SpellIds.GenAdaptiveWardingNature, SpellIds.GenAdaptiveWardingFrost, SpellIds.GenAdaptiveWardingShadow, SpellIds.GenAdaptiveWardingArcane); + return ValidateSpellInfo(SpellGenAdaptiveWardingFire, SpellGenAdaptiveWardingNature, SpellGenAdaptiveWardingFrost, SpellGenAdaptiveWardingShadow, SpellGenAdaptiveWardingArcane); } bool CheckProc(ProcEventInfo eventInfo) @@ -502,49 +62,35 @@ namespace Scripts.Spells.Generic if (GetTarget().GetAuraEffect(AuraType.ModManaRegenInterrupt, SpellFamilyNames.Mage, new FlagArray128(0x10000000, 0x0, 0x0)) == null) return false; - switch (SharedConst.GetFirstSchoolInMask(eventInfo.GetSchoolMask())) + return SharedConst.GetFirstSchoolInMask(eventInfo.GetSchoolMask()) switch { - case SpellSchools.Normal: - case SpellSchools.Holy: - return false; - default: - break; - } - return true; + SpellSchools.Normal or SpellSchools.Holy => false, + _ => true + }; } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - uint spellId; - switch (SharedConst.GetFirstSchoolInMask(eventInfo.GetSchoolMask())) + uint spellId = SharedConst.GetFirstSchoolInMask(eventInfo.GetSchoolMask()) switch { - case SpellSchools.Fire: - spellId = SpellIds.GenAdaptiveWardingFire; - break; - case SpellSchools.Nature: - spellId = SpellIds.GenAdaptiveWardingNature; - break; - case SpellSchools.Frost: - spellId = SpellIds.GenAdaptiveWardingFrost; - break; - case SpellSchools.Shadow: - spellId = SpellIds.GenAdaptiveWardingShadow; - break; - case SpellSchools.Arcane: - spellId = SpellIds.GenAdaptiveWardingArcane; - break; - default: - return; - } - GetTarget().CastSpell(GetTarget(), spellId, new CastSpellExtraArgs(aurEff)); + SpellSchools.Fire => SpellGenAdaptiveWardingFire, + SpellSchools.Nature => SpellGenAdaptiveWardingNature, + SpellSchools.Frost => SpellGenAdaptiveWardingFrost, + SpellSchools.Shadow => SpellGenAdaptiveWardingShadow, + SpellSchools.Arcane => SpellGenAdaptiveWardingArcane, + _ => 0 + }; + + if (spellId != 0) + GetTarget().CastSpell(GetTarget(), spellId, aurEff); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -553,48 +99,52 @@ namespace Scripts.Spells.Generic { SpellCastResult CheckRequirement() { - if (!GetCastItem()) + if (GetCastItem() == null) return SpellCastResult.CantDoThatRightNow; + return SpellCastResult.SpellCastOk; } public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); + OnCheckCast.Add(new(CheckRequirement)); } } [Script] // 46221 - Animal Blood class spell_gen_animal_blood : AuraScript { + const uint SpellAnimalBlood = 46221; + const uint SpellSpawnBloodPool = 63471; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.SpawnBloodPool); + return ValidateSpellInfo(SpellSpawnBloodPool); } void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) { // Remove all auras with spell id 46221, except the one currently being applied Aura aur; - while ((aur = GetUnitOwner().GetOwnedAura(SpellIds.AnimalBlood, ObjectGuid.Empty, ObjectGuid.Empty, 0, GetAura())) != null) + while ((aur = GetUnitOwner().GetOwnedAura(SpellAnimalBlood, ObjectGuid.Empty, ObjectGuid.Empty, 0, GetAura())) != null) GetUnitOwner().RemoveOwnedAura(aur); } void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { Unit owner = GetUnitOwner(); - if (owner) - owner.CastSpell(owner, SpellIds.SpawnBloodPool, true); + if (owner != null) + owner.CastSpell(owner, SpellSpawnBloodPool, true); } public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); + AfterEffectApply.Add(new(OnApply, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(OnRemove, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); } } - [Script] // 63471 -Spawn Blood Pool + [Script] // 63471 - Spawn Blood Pool class spell_spawn_blood_pool : SpellScript { void SetDest(ref SpellDestination dest) @@ -609,7 +159,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnDestinationTargetSelect.Add(new DestinationTargetSelectHandler(SetDest, 0, Targets.DestCaster)); + OnDestinationTargetSelect.Add(new(SetDest, 0, Targets.DestCaster)); } } @@ -634,14 +184,14 @@ namespace Scripts.Spells.Generic { public override bool Load() { - return GetCaster() && GetCaster().IsTypeId(TypeId.Player); + return GetCaster() != null && GetCaster().IsPlayer(); } public override bool Validate(SpellInfo spellInfo) { - if (!ValidateSpellEffect(spellInfo.Id, 0) || !spellInfo.GetEffect(0).IsAura(AuraType.ModPowerRegen)) + if (!ValidateSpellEffect((spellInfo.Id, 0)) || spellInfo.GetEffect(0).IsAura(AuraType.ModPowerRegen)) { - Log.outError(LogFilter.Spells, "Aura {GetId()} structure has been changed - first aura is no longer SPELL_AURA_MOD_POWER_REGEN"); + Log.outError(LogFilter.Spells, $"Aura {GetId()} structure has been changed - first aura is no longer AuraType.ModPowerRegen"); return false; } @@ -650,7 +200,7 @@ namespace Scripts.Spells.Generic void CalcPeriodic(AuraEffect aurEff, ref bool isPeriodic, ref int amplitude) { - // Get SPELL_AURA_MOD_POWER_REGEN aura from spell + // Get AuraType.ModPowerRegen aura from spell AuraEffect regen = GetAura().GetEffect(0); if (regen == null) return; @@ -707,9 +257,9 @@ 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)); + DoEffectCalcPeriodic.Add(new(CalcPeriodic, 1, AuraType.PeriodicDummy)); + DoEffectCalcAmount.Add(new(CalcAmount, 1, AuraType.PeriodicDummy)); + OnEffectUpdatePeriodic.Add(new(UpdatePeriodic, 1, AuraType.PeriodicDummy)); } } @@ -718,7 +268,7 @@ namespace Scripts.Spells.Generic { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 0) && ValidateSpellInfo(spellInfo.GetEffect(0).TriggerSpell); + return ValidateSpellEffect((spellInfo.Id, 0)) && ValidateSpellInfo(spellInfo.GetEffect(0).TriggerSpell); } void PeriodicTick(AuraEffect aurEff) @@ -732,7 +282,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(PeriodicTick, 0, AuraType.PeriodicTriggerSpell)); + OnEffectPeriodic.Add(new(PeriodicTick, 0, AuraType.PeriodicTriggerSpell)); } } @@ -741,35 +291,47 @@ namespace Scripts.Spells.Generic { bool CheckAreaTarget(Unit target) { - return (target.GetEntry()) switch + switch (target.GetEntry()) { // alliance - // Dun Baldar North Marshal - 14762 or 14763 or 14764 or 14765 or 11948 or 14772 or 14776 or 14773 or 14777 or 11946 => true, - _ => false, - }; + case 14762: // Dun Baldar North Marshal + case 14763: // Dun Baldar South Marshal + case 14764: // Icewing Marshal + case 14765: // Stonehearth Marshal + case 11948: // Vandar Stormspike + // horde + case 14772: // East Frostwolf Warmaster + case 14776: // Tower Point Warmaster + case 14773: // Iceblood Warmaster + case 14777: // West Frostwolf Warmaster + case 11946: // Drek'thar + return true; + default: + return false; + } } public override void Register() { - DoCheckAreaTarget.Add(new CheckAreaTargetHandler(CheckAreaTarget)); + DoCheckAreaTarget.Add(new(CheckAreaTarget)); } } [Script] class spell_gen_bandage : SpellScript { + const uint SpellRecentlyBandaged = 11196; public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.RecentlyBandaged); + return ValidateSpellInfo(SpellRecentlyBandaged); } SpellCastResult CheckCast() { Unit target = GetExplTargetUnit(); - if (target) + if (target != null) { - if (target.HasAura(SpellIds.RecentlyBandaged)) + if (target.HasAura(SpellRecentlyBandaged)) return SpellCastResult.TargetAurastate; } return SpellCastResult.SpellCastOk; @@ -778,97 +340,95 @@ namespace Scripts.Spells.Generic void HandleScript() { Unit target = GetHitUnit(); - if (target) - GetCaster().CastSpell(target, SpellIds.RecentlyBandaged, true); + if (target != null) + GetCaster().CastSpell(target, SpellRecentlyBandaged, true); } public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - AfterHit.Add(new HitHandler(HandleScript)); + OnCheckCast.Add(new(CheckCast)); + AfterHit.Add(new(HandleScript)); } } [Script] // 193970 - Mercenary Shapeshift class spell_gen_battleground_mercenary_shapeshift : AuraScript { - //using OtherFactionRacePriorityList = std::array; + List RacialSkills = new(); - static Dictionary RaceInfo = new() + Dictionary RaceInfo = new() { - { Race.Human, new[] { Race.Undead, Race.BloodElf } }, - { Race.Orc, new[] { Race.Dwarf } }, - { Race.Dwarf, new[] { Race.Orc, Race.Undead, Race.Tauren } }, - { Race.NightElf, new[] { Race.Troll, Race.BloodElf } }, - { Race.Undead, new[] { Race.Human } }, - { Race.Tauren, new[] { Race.Draenei, Race.NightElf } }, - { Race.Gnome, new[] { Race.Goblin, Race.BloodElf } }, - { Race.Troll, new[] { Race.NightElf, Race.Human, Race.Draenei } }, - { Race.Goblin, new[] { Race.Gnome, Race.Dwarf } }, - { Race.BloodElf, new[] { Race.Human, Race.NightElf } }, - { Race.Draenei, new[] { Race.Tauren, Race.Orc } }, - { Race.Worgen, new[] { Race.Troll } }, - { Race.PandarenNeutral, new[] { Race.PandarenNeutral } }, - { Race.PandarenAlliance, new[] { Race.PandarenHorde, Race.PandarenNeutral } }, - { Race.PandarenHorde, new[] { Race.PandarenAlliance, Race.PandarenNeutral } }, - { Race.Nightborne, new[] { Race.NightElf, Race.Human } }, - { Race.HighmountainTauren, new[] { Race.Draenei, Race.NightElf } }, - { Race.VoidElf, new[] { Race.Troll, Race.BloodElf } }, - { Race.LightforgedDraenei, new[] { Race.Tauren, Race.Orc } }, - { Race.ZandalariTroll, new[] { Race.KulTiran, Race.Human } }, - { Race.KulTiran, new[] { Race.ZandalariTroll } }, - { Race.DarkIronDwarf, new[] { Race.MagharOrc, Race.Orc } }, - { Race.Vulpera, new[] { Race.MechaGnome, Race.DarkIronDwarf /*Guessed, For Shamans*/ } }, - { Race.MagharOrc, new[] { Race.DarkIronDwarf } }, - { Race.MechaGnome, new[] { Race.Vulpera } }, + { Race.Human , new[] { Race.Undead, Race.BloodElf } }, + { Race.Orc , new[] { Race.Dwarf } }, + { Race.Dwarf , new[] { Race.Orc, Race.Undead, Race.Tauren } }, + { Race.NightElf , new[] { Race.Troll, Race.BloodElf } }, + { Race.Undead , new[] { Race.Human } }, + { Race.Tauren , new[] { Race.Draenei, Race.NightElf } }, + { Race.Gnome , new[] { Race.Goblin, Race.BloodElf } }, + { Race.Troll , new[] { Race.NightElf, Race.Human, Race.Draenei } }, + { Race.Goblin , new[] { Race.Gnome, Race.Dwarf } }, + { Race.BloodElf , new[] { Race.Human, Race.NightElf } }, + { Race.Draenei , new[] { Race.Tauren, Race.Orc } }, + { Race.Worgen , new[] { Race.Troll } }, + { Race.PandarenNeutral , new[] { Race.PandarenNeutral } }, + { Race.PandarenAlliance , new[] { Race.PandarenHorde, Race.PandarenNeutral } }, + { Race.PandarenHorde , new[] { Race.PandarenAlliance, Race.PandarenNeutral } }, + { Race.Nightborne , new[] { Race.NightElf, Race.Human } }, + { Race.HighmountainTauren , new[] { Race.Draenei, Race.NightElf } }, + { Race.VoidElf , new[] { Race.Troll, Race.BloodElf } }, + { Race.LightforgedDraenei , new[] { Race.Tauren, Race.Orc } }, + { Race.ZandalariTroll , new[] { Race.KulTiran, Race.Human } }, + { Race.KulTiran , new[] { Race.ZandalariTroll } }, + { Race.DarkIronDwarf , new[] { Race.MagharOrc, Race.Orc } }, + { Race.Vulpera , new[] { Race.MechaGnome, Race.DarkIronDwarf } }, + { Race.MagharOrc , new[] { Race.DarkIronDwarf } }, + { Race.MechaGnome , new[] { Race.Vulpera } }, }; - static Dictionary RaceDisplayIds = new() + Dictionary RaceDisplayIds = new() { - { Race.Human, new uint[] { 55239, 55238 } }, - { Race.Orc, new uint[] { 55257, 55256 } }, - { Race.Dwarf, new uint[] { 55241, 55240 } }, - { Race.NightElf, new uint[] { 55243, 55242 } }, - { Race.Undead, new uint[] { 55259, 55258 } }, - { Race.Tauren, new uint[] { 55261, 55260 } }, - { Race.Gnome, new uint[] { 55245, 55244 } }, - { Race.Troll, new uint[] { 55263, 55262 } }, - { Race.Goblin, new uint[] { 55267, 57244 } }, - { Race.BloodElf, new uint[] { 55265, 55264 } }, - { Race.Draenei, new uint[] { 55247, 55246 } }, - { Race.Worgen, new uint[] { 55255, 55254 } }, - { Race.PandarenNeutral, new uint[] { 55253, 55252 } }, // Not Verified, Might Be Swapped With Race.PandarenHorde - { Race.PandarenAlliance, new uint[] { 55249, 55248 } }, - { Race.PandarenHorde, new uint[] { 55251, 55250 } }, - { Race.Nightborne, new uint[] { 82375, 82376 } }, - { Race.HighmountainTauren, new uint[] { 82377, 82378 } }, - { Race.VoidElf, new uint[] { 82371, 82372 } }, - { Race.LightforgedDraenei, new uint[] { 82373, 82374 } }, - { Race.ZandalariTroll, new uint[] { 88417, 88416 } }, - { Race.KulTiran, new uint[] { 88414, 88413 } }, - { Race.DarkIronDwarf, new uint[] { 88409, 88408 } }, - { Race.Vulpera, new uint[] { 94999, 95001 } }, - { Race.MagharOrc, new uint[] { 88420, 88410 } }, - { Race.MechaGnome, new uint[] { 94998, 95000 } }, + { Race.Human , new uint[] { 55239, 55238 } }, + { Race.Orc , new uint[] { 55257, 55256 } }, + { Race.Dwarf , new uint[] { 55241, 55240 } }, + { Race.NightElf , new uint[] { 55243, 55242 } }, + { Race.Undead , new uint[] { 55259, 55258 } }, + { Race.Tauren , new uint[] { 55261, 55260 } }, + { Race.Gnome , new uint[] { 55245, 55244 } }, + { Race.Troll , new uint[] { 55263, 55262 } }, + { Race.Goblin , new uint[] { 55267, 57244 } }, + { Race.BloodElf , new uint[] { 55265, 55264 } }, + { Race.Draenei , new uint[] { 55247, 55246 } }, + { Race.Worgen , new uint[] { 55255, 55254 } }, + { Race.PandarenNeutral , new uint[] { 55253, 55252 } }, // not verified, might be swapped with RacePandarenHorde + { Race.PandarenAlliance , new uint[] { 55249, 55248 } }, + { Race.PandarenHorde , new uint[] { 55251, 55250 } }, + { Race.Nightborne , new uint[] { 82375, 82376 } }, + { Race.HighmountainTauren , new uint[] { 82377, 82378 } }, + { Race.VoidElf , new uint[] { 82371, 82372 } }, + { Race.LightforgedDraenei , new uint[] { 82373, 82374 } }, + { Race.ZandalariTroll , new uint[] { 88417, 88416 } }, + { Race.KulTiran , new uint[] { 88414, 88413 } }, + { Race.DarkIronDwarf , new uint[] { 88409, 88408 } }, + { Race.Vulpera , new uint[] { 94999, 95001 } }, + { Race.MagharOrc , new uint[] { 88420, 88410 } }, + { Race.MechaGnome , new uint[] { 94998, 95000 } }, }; - static List RacialSkills = new(); - - static Race GetReplacementRace(Race nativeRace, Class playerClass) + Race GetReplacementRace(Race nativeRace, Class playerClass) { var otherRaces = RaceInfo.LookupByKey(nativeRace); - if (otherRaces != null) + if (!otherRaces.Empty()) foreach (Race race in otherRaces) - if (Global.ObjectMgr.GetPlayerInfo(race, playerClass) != null) + if (ObjectMgr.GetPlayerInfo(race, playerClass) != null) return race; return Race.None; } - static uint GetDisplayIdForRace(Race race, Gender gender) + uint GetDisplayIdForRace(Race race, Gender gender) { var displayIds = RaceDisplayIds.LookupByKey(race); - if (displayIds != null) + if (!displayIds.Empty()) return displayIds[(int)gender]; return 0; @@ -892,12 +452,12 @@ namespace Scripts.Spells.Generic return false; foreach (uint displayId in displayIds) - if (CliDB.CreatureDisplayInfoStorage.ContainsKey(displayId)) + if (!CliDB.CreatureDisplayInfoStorage.ContainsKey(displayId)) return false; } RacialSkills.Clear(); - foreach (SkillLineRecord skillLine in CliDB.SkillLineStorage.Values) + foreach (var skillLine in CliDB.SkillLineStorage.Values) if (skillLine.GetFlags().HasFlag(SkillLineFlags.RacialForThePurposeOfTemporaryRaceChange)) RacialSkills.Add(skillLine.Id); @@ -937,32 +497,35 @@ namespace Scripts.Spells.Generic foreach (uint racialSkillId in RacialSkills) { - if (Global.DB2Mgr.GetSkillRaceClassInfo(racialSkillId, oldRace, player.GetClass()) != null) + if (DB2Mgr.GetSkillRaceClassInfo(racialSkillId, oldRace, player.GetClass()) != null) { - var skillLineAbilities = Global.DB2Mgr.GetSkillLineAbilitiesBySkill(racialSkillId); + var skillLineAbilities = DB2Mgr.GetSkillLineAbilitiesBySkill(racialSkillId); if (skillLineAbilities != null) foreach (var ability in skillLineAbilities) player.RemoveSpell(ability.Spell, false, false); } - if (Global.DB2Mgr.GetSkillRaceClassInfo(racialSkillId, newRace, player.GetClass()) != null) + if (DB2Mgr.GetSkillRaceClassInfo(racialSkillId, newRace, player.GetClass()) != null) player.LearnSkillRewardedSpells(racialSkillId, player.GetMaxSkillValueForLevel(), newRace); } } public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Transform, AuraEffectHandleModes.SendForClientMask)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.Transform, AuraEffectHandleModes.Real)); + AfterEffectApply.Add(new(HandleApply, 0, AuraType.Transform, AuraEffectHandleModes.SendForClientMask)); + AfterEffectRemove.Add(new(HandleRemove, 0, AuraType.Transform, AuraEffectHandleModes.Real)); } } [Script] // Blood Reserve - 64568 class spell_gen_blood_reserve : AuraScript { + const uint SpellGenBloodReserveAura = 64568; + const uint SpellGenBloodReserveHeal = 64569; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.BloodReserveHeal); + return ValidateSpellInfo(SpellGenBloodReserveHeal); } bool CheckProc(ProcEventInfo eventInfo) @@ -982,37 +545,41 @@ namespace Scripts.Spells.Generic Unit caster = eventInfo.GetActionTarget(); CastSpellExtraArgs args = new(aurEff); args.AddSpellMod(SpellValueMod.BasePoint0, aurEff.GetAmount()); - caster.CastSpell(caster, SpellIds.BloodReserveHeal, args); - caster.RemoveAura(SpellIds.BloodReserveAura); + caster.CastSpell(caster, SpellGenBloodReserveHeal, args); + caster.RemoveAura(SpellGenBloodReserveAura); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); } } [Script] class spell_gen_bonked : SpellScript { + const uint SpellBonked = 62991; + const uint SpellFoamSwordDefeat = 62994; + const uint SpellOnGuard = 62972; + void HandleScript(uint effIndex) { Player target = GetHitPlayer(); - if (target) + if (target != null) { Aura aura = GetHitAura(); if (!(aura != null && aura.GetStackAmount() == 3)) return; - target.CastSpell(target, SpellIds.FormSwordDefeat, true); - target.RemoveAurasDueToSpell(SpellIds.Bonked); + target.CastSpell(target, SpellFoamSwordDefeat, true); + target.RemoveAurasDueToSpell(SpellBonked); - aura = target.GetAura(SpellIds.Onguard); - if (aura != null) + Aura auraOnGuard = target.GetAura(SpellOnGuard); + if (auraOnGuard != null) { - Item item = target.GetItemByGuid(aura.GetCastItemGUID()); - if (item) + Item item = target.GetItemByGuid(auraOnGuard.GetCastItemGUID()); + if (item != null) target.DestroyItemCount(item.GetEntry(), 1, true); } } @@ -1020,7 +587,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 1, SpellEffectName.ScriptEffect)); } } @@ -1028,6 +595,13 @@ namespace Scripts.Spells.Generic [Script("spell_gen_tournament_counterattack")] class spell_gen_break_shield : SpellScript { + const uint SpellBreakShieldDamage2K = 62626; + const uint SpellBreakShieldDamage10K = 64590; + + const uint SpellBreakShieldTriggerFactionMounts = 62575; // Also on ToC5 mounts + const uint SpellBreakShieldTriggerCampaingWarhorse = 64595; + const uint SpellBreakShieldTriggerUnk = 66480; + public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(62552, 62719, 64100, 66482); @@ -1045,18 +619,19 @@ namespace Scripts.Spells.Generic switch (GetSpellInfo().Id) { - case SpellIds.BreakShieldTriggerUnk: - case SpellIds.BreakShieldTriggerCampaingWarhorse: - spellId = SpellIds.BreakShieldDamage10k; + case SpellBreakShieldTriggerUnk: + case SpellBreakShieldTriggerCampaingWarhorse: + spellId = SpellBreakShieldDamage10K; break; - case SpellIds.BreakShieldTriggerFactionMounts: - spellId = SpellIds.BreakShieldDamage2k; + case SpellBreakShieldTriggerFactionMounts: + spellId = SpellBreakShieldDamage2K; break; default: return; } + Unit rider = GetCaster().GetCharmer(); - if (rider) + if (rider != null) rider.CastSpell(target, spellId, false); else GetCaster().CastSpell(target, spellId, false); @@ -1075,7 +650,7 @@ namespace Scripts.Spells.Generic aura.ModStackAmount(-1, AuraRemoveMode.EnemySpell); // Remove dummys from rider (Necessary for updating visual shields) Unit rider = target.GetCharmer(); - if (rider) + if (rider != null) { Aura defend = rider.GetAura(aura.GetId()); if (defend != null) @@ -1094,7 +669,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, SpellConst.EffectFirstFound, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScriptEffect, SpellConst.EffectFirstFound, SpellEffectName.ScriptEffect)); } } @@ -1103,13 +678,13 @@ namespace Scripts.Spells.Generic { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 2) && ValidateSpellInfo((uint)spellInfo.GetEffect(2).CalcValue()); + return ValidateSpellEffect((spellInfo.Id, 2)) && ValidateSpellInfo((uint)(spellInfo.GetEffect(2).CalcValue())); } void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode) { Unit caster = GetCaster(); - if (caster) + if (caster != null) caster.CastSpell(GetTarget(), (uint)GetEffectInfo(2).CalcValue()); } @@ -1120,17 +695,19 @@ namespace Scripts.Spells.Generic public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Transform, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.Transform, AuraEffectHandleModes.Real)); + AfterEffectApply.Add(new(HandleApply, 0, AuraType.Transform, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(HandleRemove, 0, AuraType.Transform, AuraEffectHandleModes.Real)); } } [Script] class spell_gen_cannibalize : SpellScript { + const uint SpellCannibalizeTriggered = 20578; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.CannibalizeTriggered); + return ValidateSpellInfo(SpellCannibalizeTriggered); } SpellCastResult CheckIfCorpseNear() @@ -1138,25 +715,25 @@ namespace Scripts.Spells.Generic Unit caster = GetCaster(); float max_range = GetSpellInfo().GetMaxRange(false); // search for nearby enemy corpse in range - var check = new AnyDeadUnitSpellTargetInRangeCheck(caster, max_range, GetSpellInfo(), SpellTargetCheckTypes.Enemy, SpellTargetObjectTypes.CorpseEnemy); - var searcher = new UnitSearcher(caster, check); + AnyDeadUnitSpellTargetInRangeCheck check = new(caster, max_range, GetSpellInfo(), SpellTargetCheckTypes.Enemy, SpellTargetObjectTypes.CorpseEnemy); + WorldObjectSearcher searcher = new(caster, check); Cell.VisitWorldObjects(caster, searcher, max_range); - if (!searcher.GetTarget()) + if (searcher.GetTarget() == null) Cell.VisitGridObjects(caster, searcher, max_range); - if (!searcher.GetTarget()) + if (searcher.GetTarget() == null) return SpellCastResult.NoEdibleCorpses; return SpellCastResult.SpellCastOk; } void HandleDummy(uint effIndex) { - GetCaster().CastSpell(GetCaster(), SpellIds.CannibalizeTriggered, false); + GetCaster().CastSpell(GetCaster(), SpellCannibalizeTriggered, false); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - OnCheckCast.Add(new CheckCastHandler(CheckIfCorpseNear)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); + OnCheckCast.Add(new(CheckIfCorpseNear)); } } @@ -1176,16 +753,18 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectUpdatePeriodic.Add(new EffectUpdatePeriodicHandler(UpdatePeriodic, 1, AuraType.PeriodicDummy)); + OnEffectUpdatePeriodic.Add(new(UpdatePeriodic, 1, AuraType.PeriodicDummy)); } } [Script] class spell_gen_chaos_blast : SpellScript { + const uint SpellChaosBlast = 37675; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.ChaosBlast); + return ValidateSpellInfo(SpellChaosBlast); } void HandleDummy(uint effIndex) @@ -1193,17 +772,17 @@ namespace Scripts.Spells.Generic int basepoints0 = 100; Unit caster = GetCaster(); Unit target = GetHitUnit(); - if (target) + if (target != null) { CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); args.AddSpellMod(SpellValueMod.BasePoint0, basepoints0); - caster.CastSpell(target, SpellIds.ChaosBlast, args); + caster.CastSpell(target, SpellChaosBlast, args); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -1218,13 +797,15 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] class spell_gen_clone : SpellScript { + const uint SpellNightmareFigmentMirrorImage = 57528; + void HandleScriptEffect(uint effIndex) { PreventHitDefaultEffect(effIndex); @@ -1233,15 +814,15 @@ namespace Scripts.Spells.Generic public override void Register() { - if (m_scriptSpellId == SpellIds.NightmareFigmentMirrorImage) + if (m_scriptSpellId == SpellNightmareFigmentMirrorImage) { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.Dummy)); - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 2, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 1, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 2, SpellEffectName.Dummy)); } else { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 2, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 2, SpellEffectName.ScriptEffect)); } } } @@ -1257,75 +838,80 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } [Script] class spell_gen_clone_weapon_AuraScript : AuraScript { + const uint SpellCopyWeaponAura = 41054; + const uint SpellCopyWeapon2Aura = 63418; + const uint SpellCopyWeapon3Aura = 69893; + + const uint SpellCopyOffhandAura = 45205; + const uint SpellCopyOffhand2Aura = 69896; + + const uint SpellCopyRangedAura = 57594; + + uint prevItem; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.WeaponAura, SpellIds.Weapon2Aura, SpellIds.Weapon3Aura, SpellIds.OffhandAura, SpellIds.Offhand2Aura, SpellIds.RangedAura); - } - - public override bool Load() - { - prevItem = 0; - return true; + return ValidateSpellInfo(SpellCopyWeaponAura, SpellCopyWeapon2Aura, SpellCopyWeapon3Aura, SpellCopyOffhandAura, SpellCopyOffhand2Aura, SpellCopyRangedAura); } void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) { Unit caster = GetCaster(); Unit target = GetTarget(); - if (!caster) + if (caster == null) return; switch (GetSpellInfo().Id) { - case SpellIds.WeaponAura: - case SpellIds.Weapon2Aura: - case SpellIds.Weapon3Aura: + case SpellCopyWeaponAura: + case SpellCopyWeapon2Aura: + case SpellCopyWeapon3Aura: { prevItem = target.GetVirtualItemId(0); Player player = caster.ToPlayer(); - if (player) + if (player != null) { Item mainItem = player.GetItemByPos(InventorySlots.Bag0, EquipmentSlot.MainHand); - if (mainItem) + if (mainItem != null) target.SetVirtualItem(0, mainItem.GetEntry()); } else target.SetVirtualItem(0, caster.GetVirtualItemId(0)); break; } - case SpellIds.OffhandAura: - case SpellIds.Offhand2Aura: + case SpellCopyOffhandAura: + case SpellCopyOffhand2Aura: { prevItem = target.GetVirtualItemId(1); Player player = caster.ToPlayer(); - if (player) + if (player != null) { Item offItem = player.GetItemByPos(InventorySlots.Bag0, EquipmentSlot.OffHand); - if (offItem) + if (offItem != null) target.SetVirtualItem(1, offItem.GetEntry()); } else target.SetVirtualItem(1, caster.GetVirtualItemId(1)); break; } - case SpellIds.RangedAura: + case SpellCopyRangedAura: { prevItem = target.GetVirtualItemId(2); Player player = caster.ToPlayer(); - if (player) + if (player != null) { Item rangedItem = player.GetItemByPos(InventorySlots.Bag0, EquipmentSlot.MainHand); - if (rangedItem) + if (rangedItem != null) target.SetVirtualItem(2, rangedItem.GetEntry()); } else @@ -1343,16 +929,16 @@ namespace Scripts.Spells.Generic switch (GetSpellInfo().Id) { - case SpellIds.WeaponAura: - case SpellIds.Weapon2Aura: - case SpellIds.Weapon3Aura: + case SpellCopyWeaponAura: + case SpellCopyWeapon2Aura: + case SpellCopyWeapon3Aura: target.SetVirtualItem(0, prevItem); break; - case SpellIds.OffhandAura: - case SpellIds.Offhand2Aura: + case SpellCopyOffhandAura: + case SpellCopyOffhand2Aura: target.SetVirtualItem(1, prevItem); break; - case SpellIds.RangedAura: + case SpellCopyRangedAura: target.SetVirtualItem(2, prevItem); break; default: @@ -1362,11 +948,9 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); + OnEffectApply.Add(new(OnApply, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); + OnEffectRemove.Add(new(OnRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); } - - uint prevItem; } [Script("spell_gen_default_count_pct_from_max_hp", 0)] @@ -1390,7 +974,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnHit.Add(new HitHandler(RecalculateDamage)); + OnHit.Add(new(RecalculateDamage)); } } @@ -1400,23 +984,26 @@ namespace Scripts.Spells.Generic { void CalculateDamage(Unit victim, ref int damage, ref int flatMod, ref float pctMod) { - SpellInfo createdBySpell = Global.SpellMgr.GetSpellInfo(GetCaster().m_unitData.CreatedBySpell, GetCastDifficulty()); + SpellInfo createdBySpell = SpellMgr.GetSpellInfo(GetCaster().m_unitData.CreatedBySpell, GetCastDifficulty()); if (createdBySpell != null) - damage = createdBySpell.GetEffect(2).CalcValue(); + damage = createdBySpell.GetEffect(1).CalcValue(); } public override void Register() { - CalcDamage.Add(new DamageAndHealingCalcHandler(CalculateDamage)); + CalcDamage.Add(new(CalculateDamage)); } } [Script] // 63845 - Create Lance class spell_gen_create_lance : SpellScript { + const uint SpellCreateLanceAlliance = 63914; + const uint SpellCreateLanceHorde = 63919; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.CreateLanceAlliance, SpellIds.CreateLanceHorde); + return ValidateSpellInfo(SpellCreateLanceAlliance, SpellCreateLanceHorde); } void HandleScript(uint effIndex) @@ -1424,18 +1011,18 @@ namespace Scripts.Spells.Generic PreventHitDefaultEffect(effIndex); Player target = GetHitPlayer(); - if (target) + if (target != null) { if (target.GetTeam() == Team.Alliance) - GetCaster().CastSpell(target, SpellIds.CreateLanceAlliance, true); + GetCaster().CastSpell(target, SpellCreateLanceAlliance, true); else - GetCaster().CastSpell(target, SpellIds.CreateLanceHorde, true); + GetCaster().CastSpell(target, SpellCreateLanceHorde, true); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -1443,31 +1030,45 @@ namespace Scripts.Spells.Generic [Script("spell_gen_silver_covenant_disguise")] class spell_gen_dalaran_disguise : SpellScript { + const uint SpellSunreaverDisguiseTrigger = 69672; + const uint SpellSunreaverDisguiseFemale = 70973; + const uint SpellSunreaverDisguiseMale = 70974; + + const uint SpellSilverCovenantDisguiseTrigger = 69673; + const uint SpellSilverCovenantDisguiseFemale = 70971; + const uint SpellSilverCovenantDisguiseMale = 70972; + public override bool Validate(SpellInfo spellInfo) { - return spellInfo.Id switch + switch (spellInfo.Id) { - SpellIds.SunreaverTrigger => ValidateSpellInfo(SpellIds.SunreaverFemale, SpellIds.SunreaverMale), - SpellIds.SilverCovenantTrigger => ValidateSpellInfo(SpellIds.SilverCovenantFemale, SpellIds.SilverCovenantMale), - _ => false, - }; + case SpellSunreaverDisguiseTrigger: + return ValidateSpellInfo(SpellSunreaverDisguiseFemale, SpellSunreaverDisguiseMale); + case SpellSilverCovenantDisguiseTrigger: + return ValidateSpellInfo(SpellSilverCovenantDisguiseFemale, SpellSilverCovenantDisguiseMale); + default: + break; + } + + return false; } void HandleScript(uint effIndex) { Player player = GetHitPlayer(); - if (player) + if (player != null) { Gender gender = player.GetNativeGender(); uint spellId = GetSpellInfo().Id; + switch (spellId) { - case SpellIds.SunreaverTrigger: - spellId = gender == Gender.Female ? SpellIds.SunreaverFemale : SpellIds.SunreaverMale; + case SpellSunreaverDisguiseTrigger: + spellId = gender == Gender.Female ? SpellSunreaverDisguiseFemale : SpellSunreaverDisguiseMale; break; - case SpellIds.SilverCovenantTrigger: - spellId = gender == Gender.Female ? SpellIds.SilverCovenantFemale : SpellIds.SilverCovenantMale; + case SpellSilverCovenantDisguiseTrigger: + spellId = gender == Gender.Female ? SpellSilverCovenantDisguiseFemale : SpellSilverCovenantDisguiseMale; break; default: break; @@ -1479,12 +1080,12 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } - [Script] // 32065 - Fungal Decay - class spell_gen_decay_over_time_fungal_decay_SpellScript : SpellScript + [Script] + class spell_gen_decay_over_time_spell : SpellScript { void ModAuraStack() { @@ -1495,60 +1096,48 @@ namespace Scripts.Spells.Generic public override void Register() { - AfterHit.Add(new HitHandler(ModAuraStack)); + AfterHit.Add(new(ModAuraStack)); } } [Script] // 32065 - Fungal Decay - class spell_gen_decay_over_time_fungal_decay_AuraScript : AuraScript + class spell_gen_decay_over_time_fungal_decay : AuraScript { + // found in sniffs, there is no duration entry we can possibly use + const int AuraDuration = 12600; + + bool CheckProc(ProcEventInfo eventInfo) + { + return eventInfo.GetSpellInfo() == GetSpellInfo(); + } + + void Decay(ProcEventInfo eventInfo) + { + PreventDefaultAction(); + ModStackAmount(-1); + } + void ModDuration(AuraEffect aurEff, AuraEffectHandleModes mode) { // only on actual reapply, not on stack decay if (GetDuration() == GetMaxDuration()) { - SetMaxDuration(Misc.AuraDuration); - SetDuration(Misc.AuraDuration); + SetMaxDuration(AuraDuration); + SetDuration(AuraDuration); } } - bool CheckProc(ProcEventInfo eventInfo) - { - return eventInfo.GetSpellInfo() == GetSpellInfo(); - } - - void Decay(ProcEventInfo eventInfo) - { - PreventDefaultAction(); - ModStackAmount(-1); - } - public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnProc.Add(new AuraProcHandler(Decay)); - OnEffectApply.Add(new EffectApplyHandler(ModDuration, 0, AuraType.ModDecreaseSpeed, AuraEffectHandleModes.RealOrReapplyMask)); + DoCheckProc.Add(new(CheckProc)); + OnProc.Add(new(Decay)); + OnEffectApply.Add(new(ModDuration, 0, AuraType.ModDecreaseSpeed, AuraEffectHandleModes.RealOrReapplyMask)); } } + // 36659 - Tail Sting [Script] // 36659 - Tail Sting - class spell_gen_decay_over_time_tail_sting_SpellScript : SpellScript - { - void ModAuraStack() - { - Aura aur = GetHitAura(); - if (aur != null) - aur.SetStackAmount((byte)GetSpellInfo().StackAmount); - } - - public override void Register() - { - AfterHit.Add(new HitHandler(ModAuraStack)); - } - } - - [Script] // 36659 - Tail Sting - class spell_gen_decay_over_time_tail_sting_AuraScript : AuraScript + class spell_gen_decay_over_time_tail_sting : AuraScript { bool CheckProc(ProcEventInfo eventInfo) { @@ -1563,30 +1152,107 @@ namespace Scripts.Spells.Generic public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnProc.Add(new AuraProcHandler(Decay)); - } - } - - class spell_gen_despawn_aura : AuraScript - { - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - GetTarget().ToCreature()?.DespawnOrUnsummon(); - } - - public override void Register() - { - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, SpellConst.EffectFirstFound, AuraType.Dummy, AuraEffectHandleModes.Real)); + DoCheckProc.Add(new(CheckProc)); + OnProc.Add(new(Decay)); } } [Script] + class spell_gen_defend : AuraScript + { + const uint SpellVisualShield1 = 63130; + const uint SpellVisualShield2 = 63131; + const uint SpellVisualShield3 = 63132; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellVisualShield1, SpellVisualShield2, SpellVisualShield3); + } + + void RefreshVisualShields(AuraEffect aurEff, AuraEffectHandleModes mode) + { + if (GetCaster() != null) + { + Unit target = GetTarget(); + + for (byte i = 0; i < GetSpellInfo().StackAmount; ++i) + target.RemoveAurasDueToSpell(SpellVisualShield1 + i); + + target.CastSpell(target, SpellVisualShield1 + GetAura().GetStackAmount() - 1, aurEff); + } + else + GetTarget().RemoveAurasDueToSpell(GetId()); + } + + void RemoveVisualShields(AuraEffect aurEff, AuraEffectHandleModes mode) + { + for (byte i = 0; i < GetSpellInfo().StackAmount; ++i) + GetTarget().RemoveAurasDueToSpell(SpellVisualShield1 + i); + } + + void RemoveDummyFromDriver(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit caster = GetCaster(); + if (caster != null) + { + TempSummon vehicle = caster.ToTempSummon(); + if (vehicle != null) + { + Unit rider = vehicle.GetSummonerUnit(); + if (rider != null) + rider.RemoveAurasDueToSpell(GetId()); + } + } + } + + public override void Register() + { + SpellInfo spell = SpellMgr.GetSpellInfo(m_scriptSpellId, Difficulty.None); + + // 6.x effects Removed + + // Defend spells cast by NPCs (add visuals) + if (spell.GetEffect(0).ApplyAuraName == AuraType.ModDamagePercentTaken) + { + AfterEffectApply.Add(new(RefreshVisualShields, 0, AuraType.ModDamagePercentTaken, AuraEffectHandleModes.RealOrReapplyMask)); + OnEffectRemove.Add(new(RemoveVisualShields, 0, AuraType.ModDamagePercentTaken, AuraEffectHandleModes.ChangeAmountMask)); + } + + // Remove Defend spell from player when he dismounts + if (spell.GetEffect(2).ApplyAuraName == AuraType.ModDamagePercentTaken) + OnEffectRemove.Add(new(RemoveDummyFromDriver, 2, AuraType.ModDamagePercentTaken, AuraEffectHandleModes.Real)); + + // Defend spells cast by players (add/Remove visuals) + if (spell.GetEffect(1).ApplyAuraName == AuraType.Dummy) + { + AfterEffectApply.Add(new(RefreshVisualShields, 1, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); + OnEffectRemove.Add(new(RemoveVisualShields, 1, AuraType.Dummy, AuraEffectHandleModes.ChangeAmountMask)); + } + } + } + + [Script] + class spell_gen_despawn_AuraScript : AuraScript + { + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Creature target = GetTarget().ToCreature(); + if (target != null) + target.DespawnOrUnsummon(); + } + + public override void Register() + { + AfterEffectRemove.Add(new(OnRemove, SpellConst.EffectFirstFound, AuraType.Dummy, AuraEffectHandleModes.Real)); + } + } + + [Script] /// @todo: migrate spells to spell_gen_despawn_target, then Remove this class spell_gen_despawn_self : SpellScript { public override bool Load() { - return GetCaster().IsTypeId(TypeId.Unit); + return GetCaster().GetTypeId() == TypeId.Unit; } void HandleDummy(uint effIndex) @@ -1597,7 +1263,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, SpellConst.EffectAll, SpellEffectName.Any)); + OnEffectHitTarget.Add(new(HandleDummy, SpellConst.EffectAll, SpellEffectName.Any)); } } @@ -1616,31 +1282,33 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDespawn, SpellConst.EffectAll, SpellEffectName.Any)); + OnEffectHitTarget.Add(new(HandleDespawn, SpellConst.EffectAll, SpellEffectName.Any)); } } [Script] // 70769 Divine Storm! class spell_gen_divine_storm_cd_reset : SpellScript { + const uint SpellDivineStorm = 53385; + public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.DivineStorm); + return ValidateSpellInfo(SpellDivineStorm); } void HandleScript(uint effIndex) { - GetCaster().GetSpellHistory().ResetCooldown(SpellIds.DivineStorm, true); + GetCaster().GetSpellHistory().ResetCooldown(SpellDivineStorm, true); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.Dummy)); } } @@ -1651,10 +1319,10 @@ namespace Scripts.Spells.Generic { // Here the target is the water spout and determines the position where the player is knocked from Unit target = GetHitUnit(); - if (target) + if (target != null) { Player player = GetCaster().ToPlayer(); - if (player) + if (player != null) { float horizontalSpeed = 20.0f + (40.0f - GetCaster().GetDistance(target)); float verticalSpeed = 8.0f; @@ -1667,7 +1335,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.Dummy)); } } @@ -1676,8 +1344,7 @@ namespace Scripts.Spells.Generic { public override bool Load() { - _handled = false; - return GetCaster().IsTypeId(TypeId.Unit); + return GetCaster().GetTypeId() == TypeId.Unit; } void CreditEncounter() @@ -1695,16 +1362,21 @@ namespace Scripts.Spells.Generic public override void Register() { - AfterHit.Add(new HitHandler(CreditEncounter)); + AfterHit.Add(new(CreditEncounter)); } - bool _handled; + bool _handled = false; } - // 50051 - Ethereal Pet Aura - [Script] - class spell_ethereal_pet_aura : AuraScript + [Script] // 50051 - Ethereal Pet Aura + class spell_ethereal_pet_AuraScript : AuraScript { + const uint NpcEtherealSoulTrader = 27914; + + const uint SayStealEssence = 1; + + const uint SpellStealEssenceVisual = 50101; + bool CheckProc(ProcEventInfo eventInfo) { uint levelDiff = (uint)Math.Abs(GetTarget().GetLevel() - eventInfo.GetProcTarget().GetLevel()); @@ -1716,99 +1388,121 @@ namespace Scripts.Spells.Generic PreventDefaultAction(); List minionList = new(); - GetUnitOwner().GetAllMinionsByEntry(minionList, CreatureIds.EtherealSoulTrader); + GetUnitOwner().GetAllMinionsByEntry(minionList, NpcEtherealSoulTrader); foreach (Creature minion in minionList) { if (minion.IsAIEnabled()) { - minion.GetAI().Talk(TextIds.SayStealEssence); - minion.CastSpell(eventInfo.GetProcTarget(), SpellIds.StealEssenceVisual); + minion.GetAI().Talk(SayStealEssence); + minion.CastSpell(eventInfo.GetProcTarget(), SpellStealEssenceVisual); } } } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); } } - // 50052 - Ethereal Pet onSummon - [Script] + [Script] // 50052 - Ethereal Pet onSummon class spell_ethereal_pet_onsummon : SpellScript { + const uint SpellProcTriggerOnKillAura = 50051; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.ProcTriggerOnKillAura); + return ValidateSpellInfo(SpellProcTriggerOnKillAura); } void HandleScriptEffect(uint effIndex) { Unit target = GetHitUnit(); - target.CastSpell(target, SpellIds.ProcTriggerOnKillAura, true); + target.CastSpell(target, SpellProcTriggerOnKillAura, true); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } - // 50055 - Ethereal Pet Aura Remove - [Script] - class spell_ethereal_pet_aura_remove : SpellScript + [Script] // 50055 - Ethereal Pet Aura Remove + class spell_ethereal_pet_aura_Remove : SpellScript { + const uint SpellEtherealPetAura = 50055; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.EtherealPetAura); + return ValidateSpellInfo(SpellEtherealPetAura); } void HandleScriptEffect(uint effIndex) { - GetHitUnit().RemoveAurasDueToSpell(SpellIds.EtherealPetAura); + GetHitUnit().RemoveAurasDueToSpell(SpellEtherealPetAura); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } - // 50101 - Ethereal Pet OnKill Steal Essence - [Script] + [Script] // 50101 - Ethereal Pet OnKill Steal Essence class spell_steal_essence_visual : AuraScript { + const uint SpellCreateToken = 50063; + const uint SayCreateToken = 2; + void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { Unit caster = GetCaster(); if (caster != null) { - caster.CastSpell(caster, SpellIds.CreateToken, true); + caster.CastSpell(caster, SpellCreateToken, true); Creature soulTrader = caster.ToCreature(); if (soulTrader != null) - soulTrader.GetAI().Talk(TextIds.SayCreateToken); + soulTrader.GetAI().Talk(SayCreateToken); } } public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(HandleRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } - /* 57337 - Great Feast - 57397 - Fish Feast - 58466 - Gigantic Feast - 58475 - Small Feast - 66477 - Bountiful Feast */ - [Script] + struct FeastSpellIds + { + public const uint GreatFeast = 57337; + public const uint FishFeast = 57397; + public const uint GiganticFeast = 58466; + public const uint SmallFeast = 58475; + public const uint BountifulFeast = 66477; + + public const uint FeastFood = 45548; + public const uint FeastDrink = 57073; + public const uint BountifulFeastDrink = 66041; + public const uint BountifulFeastFood = 66478; + + public const uint GreatFeastRefreshment = 57338; + public const uint FishFeastRefreshment = 57398; + public const uint GiganticFeastRefreshment = 58467; + public const uint SmallFeastRefreshment = 58477; + public const uint BountifulFeastRefreshment = 66622; + } + + //57397 - Fish Feast + //58466 - Gigantic Feast + //58475 - Small Feast + [Script] //66477 - Bountiful Feast class spell_gen_feast : SpellScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.FeastFood, SpellIds.FeastDrink, SpellIds.BountifulFeastDrink, SpellIds.BountifulFeastFood, SpellIds.GreatFeastRefreshment, - SpellIds.FishFeastRefreshment, SpellIds.GiganticFeastRefreshment, SpellIds.SmallFeastRefreshment, SpellIds.BountifulFeastRefreshment); + return ValidateSpellInfo(FeastSpellIds.FeastFood, FeastSpellIds.FeastDrink, FeastSpellIds.BountifulFeastDrink, FeastSpellIds.BountifulFeastFood, FeastSpellIds.GreatFeastRefreshment, FeastSpellIds.FishFeastRefreshment, + FeastSpellIds.GiganticFeastRefreshment, FeastSpellIds.SmallFeastRefreshment, FeastSpellIds.BountifulFeastRefreshment); } void HandleScript(uint effIndex) @@ -1817,30 +1511,30 @@ namespace Scripts.Spells.Generic switch (GetSpellInfo().Id) { - case SpellIds.GreatFeast: - target.CastSpell(target, SpellIds.FeastFood); - target.CastSpell(target, SpellIds.FeastDrink); - target.CastSpell(target, SpellIds.GreatFeastRefreshment); + case FeastSpellIds.GreatFeast: + target.CastSpell(target, FeastSpellIds.FeastFood); + target.CastSpell(target, FeastSpellIds.FeastDrink); + target.CastSpell(target, FeastSpellIds.GreatFeastRefreshment); break; - case SpellIds.FishFeast: - target.CastSpell(target, SpellIds.FeastFood); - target.CastSpell(target, SpellIds.FeastDrink); - target.CastSpell(target, SpellIds.FishFeastRefreshment); + case FeastSpellIds.FishFeast: + target.CastSpell(target, FeastSpellIds.FeastFood); + target.CastSpell(target, FeastSpellIds.FeastDrink); + target.CastSpell(target, FeastSpellIds.FishFeastRefreshment); break; - case SpellIds.GiganticFeast: - target.CastSpell(target, SpellIds.FeastFood); - target.CastSpell(target, SpellIds.FeastDrink); - target.CastSpell(target, SpellIds.GiganticFeastRefreshment); + case FeastSpellIds.GiganticFeast: + target.CastSpell(target, FeastSpellIds.FeastFood); + target.CastSpell(target, FeastSpellIds.FeastDrink); + target.CastSpell(target, FeastSpellIds.GiganticFeastRefreshment); break; - case SpellIds.SmallFeast: - target.CastSpell(target, SpellIds.FeastFood); - target.CastSpell(target, SpellIds.FeastDrink); - target.CastSpell(target, SpellIds.SmallFeastRefreshment); + case FeastSpellIds.SmallFeast: + target.CastSpell(target, FeastSpellIds.FeastFood); + target.CastSpell(target, FeastSpellIds.FeastDrink); + target.CastSpell(target, FeastSpellIds.SmallFeastRefreshment); break; - case SpellIds.BountifulFeast: - target.CastSpell(target, SpellIds.BountifulFeastRefreshment); - target.CastSpell(target, SpellIds.BountifulFeastDrink); - target.CastSpell(target, SpellIds.BountifulFeastFood); + case FeastSpellIds.BountifulFeast: + target.CastSpell(target, FeastSpellIds.BountifulFeastRefreshment); + target.CastSpell(target, FeastSpellIds.BountifulFeastDrink); + target.CastSpell(target, FeastSpellIds.BountifulFeastFood); break; default: break; @@ -1849,23 +1543,10 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } - /* - * There are only 3 possible flags Feign Death auras can apply: UNIT_DYNFLAG_DEAD, UnitFlags2.FeignDeath - * and UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT. Some auras can apply only 2 flags - * - * spell_gen_feign_death_all_flags applies all 3 flags - * spell_gen_feign_death_all_flags_uninteractible applies all 3 flags and additionally sets UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_UNINTERACTIBLE - * spell_gen_feign_death_no_dyn_flag applies no UNIT_DYNFLAG_DEAD (does not make the creature appear dead) - * spell_gen_feign_death_no_prevent_emotes applies no UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT - * - * REACT_PASSIVE should be handled directly in scripts since not all creatures should be passive. Otherwise - * creature will be not able to aggro or execute MoveInLineOfSight events. Removing may cause more issues - * than already exists - */ [Script] class spell_gen_feign_death_all_flags : AuraScript { @@ -1895,8 +1576,8 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -1912,7 +1593,9 @@ namespace Scripts.Spells.Generic target.SetImmuneToAll(true); target.SetUninteractible(true); - target.ToCreature()?.SetReactState(ReactStates.Passive); + Creature creature = target.ToCreature(); + if (creature != null) + creature.SetReactState(ReactStates.Passive); } void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) @@ -1924,13 +1607,15 @@ namespace Scripts.Spells.Generic target.SetImmuneToAll(false); target.SetUninteractible(false); - target.ToCreature()?.InitializeReactState(); + Creature creature = target.ToCreature(); + if (creature != null) + creature.InitializeReactState(); } public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -1962,8 +1647,8 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -1994,25 +1679,29 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } [Script] // 35491 - Furious Rage class spell_gen_furious_rage : AuraScript { + const uint EmoteFuriousRage = 19415; + const uint EmoteExhausted = 18368; + const uint SpellExhaustion = 35492; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.Exhaustion) && - CliDB.BroadcastTextStorage.HasRecord(EmoteIds.FuriousRage) && - CliDB.BroadcastTextStorage.HasRecord(EmoteIds.Exhausted); + return ValidateSpellInfo(SpellExhaustion) && + CliDB.BroadcastTextStorage.HasRecord(EmoteFuriousRage) && + CliDB.BroadcastTextStorage.HasRecord(EmoteExhausted); } void AfterApply(AuraEffect aurEff, AuraEffectHandleModes mode) { Unit target = GetTarget(); - target.TextEmote(EmoteIds.FuriousRage, target, false); + target.TextEmote(EmoteFuriousRage, target, false); } void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) @@ -2021,14 +1710,14 @@ namespace Scripts.Spells.Generic return; Unit target = GetTarget(); - target.TextEmote(EmoteIds.Exhausted, target, false); - target.CastSpell(target, SpellIds.Exhaustion, true); + target.TextEmote(EmoteExhausted, target, false); + target.CastSpell(target, SpellExhaustion, true); } public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(AfterApply, 0, AuraType.ModDamagePercentDone, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 0, AuraType.ModDamagePercentDone, AuraEffectHandleModes.Real)); + AfterEffectApply.Add(new(AfterApply, 0, AuraType.ModDamagePercentDone, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(AfterRemove, 0, AuraType.ModDamagePercentDone, AuraEffectHandleModes.Real)); } } @@ -2044,21 +1733,24 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 131474 - Fishing class spell_gen_fishing : SpellScript { + const uint SpellFishingNoFishingPole = 131476; + const uint SpellFishingWithPole = 131490; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.FishingNoFishingPole, SpellIds.FishingWithPole); + return ValidateSpellInfo(SpellFishingNoFishingPole, SpellFishingWithPole); } public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } void HandleDummy(uint effIndex) @@ -2066,26 +1758,30 @@ namespace Scripts.Spells.Generic PreventHitDefaultEffect(effIndex); uint spellId; Item mainHand = GetCaster().ToPlayer().GetItemByPos(InventorySlots.Bag0, EquipmentSlot.MainHand); - if (!mainHand || mainHand.GetTemplate().GetClass() != ItemClass.Weapon || (ItemSubClassWeapon)mainHand.GetTemplate().GetSubClass() != ItemSubClassWeapon.FishingPole) - spellId = SpellIds.FishingNoFishingPole; + if (mainHand == null || mainHand.GetTemplate().GetClass() != ItemClass.Weapon || mainHand.GetTemplate().GetSubClass() != (uint)ItemSubClassWeapon.FishingPole) + spellId = SpellFishingNoFishingPole; else - spellId = SpellIds.FishingWithPole; + spellId = SpellFishingWithPole; GetCaster().CastSpell(GetCaster(), spellId, false); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] class spell_gen_gadgetzan_transporter_backfire : SpellScript { + const uint SpellTransporterMalfunctionPolymorph = 23444; + const uint SpellTransporterEvilTwin = 23445; + const uint SpellTransporterMalfunctionMiss = 36902; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.TransporterMalfunctionPolymorph, SpellIds.TransporterEviltwin, SpellIds.TransporterMalfunctionMiss); + return ValidateSpellInfo(SpellTransporterMalfunctionPolymorph, SpellTransporterEvilTwin, SpellTransporterMalfunctionMiss); } void HandleDummy(uint effIndex) @@ -2093,30 +1789,37 @@ namespace Scripts.Spells.Generic Unit caster = GetCaster(); int r = RandomHelper.IRand(0, 119); if (r < 20) // Transporter Malfunction - 1/6 polymorph - caster.CastSpell(caster, SpellIds.TransporterMalfunctionPolymorph, true); + caster.CastSpell(caster, SpellTransporterMalfunctionPolymorph, true); else if (r < 100) // Evil Twin - 4/6 evil twin - caster.CastSpell(caster, SpellIds.TransporterEviltwin, true); + caster.CastSpell(caster, SpellTransporterEvilTwin, true); else // Transporter Malfunction - 1/6 miss the target - caster.CastSpell(caster, SpellIds.TransporterMalfunctionMiss, true); + caster.CastSpell(caster, SpellTransporterMalfunctionMiss, true); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } - [Script] + // 28880 - Warrior + // 59542 - Paladin + // 59543 - Hunter + // 59544 - Priest + // 59545 - Death Knight + // 59547 - Shaman + // 59548 - Mage + [Script] // 121093 - Monk class spell_gen_gift_of_naaru : AuraScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 1); + return ValidateSpellEffect((spellInfo.Id, 1)); } void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - if (!GetCaster() || aurEff.GetTotalTicks() == 0) + if (GetCaster() == null || aurEff.GetTotalTicks() == 0) return; float healPct = GetEffectInfo(1).CalcValue() / 100.0f; @@ -2127,26 +1830,29 @@ namespace Scripts.Spells.Generic public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.PeriodicHeal)); + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.PeriodicHeal)); } } [Script] class spell_gen_gnomish_transporter : SpellScript { + const uint SpellTransporterSuccess = 23441; + const uint SpellTransporterFailure = 23446; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.TransporterSuccess, SpellIds.TransporterFailure); + return ValidateSpellInfo(SpellTransporterSuccess, SpellTransporterFailure); } void HandleDummy(uint effIndex) { - GetCaster().CastSpell(GetCaster(), RandomHelper.randChance(50) ? SpellIds.TransporterSuccess : SpellIds.TransporterFailure, true); + GetCaster().CastSpell(GetCaster(), RandomHelper.randChance(50) ? SpellTransporterSuccess : SpellTransporterFailure, true); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -2169,19 +1875,17 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); } } - /* 9204 - Hate to Zero(Melee) - * 20538 - Hate to Zero(AoE) - * 26569 - Hate to Zero(AoE) - * 26637 - Hate to Zero(AoE, Unique) - * 37326 - Hate to Zero(AoE) - * 40410 - Hate to Zero(Should be added, AoE) - * 40467 - Hate to Zero(Should be added, AoE) - * 41582 - Hate to Zero(Should be added, Melee) */ - [Script] + //20538 - Hate to Zero(AoE) + //26569 - Hate to Zero(AoE) + //26637 - Hate to Zero(AoE, Unique) + //37326 - Hate to Zero(AoE) + //40410 - Hate to Zero(Should be added, AoE) + //40467 - Hate to Zero(Should be added, AoE) + [Script] //41582 - Hate to Zero(Should be added, Melee) class spell_gen_hate_to_zero : SpellScript { void HandleDummy(uint effIndex) @@ -2192,7 +1896,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -2210,7 +1914,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -2225,7 +1929,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -2240,27 +1944,29 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } - [Script] + // 32748 - Deadly Throw Interrupt + [Script] // 44835 - Maim Interrupt class spell_gen_interrupt : AuraScript { + const uint SpellGenThrowInterrupt = 32747; public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.GenThrowInterrupt); + return ValidateSpellInfo(SpellGenThrowInterrupt); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.GenThrowInterrupt, new CastSpellExtraArgs(aurEff)); + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellGenThrowInterrupt, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -2274,25 +1980,31 @@ namespace Scripts.Spells.Generic void HandleDummy(uint effIndex) { if (GetHitUnit().IsInRaidWith(GetCaster())) - GetCaster().CastSpell(GetCaster(), (uint)GetEffectValue() + 1, true); // raid buff + GetCaster().CastSpell(GetCaster(), (uint)(GetEffectValue() + 1), true); // raid buff else GetCaster().CastSpell(GetHitUnit(), (uint)GetEffectValue(), true); // single-target buff } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } - [Script("spell_hexlord_lifebloom", SpellIds.HexlordMalacrass)] - [Script("spell_tur_ragepaw_lifebloom", SpellIds.TurragePaw)] - [Script("spell_cenarion_scout_lifebloom", SpellIds.CenarionScout)] - [Script("spell_twisted_visage_lifebloom", SpellIds.TwistedVisage)] - [Script("spell_faction_champion_dru_lifebloom", SpellIds.FactionChampionsDru)] + [Script("spell_hexlord_lifebloom", SpellHexlordMalacrassLifebloomFinalHeal)] + [Script("spell_tur_ragepaw_lifebloom", SpellTurRagepawLifebloomFinalHeal)] + [Script("spell_cenarion_scout_lifebloom", SpellCenarionScoutLifebloomFinalHeal)] + [Script("spell_twisted_visage_lifebloom", SpellTwistedVisageLifebloomFinalHeal)] + [Script("spell_faction_champion_dru_lifebloom", SpellFactionChapionsDruLifebloomFinalHeal)] class spell_gen_lifebloom : AuraScript { - readonly uint _spellId; + const uint SpellHexlordMalacrassLifebloomFinalHeal = 43422; + const uint SpellTurRagepawLifebloomFinalHeal = 52552; + const uint SpellCenarionScoutLifebloomFinalHeal = 53692; + const uint SpellTwistedVisageLifebloomFinalHeal = 57763; + const uint SpellFactionChapionsDruLifebloomFinalHeal = 66094; + + uint _spellId; public spell_gen_lifebloom(uint spellId) { @@ -2306,7 +2018,7 @@ namespace Scripts.Spells.Generic void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - // Final heal only on duration end + // final heal only on duration end or dispel if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire && GetTargetApplication().GetRemoveMode() != AuraRemoveMode.EnemySpell) return; @@ -2316,13 +2028,28 @@ namespace Scripts.Spells.Generic public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 0, AuraType.PeriodicHeal, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(AfterRemove, 0, AuraType.PeriodicHeal, AuraEffectHandleModes.Real)); } } [Script] class spell_gen_mounted_charge : SpellScript { + const uint SpellChargeDamage8K5 = 62874; + const uint SpellChargeDamage20K = 68498; + const uint SpellChargeDamage45K = 64591; + + const uint SpellChargeChargingEffect8K5 = 63661; + const uint SpellChargeCharging20K1 = 68284; + const uint SpellChargeCharging20K2 = 68501; + const uint SpellChargeCharging45K1 = 62563; + const uint SpellChargeCharging45K2 = 66481; + + const uint SpellChargeTriggerFactionMounts = 62960; + const uint SpellChargeTriggerTrialChapion = 68282; + + const uint SpellChargeMissEffect = 62977; + public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(62552, 62719, 64100, 66482); @@ -2340,11 +2067,11 @@ namespace Scripts.Spells.Generic switch (GetSpellInfo().Id) { - case SpellIds.TriggerTrialChampion: - spellId = SpellIds.Charging20k1; + case SpellChargeTriggerTrialChapion: + spellId = SpellChargeCharging20K1; break; - case SpellIds.TriggerFactionMounts: - spellId = SpellIds.ChargingEffect8k5; + case SpellChargeTriggerFactionMounts: + spellId = SpellChargeChargingEffect8K5; break; default: return; @@ -2352,10 +2079,10 @@ namespace Scripts.Spells.Generic // If target isn't a training dummy there's a chance of failing the charge if (!target.IsCharmedOwnedByPlayerOrPlayer() && RandomHelper.randChance(12.5f)) - spellId = SpellIds.MissEffect; + spellId = SpellChargeMissEffect; Unit vehicle = GetCaster().GetVehicleBase(); - if (vehicle) + if (vehicle != null) vehicle.CastSpell(target, spellId, false); else GetCaster().CastSpell(target, spellId, false); @@ -2375,7 +2102,7 @@ namespace Scripts.Spells.Generic aura.ModStackAmount(-1, AuraRemoveMode.EnemySpell); // Remove dummys from rider (Necessary for updating visual shields) Unit rider = target.GetCharmer(); - if (rider) + if (rider != null) { Aura defend = rider.GetAura(aura.GetId()); if (defend != null) @@ -2387,6 +2114,8 @@ namespace Scripts.Spells.Generic } break; } + default: + break; } } @@ -2396,22 +2125,23 @@ namespace Scripts.Spells.Generic switch (GetSpellInfo().Id) { - case SpellIds.ChargingEffect8k5: - spellId = SpellIds.Damage8k5; + case SpellChargeChargingEffect8K5: + spellId = SpellChargeDamage8K5; break; - case SpellIds.Charging20k1: - case SpellIds.Charging20k2: - spellId = SpellIds.Damage20k; + case SpellChargeCharging20K1: + case SpellChargeCharging20K2: + spellId = SpellChargeDamage20K; break; - case SpellIds.ChargingEffect45k1: - case SpellIds.ChargingEffect45k2: - spellId = SpellIds.Damage45k; + case SpellChargeCharging45K1: + case SpellChargeCharging45K2: + spellId = SpellChargeDamage45K; break; default: return; } + Unit rider = GetCaster().GetCharmer(); - if (rider) + if (rider != null) rider.CastSpell(GetHitUnit(), spellId, false); else GetCaster().CastSpell(GetHitUnit(), spellId, false); @@ -2419,13 +2149,13 @@ namespace Scripts.Spells.Generic public override void Register() { - SpellInfo spell = Global.SpellMgr.GetSpellInfo(m_scriptSpellId, Difficulty.None); + SpellInfo spell = SpellMgr.GetSpellInfo(m_scriptSpellId, Difficulty.None); if (spell.HasEffect(SpellEffectName.ScriptEffect)) - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, SpellConst.EffectFirstFound, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScriptEffect, SpellConst.EffectFirstFound, SpellEffectName.ScriptEffect)); if (spell.GetEffect(0).IsEffect(SpellEffectName.Charge)) - OnEffectHitTarget.Add(new EffectHandler(HandleChargeEffect, 0, SpellEffectName.Charge)); + OnEffectHitTarget.Add(new(HandleChargeEffect, 0, SpellEffectName.Charge)); } } @@ -2433,30 +2163,34 @@ namespace Scripts.Spells.Generic [Script] // 31399 Moss Covered Feet class spell_gen_moss_covered_feet : AuraScript { + const uint SpellFallDown = 6869; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.FallDown); + return ValidateSpellInfo(SpellFallDown); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - eventInfo.GetActionTarget().CastSpell((Unit)null, SpellIds.FallDown, new CastSpellExtraArgs(aurEff)); + eventInfo.GetActionTarget().CastSpell(null, SpellFallDown, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } [Script] // 28702 - Netherbloom class spell_gen_netherbloom : SpellScript { + const uint SpellNetherbloomPollen1 = 28703; + public override bool Validate(SpellInfo spellInfo) { for (byte i = 0; i < 5; ++i) - if (!ValidateSpellInfo(SpellIds.NetherBloomPollen1 + i)) + if (!ValidateSpellInfo(SpellNetherbloomPollen1 + i)) return false; return true; @@ -2465,8 +2199,9 @@ namespace Scripts.Spells.Generic void HandleScript(uint effIndex) { PreventHitDefaultEffect(effIndex); + Unit target = GetHitUnit(); - if (target) + if (target != null) { // 25% chance of casting a random buff if (RandomHelper.randChance(75)) @@ -2478,42 +2213,45 @@ namespace Scripts.Spells.Generic // don't overwrite an existing aura for (byte i = 0; i < 5; ++i) - if (target.HasAura(SpellIds.NetherBloomPollen1 + i)) + if (target.HasAura(SpellNetherbloomPollen1 + i)) return; - target.CastSpell(target, SpellIds.NetherBloomPollen1 + RandomHelper.URand(0, 4), true); + target.CastSpell(target, SpellNetherbloomPollen1 + RandomHelper.URand(0, 4), true); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 28720 - Nightmare Vine class spell_gen_nightmare_vine : SpellScript { + const uint SpellNightmarePollen = 28721; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.NightmarePollen); + return ValidateSpellInfo(SpellNightmarePollen); } void HandleScript(uint effIndex) { PreventHitDefaultEffect(effIndex); + Unit target = GetHitUnit(); - if (target) + if (target != null) { // 25% chance of casting Nightmare Pollen if (RandomHelper.randChance(25)) - target.CastSpell(target, SpellIds.NightmarePollen, true); + target.CastSpell(target, SpellNightmarePollen, true); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -2532,16 +2270,23 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(PeriodicTick, 1, AuraType.PeriodicTriggerSpell)); + OnEffectPeriodic.Add(new(PeriodicTick, 1, AuraType.PeriodicTriggerSpell)); } } [Script] // 27539 - Obsidian Armor class spell_gen_obsidian_armor : AuraScript { + const uint SpellGenObsidianArmorHoly = 27536; + const uint SpellGenObsidianArmorFire = 27533; + const uint SpellGenObsidianArmorNature = 27538; + const uint SpellGenObsidianArmorFrost = 27534; + const uint SpellGenObsidianArmorShadow = 27535; + const uint SpellGenObsidianArmorArcane = 27540; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.Holy, SpellIds.Fire, SpellIds.Nature, SpellIds.Frost, SpellIds.Shadow, SpellIds.Arcane); + return ValidateSpellInfo(SpellGenObsidianArmorHoly, SpellGenObsidianArmorFire, SpellGenObsidianArmorNature, SpellGenObsidianArmorFrost, SpellGenObsidianArmorShadow, SpellGenObsidianArmorArcane); } bool CheckProc(ProcEventInfo eventInfo) @@ -2563,33 +2308,33 @@ namespace Scripts.Spells.Generic switch (SharedConst.GetFirstSchoolInMask(eventInfo.GetSchoolMask())) { case SpellSchools.Holy: - spellId = SpellIds.Holy; + spellId = SpellGenObsidianArmorHoly; break; case SpellSchools.Fire: - spellId = SpellIds.Fire; + spellId = SpellGenObsidianArmorFire; break; case SpellSchools.Nature: - spellId = SpellIds.Nature; + spellId = SpellGenObsidianArmorNature; break; case SpellSchools.Frost: - spellId = SpellIds.Frost; + spellId = SpellGenObsidianArmorFrost; break; case SpellSchools.Shadow: - spellId = SpellIds.Shadow; + spellId = SpellGenObsidianArmorShadow; break; case SpellSchools.Arcane: - spellId = SpellIds.Arcane; + spellId = SpellGenObsidianArmorArcane; break; default: return; } - GetTarget().CastSpell(GetTarget(), spellId, new CastSpellExtraArgs(aurEff)); + GetTarget().CastSpell(GetTarget(), spellId, aurEff); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(OnProcEffect, 0, AuraType.Dummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(OnProcEffect, 0, AuraType.Dummy)); } } @@ -2598,12 +2343,12 @@ namespace Scripts.Spells.Generic { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 1); + return ValidateSpellEffect((spellInfo.Id, 1)); } public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } void HandleDummy(uint effIndex) @@ -2612,59 +2357,63 @@ namespace Scripts.Spells.Generic uint factionId = (uint)GetEffectInfo().CalcValue(); int repChange = GetEffectInfo(1).CalcValue(); - FactionRecord factionEntry = CliDB.FactionStorage.LookupByKey(factionId); - + var factionEntry = CliDB.FactionStorage.LookupByKey(factionId); if (factionEntry == null) return; // Set rep to baserep + basepoints (expecting spillover for oposite faction . become hated) // Not when player already has equal or higher rep with this faction - if (player.GetReputationMgr().GetBaseReputation(factionEntry) < repChange) + if (player.GetReputationMgr().GetReputation(factionEntry) < repChange) player.GetReputationMgr().SetReputation(factionEntry, repChange); - // EFFECT_INDEX_2 most likely update at war state, we already handle this in SetReputation + // EffectIndex2 most likely update at war state, we already handle this in SetReputation } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] class spell_gen_orc_disguise : SpellScript { + const uint SpellOrcDisguiseTrigger = 45759; + const uint SpellOrcDisguiseMale = 45760; + const uint SpellOrcDisguiseFemale = 45762; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.OrcDisguiseTrigger, SpellIds.OrcDisguiseMale, SpellIds.OrcDisguiseFemale); + return ValidateSpellInfo(SpellOrcDisguiseTrigger, SpellOrcDisguiseMale, SpellOrcDisguiseFemale); } void HandleScript(uint effIndex) { Unit caster = GetCaster(); Player target = GetHitPlayer(); - if (target) + if (target != null) { - Gender gender = target.GetNativeGender(); - if (gender == Gender.Male) - caster.CastSpell(target, SpellIds.OrcDisguiseMale, true); + if (target.GetNativeGender() == 0) + caster.CastSpell(target, SpellOrcDisguiseMale, true); else - caster.CastSpell(target, SpellIds.OrcDisguiseFemale, true); + caster.CastSpell(target, SpellOrcDisguiseFemale, true); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 35201 - Paralytic Poison class spell_gen_paralytic_poison : AuraScript { + const uint SpellParalysis = 35202; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.Paralysis); + return ValidateSpellInfo(SpellParalysis); } void HandleStun(AuraEffect aurEff, AuraEffectHandleModes mode) @@ -2672,12 +2421,12 @@ namespace Scripts.Spells.Generic if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire) return; - GetTarget().CastSpell((Unit)null, SpellIds.Paralysis, new CastSpellExtraArgs(aurEff)); + GetTarget().CastSpell(null, SpellParalysis, aurEff); } public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(HandleStun, 0, AuraType.PeriodicDamage, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(HandleStun, 0, AuraType.PeriodicDamage, AuraEffectHandleModes.Real)); } } @@ -2698,8 +2447,8 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(HandleEffectApply, SpellConst.EffectFirstFound, AuraType.Any, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, SpellConst.EffectFirstFound, AuraType.Any, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(HandleEffectApply, SpellConst.EffectFirstFound, AuraType.Any, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(OnRemove, SpellConst.EffectFirstFound, AuraType.Any, AuraEffectHandleModes.Real)); } } @@ -2713,7 +2462,7 @@ namespace Scripts.Spells.Generic void HandleScript(uint effIndex) { - // Note: target here is always player; caster here is gameobject, creature or player (self cast) + // Note: target here is always player; caster here is gameobj, creature or player (self cast) Unit target = GetHitUnit(); if (target != null) target.Say((uint)GetEffectValue(), target); @@ -2721,7 +2470,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -2749,7 +2498,7 @@ namespace Scripts.Spells.Generic public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); + DoCheckProc.Add(new(CheckProc)); } } @@ -2763,43 +2512,48 @@ namespace Scripts.Spells.Generic public override void Register() { - OnProc.Add(new AuraProcHandler(HandleChargeDrop)); + OnProc.Add(new(HandleChargeDrop)); } } [Script] // 45472 Parachute class spell_gen_parachute : AuraScript { + const uint SpellParachute = 45472; + const uint SpellParachuteBuff = 44795; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.Parachute, SpellIds.ParachuteBuff); + return ValidateSpellInfo(SpellParachute, SpellParachuteBuff); } void HandleEffectPeriodic(AuraEffect aurEff) { Player target = GetTarget().ToPlayer(); - if (target) - { + if (target != null) if (target.IsFalling()) { - target.RemoveAurasDueToSpell(SpellIds.Parachute); - target.CastSpell(target, SpellIds.ParachuteBuff, true); + target.RemoveAurasDueToSpell(SpellParachute); + target.CastSpell(target, SpellParachuteBuff, true); } - } } public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); } } [Script] class spell_gen_pet_summoned : SpellScript { + const uint NpcDoomguard = 11859; + const uint NpcInfernal = 89; + const uint NpcImp = 416; + public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } void HandleScript(uint effIndex) @@ -2808,7 +2562,7 @@ namespace Scripts.Spells.Generic if (player.GetLastPetNumber() != 0) { PetType newPetType = (player.GetClass() == Class.Hunter) ? PetType.Hunter : PetType.Summon; - Pet newPet = new(player, newPetType); + Pet newPet = new Pet(player, newPetType); if (newPet.LoadPetFromDB(player, 0, player.GetLastPetNumber(), true)) { // revive the pet if it is dead @@ -2820,20 +2574,22 @@ namespace Scripts.Spells.Generic switch (newPet.GetEntry()) { - case CreatureIds.Doomguard: - case CreatureIds.Infernal: - newPet.SetEntry(CreatureIds.Imp); + case NpcDoomguard: + case NpcInfernal: + newPet.SetEntry(NpcImp); break; default: break; } } + else + newPet.Dispose(); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -2848,16 +2604,18 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHit.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] class spell_gen_profession_research : SpellScript { + const uint SpellNorthrendInscriptionResearch = 61177; + public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } SpellCastResult CheckRequirement() @@ -2880,31 +2638,34 @@ namespace Scripts.Spells.Generic // Learn random explicit discovery recipe (if any) // Players will now learn 3 recipes the very first time they perform Northrend Inscription Research (3.3.0 patch notes) - if (spellId == SpellIds.NorthrendInscriptionResearch && !SkillDiscovery.HasDiscoveredAnySpell(spellId, caster)) + if (spellId == SpellNorthrendInscriptionResearch && !SkillDiscovery.HasDiscoveredAnySpell(spellId, caster)) { for (int i = 0; i < 2; ++i) { - uint _discoveredSpellId = SkillDiscovery.GetExplicitDiscoverySpell(spellId, caster); - if (_discoveredSpellId != 0) - caster.LearnSpell(_discoveredSpellId, false); + uint discoveredSpellId = SkillDiscovery.GetExplicitDiscoverySpell(spellId, caster); + if (discoveredSpellId != 0) + caster.LearnSpell(discoveredSpellId, false); } } - uint discoveredSpellId = SkillDiscovery.GetExplicitDiscoverySpell(spellId, caster); - if (discoveredSpellId != 0) - caster.LearnSpell(discoveredSpellId, false); + uint discoveredSpellId1 = SkillDiscovery.GetExplicitDiscoverySpell(spellId, caster); + if (discoveredSpellId1 != 0) + caster.LearnSpell(discoveredSpellId1, false); } public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.ScriptEffect)); + OnCheckCast.Add(new(CheckRequirement)); + OnEffectHitTarget.Add(new(HandleScript, 1, SpellEffectName.ScriptEffect)); } } [Script] class spell_gen_pvp_trinket : SpellScript { + const uint SpellPvpTrinketAlliance = 97403; + const uint SpellPvpTrinketHorde = 97404; + void TriggerAnimation() { Player caster = GetCaster().ToPlayer(); @@ -2912,27 +2673,29 @@ namespace Scripts.Spells.Generic switch (caster.GetEffectiveTeam()) { case Team.Alliance: - caster.CastSpell(caster, SpellIds.PvpTrinketAlliance, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + caster.CastSpell(caster, SpellPvpTrinketAlliance, TriggerCastFlags.FullMask); break; case Team.Horde: - caster.CastSpell(caster, SpellIds.PvpTrinketHorde, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + caster.CastSpell(caster, SpellPvpTrinketHorde, TriggerCastFlags.FullMask); + break; + default: break; } } public override void Register() { - AfterCast.Add(new CastHandler(TriggerAnimation)); + AfterCast.Add(new(TriggerAnimation)); } } [Script] - class spell_gen_remove_flight_auras : SpellScript + class spell_gen_Remove_flight_auras : SpellScript { void HandleScript(uint effIndex) { Unit target = GetHitUnit(); - if (target) + if (target != null) { target.RemoveAurasByType(AuraType.Fly); target.RemoveAurasByType(AuraType.ModIncreaseMountedFlightSpeed); @@ -2941,12 +2704,12 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 1, SpellEffectName.ScriptEffect)); } } - [Script] - class spell_gen_remove_impairing_auras : SpellScript + [Script] // 20589 - Escape artist + class spell_gen_Remove_impairing_auras : SpellScript { void HandleScriptEffect(uint effIndex) { @@ -2955,7 +2718,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } @@ -2986,7 +2749,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(PeriodicTick, 0, AuraType.PeriodicTriggerSpell)); + OnEffectPeriodic.Add(new(PeriodicTick, 0, AuraType.PeriodicTriggerSpell)); } } @@ -2994,11 +2757,11 @@ namespace Scripts.Spells.Generic // 43937 Grievous Wound // 62331 Impale [Script] // 62418 Impale - class spell_gen_remove_on_health_pct : AuraScript + class spell_gen_Remove_on_health_pct : AuraScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 1); + return ValidateSpellEffect((spellInfo.Id, 1)); } void PeriodicTick(AuraEffect aurEff) @@ -3014,7 +2777,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(PeriodicTick, 0, AuraType.PeriodicDamage)); + OnEffectPeriodic.Add(new(PeriodicTick, 0, AuraType.PeriodicDamage)); } } @@ -3023,7 +2786,7 @@ namespace Scripts.Spells.Generic // 43093 Grievous Throw // 58517 Grievous Wound [Script] // 59262 Grievous Wound - class spell_gen_remove_on_full_health : AuraScript + class spell_gen_Remove_on_full_health : AuraScript { void PeriodicTick(AuraEffect aurEff) { @@ -3041,13 +2804,13 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(PeriodicTick, 0, AuraType.PeriodicDamage)); + OnEffectPeriodic.Add(new(PeriodicTick, 0, AuraType.PeriodicDamage)); } } // 70292 - Glacial Strike [Script] // 71316 - Glacial Strike - class spell_gen_remove_on_full_health_pct : AuraScript + class spell_gen_Remove_on_full_health_pct : AuraScript { void PeriodicTick(AuraEffect aurEff) { @@ -3062,7 +2825,19 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(PeriodicTick, 2, AuraType.PeriodicDamagePercent)); + OnEffectPeriodic.Add(new(PeriodicTick, 2, AuraType.PeriodicDamagePercent)); + } + } + + class ReplenishmentCheck : ICheck + { + public bool Invoke(WorldObject obj) + { + Unit target = obj.ToUnit(); + if (target != null) + return target.GetPowerType() != PowerType.Mana; + + return true; } } @@ -3073,7 +2848,7 @@ namespace Scripts.Spells.Generic { // In arenas Replenishment may only affect the caster Player caster = GetCaster().ToPlayer(); - if (caster) + if (caster != null) { if (caster.InArena()) { @@ -3083,14 +2858,7 @@ namespace Scripts.Spells.Generic } } - targets.RemoveAll(obj => - { - var target = obj.ToUnit(); - if (target) - return target.GetPowerType() != PowerType.Mana; - - return true; - }); + targets.RemoveAll(new ReplenishmentCheck()); byte maxTargets = 10; @@ -3103,26 +2871,29 @@ namespace Scripts.Spells.Generic public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(RemoveInvalidTargets, 255, Targets.UnitCasterAreaRaid)); + OnObjectAreaTargetSelect.Add(new(RemoveInvalidTargets, SpellConst.EffectAll, Targets.UnitCasterAreaRaid)); } } [Script] class spell_gen_replenishment_AuraScript : AuraScript { + const uint SpellReplenishment = 57669; + const uint SpellInfiniteReplenishment = 61782; + public override bool Load() { - return GetUnitOwner().GetPower(PowerType.Mana) != 0; + return GetUnitOwner().GetPowerType() == PowerType.Mana; } void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { switch (GetSpellInfo().Id) { - case SpellIds.Replenishment: + case SpellReplenishment: amount = (int)(GetUnitOwner().GetMaxPower(PowerType.Mana) * 0.002f); break; - case SpellIds.InfiniteReplenishment: + case SpellInfiniteReplenishment: amount = (int)(GetUnitOwner().GetMaxPower(PowerType.Mana) * 0.0025f); break; default: @@ -3132,23 +2903,28 @@ namespace Scripts.Spells.Generic public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.PeriodicEnergize)); + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.PeriodicEnergize)); } } + struct RunningWildMountIds + { + public const uint AlteredForm = 97709; + } + [Script] class spell_gen_running_wild : SpellScript { - public override bool Validate(SpellInfo spellInfo) + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.AlteredForm); + return ValidateSpellInfo(RunningWildMountIds.AlteredForm); } public override bool Load() { // Definitely not a good thing, but currently the only way to do something at cast start // Should be replaced as soon as possible with a new hook: BeforeCastStart - GetCaster().CastSpell(GetCaster(), SpellIds.AlteredForm, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + GetCaster().CastSpell(GetCaster(), RunningWildMountIds.AlteredForm, TriggerCastFlags.FullMask); return false; } @@ -3160,7 +2936,7 @@ namespace Scripts.Spells.Generic [Script] class spell_gen_running_wild_AuraScript : AuraScript { - public override bool Validate(SpellInfo spellInfo) + public override bool Validate(SpellInfo spell) { if (!CliDB.CreatureDisplayInfoStorage.ContainsKey(SharedConst.DisplayIdHiddenMount)) return false; @@ -3175,14 +2951,14 @@ namespace Scripts.Spells.Generic target.Mount(SharedConst.DisplayIdHiddenMount, 0, 0); // cast speed aura - MountCapabilityRecord mountCapability = CliDB.MountCapabilityStorage.LookupByKey(aurEff.GetAmount()); + var mountCapability = CliDB.MountCapabilityStorage.LookupByKey(aurEff.GetAmount()); if (mountCapability != null) - target.CastSpell(target, mountCapability.ModSpellAuraID, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + target.CastSpell(target, mountCapability.ModSpellAuraID, TriggerCastFlags.FullMask); } public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(HandleMount, 1, AuraType.Mounted, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(HandleMount, 1, AuraType.Mounted, AuraEffectHandleModes.Real)); } } @@ -3198,7 +2974,8 @@ namespace Scripts.Spells.Generic } // Player cannot transform to human form if he is forced to be worgen for some reason (Darkflight) - if (GetCaster().GetAuraEffectsByType(AuraType.WorgenAlteredForm).Count > 1) + var alteredFormAuras = GetCaster().GetAuraEffectsByType(AuraType.WorgenAlteredForm); + if (alteredFormAuras.Count > 1) { SetCustomCastResultMessage(SpellCustomErrors.CantTransform); return SpellCastResult.CustomError; @@ -3214,13 +2991,13 @@ namespace Scripts.Spells.Generic if (target.HasAuraType(AuraType.WorgenAlteredForm)) target.RemoveAurasByType(AuraType.WorgenAlteredForm); else // Basepoints 1 for this aura control whether to trigger transform transition animation or not. - target.CastSpell(target, SpellIds.AlteredForm, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, 1)); + target.CastSpell(target, RunningWildMountIds.AlteredForm, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, 1)); } public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnEffectHitTarget.Add(new EffectHandler(HandleTransform, 0, SpellEffectName.Dummy)); + OnCheckCast.Add(new(CheckCast)); + OnEffectHitTarget.Add(new(HandleTransform, 0, SpellEffectName.Dummy)); } } @@ -3229,61 +3006,62 @@ namespace Scripts.Spells.Generic { void TriggerTransform() { - GetCaster().CastSpell(GetCaster(), SpellIds.AlteredForm, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + GetCaster().CastSpell(GetCaster(), RunningWildMountIds.AlteredForm, TriggerCastFlags.FullMask); } public override void Register() { - AfterCast.Add(new CastHandler(TriggerTransform)); + AfterCast.Add(new(TriggerTransform)); } } [Script] class spell_gen_seaforium_blast : SpellScript { + const uint SpellPlantChargesCreditAchievement = 60937; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.PlantChargesCreditAchievement); + return ValidateSpellInfo(SpellPlantChargesCreditAchievement); } public override bool Load() { - // OriginalCaster is always available in Spell.prepare return GetGObjCaster().GetOwnerGUID().IsPlayer(); } void AchievementCredit(uint effIndex) { - // but in effect handling OriginalCaster can become null Unit owner = GetGObjCaster().GetOwner(); if (owner != null) { GameObject go = GetHitGObj(); - if (go) + if (go != null) if (go.GetGoInfo().type == GameObjectTypes.DestructibleBuilding) - owner.CastSpell(null, SpellIds.PlantChargesCreditAchievement, true); + owner.CastSpell(null, SpellPlantChargesCreditAchievement, true); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(AchievementCredit, 1, SpellEffectName.GameObjectDamage)); + OnEffectHitTarget.Add(new(AchievementCredit, 1, SpellEffectName.GameObjectDamage)); } } [Script] class spell_gen_spectator_cheer_trigger : SpellScript { - readonly static Emote[] EmoteArray = { Emote.OneshotCheer, Emote.OneshotExclamation, Emote.OneshotApplaud }; + Emote[] EmoteArray = { Emote.OneshotCheer, Emote.OneshotExclamation, Emote.OneshotApplaud }; void HandleDummy(uint effIndex) { - GetCaster().HandleEmoteCommand(EmoteArray.SelectRandom()); + if (RandomHelper.randChance(40)) + GetCaster().HandleEmoteCommand(EmoteArray.SelectRandom()); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -3292,14 +3070,14 @@ namespace Scripts.Spells.Generic { public override bool Load() { - return GetOriginalCaster() && GetOriginalCaster().IsTypeId(TypeId.Player); + return GetOriginalCaster() != null && GetOriginalCaster().IsPlayer(); } void HandleDummy(uint effIndex) { Player originalCaster = GetOriginalCaster().ToPlayer(); Unit target = GetHitUnit(); - if (target) + if (target != null) { NPCInteractionOpenResult spiritHealerConfirm = new(); spiritHealerConfirm.Npc = target.GetGUID(); @@ -3311,16 +3089,18 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] class spell_gen_summon_tournament_mount : SpellScript { + const uint SpellLanceEquipped = 62853; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.LanceEquipped); + return ValidateSpellInfo(SpellLanceEquipped); } SpellCastResult CheckIfLanceEquiped() @@ -3328,7 +3108,7 @@ namespace Scripts.Spells.Generic if (GetCaster().IsInDisallowedMountForm()) GetCaster().RemoveAurasByType(AuraType.ModShapeshift); - if (!GetCaster().HasAura(SpellIds.LanceEquipped)) + if (!GetCaster().HasAura(SpellLanceEquipped)) { SetCustomCastResultMessage(SpellCustomErrors.MustHaveLanceEquipped); return SpellCastResult.CustomError; @@ -3339,7 +3119,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckIfLanceEquiped)); + OnCheckCast.Add(new(CheckIfLanceEquiped)); } } @@ -3354,43 +3134,47 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); } } [Script] class spell_gen_tournament_duel : SpellScript { + const uint SpellOnTournamentMount = 63034; + const uint SpellMountedDuel = 62875; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.OnTournamentMount, SpellIds.MountedDuel); + return ValidateSpellInfo(SpellOnTournamentMount, SpellMountedDuel); } void HandleScriptEffect(uint effIndex) { Unit rider = GetCaster().GetCharmer(); - if (rider) + if (rider != null) { Player playerTarget = GetHitPlayer(); - if (playerTarget) + if (playerTarget != null) { - if (playerTarget.HasAura(SpellIds.OnTournamentMount) && playerTarget.GetVehicleBase()) - rider.CastSpell(playerTarget, SpellIds.MountedDuel, true); - return; + if (playerTarget.HasAura(SpellOnTournamentMount) && playerTarget.GetVehicleBase() != null) + rider.CastSpell(playerTarget, SpellMountedDuel, true); } - - Unit unitTarget = GetHitUnit(); - if (unitTarget) + else { - if (unitTarget.GetCharmer() && unitTarget.GetCharmer().IsTypeId(TypeId.Player) && unitTarget.GetCharmer().HasAura(SpellIds.OnTournamentMount)) - rider.CastSpell(unitTarget.GetCharmer(), SpellIds.MountedDuel, true); + Unit unitTarget = GetHitUnit(); + if (unitTarget != null) + { + if (unitTarget.GetCharmer() != null && unitTarget.GetCharmer().IsPlayer() && unitTarget.GetCharmer().HasAura(SpellOnTournamentMount)) + rider.CastSpell(unitTarget.GetCharmer(), SpellMountedDuel, true); + } } } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } @@ -3399,26 +3183,31 @@ namespace Scripts.Spells.Generic { public override bool Load() { - return GetCaster() && GetCaster().IsTypeId(TypeId.Player); + return GetCaster() != null && GetCaster().IsPlayer(); } void HandleApplyEffect(AuraEffect aurEff, AuraEffectHandleModes mode) { Unit caster = GetCaster(); - if (caster) - if (!caster.GetVehicleBase()) + if (caster != null) + if (caster.GetVehicleBase() == null) caster.RemoveAurasDueToSpell(GetId()); } public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(HandleApplyEffect, 0, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); + OnEffectApply.Add(new(HandleApplyEffect, 0, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); } } [Script] class spell_gen_teleporting : SpellScript { + const uint AreaVioletCitadelSpire = 4637; + + const uint SpellTeleportSpireDown = 59316; + const uint SpellTeleportSpireUp = 59314; + void HandleScript(uint effIndex) { Unit target = GetHitUnit(); @@ -3426,16 +3215,16 @@ namespace Scripts.Spells.Generic return; // return from top - if (target.ToPlayer().GetAreaId() == Misc.AreaVioletCitadelSpire) - target.CastSpell(target, SpellIds.TeleportSpireDown, true); + if (target.ToPlayer().GetAreaId() == AreaVioletCitadelSpire) + target.CastSpell(target, SpellTeleportSpireDown, true); // teleport atop else - target.CastSpell(target, SpellIds.TeleportSpireUp, true); + target.CastSpell(target, SpellTeleportSpireUp, true); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -3455,7 +3244,7 @@ namespace Scripts.Spells.Generic public override void Register() { - AfterCast.Add(new CastHandler(HandleTrigger)); + AfterCast.Add(new(HandleTrigger)); } } @@ -3470,68 +3259,54 @@ namespace Scripts.Spells.Generic void HandleTrigger() { Unit target = GetHitUnit(); - if (target) + if (target != null) // Blizz seems to just apply aura without bothering to cast GetCaster().AddAura(GetSpellInfo().ExcludeTargetAuraSpell, target); } public override void Register() { - AfterHit.Add(new HitHandler(HandleTrigger)); + AfterHit.Add(new(HandleTrigger)); } } - [Script("spell_pvp_trinket_shared_cd", SpellIds.WillOfTheForsakenCooldownTrigger)] - [Script("spell_wotf_shared_cd", SpellIds.WillOfTheForsakenCooldownTriggerWotf)] + [Script("spell_pvp_trinket_shared_cd", SpellWillOfTheForsakenCooldownTrigger)] + [Script("spell_wotf_shared_cd", SpellWillOfTheForsakenCooldownTriggerWotf)] class spell_pvp_trinket_wotf_shared_cd : SpellScript { - readonly uint _triggered; + const uint SpellWillOfTheForsakenCooldownTrigger = 72752; + const uint SpellWillOfTheForsakenCooldownTriggerWotf = 72757; - public spell_pvp_trinket_wotf_shared_cd(uint triggered) + uint _triggeredSpellId; + + public spell_pvp_trinket_wotf_shared_cd(uint triggeredSpellId) { - _triggered = triggered; + _triggeredSpellId = triggeredSpellId; } public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(_triggered); + return ValidateSpellInfo(_triggeredSpellId); } void HandleScript() { - /* - * @workaround: PendingCast flag normally means 'triggered' spell, however - * if the spell is cast triggered, the core won't send SMSG_SPELL_GO packet - * so client never registers the cooldown (see Spell::IsNeedSendToClient) - * - * ServerToClient: SMSG_SPELL_GO (0x0132) Length: 42 ConnIdx: 0 Time: 07/19/2010 02:32:35.000 Number: 362675 - * Caster GUID: Full: Player - * Caster Unit GUID: Full: Player - * Cast Count: 0 - * Spell ID: 72752 (72752) - * Cast Flags: PendingCast, Unknown3, Unknown7 (265) - * Time: 3901468825 - * Hit Count: 1 - * [0] Hit GUID: Player - * Miss Count: 0 - * Target Flags: Unit (2) - * Target GUID: 0x0 - */ - // Spell flags need further research, until then just cast not triggered - GetCaster().CastSpell((Unit)null, _triggered, false); + GetCaster().CastSpell(null, _triggeredSpellId, false); } public override void Register() { - AfterCast.Add(new CastHandler(HandleScript)); + AfterCast.Add(new(HandleScript)); } } [Script] class spell_gen_turkey_marker : AuraScript { - readonly List _applyTimes = new(); + const uint SpellTurkeyVengeance = 25285; + + List _applyTimes = new(); void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) { @@ -3541,42 +3316,43 @@ namespace Scripts.Spells.Generic // on stack 15 cast the achievement crediting spell if (GetStackAmount() >= 15) - target.CastSpell(target, SpellIds.TurkeyVengeance, new CastSpellExtraArgs(aurEff).SetOriginalCaster(GetCasterGUID())); + target.CastSpell(target, SpellTurkeyVengeance, new CastSpellExtraArgs(aurEff) + .SetOriginalCaster(GetCasterGUID())); } void OnPeriodic(AuraEffect aurEff) { - int removeCount = 0; + int RemoveCount = 0; // pop expired times off of the stack - while (!_applyTimes.Empty() && _applyTimes.FirstOrDefault() + GetMaxDuration() < GameTime.GetGameTimeMS()) + while (!_applyTimes.Empty() && _applyTimes.First() + GetMaxDuration() < GameTime.GetGameTimeMS()) { _applyTimes.RemoveAt(0); - removeCount++; + RemoveCount++; } - if (removeCount != 0) - ModStackAmount(-removeCount, AuraRemoveMode.Expire); + if (RemoveCount != 0) + ModStackAmount(-RemoveCount, AuraRemoveMode.Expire); } public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); - OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 0, AuraType.PeriodicDummy)); + AfterEffectApply.Add(new(OnApply, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); + OnEffectPeriodic.Add(new(OnPeriodic, 0, AuraType.PeriodicDummy)); } } [Script] class spell_gen_upper_deck_create_foam_sword : SpellScript { - // green pink blue red yellow - readonly static uint[] itemId = { 45061, 45176, 45177, 45178, 45179 }; + uint[] itemId = { 45061, 45176, 45177, 45178, 45179 }; void HandleScript(uint effIndex) { Player player = GetHitPlayer(); - if (player) + if (player != null) { + // player can only have one of these items for (byte i = 0; i < 5; ++i) { @@ -3584,23 +3360,25 @@ namespace Scripts.Spells.Generic return; } - CreateItem(itemId[RandomHelper.URand(0, 4)], ItemContext.None); + CreateItem(itemId[RandomHelper.IRand(0, 4)], ItemContext.None); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } - // 52723 - Vampiric Touch - [Script] // 60501 - Vampiric Touch - class spell_gen_vampiric_touch : AuraScript + // 52723 - VaMathF.PIric Touch + [Script] // 60501 - VaMathF.PIric Touch + class spell_gen_vapiric_touch : AuraScript { + const uint SpellVapiricTouchHeal = 52724; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.VampiricTouchHeal); + return ValidateSpellInfo(SpellVapiricTouchHeal); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -3612,22 +3390,24 @@ namespace Scripts.Spells.Generic Unit caster = eventInfo.GetActor(); CastSpellExtraArgs args = new(aurEff); - args.AddSpellMod(SpellValueMod.BasePoint0, (int)damageInfo.GetDamage() / 2); - caster.CastSpell(caster, SpellIds.VampiricTouchHeal, args); + args.AddSpellMod(SpellValueMod.BasePoint0, (int)(damageInfo.GetDamage() / 2)); + caster.CastSpell(caster, SpellVapiricTouchHeal, args); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } [Script] class spell_gen_vehicle_scaling : AuraScript { + const uint SpellGearScaling = 66668; + public override bool Load() { - return GetCaster() && GetCaster().IsTypeId(TypeId.Player); + return GetCaster() != null && GetCaster().IsPlayer(); } void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) @@ -3636,10 +3416,10 @@ namespace Scripts.Spells.Generic float factor; ushort baseItemLevel; - // @todo Reserach coeffs for different vehicles + /// @todo Reserach coeffs for different vehicles switch (GetId()) { - case SpellIds.GearScaling: + case SpellGearScaling: factor = 1.0f; baseItemLevel = 205; break; @@ -3651,33 +3431,35 @@ namespace Scripts.Spells.Generic float avgILvl = caster.ToPlayer().GetAverageItemLevel(); if (avgILvl < baseItemLevel) - return; // @todo Research possibility of scaling down + return; /// @todo Research possibility of scaling down - amount = (int)((avgILvl - baseItemLevel) * factor); + amount = (ushort)((avgILvl - baseItemLevel) * factor); } public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModHealingPct)); - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 1, AuraType.ModDamagePercentDone)); - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 2, AuraType.ModIncreaseHealthPercent)); + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.ModHealingPct)); + DoEffectCalcAmount.Add(new(CalculateAmount, 1, AuraType.ModDamagePercentDone)); + DoEffectCalcAmount.Add(new(CalculateAmount, 2, AuraType.ModIncreaseHealthPercent)); } } [Script] class spell_gen_vendor_bark_trigger : SpellScript { + const uint NpcAmphitheaterVendor = 30098; + const uint SayAmphitheaterVendor = 0; void HandleDummy(uint effIndex) { Creature vendor = GetCaster().ToCreature(); - if (vendor) - if (vendor.GetEntry() == CreatureIds.AmphitheaterVendor) - vendor.GetAI().Talk(TextIds.SayAmphitheaterVendor); + if (vendor != null) + if (vendor.GetEntry() == NpcAmphitheaterVendor) + vendor.GetAI().Talk(SayAmphitheaterVendor); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -3693,27 +3475,29 @@ namespace Scripts.Spells.Generic public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); + OnCheckCast.Add(new(CheckCast)); } } [Script] class spell_gen_whisper_gulch_yogg_saron_whisper : AuraScript { + const uint SpellYoggSaronWhisperDummy = 29072; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.YoggSaronWhisperDummy); + return ValidateSpellInfo(SpellYoggSaronWhisperDummy); } void HandleEffectPeriodic(AuraEffect aurEff) { PreventDefaultAction(); - GetTarget().CastSpell((Unit)null, SpellIds.YoggSaronWhisperDummy, true); + GetTarget().CastSpell(null, SpellYoggSaronWhisperDummy, true); } public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); } } @@ -3738,19 +3522,23 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHit.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } - // BasePoints of spells is ID of npc_text used to group texts, it's not implemented so texts are grouped the old way + // BasePoints of spells is Id of npc_text used to group texts, it's not implemented so texts are grouped the old way // 50037 - Mystery of the Infinite: Future You's Whisper to Controller - Random // 50287 - Azure Dragon: On Death Force Cast Wyrmrest Defender to Whisper to Controller - Random - // 60709 - MOTI, Redux: Past You's Whisper to Controller - Random - [Script("spell_future_you_whisper_to_controller_random", 2u)] - [Script("spell_wyrmrest_defender_whisper_to_controller_random", 1u)] - [Script("spell_past_you_whisper_to_controller_random", 2u)] + // 60709 - Moti, Redux: Past You's Whisper to Controller - Random + [Script("spell_future_you_whisper_to_controller_random", WhisperFutureYou)] + [Script("spell_wyrmrest_defender_whisper_to_controller_random", WhisperDefender)] + [Script("spell_past_you_whisper_to_controller_random", WhisperPastYou)] class spell_gen_whisper_to_controller_random : SpellScript { + const uint WhisperFutureYou = 2; + const uint WhisperDefender = 1; + const uint WhisperPastYou = 2; + uint _text; public spell_gen_whisper_to_controller_random(uint text) @@ -3779,23 +3567,22 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } - [Script] class spell_gen_eject_all_passengers : SpellScript { void RemoveVehicleAuras() { Vehicle vehicle = GetHitUnit().GetVehicleKit(); - if (vehicle) + if (vehicle != null) vehicle.RemoveAllPassengers(); } public override void Register() { - AfterHit.Add(new HitHandler(RemoveVehicleAuras)); + AfterHit.Add(new(RemoveVehicleAuras)); } } @@ -3804,12 +3591,10 @@ namespace Scripts.Spells.Generic { public override bool Validate(SpellInfo spellInfo) { - if (!ValidateSpellEffect(spellInfo.Id, 0)) + if (!ValidateSpellEffect((spellInfo.Id, 0))) return false; - if (spellInfo.GetEffect(0).CalcValue() < 1) return false; - return true; } @@ -3819,14 +3604,14 @@ namespace Scripts.Spells.Generic if (vehicle != null) { Unit passenger = vehicle.GetPassenger((sbyte)(GetEffectValue() - 1)); - if (passenger) + if (passenger != null) passenger.ExitVehicle(); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(EjectPassenger, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(EjectPassenger, 0, SpellEffectName.ScriptEffect)); } } @@ -3836,9 +3621,9 @@ namespace Scripts.Spells.Generic { sbyte _seatId; - public spell_gen_eject_passenger_with_seatId(sbyte seatId) + public spell_gen_eject_passenger_with_seatId(int seatId) { - _seatId = seatId; + _seatId = (sbyte)seatId; } void EjectPassenger(uint effIndex) @@ -3854,26 +3639,28 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(EjectPassenger, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(EjectPassenger, 0, SpellEffectName.ScriptEffect)); } } [Script] class spell_gen_gm_freeze : AuraScript { + const uint SpellGmFreeze = 9454; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.GmFreeze); + return ValidateSpellInfo(SpellGmFreeze); } void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) { // Do what was done before to the target in HandleFreezeCommand Player player = GetTarget().ToPlayer(); - if (player) + if (player != null) { // stop combat + make player unattackable + duel stop + stop some spells - player.SetFaction(35); + player.SetFaction((uint)FactionTemplates.Friendly); player.CombatStop(); if (player.IsNonMeleeSpellCast(true)) player.InterruptNonMeleeSpells(true); @@ -3883,7 +3670,7 @@ namespace Scripts.Spells.Generic if ((player.GetClass() == Class.Hunter) || (player.GetClass() == Class.Warlock)) { Pet pet = player.GetPet(); - if (pet) + if (pet != null) { pet.SavePetToDB(PetSaveMode.AsCurrent); // not let dismiss dead pet @@ -3898,7 +3685,7 @@ namespace Scripts.Spells.Generic { // Do what was done before to the target in HandleUnfreezeCommand Player player = GetTarget().ToPlayer(); - if (player) + if (player != null) { // Reset player faction + allow combat + allow duels player.SetFactionForRace(player.GetRace()); @@ -3910,8 +3697,8 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.ModStun, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ModStun, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(OnApply, 0, AuraType.ModStun, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(OnRemove, 0, AuraType.ModStun, AuraEffectHandleModes.Real)); } } @@ -3921,7 +3708,7 @@ namespace Scripts.Spells.Generic void HandleScript(uint eff) { Creature target = GetHitCreature(); - if (!target) + if (target == null) return; target.SetStandState(UnitStandStateType.Stand); @@ -3930,111 +3717,111 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } - enum RequiredMixologySpells + struct MixologySpellIds { - Mixology = 53042, + public const uint Mixology = 53042; // Flasks - FlaskOfTheFrostWyrm = 53755, - FlaskOfStoneblood = 53758, - FlaskOfEndlessRage = 53760, - FlaskOfPureMojo = 54212, - LesserFlaskOfResistance = 62380, - LesserFlaskOfToughness = 53752, - FlaskOfBlindingLight = 28521, - FlaskOfChromaticWonder = 42735, - FlaskOfFortification = 28518, - FlaskOfMightyRestoration = 28519, - FlaskOfPureDeath = 28540, - FlaskOfRelentlessAssault = 28520, - FlaskOfChromaticResistance = 17629, - FlaskOfDistilledWisdom = 17627, - FlaskOfSupremePower = 17628, - FlaskOfTheTitans = 17626, + public const uint FlaskOfTheFrostWyrm = 53755; + public const uint FlaskOfStoneblood = 53758; + public const uint FlaskOfEndlessRage = 53760; + public const uint FlaskOfPureMojo = 54212; + public const uint LesserFlaskOfResistance = 62380; + public const uint LesserFlaskOfToughness = 53752; + public const uint FlaskOfBlindingLight = 28521; + public const uint FlaskOfChromaticWonder = 42735; + public const uint FlaskOfFortification = 28518; + public const uint FlaskOfMightyRestoration = 28519; + public const uint FlaskOfPureDeath = 28540; + public const uint FlaskOfRelentlessAssault = 28520; + public const uint FlaskOfChromaticResistance = 17629; + public const uint FlaskOfDistilledWisdom = 17627; + public const uint FlaskOfSupremePower = 17628; + public const uint FlaskOfTheTitans = 17626; // Elixirs - ElixirOfMightyAgility = 28497, - ElixirOfAccuracy = 60340, - ElixirOfDeadlyStrikes = 60341, - ElixirOfMightyDefense = 60343, - ElixirOfExpertise = 60344, - ElixirOfArmorPiercing = 60345, - ElixirOfLightningSpeed = 60346, - ElixirOfMightyFortitude = 53751, - ElixirOfMightyMageblood = 53764, - ElixirOfMightyStrength = 53748, - ElixirOfMightyToughts = 60347, - ElixirOfProtection = 53763, - ElixirOfSpirit = 53747, - GurusElixir = 53749, - ShadowpowerElixir = 33721, - WrathElixir = 53746, - ElixirOfEmpowerment = 28514, - ElixirOfMajorMageblood = 28509, - ElixirOfMajorShadowPower = 28503, - ElixirOfMajorDefense = 28502, - FelStrengthElixir = 38954, - ElixirOfIronskin = 39628, - ElixirOfMajorAgility = 54494, - ElixirOfDraenicWisdom = 39627, - ElixirOfMajorFirepower = 28501, - ElixirOfMajorFrostPower = 28493, - EarthenElixir = 39626, - ElixirOfMastery = 33726, - ElixirOfHealingPower = 28491, - ElixirOfMajorFortitude = 39625, - ElixirOfMajorStrength = 28490, - AdeptsElixir = 54452, - OnslaughtElixir = 33720, - MightyTrollsBloodElixir = 24361, - GreaterArcaneElixir = 17539, - ElixirOfTheMongoose = 17538, - ElixirOfBruteForce = 17537, - ElixirOfSages = 17535, - ElixirOfSuperiorDefense = 11348, - ElixirOfDemonslaying = 11406, - ElixirOfGreaterFirepower = 26276, - ElixirOfShadowPower = 11474, - MagebloodElixir = 24363, - ElixirOfGiants = 11405, - ElixirOfGreaterAgility = 11334, - ArcaneElixir = 11390, - ElixirOfGreaterIntellect = 11396, - ElixirOfGreaterDefense = 11349, - ElixirOfFrostPower = 21920, - ElixirOfAgility = 11328, - MajorTrollsBlloodElixir = 3223, - ElixirOfFortitude = 3593, - ElixirOfOgresStrength = 3164, - ElixirOfFirepower = 7844, - ElixirOfLesserAgility = 3160, - ElixirOfDefense = 3220, - StrongTrollsBloodElixir = 3222, - ElixirOfMinorAccuracy = 63729, - ElixirOfWisdom = 3166, - ElixirOfGianthGrowth = 8212, - ElixirOfMinorAgility = 2374, - ElixirOfMinorFortitude = 2378, - WeakTrollsBloodElixir = 3219, - ElixirOfLionsStrength = 2367, - ElixirOfMinorDefense = 673 + public const uint ElixirOfMightyAgility = 28497; + public const uint ElixirOfAccuracy = 60340; + public const uint ElixirOfDeadlyStrikes = 60341; + public const uint ElixirOfMightyDefense = 60343; + public const uint ElixirOfExpertise = 60344; + public const uint ElixirOfArmorPiercing = 60345; + public const uint ElixirOfLightningSpeed = 60346; + public const uint ElixirOfMightyFortitude = 53751; + public const uint ElixirOfMightyMageblood = 53764; + public const uint ElixirOfMightyStrength = 53748; + public const uint ElixirOfMightyToughts = 60347; + public const uint ElixirOfProtection = 53763; + public const uint ElixirOfSpirit = 53747; + public const uint GurusElixir = 53749; + public const uint ShadowpowerElixir = 33721; + public const uint WrathElixir = 53746; + public const uint ElixirOfEmpowerment = 28514; + public const uint ElixirOfMajorMageblood = 28509; + public const uint ElixirOfMajorShadowPower = 28503; + public const uint ElixirOfMajorDefense = 28502; + public const uint FelStrengthElixir = 38954; + public const uint ElixirOfIronskin = 39628; + public const uint ElixirOfMajorAgility = 54494; + public const uint ElixirOfDraenicWisdom = 39627; + public const uint ElixirOfMajorFirepower = 28501; + public const uint ElixirOfMajorFrostPower = 28493; + public const uint EarthenElixir = 39626; + public const uint ElixirOfMastery = 33726; + public const uint ElixirOfHealingPower = 28491; + public const uint ElixirOfMajorFortitude = 39625; + public const uint ElixirOfMajorStrength = 28490; + public const uint AdeptsElixir = 54452; + public const uint OnslaughtElixir = 33720; + public const uint MightyTrollsBloodElixir = 24361; + public const uint GreaterArcaneElixir = 17539; + public const uint ElixirOfTheMongoose = 17538; + public const uint ElixirOfBruteForce = 17537; + public const uint ElixirOfSages = 17535; + public const uint ElixirOfSuperiorDefense = 11348; + public const uint ElixirOfDemonslaying = 11406; + public const uint ElixirOfGreaterFirepower = 26276; + public const uint ElixirOfShadowPower = 11474; + public const uint MagebloodElixir = 24363; + public const uint ElixirOfGiants = 11405; + public const uint ElixirOfGreaterAgility = 11334; + public const uint ArcaneElixir = 11390; + public const uint ElixirOfGreaterIntellect = 11396; + public const uint ElixirOfGreaterDefense = 11349; + public const uint ElixirOfFrostPower = 21920; + public const uint ElixirOfAgility = 11328; + public const uint MajorTrollsBlloodElixir = 3223; + public const uint ElixirOfFortitude = 3593; + public const uint ElixirOfOgresStrength = 3164; + public const uint ElixirOfFirepower = 7844; + public const uint ElixirOfLesserAgility = 3160; + public const uint ElixirOfDefense = 3220; + public const uint StrongTrollsBloodElixir = 3222; + public const uint ElixirOfMinorAccuracy = 63729; + public const uint ElixirOfWisdom = 3166; + public const uint ElixirOfGianthGrowth = 8212; + public const uint ElixirOfMinorAgility = 2374; + public const uint ElixirOfMinorFortitude = 2378; + public const uint WeakTrollsBloodElixir = 3219; + public const uint ElixirOfLionsStrength = 2367; + public const uint ElixirOfMinorDefense = 673; } [Script] class spell_gen_mixology_bonus : AuraScript { - int bonus; + int bonus = 0; public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo((uint)RequiredMixologySpells.Mixology) && ValidateSpellEffect(spellInfo.Id, 0); + return ValidateSpellInfo(MixologySpellIds.Mixology) && ValidateSpellEffect((spellInfo.Id, 0)); } public override bool Load() { - return GetCaster() && GetCaster().GetTypeId() == TypeId.Player; + return GetCaster() != null && GetCaster().IsPlayer(); } void SetBonusValueForEffect(uint effIndex, int value, AuraEffect aurEff) @@ -4045,170 +3832,170 @@ namespace Scripts.Spells.Generic void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - if (GetCaster().HasAura((uint)RequiredMixologySpells.Mixology) && GetCaster().HasSpell(GetEffectInfo(0).TriggerSpell)) + if (GetCaster().HasAura(MixologySpellIds.Mixology) && GetCaster().HasSpell(GetEffectInfo(0).TriggerSpell)) { - switch ((RequiredMixologySpells)GetId()) + switch (GetId()) { - case RequiredMixologySpells.WeakTrollsBloodElixir: - case RequiredMixologySpells.MagebloodElixir: + case MixologySpellIds.WeakTrollsBloodElixir: + case MixologySpellIds.MagebloodElixir: bonus = amount; break; - case RequiredMixologySpells.ElixirOfFrostPower: - case RequiredMixologySpells.LesserFlaskOfToughness: - case RequiredMixologySpells.LesserFlaskOfResistance: + case MixologySpellIds.ElixirOfFrostPower: + case MixologySpellIds.LesserFlaskOfToughness: + case MixologySpellIds.LesserFlaskOfResistance: bonus = MathFunctions.CalculatePct(amount, 80); break; - case RequiredMixologySpells.ElixirOfMinorDefense: - case RequiredMixologySpells.ElixirOfLionsStrength: - case RequiredMixologySpells.ElixirOfMinorAgility: - case RequiredMixologySpells.MajorTrollsBlloodElixir: - case RequiredMixologySpells.ElixirOfShadowPower: - case RequiredMixologySpells.ElixirOfBruteForce: - case RequiredMixologySpells.MightyTrollsBloodElixir: - case RequiredMixologySpells.ElixirOfGreaterFirepower: - case RequiredMixologySpells.OnslaughtElixir: - case RequiredMixologySpells.EarthenElixir: - case RequiredMixologySpells.ElixirOfMajorAgility: - case RequiredMixologySpells.FlaskOfTheTitans: - case RequiredMixologySpells.FlaskOfRelentlessAssault: - case RequiredMixologySpells.FlaskOfStoneblood: - case RequiredMixologySpells.ElixirOfMinorAccuracy: + case MixologySpellIds.ElixirOfMinorDefense: + case MixologySpellIds.ElixirOfLionsStrength: + case MixologySpellIds.ElixirOfMinorAgility: + case MixologySpellIds.MajorTrollsBlloodElixir: + case MixologySpellIds.ElixirOfShadowPower: + case MixologySpellIds.ElixirOfBruteForce: + case MixologySpellIds.MightyTrollsBloodElixir: + case MixologySpellIds.ElixirOfGreaterFirepower: + case MixologySpellIds.OnslaughtElixir: + case MixologySpellIds.EarthenElixir: + case MixologySpellIds.ElixirOfMajorAgility: + case MixologySpellIds.FlaskOfTheTitans: + case MixologySpellIds.FlaskOfRelentlessAssault: + case MixologySpellIds.FlaskOfStoneblood: + case MixologySpellIds.ElixirOfMinorAccuracy: bonus = MathFunctions.CalculatePct(amount, 50); break; - case RequiredMixologySpells.ElixirOfProtection: + case MixologySpellIds.ElixirOfProtection: bonus = 280; break; - case RequiredMixologySpells.ElixirOfMajorDefense: + case MixologySpellIds.ElixirOfMajorDefense: bonus = 200; break; - case RequiredMixologySpells.ElixirOfGreaterDefense: - case RequiredMixologySpells.ElixirOfSuperiorDefense: + case MixologySpellIds.ElixirOfGreaterDefense: + case MixologySpellIds.ElixirOfSuperiorDefense: bonus = 140; break; - case RequiredMixologySpells.ElixirOfFortitude: + case MixologySpellIds.ElixirOfFortitude: bonus = 100; break; - case RequiredMixologySpells.FlaskOfEndlessRage: + case MixologySpellIds.FlaskOfEndlessRage: bonus = 82; break; - case RequiredMixologySpells.ElixirOfDefense: + case MixologySpellIds.ElixirOfDefense: bonus = 70; break; - case RequiredMixologySpells.ElixirOfDemonslaying: + case MixologySpellIds.ElixirOfDemonslaying: bonus = 50; break; - case RequiredMixologySpells.FlaskOfTheFrostWyrm: + case MixologySpellIds.FlaskOfTheFrostWyrm: bonus = 47; break; - case RequiredMixologySpells.WrathElixir: + case MixologySpellIds.WrathElixir: bonus = 32; break; - case RequiredMixologySpells.ElixirOfMajorFrostPower: - case RequiredMixologySpells.ElixirOfMajorFirepower: - case RequiredMixologySpells.ElixirOfMajorShadowPower: + case MixologySpellIds.ElixirOfMajorFrostPower: + case MixologySpellIds.ElixirOfMajorFirepower: + case MixologySpellIds.ElixirOfMajorShadowPower: bonus = 29; break; - case RequiredMixologySpells.ElixirOfMightyToughts: + case MixologySpellIds.ElixirOfMightyToughts: bonus = 27; break; - case RequiredMixologySpells.FlaskOfSupremePower: - case RequiredMixologySpells.FlaskOfBlindingLight: - case RequiredMixologySpells.FlaskOfPureDeath: - case RequiredMixologySpells.ShadowpowerElixir: + case MixologySpellIds.FlaskOfSupremePower: + case MixologySpellIds.FlaskOfBlindingLight: + case MixologySpellIds.FlaskOfPureDeath: + case MixologySpellIds.ShadowpowerElixir: bonus = 23; break; - case RequiredMixologySpells.ElixirOfMightyAgility: - case RequiredMixologySpells.FlaskOfDistilledWisdom: - case RequiredMixologySpells.ElixirOfSpirit: - case RequiredMixologySpells.ElixirOfMightyStrength: - case RequiredMixologySpells.FlaskOfPureMojo: - case RequiredMixologySpells.ElixirOfAccuracy: - case RequiredMixologySpells.ElixirOfDeadlyStrikes: - case RequiredMixologySpells.ElixirOfMightyDefense: - case RequiredMixologySpells.ElixirOfExpertise: - case RequiredMixologySpells.ElixirOfArmorPiercing: - case RequiredMixologySpells.ElixirOfLightningSpeed: + case MixologySpellIds.ElixirOfMightyAgility: + case MixologySpellIds.FlaskOfDistilledWisdom: + case MixologySpellIds.ElixirOfSpirit: + case MixologySpellIds.ElixirOfMightyStrength: + case MixologySpellIds.FlaskOfPureMojo: + case MixologySpellIds.ElixirOfAccuracy: + case MixologySpellIds.ElixirOfDeadlyStrikes: + case MixologySpellIds.ElixirOfMightyDefense: + case MixologySpellIds.ElixirOfExpertise: + case MixologySpellIds.ElixirOfArmorPiercing: + case MixologySpellIds.ElixirOfLightningSpeed: bonus = 20; break; - case RequiredMixologySpells.FlaskOfChromaticResistance: + case MixologySpellIds.FlaskOfChromaticResistance: bonus = 17; break; - case RequiredMixologySpells.ElixirOfMinorFortitude: - case RequiredMixologySpells.ElixirOfMajorStrength: + case MixologySpellIds.ElixirOfMinorFortitude: + case MixologySpellIds.ElixirOfMajorStrength: bonus = 15; break; - case RequiredMixologySpells.FlaskOfMightyRestoration: + case MixologySpellIds.FlaskOfMightyRestoration: bonus = 13; break; - case RequiredMixologySpells.ArcaneElixir: + case MixologySpellIds.ArcaneElixir: bonus = 12; break; - case RequiredMixologySpells.ElixirOfGreaterAgility: - case RequiredMixologySpells.ElixirOfGiants: + case MixologySpellIds.ElixirOfGreaterAgility: + case MixologySpellIds.ElixirOfGiants: bonus = 11; break; - case RequiredMixologySpells.ElixirOfAgility: - case RequiredMixologySpells.ElixirOfGreaterIntellect: - case RequiredMixologySpells.ElixirOfSages: - case RequiredMixologySpells.ElixirOfIronskin: - case RequiredMixologySpells.ElixirOfMightyMageblood: + case MixologySpellIds.ElixirOfAgility: + case MixologySpellIds.ElixirOfGreaterIntellect: + case MixologySpellIds.ElixirOfSages: + case MixologySpellIds.ElixirOfIronskin: + case MixologySpellIds.ElixirOfMightyMageblood: bonus = 10; break; - case RequiredMixologySpells.ElixirOfHealingPower: + case MixologySpellIds.ElixirOfHealingPower: bonus = 9; break; - case RequiredMixologySpells.ElixirOfDraenicWisdom: - case RequiredMixologySpells.GurusElixir: + case MixologySpellIds.ElixirOfDraenicWisdom: + case MixologySpellIds.GurusElixir: bonus = 8; break; - case RequiredMixologySpells.ElixirOfFirepower: - case RequiredMixologySpells.ElixirOfMajorMageblood: - case RequiredMixologySpells.ElixirOfMastery: + case MixologySpellIds.ElixirOfFirepower: + case MixologySpellIds.ElixirOfMajorMageblood: + case MixologySpellIds.ElixirOfMastery: bonus = 6; break; - case RequiredMixologySpells.ElixirOfLesserAgility: - case RequiredMixologySpells.ElixirOfOgresStrength: - case RequiredMixologySpells.ElixirOfWisdom: - case RequiredMixologySpells.ElixirOfTheMongoose: + case MixologySpellIds.ElixirOfLesserAgility: + case MixologySpellIds.ElixirOfOgresStrength: + case MixologySpellIds.ElixirOfWisdom: + case MixologySpellIds.ElixirOfTheMongoose: bonus = 5; break; - case RequiredMixologySpells.StrongTrollsBloodElixir: - case RequiredMixologySpells.FlaskOfChromaticWonder: + case MixologySpellIds.StrongTrollsBloodElixir: + case MixologySpellIds.FlaskOfChromaticWonder: bonus = 4; break; - case RequiredMixologySpells.ElixirOfEmpowerment: + case MixologySpellIds.ElixirOfEmpowerment: bonus = -10; break; - case RequiredMixologySpells.AdeptsElixir: + case MixologySpellIds.AdeptsElixir: SetBonusValueForEffect(0, 13, aurEff); SetBonusValueForEffect(1, 13, aurEff); SetBonusValueForEffect(2, 8, aurEff); break; - case RequiredMixologySpells.ElixirOfMightyFortitude: + case MixologySpellIds.ElixirOfMightyFortitude: SetBonusValueForEffect(0, 160, aurEff); break; - case RequiredMixologySpells.ElixirOfMajorFortitude: + case MixologySpellIds.ElixirOfMajorFortitude: SetBonusValueForEffect(0, 116, aurEff); SetBonusValueForEffect(1, 6, aurEff); break; - case RequiredMixologySpells.FelStrengthElixir: + case MixologySpellIds.FelStrengthElixir: SetBonusValueForEffect(0, 40, aurEff); SetBonusValueForEffect(1, 40, aurEff); break; - case RequiredMixologySpells.FlaskOfFortification: + case MixologySpellIds.FlaskOfFortification: SetBonusValueForEffect(0, 210, aurEff); SetBonusValueForEffect(1, 5, aurEff); break; - case RequiredMixologySpells.GreaterArcaneElixir: + case MixologySpellIds.GreaterArcaneElixir: SetBonusValueForEffect(0, 19, aurEff); SetBonusValueForEffect(1, 19, aurEff); SetBonusValueForEffect(2, 5, aurEff); break; - case RequiredMixologySpells.ElixirOfGianthGrowth: + case MixologySpellIds.ElixirOfGianthGrowth: SetBonusValueForEffect(0, 5, aurEff); break; default: - Log.outError(LogFilter.Spells, "SpellId {0} couldn't be processed in spell_gen_mixology_bonus", GetId()); + Log.outError(LogFilter.Spells, $"SpellId {GetId()} couldn't be processed in spell_gen_mixology_bonus"); break; } amount += bonus; @@ -4217,29 +4004,31 @@ namespace Scripts.Spells.Generic public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, SpellConst.EffectAll, AuraType.Any)); + DoEffectCalcAmount.Add(new(CalculateAmount, SpellConst.EffectAll, AuraType.Any)); } } [Script] class spell_gen_landmine_knockback_achievement : SpellScript { + const uint SpellLandmineKnockbackAchievement = 57064; + void HandleScript(uint effIndex) { Player target = GetHitPlayer(); - if (target) + if (target != null) { Aura aura = GetHitAura(); if (aura == null || aura.GetStackAmount() < 10) return; - target.CastSpell(target, SpellIds.LandmineKnockbackAchievement, true); + target.CastSpell(target, SpellLandmineKnockbackAchievement, true); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -4249,38 +4038,41 @@ namespace Scripts.Spells.Generic void HandleScript(uint effIndex) { Unit target = GetHitUnit(); - if (target) + if (target != null) { target.RemoveOwnedAuras(aura => { SpellInfo spellInfo = aura.GetSpellInfo(); - return !spellInfo.IsPositive() && !spellInfo.IsPassive(); + return spellInfo.IsPositive() && spellInfo.IsPassive(); }); + } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] class spell_gen_pony_mount_check : AuraScript { + const uint AchievPonyUp = 3736; + const uint MountPony = 29736; + void HandleEffectPeriodic(AuraEffect aurEff) { Unit caster = GetCaster(); - if (!caster) + if (caster == null) return; - Player owner = caster.GetOwner().ToPlayer(); - if (!owner || !owner.HasAchieved(SpellIds.AchievementPonyup)) + if (owner == null || !owner.HasAchieved(AchievPonyUp)) return; if (owner.IsMounted()) { - caster.Mount(SpellIds.MountPony); + caster.Mount(MountPony); caster.SetSpeedRate(UnitMoveType.Run, owner.GetSpeedRate(UnitMoveType.Run)); } else if (caster.IsMounted()) @@ -4292,13 +4084,24 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); } } + struct CorruptinPlagueIds + { + public const uint NpcApexisFlayer = 22175; + public const uint NpcShardHideBoar = 22180; + public const uint NpcAetherRay = 22181; + public const uint SpellCorruptingPlague = 40350; + } + // 40350 - Corrupting Plague class CorruptingPlagueSearcher : ICheck { + Unit _unit; + float _distance; + public CorruptingPlagueSearcher(Unit obj, float distance) { _unit = obj; @@ -4308,23 +4111,20 @@ namespace Scripts.Spells.Generic public bool Invoke(Unit u) { if (_unit.GetDistance2d(u) < _distance && - (u.GetEntry() == CreatureIds.ApexisFlayer || u.GetEntry() == CreatureIds.ShardHideBoar || u.GetEntry() == CreatureIds.AetherRay) && - !u.HasAura(SpellIds.CorruptingPlague)) + (u.GetEntry() == CorruptinPlagueIds.NpcApexisFlayer || u.GetEntry() == CorruptinPlagueIds.NpcShardHideBoar || u.GetEntry() == CorruptinPlagueIds.NpcAetherRay) && + !u.HasAura(CorruptinPlagueIds.SpellCorruptingPlague)) return true; return false; } - - Unit _unit; - float _distance; } [Script] // 40349 - Corrupting Plague - class spell_corrupting_plague_aura : AuraScript + class spell_corrupting_plague_AuraScript : AuraScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.CorruptingPlague); + return ValidateSpellInfo(CorruptinPlagueIds.SpellCorruptingPlague); } void OnPeriodic(AuraEffect aurEff) @@ -4344,16 +4144,45 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 0, AuraType.PeriodicTriggerSpell)); + OnEffectPeriodic.Add(new(OnPeriodic, 0, AuraType.PeriodicTriggerSpell)); + } + } + + struct StasisFieldIds + { + public const uint NpcDaggertailLizard = 22255; + public const uint SpellStasisField = 40307; + } + + // 40307 - Stasis Field + class StasisFieldSearcher : ICheck + { + Unit _unit; + float _distance; + + public StasisFieldSearcher(Unit obj, float distance) + { + _unit = obj; + _distance = distance; + } + + public bool Invoke(Unit u) + { + if (_unit.GetDistance2d(u) < _distance && + (u.GetEntry() == CorruptinPlagueIds.NpcApexisFlayer || u.GetEntry() == CorruptinPlagueIds.NpcShardHideBoar || u.GetEntry() == CorruptinPlagueIds.NpcAetherRay || u.GetEntry() == StasisFieldIds.NpcDaggertailLizard) && + !u.HasAura(StasisFieldIds.SpellStasisField)) + return true; + + return false; } } [Script] // 40306 - Stasis Field - class spell_stasis_field_aura : AuraScript + class spell_stasis_field_AuraScript : AuraScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.StasisField); + return ValidateSpellInfo(StasisFieldIds.SpellStasisField); } void OnPeriodic(AuraEffect aurEff) @@ -4373,52 +4202,63 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 0, AuraType.PeriodicTriggerSpell)); + OnEffectPeriodic.Add(new(OnPeriodic, 0, AuraType.PeriodicTriggerSpell)); } } [Script] class spell_gen_vehicle_control_link : AuraScript { + const uint SpellSiegeTankControl = 47963; + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - GetTarget().RemoveAurasDueToSpell(SpellIds.SiegeTankControl); //aurEff.GetAmount() + GetTarget().RemoveAurasDueToSpell(SpellSiegeTankControl); //aurEff.GetAmount() } public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(OnRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); } } [Script] // 34779 - Freezing Circle class spell_freezing_circle : SpellScript { + const uint SpellFreezingCirclePitOfSaronNormal = 69574; + const uint SpellFreezingCirclePitOfSaronHeroic = 70276; + const uint SpellFreezingCircle = 34787; + const uint SpellFreezingCircleScenario = 141383; + const uint MapIdBloodInTheSnowScenario = 1130; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.FreezingCirclePitOfSaronNormal, SpellIds.FreezingCirclePitOfSaronHeroic, SpellIds.FreezingCircle, SpellIds.FreezingCircleScenario); + return ValidateSpellInfo(SpellFreezingCirclePitOfSaronNormal, + SpellFreezingCirclePitOfSaronHeroic, + SpellFreezingCircle, + SpellFreezingCircleScenario + ); } void HandleDamage(uint effIndex) { Unit caster = GetCaster(); - uint spellId = 0; + uint spellId; Map map = caster.GetMap(); if (map.IsDungeon()) - spellId = map.IsHeroic() ? SpellIds.FreezingCirclePitOfSaronHeroic : SpellIds.FreezingCirclePitOfSaronNormal; + spellId = map.IsHeroic() ? SpellFreezingCirclePitOfSaronHeroic : SpellFreezingCirclePitOfSaronNormal; else - spellId = map.GetId() == Misc.MapIdBloodInTheSnowScenario ? SpellIds.FreezingCircleScenario : SpellIds.FreezingCircle; + spellId = map.GetId() == MapIdBloodInTheSnowScenario ? SpellFreezingCircleScenario : SpellFreezingCircle; - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, GetCastDifficulty()); - if (spellInfo != null) - if (!spellInfo.GetEffects().Empty()) - SetHitDamage(spellInfo.GetEffect(0).CalcValue()); + SpellInfo spellInfo = SpellMgr.GetSpellInfo(spellId, GetCastDifficulty()); + if (spellInfo != null && spellInfo.GetEffects().Empty()) + SetHitDamage(spellInfo.GetEffect(0).CalcValue()); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDamage, 1, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new(HandleDamage, 1, SpellEffectName.SchoolDamage)); } } @@ -4441,16 +4281,19 @@ namespace Scripts.Spells.Generic public override void Register() { - OnCast.Add(new CastHandler(HandleCast)); + OnCast.Add(new(HandleCast)); } } [Script] class spell_gen_cannon_blast : SpellScript { + const uint SpellCannonBlast = 42578; + const uint SpellCannonBlastDamage = 42576; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.CannonBlast); + return ValidateSpellInfo(SpellCannonBlast); } void HandleScript(uint effIndex) { @@ -4458,12 +4301,12 @@ namespace Scripts.Spells.Generic Unit target = GetHitUnit(); CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); args.AddSpellMod(SpellValueMod.BasePoint0, bp); - target.CastSpell(target, SpellIds.CannonBlastDamage, args); + target.CastSpell(target, SpellCannonBlastDamage, args); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -4479,7 +4322,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -4489,13 +4332,13 @@ namespace Scripts.Spells.Generic void HandleScript(uint effIndex) { Unit target = GetHitUnit(); - if (target) + if (target != null) target.SetHealth(target.CountPctFromMaxHealth(25)); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 1, SpellEffectName.ScriptEffect)); } } @@ -4509,7 +4352,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -4521,7 +4364,7 @@ namespace Scripts.Spells.Generic targets.RemoveAll(target => { Unit unit = target.ToUnit(); - if (unit) + if (unit != null) return unit.GetPowerType() != PowerType.Mana; return false; }); @@ -4529,16 +4372,19 @@ namespace Scripts.Spells.Generic public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); } } [Script] class spell_gen_mark_of_kazrogal_hellfire_AuraScript : AuraScript { + const uint SpellMarkOfKazrogalHellfire = 189512; + const uint SpellMarkOfKazrogalDamageHellfire = 189515; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.MarkOfKazrogalDamageHellfire); + return ValidateSpellInfo(SpellMarkOfKazrogalDamageHellfire); } void OnPeriodic(AuraEffect aurEff) @@ -4547,7 +4393,7 @@ namespace Scripts.Spells.Generic if (target.GetPower(PowerType.Mana) == 0) { - target.CastSpell(target, SpellIds.MarkOfKazrogalDamageHellfire, new CastSpellExtraArgs(aurEff)); + target.CastSpell(target, SpellMarkOfKazrogalDamageHellfire, aurEff); // Remove aura SetDuration(0); } @@ -4555,7 +4401,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 0, AuraType.PowerBurn)); + OnEffectPeriodic.Add(new(OnPeriodic, 0, AuraType.PowerBurn)); } } @@ -4569,35 +4415,40 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 99947 - Face Rage class spell_gen_face_rage : AuraScript { + const uint SpellFaceRage = 99947; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.FaceRage) && ValidateSpellEffect(spellInfo.Id, 2); + return ValidateSpellInfo(SpellFaceRage) + && ValidateSpellEffect((spellInfo.Id, 2)); } void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) - { + { GetTarget().RemoveAurasDueToSpell(GetEffectInfo(2).TriggerSpell); } public override void Register() { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ModStun, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(OnRemove, 0, AuraType.ModStun, AuraEffectHandleModes.Real)); } } [Script] // 187213 - Impatient Mind class spell_gen_impatient_mind : AuraScript { + const uint SpellImpatientMind = 187213; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.ImpatientMind); + return ValidateSpellInfo(SpellImpatientMind); } void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) @@ -4607,7 +4458,30 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); + } + } + + [Script] // 209352 - Boost 2.0 [Paladin+Priest] - Watch for Shield + class spell_gen_boost_2_0_paladin_priest_watch_for_shield : AuraScript + { + uint SpellPowerWordShield = 17; + uint SpellDivineShield = 642; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellPowerWordShield, SpellDivineShield); + } + + bool CheckProc(AuraEffect aurEff, ProcEventInfo procInfo) + { + SpellInfo spellInfo = procInfo.GetSpellInfo(); + return spellInfo != null && (spellInfo.Id == SpellPowerWordShield || spellInfo.Id == SpellDivineShield); + } + + public override void Register() + { + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.ProcTriggerSpell)); } } @@ -4624,47 +4498,55 @@ namespace Scripts.Spells.Generic switch (target.GetTeamId()) { case TeamId.Alliance: - amount = Global.WorldStateMgr.GetValue(WorldStates.WarModeAllianceBuffValue, target.GetMap()); + amount = WorldStateMgr.GetValue(WorldStates.WarModeAllianceBuffValue, target.GetMap()); break; case TeamId.Horde: - amount = Global.WorldStateMgr.GetValue(WorldStates.WarModeHordeBuffValue, target.GetMap()); + amount = WorldStateMgr.GetValue(WorldStates.WarModeHordeBuffValue, target.GetMap()); + break; + default: break; } } public override void Register() { - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(m_scriptSpellId, Difficulty.None); + SpellInfo spellInfo = SpellMgr.GetSpellInfo(m_scriptSpellId, Difficulty.None); if (spellInfo.HasAura(AuraType.ModXpPct)) - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalcWarModeBonus, SpellConst.EffectAll, AuraType.ModXpPct)); + DoEffectCalcAmount.Add(new(CalcWarModeBonus, SpellConst.EffectAll, AuraType.ModXpPct)); if (spellInfo.HasAura(AuraType.ModXpQuestPct)) - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalcWarModeBonus, SpellConst.EffectAll, AuraType.ModXpQuestPct)); + DoEffectCalcAmount.Add(new(CalcWarModeBonus, SpellConst.EffectAll, AuraType.ModXpQuestPct)); if (spellInfo.HasAura(AuraType.ModCurrencyGainFromSource)) - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalcWarModeBonus, SpellConst.EffectAll, AuraType.ModCurrencyGainFromSource)); + DoEffectCalcAmount.Add(new(CalcWarModeBonus, SpellConst.EffectAll, AuraType.ModCurrencyGainFromSource)); if (spellInfo.HasAura(AuraType.ModMoneyGain)) - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalcWarModeBonus, SpellConst.EffectAll, AuraType.ModMoneyGain)); + DoEffectCalcAmount.Add(new(CalcWarModeBonus, SpellConst.EffectAll, AuraType.ModMoneyGain)); if (spellInfo.HasAura(AuraType.ModAnimaGain)) - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalcWarModeBonus, SpellConst.EffectAll, AuraType.ModAnimaGain)); + DoEffectCalcAmount.Add(new(CalcWarModeBonus, SpellConst.EffectAll, AuraType.ModAnimaGain)); if (spellInfo.HasAura(AuraType.Dummy)) - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalcWarModeBonus, SpellConst.EffectAll, AuraType.Dummy)); + DoEffectCalcAmount.Add(new(CalcWarModeBonus, SpellConst.EffectAll, AuraType.Dummy)); } } [Script] class spell_defender_of_azeroth_death_gate_selector : SpellScript { - (WorldLocation, uint) StormwindInnLoc = (new WorldLocation(0, -8868.1f, 675.82f, 97.9f, 5.164778709411621093f), 5148); - (WorldLocation, uint) OrgrimmarInnLoc = (new WorldLocation(1, 1573.18f, -4441.62f, 16.06f, 1.818284034729003906f), 8618); + const uint SpellDeathGateTeleportStormwind = 316999; + const uint SpellDeathGateTeleportOrgrimmar = 317000; + + const uint QuestDefenderOfAzerothAlliance = 58902; + const uint QuestDefenderOfAzerothHorde = 58903; + + (WorldLocation, uint) StormwindInnLoc = (new(0, -8868.1f, 675.82f, 97.9f, 5.164778709411621093f), 5148); + (WorldLocation, uint) OrgrimmarInnLoc = (new(1, 1573.18f, -4441.62f, 16.06f, 1.818284034729003906f), 8618); public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.DeathGateTeleportStormwind, SpellIds.DeathGateTeleportOrgrimmar); + return ValidateSpellInfo(SpellDeathGateTeleportStormwind, SpellDeathGateTeleportOrgrimmar); } void HandleDummy(uint effIndex) @@ -4673,63 +4555,65 @@ namespace Scripts.Spells.Generic if (player == null) return; - if (player.GetQuestStatus(QuestIds.DefenderOfAzerothAlliance) == QuestStatus.None && player.GetQuestStatus(QuestIds.DefenderOfAzerothHorde) == QuestStatus.None) + if (player.GetQuestStatus(QuestDefenderOfAzerothAlliance) == QuestStatus.None && player.GetQuestStatus(QuestDefenderOfAzerothHorde) == QuestStatus.None) return; - (WorldLocation Loc, uint AreaId) bindLoc = player.GetTeam() == Team.Alliance ? StormwindInnLoc : OrgrimmarInnLoc; - player.SetHomebind(bindLoc.Loc, bindLoc.AreaId); + var (loc, areaId) = player.GetTeam() == Team.Alliance ? StormwindInnLoc : OrgrimmarInnLoc; + player.SetHomebind(loc, areaId); player.SendBindPointUpdate(); - player.SendPlayerBound(player.GetGUID(), bindLoc.AreaId); + player.SendPlayerBound(player.GetGUID(), areaId); - player.CastSpell(player, player.GetTeam() == Team.Alliance ? SpellIds.DeathGateTeleportStormwind : SpellIds.DeathGateTeleportOrgrimmar); + player.CastSpell(player, player.GetTeam() == Team.Alliance ? SpellDeathGateTeleportStormwind : SpellDeathGateTeleportOrgrimmar); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] class spell_defender_of_azeroth_speak_with_mograine : SpellScript { + const uint NpcNazgrim = 161706; + const uint NpcTrollbane = 161707; + const uint NpcWhitemane = 161708; + void HandleDummy(uint effIndex) { - if (!GetCaster()) + if (GetCaster() == null) return; Player player = GetCaster().ToPlayer(); if (player == null) return; - Creature nazgrim = GetHitUnit().FindNearestCreature(CreatureIds.Nazgrim, 10.0f); + Creature nazgrim = GetHitUnit().FindNearestCreature(NpcNazgrim, 10.0f); if (nazgrim != null) nazgrim.HandleEmoteCommand(Emote.OneshotPoint, player); - - Creature trollbane = GetHitUnit().FindNearestCreature(CreatureIds.Trollbane, 10.0f); + Creature trollbane = GetHitUnit().FindNearestCreature(NpcTrollbane, 10.0f); if (trollbane != null) trollbane.HandleEmoteCommand(Emote.OneshotPoint, player); - - Creature whitemane = GetHitUnit().FindNearestCreature(CreatureIds.Whitemane, 10.0f); + Creature whitemane = GetHitUnit().FindNearestCreature(NpcWhitemane, 10.0f); if (whitemane != null) whitemane.HandleEmoteCommand(Emote.OneshotPoint, player); - // @TODO: spawntracking - show death gate for casting player + // @Todo: spawntracking - show death gate for casting player } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } - [Script]// 118301 - Summon Battle Pet + [Script] // 118301 - Summon Battle Pet class spell_summon_battle_pet : SpellScript { void HandleSummon(uint effIndex) { uint creatureId = (uint)GetSpellValue().EffectBasePoints[effIndex]; - if (Global.ObjectMgr.GetCreatureTemplate(creatureId) != null) + if (ObjectMgr.GetCreatureTemplate(creatureId) != null) { PreventHitDefaultEffect(effIndex); @@ -4746,11 +4630,11 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleSummon, 0, SpellEffectName.Summon)); + OnEffectHit.Add(new(HandleSummon, 0, SpellEffectName.Summon)); } } - [Script] // 132334 - Trainer Heal Cooldown (SERVERSIDE) + [Script] // 132334 - Trainer Heal Cooldown (Serverside) class spell_gen_trainer_heal_cooldown : AuraScript { public override bool Validate(SpellInfo spellInfo) @@ -4766,12 +4650,12 @@ namespace Scripts.Spells.Generic void UpdateReviveBattlePetCooldown(AuraEffect aurEff, AuraEffectHandleModes mode) { Player target = GetUnitOwner().ToPlayer(); - SpellInfo reviveBattlePetSpellInfo = Global.SpellMgr.GetSpellInfo(SharedConst.SpellReviveBattlePets, Difficulty.None); + SpellInfo reviveBattlePetSpellInfo = SpellMgr.GetSpellInfo(SharedConst.SpellReviveBattlePets, Difficulty.None); if (target.GetSession().GetBattlePetMgr().IsBattlePetSystemEnabled()) { TimeSpan expectedCooldown = TimeSpan.FromMilliseconds(GetAura().GetMaxDuration()); - TimeSpan remainingCooldown = target.GetSpellHistory().GetRemainingCategoryCooldown(reviveBattlePetSpellInfo); + var remainingCooldown = target.GetSpellHistory().GetRemainingCategoryCooldown(reviveBattlePetSpellInfo); if (remainingCooldown > TimeSpan.Zero) { if (remainingCooldown < expectedCooldown) @@ -4786,7 +4670,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(UpdateReviveBattlePetCooldown, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(UpdateReviveBattlePetCooldown, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -4802,12 +4686,12 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } - [Script] // 147066 - (Serverside/Non-DB2) Generic - Mount Check Aura - class spell_gen_mount_check_aura : AuraScript + [Script] // 147066 - (Serverside/Non-Db2) Generic - Mount Check Aura + class spell_gen_mount_check_AuraScript : AuraScript { void OnPeriodic(AuraEffect aurEff) { @@ -4824,7 +4708,7 @@ namespace Scripts.Spells.Generic if (summoner.IsMounted() && (!summoner.IsInCombat() || summoner.IsFlying())) { - CreatureSummonedData summonedData = Global.ObjectMgr.GetCreatureSummonedData(tempSummon.GetEntry()); + CreatureSummonedData summonedData = ObjectMgr.GetCreatureSummonedData(tempSummon.GetEntry()); if (summonedData != null) { if (summoner.IsFlying() && summonedData.FlyingMountDisplayID.HasValue) @@ -4840,19 +4724,24 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 0, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(OnPeriodic, 0, AuraType.PeriodicDummy)); } } [Script] // 274738 - Ancestral Call (Mag'har Orc Racial) class spell_gen_ancestral_call : SpellScript { + const uint SpellRictusOfTheLaughingSkull = 274739; + const uint SpellZealOfTheBurningBlade = 274740; + const uint SpellFerocityOfTheFrostwolf = 274741; + const uint SpellMightOfTheBlackrock = 274742; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.RictusOfTheLaughingSkull, SpellIds.ZealOfTheBurningBlade, SpellIds.FerocityOfTheFrostwolf, SpellIds.MightOfTheBlackrock); + return ValidateSpellInfo(SpellRictusOfTheLaughingSkull, SpellZealOfTheBurningBlade, SpellFerocityOfTheFrostwolf, SpellMightOfTheBlackrock); } - static uint[] AncestralCallBuffs = { SpellIds.RictusOfTheLaughingSkull, SpellIds.ZealOfTheBurningBlade, SpellIds.FerocityOfTheFrostwolf, SpellIds.MightOfTheBlackrock }; + uint[] AncestralCallBuffs = { SpellRictusOfTheLaughingSkull, SpellZealOfTheBurningBlade, SpellFerocityOfTheFrostwolf, SpellMightOfTheBlackrock }; void HandleOnCast() { @@ -4864,7 +4753,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnCast.Add(new CastHandler(HandleOnCast)); + OnCast.Add(new(HandleOnCast)); } } @@ -4883,7 +4772,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } @@ -4897,11 +4786,11 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } - // Note: this spell unsummons any creature owned by the caster. Set appropriate target conditions on the DB. + // Note: this spell unsummons any creature owned by the caster. Set appropriate target conditions on the Db. // 84065 - Despawn All Summons // 83935 - Despawn All Summons [Script] // 160938 - Despawn All Summons (Garrison Intro Only) @@ -4921,38 +4810,34 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } - enum SkinningLearningSpell - { - Classic = 265856, - Outland = 265858, - Northrend = 265860, - Cataclysm = 265862, - Pandaria = 265864, - Draenor = 265866, - Legion = 265868, - KulTiran = 265870, - Zandalari = 265872, - Shadowlands = 308570, - DragonIsles = 366263 - } - [Script] // 8613 - Skinning class spell_gen_skinning : SpellScript { + const uint SpellClassicSkinning = 265856; + const uint SpellOutlandSkinning = 265858; + const uint SpellNorthrendSkinning = 265860; + const uint SpellCataclysmSkinning = 265862; + const uint SpellPandariaSkinning = 265864; + const uint SpellDraenorSkinning = 265866; + const uint SpellLegionSkinning = 265868; + const uint SpellKulTiranSkinning = 265870; + const uint SpellZandalariSkinning = 265872; + const uint SpellShadowlandsSkinning = 308570; + const uint SpellDragonIslesSkinning = 366263; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo((uint)SkinningLearningSpell.Outland, (uint)SkinningLearningSpell.Northrend, (uint)SkinningLearningSpell.Cataclysm, (uint)SkinningLearningSpell.Pandaria, (uint)SkinningLearningSpell.Draenor, - (uint)SkinningLearningSpell.KulTiran, (uint)SkinningLearningSpell.Zandalari, (uint)SkinningLearningSpell.Shadowlands, (uint)SkinningLearningSpell.DragonIsles); + return ValidateSpellInfo(SpellOutlandSkinning, SpellNorthrendSkinning, SpellCataclysmSkinning, SpellPandariaSkinning, SpellDraenorSkinning, SpellKulTiranSkinning, SpellZandalariSkinning, SpellShadowlandsSkinning, SpellDragonIslesSkinning); } void HandleSkinningEffect(uint effIndex) { Player player = GetCaster().ToPlayer(); - if (!player) + if (player == null) return; var contentTuning = CliDB.ContentTuningStorage.LookupByKey(GetHitUnit().GetContentTuning()); @@ -4964,28 +4849,20 @@ namespace Scripts.Spells.Generic return; // Autolearning missing skinning skill (Dragonflight) - SkinningLearningSpell getSkinningLearningSpellBySkill() + uint getSkinningLearningSpellBySkill() { switch ((SkillType)skinningSkill) { - case SkillType.OutlandSkinning: - return SkinningLearningSpell.Outland; - case SkillType.NorthrendSkinning: - return SkinningLearningSpell.Northrend; - case SkillType.CataclysmSkinning: - return SkinningLearningSpell.Cataclysm; - case SkillType.PandariaSkinning: - return SkinningLearningSpell.Pandaria; - case SkillType.DraenorSkinning: - return SkinningLearningSpell.Draenor; - case SkillType.KulTiranSkinning: - return player.GetTeam() == Team.Alliance ? SkinningLearningSpell.KulTiran : SkinningLearningSpell.Zandalari; - case SkillType.ShadowlandsSkinning: - return SkinningLearningSpell.Shadowlands; - case SkillType.DragonIslesSkinning: - return SkinningLearningSpell.DragonIsles; - case SkillType.ClassicSkinning: // Trainer only - case SkillType.LegionSkinning: // Quest only + case SkillType.OutlandSkinning: return SpellOutlandSkinning; + case SkillType.NorthrendSkinning: return SpellNorthrendSkinning; + case SkillType.CataclysmSkinning: return SpellCataclysmSkinning; + case SkillType.PandariaSkinning: return SpellPandariaSkinning; + case SkillType.DraenorSkinning: return SpellDraenorSkinning; + case SkillType.KulTiranSkinning: return player.GetTeam() == Team.Alliance ? SpellKulTiranSkinning : SpellZandalariSkinning; + case SkillType.ShadowlandsSkinning: return SpellShadowlandsSkinning; + case SkillType.DragonIslesSkinning: return SpellDragonIslesSkinning; + case SkillType.ClassicSkinning: // Trainer only + case SkillType.LegionSkinning: // Quest only default: break; } @@ -4994,7 +4871,7 @@ namespace Scripts.Spells.Generic if (!player.HasSkill(skinningSkill)) { - uint spellId = (uint)getSkinningLearningSpellBySkill(); + uint spellId = getSkinningLearningSpellBySkill(); if (spellId != 0) player.CastSpell(null, spellId, true); } @@ -5002,7 +4879,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleSkinningEffect, 0, SpellEffectName.Skinning)); + OnEffectHitTarget.Add(new(HandleSkinningEffect, 0, SpellEffectName.Skinning)); } } @@ -5017,14 +4894,20 @@ namespace Scripts.Spells.Generic // 256740 - Drums of the Maelstrom // 309658 - Drums of Deathly Ferocity // 381301 - Feral Hide Drums - [Script("spell_sha_bloodlust", SpellIds.ShamanSated)] - [Script("spell_sha_heroism", SpellIds.ShamanExhaustion)] - [Script("spell_mage_time_warp", SpellIds.MageTemporalDisplacement)] - [Script("spell_hun_primal_rage", SpellIds.HunterFatigued)] - [Script("spell_evo_fury_of_the_aspects", SpellIds.EvokerExhaustion)] - [Script("spell_item_bloodlust_drums", SpellIds.ShamanExhaustion)] + [Script("spell_sha_bloodlust", SpellShamanSated)] + [Script("spell_sha_heroism", SpellShamanExhaustion)] + [Script("spell_mage_time_warp", SpellMageTemporalDisplacement)] + [Script("spell_hun_primal_rage", SpellHunterFatigued)] + [Script("spell_evo_fury_of_the_aspects", SpellEvokerExhaustion)] + [Script("spell_item_bloodlust_drums", SpellShamanExhaustion)] class spell_gen_bloodlust : SpellScript { + const uint SpellShamanSated = 57724; // Bloodlust + const uint SpellShamanExhaustion = 57723; // Heroism, Drums + const uint SpellMageTemporalDisplacement = 80354; + const uint SpellHunterFatigued = 264689; + const uint SpellEvokerExhaustion = 390435; + uint _exhaustionSpellId; public spell_gen_bloodlust(uint exhaustionSpellId) @@ -5034,7 +4917,7 @@ namespace Scripts.Spells.Generic public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.ShamanSated, SpellIds.ShamanExhaustion, SpellIds.MageTemporalDisplacement, SpellIds.HunterFatigued, SpellIds.EvokerExhaustion); + return ValidateSpellInfo(SpellShamanSated, SpellShamanExhaustion, SpellMageTemporalDisplacement, SpellHunterFatigued, SpellEvokerExhaustion); } void FilterTargets(List targets) @@ -5045,11 +4928,11 @@ namespace Scripts.Spells.Generic if (unit == null) return true; - return unit.HasAura(SpellIds.ShamanSated) - || unit.HasAura(SpellIds.ShamanExhaustion) - || unit.HasAura(SpellIds.MageTemporalDisplacement) - || unit.HasAura(SpellIds.HunterFatigued) - || unit.HasAura(SpellIds.EvokerExhaustion); + return unit.HasAura(SpellShamanSated) + || unit.HasAura(SpellShamanExhaustion) + || unit.HasAura(SpellMageTemporalDisplacement) + || unit.HasAura(SpellHunterFatigued) + || unit.HasAura(SpellEvokerExhaustion); }); } @@ -5061,9 +4944,9 @@ namespace Scripts.Spells.Generic public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitCasterAreaRaid)); - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitCasterAreaRaid)); - OnEffectHitTarget.Add(new EffectHandler(HandleHit, 0, SpellEffectName.ApplyAura)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitCasterAreaRaid)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 1, Targets.UnitCasterAreaRaid)); + OnEffectHitTarget.Add(new(HandleHit, 0, SpellEffectName.ApplyAura)); } } @@ -5086,7 +4969,7 @@ namespace Scripts.Spells.Generic public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitDestAreaAlly)); } } @@ -5094,7 +4977,7 @@ namespace Scripts.Spells.Generic [Script] // 156758 - Spirit Heal class spell_gen_spirit_heal_personal : AuraScript { - uint SPELL_SPIRIT_HEAL_EFFECT = 156763; + uint SpellSpiritHealEffect = 156763; void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { @@ -5110,12 +4993,12 @@ namespace Scripts.Spells.Generic return; if (targetPlayer.CanAcceptAreaSpiritHealFrom(caster)) - caster.CastSpell(targetPlayer, SPELL_SPIRIT_HEAL_EFFECT); + caster.CastSpell(targetPlayer, SpellSpiritHealEffect); } public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -5151,7 +5034,7 @@ namespace Scripts.Spells.Generic public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(OnRemove, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); } } @@ -5169,30 +5052,123 @@ namespace Scripts.Spells.Generic public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } - // 40307 - Stasis Field - class StasisFieldSearcher : ICheck + struct MajorPlayerHealingCooldownHelpers { - Unit _unit; - float _distance; + public const uint SpellDruidTranquility = 740; + public const uint SpellDruidTranquilityHeal = 157982; + public const uint SpellPriestDivineHymn = 64843; + public const uint SpellPriestDivineHymnHeal = 64844; + public const uint SpellPriestLuminousBarrier = 271466; + public const uint SpellShamanHealingTideTotem = 108280; + public const uint SpellShamanHealingTideTotemHeal = 114942; + public const uint SpellMonkRevival = 115310; + public const uint SpellEvokerRewind = 363534; - public StasisFieldSearcher(Unit obj, float distance) + public static float GetBonusMultiplier(Unit unit, uint spellId) { - _unit = obj; - _distance = distance; + // Note: if caster is not in a raid setting, is in PvP or while in arena combat with 5 or less allied players. + if (!unit.GetMap().IsRaid() || !unit.GetMap().IsBattleground()) + { + uint bonusSpellId; + uint effIndex; + switch (spellId) + { + case SpellDruidTranquilityHeal: + bonusSpellId = SpellDruidTranquility; + effIndex = 2; + break; + case SpellPriestDivineHymnHeal: + bonusSpellId = SpellPriestDivineHymn; + effIndex = 1; + break; + case SpellPriestLuminousBarrier: + bonusSpellId = spellId; + effIndex = 1; + break; + case SpellShamanHealingTideTotemHeal: + bonusSpellId = SpellShamanHealingTideTotem; + effIndex = 2; + break; + case SpellMonkRevival: + bonusSpellId = spellId; + effIndex = 4; + break; + case SpellEvokerRewind: + bonusSpellId = spellId; + effIndex = 3; + break; + default: + return 0.0f; + } + + AuraEffect healingIncreaseEffect = unit.GetAuraEffect(bonusSpellId, effIndex); + if (healingIncreaseEffect != null) + return healingIncreaseEffect.GetAmount(); + + return SpellMgr.GetSpellInfo(bonusSpellId, Difficulty.None).GetEffect(effIndex).CalcValue(unit); + } + + return 0.0f; + } + } + + // 157982 - Tranquility (Heal) + // 64844 - Divine Hymn (Heal) + // 114942 - Healing Tide (Heal) + [Script] // 115310 - Revival (Heal) + class spell_gen_major_healing_cooldown_modifier : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellEffect + ( + (MajorPlayerHealingCooldownHelpers.SpellDruidTranquility, 2), + (MajorPlayerHealingCooldownHelpers.SpellPriestDivineHymn, 1), + (MajorPlayerHealingCooldownHelpers.SpellShamanHealingTideTotem, 2), + (MajorPlayerHealingCooldownHelpers.SpellMonkRevival, 4) + ); } - public bool Invoke(Unit u) + void CalculateHealingBonus(Unit victim, ref int healing, ref int flatMod, ref float pctMod) { - if (_unit.GetDistance2d(u) < _distance && - (u.GetEntry() == CreatureIds.ApexisFlayer || u.GetEntry() == CreatureIds.ShardHideBoar || u.GetEntry() == CreatureIds.AetherRay || u.GetEntry() == CreatureIds.DaggertailLizard) && - !u.HasAura(SpellIds.StasisField)) - return true; + MathFunctions.AddPct(ref pctMod, MajorPlayerHealingCooldownHelpers.GetBonusMultiplier(GetCaster(), GetSpellInfo().Id)); + } - return false; + public override void Register() + { + CalcHealing.Add(new(CalculateHealingBonus)); + } + } + + // 157982 - Tranquility (Heal) + // 271466 - Luminous Barrier (Absorb) + [Script] // 363534 - Rewind (Heal) + class spell_gen_major_healing_cooldown_modifier_AuraScript : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellEffect + ( + (MajorPlayerHealingCooldownHelpers.SpellDruidTranquility, 2), + (MajorPlayerHealingCooldownHelpers.SpellPriestLuminousBarrier, 1), + (MajorPlayerHealingCooldownHelpers.SpellEvokerRewind, 3) + ); + } + + void CalculateHealingBonus(AuraEffect aurEff, Unit victim, ref int damageOrHealing, ref int flatMod, ref float pctMod) + { + Unit caster = GetCaster(); + if (caster != null) + MathFunctions.AddPct(ref pctMod, MajorPlayerHealingCooldownHelpers.GetBonusMultiplier(caster, GetSpellInfo().Id)); + } + + public override void Register() + { + DoEffectCalcDamageAndHealing.Add(new(CalculateHealingBonus, SpellConst.EffectAll, AuraType.Any)); } } } \ No newline at end of file diff --git a/Source/Scripts/Spells/Hunter.cs b/Source/Scripts/Spells/Hunter.cs index 4ddbeff11..ae6724956 100644 --- a/Source/Scripts/Spells/Hunter.cs +++ b/Source/Scripts/Spells/Hunter.cs @@ -1,4 +1,4 @@ -// Copyright (c) CypherCore All rights reserved. +// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; @@ -6,7 +6,7 @@ using Game.Entities; using Game.Scripting; using Game.Spells; using System; -using System.Collections.Generic; +using static Global; namespace Scripts.Spells.Hunter { @@ -21,10 +21,15 @@ namespace Scripts.Spells.Hunter public const uint ExhilarationPet = 128594; public const uint ExhilarationR2 = 231546; public const uint ExplosiveShotDamage = 212680; - public const uint Lonewolf = 155228; + public const uint LatentPoisonStack = 378015; + public const uint LatentPoisonDamage = 378016; + public const uint LatentPoisonInjectorsStack = 336903; + public const uint LatentPoisonInjectorsDamage = 336904; + public const uint LoneWolf = 155228; public const uint MastersCallTriggered = 62305; public const uint Misdirection = 34477; public const uint MisdirectionProc = 35079; + public const uint MultiShotFocus = 213363; public const uint PetLastStandTriggered = 53479; public const uint PetHeartOfThePhoenixTriggered = 54114; public const uint PetHeartOfThePhoenixDebuff = 55711; @@ -34,8 +39,9 @@ namespace Scripts.Spells.Hunter public const uint RapidFireEnergize = 263585; public const uint SteadyShotFocus = 77443; public const uint T94PGreatness = 68130; - public const uint DraeneiGiftOfTheNaaru = 59543; + public const uint T292PMarksmanshipDamage = 394371; public const uint RoarOfSacrificeTriggered = 67481; + public const uint DraeneiGiftOfTheNaaru = 59543; } [Script] // 131894 - A Murder of Crows @@ -49,6 +55,7 @@ namespace Scripts.Spells.Hunter void HandleDummyTick(AuraEffect aurEff) { Unit target = GetTarget(); + Unit caster = GetCaster(); if (caster != null) caster.CastSpell(target, SpellIds.AMurderOfCrowsDamage, true); @@ -71,8 +78,8 @@ namespace Scripts.Spells.Hunter public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleDummyTick, 0, AuraType.PeriodicDummy)); - OnEffectRemove.Add(new EffectApplyHandler(RemoveEffect, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); + OnEffectPeriodic.Add(new(HandleDummyTick, 0, AuraType.PeriodicDummy)); + OnEffectRemove.Add(new(RemoveEffect, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); } } @@ -92,7 +99,26 @@ namespace Scripts.Spells.Hunter public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(HandleOnRemove, 0, AuraType.ModIncreaseSpeed, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(HandleOnRemove, 0, AuraType.ModIncreaseSpeed, AuraEffectHandleModes.Real)); + } + } + + [Script] // 378750 - Cobra Sting + class spell_hun_cobra_sting : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellEffect((spellInfo.Id, 1)); + } + + bool RollProc(AuraEffect aurEff, ProcEventInfo procInfo) + { + return RandomHelper.randChance(GetEffect(1).GetAmount()); + } + + public override void Register() + { + DoCheckEffectProc.Add(new(RollProc, 0, AuraType.ProcTriggerSpell)); } } @@ -101,18 +127,18 @@ namespace Scripts.Spells.Hunter { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.ExhilarationR2, SpellIds.Lonewolf); + return ValidateSpellInfo(SpellIds.ExhilarationR2, SpellIds.LoneWolf); } void HandleOnHit() { - if (GetCaster().HasAura(SpellIds.ExhilarationR2) && !GetCaster().HasAura(SpellIds.Lonewolf)) + if (GetCaster().HasAura(SpellIds.ExhilarationR2) && !GetCaster().HasAura(SpellIds.LoneWolf)) GetCaster().CastSpell(null, SpellIds.ExhilarationPet, true); } public override void Register() { - OnHit.Add(new HitHandler(HandleOnHit)); + OnHit.Add(new(HandleOnHit)); } } @@ -126,12 +152,14 @@ namespace Scripts.Spells.Hunter void HandlePeriodic(AuraEffect aurEff) { - GetCaster()?.CastSpell(GetTarget(), SpellIds.ExplosiveShotDamage, true); + Unit caster = GetCaster(); + if (caster != null) + caster.CastSpell(GetTarget(), SpellIds.ExplosiveShotDamage, true); } public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodic, 0, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandlePeriodic, 0, AuraType.PeriodicDummy)); } } @@ -152,12 +180,11 @@ namespace Scripts.Spells.Hunter public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } - // 53478 - Last Stand Pet - [Script] + [Script] // 53478 - Last Stand Pet class spell_hun_last_stand_pet : SpellScript { public override bool Validate(SpellInfo spellInfo) @@ -175,17 +202,109 @@ namespace Scripts.Spells.Hunter public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } - // 53271 - Masters Call - [Script] + [Script] // 378016 - Latent Poison + class spell_hun_latent_poison_damage : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.LatentPoisonStack); + } + + void CalculateDamage() + { + Aura stack = GetHitUnit().GetAura(SpellIds.LatentPoisonStack, GetCaster().GetGUID()); + if (stack != null) + { + SetHitDamage(GetHitDamage() * stack.GetStackAmount()); + stack.Remove(); + } + } + + public override void Register() + { + OnHit.Add(new(CalculateDamage)); + } + } + + // 19434 - Aimed Shot + // 186270 - Raptor Strike + // 217200 - Barbed Shot + [Script] // 259387 - Mongoose Bite + class spell_hun_latent_poison_trigger : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.LatentPoisonStack, SpellIds.LatentPoisonDamage); + } + + void TriggerDamage() + { + if (GetHitUnit().HasAura(SpellIds.LatentPoisonStack, GetCaster().GetGUID())) + GetCaster().CastSpell(GetHitUnit(), SpellIds.LatentPoisonDamage, GetSpell()); + } + + public override void Register() + { + AfterHit.Add(new(TriggerDamage)); + } + } + + [Script] // 336904 - Latent Poison Injectors + class spell_hun_latent_poison_injectors_damage : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.LatentPoisonInjectorsStack); + } + + void CalculateDamage() + { + Aura stack = GetHitUnit().GetAura(SpellIds.LatentPoisonInjectorsStack, GetCaster().GetGUID()); + if (stack != null) + { + SetHitDamage(GetHitDamage() * stack.GetStackAmount()); + stack.Remove(); + } + } + + public override void Register() + { + OnHit.Add(new(CalculateDamage)); + } + } + + // 186270 - Raptor Strike + [Script] // 259387 - Mongoose Bite + class spell_hun_latent_poison_injectors_trigger : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.LatentPoisonInjectorsStack, SpellIds.LatentPoisonInjectorsDamage); + } + + void TriggerDamage() + { + if (GetHitUnit().HasAura(SpellIds.LatentPoisonInjectorsStack, GetCaster().GetGUID())) + GetCaster().CastSpell(GetHitUnit(), SpellIds.LatentPoisonInjectorsDamage, GetSpell()); + } + + public override void Register() + { + AfterHit.Add(new(TriggerDamage)); + } + } + + [Script] // 53271 - Masters Call class spell_hun_masters_call : SpellScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 0) && ValidateSpellInfo(SpellIds.MastersCallTriggered, (uint)spellInfo.GetEffect(0).CalcValue()); + return ValidateSpellEffect((spellInfo.Id, 0)) + && ValidateSpellInfo(SpellIds.MastersCallTriggered, (uint)spellInfo.GetEffect(0).CalcValue()); } public override bool Load() @@ -196,26 +315,28 @@ namespace Scripts.Spells.Hunter SpellCastResult DoCheckCast() { Guardian pet = GetCaster().ToPlayer().GetGuardianPet(); - if (pet == null || !pet.IsPet() || !pet.IsAlive()) + Cypher.Assert(pet != null); // checked in Spell.CheckCast + + if (!pet.IsPet() || !pet.IsAlive()) return SpellCastResult.NoPet; - // Do a mini Spell::CheckCasterAuras on the pet, no other way of doing this + // Do a mini Spell.CheckCasterAuras on the pet, no other way of doing this SpellCastResult result = SpellCastResult.SpellCastOk; UnitFlags unitflag = (UnitFlags)(uint)pet.m_unitData.Flags; if (!pet.GetCharmerGUID().IsEmpty()) result = SpellCastResult.Charmed; - else if (unitflag.HasAnyFlag(UnitFlags.Stunned)) + else if (unitflag.HasFlag(UnitFlags.Stunned)) result = SpellCastResult.Stunned; - else if (unitflag.HasAnyFlag(UnitFlags.Fleeing)) + else if (unitflag.HasFlag(UnitFlags.Fleeing)) result = SpellCastResult.Fleeing; - else if (unitflag.HasAnyFlag(UnitFlags.Confused)) + else if (unitflag.HasFlag(UnitFlags.Confused)) result = SpellCastResult.Confused; if (result != SpellCastResult.SpellCastOk) return result; Unit target = GetExplTargetUnit(); - if (!target) + if (target == null) return SpellCastResult.BadTargets; if (!pet.IsWithinLOSInMap(target)) @@ -231,19 +352,19 @@ namespace Scripts.Spells.Hunter void HandleScriptEffect(uint effIndex) { - GetHitUnit().CastSpell((Unit)null, SpellIds.MastersCallTriggered, true); + GetHitUnit().CastSpell(null, SpellIds.MastersCallTriggered, true); } public override void Register() { - OnCheckCast.Add(new CheckCastHandler(DoCheckCast)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); + OnCheckCast.Add(new(DoCheckCast)); + + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); } } - // 34477 - Misdirection - [Script] + [Script] // 34477 - Misdirection class spell_hun_misdirection : AuraScript { public override bool Validate(SpellInfo spellInfo) @@ -263,18 +384,17 @@ namespace Scripts.Spells.Hunter void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.MisdirectionProc, new CastSpellExtraArgs(aurEff)); + GetTarget().CastSpell(GetTarget(), SpellIds.MisdirectionProc, aurEff); } public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); + AfterEffectRemove.Add(new(OnRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectProc.Add(new(HandleProc, 1, AuraType.Dummy)); } } - // 35079 - Misdirection (Proc) - [Script] + [Script] // 35079 - Misdirection (Proc) class spell_hun_misdirection_proc : AuraScript { void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) @@ -284,12 +404,37 @@ namespace Scripts.Spells.Hunter public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } - // 55709 - Pet Heart of the Phoenix - [Script] + [Script] // 2643 - Multi-Shot + class spell_hun_multi_shot : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.MultiShotFocus); + } + + public override bool Load() + { + return GetCaster().IsPlayer(); + } + + void HandleOnHit() + { + // We need to check hunter's spec because it doesn't generate focus on other specs than Mm + if (GetCaster().ToPlayer().GetPrimarySpecialization() == ChrSpecialization.HunterMarksmanship) + GetCaster().CastSpell(GetCaster(), SpellIds.MultiShotFocus, true); + } + + public override void Register() + { + OnHit.Add(new(HandleOnHit)); + } + } + + [Script] // 55709 - Pet Heart of the Phoenix class spell_hun_pet_heart_of_the_phoenix : SpellScript { public override bool Load() @@ -308,7 +453,7 @@ namespace Scripts.Spells.Hunter { Unit caster = GetCaster(); Unit owner = caster.GetOwner(); - if (owner) + if (owner != null) { if (!caster.HasAura(SpellIds.PetHeartOfThePhoenixDebuff)) { @@ -322,7 +467,7 @@ namespace Scripts.Spells.Hunter public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -345,7 +490,7 @@ namespace Scripts.Spells.Hunter public override void Register() { - AfterCast.Add(new CastHandler(HandleAfterCast)); + AfterCast.Add(new(HandleAfterCast)); } } @@ -366,7 +511,7 @@ namespace Scripts.Spells.Hunter public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodic, 1, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandlePeriodic, 1, AuraType.PeriodicDummy)); } } @@ -385,10 +530,10 @@ namespace Scripts.Spells.Hunter public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleHit, 0, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new(HandleHit, 0, SpellEffectName.SchoolDamage)); } } - + [Script] // 53480 - Roar of Sacrifice class spell_hun_roar_of_sacrifice : AuraScript { @@ -400,10 +545,10 @@ namespace Scripts.Spells.Hunter bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo) { DamageInfo damageInfo = eventInfo.GetDamageInfo(); - if (damageInfo == null || !Convert.ToBoolean((int)damageInfo.GetSchoolMask() & aurEff.GetMiscValue())) + if (damageInfo == null || (damageInfo.GetSchoolMask() & (SpellSchoolMask)aurEff.GetMiscValue()) == 0) return false; - if (!GetCaster()) + if (GetCaster() == null) return false; return true; @@ -420,24 +565,23 @@ namespace Scripts.Spells.Hunter public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckProc, 1, AuraType.Dummy)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); + DoCheckEffectProc.Add(new(CheckProc, 1, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 1, AuraType.Dummy)); } } - // 37506 - Scatter Shot - [Script] + [Script] // 37506 - Scatter Shot class spell_hun_scatter_shot : SpellScript { public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } void HandleDummy(uint effIndex) { Player caster = GetCaster().ToPlayer(); - // break auto Shot and varhit + // break var Shot and autohit caster.InterruptSpell(CurrentSpellTypes.AutoRepeat); caster.AttackStop(); caster.SendAttackSwingCancelAttack(); @@ -445,12 +589,11 @@ namespace Scripts.Spells.Hunter public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } - // 56641 - Steady Shot - [Script] + [Script] // 56641 - Steady Shot class spell_hun_steady_shot : SpellScript { public override bool Validate(SpellInfo spellInfo) @@ -460,7 +603,7 @@ namespace Scripts.Spells.Hunter public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } void HandleOnHit() @@ -470,15 +613,14 @@ namespace Scripts.Spells.Hunter public override void Register() { - OnHit.Add(new HitHandler(HandleOnHit)); + OnHit.Add(new(HandleOnHit)); } } - // 1515 - Tame Beast - [Script] + [Script] // 1515 - Tame Beast class spell_hun_tame_beast : SpellScript { - static uint[] CallPetSpellIds = { 883, 83242, 83243, 83244, 83245, }; + uint[] CallPetSpellIds = { 883, 83242, 83243, 83244, 83245, }; SpellCastResult CheckCast() { @@ -486,16 +628,16 @@ namespace Scripts.Spells.Hunter if (caster == null) return SpellCastResult.DontReport; - if (!GetExplTargetUnit()) + if (GetExplTargetUnit() == null) return SpellCastResult.BadImplicitTargets; Creature target = GetExplTargetUnit().ToCreature(); - if (target) + if (target != null) { if (target.GetLevelForTarget(caster) > caster.GetLevel()) return SpellCastResult.Highlevel; - // use SMSG_PET_TAME_FAILURE? + // use SmsgPetTameFailure? if (!target.GetCreatureTemplate().IsTameable(caster.CanTameExoticPets(), target.GetCreatureDifficulty())) return SpellCastResult.BadTargets; @@ -537,7 +679,7 @@ namespace Scripts.Spells.Hunter public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); + OnCheckCast.Add(new(CheckCast)); } } @@ -551,7 +693,7 @@ namespace Scripts.Spells.Hunter bool CheckProc(ProcEventInfo eventInfo) { - if (eventInfo.GetActor().IsTypeId(TypeId.Player) && eventInfo.GetActor().ToPlayer().GetPet()) + if (eventInfo.GetActor().IsPlayer() && eventInfo.GetActor().ToPlayer().GetPet() != null) return true; return false; } @@ -561,13 +703,41 @@ namespace Scripts.Spells.Hunter PreventDefaultAction(); Unit caster = eventInfo.GetActor(); - caster.CastSpell(caster.ToPlayer().GetPet(), SpellIds.T94PGreatness, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(caster.ToPlayer().GetPet(), SpellIds.T94PGreatness, aurEff); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); + } + } + + [Script] // 394366 - Find The Mark + class spell_hun_t29_2p_marksmanship_bonus : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellEffect((SpellIds.T292PMarksmanshipDamage, 0)) + && SpellMgr.GetSpellInfo(SpellIds.T292PMarksmanshipDamage, Difficulty.None).GetMaxTicks() != 0; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + + Unit caster = eventInfo.GetActor(); + uint ticks = SpellMgr.GetSpellInfo(SpellIds.T292PMarksmanshipDamage, Difficulty.None).GetMaxTicks(); + uint damage = MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetOriginalDamage(), aurEff.GetAmount()) / ticks; + + caster.CastSpell(eventInfo.GetActionTarget(), SpellIds.T292PMarksmanshipDamage, new CastSpellExtraArgs(aurEff) + .SetTriggeringSpell(eventInfo.GetProcSpell()) + .AddSpellMod(SpellValueMod.BasePoint0, (int)damage)); + } + + public override void Register() + { + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } } diff --git a/Source/Scripts/Spells/Items.cs b/Source/Scripts/Spells/Item.cs similarity index 51% rename from Source/Scripts/Spells/Items.cs rename to Source/Scripts/Spells/Item.cs index eb13c47e0..ca3717a32 100644 --- a/Source/Scripts/Spells/Items.cs +++ b/Source/Scripts/Spells/Item.cs @@ -1,4 +1,4 @@ -// Copyright (c) CypherCore All rights reserved. +// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; @@ -12,535 +12,28 @@ using Game.Spells; using System; using System.Collections.Generic; using System.Linq; +using static Global; -namespace Scripts.Spells.Items +namespace Scripts.Spells.Azerite { - struct SpellIds - { - //Aegisofpreservation - public const uint AegisHeal = 23781; - - //ZezzaksShard - public const uint EyeOfGrillok = 38495; - - // LowerCityPrayerbook - public const uint BlessingOfLowerCityDruid = 37878; - public const uint BlessingOfLowerCityPaladin = 37879; - public const uint BlessingOfLowerCityPriest = 37880; - public const uint BlessingOfLowerCityShaman = 37881; - - //Alchemiststone - public const uint AlchemistStoneExtraHeal = 21399; - public const uint AlchemistStoneExtraMana = 21400; - - //Angercapacitor - public const uint MoteOfAnger = 71432; - public const uint ManifestAngerMainHand = 71433; - public const uint ManifestAngerOffHand = 71434; - - //Auraofmadness - public const uint Sociopath = 39511; // Sociopath: +35 Strength(Paladin; Rogue; Druid; Warrior) - public const uint Delusional = 40997; // Delusional: +70 Attack Power(Rogue; Hunter; Paladin; Warrior; Druid) - public const uint Kleptomania = 40998; // Kleptomania: +35 Agility(Warrior; Rogue; Paladin; Hunter; Druid) - public const uint Megalomania = 40999; // Megalomania: +41 Damage / Healing(Druid; Shaman; Priest; Warlock; Mage; Paladin) - public const uint Paranoia = 41002; // Paranoia: +35 Spell / Melee / Ranged Crit Strike Rating(All Classes) - public const uint Manic = 41005; // Manic: +35 Haste(Spell; Melee And Ranged) (All Classes) - public const uint Narcissism = 41009; // Narcissism: +35 Intellect(Druid; Shaman; Priest; Warlock; Mage; Paladin; Hunter) - public const uint MartyrComplex = 41011; // Martyr Complex: +35 Stamina(All Classes) - public const uint Dementia = 41404; // Dementia: Every 5 Seconds Either Gives You +5/-5% Damage/Healing. (Druid; Shaman; Priest; Warlock; Mage; Paladin) - public const uint DementiaPos = 41406; - public const uint DementiaNeg = 41409; - - // BrittleArmor - public const uint BrittleArmor = 24575; - - //Blessingofancientkings - public const uint ProtectionOfAncientKings = 64413; - - //Deadlyprecision - public const uint DeadlyPrecision = 71564; - - //Deathbringerswill - public const uint StrengthOfTheTaunka = 71484; // +600 Strength - public const uint AgilityOfTheVrykul = 71485; // +600 Agility - public const uint PowerOfTheTaunka = 71486; // +1200 Attack Power - public const uint AimOfTheIronDwarves = 71491; // +600 Critical - public const uint SpeedOfTheVrykul = 71492; // +600 Haste - public const uint AgilityOfTheVrykulHero = 71556; // +700 Agility - public const uint PowerOfTheTaunkaHero = 71558; // +1400 Attack Power - public const uint AimOfTheIronDwarvesHero = 71559; // +700 Critical - public const uint SpeedOfTheVrykulHero = 71560; // +700 Haste - public const uint StrengthOfTheTaunkaHero = 71561; // +700 Strength - - //GoblinBombDispenser - public const uint SummonGoblinBomb = 13258; - public const uint MalfunctionExplosion = 13261; - - //GoblinWeatherMachine - public const uint PersonalizedWeather1 = 46740; - public const uint PersonalizedWeather2 = 46739; - public const uint PersonalizedWeather3 = 46738; - public const uint PersonalizedWeather4 = 46736; - - //Defibrillate - public const uint GoblinJumperCablesFail = 8338; - public const uint GoblinJumperCablesXlFail = 23055; - - //Desperatedefense - public const uint DesperateRage = 33898; - - //Deviatefishspells - public const uint Sleepy = 8064; - public const uint Invigorate = 8065; - public const uint Shrink = 8066; - public const uint PartyTime = 8067; - public const uint HealthySpirit = 8068; - public const uint Rejuvenation = 8070; - - //Discerningeyebeastmisc - public const uint DiscerningEyeBeast = 59914; - - //Fateruneofunsurpassedvigor - public const uint UnsurpassedVigor = 25733; - - //Flaskofthenorthspells - public const uint FlaskOfTheNorthSp = 67016; - public const uint FlaskOfTheNorthAp = 67017; - public const uint FlaskOfTheNorthStr = 67018; - - //Frozenshadoweave - public const uint Shadowmend = 39373; - - //Gnomishdeathray - public const uint GnomishDeathRaySelf = 13493; - public const uint GnomishDeathRayTarget = 13279; - - //Heartpierce - public const uint InvigorationMana = 71881; - public const uint InvigorationEnergy = 71882; - public const uint InvigorationRage = 71883; - public const uint InvigorationRp = 71884; - public const uint InvigorationRpHero = 71885; - public const uint InvigorationRageHero = 71886; - public const uint InvigorationEnergyHero = 71887; - public const uint InvigorationManaHero = 71888; - - //HourglassSand - public const uint BroodAfflictionBronze = 23170; - - //Makeawish - public const uint MrPinchysBlessing = 33053; - public const uint SummonMightyMrPinchy = 33057; - public const uint SummonFuriousMrPinchy = 33059; - public const uint TinyMagicalCrawdad = 33062; - public const uint MrPinchysGift = 33064; - - //Markofconquest - public const uint MarkOfConquestEnergize = 39599; - - // MercurialShield - public const uint MercurialShield = 26464; - - //MingoFortune - public const uint CreateFortune1 = 40804; - public const uint CreateFortune2 = 40805; - public const uint CreateFortune3 = 40806; - public const uint CreateFortune4 = 40807; - public const uint CreateFortune5 = 40808; - public const uint CreateFortune6 = 40809; - public const uint CreateFortune7 = 40908; - public const uint CreateFortune8 = 40910; - public const uint CreateFortune9 = 40911; - public const uint CreateFortune10 = 40912; - public const uint CreateFortune11 = 40913; - public const uint CreateFortune12 = 40914; - public const uint CreateFortune13 = 40915; - public const uint CreateFortune14 = 40916; - public const uint CreateFortune15 = 40918; - public const uint CreateFortune16 = 40919; - public const uint CreateFortune17 = 40920; - public const uint CreateFortune18 = 40921; - public const uint CreateFortune19 = 40922; - public const uint CreateFortune20 = 40923; - - //Necrotictouch - public const uint ItemNecroticTouchProc = 71879; - - //Netomaticspells - public const uint NetOMaticTriggered1 = 16566; - public const uint NetOMaticTriggered2 = 13119; - public const uint NetOMaticTriggered3 = 13099; - - //Noggenfoggerelixirspells - public const uint NoggenfoggerElixirTriggered1 = 16595; - public const uint NoggenfoggerElixirTriggered2 = 16593; - public const uint NoggenfoggerElixirTriggered3 = 16591; - - //Persistentshieldmisc - public const uint PersistentShieldTriggered = 26470; - - //Pethealing - public const uint HealthLink = 37382; - - //PowerCircle - public const uint LimitlessPower = 45044; - - //Savorydeviatedelight - public const uint FlipOutMale = 8219; - public const uint FlipOutFemale = 8220; - public const uint YaaarrrrMale = 8221; - public const uint YaaarrrrFemale = 8222; - - //Scrollofrecall - public const uint ScrollOfRecallI = 48129; - public const uint ScrollOfRecallII = 60320; - public const uint ScrollOfRecallIII = 60321; - public const uint Lost = 60444; - public const uint ScrollOfRecallFailAlliance1 = 60323; - public const uint ScrollOfRecallFailHorde1 = 60328; - - // TransporterSpells - public const uint EvilTwin = 23445; - public const uint TransporterMalfunctionFire = 23449; - public const uint TransporterMalfunctionSmaller = 36893; - public const uint TransporterMalfunctionBigger = 36895; - public const uint TransporterMalfunctionChicken = 36940; - public const uint TransformHorde = 36897; - public const uint TransformAlliance = 36899; - public const uint SoulSplitEvil = 36900; - public const uint SoulSplitGood = 36901; - - //Shadowsfate - public const uint SoulFeast = 71203; - - //Shadowmourne - public const uint ShadowmourneChaosBaneDamage = 71904; - public const uint ShadowmourneSoulFragment = 71905; - public const uint ShadowmourneVisualLow = 72521; - public const uint ShadowmourneVisualHigh = 72523; - public const uint ShadowmourneChaosBaneBuff = 73422; - - //Sixdemonbagspells - public const uint Frostbolt = 11538; - public const uint Polymorph = 14621; - public const uint SummonFelhoundMinion = 14642; - public const uint Fireball = 15662; - public const uint ChainLightning = 21179; - public const uint EnvelopingWinds = 25189; - - //Swifthandjusticemisc - public const uint SwiftHandOfJusticeHeal = 59913; - - //Underbellyelixirspells - public const uint UnderbellyElixirTriggered1 = 59645; - public const uint UnderbellyElixirTriggered2 = 59831; - public const uint UnderbellyElixirTriggered3 = 59843; - - //Wormholegeneratorpandariaspell - public const uint Wormholepandariaisleofreckoning = 126756; - public const uint Wormholepandariakunlaiunderwater = 126757; - public const uint Wormholepandariasravess = 126758; - public const uint Wormholepandariarikkitunvillage = 126759; - public const uint Wormholepandariazanvesstree = 126760; - public const uint Wormholepandariaanglerswharf = 126761; - public const uint Wormholepandariacranestatue = 126762; - public const uint Wormholepandariaemperorsomen = 126763; - public const uint Wormholepandariawhitepetallake = 126764; - - //Airriflespells - public const uint AirRifleHoldVisual = 65582; - public const uint AirRifleShoot = 67532; - public const uint AirRifleShootSelf = 65577; - - //Genericdata - public const uint ArcaniteDragonling = 19804; - public const uint BattleChicken = 13166; - public const uint MechanicalDragonling = 4073; - public const uint MithrilMechanicalDragonling = 12749; - - //Vanquishedclutchesspells - public const uint Crusher = 64982; - public const uint Constrictor = 64983; - public const uint Corruptor = 64984; - - //Magiceater - public const uint WildMagic = 58891; - public const uint WellFed1 = 57288; - public const uint WellFed2 = 57139; - public const uint WellFed3 = 57111; - public const uint WellFed4 = 57286; - public const uint WellFed5 = 57291; - - //Purifyhelboarmeat - public const uint SummonPurifiedHelboarMeat = 29277; - public const uint SummonToxicHelboarMeat = 29278; - - //Nighinvulnerability - public const uint NighInvulnerability = 30456; - public const uint CompleteVulnerability = 30457; - - //Poultryzer - public const uint PoultryizerSuccess = 30501; - public const uint PoultryizerBackfire = 30504; - - //Socretharsstone - public const uint SocretharToSeat = 35743; - public const uint SocretharFromSeat = 35744; - - //Demonbroiledsurprise - public const uint CreateDemonBroiledSurprise = 43753; - - //Completeraptorcapture - public const uint RaptorCaptureCredit = 42337; - - //Impaleleviroth - public const uint LevirothSelfImpale = 49882; - - //LifegivingGem - public const uint GiftOfLife1 = 23782; - public const uint GiftOfLife2 = 23783; - - //Nitroboots - public const uint NitroBoostsSuccess = 54861; - public const uint NitroBoostsBackfire = 46014; - public const uint NitroBoostsParachute = 54649; - - //Teachlanguage - public const uint LearnGnomishBinary = 50242; - public const uint LearnGoblinBinary = 50246; - - //Rocketboots - public const uint RocketBootsProc = 30452; - - //Pygmyoil - public const uint PygmyOilPygmyAura = 53806; - public const uint PygmyOilSmallerAura = 53805; - - //Chickencover - public const uint ChickenNet = 51959; - public const uint CaptureChickenEscape = 51037; - - //Greatmotherssoulcather - public const uint ForceCastSummonGnomeSoul = 46486; - - //Shardofthescale - public const uint PurifiedCauterizingHeal = 69733; - public const uint PurifiedSearingFlames = 69729; - public const uint ShinyCauterizingHeal = 69734; - public const uint ShinySearingFlames = 69730; - - //Soulpreserver - public const uint SoulPreserverDruid = 60512; - public const uint SoulPreserverPaladin = 60513; - public const uint SoulPreserverPriest = 60514; - public const uint SoulPreserverShaman = 60515; - - //ExaltedSunwellNeck - public const uint LightsWrath = 45479; // Light'S Wrath If Exalted By Aldor - public const uint ArcaneBolt = 45429; // Arcane Bolt If Exalted By Scryers - - public const uint LightsStrength = 45480; // Light'S Strength If Exalted By Aldor - public const uint ArcaneStrike = 45428; // Arcane Strike If Exalted By Scryers - - public const uint LightsWard = 45432; // Light'S Ward If Exalted By Aldor - public const uint ArcaneInsight = 45431; // Arcane Insight If Exalted By Scryers - - public const uint LightsSalvation = 45478; // Light'S Salvation If Exalted By Aldor - public const uint ArcaneSurge = 45430; // Arcane Surge If Exalted By Scryers - - //Deathchoicespells - public const uint DeathChoiceNormalAura = 67702; - public const uint DeathChoiceNormalAgility = 67703; - public const uint DeathChoiceNormalStrength = 67708; - public const uint DeathChoiceHeroicAura = 67771; - public const uint DeathChoiceHeroicAgility = 67772; - public const uint DeathChoiceHeroicStrength = 67773; - - //Trinketstackspells - public const uint LightningCapacitorAura = 37657; // Lightning Capacitor - public const uint LightningCapacitorStack = 37658; - public const uint LightningCapacitorTrigger = 37661; - public const uint ThunderCapacitorAura = 54841; // Thunder Capacitor - public const uint ThunderCapacitorStack = 54842; - public const uint ThunderCapacitorTrigger = 54843; - public const uint Toc25CasterTrinketNormalAura = 67712; // Item - Coliseum 25 Normal Caster Trinket - public const uint Toc25CasterTrinketNormalStack = 67713; - public const uint Toc25CasterTrinketNormalTrigger = 67714; - public const uint Toc25CasterTrinketHeroicAura = 67758; // Item - Coliseum 25 Heroic Caster Trinket - public const uint Toc25CasterTrinketHeroicStack = 67759; - public const uint Toc25CasterTrinketHeroicTrigger = 67760; - - //Darkmooncardspells - public const uint DarkmoonCardStrenght = 60229; - public const uint DarkmoonCardAgility = 60233; - public const uint DarkmoonCardIntellect = 60234; - public const uint DarkmoonCardVersatility = 60235; - - //Manadrainspells - public const uint ManaDrainEnergize = 29471; - public const uint ManaDrainLeech = 27526; - - //Tauntflag - public const uint TauntFlag = 51657; - - //MirrensDrinkingHat - public const uint LochModanLager = 29827; - public const uint StouthammerLite = 29828; - public const uint AeriePeakPaleAle = 29829; - - //MindControlCap - public const uint GnomishMindControlCap = 13181; - public const uint Dullard = 67809; - - //UniversalRemote - public const uint ControlMachine = 8345; - public const uint MobilityMalfunction = 8346; - public const uint TargetLock = 8347; - - //Zandalariancharms - public const uint UnstablePowerAuraStack = 24659; - public const uint RestlessStrengthAuraStack = 24662; - - // AuraprocRemovespells - public const uint TalismanOfAscendance = 28200; - public const uint JomGabbar = 29602; - public const uint BattleTrance = 45040; - public const uint WorldQuellerFocus = 90900; - public const uint BrutalKinship1 = 144671; - public const uint BrutalKinship2 = 145738; - - // Eggnog - public const uint EggNogReindeer = 21936; - public const uint EggNogSnowman = 21980; - - // HighfathersMachination - public const uint HighfathersTimekeepingHeal = 253288; - - //SeepingScourgewing - public const uint ShadowStrikeAoeCheck = 255861; - public const uint IsolatedStrike = 255609; - } - - struct TextIds - { - //Auraofmadness - public const uint SayMadness = 21954; - - //Roll Dice - public const uint DecahedralDwarvenDice = 26147; - - //Roll 'dem Bones - public const uint WornTrollDice = 26152; - - //TauntFlag - public const uint EmotePlantsFlag = 28008; - - //Feast - public const uint GreatFeast = 31843; - public const uint TextFishFeast = 31844; - public const uint TextGiganticFeast = 31846; - public const uint SmallFeast = 31845; - public const uint BountifulFeast = 35153; - } - - struct FactionIds - { - //ExaltedSunwellNeck - public const uint Aldor = 932; - public const uint Scryers = 934; - } - - struct ObjectIds - { - //Crystalprison - public const uint ImprisonedDoomguard = 179644; - } - - struct CreatureIds - { - //Shadowsfate - public const uint Sindragosa = 36853; - - //Giftoftheharvester - public const uint Ghoul = 28845; - public const uint MaxGhouls = 5; - - //Sinkholes - public const uint SouthSinkhole = 25664; - public const uint NortheastSinkhole = 25665; - public const uint NorthwestSinkhole = 25666; - - //Demonbroiledsurprise - public const uint AbyssalFlamebringer = 19973; - - //Impaleleviroth - public const uint Leviroth = 26452; - } - - struct ItemIds - { - //Createheartcandy - public const uint HeartCandy1 = 21818; - public const uint HeartCandy2 = 21817; - public const uint HeartCandy3 = 21821; - public const uint HeartCandy4 = 21819; - public const uint HeartCandy5 = 21816; - public const uint HeartCandy6 = 21823; - public const uint HeartCandy7 = 21822; - public const uint HeartCandy8 = 21820; - } - - struct QuestIds - { - //Demonbroiledsurprise - public const uint SuperHotStew = 11379; - - //Chickencover - public const uint ChickenParty = 12702; - public const uint FlownTheCoop = 12532; - } - - struct SoundIds - { - //Ashbringersounds - public const uint Ashbringer1 = 8906; // "I Was Pure Once" - public const uint Ashbringer2 = 8907; // "Fought For Righteousness" - public const uint Ashbringer3 = 8908; // "I Was Once Called Ashbringer" - public const uint Ashbringer4 = 8920; // "Betrayed By My Order" - public const uint Ashbringer5 = 8921; // "Destroyed By Kel'Thuzad" - public const uint Ashbringer6 = 8922; // "Made To Serve" - public const uint Ashbringer7 = 8923; // "My Son Watched Me Die" - public const uint Ashbringer8 = 8924; // "Crusades Fed His Rage" - public const uint Ashbringer9 = 8925; // "Truth Is Unknown To Him" - public const uint Ashbringer10 = 8926; // "Scarlet Crusade Is Pure No Longer" - public const uint Ashbringer11 = 8927; // "Balnazzar'S Crusade Corrupted My Son" - public const uint Ashbringer12 = 8928; // "Kill Them All!" - } - - struct ModelIds - { - //DireBrew - public const uint ClassClothMale = 25229; - public const uint ClassClothFemale = 25233; - public const uint ClassLeatherMale = 25230; - public const uint ClassLeatherFemale = 25234; - public const uint ClassMailMale = 25231; - public const uint ClassMailFemale = 25235; - public const uint ClassPlateMale = 25232; - public const uint ClassPlateFemale = 25236; - } - // 23074 Arcanite Dragonling + [Script("spell_item_arcanite_dragonling", SpellArcaniteDragonling)] // 23133 Gnomish Battle Chicken + [Script("spell_item_gnomish_battle_chicken", SpellBattleChicken)] // 23076 Mechanical Dragonling + [Script("spell_item_mechanical_dragonling", SpellMechanicalDragonling)] // 23075 Mithril Mechanical Dragonling - [Script("spell_item_arcanite_dragonling", SpellIds.ArcaniteDragonling)] - [Script("spell_item_gnomish_battle_chicken", SpellIds.BattleChicken)] - [Script("spell_item_mechanical_dragonling", SpellIds.MechanicalDragonling)] - [Script("spell_item_mithril_mechanical_dragonling", SpellIds.MithrilMechanicalDragonling)] - class spell_item_trigger_spell : SpellScript + [Script("spell_item_mithril_mechanical_dragonling", SpellMithrilMechanicalDragonling)] + class spell_item_trigger_spell_SpellScript : SpellScript { - public spell_item_trigger_spell(uint triggeredSpellId) + const uint SpellArcaniteDragonling = 19804; + const uint SpellBattleChicken = 13166; + const uint SpellMechanicalDragonling = 4073; + const uint SpellMithrilMechanicalDragonling = 12749; + + uint _triggeredSpellId; + + public spell_item_trigger_spell_SpellScript(uint triggeredSpellId) { _triggeredSpellId = triggeredSpellId; } @@ -554,69 +47,76 @@ namespace Scripts.Spells.Items { Unit caster = GetCaster(); Item item = GetCastItem(); - if (item) - caster.CastSpell(caster, _triggeredSpellId, new CastSpellExtraArgs(item)); + if (item != null) + caster.CastSpell(caster, _triggeredSpellId, item); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } - - uint _triggeredSpellId; } [Script] // 23780 - Aegis of Preservation class spell_item_aegis_of_preservation : AuraScript { + const uint SpellAegisHeal = 23781; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.AegisHeal); + return ValidateSpellInfo(SpellAegisHeal); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.AegisHeal, new CastSpellExtraArgs(aurEff)); + GetTarget().CastSpell(GetTarget(), SpellAegisHeal, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.PeriodicTriggerSpell)); + OnEffectProc.Add(new(HandleProc, 1, AuraType.ProcTriggerSpell)); } } [Script] // 38554 - Absorb Eye of Grillok (31463: Zezzak's Shard) class spell_item_absorb_eye_of_grillok : AuraScript { + const uint SpellEyeOfGrillok = 38495; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.EyeOfGrillok); + return ValidateSpellInfo(SpellEyeOfGrillok); } void PeriodicTick(AuraEffect aurEff) { PreventDefaultAction(); - if (!GetCaster() || !GetTarget().IsTypeId(TypeId.Unit)) + if (GetCaster() == null || GetTarget().GetTypeId() != TypeId.Unit) return; - GetCaster().CastSpell(GetCaster(), SpellIds.EyeOfGrillok, new CastSpellExtraArgs(aurEff)); + GetCaster().CastSpell(GetCaster(), SpellEyeOfGrillok, aurEff); GetTarget().ToCreature().DespawnOrUnsummon(); } public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(PeriodicTick, 0, AuraType.PeriodicTriggerSpell)); + OnEffectPeriodic.Add(new(PeriodicTick, 0, AuraType.PeriodicTriggerSpell)); } } - // 37877 - Blessing of Faith + [Script] // 37877 - Blessing of Faith class spell_item_blessing_of_faith : SpellScript { + const uint SpellBlessingOfLowerCityDruid = 37878; + const uint SpellBlessingOfLowerCityPaladin = 37879; + const uint SpellBlessingOfLowerCityPriest = 37880; + const uint SpellBlessingOfLowerCityShaman = 37881; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.BlessingOfLowerCityDruid, SpellIds.BlessingOfLowerCityPaladin, SpellIds.BlessingOfLowerCityPriest, SpellIds.BlessingOfLowerCityShaman); + return ValidateSpellInfo(SpellBlessingOfLowerCityDruid, SpellBlessingOfLowerCityPaladin, SpellBlessingOfLowerCityPriest, SpellBlessingOfLowerCityShaman); } void HandleDummy(uint effIndex) @@ -624,20 +124,20 @@ namespace Scripts.Spells.Items Unit unitTarget = GetHitUnit(); if (unitTarget != null) { - uint spellId = 0; + uint spellId; switch (unitTarget.GetClass()) { case Class.Druid: - spellId = SpellIds.BlessingOfLowerCityDruid; + spellId = SpellBlessingOfLowerCityDruid; break; case Class.Paladin: - spellId = SpellIds.BlessingOfLowerCityPaladin; + spellId = SpellBlessingOfLowerCityPaladin; break; case Class.Priest: - spellId = SpellIds.BlessingOfLowerCityPriest; + spellId = SpellBlessingOfLowerCityPriest; break; case Class.Shaman: - spellId = SpellIds.BlessingOfLowerCityShaman; + spellId = SpellBlessingOfLowerCityShaman; break; default: return; // ignore for non-healing classes @@ -650,7 +150,7 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -658,16 +158,20 @@ namespace Scripts.Spells.Items // Item - 35748: Guardian's Alchemist Stone // Item - 35749: Sorcerer's Alchemist Stone // Item - 35750: Redeemer's Alchemist Stone - // Item - 35751: Assassin's Alchemist Stone + // Item - 35751: AssasMath.Sin's Alchemist Stone // Item - 44322: Mercurial Alchemist Stone // Item - 44323: Indestructible Alchemist's Stone // Item - 44324: Mighty Alchemist's Stone + [Script] // 17619 - Alchemist Stone class spell_item_alchemist_stone : AuraScript { + const uint SpellAlchemistStoneExtraHeal = 21399; + const uint SpellAlchemistStoneExtraMana = 21400; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.AlchemistStoneExtraHeal, SpellIds.AlchemistStoneExtraMana); + return ValidateSpellInfo(SpellAlchemistStoneExtraHeal, SpellAlchemistStoneExtraMana); } bool CheckProc(ProcEventInfo eventInfo) @@ -683,9 +187,9 @@ namespace Scripts.Spells.Items int amount = (int)(eventInfo.GetDamageInfo().GetDamage() * 0.4f); if (eventInfo.GetDamageInfo().GetSpellInfo().HasEffect(SpellEffectName.Heal)) - spellId = SpellIds.AlchemistStoneExtraHeal; + spellId = SpellAlchemistStoneExtraHeal; else if (eventInfo.GetDamageInfo().GetSpellInfo().HasEffect(SpellEffectName.Energize)) - spellId = SpellIds.AlchemistStoneExtraMana; + spellId = SpellAlchemistStoneExtraMana; if (spellId == 0) return; @@ -693,32 +197,39 @@ namespace Scripts.Spells.Items Unit caster = eventInfo.GetActionTarget(); CastSpellExtraArgs args = new(aurEff); args.AddSpellMod(SpellValueMod.BasePoint0, amount); - caster.CastSpell((Unit)null, spellId, args); + caster.CastSpell(null, spellId, args); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } // Item - 50351: Tiny Abomination in a Jar // 71406 - Anger Capacitor + // Item - 50706: Tiny Abomination in a Jar (Heroic) // 71545 - Anger Capacitor [Script("spell_item_tiny_abomination_in_a_jar", 8)] [Script("spell_item_tiny_abomination_in_a_jar_hero", 7)] - class spell_item_anger_capacitor : AuraScript + class spell_item_anger_capacitor_AuraScript : AuraScript { - public spell_item_anger_capacitor(int stackAmount) + const uint SpellMoteOfAnger = 71432; + const uint SpellManifestAngerMainHand = 71433; + const uint SpellManifestAngerOffHand = 71434; + + uint _stacks; + + public spell_item_anger_capacitor_AuraScript(uint stacks) { - _stackAmount = stackAmount; + _stacks = stacks; } public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.MoteOfAnger, SpellIds.ManifestAngerMainHand, SpellIds.ManifestAngerOffHand); + return ValidateSpellInfo(SpellMoteOfAnger, SpellManifestAngerMainHand, SpellManifestAngerOffHand); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -727,33 +238,31 @@ namespace Scripts.Spells.Items Unit caster = eventInfo.GetActor(); Unit target = eventInfo.GetProcTarget(); - caster.CastSpell((Unit)null, SpellIds.MoteOfAnger, true); - Aura motes = caster.GetAura(SpellIds.MoteOfAnger); - if (motes == null || motes.GetStackAmount() < _stackAmount) + caster.CastSpell(null, SpellMoteOfAnger, true); + Aura motes = caster.GetAura(SpellMoteOfAnger); + if (motes == null || motes.GetStackAmount() < _stacks) return; - caster.RemoveAurasDueToSpell(SpellIds.MoteOfAnger); - uint spellId = SpellIds.ManifestAngerMainHand; + caster.RemoveAurasDueToSpell(SpellMoteOfAnger); + uint spellId = SpellManifestAngerMainHand; Player player = caster.ToPlayer(); - if (player) - if (player.GetWeaponForAttack(WeaponAttackType.OffAttack, true) && RandomHelper.URand(0, 1) != 0) - spellId = SpellIds.ManifestAngerOffHand; + if (player != null) + if (player.GetWeaponForAttack(WeaponAttackType.OffAttack, true) != null && RandomHelper.randChance(50)) + spellId = SpellManifestAngerOffHand; - caster.CastSpell(target, spellId, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(target, spellId, aurEff); } void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - GetTarget().RemoveAurasDueToSpell(SpellIds.MoteOfAnger); + GetTarget().RemoveAurasDueToSpell(SpellMoteOfAnger); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); + AfterEffectRemove.Add(new(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } - - int _stackAmount; } [Script] // 26400 - Arcane Shroud @@ -761,14 +270,14 @@ namespace Scripts.Spells.Items { void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - int diff = (int)GetUnitOwner().GetLevel() - 60; + int diff = (int)(GetUnitOwner().GetLevel() - 60); if (diff > 0) amount += 2 * diff; } public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModThreat)); + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.ModThreat)); } } @@ -776,102 +285,121 @@ namespace Scripts.Spells.Items [Script] // 39446 - Aura of Madness class spell_item_aura_of_madness : AuraScript { + const uint SpellSociopath = 39511; // Sociopath: +35 strength(Paladin, Rogue, Druid, Warrior) + const uint SpellDelusional = 40997; // Delusional: +70 attack power(Rogue, Hunter, Paladin, Warrior, Druid) + const uint SpellKleptomania = 40998; // Kleptomania: +35 agility(Warrior, Rogue, Paladin, Hunter, Druid) + const uint SpellMegalomania = 40999; // Megalomania: +41 damage / healing(Druid, Shaman, Priest, Warlock, Mage, Paladin) + const uint SpellParanoia = 41002; // Paranoia: +35 spell / melee / ranged crit strike rating(All classes) + const uint SpellManic = 41005; // Manic: +35 haste(spell, melee and ranged) (All classes) + const uint SpellNarcissism = 41009; // Narcissism: +35 intellect(Druid, Shaman, Priest, Warlock, Mage, Paladin, Hunter) + const uint SpellMartyrComplex = 41011; // Martyr Complex: +35 stamina(All classes) + const uint SpellDementia = 41404; // Dementia: Every 5 seconds either gives you +5/-5% damage/healing. (Druid, Shaman, Priest, Warlock, Mage, Paladin) + + const uint SayMadness = 21954; + public override bool Validate(SpellInfo spellInfo) { - return CliDB.BroadcastTextStorage.ContainsKey(TextIds.SayMadness) && ValidateSpellInfo(SpellIds.Sociopath, SpellIds.Delusional, SpellIds.Kleptomania, - SpellIds.Megalomania, SpellIds.Paranoia, SpellIds.Manic, SpellIds.Narcissism, SpellIds.MartyrComplex, SpellIds.Dementia); + return ValidateSpellInfo(SpellSociopath, SpellDelusional, SpellKleptomania, SpellMegalomania, SpellParanoia, SpellManic, SpellNarcissism, SpellMartyrComplex, SpellDementia) && CliDB.BroadcastTextStorage.ContainsKey(SayMadness); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { uint[][] triggeredSpells = { - //CLASS_NONE - Array.Empty(), - //CLASS_WARRIOR - new uint[] {SpellIds.Sociopath, SpellIds.Delusional, SpellIds.Kleptomania, SpellIds.Paranoia, SpellIds.Manic, SpellIds.MartyrComplex }, - //CLASS_PALADIN - new uint[] {SpellIds.Sociopath, SpellIds.Delusional, SpellIds.Kleptomania, SpellIds.Megalomania, SpellIds.Paranoia, SpellIds.Manic, SpellIds.Narcissism, SpellIds.MartyrComplex, SpellIds.Dementia }, - //CLASS_HUNTER - new uint[] {SpellIds.Delusional, SpellIds.Megalomania, SpellIds.Paranoia, SpellIds.Manic, SpellIds.Narcissism, SpellIds.MartyrComplex, SpellIds.Dementia }, - //CLASS_ROGUE - new uint[] {SpellIds.Sociopath, SpellIds.Delusional, SpellIds.Kleptomania, SpellIds.Paranoia, SpellIds.Manic, SpellIds.MartyrComplex }, - //CLASS_PRIEST - new uint[] {SpellIds.Megalomania, SpellIds.Paranoia, SpellIds.Manic, SpellIds.Narcissism, SpellIds.MartyrComplex, SpellIds.Dementia }, - //CLASS_DEATH_KNIGHT - new uint[] {SpellIds.Sociopath, SpellIds.Delusional, SpellIds.Kleptomania, SpellIds.Paranoia, SpellIds.Manic, SpellIds.MartyrComplex }, - //CLASS_SHAMAN - new uint[] {SpellIds.Megalomania, SpellIds.Paranoia, SpellIds.Manic, SpellIds.Narcissism, SpellIds.MartyrComplex, SpellIds.Dementia }, - //CLASS_MAGE - new uint[] {SpellIds.Megalomania, SpellIds.Paranoia, SpellIds.Manic, SpellIds.Narcissism, SpellIds.MartyrComplex, SpellIds.Dementia }, - //CLASS_WARLOCK - new uint[] {SpellIds.Megalomania, SpellIds.Paranoia, SpellIds.Manic, SpellIds.Narcissism, SpellIds.MartyrComplex, SpellIds.Dementia }, - //CLASS_UNK - Array.Empty(), - //CLASS_DRUID - new uint[] {SpellIds.Sociopath, SpellIds.Delusional, SpellIds.Kleptomania, SpellIds.Megalomania, SpellIds.Paranoia, SpellIds.Manic, SpellIds.Narcissism, SpellIds.MartyrComplex, SpellIds.Dementia } - }; + //ClassNone + Array.Empty(), + //ClassWarrior + new uint[] { SpellSociopath, SpellDelusional, SpellKleptomania, SpellParanoia, SpellManic, SpellMartyrComplex }, + //ClassPaladin + new uint[] { SpellSociopath, SpellDelusional, SpellKleptomania, SpellMegalomania, SpellParanoia, SpellManic, SpellNarcissism, SpellMartyrComplex, SpellDementia }, + //ClassHunter + new uint[] { SpellDelusional, SpellMegalomania, SpellParanoia, SpellManic, SpellNarcissism, SpellMartyrComplex, SpellDementia }, + //ClassRogue + new uint[] { SpellSociopath, SpellDelusional, SpellKleptomania, SpellParanoia, SpellManic, SpellMartyrComplex }, + //ClassPriest + new uint[] { SpellMegalomania, SpellParanoia, SpellManic, SpellNarcissism, SpellMartyrComplex, SpellDementia }, + //ClassDeathKnight + new uint[] { SpellSociopath, SpellDelusional, SpellKleptomania, SpellParanoia, SpellManic, SpellMartyrComplex }, + //ClassShaman + new uint[] { SpellMegalomania, SpellParanoia, SpellManic, SpellNarcissism, SpellMartyrComplex, SpellDementia }, + //ClassMage + new uint[] { SpellMegalomania, SpellParanoia, SpellManic, SpellNarcissism, SpellMartyrComplex, SpellDementia }, + //ClassWarlock + new uint[] { SpellMegalomania, SpellParanoia, SpellManic, SpellNarcissism, SpellMartyrComplex, SpellDementia }, + //ClassUnk + Array.Empty(), + //ClassDruid + new uint[] { SpellSociopath, SpellDelusional, SpellKleptomania, SpellMegalomania, SpellParanoia, SpellManic, SpellNarcissism, SpellMartyrComplex, SpellDementia } + }; + PreventDefaultAction(); Unit caster = eventInfo.GetActor(); uint spellId = triggeredSpells[(int)caster.GetClass()].SelectRandom(); - caster.CastSpell(caster, spellId, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(caster, spellId, aurEff); if (RandomHelper.randChance(10)) - caster.Say(TextIds.SayMadness); + caster.Say(SayMadness); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } [Script] // 41404 - Dementia class spell_item_dementia : AuraScript { + const uint SpellDementiaPos = 41406; + const uint SpellDementiaNeg = 41409; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.DementiaPos, SpellIds.DementiaNeg); + return ValidateSpellInfo(SpellDementiaPos, SpellDementiaNeg); } void HandlePeriodicDummy(AuraEffect aurEff) { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), RandomHelper.RAND(SpellIds.DementiaPos, SpellIds.DementiaNeg), new CastSpellExtraArgs(aurEff)); + GetTarget().CastSpell(GetTarget(), RandomHelper.RAND(SpellDementiaPos, SpellDementiaNeg), aurEff); } public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodicDummy, 0, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandlePeriodicDummy, 0, AuraType.PeriodicDummy)); } } - [Script]// 24590 - Brittle Armor + [Script] // 24590 - Brittle Armor class spell_item_brittle_armor : SpellScript { + const uint SpellBrittleArmor = 24575; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.BrittleArmor); + return ValidateSpellInfo(SpellBrittleArmor); } void HandleScript(uint effIndex) { - GetHitUnit().RemoveAuraFromStack(SpellIds.BrittleArmor); + GetHitUnit().RemoveAuraFromStack(SpellBrittleArmor); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 64411 - Blessing of Ancient Kings (Val'anyr, Hammer of Ancient Kings) class spell_item_blessing_of_ancient_kings : AuraScript { + const uint SpellProtectionOfAncientKings = 64413; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.ProtectionOfAncientKings); + return ValidateSpellInfo(SpellProtectionOfAncientKings); } bool CheckProc(ProcEventInfo eventInfo) @@ -888,7 +416,7 @@ namespace Scripts.Spells.Items return; int absorb = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), 15.0f); - AuraEffect protEff = eventInfo.GetProcTarget().GetAuraEffect(SpellIds.ProtectionOfAncientKings, 0, eventInfo.GetActor().GetGUID()); + AuraEffect protEff = eventInfo.GetProcTarget().GetAuraEffect(SpellProtectionOfAncientKings, 0, eventInfo.GetActor().GetGUID()); if (protEff != null) { // The shield can grow to a maximum size of 20,000 damage absorbtion @@ -901,14 +429,14 @@ namespace Scripts.Spells.Items { CastSpellExtraArgs args = new(aurEff); args.AddSpellMod(SpellValueMod.BasePoint0, absorb); - GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.ProtectionOfAncientKings, args); + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellProtectionOfAncientKings, args); } } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -922,7 +450,7 @@ namespace Scripts.Spells.Items public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); + DoCheckProc.Add(new(CheckProc)); } } @@ -937,21 +465,23 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleStackDrop, 0, AuraType.ModRating)); + OnEffectProc.Add(new(HandleStackDrop, 0, AuraType.ModRating)); } } [Script] // 71563 - Deadly Precision Dummy class spell_item_deadly_precision_dummy : SpellScript { + const uint SpellDeadlyPrecision = 71564; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.DeadlyPrecision); + return ValidateSpellInfo(SpellDeadlyPrecision); } void HandleDummy(uint effIndex) { - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.DeadlyPrecision, GetCastDifficulty()); + SpellInfo spellInfo = SpellMgr.GetSpellInfo(SpellDeadlyPrecision, GetCastDifficulty()); CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); args.AddSpellMod(SpellValueMod.AuraStack, (int)spellInfo.StackAmount); GetCaster().CastSpell(GetCaster(), spellInfo.Id, args); @@ -959,7 +489,7 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ApplyAura)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.ApplyAura)); } } @@ -968,53 +498,72 @@ namespace Scripts.Spells.Items // Item - 50363: Deathbringer's Will // 71562 - Item - Icecrown 25 Heroic Melee Trinket - [Script("spell_item_deathbringers_will_normal", SpellIds.StrengthOfTheTaunka, SpellIds.AgilityOfTheVrykul, SpellIds.PowerOfTheTaunka, SpellIds.AimOfTheIronDwarves, SpellIds.SpeedOfTheVrykul)] - [Script("spell_item_deathbringers_will_heroic", SpellIds.StrengthOfTheTaunkaHero, SpellIds.AgilityOfTheVrykulHero, SpellIds.PowerOfTheTaunkaHero, SpellIds.AimOfTheIronDwarvesHero, SpellIds.SpeedOfTheVrykulHero)] - class spell_item_deathbringers_will : AuraScript + [Script("spell_item_deathbringers_will_normal", SpellStrengthOfTheTaunka, SpellAgilityOfTheVrykul, SpellPowerOfTheTaunka, SpellAimOfTheIronDwarves, SpellSpeedOfTheVrykul)] + [Script("spell_item_deathbringers_will_heroic", SpellStrengthOfTheTaunkaHero, SpellAgilityOfTheVrykulHero, SpellPowerOfTheTaunkaHero, SpellAimOfTheIronDwarvesHero, SpellSpeedOfTheVrykulHero)] + class spell_item_deathbringers_will_AuraScript : AuraScript { - public spell_item_deathbringers_will(uint strengthSpellId, uint agilitySpellId, uint apSpellId, uint criticalSpellId, uint hasteSpellId) + const uint SpellStrengthOfTheTaunka = 71484; // +600 Strength + const uint SpellAgilityOfTheVrykul = 71485; // +600 Agility + const uint SpellPowerOfTheTaunka = 71486; // +1200 Attack Power + const uint SpellAimOfTheIronDwarves = 71491; // +600 Critical + const uint SpellSpeedOfTheVrykul = 71492; // +600 Haste + + const uint SpellAgilityOfTheVrykulHero = 71556; // +700 Agility + const uint SpellPowerOfTheTaunkaHero = 71558; // +1400 Attack Power + const uint SpellAimOfTheIronDwarvesHero = 71559; // +700 Critical + const uint SpellSpeedOfTheVrykulHero = 71560; // +700 Haste + const uint SpellStrengthOfTheTaunkaHero = 71561; // +700 Strength + + uint _strength; + uint _agility; + uint _attackPower; + uint _critical; + uint _haste; + + public spell_item_deathbringers_will_AuraScript(uint strength, uint agility, uint attackPower, uint critical, uint haste) { - _strengthSpellId = strengthSpellId; - _agilitySpellId = agilitySpellId; - _apSpellId = apSpellId; - _criticalSpellId = criticalSpellId; - _hasteSpellId = hasteSpellId; + _strength = strength; + _agility = agility; + _attackPower = attackPower; + _critical = critical; + _haste = haste; } public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(_strengthSpellId, _agilitySpellId, _apSpellId, _criticalSpellId, _hasteSpellId); + return ValidateSpellInfo(_strength, _agility, _attackPower, _critical, _haste); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { uint[][] triggeredSpells = { - //CLASS_NONE - Array.Empty(), - //CLASS_WARRIOR - new uint[] {_strengthSpellId, _criticalSpellId, _hasteSpellId }, - //CLASS_PALADIN - new uint[] { _strengthSpellId, _criticalSpellId, _hasteSpellId }, - //CLASS_HUNTER - new uint[] {_agilitySpellId, _criticalSpellId, _apSpellId }, - //CLASS_ROGUE - new uint[] {_agilitySpellId, _hasteSpellId, _apSpellId }, - //CLASS_PRIEST - Array.Empty(), - //CLASS_DEATH_KNIGHT - new uint[] {_strengthSpellId, _criticalSpellId, _hasteSpellId }, - //CLASS_SHAMAN - new uint[] {_agilitySpellId, _hasteSpellId, _apSpellId }, - //CLASS_MAGE - Array.Empty(), - //CLASS_WARLOCK - Array.Empty(), - //CLASS_UNK - Array.Empty(), - //CLASS_DRUID - new uint[] {_strengthSpellId, _agilitySpellId, _hasteSpellId } - }; + //ClassNone + Array.Empty(), + //ClassWarrior + new uint[] { _strength, _critical, _haste }, + //ClassPaladin + new uint[] { _strength, _critical, _haste }, + //ClassHunter + new uint[] { _agility, _critical, _attackPower }, + //ClassRogue + new uint[] { _agility, _haste, _attackPower }, + //ClassPriest + Array.Empty(), + //ClassDeathKnight + new uint[] { _strength, _critical, _haste }, + //ClassShaman + new uint[] { _agility, _haste, _attackPower }, + //ClassMage + Array.Empty(), + //ClassWarlock + Array.Empty(), + //ClassUnk + Array.Empty(), + //ClassDruid + new uint[] { _strength, _agility, _haste } + }; + PreventDefaultAction(); Unit caster = eventInfo.GetActor(); @@ -1023,39 +572,35 @@ namespace Scripts.Spells.Items return; uint spellId = randomSpells.SelectRandom(); - caster.CastSpell(caster, spellId, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(caster, spellId, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } - - uint _strengthSpellId; - uint _agilitySpellId; - uint _apSpellId; - uint _criticalSpellId; - uint _hasteSpellId; } [Script] // 47770 - Roll Dice class spell_item_decahedral_dwarven_dice : SpellScript { + const uint TextDecahedralDwarvenDice = 26147; + public override bool Validate(SpellInfo spellInfo) { - if (!CliDB.BroadcastTextStorage.ContainsKey(TextIds.DecahedralDwarvenDice)) + if (!CliDB.BroadcastTextStorage.ContainsKey(TextDecahedralDwarvenDice)) return false; return true; } public override bool Load() { - return GetCaster().GetTypeId() == TypeId.Player; + return GetCaster().IsPlayer(); } void HandleScript(uint effIndex) { - GetCaster().TextEmote(TextIds.DecahedralDwarvenDice, GetHitUnit()); + GetCaster().TextEmote(TextDecahedralDwarvenDice, GetHitUnit()); uint minimum = 1; uint maximum = 100; @@ -1065,57 +610,71 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 23134 - Goblin Bomb class spell_item_goblin_bomb_dispenser : SpellScript { + const uint SpellSummonGoblinBomb = 13258; + const uint SpellMalfunctionExplosion = 13261; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.SummonGoblinBomb, SpellIds.MalfunctionExplosion); + return ValidateSpellInfo(SpellSummonGoblinBomb, SpellMalfunctionExplosion); } void HandleDummy(uint effIndex) { Item item = GetCastItem(); if (item != null) - GetCaster().CastSpell(GetCaster(), RandomHelper.randChance(95) ? SpellIds.SummonGoblinBomb : SpellIds.MalfunctionExplosion, item); + GetCaster().CastSpell(GetCaster(), RandomHelper.randChance(95) ? SpellSummonGoblinBomb : SpellMalfunctionExplosion, item); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 46203 - Goblin Weather Machine class spell_item_goblin_weather_machine : SpellScript { + const uint SpellPersonalizedWeather1 = 46740; + const uint SpellPersonalizedWeather2 = 46739; + const uint SpellPersonalizedWeather3 = 46738; + const uint SpellPersonalizedWeather4 = 46736; + void HandleScript(uint effIndex) { Unit target = GetHitUnit(); - uint spellId = RandomHelper.RAND(SpellIds.PersonalizedWeather1, SpellIds.PersonalizedWeather2, SpellIds.PersonalizedWeather3, SpellIds.PersonalizedWeather4); - target.CastSpell(target, spellId, new CastSpellExtraArgs(GetSpell())); + uint spellId = RandomHelper.RAND(SpellPersonalizedWeather1, SpellPersonalizedWeather2, SpellPersonalizedWeather3, SpellPersonalizedWeather4); + target.CastSpell(target, spellId, GetSpell()); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } // 8342 - Defibrillate (Goblin Jumper Cables) have 33% chance on success - // 22999 - Defibrillate (Goblin Jumper Cables XL) have 50% chance on success + // 22999 - Defibrillate (Goblin Jumper Cables Xl) have 50% chance on success // 54732 - Defibrillate (Gnomish Army Knife) have 67% chance on success - [Script("spell_item_goblin_jumper_cables", 33u, SpellIds.GoblinJumperCablesFail)] - [Script("spell_item_goblin_jumper_cables_xl", 50u, SpellIds.GoblinJumperCablesXlFail)] - [Script("spell_item_gnomish_army_knife", 67u, 0u)] - class spell_item_defibrillate : SpellScript + [Script("spell_item_goblin_jumper_cables", 67, SpellGoblinJumperCablesFail)] + [Script("spell_item_goblin_jumper_cables_xl", 50, SpellGoblinJumperCablesXlFail)] + [Script("spell_item_gnomish_army_knife", 33, 0u)] + class spell_item_defibrillate_SpellScript : SpellScript { - public spell_item_defibrillate(uint chance, uint failSpell) + const uint SpellGoblinJumperCablesFail = 8338; + const uint SpellGoblinJumperCablesXlFail = 23055; + + byte _chance; + uint _failSpell; + + public spell_item_defibrillate_SpellScript(byte chance, uint failSpell) { _chance = chance; _failSpell = failSpell; @@ -1123,9 +682,7 @@ namespace Scripts.Spells.Items public override bool Validate(SpellInfo spellInfo) { - if (_failSpell != 0 && !ValidateSpellInfo(_failSpell)) - return false; - return true; + return _failSpell == 0 || ValidateSpellInfo(_failSpell); } void HandleScript(uint effIndex) @@ -1134,36 +691,35 @@ namespace Scripts.Spells.Items { PreventHitDefaultEffect(effIndex); if (_failSpell != 0) - GetCaster().CastSpell(GetCaster(), _failSpell, new CastSpellExtraArgs(GetCastItem())); + GetCaster().CastSpell(GetCaster(), _failSpell, GetCastItem()); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Resurrect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.Resurrect)); } - - uint _chance; - uint _failSpell; } [Script] // 33896 - Desperate Defense class spell_item_desperate_defense : AuraScript { + const uint SpellDesperateRage = 33898; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.DesperateRage); + return ValidateSpellInfo(SpellDesperateRage); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.DesperateRage, new CastSpellExtraArgs(aurEff)); + GetTarget().CastSpell(GetTarget(), SpellDesperateRage, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 2, AuraType.PeriodicTriggerSpell)); + OnEffectProc.Add(new(HandleProc, 2, AuraType.ProcTriggerSpell)); } } @@ -1171,31 +727,40 @@ namespace Scripts.Spells.Items [Script] // 8063 Deviate Fish class spell_item_deviate_fish : SpellScript { + const uint SpellSleepy = 8064; + const uint SpellInvigorate = 8065; + const uint SpellShrink = 8066; + const uint SpellPartyTime = 8067; + const uint SpellHealthySpirit = 8068; + const uint SpellRejuvenation = 8070; + public override bool Load() { - return GetCaster().GetTypeId() == TypeId.Player; + return GetCaster().IsPlayer(); } public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.Sleepy, SpellIds.Invigorate, SpellIds.Shrink, SpellIds.PartyTime, SpellIds.HealthySpirit, SpellIds.Rejuvenation); + return ValidateSpellInfo(SpellSleepy, SpellInvigorate, SpellShrink, SpellPartyTime, SpellHealthySpirit, SpellRejuvenation); } void HandleDummy(uint effIndex) { Unit caster = GetCaster(); - uint spellId = RandomHelper.RAND(SpellIds.Sleepy, SpellIds.Invigorate, SpellIds.Shrink, SpellIds.PartyTime, SpellIds.HealthySpirit, SpellIds.Rejuvenation); + uint spellId = RandomHelper.RAND(SpellSleepy, SpellInvigorate, SpellShrink, SpellPartyTime, SpellHealthySpirit, SpellRejuvenation); caster.CastSpell(caster, spellId, true); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } class PartyTimeEmoteEvent : BasicEvent { + const uint SpellPartyTime = 8067; + Player _player; public PartyTimeEmoteEvent(Player player) @@ -1205,7 +770,7 @@ namespace Scripts.Spells.Items public override bool Execute(ulong time, uint diff) { - if (!_player.HasAura(SpellIds.PartyTime)) + if (!_player.HasAura(SpellPartyTime)) return true; if (_player.IsMoving()) @@ -1213,9 +778,9 @@ namespace Scripts.Spells.Items else _player.HandleEmoteCommand(RandomHelper.RAND(Emote.OneshotApplaud, Emote.OneshotDancespecial, Emote.OneshotLaugh, Emote.OneshotCheer, Emote.OneshotChicken)); - _player.m_Events.AddEventAtOffset(this, TimeSpan.FromSeconds(RandomHelper.RAND(5, 10, 15))); + _player.m_Events.AddEventAtOffset(this, RandomHelper.RAND(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(15))); - return false; // do not delete re-added event in EventProcessor::Update + return false; // do not delete re-added event in EventProcessor.Update } } @@ -1228,15 +793,27 @@ namespace Scripts.Spells.Items if (player == null) return; - player.m_Events.AddEventAtOffset(new PartyTimeEmoteEvent(player), TimeSpan.FromSeconds(RandomHelper.RAND(5, 10, 15))); + player.m_Events.AddEventAtOffset(new PartyTimeEmoteEvent(player), RandomHelper.RAND(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(15))); } public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } + struct DireBrewModels + { + public const uint ClothMale = 25229; + public const uint ClothFemale = 25233; + public const uint LeatherMale = 25230; + public const uint LeatherFemale = 25234; + public const uint MailMale = 25231; + public const uint MailFemale = 25235; + public const uint PlateMale = 25232; + public const uint PlateFemale = 25236; + } + [Script] // 51010 - Dire Brew class spell_item_dire_brew : AuraScript { @@ -1245,16 +822,16 @@ namespace Scripts.Spells.Items Unit target = GetTarget(); uint model = 0; - var gender = target.GetGender(); - var chrClass = CliDB.ChrClassesStorage.LookupByKey(target.GetClass()); + Gender gender = target.GetGender(); + ChrClassesRecord chrClass = CliDB.ChrClassesStorage.LookupByKey(target.GetClass()); if ((chrClass.ArmorTypeMask & (1 << (int)ItemSubClassArmor.Plate)) != 0) - model = gender == Gender.Male ? ModelIds.ClassPlateMale : ModelIds.ClassPlateFemale; + model = gender == Gender.Male ? DireBrewModels.PlateMale : DireBrewModels.PlateFemale; else if ((chrClass.ArmorTypeMask & (1 << (int)ItemSubClassArmor.Mail)) != 0) - model = gender == Gender.Male ? ModelIds.ClassMailMale : ModelIds.ClassMailFemale; + model = gender == Gender.Male ? DireBrewModels.MailMale : DireBrewModels.MailFemale; else if ((chrClass.ArmorTypeMask & (1 << (int)ItemSubClassArmor.Leather)) != 0) - model = gender == Gender.Male ? ModelIds.ClassLeatherMale : ModelIds.ClassLeatherFemale; + model = gender == Gender.Male ? DireBrewModels.LeatherMale : DireBrewModels.LeatherFemale; else if ((chrClass.ArmorTypeMask & (1 << (int)ItemSubClassArmor.Cloth)) != 0) - model = gender == Gender.Male ? ModelIds.ClassClothMale : ModelIds.ClassClothFemale; + model = gender == Gender.Male ? DireBrewModels.ClothMale : DireBrewModels.ClothFemale; if (model != 0) target.SetDisplayId(model); @@ -1262,27 +839,29 @@ namespace Scripts.Spells.Items public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(AfterApply, 0, AuraType.Transform, AuraEffectHandleModes.Real)); + AfterEffectApply.Add(new(AfterApply, 0, AuraType.Transform, AuraEffectHandleModes.Real)); } } [Script] // 59915 - Discerning Eye of the Beast Dummy class spell_item_discerning_eye_beast_dummy : AuraScript { + const uint SpellDiscerningEyeBeast = 59914; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.DiscerningEyeBeast); + return ValidateSpellInfo(SpellDiscerningEyeBeast); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - eventInfo.GetActor().CastSpell((Unit)null, SpellIds.DiscerningEyeBeast, new CastSpellExtraArgs(aurEff)); + eventInfo.GetActor().CastSpell(null, SpellDiscerningEyeBeast, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1303,7 +882,7 @@ namespace Scripts.Spells.Items public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitDestAreaAlly)); } } @@ -1315,8 +894,8 @@ namespace Scripts.Spells.Items PreventDefaultAction(); // move loot to player inventory and despawn target - if (GetCaster() != null && GetCaster().IsTypeId(TypeId.Player) && - GetTarget().IsTypeId(TypeId.Unit) && + if (GetCaster() != null && GetCaster().IsPlayer() && + GetTarget().GetTypeId() == TypeId.Unit && GetTarget().ToCreature().GetCreatureTemplate().CreatureType == CreatureType.GasCloud) { Player player = GetCaster().ToPlayer(); @@ -1333,37 +912,49 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(PeriodicTick, 0, AuraType.PeriodicTriggerSpell)); + OnEffectPeriodic.Add(new(PeriodicTick, 0, AuraType.PeriodicTriggerSpell)); } } [Script] // 7434 - Fate Rune of Unsurpassed Vigor class spell_item_fate_rune_of_unsurpassed_vigor : AuraScript { + const uint SpellUnsurpassedVigor = 25733; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.UnsurpassedVigor); + return ValidateSpellInfo(SpellUnsurpassedVigor); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.UnsurpassedVigor, true); + GetTarget().CastSpell(GetTarget(), SpellUnsurpassedVigor, true); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } - [Script("spell_item_great_feast", TextIds.GreatFeast)] - [Script("spell_item_fish_feast", TextIds.TextFishFeast)] - [Script("spell_item_gigantic_feast", TextIds.TextGiganticFeast)] - [Script("spell_item_small_feast", TextIds.SmallFeast)] - [Script("spell_item_bountiful_feast", TextIds.BountifulFeast)] + //57426 - Fish Feast + //58465 - Gigantic Feast + //58474 - Small Feast + //66476 - Bountiful Feast + [Script("spell_item_great_feast", TextGreatFeast)] + [Script("spell_item_fish_feast", TextFishFeast)] + [Script("spell_item_gigantic_feast", TextGiganticFeast)] + [Script("spell_item_small_feast", TextSmallFeast)] + [Script("spell_item_bountiful_feast", TextBountifulFeast)] class spell_item_feast : SpellScript { + const uint TextGreatFeast = 31843; + const uint TextFishFeast = 31844; + const uint TextGiganticFeast = 31846; + const uint TextSmallFeast = 31845; + const uint TextBountifulFeast = 35153; + uint _text; public spell_item_feast(uint text) @@ -1384,7 +975,7 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHit.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -1392,9 +983,13 @@ namespace Scripts.Spells.Items [Script] // 67019 Flask of the North class spell_item_flask_of_the_north : SpellScript { + const uint SpellFlaskOfTheNorthSp = 67016; + const uint SpellFlaskOfTheNorthAp = 67017; + const uint SpellFlaskOfTheNorthStr = 67018; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.FlaskOfTheNorthSp, SpellIds.FlaskOfTheNorthAp, SpellIds.FlaskOfTheNorthStr); + return ValidateSpellInfo(SpellFlaskOfTheNorthSp, SpellFlaskOfTheNorthAp, SpellFlaskOfTheNorthStr); } void HandleDummy(uint effIndex) @@ -1406,30 +1001,30 @@ namespace Scripts.Spells.Items case Class.Warlock: case Class.Mage: case Class.Priest: - possibleSpells.Add(SpellIds.FlaskOfTheNorthSp); + possibleSpells.Add(SpellFlaskOfTheNorthSp); break; case Class.Deathknight: case Class.Warrior: - possibleSpells.Add(SpellIds.FlaskOfTheNorthStr); + possibleSpells.Add(SpellFlaskOfTheNorthStr); break; case Class.Rogue: case Class.Hunter: - possibleSpells.Add(SpellIds.FlaskOfTheNorthAp); + possibleSpells.Add(SpellFlaskOfTheNorthAp); break; case Class.Druid: case Class.Paladin: - possibleSpells.Add(SpellIds.FlaskOfTheNorthSp); - possibleSpells.Add(SpellIds.FlaskOfTheNorthStr); + possibleSpells.Add(SpellFlaskOfTheNorthSp); + possibleSpells.Add(SpellFlaskOfTheNorthStr); break; case Class.Shaman: - possibleSpells.Add(SpellIds.FlaskOfTheNorthSp); - possibleSpells.Add(SpellIds.FlaskOfTheNorthAp); + possibleSpells.Add(SpellFlaskOfTheNorthSp); + possibleSpells.Add(SpellFlaskOfTheNorthAp); break; } if (possibleSpells.Empty()) { - Log.outWarn(LogFilter.Spells, "Missing spells for class {0} in script spell_item_flask_of_the_north", caster.GetClass()); + Log.outWarn(LogFilter.Spells, $"Missing spells for class {caster.GetClass()} in script spell_item_flask_of_the_north"); return; } @@ -1438,7 +1033,7 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -1446,9 +1041,11 @@ namespace Scripts.Spells.Items [Script] // Frozen Shadoweave set 3p bonus class spell_item_frozen_shadoweave : AuraScript { + const uint SpellShadowmend = 39373; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.Shadowmend); + return ValidateSpellInfo(SpellShadowmend); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -1461,12 +1058,12 @@ namespace Scripts.Spells.Items Unit caster = eventInfo.GetActor(); CastSpellExtraArgs args = new(aurEff); args.AddSpellMod(SpellValueMod.BasePoint0, (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount())); - caster.CastSpell((Unit)null, SpellIds.Shadowmend, args); + caster.CastSpell(null, SpellShadowmend, args); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1474,27 +1071,52 @@ namespace Scripts.Spells.Items [Script] // 13280 Gnomish Death Ray class spell_item_gnomish_death_ray : SpellScript { + const uint SpellGnomishDeathRaySelf = 13493; + const uint SpellGnomishDeathRayTarget = 13279; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.GnomishDeathRaySelf, SpellIds.GnomishDeathRayTarget); + return ValidateSpellInfo(SpellGnomishDeathRaySelf, SpellGnomishDeathRayTarget); } void HandleDummy(uint effIndex) { Unit caster = GetCaster(); Unit target = GetHitUnit(); - if (target) + if (target != null) { if (RandomHelper.URand(0, 99) < 15) - caster.CastSpell(caster, SpellIds.GnomishDeathRaySelf, true); // failure + caster.CastSpell(caster, SpellGnomishDeathRaySelf, true); // failure else - caster.CastSpell(target, SpellIds.GnomishDeathRayTarget, true); + caster.CastSpell(target, SpellGnomishDeathRayTarget, true); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + // Item 10721: Gnomish Harm Prevention Belt + [Script] // 13234 - Harm Prevention Belt + class spell_item_harm_prevention_belt : AuraScript + { + const uint SpellForcefieldCollapse = 13235; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellForcefieldCollapse); + } + + void HandleProc(ProcEventInfo eventInfo) + { + GetTarget().CastSpell(null, SpellForcefieldCollapse, true); + } + + public override void Register() + { + OnProc.Add(new(HandleProc)); } } @@ -1503,21 +1125,36 @@ namespace Scripts.Spells.Items // Item - 50641: Heartpierce (Heroic) // 71892 - Item - Icecrown 25 Heroic Dagger Proc - [Script("spell_item_heartpierce", SpellIds.InvigorationEnergy, SpellIds.InvigorationMana, SpellIds.InvigorationRage, SpellIds.InvigorationRp)] - [Script("spell_item_heartpierce_hero", SpellIds.InvigorationEnergyHero, SpellIds.InvigorationManaHero, SpellIds.InvigorationRageHero, SpellIds.InvigorationRpHero)] + [Script("spell_item_heartpierce", SpellInvigorationEnergy, SpellInvigorationMana, SpellInvigorationRage, SpellInvigorationRp)] + [Script("spell_item_heartpierce_hero", SpellInvigorationEnergyHero, SpellInvigorationManaHero, SpellInvigorationRageHero, SpellInvigorationRpHero)] class spell_item_heartpierce : AuraScript { - public spell_item_heartpierce(uint energySpellId, uint manaSpellId, uint rageSpellId, uint rpSpellId) + const uint SpellInvigorationMana = 71881; + const uint SpellInvigorationEnergy = 71882; + const uint SpellInvigorationRage = 71883; + const uint SpellInvigorationRp = 71884; + + const uint SpellInvigorationRpHero = 71885; + const uint SpellInvigorationRageHero = 71886; + const uint SpellInvigorationEnergyHero = 71887; + const uint SpellInvigorationManaHero = 71888; + + uint _energy; + uint _mana; + uint _rage; + uint _runicPower; + + public spell_item_heartpierce(uint energy, uint mana, uint rage, uint runicPower) { - _energySpellId = energySpellId; - _manaSpellId = manaSpellId; - _rageSpellId = rageSpellId; - _rpSpellId = rpSpellId; + _energy = energy; + _mana = mana; + _rage = rage; + _runicPower = runicPower; } public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(_energySpellId, _manaSpellId, _rageSpellId, _rpSpellId); + return ValidateSpellInfo(_energy, _mana, _rage, _runicPower); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -1529,52 +1166,49 @@ namespace Scripts.Spells.Items switch (caster.GetPowerType()) { case PowerType.Mana: - spellId = _manaSpellId; + spellId = _mana; break; case PowerType.Energy: - spellId = _energySpellId; + spellId = _energy; break; case PowerType.Rage: - spellId = _rageSpellId; + spellId = _rage; break; // Death Knights can't use daggers, but oh well case PowerType.RunicPower: - spellId = _rpSpellId; + spellId = _runicPower; break; default: return; } - caster.CastSpell((Unit)null, spellId, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(null, spellId, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } - - uint _energySpellId; - uint _manaSpellId; - uint _rageSpellId; - uint _rpSpellId; } [Script] // 23645 - Hourglass Sand class spell_item_hourglass_sand : SpellScript { + const uint SpellBroodAfflictionBronze = 23170; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.BroodAfflictionBronze); + return ValidateSpellInfo(SpellBroodAfflictionBronze); } void HandleDummy(uint effIndex) { - GetCaster().RemoveAurasDueToSpell(SpellIds.BroodAfflictionBronze); + GetCaster().RemoveAurasDueToSpell(SpellBroodAfflictionBronze); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -1583,7 +1217,7 @@ namespace Scripts.Spells.Items { public override bool Validate(SpellInfo spellInfo) { - return !spellInfo.GetEffects().Empty(); + return ValidateSpellEffect((spellInfo.Id, 0)); } bool CheckProc(ProcEventInfo eventInfo) @@ -1593,7 +1227,7 @@ namespace Scripts.Spells.Items if (healInfo != null) { Unit healTarget = healInfo.GetTarget(); - if (healTarget) + if (healTarget != null) if (healTarget.GetHealth() - healInfo.GetEffectiveHeal() <= healTarget.CountPctFromMaxHealth(pct)) return true; } @@ -1603,7 +1237,7 @@ namespace Scripts.Spells.Items public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); + DoCheckProc.Add(new(CheckProc)); } } @@ -1611,41 +1245,39 @@ namespace Scripts.Spells.Items [Script] // 33060 Make a Wish class spell_item_make_a_wish : SpellScript { + const uint SpellMrPinchysBlessing = 33053; + const uint SpellSummonMightyMrPinchy = 33057; + const uint SpellSummonFuriousMrPinchy = 33059; + const uint SpellTinyMagicalCrawdad = 33062; + const uint SpellMrPinchysGift = 33064; + public override bool Load() { - return GetCaster().GetTypeId() == TypeId.Player; + return GetCaster().IsPlayer(); } public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.MrPinchysBlessing, SpellIds.SummonMightyMrPinchy, SpellIds.SummonFuriousMrPinchy, SpellIds.TinyMagicalCrawdad, SpellIds.MrPinchysGift); + return ValidateSpellInfo(SpellMrPinchysBlessing, SpellSummonMightyMrPinchy, SpellSummonFuriousMrPinchy, SpellTinyMagicalCrawdad, SpellMrPinchysGift); } void HandleDummy(uint effIndex) { Unit caster = GetCaster(); - uint spellId = SpellIds.MrPinchysGift; + uint spellId = SpellMrPinchysGift; switch (RandomHelper.URand(1, 5)) { - case 1: - spellId = SpellIds.MrPinchysBlessing; - break; - case 2: - spellId = SpellIds.SummonMightyMrPinchy; - break; - case 3: - spellId = SpellIds.SummonFuriousMrPinchy; - break; - case 4: - spellId = SpellIds.TinyMagicalCrawdad; - break; + case 1: spellId = SpellMrPinchysBlessing; break; + case 2: spellId = SpellSummonMightyMrPinchy; break; + case 3: spellId = SpellSummonFuriousMrPinchy; break; + case 4: spellId = SpellTinyMagicalCrawdad; break; } caster.CastSpell(caster, spellId, true); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -1654,9 +1286,11 @@ namespace Scripts.Spells.Items [Script] // 33510 - Health Restore class spell_item_mark_of_conquest : AuraScript { + const uint SpellMarkOfConquestEnergize = 39599; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.MarkOfConquestEnergize); + return ValidateSpellInfo(SpellMarkOfConquestEnergize); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -1666,32 +1300,34 @@ namespace Scripts.Spells.Items // in that case, do not cast heal spell PreventDefaultAction(); // but mana instead - eventInfo.GetActor().CastSpell((Unit)null, SpellIds.MarkOfConquestEnergize, new CastSpellExtraArgs(aurEff)); + eventInfo.GetActor().CastSpell(null, SpellMarkOfConquestEnergize, aurEff); } } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); } } - [Script]// 26465 - Mercurial Shield + [Script] // 26465 - Mercurial Shield class spell_item_mercurial_shield : SpellScript { + const uint SpellMercurialShield = 26464; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.MercurialShield); + return ValidateSpellInfo(SpellMercurialShield); } void HandleScript(uint effIndex) { - GetHitUnit().RemoveAuraFromStack(SpellIds.MercurialShield); + GetHitUnit().RemoveAuraFromStack(SpellMercurialShield); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -1701,10 +1337,10 @@ namespace Scripts.Spells.Items { uint[] CreateFortuneSpells = { - SpellIds.CreateFortune1, SpellIds.CreateFortune2, SpellIds.CreateFortune3, SpellIds.CreateFortune4, SpellIds.CreateFortune5, - SpellIds.CreateFortune6, SpellIds.CreateFortune7, SpellIds.CreateFortune8, SpellIds.CreateFortune9, SpellIds.CreateFortune10, - SpellIds.CreateFortune11, SpellIds.CreateFortune12, SpellIds.CreateFortune13, SpellIds.CreateFortune14, SpellIds.CreateFortune15, - SpellIds.CreateFortune16, SpellIds.CreateFortune17, SpellIds.CreateFortune18, SpellIds.CreateFortune19, SpellIds.CreateFortune20 + 40804, 40805, 40806, 40807, 40808, + 40809, 40908, 40910, 40911, 40912, + 40913, 40914, 40915, 40916, 40918, + 40919, 40920, 40921, 40922, 40923 }; public override bool Validate(SpellInfo spellInfo) @@ -1719,21 +1355,23 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 71875, 71877 - Item - Black Bruise: Necrotic Touch Proc class spell_item_necrotic_touch : AuraScript { + const uint SpellItemNecroticTouchProc = 71879; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.ItemNecroticTouchProc); + return ValidateSpellInfo(SpellItemNecroticTouchProc); } bool CheckProc(ProcEventInfo eventInfo) { - return eventInfo.GetProcTarget() && eventInfo.GetProcTarget().IsAlive(); + return eventInfo.GetProcTarget() != null && eventInfo.GetProcTarget().IsAlive(); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -1745,13 +1383,13 @@ namespace Scripts.Spells.Items CastSpellExtraArgs args = new(aurEff); args.AddSpellMod(SpellValueMod.BasePoint0, (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount())); - GetTarget().CastSpell((Unit)null, SpellIds.ItemNecroticTouchProc, args); + GetTarget().CastSpell(null, SpellItemNecroticTouchProc, args); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1759,22 +1397,26 @@ namespace Scripts.Spells.Items [Script] // 13120 Net-o-Matic class spell_item_net_o_matic : SpellScript { + const uint SpellNetOMaticTriggered1 = 16566; + const uint SpellNetOMaticTriggered2 = 13119; + const uint SpellNetOMaticTriggered3 = 13099; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.NetOMaticTriggered1, SpellIds.NetOMaticTriggered2, SpellIds.NetOMaticTriggered3); + return ValidateSpellInfo(SpellNetOMaticTriggered1, SpellNetOMaticTriggered2, SpellNetOMaticTriggered3); } void HandleDummy(uint effIndex) { Unit target = GetHitUnit(); - if (target) + if (target != null) { - uint spellId = SpellIds.NetOMaticTriggered3; + uint spellId = SpellNetOMaticTriggered3; uint roll = RandomHelper.URand(0, 99); if (roll < 2) // 2% for 30 sec self root (off-like chance unknown) - spellId = SpellIds.NetOMaticTriggered1; + spellId = SpellNetOMaticTriggered1; else if (roll < 4) // 2% for 20 sec root, charge to target (off-like chance unknown) - spellId = SpellIds.NetOMaticTriggered2; + spellId = SpellNetOMaticTriggered2; GetCaster().CastSpell(target, spellId, true); } @@ -1782,7 +1424,7 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -1790,28 +1432,28 @@ namespace Scripts.Spells.Items [Script] // 16589 Noggenfogger Elixir class spell_item_noggenfogger_elixir : SpellScript { + const uint SpellNoggenfoggerElixirTriggered1 = 16595; + const uint SpellNoggenfoggerElixirTriggered2 = 16593; + const uint SpellNoggenfoggerElixirTriggered3 = 16591; + public override bool Load() { - return GetCaster().GetTypeId() == TypeId.Player; + return GetCaster().IsPlayer(); } public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.NoggenfoggerElixirTriggered1, SpellIds.NoggenfoggerElixirTriggered2, SpellIds.NoggenfoggerElixirTriggered3); + return ValidateSpellInfo(SpellNoggenfoggerElixirTriggered1, SpellNoggenfoggerElixirTriggered2, SpellNoggenfoggerElixirTriggered3); } void HandleDummy(uint effIndex) { Unit caster = GetCaster(); - uint spellId = SpellIds.NoggenfoggerElixirTriggered3; + uint spellId = SpellNoggenfoggerElixirTriggered3; switch (RandomHelper.URand(1, 3)) { - case 1: - spellId = SpellIds.NoggenfoggerElixirTriggered1; - break; - case 2: - spellId = SpellIds.NoggenfoggerElixirTriggered2; - break; + case 1: spellId = SpellNoggenfoggerElixirTriggered1; break; + case 2: spellId = SpellNoggenfoggerElixirTriggered2; break; } caster.CastSpell(caster, spellId, true); @@ -1819,7 +1461,7 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -1831,8 +1473,8 @@ namespace Scripts.Spells.Items Spell spell = eventInfo.GetProcSpell(); if (spell != null) { - var costs = spell.GetPowerCost(); - var m = costs.FirstOrDefault(cost => cost.Power == PowerType.Mana && cost.Amount > 0); + var cost = spell.GetPowerCost(); + var m = cost.Find(cost => cost.Power == PowerType.Mana && cost.Amount > 0); if (m != null) return true; } @@ -1842,16 +1484,18 @@ namespace Scripts.Spells.Items public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); + DoCheckProc.Add(new(CheckProc)); } } [Script] // 26467 - Persistent Shield class spell_item_persistent_shield : AuraScript { + const uint SpellPersistentShieldTriggered = 26470; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.PersistentShieldTriggered); + return ValidateSpellInfo(SpellPersistentShieldTriggered); } bool CheckProc(ProcEventInfo eventInfo) @@ -1866,20 +1510,19 @@ namespace Scripts.Spells.Items int bp0 = (int)MathFunctions.CalculatePct(eventInfo.GetHealInfo().GetHeal(), 15); // Scarab Brooch does not replace stronger shields - AuraEffect shield = target.GetAuraEffect(SpellIds.PersistentShieldTriggered, 0, caster.GetGUID()); - if (shield != null) - if (shield.GetAmount() > bp0) - return; + AuraEffect shield = target.GetAuraEffect(SpellPersistentShieldTriggered, 0, caster.GetGUID()); + if (shield != null && shield.GetAmount() > bp0) + return; CastSpellExtraArgs args = new(aurEff); args.AddSpellMod(SpellValueMod.BasePoint0, bp0); - caster.CastSpell(target, SpellIds.PersistentShieldTriggered, args); + caster.CastSpell(target, SpellPersistentShieldTriggered, args); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); } } @@ -1888,9 +1531,11 @@ namespace Scripts.Spells.Items [Script] // Warlock T5 2P Bonus class spell_item_pet_healing : AuraScript { + const uint SpellHealthLink = 37382; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.HealthLink); + return ValidateSpellInfo(SpellHealthLink); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -1902,12 +1547,12 @@ namespace Scripts.Spells.Items CastSpellExtraArgs args = new(aurEff); args.AddSpellMod(SpellValueMod.BasePoint0, (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount())); - eventInfo.GetActor().CastSpell((Unit)null, SpellIds.HealthLink, args); + eventInfo.GetActor().CastSpell(null, SpellHealthLink, args); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1918,22 +1563,24 @@ namespace Scripts.Spells.Items { PreventHitDefaultEffect(effIndex); Player target = GetHitPlayer(); - if (target) + if (target != null) target.HandleEmoteCommand(Emote.StateDance); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 45043 - Power Circle (Shifting Naaru Sliver) class spell_item_power_circle : AuraScript { + const uint SpellLimitlessPower = 45044; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.LimitlessPower); + return ValidateSpellInfo(SpellLimitlessPower); } bool CheckCaster(Unit target) @@ -1943,22 +1590,22 @@ namespace Scripts.Spells.Items void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - GetTarget().CastSpell(null, SpellIds.LimitlessPower, true); - Aura buff = GetTarget().GetAura(SpellIds.LimitlessPower); - if (buff != null) - buff.SetDuration(GetDuration()); + GetTarget().CastSpell(null, SpellLimitlessPower, true); + Aura buff = GetTarget().GetAura(SpellLimitlessPower); + buff?.SetDuration(GetDuration()); } void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - GetTarget().RemoveAurasDueToSpell(SpellIds.LimitlessPower); + GetTarget().RemoveAurasDueToSpell(SpellLimitlessPower); } public override void Register() { - DoCheckAreaTarget.Add(new CheckAreaTargetHandler(CheckCaster)); - AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + DoCheckAreaTarget.Add(new(CheckCaster)); + + AfterEffectApply.Add(new(OnApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -1966,14 +1613,19 @@ namespace Scripts.Spells.Items [Script] // 8213 Savory Deviate Delight class spell_item_savory_deviate_delight : SpellScript { + const uint SpellFlipOutMale = 8219; + const uint SpellFlipOutFemale = 8220; + const uint SpellYaaarrrrMale = 8221; + const uint SpellYaaarrrrFemale = 8222; + public override bool Load() { - return GetCaster().GetTypeId() == TypeId.Player; + return GetCaster().IsPlayer(); } public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.FlipOutMale, SpellIds.FlipOutFemale, SpellIds.YaaarrrrMale, SpellIds.YaaarrrrFemale); + return ValidateSpellInfo(SpellFlipOutMale, SpellFlipOutFemale, SpellYaaarrrrMale, SpellYaaarrrrFemale); } void HandleDummy(uint effIndex) @@ -1983,27 +1635,34 @@ namespace Scripts.Spells.Items switch (RandomHelper.URand(1, 2)) { // Flip Out - ninja - case 1: spellId = (caster.GetNativeGender() == Gender.Male ? SpellIds.FlipOutMale : SpellIds.FlipOutFemale); break; + case 1: spellId = (caster.GetNativeGender() == Gender.Male ? SpellFlipOutMale : SpellFlipOutFemale); break; // Yaaarrrr - pirate - case 2: spellId = (caster.GetNativeGender() == Gender.Male ? SpellIds.YaaarrrrMale : SpellIds.YaaarrrrFemale); break; + case 2: spellId = (caster.GetNativeGender() == Gender.Male ? SpellYaaarrrrMale : SpellYaaarrrrFemale); break; } caster.CastSpell(caster, spellId, true); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } // 48129 - Scroll of Recall - // 60320 - Scroll of Recall II - [Script] // 60321 - Scroll of Recall III + // 60320 - Scroll of Recall Ii + [Script] // 60321 - Scroll of Recall Iii class spell_item_scroll_of_recall : SpellScript { + const uint SpellScrollOfRecallI = 48129; + const uint SpellScrollOfRecallIi = 60320; + const uint SpellScrollOfRecallIii = 60321; + const uint SpellLost = 60444; + const uint SpellScrollOfRecallFailAlliance1 = 60323; + const uint SpellScrollOfRecallFailHorde1 = 60328; + public override bool Load() { - return GetCaster().GetTypeId() == TypeId.Player; + return GetCaster().IsPlayer(); } void HandleScript(uint effIndex) @@ -2012,13 +1671,13 @@ namespace Scripts.Spells.Items byte maxSafeLevel = 0; switch (GetSpellInfo().Id) { - case SpellIds.ScrollOfRecallI: // Scroll of Recall + case SpellScrollOfRecallI: // Scroll of Recall maxSafeLevel = 40; break; - case SpellIds.ScrollOfRecallII: // Scroll of Recall II + case SpellScrollOfRecallIi: // Scroll of Recall Ii maxSafeLevel = 70; break; - case SpellIds.ScrollOfRecallIII: // Scroll of Recal III + case SpellScrollOfRecallIii: // Scroll of Recal Iii maxSafeLevel = 80; break; default: @@ -2027,12 +1686,12 @@ namespace Scripts.Spells.Items if (caster.GetLevel() > maxSafeLevel) { - caster.CastSpell(caster, SpellIds.Lost, true); + caster.CastSpell(caster, SpellLost, true); - // ALLIANCE from 60323 to 60330 - HORDE from 60328 to 60335 - uint spellId = SpellIds.ScrollOfRecallFailAlliance1; + // Alliance from 60323 to 60330 - Horde from 60328 to 60335 + uint spellId = SpellScrollOfRecallFailAlliance1; if (GetCaster().ToPlayer().GetTeam() == Team.Horde) - spellId = SpellIds.ScrollOfRecallFailHorde1; + spellId = SpellScrollOfRecallFailHorde1; GetCaster().CastSpell(GetCaster(), spellId + RandomHelper.URand(0, 7), true); @@ -2042,16 +1701,29 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.TeleportUnits)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.TeleportUnits)); } } + struct TransporterSpells + { + public const uint EvilTwin = 23445; + public const uint TransporterMalfunctionFire = 23449; + public const uint TransporterMalfunctionSmaller = 36893; + public const uint TransporterMalfunctionBigger = 36895; + public const uint TransporterMalfunctionChicken = 36940; + public const uint TransformHorde = 36897; + public const uint TransformAlliance = 36899; + public const uint SoulSplitEvil = 36900; + public const uint SoulSplitGood = 36901; + } + [Script] // 23442 - Dimensional Ripper - Everlook class spell_item_dimensional_ripper_everlook : SpellScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.TransporterMalfunctionFire, SpellIds.EvilTwin); + return ValidateSpellInfo(TransporterSpells.TransporterMalfunctionFire, TransporterSpells.EvilTwin); } public override bool Load() @@ -2068,14 +1740,14 @@ namespace Scripts.Spells.Items Unit caster = GetCaster(); if (r < 100) // 4/12 evil twin - caster.CastSpell(caster, SpellIds.EvilTwin, true); + caster.CastSpell(caster, TransporterSpells.EvilTwin, true); else // 1/12 fire - caster.CastSpell(caster, SpellIds.TransporterMalfunctionFire, true); + caster.CastSpell(caster, TransporterSpells.TransporterMalfunctionFire, true); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.TeleportUnits)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.TeleportUnits)); } } @@ -2084,7 +1756,8 @@ namespace Scripts.Spells.Items { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.TransporterMalfunctionSmaller, SpellIds.TransporterMalfunctionBigger, SpellIds.SoulSplitEvil, SpellIds.SoulSplitGood, SpellIds.TransformHorde, SpellIds.TransformAlliance, SpellIds.TransporterMalfunctionChicken, SpellIds.EvilTwin); + return ValidateSpellInfo(TransporterSpells.TransporterMalfunctionSmaller, TransporterSpells.TransporterMalfunctionBigger, TransporterSpells.SoulSplitEvil, TransporterSpells.SoulSplitGood, + TransporterSpells.TransformHorde, TransporterSpells.TransformAlliance, TransporterSpells.TransporterMalfunctionChicken, TransporterSpells.EvilTwin); } public override bool Load() @@ -2103,28 +1776,30 @@ namespace Scripts.Spells.Items switch (RandomHelper.URand(0, 6)) { case 0: - spellId = SpellIds.TransporterMalfunctionSmaller; + spellId = TransporterSpells.TransporterMalfunctionSmaller; break; case 1: - spellId = SpellIds.TransporterMalfunctionBigger; + spellId = TransporterSpells.TransporterMalfunctionBigger; break; case 2: - spellId = SpellIds.SoulSplitEvil; + spellId = TransporterSpells.SoulSplitEvil; break; case 3: - spellId = SpellIds.SoulSplitGood; + spellId = TransporterSpells.SoulSplitGood; break; case 4: - if (caster.ToPlayer().GetTeamId() == TeamId.Alliance) - spellId = SpellIds.TransformHorde; + if (caster.ToPlayer().GetTeam() == Team.Alliance) + spellId = TransporterSpells.TransformHorde; else - spellId = SpellIds.TransformAlliance; + spellId = TransporterSpells.TransformAlliance; break; case 5: - spellId = SpellIds.TransporterMalfunctionChicken; + spellId = TransporterSpells.TransporterMalfunctionChicken; break; case 6: - spellId = SpellIds.EvilTwin; + spellId = TransporterSpells.EvilTwin; + break; + default: break; } @@ -2133,7 +1808,7 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.TeleportUnits)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.TeleportUnits)); } } @@ -2142,7 +1817,7 @@ namespace Scripts.Spells.Items { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.TransporterMalfunctionBigger, SpellIds.SoulSplitEvil, SpellIds.SoulSplitGood, SpellIds.TransformHorde, SpellIds.TransformAlliance); + return ValidateSpellInfo(TransporterSpells.TransporterMalfunctionBigger, TransporterSpells.SoulSplitEvil, TransporterSpells.SoulSplitGood, TransporterSpells.TransformHorde, TransporterSpells.TransformAlliance); } public override bool Load() @@ -2161,19 +1836,21 @@ namespace Scripts.Spells.Items switch (RandomHelper.URand(0, 3)) { case 0: - spellId = SpellIds.TransporterMalfunctionBigger; + spellId = TransporterSpells.TransporterMalfunctionBigger; break; case 1: - spellId = SpellIds.SoulSplitEvil; + spellId = TransporterSpells.SoulSplitEvil; break; case 2: - spellId = SpellIds.SoulSplitGood; + spellId = TransporterSpells.SoulSplitGood; break; case 3: - if (caster.ToPlayer().GetTeamId() == TeamId.Alliance) - spellId = SpellIds.TransformHorde; + if (caster.ToPlayer().GetTeam() == Team.Alliance) + spellId = TransporterSpells.TransformHorde; else - spellId = SpellIds.TransformAlliance; + spellId = TransporterSpells.TransformAlliance; + break; + default: break; } @@ -2182,21 +1859,23 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.TeleportUnits)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.TeleportUnits)); } } [Script] // 71169 - Shadow's Fate (Shadowmourne questline) class spell_item_unsated_craving : AuraScript { + const uint NpcSindragosa = 36853; + bool CheckProc(ProcEventInfo procInfo) { Unit caster = procInfo.GetActor(); - if (!caster || caster.GetTypeId() != TypeId.Player) + if (caster == null || !caster.IsPlayer()) return false; Unit target = procInfo.GetActionTarget(); - if (!target || target.GetTypeId() != TypeId.Unit || target.IsCritter() || (target.GetEntry() != CreatureIds.Sindragosa && target.IsSummon())) + if (target == null || target.GetTypeId() != TypeId.Unit || target.IsCritter() || (target.GetEntry() != NpcSindragosa && target.IsSummon())) return false; return true; @@ -2204,58 +1883,64 @@ namespace Scripts.Spells.Items public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); + DoCheckProc.Add(new(CheckProc)); } } [Script] class spell_item_shadows_fate : AuraScript { + const uint SpellSoulFeast = 71203; + void HandleProc(ProcEventInfo procInfo) { PreventDefaultAction(); Unit caster = procInfo.GetActor(); Unit target = GetCaster(); - if (!caster || !target) + if (caster == null || target == null) return; - caster.CastSpell(target, SpellIds.SoulFeast, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + caster.CastSpell(target, SpellSoulFeast, TriggerCastFlags.FullMask); } public override void Register() { - OnProc.Add(new AuraProcHandler(HandleProc)); + OnProc.Add(new(HandleProc)); } } [Script] // 71903 - Item - Shadowmourne Legendary class spell_item_shadowmourne : AuraScript { + const uint SpellShadowmourneChaosBaneDamage = 71904; + const uint SpellShadowmourneSoulFragment = 71905; + const uint SpellShadowmourneChaosBaneBuff = 73422; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.ShadowmourneChaosBaneDamage, SpellIds.ShadowmourneSoulFragment, SpellIds.ShadowmourneChaosBaneBuff); + return ValidateSpellInfo(SpellShadowmourneChaosBaneDamage, SpellShadowmourneSoulFragment, SpellShadowmourneChaosBaneBuff); } bool CheckProc(ProcEventInfo eventInfo) { - if (GetTarget().HasAura(SpellIds.ShadowmourneChaosBaneBuff)) // cant collect shards while under effect of Chaos Bane buff + if (GetTarget().HasAura(SpellShadowmourneChaosBaneBuff)) // cant collect shards while under effect of Chaos Bane buff return false; - return eventInfo.GetProcTarget() && eventInfo.GetProcTarget().IsAlive(); + return eventInfo.GetProcTarget() != null && eventInfo.GetProcTarget().IsAlive(); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.ShadowmourneSoulFragment, new CastSpellExtraArgs(aurEff)); + GetTarget().CastSpell(GetTarget(), SpellShadowmourneSoulFragment, aurEff); // this can't be handled in AuraScript of SoulFragments because we need to know victim - Aura soulFragments = GetTarget().GetAura(SpellIds.ShadowmourneSoulFragment); + Aura soulFragments = GetTarget().GetAura(SpellShadowmourneSoulFragment); if (soulFragments != null) { if (soulFragments.GetStackAmount() >= 10) { - GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.ShadowmourneChaosBaneDamage, new CastSpellExtraArgs(aurEff)); + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellShadowmourneChaosBaneDamage, aurEff); soulFragments.Remove(); } } @@ -2263,23 +1948,27 @@ namespace Scripts.Spells.Items void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - GetTarget().RemoveAurasDueToSpell(SpellIds.ShadowmourneSoulFragment); + GetTarget().RemoveAurasDueToSpell(SpellShadowmourneSoulFragment); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); + AfterEffectRemove.Add(new(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } [Script] // 71905 - Soul Fragment class spell_item_shadowmourne_soul_fragment : AuraScript { + const uint SpellShadowmourneVisualLow = 72521; + const uint SpellShadowmourneVisualHigh = 72523; + const uint SpellShadowmourneChaosBaneBuff = 73422; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.ShadowmourneVisualLow, SpellIds.ShadowmourneVisualHigh, SpellIds.ShadowmourneChaosBaneBuff); + return ValidateSpellInfo(SpellShadowmourneVisualLow, SpellShadowmourneVisualHigh, SpellShadowmourneChaosBaneBuff); } void OnStackChange(AuraEffect aurEff, AuraEffectHandleModes mode) @@ -2288,15 +1977,15 @@ namespace Scripts.Spells.Items switch (GetStackAmount()) { case 1: - target.CastSpell(target, SpellIds.ShadowmourneVisualLow, true); + target.CastSpell(target, SpellShadowmourneVisualLow, true); break; case 6: - target.RemoveAurasDueToSpell(SpellIds.ShadowmourneVisualLow); - target.CastSpell(target, SpellIds.ShadowmourneVisualHigh, true); + target.RemoveAurasDueToSpell(SpellShadowmourneVisualLow); + target.CastSpell(target, SpellShadowmourneVisualHigh, true); break; case 10: - target.RemoveAurasDueToSpell(SpellIds.ShadowmourneVisualHigh); - target.CastSpell(target, SpellIds.ShadowmourneChaosBaneBuff, true); + target.RemoveAurasDueToSpell(SpellShadowmourneVisualHigh); + target.CastSpell(target, SpellShadowmourneChaosBaneBuff, true); break; default: break; @@ -2306,14 +1995,14 @@ namespace Scripts.Spells.Items void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { Unit target = GetTarget(); - target.RemoveAurasDueToSpell(SpellIds.ShadowmourneVisualLow); - target.RemoveAurasDueToSpell(SpellIds.ShadowmourneVisualHigh); + target.RemoveAurasDueToSpell(SpellShadowmourneVisualLow); + target.RemoveAurasDueToSpell(SpellShadowmourneVisualHigh); } public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(OnStackChange, 0, AuraType.ModStat, AuraEffectHandleModes.Real | AuraEffectHandleModes.Reapply)); - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ModStat, AuraEffectHandleModes.Real)); + AfterEffectApply.Add(new(OnStackChange, 0, AuraType.ModStat, (AuraEffectHandleModes.Real | AuraEffectHandleModes.Reapply))); + AfterEffectRemove.Add(new(OnRemove, 0, AuraType.ModStat, AuraEffectHandleModes.Real)); } } @@ -2321,55 +2010,64 @@ namespace Scripts.Spells.Items [Script] // 14537 Six Demon Bag class spell_item_six_demon_bag : SpellScript { + const uint SpellFrostbolt = 11538; + const uint SpellPolymorph = 14621; + const uint SpellSummonFelhoundMinion = 14642; + const uint SpellFireball = 15662; + const uint SpellChainLightning = 21179; + const uint SpellEnvelopingWinds = 25189; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.Frostbolt, SpellIds.Polymorph, SpellIds.SummonFelhoundMinion, SpellIds.Fireball, SpellIds.ChainLightning, SpellIds.EnvelopingWinds); + return ValidateSpellInfo(SpellFrostbolt, SpellPolymorph, SpellSummonFelhoundMinion, SpellFireball, SpellChainLightning, SpellEnvelopingWinds); } void HandleDummy(uint effIndex) { Unit caster = GetCaster(); Unit target = GetHitUnit(); - if (target) + if (target != null) { uint spellId; uint rand = RandomHelper.URand(0, 99); if (rand < 25) // Fireball (25% chance) - spellId = SpellIds.Fireball; + spellId = SpellFireball; else if (rand < 50) // Frostball (25% chance) - spellId = SpellIds.Frostbolt; + spellId = SpellFrostbolt; else if (rand < 70) // Chain Lighting (20% chance) - spellId = SpellIds.ChainLightning; + spellId = SpellChainLightning; else if (rand < 80) // Polymorph (10% chance) { - spellId = SpellIds.Polymorph; + spellId = SpellPolymorph; if (RandomHelper.URand(0, 100) <= 30) // 30% chance to self-cast target = caster; } else if (rand < 95) // Enveloping Winds (15% chance) - spellId = SpellIds.EnvelopingWinds; + spellId = SpellEnvelopingWinds; else // Summon Felhund minion (5% chance) { - spellId = SpellIds.SummonFelhoundMinion; + spellId = SpellSummonFelhoundMinion; target = caster; } - caster.CastSpell(target, spellId, new CastSpellExtraArgs(GetCastItem())); + caster.CastSpell(target, spellId, GetCastItem()); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 59906 - Swift Hand of Justice Dummy class spell_item_swift_hand_justice_dummy : AuraScript { + const uint SpellSwiftHandOfJusticeHeal = 59913; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.SwiftHandOfJusticeHeal); + return ValidateSpellInfo(SpellSwiftHandOfJusticeHeal); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -2379,12 +2077,12 @@ namespace Scripts.Spells.Items Unit caster = eventInfo.GetActor(); CastSpellExtraArgs args = new(aurEff); args.AddSpellMod(SpellValueMod.BasePoint0, (int)caster.CountPctFromMaxHealth(aurEff.GetAmount())); - caster.CastSpell((Unit)null, SpellIds.SwiftHandOfJusticeHeal, args); + caster.CastSpell(null, SpellSwiftHandOfJusticeHeal, args); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -2393,14 +2091,14 @@ namespace Scripts.Spells.Items { void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - int diff = (int)GetUnitOwner().GetLevel() - 60; + int diff = (int)(GetUnitOwner().GetLevel() - 60); if (diff > 0) amount += diff; } public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModThreat)); + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.ModThreat)); } } @@ -2408,35 +2106,34 @@ namespace Scripts.Spells.Items [Script] // 59640 Underbelly Elixir class spell_item_underbelly_elixir : SpellScript { + const uint SpellUnderbellyElixirTriggered1 = 59645; + const uint SpellUnderbellyElixirTriggered2 = 59831; + const uint SpellUnderbellyElixirTriggered3 = 59843; + public override bool Load() { - return GetCaster().GetTypeId() == TypeId.Player; + return GetCaster().IsPlayer(); } - public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.UnderbellyElixirTriggered1, SpellIds.UnderbellyElixirTriggered2, SpellIds.UnderbellyElixirTriggered3); + return ValidateSpellInfo(SpellUnderbellyElixirTriggered1, SpellUnderbellyElixirTriggered2, SpellUnderbellyElixirTriggered3); } void HandleDummy(uint effIndex) { Unit caster = GetCaster(); - uint spellId = SpellIds.UnderbellyElixirTriggered3; + uint spellId = SpellUnderbellyElixirTriggered3; switch (RandomHelper.URand(1, 3)) { - case 1: - spellId = SpellIds.UnderbellyElixirTriggered1; - break; - case 2: - spellId = SpellIds.UnderbellyElixirTriggered2; - break; + case 1: spellId = SpellUnderbellyElixirTriggered1; break; + case 2: spellId = SpellUnderbellyElixirTriggered2; break; } caster.CastSpell(caster, spellId, true); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -2445,15 +2142,15 @@ namespace Scripts.Spells.Items { uint[] WormholeTargetLocations = { - SpellIds.Wormholepandariaisleofreckoning, - SpellIds. Wormholepandariakunlaiunderwater, - SpellIds.Wormholepandariasravess, - SpellIds.Wormholepandariarikkitunvillage, - SpellIds.Wormholepandariazanvesstree, - SpellIds.Wormholepandariaanglerswharf, - SpellIds.Wormholepandariacranestatue, - SpellIds.Wormholepandariaemperorsomen, - SpellIds.Wormholepandariawhitepetallake + 126756, //SpellWormholePandariaIsleOfReckoning + 126757, //SpellWormholePandariaKunlaiUnderwater + 126758, //SpellWormholePandariaSraVess + 126759, //SpellWormholePandariaRikkitunVillage + 126760, //SpellWormholePandariaZanvessTree + 126761, //SpellWormholePandariaAnglersWharf + 126762, //SpellWormholePandariaCraneStatue + 126763, //SpellWormholePandariaEmperorsOmen + 126764 //SpellWormholePandariaWhitepetalLake }; public override bool Validate(SpellInfo spellInfo) @@ -2470,28 +2167,30 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleTeleport, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleTeleport, 0, SpellEffectName.Dummy)); } } [Script] // 47776 - Roll 'dem Bones class spell_item_worn_troll_dice : SpellScript { + const uint TextWornTrollDice = 26152; + public override bool Validate(SpellInfo spellInfo) { - if (!CliDB.BroadcastTextStorage.ContainsKey(TextIds.WornTrollDice)) + if (!CliDB.BroadcastTextStorage.ContainsKey(TextWornTrollDice)) return false; return true; } public override bool Load() { - return GetCaster().GetTypeId() == TypeId.Player; + return GetCaster().IsPlayer(); } void HandleScript(uint effIndex) { - GetCaster().TextEmote(TextIds.WornTrollDice, GetHitUnit()); + GetCaster().TextEmote(TextWornTrollDice, GetHitUnit()); uint minimum = 1; uint maximum = 6; @@ -2503,16 +2202,20 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] class spell_item_red_rider_air_rifle : SpellScript { + const uint SpellAirRifleHoldVisual = 65582; + const uint SpellAirRifleShoot = 67532; + const uint SpellAirRifleShootSelf = 65577; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.AirRifleHoldVisual, SpellIds.AirRifleShoot, SpellIds.AirRifleShootSelf); + return ValidateSpellInfo(SpellAirRifleHoldVisual, SpellAirRifleShoot, SpellAirRifleShootSelf); } void HandleScript(uint effIndex) @@ -2520,23 +2223,23 @@ namespace Scripts.Spells.Items PreventHitDefaultEffect(effIndex); Unit caster = GetCaster(); Unit target = GetHitUnit(); - if (target) + if (target != null) { - caster.CastSpell(caster, SpellIds.AirRifleHoldVisual, true); - // needed because this spell shares GCD with its triggered spells (which must not be cast with triggered flag) + caster.CastSpell(caster, SpellAirRifleHoldVisual, true); + // needed because this spell shares Gcd with its triggered spells (which must not be cast with triggered flag) Player player = caster.ToPlayer(); - if (player) + if (player != null) player.GetSpellHistory().CancelGlobalCooldown(GetSpellInfo()); if (RandomHelper.URand(0, 4) != 0) - caster.CastSpell(target, SpellIds.AirRifleShoot, false); + caster.CastSpell(target, SpellAirRifleShoot, false); else - caster.CastSpell(caster, SpellIds.AirRifleShootSelf, false); + caster.CastSpell(caster, SpellAirRifleShootSelf, false); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -2545,7 +2248,7 @@ namespace Scripts.Spells.Items { public override bool Load() { - return GetCaster().GetTypeId() == TypeId.Player; + return GetCaster().IsPlayer(); } SpellCastResult CheckRequirement() @@ -2572,19 +2275,22 @@ namespace Scripts.Spells.Items public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnCheckCast.Add(new(CheckRequirement)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] class spell_item_gift_of_the_harvester : SpellScript { + const uint NpcGhoul = 28845; + const uint MaxGhouls = 5; + SpellCastResult CheckRequirement() { List ghouls = new(); - GetCaster().GetAllMinionsByEntry(ghouls, CreatureIds.Ghoul); - if (ghouls.Count >= CreatureIds.MaxGhouls) + GetCaster().GetAllMinionsByEntry(ghouls, NpcGhoul); + if (ghouls.Count >= MaxGhouls) { SetCustomCastResultMessage(SpellCustomErrors.TooManyGhouls); return SpellCastResult.CustomError; @@ -2595,19 +2301,23 @@ namespace Scripts.Spells.Items public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); + OnCheckCast.Add(new(CheckRequirement)); } } [Script] class spell_item_map_of_the_geyser_fields : SpellScript { + const uint NpcSouthSinkhole = 25664; + const uint NpcNortheastSinkhole = 25665; + const uint NpcNorthwestSinkhole = 25666; + SpellCastResult CheckSinkholes() { Unit caster = GetCaster(); - if (caster.FindNearestCreature(CreatureIds.SouthSinkhole, 30.0f, true) || - caster.FindNearestCreature(CreatureIds.NortheastSinkhole, 30.0f, true) || - caster.FindNearestCreature(CreatureIds.NorthwestSinkhole, 30.0f, true)) + if (caster.FindNearestCreature(NpcSouthSinkhole, 30.0f, true) != null || + caster.FindNearestCreature(NpcNortheastSinkhole, 30.0f, true) != null || + caster.FindNearestCreature(NpcNorthwestSinkhole, 30.0f, true) != null) return SpellCastResult.SpellCastOk; SetCustomCastResultMessage(SpellCustomErrors.MustBeCloseToSinkhole); @@ -2616,37 +2326,57 @@ namespace Scripts.Spells.Items public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckSinkholes)); + OnCheckCast.Add(new(CheckSinkholes)); } } [Script] class spell_item_vanquished_clutches : SpellScript { + const uint SpellCrusher = 64982; + const uint SpellConstrictor = 64983; + const uint SpellCorruptor = 64984; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.Crusher, SpellIds.Constrictor, SpellIds.Corruptor); + return ValidateSpellInfo(SpellCrusher, SpellConstrictor, SpellCorruptor); } void HandleDummy(uint effIndex) { - uint spellId = RandomHelper.RAND(SpellIds.Crusher, SpellIds.Constrictor, SpellIds.Corruptor); + uint spellId = RandomHelper.RAND(SpellCrusher, SpellConstrictor, SpellCorruptor); Unit caster = GetCaster(); caster.CastSpell(caster, spellId, true); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] class spell_item_ashbringer : SpellScript { + uint[] AshbringerSounds = + { + 8906, // "I was pure once" + 8907, // "Fought for righteousness" + 8908, // "I was once called Ashbringer" + 8920, // "Betrayed by my order" + 8921, // "Destroyed by Kel'Thuzad" + 8922, // "Made to serve" + 8923, // "My son watched me die" + 8924, // "Crusades fed his rage" + 8925, // "Truth is unknown to him" + 8926, // "Scarlet Crusade is pure no longer" + 8927, // "Balnazzar's crusade corrupted my son" + 8928 // "Kill them all!" + }; + public override bool Load() { - return GetCaster().GetTypeId() == TypeId.Player; + return GetCaster().IsPlayer(); } void OnDummyEffect(uint effIndex) @@ -2654,23 +2384,29 @@ namespace Scripts.Spells.Items PreventHitDefaultEffect(effIndex); Player player = GetCaster().ToPlayer(); - uint sound_id = RandomHelper.RAND(SoundIds.Ashbringer1, SoundIds.Ashbringer2, SoundIds.Ashbringer3, SoundIds.Ashbringer4, SoundIds.Ashbringer5, SoundIds.Ashbringer6, - SoundIds.Ashbringer7, SoundIds.Ashbringer8, SoundIds.Ashbringer9, SoundIds.Ashbringer10, SoundIds.Ashbringer11, SoundIds.Ashbringer12); + uint sound_id = RandomHelper.RAND(AshbringerSounds); - // Ashbringers effect (SpellIds.ID 28441) retriggers every 5 seconds, with a chance of making it say one of the above 12 sounds + // Ashbringers effect (spellID 28441) retriggers every 5 seconds, with a chance of making it say one of the above 12 sounds if (RandomHelper.URand(0, 60) < 1) player.PlayDirectSound(sound_id, player); } public override void Register() { - OnEffectHit.Add(new EffectHandler(OnDummyEffect, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(OnDummyEffect, 0, SpellEffectName.Dummy)); } } [Script] // 58886 - Food class spell_magic_eater_food : AuraScript { + const uint SpellWildMagic = 58891; + const uint SpellWellFed1 = 57288; + const uint SpellWellFed2 = 57139; + const uint SpellWellFed3 = 57111; + const uint SpellWellFed4 = 57286; + const uint SpellWellFed5 = 57291; + void HandleTriggerSpell(AuraEffect aurEff) { PreventDefaultAction(); @@ -2678,115 +2414,126 @@ namespace Scripts.Spells.Items switch (RandomHelper.URand(0, 5)) { case 0: - target.CastSpell(target, SpellIds.WildMagic, true); + target.CastSpell(target, SpellWildMagic, true); break; case 1: - target.CastSpell(target, SpellIds.WellFed1, true); + target.CastSpell(target, SpellWellFed1, true); break; case 2: - target.CastSpell(target, SpellIds.WellFed2, true); + target.CastSpell(target, SpellWellFed2, true); break; case 3: - target.CastSpell(target, SpellIds.WellFed3, true); + target.CastSpell(target, SpellWellFed3, true); break; case 4: - target.CastSpell(target, SpellIds.WellFed4, true); + target.CastSpell(target, SpellWellFed4, true); break; case 5: - target.CastSpell(target, SpellIds.WellFed5, true); + target.CastSpell(target, SpellWellFed5, true); break; } } public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleTriggerSpell, 1, AuraType.PeriodicTriggerSpell)); + OnEffectPeriodic.Add(new(HandleTriggerSpell, 1, AuraType.PeriodicTriggerSpell)); } } [Script] class spell_item_purify_helboar_meat : SpellScript { + const uint SpellSummonPurifiedHelboarMeat = 29277; + const uint SpellSummonToxicHelboarMeat = 29278; + public override bool Load() { - return GetCaster().GetTypeId() == TypeId.Player; + return GetCaster().IsPlayer(); } public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.SummonPurifiedHelboarMeat, SpellIds.SummonToxicHelboarMeat); + return ValidateSpellInfo(SpellSummonPurifiedHelboarMeat, SpellSummonToxicHelboarMeat); } void HandleDummy(uint effIndex) { Unit caster = GetCaster(); - caster.CastSpell(caster, RandomHelper.randChance(50) ? SpellIds.SummonPurifiedHelboarMeat : SpellIds.SummonToxicHelboarMeat, true); + caster.CastSpell(caster, RandomHelper.randChance(50) ? SpellSummonPurifiedHelboarMeat : SpellSummonToxicHelboarMeat, true); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] class spell_item_nigh_invulnerability : SpellScript { + const uint SpellNighInvulnerability = 30456; + const uint SpellCompleteVulnerability = 30457; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.NighInvulnerability, SpellIds.CompleteVulnerability); + return ValidateSpellInfo(SpellNighInvulnerability, SpellCompleteVulnerability); } void HandleDummy(uint effIndex) { Unit caster = GetCaster(); Item castItem = GetCastItem(); - if (castItem) + if (castItem != null) { if (RandomHelper.randChance(86)) // Nigh-Invulnerability - success - caster.CastSpell(caster, SpellIds.NighInvulnerability, new CastSpellExtraArgs(castItem)); + caster.CastSpell(caster, SpellNighInvulnerability, castItem); else // Complete Vulnerability - backfire in 14% casts - caster.CastSpell(caster, SpellIds.CompleteVulnerability, new CastSpellExtraArgs(castItem)); + caster.CastSpell(caster, SpellCompleteVulnerability, castItem); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] class spell_item_poultryizer : SpellScript { + const uint SpellPoultryizerSuccess = 30501; + const uint SpellPoultryizerBackfire = 30504; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.PoultryizerSuccess, SpellIds.PoultryizerBackfire); + return ValidateSpellInfo(SpellPoultryizerSuccess, SpellPoultryizerBackfire); } void HandleDummy(uint effIndex) { - if (GetCastItem() && GetHitUnit()) - GetCaster().CastSpell(GetHitUnit(), RandomHelper.randChance(80) ? SpellIds.PoultryizerSuccess : SpellIds.PoultryizerBackfire, new CastSpellExtraArgs(GetCastItem())); + if (GetCastItem() != null && GetHitUnit() != null) + GetCaster().CastSpell(GetHitUnit(), RandomHelper.randChance(80) ? SpellPoultryizerSuccess : SpellPoultryizerBackfire, GetCastItem()); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] class spell_item_socrethars_stone : SpellScript { + const uint SpellSocretharToSeat = 35743; + const uint SpellSocretharFromSeat = 35744; + public override bool Load() { return (GetCaster().GetAreaId() == 3900 || GetCaster().GetAreaId() == 3742); } - public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.SocretharToSeat, SpellIds.SocretharFromSeat); + return ValidateSpellInfo(SpellSocretharToSeat, SpellSocretharFromSeat); } void HandleDummy(uint effIndex) @@ -2795,10 +2542,10 @@ namespace Scripts.Spells.Items switch (caster.GetAreaId()) { case 3900: - caster.CastSpell(caster, SpellIds.SocretharToSeat, true); + caster.CastSpell(caster, SpellSocretharToSeat, true); break; case 3742: - caster.CastSpell(caster, SpellIds.SocretharFromSeat, true); + caster.CastSpell(caster, SpellSocretharFromSeat, true); break; default: return; @@ -2807,39 +2554,43 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] class spell_item_demon_broiled_surprise : SpellScript { + const uint QuestSuperHotStew = 11379; + const uint SpellCreateDemonBroiledSurprise = 43753; + const uint NpcAbyssalFlamebringer = 19973; + public override bool Validate(SpellInfo spell) { - return Global.ObjectMgr.GetCreatureTemplate(CreatureIds.AbyssalFlamebringer) != null - && Global.ObjectMgr.GetQuestTemplate(QuestIds.SuperHotStew) != null - && ValidateSpellInfo(SpellIds.CreateDemonBroiledSurprise); + return ValidateSpellInfo(SpellCreateDemonBroiledSurprise) && + ObjectMgr.GetCreatureTemplate(NpcAbyssalFlamebringer) != null && + ObjectMgr.GetQuestTemplate(QuestSuperHotStew) != null; } public override bool Load() { - return GetCaster().GetTypeId() == TypeId.Player; + return GetCaster().IsPlayer(); } void HandleDummy(uint effIndex) { Unit player = GetCaster(); - player.CastSpell(player, SpellIds.CreateDemonBroiledSurprise, false); + player.CastSpell(player, SpellCreateDemonBroiledSurprise, false); } SpellCastResult CheckRequirement() { Player player = GetCaster().ToPlayer(); - if (player.GetQuestStatus(QuestIds.SuperHotStew) != QuestStatus.Incomplete) + if (player.GetQuestStatus(QuestSuperHotStew) != QuestStatus.Incomplete) return SpellCastResult.CantDoThatRightNow; - Creature creature = player.FindNearestCreature(CreatureIds.AbyssalFlamebringer, 10, false); - if (creature) + Creature creature = player.FindNearestCreature(NpcAbyssalFlamebringer, 10, false); + if (creature != null) if (creature.IsDead()) return SpellCastResult.SpellCastOk; return SpellCastResult.NotHere; @@ -2847,43 +2598,48 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 1, SpellEffectName.Dummy)); - OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); + OnEffectHitTarget.Add(new(HandleDummy, 1, SpellEffectName.Dummy)); + OnCheckCast.Add(new(CheckRequirement)); } } [Script] class spell_item_complete_raptor_capture : SpellScript { + const uint SpellRaptorCaptureCredit = 42337; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.RaptorCaptureCredit); + return ValidateSpellInfo(SpellRaptorCaptureCredit); } void HandleDummy(uint effIndex) { Unit caster = GetCaster(); - if (GetHitCreature()) + if (GetHitCreature() != null) { GetHitCreature().DespawnOrUnsummon(); //cast spell Raptor Capture Credit - caster.CastSpell(caster, SpellIds.RaptorCaptureCredit, true); + caster.CastSpell(caster, SpellRaptorCaptureCredit, true); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] class spell_item_impale_leviroth : SpellScript { + const uint NpcLeviroth = 26452; + const uint SpellLevirothSelfImpale = 49882; + public override bool Validate(SpellInfo spell) { - if (Global.ObjectMgr.GetCreatureTemplate(CreatureIds.Leviroth) == null) + if (ObjectMgr.GetCreatureTemplate(NpcLeviroth) == null) return false; return true; } @@ -2891,54 +2647,58 @@ namespace Scripts.Spells.Items void HandleDummy(uint effIndex) { Creature target = GetHitCreature(); - if (target) - if (target.GetEntry() == CreatureIds.Leviroth && !target.HealthBelowPct(95)) + if (target != null) + if (target.GetEntry() == NpcLeviroth && !target.HealthBelowPct(95)) { - target.CastSpell(target, SpellIds.LevirothSelfImpale, true); + target.CastSpell(target, SpellLevirothSelfImpale, true); target.ResetPlayerDamageReq(); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 23725 - Gift of Life class spell_item_lifegiving_gem : SpellScript { + const uint SpellGiftOfLife1 = 23782; + const uint SpellGiftOfLife2 = 23783; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.GiftOfLife1, SpellIds.GiftOfLife2); + return ValidateSpellInfo(SpellGiftOfLife1, SpellGiftOfLife2); } void HandleDummy(uint effIndex) { Unit caster = GetCaster(); - caster.CastSpell(caster, SpellIds.GiftOfLife1, true); - caster.CastSpell(caster, SpellIds.GiftOfLife2, true); + caster.CastSpell(caster, SpellGiftOfLife1, true); + caster.CastSpell(caster, SpellGiftOfLife2, true); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] class spell_item_nitro_boosts : SpellScript { + const uint SpellNitroBoostsSuccess = 54861; + const uint SpellNitroBoostsBackfire = 54621; + public override bool Load() { - if (!GetCastItem()) - return false; - return true; + return GetCastItem() != null; } public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.NitroBoostsSuccess, SpellIds.NitroBoostsBackfire); + return ValidateSpellInfo(SpellNitroBoostsSuccess, SpellNitroBoostsBackfire); } void HandleDummy(uint effIndex) @@ -2946,22 +2706,26 @@ namespace Scripts.Spells.Items Unit caster = GetCaster(); bool success = true; if (!caster.GetMap().IsDungeon()) - success = RandomHelper.randChance(95); - caster.CastSpell(caster, success ? SpellIds.NitroBoostsSuccess : SpellIds.NitroBoostsBackfire, new CastSpellExtraArgs(GetCastItem())); + success = RandomHelper.randChance(95); // nitro boosts can only fail in flying-enabled locations on 3.3.5 + caster.CastSpell(caster, success ? SpellNitroBoostsSuccess : SpellNitroBoostsBackfire, GetCastItem()); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] class spell_item_nitro_boosts_backfire : AuraScript { + const uint SpellNitroBoostsParachute = 54649; + + float lastZ = MapConst.InvalidHeight; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.NitroBoostsParachute); + return ValidateSpellInfo(SpellNitroBoostsParachute); } void HandleApply(AuraEffect effect, AuraEffectHandleModes mode) @@ -2976,7 +2740,7 @@ namespace Scripts.Spells.Items if (curZ < lastZ) { if (RandomHelper.randChance(80)) // we don't have enough sniffs to verify this, guesstimate - GetTarget().CastSpell(GetTarget(), SpellIds.NitroBoostsParachute, new CastSpellExtraArgs(effect)); + GetTarget().CastSpell(GetTarget(), SpellNitroBoostsParachute, effect); GetAura().Remove(); } else @@ -2985,36 +2749,34 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(HandleApply, 1, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodicDummy, 1, AuraType.PeriodicTriggerSpell)); + OnEffectApply.Add(new(HandleApply, 1, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); + OnEffectPeriodic.Add(new(HandlePeriodicDummy, 1, AuraType.PeriodicTriggerSpell)); } - - float lastZ = MapConst.InvalidHeight; } [Script] class spell_item_rocket_boots : SpellScript { + const uint SpellRocketBootsProc = 30452; + public override bool Load() { - return GetCaster().GetTypeId() == TypeId.Player; + return GetCaster().IsPlayer(); } public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.RocketBootsProc); + return ValidateSpellInfo(SpellRocketBootsProc); } void HandleDummy(uint effIndex) { Player caster = GetCaster().ToPlayer(); - Battleground bg = caster.GetBattleground(); - if (bg) - bg.EventPlayerDroppedFlag(caster); + bg?.EventPlayerDroppedFlag(caster); - caster.GetSpellHistory().ResetCooldown(SpellIds.RocketBootsProc); - caster.CastSpell(caster, SpellIds.RocketBootsProc, true); + caster.GetSpellHistory().ResetCooldown(SpellRocketBootsProc); + caster.CastSpell(caster, SpellRocketBootsProc, true); } SpellCastResult CheckCast() @@ -3026,8 +2788,8 @@ namespace Scripts.Spells.Items public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnCheckCast.Add(new(CheckCast)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -3049,40 +2811,43 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleHeal, 0, SpellEffectName.Heal)); + OnEffectHitTarget.Add(new(HandleHeal, 0, SpellEffectName.Heal)); } } [Script] class spell_item_pygmy_oil : SpellScript { + const uint SpellPygmyOilPygmyAura = 53806; + const uint SpellPygmyOilSmallerAura = 53805; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.PygmyOilPygmyAura, SpellIds.PygmyOilSmallerAura); + return ValidateSpellInfo(SpellPygmyOilPygmyAura, SpellPygmyOilSmallerAura); } void HandleDummy(uint effIndex) { Unit caster = GetCaster(); - Aura aura = caster.GetAura(SpellIds.PygmyOilPygmyAura); + Aura aura = caster.GetAura(SpellPygmyOilPygmyAura); if (aura != null) aura.RefreshDuration(); else { - aura = caster.GetAura(SpellIds.PygmyOilSmallerAura); + aura = caster.GetAura(SpellPygmyOilSmallerAura); if (aura == null || aura.GetStackAmount() < 5 || !RandomHelper.randChance(50)) - caster.CastSpell(caster, SpellIds.PygmyOilSmallerAura, true); + caster.CastSpell(caster, SpellPygmyOilSmallerAura, true); else { aura.Remove(); - caster.CastSpell(caster, SpellIds.PygmyOilPygmyAura, true); + caster.CastSpell(caster, SpellPygmyOilPygmyAura, true); } } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -3092,39 +2857,44 @@ namespace Scripts.Spells.Items void HandleDummy(uint effIndex) { Unit caster = GetCaster(); - caster.SetFacingTo(RandomHelper.FRand(0.0f, 2.0f * (float)Math.PI)); + caster.SetFacingTo(RandomHelper.FRand(0.0f, 2.0f * (float)(MathF.PI))); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] class spell_item_chicken_cover : SpellScript { + const uint SpellChickenNet = 51959; + const uint SpellCaptureChickenEscape = 51037; + const uint QuestChickenParty = 12702; + const uint QuestFlownTheCoop = 12532; + public override bool Load() { - return GetCaster().GetTypeId() == TypeId.Player; + return GetCaster().IsPlayer(); } public override bool Validate(SpellInfo spell) { - return Global.ObjectMgr.GetQuestTemplate(QuestIds.ChickenParty) != null - && Global.ObjectMgr.GetQuestTemplate(QuestIds.FlownTheCoop) != null - && ValidateSpellInfo(SpellIds.ChickenNet, SpellIds.CaptureChickenEscape); + return ValidateSpellInfo(SpellChickenNet, SpellCaptureChickenEscape) && + ObjectMgr.GetQuestTemplate(QuestChickenParty) != null && + ObjectMgr.GetQuestTemplate(QuestFlownTheCoop) != null; } void HandleDummy(uint effIndex) { Player caster = GetCaster().ToPlayer(); Unit target = GetHitUnit(); - if (target) + if (target != null) { - if (!target.HasAura(SpellIds.ChickenNet) && (caster.GetQuestStatus(QuestIds.ChickenParty) == QuestStatus.Incomplete || caster.GetQuestStatus(QuestIds.FlownTheCoop) == QuestStatus.Incomplete)) + if (!target.HasAura(SpellChickenNet) && (caster.GetQuestStatus(QuestChickenParty) == QuestStatus.Incomplete || caster.GetQuestStatus(QuestFlownTheCoop) == QuestStatus.Incomplete)) { - caster.CastSpell(caster, SpellIds.CaptureChickenEscape, true); + caster.CastSpell(caster, SpellCaptureChickenEscape, true); target.KillSelf(); } } @@ -3132,7 +2902,7 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -3142,29 +2912,31 @@ namespace Scripts.Spells.Items void HandleDummy(uint effIndex) { Creature target = GetHitCreature(); - if (target) + if (target != null) if (target.IsDead()) target.DespawnOrUnsummon(); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] class spell_item_greatmothers_soulcatcher : SpellScript { + const uint SpellForceCastSummonGnomeSoul = 46486; + void HandleDummy(uint effIndex) { - if (GetHitUnit()) - GetCaster().CastSpell(GetCaster(), SpellIds.ForceCastSummonGnomeSoul); + if (GetHitUnit() != null) + GetCaster().CastSpell(GetCaster(), SpellForceCastSummonGnomeSoul); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -3173,19 +2945,22 @@ namespace Scripts.Spells.Items // Item - 49488: Shiny Shard of the Scale // 69739 - Shiny Shard of the Scale - Equip Effect - [Script("spell_item_purified_shard_of_the_scale", SpellIds.PurifiedCauterizingHeal, SpellIds.PurifiedSearingFlames)] - [Script("spell_item_shiny_shard_of_the_scale", SpellIds.ShinyCauterizingHeal, SpellIds.ShinySearingFlames)] + [Script("spell_item_purified_shard_of_the_scale", 69733, 69729)] + [Script("spell_item_shiny_shard_of_the_scale", 69734, 69730)] class spell_item_shard_of_the_scale : AuraScript { - public spell_item_shard_of_the_scale(uint healProcSpellId, uint damageProcSpellId) + uint _healProc; + uint _damageProc; + + public spell_item_shard_of_the_scale(uint healProc, uint damageProc) { - _healProcSpellId = healProcSpellId; - _damageProcSpellId = damageProcSpellId; + _healProc = healProc; + _damageProc = damageProc; } public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(_healProcSpellId, _damageProcSpellId); + return ValidateSpellInfo(_healProc, _damageProc); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -3195,27 +2970,29 @@ namespace Scripts.Spells.Items Unit target = eventInfo.GetProcTarget(); if (eventInfo.GetTypeMask().HasFlag(ProcFlags.DealHelpfulSpell)) - caster.CastSpell(target, _healProcSpellId, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(target, _healProc, aurEff); if (eventInfo.GetTypeMask().HasFlag(ProcFlags.DealHarmfulSpell)) - caster.CastSpell(target, _damageProcSpellId, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(target, _damageProc, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } - - uint _healProcSpellId; - uint _damageProcSpellId; } [Script] class spell_item_soul_preserver : AuraScript { + const uint SpellSoulPreserverDruid = 60512; + const uint SpellSoulPreserverPaladin = 60513; + const uint SpellSoulPreserverPriest = 60514; + const uint SpellSoulPreserverShaman = 60515; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.SoulPreserverDruid, SpellIds.SoulPreserverPaladin, SpellIds.SoulPreserverPriest, SpellIds.SoulPreserverShaman); + return ValidateSpellInfo(SpellSoulPreserverDruid, SpellSoulPreserverPaladin, SpellSoulPreserverPriest, SpellSoulPreserverShaman); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -3227,16 +3004,16 @@ namespace Scripts.Spells.Items switch (caster.GetClass()) { case Class.Druid: - caster.CastSpell(caster, SpellIds.SoulPreserverDruid, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(caster, SpellSoulPreserverDruid, aurEff); break; case Class.Paladin: - caster.CastSpell(caster, SpellIds.SoulPreserverPaladin, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(caster, SpellSoulPreserverPaladin, aurEff); break; case Class.Priest: - caster.CastSpell(caster, SpellIds.SoulPreserverPriest, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(caster, SpellSoulPreserverPriest, aurEff); break; case Class.Shaman: - caster.CastSpell(caster, SpellIds.SoulPreserverShaman, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(caster, SpellSoulPreserverShaman, aurEff); break; default: break; @@ -3245,31 +3022,49 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); } } - [Script("spell_item_sunwell_exalted_caster_neck", SpellIds.LightsWrath, SpellIds.ArcaneBolt)] - [Script("spell_item_sunwell_exalted_melee_neck", SpellIds.LightsStrength, SpellIds.ArcaneStrike)] - [Script("spell_item_sunwell_exalted_tank_neck", SpellIds.LightsWard, SpellIds.ArcaneInsight)] - [Script("spell_item_sunwell_exalted_healer_neck", SpellIds.LightsSalvation, SpellIds.ArcaneSurge)] + // Item - 34678: Shattered Sun Pendant of Acumen + // 45481 - Sunwell Exalted Caster Neck + + // Item - 34679: Shattered Sun Pendant of Might + // 45482 - Sunwell Exalted Melee Neck + + // Item - 34680: Shattered Sun Pendant of Resolve + // 45483 - Sunwell Exalted Tank Neck + + // Item - 34677: Shattered Sun Pendant of Restoration + // 45484 Sunwell Exalted Healer Neck + [Script("spell_item_sunwell_exalted_caster_neck", 45479, 45429)] // Light's Wrath if Exalted by Aldor, Arcane Bolt if Exalted by Scryers + [Script("spell_item_sunwell_exalted_melee_neck", 45480, 45428)] // Light's Strength if Exalted by Aldor, Arcane Strike if Exalted by Scryers + [Script("spell_item_sunwell_exalted_tank_neck", 45432, 45431)] //Light's Ward if Exalted by Aldor, Arcane Insight if Exalted by Scryers + [Script("spell_item_sunwell_exalted_healer_neck", 45478, 45430)] //Light's Salvation if Exalted by Aldor, Arcane Surge if Exalted by Scryers class spell_item_sunwell_neck : AuraScript { - public spell_item_sunwell_neck(uint aldorSpellId, uint scryersSpellId) + const uint FactionAldor = 932; + const uint FactionScryers = 934; + + uint _aldor; + uint _scryers; + + public spell_item_sunwell_neck(uint aldor, uint scryers) { - _aldorSpellId = aldorSpellId; - _scryersSpellId = scryersSpellId; + _aldor = aldor; + _scryers = scryers; } public override bool Validate(SpellInfo spellInfo) { - return CliDB.FactionStorage.ContainsKey(FactionIds.Aldor) && CliDB.FactionStorage.ContainsKey(FactionIds.Scryers) - && ValidateSpellInfo(_aldorSpellId, _scryersSpellId); + return ValidateSpellInfo(_aldor, _scryers) && + CliDB.FactionStorage.ContainsKey(FactionAldor) && + CliDB.FactionStorage.ContainsKey(FactionScryers); } bool CheckProc(ProcEventInfo eventInfo) { - if (eventInfo.GetActor().GetTypeId() != TypeId.Player) + if (!eventInfo.GetActor().IsPlayer()) return false; return true; } @@ -3281,21 +3076,18 @@ namespace Scripts.Spells.Items Unit target = eventInfo.GetProcTarget(); // Aggression checks are in the spell system... just cast and forget - if (player.GetReputationRank(FactionIds.Aldor) == ReputationRank.Exalted) - player.CastSpell(target, _aldorSpellId, new CastSpellExtraArgs(aurEff)); + if (player.GetReputationRank(FactionAldor) == ReputationRank.Exalted) + player.CastSpell(target, _aldor, aurEff); - if (player.GetReputationRank(FactionIds.Scryers) == ReputationRank.Exalted) - player.CastSpell(target, _scryersSpellId, new CastSpellExtraArgs(aurEff)); + if (player.GetReputationRank(FactionScryers) == ReputationRank.Exalted) + player.CastSpell(target, _scryers, aurEff); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } - - uint _aldorSpellId; - uint _scryersSpellId; } [Script] @@ -3304,10 +3096,10 @@ namespace Scripts.Spells.Items void HandleDummy(uint index) { Player target = GetHitUnit().ToPlayer(); - if (target) + if (target != null) { target.HandleEmoteCommand(Emote.OneshotTrain); - EmotesTextSoundRecord soundEntry = Global.DB2Mgr.GetTextSoundEmoteFor((uint)TextEmotes.Train, target.GetRace(), target.GetNativeGender(), target.GetClass()); + var soundEntry = DB2Mgr.GetTextSoundEmoteFor((uint)TextEmotes.Train, target.GetRace(), target.GetNativeGender(), target.GetClass()); if (soundEntry != null) target.PlayDistanceSound(soundEntry.SoundId); } @@ -3315,22 +3107,29 @@ namespace Scripts.Spells.Items void HandleTargets(List targetList) { - targetList.RemoveAll(obj => !obj.IsTypeId(TypeId.Player)); + targetList.RemoveAll(obj => !obj.IsPlayer()); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ScriptEffect)); - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(HandleTargets, SpellConst.EffectAll, Targets.UnitSrcAreaAlly)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.ScriptEffect)); + OnObjectAreaTargetSelect.Add(new(HandleTargets, SpellConst.EffectAll, Targets.UnitSrcAreaAlly)); } } [Script] class spell_item_death_choice : AuraScript { + const uint SpellDeathChoiceNormalAura = 67702; + const uint SpellDeathChoiceNormalAgility = 67703; + const uint SpellDeathChoiceNormalStrength = 67708; + const uint SpellDeathChoiceHeroicAura = 67771; + const uint SpellDeathChoiceHeroicAgility = 67772; + const uint SpellDeathChoiceHeroicStrength = 67773; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.DeathChoiceNormalStrength, SpellIds.DeathChoiceNormalAgility, SpellIds.DeathChoiceHeroicStrength, SpellIds.DeathChoiceHeroicAgility); + return ValidateSpellInfo(SpellDeathChoiceNormalStrength, SpellDeathChoiceNormalAgility, SpellDeathChoiceHeroicStrength, SpellDeathChoiceHeroicAgility); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -3343,20 +3142,20 @@ namespace Scripts.Spells.Items switch (aurEff.GetId()) { - case SpellIds.DeathChoiceNormalAura: + case SpellDeathChoiceNormalAura: { if (str > agi) - caster.CastSpell(caster, SpellIds.DeathChoiceNormalStrength, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(caster, SpellDeathChoiceNormalStrength, aurEff); else - caster.CastSpell(caster, SpellIds.DeathChoiceNormalAgility, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(caster, SpellDeathChoiceNormalAgility, aurEff); break; } - case SpellIds.DeathChoiceHeroicAura: + case SpellDeathChoiceHeroicAura: { if (str > agi) - caster.CastSpell(caster, SpellIds.DeathChoiceHeroicStrength, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(caster, SpellDeathChoiceHeroicStrength, aurEff); else - caster.CastSpell(caster, SpellIds.DeathChoiceHeroicAgility, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(caster, SpellDeathChoiceHeroicAgility, aurEff); break; } default: @@ -3366,17 +3165,20 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); } } - [Script("spell_item_lightning_capacitor", SpellIds.LightningCapacitorStack, SpellIds.LightningCapacitorTrigger)] - [Script("spell_item_thunder_capacitor", SpellIds.ThunderCapacitorStack, SpellIds.ThunderCapacitorTrigger)] - [Script("spell_item_toc25_normal_caster_trinket", SpellIds.Toc25CasterTrinketNormalStack, SpellIds.Toc25CasterTrinketNormalTrigger)] - [Script("spell_item_toc25_heroic_caster_trinket", SpellIds.Toc25CasterTrinketHeroicStack, SpellIds.Toc25CasterTrinketHeroicTrigger)] - class spell_item_trinket_stack : AuraScript + [Script("spell_item_lightning_capacitor", 37658, 37661)] // Lightning Capacitor + [Script("spell_item_thunder_capacitor", 54842, 54843)] // Thunder Capacitor + [Script("spell_item_toc25_normal_caster_trinket", 67713, 67714)] // Item - Coliseum 25 Normal Caster Trinket + [Script("spell_item_toc25_heroic_caster_trinket", 67759, 67760)] // Item - Coliseum 25 Heroic Caster Trinket + class spell_item_trinket_stack_AuraScript : AuraScript { - public spell_item_trinket_stack(uint stackSpell, uint triggerSpell) + uint _stackSpell; + uint _triggerSpell; + + public spell_item_trinket_stack_AuraScript(uint stackSpell, uint triggerSpell) { _stackSpell = stackSpell; _triggerSpell = triggerSpell; @@ -3393,7 +3195,7 @@ namespace Scripts.Spells.Items Unit caster = eventInfo.GetActor(); - caster.CastSpell(caster, _stackSpell, new CastSpellExtraArgs(aurEff)); // cast the stack + caster.CastSpell(caster, _stackSpell, aurEff); // cast the stack Aura dummy = caster.GetAura(_stackSpell); // retrieve aura @@ -3404,8 +3206,8 @@ namespace Scripts.Spells.Items // if right amount, Remove the aura and cast real trigger caster.RemoveAurasDueToSpell(_stackSpell); Unit target = eventInfo.GetActionTarget(); - if (target) - caster.CastSpell(target, _triggerSpell, new CastSpellExtraArgs(aurEff)); + if (target != null) + caster.CastSpell(target, _triggerSpell, aurEff); } void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) @@ -3415,20 +3217,22 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); + AfterEffectRemove.Add(new(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); } - - uint _stackSpell; - uint _triggerSpell; } [Script] // 57345 - Darkmoon Card: Greatness class spell_item_darkmoon_card_greatness : AuraScript { + const uint SpellDarkmoonCardStrength = 60229; + const uint SpellDarkmoonCardAgility = 60233; + const uint SpellDarkmoonCardIntellect = 60234; + const uint SpellDarkmoonCardVersatility = 60235; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.DarkmoonCardStrenght, SpellIds.DarkmoonCardAgility, SpellIds.DarkmoonCardIntellect, SpellIds.DarkmoonCardVersatility); + return ValidateSpellInfo(SpellDarkmoonCardStrength, SpellDarkmoonCardAgility, SpellDarkmoonCardIntellect, SpellDarkmoonCardVersatility); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -3439,50 +3243,50 @@ namespace Scripts.Spells.Items float str = caster.GetStat(Stats.Strength); float agi = caster.GetStat(Stats.Agility); float intl = caster.GetStat(Stats.Intellect); - float vers = 0.0f; // caster.GetStat(STAT_VERSATILITY); + float vers = 0.0f; // caster.GetStat(StatVersatility); float stat = 0.0f; - uint spellTrigger = SpellIds.DarkmoonCardStrenght; + uint spellTrigger = SpellDarkmoonCardStrength; if (str > stat) { - spellTrigger = SpellIds.DarkmoonCardStrenght; + spellTrigger = SpellDarkmoonCardStrength; stat = str; } if (agi > stat) { - spellTrigger = SpellIds.DarkmoonCardAgility; + spellTrigger = SpellDarkmoonCardAgility; stat = agi; } if (intl > stat) { - spellTrigger = SpellIds.DarkmoonCardIntellect; + spellTrigger = SpellDarkmoonCardIntellect; stat = intl; } if (vers > stat) - { - spellTrigger = SpellIds.DarkmoonCardVersatility; - stat = vers; - } + spellTrigger = SpellDarkmoonCardVersatility; - caster.CastSpell(caster, spellTrigger, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(caster, spellTrigger, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); } } - [Script] // 27522, 40336 - Mana Drain + [Script] // 27522,40336 - Mana Drain class spell_item_mana_drain : AuraScript { + const uint SpellManaDrainEnergize = 29471; + const uint SpellManaDrainLeech = 27526; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.ManaDrainEnergize, SpellIds.ManaDrainLeech); + return ValidateSpellInfo(SpellManaDrainEnergize, SpellManaDrainLeech); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -3493,29 +3297,33 @@ namespace Scripts.Spells.Items Unit target = eventInfo.GetActionTarget(); if (caster.IsAlive()) - caster.CastSpell(caster, SpellIds.ManaDrainEnergize, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(caster, SpellManaDrainEnergize, aurEff); - if (target && target.IsAlive()) - caster.CastSpell(target, SpellIds.ManaDrainLeech, new CastSpellExtraArgs(aurEff)); + if (target != null && target.IsAlive()) + caster.CastSpell(target, SpellManaDrainLeech, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); } } [Script] // 51640 - Taunt Flag Targeting class spell_item_taunt_flag_targeting : SpellScript { + const uint SpellTauntFlag = 51657; + const uint EmotePlantsFlag = 28008; + public override bool Validate(SpellInfo spellInfo) { - return CliDB.BroadcastTextStorage.ContainsKey(TextIds.EmotePlantsFlag) && ValidateSpellInfo(SpellIds.TauntFlag); + return ValidateSpellInfo(SpellTauntFlag) && + CliDB.BroadcastTextStorage.ContainsKey(EmotePlantsFlag); } void FilterTargets(List targets) { - targets.RemoveAll(obj => !obj.IsTypeId(TypeId.Player) && !obj.IsTypeId(TypeId.Corpse)); + targets.RemoveAll(obj => !obj.IsPlayer() && obj.GetTypeId() != TypeId.Corpse); if (targets.Empty()) { @@ -3530,119 +3338,125 @@ namespace Scripts.Spells.Items { // we *really* want the unit implementation here // it sends a packet like seen on sniff - GetCaster().TextEmote(TextIds.EmotePlantsFlag, GetHitUnit(), false); + GetCaster().TextEmote(EmotePlantsFlag, GetHitUnit(), false); - GetCaster().CastSpell(GetHitUnit(), SpellIds.TauntFlag, true); + GetCaster().CastSpell(GetHitUnit(), SpellTauntFlag, true); } public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.CorpseSrcAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.CorpseSrcAreaEnemy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 29830 - Mirren's Drinking Hat class spell_item_mirrens_drinking_hat : SpellScript { + const uint SpellLochModanLager = 29827; + const uint SpellStouthammerLite = 29828; + const uint SpellAeriePeakPaleAle = 29829; + void HandleScriptEffect(uint effIndex) { - uint spellId = 0; + uint spellId; switch (RandomHelper.URand(1, 6)) { case 1: case 2: case 3: - spellId = SpellIds.LochModanLager; - break; + spellId = SpellLochModanLager; break; case 4: case 5: - spellId = SpellIds.StouthammerLite; - break; + spellId = SpellStouthammerLite; break; case 6: - spellId = SpellIds.AeriePeakPaleAle; - break; + spellId = SpellAeriePeakPaleAle; break; default: return; } Unit caster = GetCaster(); - caster.CastSpell(caster, spellId, new CastSpellExtraArgs(GetSpell())); + caster.CastSpell(caster, spellId, GetSpell()); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } [Script] // 13180 - Gnomish Mind Control Cap - class spell_item_mind_control_cap_SpellScript : SpellScript + class spell_item_mind_control_cap : SpellScript { + const uint RollChanceDullard = 32; + const uint RollChanceNoBackfire = 95; + const uint SpellGnomishMindControlCap = 13181; + const uint SpellDullard = 67809; + public override bool Load() { - if (!GetCastItem()) - return false; - return true; + return GetCastItem() != null; } - public override bool Validate(SpellInfo spellInfo) + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.GnomishMindControlCap, SpellIds.Dullard); + return ValidateSpellInfo(SpellGnomishMindControlCap, SpellDullard); } void HandleDummy(uint effIndex) { Unit caster = GetCaster(); Unit target = GetHitUnit(); - if (target) + if (target != null) { - if (RandomHelper.randChance(95)) - caster.CastSpell(target, RandomHelper.randChance(32) ? SpellIds.Dullard : SpellIds.GnomishMindControlCap, new CastSpellExtraArgs(GetCastItem())); + if (RandomHelper.randChance(RollChanceNoBackfire)) + caster.CastSpell(target, RandomHelper.randChance(RollChanceDullard) ? SpellDullard : SpellGnomishMindControlCap, GetCastItem()); else - target.CastSpell(caster, SpellIds.GnomishMindControlCap, true); // backfire - 5% chance + target.CastSpell(caster, SpellGnomishMindControlCap, true); // backfire - 5% chance } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 8344 - Universal Remote (Gnomish Universal Remote) - class spell_item_universal_remote_SpellScript : SpellScript + class spell_item_universal_remote : SpellScript { + const uint SpellControlMachine = 8345; + const uint SpellMobilityMalfunction = 8346; + const uint SpellTargetLock = 8347; + public override bool Load() { - if (!GetCastItem()) - return false; - return true; + return GetCastItem() != null; } public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.ControlMachine, SpellIds.MobilityMalfunction, SpellIds.TargetLock); + return ValidateSpellInfo(SpellControlMachine, SpellMobilityMalfunction, SpellTargetLock); } void HandleDummy(uint effIndex) { Unit target = GetHitUnit(); - if (target) + if (target != null) { uint chance = RandomHelper.URand(0, 99); if (chance < 15) - GetCaster().CastSpell(target, SpellIds.TargetLock, new CastSpellExtraArgs(GetCastItem())); + GetCaster().CastSpell(target, SpellTargetLock, GetCastItem()); else if (chance < 25) - GetCaster().CastSpell(target, SpellIds.MobilityMalfunction, new CastSpellExtraArgs(GetCastItem())); + GetCaster().CastSpell(target, SpellMobilityMalfunction, GetCastItem()); else - GetCaster().CastSpell(target, SpellIds.ControlMachine, new CastSpellExtraArgs(GetCastItem())); + GetCaster().CastSpell(target, SpellControlMachine, GetCastItem()); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -3650,10 +3464,12 @@ namespace Scripts.Spells.Items // 24658 - Unstable Power // Item - 19949: Zandalarian Hero Medallion // 24661 - Restless Strength - [Script("spell_item_unstable_power", SpellIds.UnstablePowerAuraStack)] - [Script("spell_item_restless_strength", SpellIds.RestlessStrengthAuraStack)] + [Script("spell_item_unstable_power", 24659)] + [Script("spell_item_restless_strength", 24662)] class spell_item_zandalarian_charm : AuraScript { + uint _spellId; + public spell_item_zandalarian_charm(uint SpellId) { _spellId = SpellId; @@ -3682,11 +3498,9 @@ namespace Scripts.Spells.Items public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleStackDrop, 0, AuraType.Dummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleStackDrop, 0, AuraType.Dummy)); } - - uint _spellId; } [Script] @@ -3694,24 +3508,24 @@ namespace Scripts.Spells.Items { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 1); + return ValidateSpellEffect((spellInfo.Id, 1)); } public override bool Load() { - return GetOwner().IsTypeId(TypeId.Player); + return GetOwner().IsPlayer(); } void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { Item artifact = GetOwner().ToPlayer().GetItemByGuid(GetAura().GetCastItemGUID()); - if (artifact) + if (artifact != null) amount = (int)(GetEffectInfo(1).BasePoints * artifact.GetTotalPurchasedArtifactPowers() / 100); } public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModTotalStatPercentage)); + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.ModTotalStatPercentage)); } } @@ -3720,33 +3534,35 @@ namespace Scripts.Spells.Items { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 1); + return ValidateSpellEffect((spellInfo.Id, 1)); } public override bool Load() { - return GetOwner().IsTypeId(TypeId.Player); + return GetOwner().IsPlayer(); } void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { Item artifact = GetOwner().ToPlayer().GetItemByGuid(GetAura().GetCastItemGUID()); - if (artifact) + if (artifact != null) amount = (int)(GetSpellInfo().GetEffect(1).BasePoints * artifact.GetTotalPurchasedArtifactPowers() / 100); } public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModDamagePercentDone)); + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.ModDamagePercentDone)); } } [Script] // 28200 - Ascendance class spell_item_talisman_of_ascendance : AuraScript { + const uint SpellTalismanOfAscendance = 28200; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.TalismanOfAscendance); + return ValidateSpellInfo(SpellTalismanOfAscendance); } void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) @@ -3756,16 +3572,18 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); } } [Script] // 29602 - Jom Gabbar class spell_item_jom_gabbar : AuraScript { + const uint SpellJomGabbar = 29602; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.JomGabbar); + return ValidateSpellInfo(SpellJomGabbar); } void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) @@ -3775,16 +3593,18 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(OnRemove, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); } } [Script] // 45040 - Battle Trance class spell_item_battle_trance : AuraScript { + const uint SpellBattleTrance = 45040; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.BattleTrance); + return ValidateSpellInfo(SpellBattleTrance); } void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) @@ -3794,16 +3614,18 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); } } [Script] // 90900 - World-Queller Focus class spell_item_world_queller_focus : AuraScript { + const uint SpellWorldQuellerFocus = 90900; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.WorldQuellerFocus); + return ValidateSpellInfo(SpellWorldQuellerFocus); } void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) @@ -3813,7 +3635,7 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); } } @@ -3826,7 +3648,7 @@ namespace Scripts.Spells.Items { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 1); + return ValidateSpellEffect((spellInfo.Id, 1)); } void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) @@ -3836,7 +3658,7 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Mounted, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(OnRemove, 0, AuraType.Mounted, AuraEffectHandleModes.Real)); } } @@ -3844,9 +3666,12 @@ namespace Scripts.Spells.Items [Script] // 145738 - Brutal Kinship class spell_item_brutal_kinship : AuraScript { + const uint SpellBrutalKinship1 = 144671; + const uint SpellBrutalKinship2 = 145738; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.BrutalKinship1, SpellIds.BrutalKinship2); + return ValidateSpellInfo(SpellBrutalKinship1, SpellBrutalKinship2); } void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) @@ -3856,11 +3681,11 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); } } - [Script]// 45051 - Mad Alchemist's Potion (34440) + [Script] // 45051 - Mad Alchemist's Potion (34440) class spell_item_mad_alchemists_potion : SpellScript { void SecondaryEffect() @@ -3900,18 +3725,18 @@ namespace Scripts.Spells.Items bool useElixir = true; SpellGroup chosenSpellGroup = SpellGroup.None; - if (Global.SpellMgr.IsSpellMemberOfSpellGroup(chosenElixir, SpellGroup.ElixirBattle)) + if (SpellMgr.IsSpellMemberOfSpellGroup(chosenElixir, SpellGroup.ElixirBattle)) chosenSpellGroup = SpellGroup.ElixirBattle; - if (Global.SpellMgr.IsSpellMemberOfSpellGroup(chosenElixir, SpellGroup.ElixirGuardian)) + if (SpellMgr.IsSpellMemberOfSpellGroup(chosenElixir, SpellGroup.ElixirGuardian)) chosenSpellGroup = SpellGroup.ElixirGuardian; // If another spell of the same group is already active the elixir should not be cast - if (chosenSpellGroup != 0) + if (chosenSpellGroup != SpellGroup.None) { - var Auras = target.GetAppliedAuras(); - foreach (var pair in Auras) + var auraMap = target.GetAppliedAuras(); + foreach (var (_, app) in auraMap) { - uint spell_id = pair.Value.GetBase().GetId(); - if (Global.SpellMgr.IsSpellMemberOfSpellGroup(spell_id, chosenSpellGroup) && spell_id != chosenElixir) + uint spellId = app.GetBase().GetId(); + if (SpellMgr.IsSpellMemberOfSpellGroup(spellId, chosenSpellGroup) && spellId != chosenElixir) { useElixir = false; break; @@ -3920,16 +3745,16 @@ namespace Scripts.Spells.Items } if (useElixir) - target.CastSpell(target, chosenElixir, new CastSpellExtraArgs(GetCastItem())); + target.CastSpell(target, chosenElixir, GetCastItem()); } public override void Register() { - AfterCast.Add(new CastHandler(SecondaryEffect)); + AfterCast.Add(new(SecondaryEffect)); } } - [Script]// 53750 - Crazy Alchemist's Potion (40077) + [Script] // 53750 - Crazy Alchemist's Potion (40077) class spell_item_crazy_alchemists_potion : SpellScript { void SecondaryEffect() @@ -3949,6 +3774,7 @@ namespace Scripts.Spells.Items 53915 // Mighty Shadow Protection Potion (40217) }; + Unit target = GetCaster(); if (!target.IsInCombat()) @@ -3958,53 +3784,105 @@ namespace Scripts.Spells.Items uint chosenElixir = availableElixirs.SelectRandom(); - target.CastSpell(target, chosenElixir, new CastSpellExtraArgs(GetCastItem())); + target.CastSpell(target, chosenElixir, GetCastItem()); } public override void Register() { - AfterCast.Add(new CastHandler(SecondaryEffect)); + AfterCast.Add(new(SecondaryEffect)); } } [Script] // 21149 - Egg Nog class spell_item_eggnog : SpellScript { + const uint SpellEggNogReindeer = 21936; + const uint SpellEggNogSnowman = 21980; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.EggNogReindeer, SpellIds.EggNogSnowman); + return ValidateSpellInfo(SpellEggNogReindeer, SpellEggNogSnowman); } void HandleScript(uint effIndex) { if (RandomHelper.randChance(40)) - GetCaster().CastSpell(GetHitUnit(), RandomHelper.randChance(50) ? SpellIds.EggNogReindeer : SpellIds.EggNogSnowman, GetCastItem()); + GetCaster().CastSpell(GetHitUnit(), RandomHelper.randChance(50) ? SpellEggNogReindeer : SpellEggNogSnowman, GetCastItem()); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 2, SpellEffectName.Inebriate)); + OnEffectHitTarget.Add(new(HandleScript, 2, SpellEffectName.Inebriate)); } } - enum AmalgamsSeventhSpineSpellIds + // 208051 - Sephuz's Secret + // 234867 - Sephuz's Secret + [Script] // 236763 - Sephuz's Secret + class spell_item_sephuzs_secret : AuraScript { - FragileEchoesMonk = 225281, - FragileEchoesShaman = 225292, - FragileEchoesPriestDiscipline = 225294, - FragileEchoesPaladin = 225297, - FragileEchoesDruid = 225298, - FragileEchoesPriestHoly = 225366, - FragileEchoEnergize = 215270, + const uint SpellSephuzsSecretCooldown = 226262; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellSephuzsSecretCooldown); + } + + bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + if (GetUnitOwner().HasAura(SpellSephuzsSecretCooldown)) + return false; + + if (eventInfo.GetHitMask().HasAnyFlag(ProcFlagsHit.Interrupt | ProcFlagsHit.Dispel)) + return true; + + Spell procSpell = eventInfo.GetProcSpell(); + if (procSpell == null) + return false; + + bool isCrowdControl = procSpell.GetSpellInfo().HasAura(AuraType.ModConfuse) + || procSpell.GetSpellInfo().HasAura(AuraType.ModFear) + || procSpell.GetSpellInfo().HasAura(AuraType.ModStun) + || procSpell.GetSpellInfo().HasAura(AuraType.ModPacify) + || procSpell.GetSpellInfo().HasAura(AuraType.ModRoot) + || procSpell.GetSpellInfo().HasAura(AuraType.ModSilence) + || procSpell.GetSpellInfo().HasAura(AuraType.ModPacifySilence) + || procSpell.GetSpellInfo().HasAura(AuraType.ModRoot2); + + if (!isCrowdControl) + return false; + + return true; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo procInfo) + { + PreventDefaultAction(); + + GetUnitOwner().CastSpell(GetUnitOwner(), SpellSephuzsSecretCooldown, TriggerCastFlags.FullMask); + GetUnitOwner().CastSpell(procInfo.GetProcTarget(), aurEff.GetSpellEffectInfo().TriggerSpell, new CastSpellExtraArgs(aurEff).SetTriggeringSpell(procInfo.GetProcSpell())); + } + + public override void Register() + { + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.ProcTriggerSpell)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); + } } [Script] // 215266 - Fragile Echoes class spell_item_amalgams_seventh_spine : AuraScript { + const uint SpellFragileEchoesMonk = 225281; + const uint SpellFragileEchoesShaman = 225292; + const uint SpellFragileEchoesPriestDiscipline = 225294; + const uint SpellFragileEchoesPaladin = 225297; + const uint SpellFragileEchoesDruid = 225298; + const uint SpellFragileEchoesPriestHoly = 225366; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo((uint)AmalgamsSeventhSpineSpellIds.FragileEchoesMonk, (uint)AmalgamsSeventhSpineSpellIds.FragileEchoesShaman, (uint)AmalgamsSeventhSpineSpellIds.FragileEchoesPriestDiscipline, - (uint)AmalgamsSeventhSpineSpellIds.FragileEchoesPaladin, (uint)AmalgamsSeventhSpineSpellIds.FragileEchoesDruid, (uint)AmalgamsSeventhSpineSpellIds.FragileEchoesPriestHoly); + return ValidateSpellInfo(SpellFragileEchoesMonk, SpellFragileEchoesShaman, SpellFragileEchoesPriestDiscipline, SpellFragileEchoesPaladin, SpellFragileEchoesDruid, SpellFragileEchoesPriestHoly); } void ForcePeriodic(AuraEffect aurEff, ref bool isPeriodic, ref int amplitude) @@ -4018,34 +3896,34 @@ namespace Scripts.Spells.Items { PreventDefaultAction(); Player target = GetTarget().ToPlayer(); - if (!target) + if (target == null) return; - void updateAuraIfInCorrectSpec(ChrSpecialization spec, AmalgamsSeventhSpineSpellIds aura) + void updateAuraIfInCorrectSpec(ChrSpecialization spec, uint aura) { if (target.GetPrimarySpecialization() != spec) - target.RemoveAurasDueToSpell((uint)aura); - else if (!target.HasAura((uint)aura)) - target.CastSpell(target, (uint)aura, new CastSpellExtraArgs(aurEff)); - }; + target.RemoveAurasDueToSpell(aura); + else if (!target.HasAura(aura)) + target.CastSpell(target, aura, aurEff); + } switch (target.GetClass()) { case Class.Monk: - updateAuraIfInCorrectSpec(ChrSpecialization.MonkMistweaver, AmalgamsSeventhSpineSpellIds.FragileEchoesMonk); + updateAuraIfInCorrectSpec(ChrSpecialization.MonkMistweaver, SpellFragileEchoesMonk); break; case Class.Shaman: - updateAuraIfInCorrectSpec(ChrSpecialization.ShamanRestoration, AmalgamsSeventhSpineSpellIds.FragileEchoesShaman); + updateAuraIfInCorrectSpec(ChrSpecialization.ShamanRestoration, SpellFragileEchoesShaman); break; case Class.Priest: - updateAuraIfInCorrectSpec(ChrSpecialization.PriestDiscipline, AmalgamsSeventhSpineSpellIds.FragileEchoesPriestDiscipline); - updateAuraIfInCorrectSpec(ChrSpecialization.PriestHoly, AmalgamsSeventhSpineSpellIds.FragileEchoesPriestHoly); + updateAuraIfInCorrectSpec(ChrSpecialization.PriestDiscipline, SpellFragileEchoesPriestDiscipline); + updateAuraIfInCorrectSpec(ChrSpecialization.PriestHoly, SpellFragileEchoesPriestHoly); break; case Class.Paladin: - updateAuraIfInCorrectSpec(ChrSpecialization.PaladinHoly, AmalgamsSeventhSpineSpellIds.FragileEchoesPaladin); + updateAuraIfInCorrectSpec(ChrSpecialization.PaladinHoly, SpellFragileEchoesPaladin); break; case Class.Druid: - updateAuraIfInCorrectSpec(ChrSpecialization.DruidRestoration, AmalgamsSeventhSpineSpellIds.FragileEchoesDruid); + updateAuraIfInCorrectSpec(ChrSpecialization.DruidRestoration, SpellFragileEchoesDruid); break; default: break; @@ -4054,17 +3932,19 @@ namespace Scripts.Spells.Items public override void Register() { - DoEffectCalcPeriodic.Add(new EffectCalcPeriodicHandler(ForcePeriodic, 0, AuraType.Dummy)); - OnEffectPeriodic.Add(new EffectPeriodicHandler(UpdateSpecAura, 0, AuraType.Dummy)); + DoEffectCalcPeriodic.Add(new(ForcePeriodic, 0, AuraType.Dummy)); + OnEffectPeriodic.Add(new(UpdateSpecAura, 0, AuraType.Dummy)); } } [Script] // 215267 - Fragile Echo class spell_item_amalgams_seventh_spine_mana_restore : AuraScript { + const uint SpellFragileEchoEnergize = 215270; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo((uint)AmalgamsSeventhSpineSpellIds.FragileEchoEnergize); + return ValidateSpellInfo(SpellFragileEchoEnergize); } void TriggerManaRestoration(AuraEffect aurEff, AuraEffectHandleModes mode) @@ -4073,17 +3953,17 @@ namespace Scripts.Spells.Items return; Unit caster = GetCaster(); - if (!caster) + if (caster == null) return; AuraEffect trinketEffect = caster.GetAuraEffect(aurEff.GetSpellEffectInfo().TriggerSpell, 0); if (trinketEffect != null) - caster.CastSpell(caster, (uint)AmalgamsSeventhSpineSpellIds.FragileEchoEnergize, new CastSpellExtraArgs(aurEff).AddSpellMod(SpellValueMod.BasePoint0, trinketEffect.GetAmount())); + caster.CastSpell(caster, SpellFragileEchoEnergize, new CastSpellExtraArgs(aurEff).AddSpellMod(SpellValueMod.BasePoint0, trinketEffect.GetAmount())); } public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(TriggerManaRestoration, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(TriggerManaRestoration, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -4092,12 +3972,12 @@ namespace Scripts.Spells.Items { bool IsDemon(AuraEffect aurEff, ProcEventInfo eventInfo) { - return eventInfo.GetProcTarget() && eventInfo.GetProcTarget().GetCreatureType() == CreatureType.Demon; + return eventInfo.GetProcTarget() != null && eventInfo.GetProcTarget().GetCreatureType() == CreatureType.Demon; } public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(IsDemon, 0, AuraType.ProcTriggerSpell)); + DoCheckEffectProc.Add(new(IsDemon, 0, AuraType.ProcTriggerSpell)); } } @@ -4106,18 +3986,17 @@ namespace Scripts.Spells.Items { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 1) - && ValidateSpellInfo(spellInfo.GetEffect(1).TriggerSpell); + return ValidateSpellEffect((spellInfo.Id, 1)) && ValidateSpellInfo(spellInfo.GetEffect(1).TriggerSpell); } bool CheckCooldownAura(ProcEventInfo eventInfo) { - return eventInfo.GetProcTarget() && !eventInfo.GetProcTarget().HasAura(GetEffectInfo(1).TriggerSpell, GetTarget().GetGUID()); + return eventInfo.GetProcTarget() != null && !eventInfo.GetProcTarget().HasAura(GetEffectInfo(1).TriggerSpell, GetTarget().GetGUID()); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckCooldownAura)); + DoCheckProc.Add(new(CheckCooldownAura)); } } @@ -4126,21 +4005,23 @@ namespace Scripts.Spells.Items { bool IsDemon(AuraEffect aurEff, ProcEventInfo eventInfo) { - return eventInfo.GetProcTarget() && eventInfo.GetProcTarget().GetCreatureType() == CreatureType.Demon; + return eventInfo.GetProcTarget() != null && eventInfo.GetProcTarget().GetCreatureType() == CreatureType.Demon; } public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(IsDemon, 0, AuraType.ProcTriggerSpell)); + DoCheckEffectProc.Add(new(IsDemon, 0, AuraType.ProcTriggerSpell)); } } [Script] // 253287 - Highfather's Timekeeping class spell_item_highfathers_machination : AuraScript { + const uint SpellHighfathersTimekeepingHeal = 253288; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.HighfathersTimekeepingHeal); + return ValidateSpellInfo(SpellHighfathersTimekeepingHeal); } bool CheckHealth(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -4153,55 +4034,61 @@ namespace Scripts.Spells.Items PreventDefaultAction(); Unit caster = GetCaster(); if (caster != null) - caster.CastSpell(GetTarget(), SpellIds.HighfathersTimekeepingHeal, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(GetTarget(), SpellHighfathersTimekeepingHeal, aurEff); } public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckHealth, 0, AuraType.Dummy)); - OnEffectProc.Add(new EffectProcHandler(Heal, 0, AuraType.Dummy)); + DoCheckEffectProc.Add(new(CheckHealth, 0, AuraType.Dummy)); + OnEffectProc.Add(new(Heal, 0, AuraType.Dummy)); } } [Script] // 253323 - Shadow Strike class spell_item_seeping_scourgewing : AuraScript { + const uint SpellShadowStrikeAoeCheck = 255861; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.ShadowStrikeAoeCheck); + return ValidateSpellInfo(SpellShadowStrikeAoeCheck); } void TriggerIsolatedStrikeCheck(AuraEffect aurEff, ProcEventInfo eventInfo) { - GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.ShadowStrikeAoeCheck, + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellShadowStrikeAoeCheck, new CastSpellExtraArgs(aurEff).SetTriggeringSpell(eventInfo.GetProcSpell())); } public override void Register() { - AfterEffectProc.Add(new EffectProcHandler(TriggerIsolatedStrikeCheck, 0, AuraType.ProcTriggerSpell)); + AfterEffectProc.Add(new(TriggerIsolatedStrikeCheck, 0, AuraType.ProcTriggerSpell)); } } [Script] // 255861 - Shadow Strike class spell_item_seeping_scourgewing_aoe_check : SpellScript { + const uint SpellIsolatedStrike = 255609; + void TriggerAdditionalDamage() { if (GetUnitTargetCountForEffect(0) > 1) return; - CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); - args.OriginalCastId = GetSpell().m_originalCastId; + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask) + { + OriginalCastId = GetSpell().m_originalCastId + }; if (GetSpell().m_castItemLevel >= 0) args.OriginalCastItemLevel = GetSpell().m_castItemLevel; - GetCaster().CastSpell(GetHitUnit(), SpellIds.IsolatedStrike, args); + GetCaster().CastSpell(GetHitUnit(), SpellIsolatedStrike, args); } public override void Register() { - AfterHit.Add(new HitHandler(TriggerAdditionalDamage)); + AfterHit.Add(new(TriggerAdditionalDamage)); } } @@ -4210,17 +4097,17 @@ namespace Scripts.Spells.Items { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 1); + return ValidateSpellEffect((spellInfo.Id, 1)); } bool CheckHealth(AuraEffect aurEff, ProcEventInfo eventInfo) { - return eventInfo.GetActor().GetHealthPct() >= (float)GetEffectInfo(1).CalcValue(); + return eventInfo.GetActor().GetHealthPct() >= (float)(GetEffectInfo(1).CalcValue()); } public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckHealth, 0, AuraType.ProcTriggerSpell)); + DoCheckEffectProc.Add(new(CheckHealth, 0, AuraType.ProcTriggerSpell)); } } @@ -4234,17 +4121,15 @@ namespace Scripts.Spells.Items public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckProc, 0, AuraType.ProcTriggerSpell)); + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.ProcTriggerSpell)); } } - // 303358 Venomous Bolt - // 303361 Shivering Lance - [Script("spell_item_shiver_venom_crossbow", 303559)] - [Script("spell_item_shiver_venom_lance", 303562)] + [Script("spell_item_shiver_venom_crossbow", 303559)]// 303358 Venomous Bolt + [Script("spell_item_shiver_venom_lance", 303562)]// 303361 Shivering Lance class spell_item_shiver_venom_weapon_proc : AuraScript { - static uint SPELL_SHIVER_VENOM = 301624; + const uint SpellShiverVenom = 301624; uint _additionalProcSpellId; @@ -4255,12 +4140,12 @@ namespace Scripts.Spells.Items public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SPELL_SHIVER_VENOM, _additionalProcSpellId); + return ValidateSpellInfo(SpellShiverVenom, _additionalProcSpellId); } void HandleAdditionalProc(AuraEffect aurEff, ProcEventInfo procInfo) { - if (procInfo.GetProcTarget().HasAura(SPELL_SHIVER_VENOM)) + if (procInfo.GetProcTarget().HasAura(SpellShiverVenom)) procInfo.GetActor().CastSpell(procInfo.GetProcTarget(), _additionalProcSpellId, new CastSpellExtraArgs(aurEff) .AddSpellMod(SpellValueMod.BasePoint0, aurEff.GetAmount()) .SetTriggeringSpell(procInfo.GetProcSpell())); @@ -4268,7 +4153,7 @@ namespace Scripts.Spells.Items public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleAdditionalProc, 1, AuraType.Dummy)); + OnEffectProc.Add(new(HandleAdditionalProc, 1, AuraType.Dummy)); } } @@ -4290,7 +4175,7 @@ namespace Scripts.Spells.Items public override void Register() { - AfterCast.Add(new CastHandler(ModifyStacks)); + AfterCast.Add(new(ModifyStacks)); } } @@ -4304,7 +4189,57 @@ namespace Scripts.Spells.Items public override void Register() { - DoEffectCalcPeriodic.Add(new EffectCalcPeriodicHandler(CalculatePeriod, 0, AuraType.PeriodicTriggerSpell)); + DoEffectCalcPeriodic.Add(new(CalculatePeriod, 0, AuraType.PeriodicTriggerSpell)); + } + } + + // 410530 - Mettle + [Script] // 410964 - Mettle + class spell_item_infurious_crafted_gear_mettle : AuraScript + { + uint SpellMettleCooldown = 410532; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellMettleCooldown); + } + + bool CheckProc(ProcEventInfo eventInfo) + { + if (GetTarget().HasAura(SpellMettleCooldown)) + return false; + + if (eventInfo.GetHitMask().HasAnyFlag(ProcFlagsHit.Interrupt | ProcFlagsHit.Dispel)) + return true; + + Spell procSpell = eventInfo.GetProcSpell(); + if (procSpell == null) + return false; + + bool isCrowdControl = procSpell.GetSpellInfo().HasAura(AuraType.ModConfuse) + || procSpell.GetSpellInfo().HasAura(AuraType.ModFear) + || procSpell.GetSpellInfo().HasAura(AuraType.ModStun) + || procSpell.GetSpellInfo().HasAura(AuraType.ModPacify) + || procSpell.GetSpellInfo().HasAura(AuraType.ModRoot) + || procSpell.GetSpellInfo().HasAura(AuraType.ModSilence) + || procSpell.GetSpellInfo().HasAura(AuraType.ModPacifySilence) + || procSpell.GetSpellInfo().HasAura(AuraType.ModRoot2); + + if (!isCrowdControl) + return false; + + return eventInfo.GetActionTarget().HasAura(aura => aura.GetCastId() == procSpell.m_castId); + } + + void TriggerCooldown(ProcEventInfo eventInfo) + { + GetTarget().CastSpell(GetTarget(), SpellMettleCooldown, true); + } + + public override void Register() + { + DoCheckProc.Add(new(CheckProc)); + AfterProc.Add(new(TriggerCooldown)); } } } diff --git a/Source/Scripts/Spells/Mage.cs b/Source/Scripts/Spells/Mage.cs index 672055465..719eb2c94 100644 --- a/Source/Scripts/Spells/Mage.cs +++ b/Source/Scripts/Spells/Mage.cs @@ -1,17 +1,17 @@ -// Copyright (c) CypherCore All rights reserved. +// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; using Framework.Dynamic; +using Game.AI; using Game.DataStorage; using Game.Entities; using Game.Groups; -using Game.Maps; using Game.Scripting; using Game.Spells; using System; using System.Collections.Generic; -using Game.AI; +using static Global; namespace Scripts.Spells.Mage { @@ -28,8 +28,8 @@ namespace Scripts.Spells.Mage public const uint Blink = 1953; public const uint BlizzardDamage = 190357; public const uint BlizzardSlow = 12486; - public const uint Cauterized = 87024; public const uint CauterizeDot = 87023; + public const uint Cauterized = 87024; public const uint Chilled = 205708; public const uint CometStormDamage = 153596; public const uint CometStormVisual = 228601; @@ -37,8 +37,10 @@ namespace Scripts.Spells.Mage public const uint ConeOfColdSlow = 212792; public const uint ConjureRefreshment = 116136; public const uint ConjureRefreshmentTable = 167145; - public const uint DradonhawkForm = 32818; + public const uint DragonhawkForm = 32818; + public const uint EtherealBlink = 410939; public const uint EverwarmSocks = 320913; + public const uint FeelTheBurn = 383391; public const uint FingersOfFrost = 44544; public const uint FireBlast = 108853; public const uint FlurryDamage = 228596; @@ -53,6 +55,7 @@ namespace Scripts.Spells.Mage public const uint LivingBombPeriodic = 217694; public const uint ManaSurge = 37445; public const uint MasterOfTime = 342249; + public const uint RadiantSparkProcBlocker = 376105; public const uint RayOfFrostBonus = 208141; public const uint RayOfFrostFingersOfFrost = 269748; public const uint Reverberate = 281482; @@ -61,8 +64,12 @@ namespace Scripts.Spells.Mage public const uint RingOfFrostSummon = 113724; public const uint SerpentForm = 32817; public const uint SheepForm = 32820; + public const uint Shimmer = 212653; + public const uint Slow = 31589; public const uint SquirrelForm = 32813; + public const uint Supernova = 157980; public const uint WorgenForm = 32819; + public const uint PetNetherwindsFatigued = 160455; public const uint IceLanceTrigger = 228598; public const uint ThermalVoid = 155149; public const uint IcyVeins = 12472; @@ -74,7 +81,7 @@ namespace Scripts.Spells.Mage // 110909 - Alter Time Aura [Script] // 342246 - Alter Time Aura - class spell_mage_alter_time_aura : AuraScript + class spell_mage_alter_time_AuraScript : AuraScript { ulong _health; Position _pos; @@ -88,7 +95,7 @@ namespace Scripts.Spells.Mage { Unit unit = GetTarget(); _health = unit.GetHealth(); - _pos = new(unit.GetPosition()); + _pos = unit.GetPosition(); } void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) @@ -101,7 +108,7 @@ namespace Scripts.Spells.Mage if (unit.HasAura(SpellIds.MasterOfTime)) { - SpellInfo blink = Global.SpellMgr.GetSpellInfo(SpellIds.Blink, Difficulty.None); + SpellInfo blink = SpellMgr.GetSpellInfo(SpellIds.Blink, Difficulty.None); unit.GetSpellHistory().ResetCharges(blink.ChargeCategoryId); } unit.CastSpell(unit, SpellIds.AlterTimeVisual); @@ -110,8 +117,8 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.OverrideActionbarSpells, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 0, AuraType.OverrideActionbarSpells, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(OnApply, 0, AuraType.OverrideActionbarSpells, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(AfterRemove, 0, AuraType.OverrideActionbarSpells, AuraEffectHandleModes.Real)); } } @@ -133,7 +140,7 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectHit.Add(new EffectHandler(RemoveAlterTimeAura, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(RemoveAlterTimeAura, 0, SpellEffectName.Dummy)); } } @@ -144,7 +151,7 @@ namespace Scripts.Spells.Mage public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.ArcaneBarrageR3, SpellIds.ArcaneBarrageEnergize) && ValidateSpellEffect(spellInfo.Id, 1); + return ValidateSpellInfo(SpellIds.ArcaneBarrageR3, SpellIds.ArcaneBarrageEnergize) && ValidateSpellEffect((spellInfo.Id, 1)); } void ConsumeArcaneCharges() @@ -174,9 +181,9 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleEffectHitTarget, 0, SpellEffectName.SchoolDamage)); - OnEffectLaunchTarget.Add(new EffectHandler(MarkPrimaryTarget, 1, SpellEffectName.Dummy)); - AfterCast.Add(new CastHandler(ConsumeArcaneCharges)); + OnEffectHitTarget.Add(new(HandleEffectHitTarget, 0, SpellEffectName.SchoolDamage)); + OnEffectLaunchTarget.Add(new(MarkPrimaryTarget, 1, SpellEffectName.Dummy)); + AfterCast.Add(new(ConsumeArcaneCharges)); } } @@ -195,7 +202,7 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(RemoveArcaneCharge, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(RemoveArcaneCharge, 0, SpellEffectName.Dummy)); } } @@ -207,7 +214,7 @@ namespace Scripts.Spells.Mage if (!ValidateSpellInfo(SpellIds.ArcaneMage, SpellIds.Reverberate)) return false; - if (!ValidateSpellEffect(spellInfo.Id, 1)) + if (!ValidateSpellEffect((spellInfo.Id, 1))) return false; return spellInfo.GetEffect(1).IsEffect(SpellEffectName.SchoolDamage); @@ -221,25 +228,28 @@ namespace Scripts.Spells.Mage void HandleReverberate(uint effIndex) { - bool procTriggered = false; - - Unit caster = GetCaster(); - AuraEffect triggerChance = caster.GetAuraEffect(SpellIds.Reverberate, 0); - if (triggerChance != null) + bool procTriggered() { + Unit caster = GetCaster(); + AuraEffect triggerChance = caster.GetAuraEffect(SpellIds.Reverberate, 0); + if (triggerChance == null) + return false; + AuraEffect requiredTargets = caster.GetAuraEffect(SpellIds.Reverberate, 1); - if (requiredTargets != null) - procTriggered = GetUnitTargetCountForEffect(1) >= requiredTargets.GetAmount() && RandomHelper.randChance(triggerChance.GetAmount()); + if (requiredTargets == null) + return false; + + return GetUnitTargetCountForEffect(1) >= requiredTargets.GetAmount() && RandomHelper.randChance(triggerChance.GetAmount()); } - if (!procTriggered) + if (!procTriggered()) PreventHitDefaultEffect(effIndex); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(CheckRequiredAuraForBaselineEnergize, 0, SpellEffectName.Energize)); - OnEffectHitTarget.Add(new EffectHandler(HandleReverberate, 2, SpellEffectName.Energize)); + OnEffectHitTarget.Add(new(CheckRequiredAuraForBaselineEnergize, 0, SpellEffectName.Energize)); + OnEffectHitTarget.Add(new(HandleReverberate, 2, SpellEffectName.Energize)); } } @@ -255,7 +265,7 @@ namespace Scripts.Spells.Mage { canBeRecalculated = false; Unit caster = GetCaster(); - if (caster) + if (caster != null) amount = (int)(caster.SpellBaseHealingBonusDone(GetSpellInfo().GetSchoolMask()) * 7.0f); } @@ -265,14 +275,14 @@ namespace Scripts.Spells.Mage Unit caster = eventInfo.GetDamageInfo().GetVictim(); Unit target = eventInfo.GetDamageInfo().GetAttacker(); - if (caster && target) + if (caster != null && target != null) caster.CastSpell(target, SpellIds.BlazingBarrierTrigger, true); } public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.ProcTriggerSpell)); + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.SchoolAbsorb)); + OnEffectProc.Add(new(HandleProc, 1, AuraType.ProcTriggerSpell)); } } @@ -280,24 +290,26 @@ namespace Scripts.Spells.Mage [Script] // 4658 - AreaTrigger Create Properties class areatrigger_mage_blizzard : AreaTriggerAI { + TimeSpan TickPeriod = TimeSpan.FromMilliseconds(1000); + TimeSpan _tickTimer; public areatrigger_mage_blizzard(AreaTrigger areatrigger) : base(areatrigger) { - _tickTimer = TimeSpan.FromMilliseconds(1000); + _tickTimer = TickPeriod; } public override void OnUpdate(uint diff) { _tickTimer -= TimeSpan.FromMilliseconds(diff); - while (_tickTimer <= TimeSpan.Zero) + while (_tickTimer <= TimeSpan.FromSeconds(0)) { Unit caster = at.GetCaster(); if (caster != null) - caster.CastSpell(at.GetPosition(), SpellIds.BlizzardDamage, new CastSpellExtraArgs()); + caster.CastSpell(at.GetPosition(), SpellIds.BlizzardDamage); - _tickTimer += TimeSpan.FromMilliseconds(1000); + _tickTimer += TickPeriod; } } } @@ -312,31 +324,30 @@ namespace Scripts.Spells.Mage void HandleSlow(uint effIndex) { - GetCaster().CastSpell(GetHitUnit(), SpellIds.BlizzardSlow, new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress)); + GetCaster().CastSpell(GetHitUnit(), SpellIds.BlizzardSlow, TriggerCastFlags.IgnoreCastInProgress); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleSlow, 0, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new(HandleSlow, 0, SpellEffectName.SchoolDamage)); } } - + [Script] // 198063 - Burning Determination class spell_mage_burning_determination : AuraScript { bool CheckProc(ProcEventInfo eventInfo) { SpellInfo spellInfo = eventInfo.GetSpellInfo(); - if (spellInfo != null) - if (spellInfo.GetAllEffectsMechanicMask().HasAnyFlag(((1u << (int)Mechanics.Interrupt) | (1 << (int)Mechanics.Silence)))) - return true; + if (spellInfo != null && (spellInfo.GetAllEffectsMechanicMask() & ((1 << (int)Mechanics.Interrupt) | (1 << (int)Mechanics.Silence))) != 0) + return true; return false; } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); + DoCheckProc.Add(new(CheckProc)); } } @@ -350,7 +361,7 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectLaunch.Add(new EffectHandler(SuppressSpeedBuff, 2, SpellEffectName.TriggerSpell)); + OnEffectLaunch.Add(new(SuppressSpeedBuff, 2, SpellEffectName.TriggerSpell)); } } @@ -359,13 +370,14 @@ namespace Scripts.Spells.Mage { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 2) && ValidateSpellInfo(SpellIds.CauterizeDot, SpellIds.Cauterized, spellInfo.GetEffect(2).TriggerSpell); + return ValidateSpellEffect((spellInfo.Id, 2)) && ValidateSpellInfo(SpellIds.CauterizeDot, SpellIds.Cauterized, spellInfo.GetEffect(2).TriggerSpell); } void HandleAbsorb(AuraEffect aurEff, DamageInfo dmgInfo, ref uint absorbAmount) { - AuraEffect effectInfo = GetEffect(1); - if (effectInfo == null || !GetTargetApplication().HasEffect(1) || + AuraEffect effect1 = GetEffect(1); + if (effect1 == null || + !GetTargetApplication().HasEffect(1) || dmgInfo.GetDamage() < GetTarget().GetHealth() || dmgInfo.GetDamage() > GetTarget().GetMaxHealth() * 2 || GetTarget().HasAura(SpellIds.Cauterized)) @@ -374,26 +386,26 @@ namespace Scripts.Spells.Mage return; } - GetTarget().SetHealth(GetTarget().CountPctFromMaxHealth(effectInfo.GetAmount())); - GetTarget().CastSpell(GetTarget(), GetEffectInfo(2).TriggerSpell, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); - GetTarget().CastSpell(GetTarget(), SpellIds.CauterizeDot, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); - GetTarget().CastSpell(GetTarget(), SpellIds.Cauterized, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + GetTarget().SetHealth(GetTarget().CountPctFromMaxHealth(effect1.GetAmount())); + GetTarget().CastSpell(GetTarget(), GetEffectInfo(2).TriggerSpell, TriggerCastFlags.FullMask); + GetTarget().CastSpell(GetTarget(), SpellIds.CauterizeDot, TriggerCastFlags.FullMask); + GetTarget().CastSpell(GetTarget(), SpellIds.Cauterized, TriggerCastFlags.FullMask); } public override void Register() { - OnEffectAbsorb.Add(new EffectAbsorbHandler(HandleAbsorb, 0)); + OnEffectAbsorb.Add(new(HandleAbsorb, 0)); } } [Script] // 235219 - Cold Snap class spell_mage_cold_snap : SpellScript { - static uint[] SpellsToReset = + uint[] SpellsToReset = { SpellIds.ConeOfCold, SpellIds.IceBarrier, - SpellIds.IceBlock + SpellIds.IceBlock, }; public override bool Validate(SpellInfo spellInfo) @@ -406,12 +418,12 @@ namespace Scripts.Spells.Mage foreach (uint spellId in SpellsToReset) GetCaster().GetSpellHistory().ResetCooldown(spellId, true); - GetCaster().GetSpellHistory().RestoreCharge(Global.SpellMgr.GetSpellInfo(SpellIds.FrostNova, GetCastDifficulty()).ChargeCategoryId); + GetCaster().GetSpellHistory().RestoreCharge(SpellMgr.GetSpellInfo(SpellIds.FrostNova, GetCastDifficulty()).ChargeCategoryId); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ScriptEffect)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.ScriptEffect)); } } @@ -432,7 +444,8 @@ namespace Scripts.Spells.Mage public override bool Execute(ulong time, uint diff) { Position destPosition = new(_dest.GetPositionX() + RandomHelper.FRand(-3.0f, 3.0f), _dest.GetPositionY() + RandomHelper.FRand(-3.0f, 3.0f), _dest.GetPositionZ()); - _caster.CastSpell(destPosition, SpellIds.CometStormVisual, new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress).SetOriginalCastId(_originalCastId)); + _caster.CastSpell(destPosition, SpellIds.CometStormVisual, + new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress).SetOriginalCastId(_originalCastId)); ++_count; if (_count >= 7) @@ -458,7 +471,7 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectHit.Add(new EffectHandler(EffectHit, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(EffectHit, 0, SpellEffectName.Dummy)); } } @@ -472,15 +485,16 @@ namespace Scripts.Spells.Mage void HandleEffectHitTarget(uint effIndex) { - GetCaster().CastSpell(GetHitDest(), SpellIds.CometStormDamage, new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress).SetOriginalCastId(GetSpell().m_originalCastId)); + GetCaster().CastSpell(GetHitDest(), SpellIds.CometStormDamage, + new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress).SetOriginalCastId(GetSpell().m_originalCastId)); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleEffectHitTarget, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleEffectHitTarget, 0, SpellEffectName.Dummy)); } } - + [Script] // 120 - Cone of Cold class spell_mage_cone_of_cold : SpellScript { @@ -496,7 +510,7 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleSlow, 0, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new(HandleSlow, 0, SpellEffectName.SchoolDamage)); } } @@ -511,10 +525,10 @@ namespace Scripts.Spells.Mage void HandleDummy(uint effIndex) { Player caster = GetCaster().ToPlayer(); - if (caster) + if (caster != null) { Group group = caster.GetGroup(); - if (group) + if (group != null) caster.CastSpell(caster, SpellIds.ConjureRefreshmentTable, true); else caster.CastSpell(caster, SpellIds.ConjureRefreshment, true); @@ -523,12 +537,122 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] // 410939 - Ethereal Blink + class spell_mage_ethereal_blink : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.Blink, SpellIds.Shimmer); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo procInfo) + { + PreventDefaultAction(); + + // this proc only works for players because teleport relocation happens after an Ack + GetTarget().CastSpell(procInfo.GetProcSpell().m_targets.GetDst(), aurEff.GetSpellEffectInfo().TriggerSpell, new CastSpellExtraArgs(aurEff) + .SetTriggeringSpell(procInfo.GetProcSpell()) + .SetCustomArg(GetTarget().GetPosition())); + } + + public override void Register() + { + OnEffectProc.Add(new(HandleProc, 1, AuraType.ProcTriggerSpell)); + } + } + + [Script] // 410941 - Ethereal Blink + class spell_mage_ethereal_blink_triggered : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.Blink, SpellIds.Shimmer, SpellIds.Slow) && ValidateSpellEffect((SpellIds.EtherealBlink, 3)); + } + + void FilterTargets(List targets) + { + Position src = (Position)GetSpell().m_customArg; + WorldLocation dst = GetExplTargetDest(); + if (src == null || dst == null) + { + targets.Clear(); + return; + } + + targets.RemoveAll(target => !target.IsInBetween(src, dst, (target.GetCombatReach() + GetCaster().GetCombatReach()) / 2.0f)); + + AuraEffect reductionEffect = GetCaster().GetAuraEffect(SpellIds.EtherealBlink, 2); + if (reductionEffect == null) + return; + + TimeSpan reduction = TimeSpan.FromSeconds(reductionEffect.GetAmount()) * targets.Count; + + AuraEffect cap = GetCaster().GetAuraEffect(SpellIds.EtherealBlink, 3); + if (cap != null) + if (reduction > TimeSpan.FromSeconds(cap.GetAmount())) + reduction = TimeSpan.FromSeconds(cap.GetAmount()); + + if (reduction > TimeSpan.FromSeconds(0)) + { + GetCaster().GetSpellHistory().ModifyCooldown(SpellIds.Blink, -reduction); + GetCaster().GetSpellHistory().ModifyCooldown(SpellIds.Shimmer, -reduction); + } + } + + void TriggerSlow(uint effIndex) + { + int effectivenessPct = 100; + AuraEffect effectivenessEffect = GetCaster().GetAuraEffect(SpellIds.EtherealBlink, 1); + if (effectivenessEffect != null) + effectivenessPct = effectivenessEffect.GetAmount(); + + int slowPct = SpellMgr.GetSpellInfo(SpellIds.Slow, Difficulty.None).GetEffect(0).CalcBaseValue(GetCaster(), GetHitUnit(), 0, -1); + MathFunctions.ApplyPct(ref slowPct, effectivenessPct); + + GetCaster().CastSpell(GetHitUnit(), SpellIds.Slow, new CastSpellExtraArgs(GetSpell()) + .AddSpellMod(SpellValueMod.BasePoint0, slowPct)); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitDestAreaEnemy)); + OnEffectHitTarget.Add(new(TriggerSlow, 0, SpellEffectName.Dummy)); + } + } + + [Script] // 383395 - Feel the Burn + class spell_mage_feel_the_burn : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.FeelTheBurn); + } + + void CalcAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit caster = GetCaster(); + if (caster != null) + { + AuraEffect valueHolder = caster.GetAuraEffect(SpellIds.FeelTheBurn, 0); + if (valueHolder != null) + amount = valueHolder.GetAmount(); + } + + canBeRecalculated = false; + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalcAmount, 0, AuraType.Mastery)); } } [Script] // 112965 - Fingers of Frost - class spell_mage_fingers_of_frost_AuraScript : AuraScript + class spell_mage_fingers_of_frost : AuraScript { public override bool Validate(SpellInfo spellInfo) { @@ -549,15 +673,15 @@ namespace Scripts.Spells.Mage void Trigger(AuraEffect aurEff, ProcEventInfo eventInfo) { - eventInfo.GetActor().CastSpell(GetTarget(), SpellIds.FingersOfFrost, new CastSpellExtraArgs(aurEff)); + eventInfo.GetActor().CastSpell(GetTarget(), SpellIds.FingersOfFrost, aurEff); } public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckFrostboltProc, 0, AuraType.Dummy)); - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckFrozenOrbProc, 1, AuraType.Dummy)); - AfterEffectProc.Add(new EffectProcHandler(Trigger, 0, AuraType.Dummy)); - AfterEffectProc.Add(new EffectProcHandler(Trigger, 1, AuraType.Dummy)); + DoCheckEffectProc.Add(new(CheckFrostboltProc, 0, AuraType.Dummy)); + DoCheckEffectProc.Add(new(CheckFrozenOrbProc, 1, AuraType.Dummy)); + AfterEffectProc.Add(new(Trigger, 0, AuraType.Dummy)); + AfterEffectProc.Add(new(Trigger, 1, AuraType.Dummy)); } } @@ -573,14 +697,13 @@ namespace Scripts.Spells.Mage void CalcCritChance(Unit victim, ref float critChance) { AuraEffect aurEff = GetCaster().GetAuraEffect(SpellIds.Firestarter, 0); - if (aurEff != null) - if (victim.GetHealthPct() >= aurEff.GetAmount()) - critChance = 100.0f; + if (aurEff != null && victim.GetHealthPct() >= aurEff.GetAmount()) + critChance = 100.0f; } public override void Register() { - OnCalcCritChance.Add(new OnCalcCritChanceHandler(CalcCritChance)); + OnCalcCritChance.Add(new(CalcCritChance)); } } @@ -594,15 +717,14 @@ namespace Scripts.Spells.Mage void CalcCritChance(AuraEffect aurEff, Unit victim, ref float critChance) { - AuraEffect aurEff0 = GetCaster().GetAuraEffect(SpellIds.Firestarter, 0); - if (aurEff0 != null) - if (victim.GetHealthPct() >= aurEff0.GetAmount()) - critChance = 100.0f; + AuraEffect fireStarterEff = GetCaster().GetAuraEffect(SpellIds.Firestarter, 0); + if (fireStarterEff != null && victim.GetHealthPct() >= aurEff.GetAmount()) + critChance = 100.0f; } public override void Register() { - DoEffectCalcCritChance.Add(new EffectCalcCritChanceHandler(CalcCritChance, SpellConst.EffectAll, AuraType.PeriodicDamage)); + DoEffectCalcCritChance.Add(new(CalcCritChance, SpellConst.EffectAll, AuraType.PeriodicDamage)); } } @@ -612,23 +734,23 @@ namespace Scripts.Spells.Mage public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.FireBlast) - && CliDB.SpellCategoryStorage.HasRecord(Global.SpellMgr.GetSpellInfo(SpellIds.FireBlast, Difficulty.None).ChargeCategoryId) - && ValidateSpellEffect(spellInfo.Id, 2); + && CliDB.SpellCategoryStorage.HasRecord(SpellMgr.GetSpellInfo(SpellIds.FireBlast, Difficulty.None).ChargeCategoryId) + && ValidateSpellEffect((spellInfo.Id, 2)); } void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { canBeRecalculated = false; - amount = -(int)MathFunctions.GetPctOf(GetEffectInfo(2).CalcValue() * Time.InMilliseconds, CliDB.SpellCategoryStorage.LookupByKey(Global.SpellMgr.GetSpellInfo(SpellIds.FireBlast, Difficulty.None).ChargeCategoryId).ChargeRecoveryTime); + amount = -(int)MathFunctions.GetPctOf(GetEffectInfo(2).CalcValue() * Time.InMilliseconds, CliDB.SpellCategoryStorage.LookupByKey(SpellMgr.GetSpellInfo(SpellIds.FireBlast, Difficulty.None).ChargeCategoryId).ChargeRecoveryTime); } public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 1, AuraType.ChargeRecoveryMultiplier)); + DoEffectCalcAmount.Add(new(CalculateAmount, 1, AuraType.ChargeRecoveryMultiplier)); } } - // 44614 - Flurry + [Script] // 44614 - Flurry class spell_mage_flurry : SpellScript { class FlurryEvent : BasicEvent @@ -648,13 +770,14 @@ namespace Scripts.Spells.Mage public override bool Execute(ulong time, uint diff) { - Unit target = Global.ObjAccessor.GetUnit(_caster, _target); + Unit target = ObjAccessor.GetUnit(_caster, _target); + if (target == null) return true; _caster.CastSpell(target, SpellIds.FlurryDamage, new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress).SetOriginalCastId(_originalCastId)); - if ((--_count) == 0) + if (--_count == 0) return true; _caster.m_Events.AddEvent(this, TimeSpan.FromMilliseconds(time) + RandomHelper.RandTime(TimeSpan.FromMilliseconds(300), TimeSpan.FromMilliseconds(400))); @@ -674,7 +797,7 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(EffectHit, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(EffectHit, 0, SpellEffectName.Dummy)); } } @@ -693,10 +816,10 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDamage, 1, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new(HandleDamage, 1, SpellEffectName.SchoolDamage)); } } - + [Script] // 116 - Frostbolt class spell_mage_frostbolt : SpellScript { @@ -709,19 +832,38 @@ namespace Scripts.Spells.Mage { Unit target = GetHitUnit(); if (target != null) - GetCaster().CastSpell(target, SpellIds.Chilled, new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress)); + GetCaster().CastSpell(target, SpellIds.Chilled, TriggerCastFlags.IgnoreCastInProgress); } public override void Register() { - OnHit.Add(new HitHandler(HandleChilled)); + OnHit.Add(new(HandleChilled)); } } - + + [Script] // 386737 - Hyper Impact + class spell_mage_hyper_impact : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.Supernova); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + eventInfo.GetActor().CastSpell(eventInfo.GetActionTarget(), SpellIds.Supernova, true); + } + + public override void Register() + { + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); + } + } + [Script] // 11426 - Ice Barrier class spell_mage_ice_barrier : AuraScript { - public override bool Validate(SpellInfo spellEntry) + public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.Chilled); } @@ -730,7 +872,7 @@ namespace Scripts.Spells.Mage { canBeRecalculated = false; Unit caster = GetCaster(); - if (caster) + if (caster != null) amount += (int)(caster.SpellBaseHealingBonusDone(GetSpellInfo().GetSchoolMask()) * 10.0f); } @@ -739,14 +881,14 @@ namespace Scripts.Spells.Mage Unit caster = eventInfo.GetDamageInfo().GetVictim(); Unit target = eventInfo.GetDamageInfo().GetAttacker(); - if (caster && target) + if (caster != null && target != null) caster.CastSpell(target, SpellIds.Chilled, true); } public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.SchoolAbsorb)); + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.SchoolAbsorb)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.SchoolAbsorb)); } } @@ -772,9 +914,9 @@ namespace Scripts.Spells.Mage public override void Register() { - OnObjectTargetSelect.Add(new ObjectTargetSelectHandler(PreventStunWithEverwarmSocks, 0, Targets.UnitCaster)); - OnObjectTargetSelect.Add(new ObjectTargetSelectHandler(PreventEverwarmSocks, 5, Targets.UnitCaster)); - OnObjectTargetSelect.Add(new ObjectTargetSelectHandler(PreventEverwarmSocks, 6, Targets.UnitCaster)); + OnObjectTargetSelect.Add(new(PreventStunWithEverwarmSocks, 0, Targets.UnitCaster)); + OnObjectTargetSelect.Add(new(PreventEverwarmSocks, 5, Targets.UnitCaster)); + OnObjectTargetSelect.Add(new(PreventEverwarmSocks, 6, Targets.UnitCaster)); } } @@ -798,18 +940,21 @@ namespace Scripts.Spells.Mage Unit caster = GetCaster(); Unit target = GetHitUnit(); - int index = _orderedTargets.IndexOf(target.GetGUID()); + var index = _orderedTargets.IndexOf(target.GetGUID()); if (index == 0 // only primary target triggers these benefits && target.HasAuraState(AuraStateType.Frozen, GetSpellInfo(), caster)) { // Thermal Void Aura thermalVoid = caster.GetAura(SpellIds.ThermalVoid); - if (!thermalVoid.GetSpellInfo().GetEffects().Empty()) + if (thermalVoid != null) { - Aura icyVeins = caster.GetAura(SpellIds.IcyVeins); - if (icyVeins != null) - icyVeins.SetDuration(icyVeins.GetDuration() + thermalVoid.GetSpellInfo().GetEffect(0).CalcValue(caster) * Time.InMilliseconds); + if (!thermalVoid.GetSpellInfo().GetEffects().Empty()) + { + Aura icyVeins = caster.GetAura(SpellIds.IcyVeins); + if (icyVeins != null) + icyVeins.SetDuration(icyVeins.GetDuration() + thermalVoid.GetSpellInfo().GetEffect(0).CalcValue(caster) * Time.InMilliseconds); + } } // Chain Reaction @@ -817,7 +962,7 @@ namespace Scripts.Spells.Mage caster.CastSpell(caster, SpellIds.ChainReaction, true); } - // put target index for chain value multiplier into EFFECT_1 base points, otherwise triggered spell doesn't know which damage multiplier to apply + // put target index for chain value multiplier into 1 base points, otherwise triggered spell doesn't know which damage multiplier to apply CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); args.AddSpellMod(SpellValueMod.BasePoint1, index); caster.CastSpell(target, SpellIds.IceLanceTrigger, args); @@ -825,8 +970,8 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectLaunchTarget.Add(new EffectHandler(IndexTarget, 0, SpellEffectName.ScriptEffect)); - OnEffectHitTarget.Add(new EffectHandler(HandleOnHit, 0, SpellEffectName.ScriptEffect)); + OnEffectLaunchTarget.Add(new(IndexTarget, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleOnHit, 0, SpellEffectName.ScriptEffect)); } } @@ -839,7 +984,7 @@ namespace Scripts.Spells.Mage if ((spellValue.CustomBasePointsMask & (1 << 1)) != 0) { int originalDamage = GetHitDamage(); - float targetIndex = (float)spellValue.EffectBasePoints[1]; + float targetIndex = (float)(spellValue.EffectBasePoints[1]); float multiplier = MathF.Pow(GetEffectInfo().CalcDamageMultiplier(GetCaster(), GetSpell()), targetIndex); SetHitDamage((int)(originalDamage * multiplier)); } @@ -847,11 +992,11 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(ApplyDamageMultiplier, 0, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new(ApplyDamageMultiplier, 0, SpellEffectName.SchoolDamage)); } } - [Script] // 11119 - Ignite + [Script] // 12846 - Ignite class spell_mage_ignite : AuraScript { public override bool Validate(SpellInfo spellInfo) @@ -861,16 +1006,17 @@ namespace Scripts.Spells.Mage bool CheckProc(ProcEventInfo eventInfo) { - return eventInfo.GetProcTarget(); + return eventInfo.GetProcTarget() != null; } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - SpellInfo igniteDot = Global.SpellMgr.GetSpellInfo(SpellIds.Ignite, GetCastDifficulty()); + SpellInfo igniteDot = SpellMgr.GetSpellInfo(SpellIds.Ignite, GetCastDifficulty()); int pct = aurEff.GetAmount(); + Cypher.Assert(igniteDot.GetMaxTicks() > 0); int amount = (int)(MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), pct) / igniteDot.GetMaxTicks()); CastSpellExtraArgs args = new(aurEff); @@ -880,8 +1026,8 @@ namespace Scripts.Spells.Mage public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -897,19 +1043,19 @@ namespace Scripts.Spells.Mage void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - eventInfo.GetActor().CastSpell((Unit)null, SpellIds.ManaSurge, true); + eventInfo.GetActor().CastSpell(null, SpellIds.ManaSurge, true); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 1, AuraType.Dummy)); } } [Script] // 1463 - Incanter's Flow class spell_mage_incanters_flow : AuraScript { - sbyte modifier = 1; + int modifier = 1; public override bool Validate(SpellInfo spellInfo) { @@ -942,7 +1088,7 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodicTick, 0, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandlePeriodicTick, 0, AuraType.PeriodicDummy)); } } @@ -962,7 +1108,7 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -987,8 +1133,8 @@ namespace Scripts.Spells.Mage public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitDestAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(HandleSpread, 1, SpellEffectName.SchoolDamage)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 1, Targets.UnitDestAreaEnemy)); + OnEffectHitTarget.Add(new(HandleSpread, 1, SpellEffectName.SchoolDamage)); } } @@ -1006,20 +1152,32 @@ namespace Scripts.Spells.Mage return; Unit caster = GetCaster(); - if (caster) + if (caster != null) caster.CastSpell(GetTarget(), SpellIds.LivingBombExplosion, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, aurEff.GetAmount())); } public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 2, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(AfterRemove, 2, AuraType.Dummy, AuraEffectHandleModes.Real)); } } - // @todo move out of here and rename - not a mage spell + /// @todo move out of here and rename - not a mage spell [Script] // 32826 - Polymorph (Visual) class spell_mage_polymorph_visual : SpellScript { + const uint NpcAurosalia = 18744; + + uint[] PolymorhForms = + { + SpellIds.SquirrelForm, + SpellIds.GiraffeForm, + SpellIds.SerpentForm, + SpellIds.DragonhawkForm, + SpellIds.WorgenForm, + SpellIds.SheepForm + }; + public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(PolymorhForms); @@ -1027,28 +1185,17 @@ namespace Scripts.Spells.Mage void HandleDummy(uint effIndex) { - Unit target = GetCaster().FindNearestCreature(NPC_AUROSALIA, 30.0f); - if (target) - if (target.IsTypeId(TypeId.Unit)) + Unit target = GetCaster().FindNearestCreature(NpcAurosalia, 30.0f); + if (target != null) + if (target.GetTypeId() == TypeId.Unit) target.CastSpell(target, PolymorhForms[RandomHelper.IRand(0, 5)], true); } public override void Register() { // add dummy effect spell handler to Polymorph visual - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } - - const uint NPC_AUROSALIA = 18744; - uint[] PolymorhForms = - { - SpellIds.SquirrelForm, - SpellIds.GiraffeForm, - SpellIds.SerpentForm, - SpellIds.DradonhawkForm, - SpellIds.WorgenForm, - SpellIds.SheepForm - }; } [Script] // 235450 - Prismatic Barrier @@ -1063,13 +1210,38 @@ namespace Scripts.Spells.Mage { canBeRecalculated = false; Unit caster = GetCaster(); - if (caster) - amount += (int)MathFunctions.CalculatePct(caster.GetMaxHealth(), GetEffectInfo(5).CalcValue(caster)); + if (caster != null) + amount = (int)MathFunctions.CalculatePct(caster.GetMaxHealth(), GetEffectInfo(5).CalcValue(caster)); } public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.SchoolAbsorb)); + } + } + + [Script] // 376103 - Radiant Spark + class spell_mage_radiant_spark : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.RadiantSparkProcBlocker); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo procInfo) + { + Aura vulnerability = procInfo.GetProcTarget().GetAura(aurEff.GetSpellEffectInfo().TriggerSpell, GetCasterGUID()); + if (vulnerability != null && vulnerability.GetStackAmount() == vulnerability.CalcMaxStackAmount()) + { + PreventDefaultAction(); + vulnerability.Remove(); + GetTarget().CastSpell(GetTarget(), SpellIds.RadiantSparkProcBlocker, true); + } + } + + public override void Register() + { + OnEffectProc.Add(new(HandleProc, 2, AuraType.ProcTriggerSpell)); } } @@ -1085,17 +1257,17 @@ namespace Scripts.Spells.Mage { Unit caster = GetCaster(); if (caster != null) - caster.CastSpell(caster, SpellIds.RayOfFrostFingersOfFrost, new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress)); + caster.CastSpell(caster, SpellIds.RayOfFrostFingersOfFrost, TriggerCastFlags.IgnoreCastInProgress); } public override void Register() { - OnHit.Add(new HitHandler(HandleOnHit)); + OnHit.Add(new(HandleOnHit)); } } [Script] - class spell_mage_ray_of_frost_aura : AuraScript + class spell_mage_ray_of_frost_AuraScript : AuraScript { public override bool Validate(SpellInfo spellInfo) { @@ -1121,36 +1293,39 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 1, AuraType.PeriodicDamage)); - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 1, AuraType.PeriodicDamage, AuraEffectHandleModes.Real)); + OnEffectPeriodic.Add(new(HandleEffectPeriodic, 1, AuraType.PeriodicDamage)); + AfterEffectRemove.Add(new(OnRemove, 1, AuraType.PeriodicDamage, AuraEffectHandleModes.Real)); } } - + [Script] // 136511 - Ring of Frost class spell_mage_ring_of_frost : AuraScript { + ObjectGuid _ringOfFrostGUID; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.RingOfFrostSummon, SpellIds.RingOfFrostFreeze) && ValidateSpellEffect(SpellIds.RingOfFrostSummon, 0); + return ValidateSpellInfo(SpellIds.RingOfFrostSummon, SpellIds.RingOfFrostFreeze) + && ValidateSpellEffect((SpellIds.RingOfFrostSummon, 0)); } void HandleEffectPeriodic(AuraEffect aurEff) { TempSummon ringOfFrost = GetRingOfFrostMinion(); - if (ringOfFrost) - GetTarget().CastSpell(ringOfFrost.GetPosition(), SpellIds.RingOfFrostFreeze, new CastSpellExtraArgs(true)); + if (ringOfFrost != null) + GetTarget().CastSpell(ringOfFrost.GetPosition(), SpellIds.RingOfFrostFreeze, true); } void Apply(AuraEffect aurEff, AuraEffectHandleModes mode) { List minions = new(); - GetTarget().GetAllMinionsByEntry(minions, (uint)Global.SpellMgr.GetSpellInfo(SpellIds.RingOfFrostSummon, GetCastDifficulty()).GetEffect(0).MiscValue); + GetTarget().GetAllMinionsByEntry(minions, (uint)SpellMgr.GetSpellInfo(SpellIds.RingOfFrostSummon, GetCastDifficulty()).GetEffect(0).MiscValue); // Get the last summoned RoF, save it and despawn older ones - foreach (var summon in minions) + foreach (TempSummon summon in minions) { TempSummon ringOfFrost = GetRingOfFrostMinion(); - if (ringOfFrost) + if (ringOfFrost != null) { if (summon.GetTimer() > ringOfFrost.GetTimer()) { @@ -1167,19 +1342,17 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.ProcTriggerSpell)); - OnEffectApply.Add(new EffectApplyHandler(Apply, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.RealOrReapplyMask)); + OnEffectPeriodic.Add(new(HandleEffectPeriodic, 0, AuraType.PeriodicTriggerSpell)); + OnEffectApply.Add(new(Apply, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.RealOrReapplyMask)); } TempSummon GetRingOfFrostMinion() { Creature creature = ObjectAccessor.GetCreature(GetOwner(), _ringOfFrostGUID); - if (creature) + if (creature != null) return creature.ToTempSummon(); return null; } - - ObjectGuid _ringOfFrostGUID; } [Script] // 82691 - Ring of Frost (freeze efect) @@ -1187,28 +1360,28 @@ namespace Scripts.Spells.Mage { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.RingOfFrostSummon, SpellIds.RingOfFrostFreeze) && ValidateSpellEffect(SpellIds.RingOfFrostSummon, 0); + return ValidateSpellInfo(SpellIds.RingOfFrostSummon, SpellIds.RingOfFrostFreeze) + && ValidateSpellEffect((SpellIds.RingOfFrostSummon, 0)); } void FilterTargets(List targets) { WorldLocation dest = GetExplTargetDest(); - float outRadius = Global.SpellMgr.GetSpellInfo(SpellIds.RingOfFrostSummon, GetCastDifficulty()).GetEffect(0).CalcRadius(null, SpellTargetIndex.TargetB); + float outRadius = SpellMgr.GetSpellInfo(SpellIds.RingOfFrostSummon, GetCastDifficulty()).GetEffect(0).CalcRadius(null, SpellTargetIndex.TargetB); float inRadius = 6.5f; targets.RemoveAll(target => { Unit unit = target.ToUnit(); - if (!unit) + if (unit == null) return true; - return unit.HasAura(SpellIds.RingOfFrostDummy) || unit.HasAura(SpellIds.RingOfFrostFreeze) || unit.GetExactDist(dest) > outRadius || unit.GetExactDist(dest) < inRadius; }); } public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaEnemy)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitDestAreaEnemy)); } } @@ -1223,13 +1396,13 @@ namespace Scripts.Spells.Mage void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire) - if (GetCaster()) + if (GetCaster() != null) GetCaster().CastSpell(GetTarget(), SpellIds.RingOfFrostDummy, true); } public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ModStun, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(OnRemove, 0, AuraType.ModStun, AuraEffectHandleModes.Real)); } } @@ -1248,12 +1421,12 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDamage, 1, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new(HandleDamage, 1, SpellEffectName.SchoolDamage)); } } [Script] // 210824 - Touch of the Magi (Aura) - class spell_mage_touch_of_the_magi_aura : AuraScript + class spell_mage_touch_of_the_magi : AuraScript { public override bool Validate(SpellInfo spellInfo) { @@ -1287,8 +1460,8 @@ namespace Scripts.Spells.Mage public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); + AfterEffectRemove.Add(new(AfterRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -1303,7 +1476,7 @@ namespace Scripts.Spells.Mage void HandleImprovedFreeze() { Unit owner = GetCaster().GetOwner(); - if (!owner) + if (owner == null) return; owner.CastSpell(owner, SpellIds.FingersOfFrost, true); @@ -1311,7 +1484,7 @@ namespace Scripts.Spells.Mage public override void Register() { - AfterHit.Add(new HitHandler(HandleImprovedFreeze)); + AfterHit.Add(new(HandleImprovedFreeze)); } } -} +} \ No newline at end of file diff --git a/Source/Scripts/Spells/Monk.cs b/Source/Scripts/Spells/Monk.cs index 4b4e713e2..8e0c7d596 100644 --- a/Source/Scripts/Spells/Monk.cs +++ b/Source/Scripts/Spells/Monk.cs @@ -1,17 +1,17 @@ -// Copyright (c) CypherCore All rights reserved. +// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; using Game.Entities; using Game.Scripting; using Game.Spells; -using System; -using System.Collections.Generic; +using static Global; namespace Scripts.Spells.Monk { struct SpellIds { + public const uint CalmingCoalescence = 388220; public const uint CracklingJadeLightningChannel = 117952; public const uint CracklingJadeLightningChiProc = 123333; public const uint CracklingJadeLightningKnockback = 117962; @@ -21,6 +21,7 @@ namespace Scripts.Spells.Monk public const uint ProvokeSingleTarget = 116189; public const uint ProvokeAoe = 118635; public const uint NoFeatherFall = 79636; + public const uint OpenPalmStrikesTalent = 392970; public const uint RollBackward = 109131; public const uint RollForward = 107427; public const uint SoothingMist = 115175; @@ -32,6 +33,27 @@ namespace Scripts.Spells.Monk public const uint SurgingMistHeal = 116995; } + struct MonkUtility + { + // Utility for stagger scripts + public static Aura FindExistingStaggerEffect(Unit unit) + { + Aura auraLight = unit.GetAura(SpellIds.StaggerLight); + if (auraLight != null) + return auraLight; + + Aura auraModerate = unit.GetAura(SpellIds.StaggerModerate); + if (auraModerate != null) + return auraModerate; + + Aura auraHeavy = unit.GetAura(SpellIds.StaggerHeavy); + if (auraHeavy != null) + return auraHeavy; + + return null; + } + } + [Script] // 117952 - Crackling Jade Lightning class spell_monk_crackling_jade_lightning : AuraScript { @@ -43,23 +65,25 @@ namespace Scripts.Spells.Monk void OnTick(AuraEffect aurEff) { Unit caster = GetCaster(); - if (caster) + if (caster != null) if (caster.HasAura(SpellIds.StanceOfTheSpiritedCrane)) - caster.CastSpell(caster, SpellIds.CracklingJadeLightningChiProc, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + caster.CastSpell(caster, SpellIds.CracklingJadeLightningChiProc, TriggerCastFlags.FullMask); } public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(OnTick, 0, AuraType.PeriodicDamage)); + OnEffectPeriodic.Add(new(OnTick, 0, AuraType.PeriodicDamage)); } } [Script] // 117959 - Crackling Jade Lightning - class spell_monk_crackling_jade_lightning_knockback_proc_aura : AuraScript + class spell_monk_crackling_jade_lightning_knockback_proc : AuraScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.CracklingJadeLightningKnockback, SpellIds.CracklingJadeLightningKnockbackCd); + return ValidateSpellInfo(SpellIds.CracklingJadeLightningKnockback, + SpellIds.CracklingJadeLightningKnockbackCd + ); } bool CheckProc(ProcEventInfo eventInfo) @@ -71,7 +95,7 @@ namespace Scripts.Spells.Monk return false; Spell currentChanneledSpell = GetTarget().GetCurrentSpell(CurrentSpellTypes.Channeled); - if (!currentChanneledSpell || currentChanneledSpell.GetSpellInfo().Id != SpellIds.CracklingJadeLightningChannel) + if (currentChanneledSpell == null || currentChanneledSpell.GetSpellInfo().Id != SpellIds.CracklingJadeLightningChannel) return false; return true; @@ -79,14 +103,65 @@ namespace Scripts.Spells.Monk void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - GetTarget().CastSpell(eventInfo.GetActor(), SpellIds.CracklingJadeLightningKnockback, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); - GetTarget().CastSpell(GetTarget(), SpellIds.CracklingJadeLightningKnockbackCd, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + GetTarget().CastSpell(eventInfo.GetActor(), SpellIds.CracklingJadeLightningKnockback, TriggerCastFlags.FullMask); + GetTarget().CastSpell(GetTarget(), SpellIds.CracklingJadeLightningKnockbackCd, TriggerCastFlags.FullMask); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); + } + } + + [Script] // 116849 - Life Cocoon + class spell_monk_life_cocoon : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.CalmingCoalescence); + } + + void CalculateAbsorb(uint effIndex) + { + int absorb = (int)GetCaster().CountPctFromMaxHealth(GetEffectValue()); + Player player = GetCaster().ToPlayer(); + if (player != null) + MathFunctions.AddPct(ref absorb, player.GetRatingBonusValue(CombatRating.VersatilityHealingDone)); + + AuraEffect calmingCoalescence = GetCaster().GetAuraEffect(SpellIds.CalmingCoalescence, 0, GetCaster().GetGUID()); + if (calmingCoalescence != null) + { + MathFunctions.AddPct(ref absorb, calmingCoalescence.GetAmount()); + calmingCoalescence.GetBase().Remove(); + } + + GetSpell().SetSpellValue(SpellValueMod.BasePoint0, absorb); + } + + public override void Register() + { + OnEffectLaunch.Add(new(CalculateAbsorb, 2, SpellEffectName.Dummy)); + } + } + + [Script] // 392972 - Open Palm Strikes + class spell_monk_open_palm_strikes : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellEffect((SpellIds.OpenPalmStrikesTalent, 1)); + } + + bool CheckProc(AuraEffect aurEff, ProcEventInfo procInfo) + { + AuraEffect talent = GetTarget().GetAuraEffect(SpellIds.OpenPalmStrikesTalent, 1); + return talent != null && RandomHelper.randChance(talent.GetAmount()); + } + + public override void Register() + { + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.ProcTriggerSpell)); } } @@ -105,7 +180,7 @@ namespace Scripts.Spells.Monk public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodic, 0, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandlePeriodic, 0, AuraType.PeriodicDummy)); } } @@ -124,10 +199,10 @@ namespace Scripts.Spells.Monk public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } - + [Script] // 115546 - Provoke class spell_monk_provoke : SpellScript { @@ -135,16 +210,18 @@ namespace Scripts.Spells.Monk public override bool Validate(SpellInfo spellInfo) { - if (!spellInfo.GetExplicitTargetMask().HasAnyFlag(SpellCastTargetFlags.UnitMask)) // ensure GetExplTargetUnit() will return something meaningful during CheckCast + if (!spellInfo.GetExplicitTargetMask().HasFlag(SpellCastTargetFlags.UnitMask)) // ensure GetExplTargetUnit() will return something meaningful during CheckCast return false; - return ValidateSpellInfo(SpellIds.ProvokeSingleTarget, SpellIds.ProvokeAoe); + return ValidateSpellInfo(SpellIds.ProvokeSingleTarget, + SpellIds.ProvokeAoe + ); } SpellCastResult CheckExplicitTarget() { if (GetExplTargetUnit().GetEntry() != BlackOxStatusEntry) { - SpellInfo singleTarget = Global.SpellMgr.GetSpellInfo(SpellIds.ProvokeSingleTarget, GetCastDifficulty()); + SpellInfo singleTarget = SpellMgr.GetSpellInfo(SpellIds.ProvokeSingleTarget, GetCastDifficulty()); SpellCastResult singleTargetExplicitResult = singleTarget.CheckExplicitTarget(GetCaster(), GetExplTargetUnit()); if (singleTargetExplicitResult != SpellCastResult.SpellCastOk) return singleTargetExplicitResult; @@ -166,8 +243,8 @@ namespace Scripts.Spells.Monk public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckExplicitTarget)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnCheckCast.Add(new(CheckExplicitTarget)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -189,20 +266,20 @@ namespace Scripts.Spells.Monk void HandleDummy(uint effIndex) { GetCaster().CastSpell(GetCaster(), GetCaster().HasUnitMovementFlag(MovementFlag.Backward) ? SpellIds.RollBackward : SpellIds.RollForward, - new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress)); + TriggerCastFlags.IgnoreCastInProgress); GetCaster().CastSpell(GetCaster(), SpellIds.NoFeatherFall, true); } public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnCheckCast.Add(new(CheckCast)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } // 107427 - Roll [Script] // 109131 - Roll (backward) - class spell_monk_roll_aura : AuraScript + class spell_monk_roll_AuraScript : AuraScript { void CalcMovementAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { @@ -227,17 +304,17 @@ namespace Scripts.Spells.Monk public override void Register() { // Values need manual correction - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalcMovementAmount, 0, AuraType.ModSpeedNoControl)); - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalcMovementAmount, 2, AuraType.ModMinimumSpeed)); - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalcImmunityAmount, 5, AuraType.MechanicImmunity)); - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalcImmunityAmount, 6, AuraType.MechanicImmunity)); + DoEffectCalcAmount.Add(new(CalcMovementAmount, 0, AuraType.ModSpeedNoControl)); + DoEffectCalcAmount.Add(new(CalcMovementAmount, 2, AuraType.ModMinimumSpeed)); + DoEffectCalcAmount.Add(new(CalcImmunityAmount, 5, AuraType.MechanicImmunity)); + DoEffectCalcAmount.Add(new(CalcImmunityAmount, 6, AuraType.MechanicImmunity)); // This is a special aura that sets backward run speed equal to forward speed - AfterEffectApply.Add(new EffectApplyHandler(ChangeRunBackSpeed, 4, AuraType.UseNormalMovementSpeed, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(RestoreRunBackSpeed, 4, AuraType.UseNormalMovementSpeed, AuraEffectHandleModes.Real)); + AfterEffectApply.Add(new(ChangeRunBackSpeed, 4, AuraType.UseNormalMovementSpeed, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(RestoreRunBackSpeed, 4, AuraType.UseNormalMovementSpeed, AuraEffectHandleModes.Real)); } } - + [Script] // 115069 - Stagger class spell_monk_stagger : AuraScript { @@ -257,19 +334,18 @@ namespace Scripts.Spells.Monk if (effect == null) return; - Absorb(dmgInfo, effect.GetAmount() / 100.0f); + Absorb(dmgInfo, (float)(effect.GetAmount()) / 100.0f); } void Absorb(DamageInfo dmgInfo, float multiplier) { - // Prevent default action (which would remove the aura) + // Prevent default action (which would Remove the aura) PreventDefaultAction(); - // make sure damage doesn't come from stagger damage spell SPELL_MONK_STAGGER_DAMAGE_AURA + // make sure damage doesn't come from stagger damage spell SpellIds.StaggerDamageAura SpellInfo dmgSpellInfo = dmgInfo.GetSpellInfo(); - if (dmgSpellInfo != null) - if (dmgSpellInfo.Id == SpellIds.StaggerDamageAura) - return; + if (dmgSpellInfo != null && dmgSpellInfo.Id == SpellIds.StaggerDamageAura) + return; AuraEffect effect = GetEffect(0); if (effect == null) @@ -277,14 +353,14 @@ namespace Scripts.Spells.Monk Unit target = GetTarget(); float agility = target.GetStat(Stats.Agility); - float baseAmount = MathFunctions.CalculatePct(agility, effect.GetAmount()); - float K = Global.DB2Mgr.EvaluateExpectedStat(ExpectedStatType.ArmorConstant, target.GetLevel(), -2, 0, target.GetClass(), 0); + float baseAmount = MathFunctions.CalculatePct(agility, (float)(effect.GetAmount())); + float K = DB2Mgr.EvaluateExpectedStat(ExpectedStatType.ArmorConstant, target.GetLevel(), -2, 0, target.GetClass(), 0); float newAmount = (baseAmount / (baseAmount + K)); newAmount *= multiplier; // Absorb X percentage of the damage - float absorbAmount = dmgInfo.GetDamage() * newAmount; + float absorbAmount = (float)(dmgInfo.GetDamage()) * newAmount; if (absorbAmount > 0) { dmgInfo.AbsorbDamage((uint)absorbAmount); @@ -296,14 +372,14 @@ namespace Scripts.Spells.Monk public override void Register() { - OnEffectAbsorb.Add(new EffectAbsorbHandler(AbsorbNormal, 1)); - OnEffectAbsorb.Add(new EffectAbsorbHandler(AbsorbMagic, 2)); + OnEffectAbsorb.Add(new(AbsorbNormal, 1)); + OnEffectAbsorb.Add(new(AbsorbMagic, 2)); } void AddAndRefreshStagger(float amount) { Unit target = GetTarget(); - Aura auraStagger = FindExistingStaggerEffect(target); + Aura auraStagger = MonkUtility.FindExistingStaggerEffect(target); if (auraStagger != null) { AuraEffect effStaggerRemaining = auraStagger.GetEffect(1); @@ -315,7 +391,7 @@ namespace Scripts.Spells.Monk if (spellId == effStaggerRemaining.GetSpellInfo().Id) { auraStagger.RefreshDuration(); - effStaggerRemaining.ChangeAmount((int)newAmount, false, true /* reapply */); + effStaggerRemaining.ChangeAmount((int)newAmount, false, true); } else { @@ -330,10 +406,10 @@ namespace Scripts.Spells.Monk uint GetStaggerSpellId(Unit unit, float amount) { - const float StaggerHeavy = 0.6f; - const float StaggerModerate = 0.3f; + float StaggerHeavy = 0.6f; + float StaggerModerate = 0.3f; - float staggerPct = amount / unit.GetMaxHealth(); + float staggerPct = amount / (float)(unit.GetMaxHealth()); return (staggerPct >= StaggerHeavy) ? SpellIds.StaggerHeavy : (staggerPct >= StaggerModerate) ? SpellIds.StaggerModerate : SpellIds.StaggerLight; @@ -344,27 +420,10 @@ namespace Scripts.Spells.Monk // We only set the total stagger amount. The amount per tick will be set by the stagger spell script unit.CastSpell(unit, staggerSpellId, new CastSpellExtraArgs(SpellValueMod.BasePoint1, (int)staggerAmount).SetTriggerFlags(TriggerCastFlags.FullMask)); } - - public static Aura FindExistingStaggerEffect(Unit unit) - { - Aura auraLight = unit.GetAura(SpellIds.StaggerLight); - if (auraLight != null) - return auraLight; - - Aura auraModerate = unit.GetAura(SpellIds.StaggerModerate); - if (auraModerate != null) - return auraModerate; - - Aura auraHeavy = unit.GetAura(SpellIds.StaggerHeavy); - if (auraHeavy != null) - return auraHeavy; - - return null; - } } - [Script] // 124255 - Stagger - SPELL_MONK_STAGGER_DAMAGE_AURA - class spell_monk_stagger_damage_aura : AuraScript + [Script] // 124255 - Stagger - SpellIds.StaggerDamageAura + class spell_monk_stagger_damage : AuraScript { public override bool Validate(SpellInfo spellInfo) { @@ -374,14 +433,14 @@ namespace Scripts.Spells.Monk void OnPeriodicDamage(AuraEffect aurEff) { // Update our light/medium/heavy stagger with the correct stagger amount left - Aura auraStagger = spell_monk_stagger.FindExistingStaggerEffect(GetTarget()); + Aura auraStagger = MonkUtility.FindExistingStaggerEffect(GetTarget()); if (auraStagger != null) { AuraEffect auraEff = auraStagger.GetEffect(1); if (auraEff != null) { - float total = auraEff.GetAmount(); - float tickDamage = aurEff.GetAmount(); + float total = (float)(auraEff.GetAmount()); + float tickDamage = (float)(aurEff.GetAmount()); auraEff.ChangeAmount((int)(total - tickDamage)); } } @@ -389,32 +448,31 @@ namespace Scripts.Spells.Monk public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodicDamage, 0, AuraType.PeriodicDamage)); + OnEffectPeriodic.Add(new(OnPeriodicDamage, 0, AuraType.PeriodicDamage)); } } - [Script] // 124273, 124274, 124275 - Light/Moderate/Heavy Stagger - SPELL_MONK_STAGGER_LIGHT / SPELL_MONK_STAGGER_MODERATE / SPELL_MONK_STAGGER_HEAVY - class spell_monk_stagger_debuff_aura : AuraScript + [Script] // 124273, 124274, 124275 - Light/Moderate/Heavy Stagger - SpellIds.StaggerLight / SpellIds.StaggerModerate / SpellIds.StaggerHeavy + class spell_monk_stagger_debuff : AuraScript { float _period; public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.StaggerDamageAura) - && ValidateSpellEffect(SpellIds.StaggerDamageAura, 0); + return ValidateSpellInfo(SpellIds.StaggerDamageAura) && ValidateSpellEffect((SpellIds.StaggerDamageAura, 0)); } public override bool Load() { - _period = (float)Global.SpellMgr.GetSpellInfo(SpellIds.StaggerDamageAura, GetCastDifficulty()).GetEffect(0).ApplyAuraPeriod; + _period = (float)(SpellMgr.GetSpellInfo(SpellIds.StaggerDamageAura, GetCastDifficulty()).GetEffect(0).ApplyAuraPeriod); return true; } void OnReapply(AuraEffect aurEff, AuraEffectHandleModes mode) { // Calculate damage per tick - float total = aurEff.GetAmount(); - float perTick = total * _period / (float)GetDuration(); // should be same as GetMaxDuration() TODO: verify + float total = (float)(aurEff.GetAmount()); + float perTick = total * _period / (float)(GetDuration()); // should be same as GetMaxDuration() Todo: verify // Set amount on effect for tooltip AuraEffect effInfo = GetAura().GetEffect(0); @@ -436,8 +494,8 @@ namespace Scripts.Spells.Monk public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(OnReapply, 1, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectApply.Add(new(OnReapply, 1, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); + AfterEffectRemove.Add(new(OnRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); } void CastOrChangeTickDamage(float tickDamage) diff --git a/Source/Scripts/Spells/Paladin.cs b/Source/Scripts/Spells/Paladin.cs index edd125154..b9255f7ae 100644 --- a/Source/Scripts/Spells/Paladin.cs +++ b/Source/Scripts/Spells/Paladin.cs @@ -1,7 +1,8 @@ -// Copyright (c) CypherCore All rights reserved. +// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; +using Framework.Dynamic; using Game.AI; using Game.DataStorage; using Game.Entities; @@ -9,17 +10,15 @@ using Game.Scripting; using Game.Spells; using System; using System.Collections.Generic; -using Framework.Dynamic; +using System.Linq; +using static Global; namespace Scripts.Spells.Paladin { struct SpellIds { + public const uint ArdentDefenderHeal = 66235; public const uint ArtOfWarTriggered = 231843; - public const uint AshenHallow = 316958; - public const uint AshenHallowDamage = 317221; - public const uint AshenHallowHeal = 317223; - public const uint AshenHallowAllowHammer = 330382; public const uint AvengersShield = 31935; public const uint AvengingWrath = 31884; public const uint BeaconOfLight = 53563; @@ -32,7 +31,8 @@ namespace Scripts.Spells.Paladin public const uint Consecration = 26573; public const uint ConsecrationDamage = 81297; public const uint ConsecrationProtectionAura = 188370; - public const uint DivinePurposeTriggerred = 223819; + public const uint CrusadingStrikesEnergize = 406834; + public const uint DivinePurposeTriggered = 223819; public const uint DivineSteedHuman = 221883; public const uint DivineSteedDwarf = 276111; public const uint DivineSteedDraenei = 221887; @@ -48,7 +48,7 @@ namespace Scripts.Spells.Paladin public const uint FinalStand = 204077; public const uint FinalStandEffect = 204079; public const uint Forbearance = 25771; - public const uint GuardianOfAcientKings = 86659; + public const uint GuardianOfAncientKings = 86659; public const uint HammerOfJustice = 853; public const uint HammerOfTheRighteousAoe = 88263; public const uint HandOfSacrifice = 6940; @@ -81,20 +81,53 @@ namespace Scripts.Spells.Paladin public const uint SealOfRighteousness = 25742; public const uint ShieldOfVengeanceDamage = 184689; public const uint TemplarVerdictDamage = 224266; + public const uint T302PHeartfireDamage = 408399; + public const uint T302PHeartfireHeal = 408400; public const uint ZealAura = 269571; + + public const uint AshenHallow = 316958; + public const uint AshenHallowDamage = 317221; + public const uint AshenHallowHeal = 317223; + public const uint AshenHallowAllowHammer = 330382; } - struct SpellVisualKit + [Script] // 31850 - Ardent Defender + class spell_pal_ardent_defender : AuraScript { - public const uint DivineStorm = 73892; - } + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.ArdentDefenderHeal) + && ValidateSpellEffect((spellInfo.Id, 1)); + } - struct SpellVisual - { - public const uint HolyShockDamage = 83731; - public const uint HolyShockDamageCrit = 83881; - public const uint HolyShockHeal = 83732; - public const uint HolyShockHealCrit = 83880; + void HandleAbsorb(AuraEffect aurEff, DamageInfo dmgInfo, ref uint absorbAmount) + { + PreventDefaultAction(); + + int targetHealthPercent = GetEffectInfo(1).CalcValue(GetTarget()); + ulong targetHealth = (ulong)GetTarget().CountPctFromMaxHealth(targetHealthPercent); + if (GetTarget().HealthBelowPct(targetHealthPercent)) + { + // we are currently below desired health + // absorb everything and heal up + GetTarget().CastSpell(GetTarget(), SpellIds.ArdentDefenderHeal, + new CastSpellExtraArgs(aurEff) + .AddSpellMod(SpellValueMod.BasePoint0, (int)(targetHealth - GetTarget().GetHealth()))); + } + else + { + // we are currently above desired health + // just absorb enough to reach that percentage + absorbAmount = (uint)(dmgInfo.GetDamage() - (int)(GetTarget().GetHealth() - targetHealth)); + } + + Remove(); + } + + public override void Register() + { + OnEffectAbsorb.Add(new(HandleAbsorb, 2)); + } } [Script] // 267344 - Art of War @@ -113,16 +146,16 @@ namespace Scripts.Spells.Paladin void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { GetTarget().GetSpellHistory().ResetCooldown(SpellIds.BladeOfJustice, true); - GetTarget().CastSpell(GetTarget(), SpellIds.ArtOfWarTriggered, new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress)); + GetTarget().CastSpell(GetTarget(), SpellIds.ArtOfWarTriggered, TriggerCastFlags.IgnoreCastInProgress); } public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckProc, 0, AuraType.Dummy)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } - + [Script] // 19042 - Ashen Hallow class areatrigger_pal_ashen_hallow : AreaTriggerAI { @@ -152,13 +185,13 @@ namespace Scripts.Spells.Paladin { _refreshTimer -= TimeSpan.FromMilliseconds(diff); - while (_refreshTimer <= TimeSpan.Zero) + while (_refreshTimer <= TimeSpan.FromSeconds(0)) { Unit caster = at.GetCaster(); if (caster != null) { - caster.CastSpell(at.GetPosition(), SpellIds.AshenHallowHeal, new CastSpellExtraArgs()); - caster.CastSpell(at.GetPosition(), SpellIds.AshenHallowDamage, new CastSpellExtraArgs()); + caster.CastSpell(at.GetPosition(), SpellIds.AshenHallowHeal); + caster.CastSpell(at.GetPosition(), SpellIds.AshenHallowDamage); } RefreshPeriod(); @@ -185,7 +218,8 @@ namespace Scripts.Spells.Paladin { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.AvengingWrath) && ValidateSpellEffect(spellInfo.Id, 1); + return ValidateSpellInfo(SpellIds.AvengingWrath) + && ValidateSpellEffect((spellInfo.Id, 1)); } bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -195,16 +229,16 @@ namespace Scripts.Spells.Paladin void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - TimeSpan extraDuration = TimeSpan.Zero; + TimeSpan extraDuration = TimeSpan.FromMilliseconds(0); AuraEffect durationEffect = GetEffect(1); if (durationEffect != null) - extraDuration = TimeSpan.FromSeconds(durationEffect.GetAmount()); + extraDuration = TimeSpan.FromSeconds(durationEffect.GetAmount()); Aura avengingWrath = GetTarget().GetAura(SpellIds.AvengingWrath); if (avengingWrath != null) { - avengingWrath.SetDuration((int)(avengingWrath.GetDuration() + extraDuration.TotalMilliseconds)); - avengingWrath.SetMaxDuration((int)(avengingWrath.GetMaxDuration() + extraDuration.TotalMilliseconds)); + avengingWrath.SetDuration(avengingWrath.GetDuration() + (int)extraDuration.TotalMilliseconds); + avengingWrath.SetMaxDuration(avengingWrath.GetMaxDuration() + (int)extraDuration.TotalMilliseconds); } else GetTarget().CastSpell(GetTarget(), SpellIds.AvengingWrath, @@ -215,19 +249,18 @@ namespace Scripts.Spells.Paladin public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckProc, 0, AuraType.Dummy)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } - + // 1022 - Blessing of Protection [Script] // 204018 - Blessing of Spellwarding class spell_pal_blessing_of_protection : SpellScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.Forbearance) //, SpellIds._PALADIN_IMMUNE_SHIELD_MARKER) // uncomment when we have serverside only spells - && spellInfo.ExcludeTargetAuraSpell == SpellIds.ImmuneShieldMarker; + return ValidateSpellInfo(SpellIds.Forbearance, SpellIds.ImmuneShieldMarker) && spellInfo.ExcludeTargetAuraSpell == SpellIds.ImmuneShieldMarker; } SpellCastResult CheckForbearance() @@ -242,7 +275,7 @@ namespace Scripts.Spells.Paladin void TriggerForbearance() { Unit target = GetHitUnit(); - if (target) + if (target != null) { GetCaster().CastSpell(target, SpellIds.Forbearance, true); GetCaster().CastSpell(target, SpellIds.ImmuneShieldMarker, true); @@ -251,8 +284,8 @@ namespace Scripts.Spells.Paladin public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckForbearance)); - AfterHit.Add(new HitHandler(TriggerForbearance)); + OnCheckCast.Add(new(CheckForbearance)); + AfterHit.Add(new(TriggerForbearance)); } } @@ -267,13 +300,13 @@ namespace Scripts.Spells.Paladin void HandleDummy(uint effIndex) { Unit target = GetHitUnit(); - if (target) + if (target != null) GetCaster().CastSpell(target, SpellIds.BlindingLightEffect, true); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ApplyAura)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.ApplyAura)); } } @@ -288,13 +321,13 @@ namespace Scripts.Spells.Paladin void HandleEffectPeriodic(AuraEffect aurEff) { AreaTrigger at = GetTarget().GetAreaTrigger(SpellIds.Consecration); - if (at != null) - GetTarget().CastSpell(at.GetPosition(), SpellIds.ConsecrationDamage, new CastSpellExtraArgs()); + if (at) + GetTarget().CastSpell(at.GetPosition(), SpellIds.ConsecrationDamage); } public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); } } @@ -343,7 +376,32 @@ namespace Scripts.Spells.Paladin public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.Dummy)); + } + } + + [Script] // 406833 - Crusading Strikes + class spell_pal_crusading_strikes : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.CrusadingStrikesEnergize); + } + + void HandleEffectProc(AuraEffect aurEff, AuraEffectHandleModes mode) + { + if (GetStackAmount() == 2) + { + GetTarget().CastSpell(GetTarget(), SpellIds.CrusadingStrikesEnergize, aurEff); + + // this spell has weird proc order dependency set up in db2 data so we do removal manually + Remove(); + } + } + + public override void Register() + { + AfterEffectApply.Add(new(HandleEffectProc, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.RealOrReapplyMask)); } } @@ -352,13 +410,13 @@ namespace Scripts.Spells.Paladin { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.DivinePurposeTriggerred); + return ValidateSpellInfo(SpellIds.DivinePurposeTriggered); } bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo) { Spell procSpell = eventInfo.GetProcSpell(); - if (!procSpell) + if (procSpell == null) return false; if (!procSpell.HasPowerTypeCost(PowerType.HolyPower)) @@ -369,24 +427,23 @@ namespace Scripts.Spells.Paladin void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - eventInfo.GetActor().CastSpell(eventInfo.GetActor(), SpellIds.DivinePurposeTriggerred, + eventInfo.GetActor().CastSpell(eventInfo.GetActor(), SpellIds.DivinePurposeTriggered, new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress).SetTriggeringSpell(eventInfo.GetProcSpell())); } public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckProc, 0, AuraType.Dummy)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } - + [Script] // 642 - Divine Shield class spell_pal_divine_shield : SpellScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.FinalStand, SpellIds.FinalStandEffect, SpellIds.Forbearance) //, SpellIds._PALADIN_IMMUNE_SHIELD_MARKER // uncomment when we have serverside only spells - && spellInfo.ExcludeCasterAuraSpell == SpellIds.ImmuneShieldMarker; + return ValidateSpellInfo(SpellIds.FinalStand, SpellIds.FinalStandEffect, SpellIds.Forbearance, SpellIds.ImmuneShieldMarker) && spellInfo.ExcludeCasterAuraSpell == SpellIds.ImmuneShieldMarker; } SpellCastResult CheckForbearance() @@ -400,7 +457,7 @@ namespace Scripts.Spells.Paladin void HandleFinalStand() { if (GetCaster().HasAura(SpellIds.FinalStand)) - GetCaster().CastSpell((Unit)null, SpellIds.FinalStandEffect, true); + GetCaster().CastSpell(null, SpellIds.FinalStandEffect, true); } void TriggerForbearance() @@ -412,9 +469,9 @@ namespace Scripts.Spells.Paladin public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckForbearance)); - AfterCast.Add(new CastHandler(HandleFinalStand)); - AfterCast.Add(new CastHandler(TriggerForbearance)); + OnCheckCast.Add(new(CheckForbearance)); + AfterCast.Add(new(HandleFinalStand)); + AfterCast.Add(new(TriggerForbearance)); } } @@ -423,69 +480,54 @@ namespace Scripts.Spells.Paladin { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.DivineSteedHuman, SpellIds.DivineSteedDwarf, SpellIds.DivineSteedDraenei, SpellIds.DivineSteedDarkIronDwarf, SpellIds.DivineSteedBloodelf, SpellIds.DivineSteedTauren, SpellIds.DivineSteedZandalariTroll, SpellIds.DivineSteedLfDraenei); + return ValidateSpellInfo(SpellIds.DivineSteedHuman, SpellIds.DivineSteedDwarf, SpellIds.DivineSteedDraenei, SpellIds.DivineSteedDarkIronDwarf, + SpellIds.DivineSteedBloodelf, SpellIds.DivineSteedTauren, SpellIds.DivineSteedZandalariTroll, SpellIds.DivineSteedLfDraenei); } void HandleOnCast() { Unit caster = GetCaster(); - uint spellId = SpellIds.DivineSteedHuman; - switch (caster.GetRace()) + uint spellId = caster.GetRace() switch { - case Race.Human: - spellId = SpellIds.DivineSteedHuman; - break; - case Race.Dwarf: - spellId = SpellIds.DivineSteedDwarf; - break; - case Race.Draenei: - spellId = SpellIds.DivineSteedDraenei; - break; - case Race.LightforgedDraenei: - spellId = SpellIds.DivineSteedLfDraenei; - break; - case Race.DarkIronDwarf: - spellId = SpellIds.DivineSteedDarkIronDwarf; - break; - case Race.BloodElf: - spellId = SpellIds.DivineSteedBloodelf; - break; - case Race.Tauren: - spellId = SpellIds.DivineSteedTauren; - break; - case Race.ZandalariTroll: - spellId = SpellIds.DivineSteedZandalariTroll; - break; - default: - break; - } + Race.Human => SpellIds.DivineSteedHuman, + Race.Dwarf => SpellIds.DivineSteedDwarf, + Race.Draenei => SpellIds.DivineSteedDraenei, + Race.LightforgedDraenei => SpellIds.DivineSteedLfDraenei, + Race.DarkIronDwarf => SpellIds.DivineSteedDarkIronDwarf, + Race.BloodElf => SpellIds.DivineSteedBloodelf, + Race.Tauren => SpellIds.DivineSteedTauren, + Race.ZandalariTroll => SpellIds.DivineSteedZandalariTroll, + _ => SpellIds.DivineSteedHuman + }; caster.CastSpell(caster, spellId, true); } public override void Register() { - OnCast.Add(new CastHandler(HandleOnCast)); + OnCast.Add(new(HandleOnCast)); } } - [Script] // 224239 - Divine Storm + [Script] // 53385 - Divine Storm class spell_pal_divine_storm : SpellScript { + const uint PaladinVisualKitDivineStorm = 73892; + public override bool Validate(SpellInfo spellInfo) { - return CliDB.SpellVisualKitStorage.HasRecord(SpellVisualKit.DivineStorm); + return CliDB.SpellVisualKitStorage.HasRecord(PaladinVisualKitDivineStorm); } void HandleOnCast() { - GetCaster().SendPlaySpellVisualKit(SpellVisualKit.DivineStorm, 0, 0); + GetCaster().SendPlaySpellVisualKit(PaladinVisualKitDivineStorm, 0, 0); } public override void Register() { - OnCast.Add(new CastHandler(HandleOnCast)); + OnCast.Add(new(HandleOnCast)); } } @@ -504,10 +546,10 @@ namespace Scripts.Spells.Paladin public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.Dummy)); } } - + [Script] // 234299 - Fist of Justice class spell_pal_fist_of_justice : AuraScript { @@ -534,8 +576,8 @@ namespace Scripts.Spells.Paladin public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckEffectProc, 0, AuraType.Dummy)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); + DoCheckEffectProc.Add(new(CheckEffectProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.Dummy)); } } @@ -549,7 +591,7 @@ namespace Scripts.Spells.Paladin bool CheckProc(ProcEventInfo eventInfo) { - return GetTarget().IsTypeId(TypeId.Player); + return GetTarget().IsPlayer(); } void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -559,8 +601,8 @@ namespace Scripts.Spells.Paladin public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.ProcTriggerSpell)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.ProcTriggerSpell)); } } @@ -580,7 +622,7 @@ namespace Scripts.Spells.Paladin public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitDestAreaAlly)); } } @@ -600,7 +642,7 @@ namespace Scripts.Spells.Paladin public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleAoEHit, 0, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new(HandleAoEHit, 0, SpellEffectName.SchoolDamage)); } } @@ -612,7 +654,7 @@ namespace Scripts.Spells.Paladin public override bool Load() { Unit caster = GetCaster(); - if (caster) + if (caster != null) { remainingAmount = (int)caster.GetMaxHealth(); return true; @@ -632,14 +674,14 @@ namespace Scripts.Spells.Paladin public override void Register() { - OnEffectSplit.Add(new EffectSplitHandler(Split, 0)); + OnEffectSplit.Add(new(Split, 0)); } } [Script] // 54149 - Infusion of Light class spell_pal_infusion_of_light : AuraScript { - static FlagArray128 HolyLightSpellClassMask = new(0, 0, 0x400); + FlagArray128 HolyLightSpellClassMask = new(0, 0, 0x400); public override bool Validate(SpellInfo spellInfo) { @@ -648,7 +690,7 @@ namespace Scripts.Spells.Paladin bool CheckFlashOfLightProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return eventInfo.GetProcSpell() && eventInfo.GetProcSpell().m_appliedMods.Contains(GetAura()); + return eventInfo.GetProcSpell() != null && eventInfo.GetProcSpell().m_appliedMods.Contains(GetAura()); } bool CheckHolyLightProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -664,14 +706,14 @@ namespace Scripts.Spells.Paladin public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckFlashOfLightProc, 0, AuraType.AddPctModifier)); - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckFlashOfLightProc, 2, AuraType.AddFlatModifier)); + DoCheckEffectProc.Add(new(CheckFlashOfLightProc, 0, AuraType.AddPctModifier)); + DoCheckEffectProc.Add(new(CheckFlashOfLightProc, 2, AuraType.AddFlatModifier)); - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckHolyLightProc, 1, AuraType.Dummy)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); + DoCheckEffectProc.Add(new(CheckHolyLightProc, 1, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 1, AuraType.Dummy)); } } - + [Script] // 327193 - Moment of Glory class spell_pal_moment_of_glory : SpellScript { @@ -687,7 +729,7 @@ namespace Scripts.Spells.Paladin public override void Register() { - OnHit.Add(new HitHandler(HandleOnHit)); + OnHit.Add(new(HandleOnHit)); } } @@ -702,6 +744,7 @@ namespace Scripts.Spells.Paladin void HandleOnHit() { Unit caster = GetCaster(); + if (caster.HasSpell(SpellIds.JudgmentProtRetR3)) caster.CastSpell(caster, SpellIds.JudgmentGainHolyPower, GetSpell()); @@ -711,7 +754,7 @@ namespace Scripts.Spells.Paladin public override void Register() { - OnHit.Add(new HitHandler(HandleOnHit)); + OnHit.Add(new(HandleOnHit)); } } @@ -735,7 +778,7 @@ namespace Scripts.Spells.Paladin public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -748,7 +791,7 @@ namespace Scripts.Spells.Paladin public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.HolyPrismTargetAlly, SpellIds.HolyPrismTargetBeamVisual); + return ValidateSpellInfo(SpellIds.HolyPrismTargetAlly, SpellIds.HolyPrismAreaBeamVisual); } void SaveTargetGuid(uint effIndex) @@ -782,25 +825,25 @@ namespace Scripts.Spells.Paladin void HandleScript(uint effIndex) { - Unit initialTarget = Global.ObjAccessor.GetUnit(GetCaster(), _targetGUID); - if (initialTarget != null) - initialTarget.CastSpell(GetHitUnit(), SpellIds.HolyPrismTargetBeamVisual, true); + Unit initialTarget = ObjAccessor.GetUnit(GetCaster(), _targetGUID); + if (initialTarget) + initialTarget.CastSpell(GetHitUnit(), SpellIds.HolyPrismAreaBeamVisual, true); } public override void Register() { if (m_scriptSpellId == SpellIds.HolyPrismTargetEnemy) - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitDestAreaAlly)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 1, Targets.UnitDestAreaAlly)); else if (m_scriptSpellId == SpellIds.HolyPrismTargetAlly) - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitDestAreaEnemy)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 1, Targets.UnitDestAreaEnemy)); - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(ShareTargets, 2, Targets.UnitDestAreaEntry)); + OnObjectAreaTargetSelect.Add(new(ShareTargets, 2, Targets.UnitDestAreaEntry)); - OnEffectHitTarget.Add(new EffectHandler(SaveTargetGuid, 0, SpellEffectName.Any)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 2, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(SaveTargetGuid, 0, SpellEffectName.Any)); + OnEffectHitTarget.Add(new(HandleScript, 2, SpellEffectName.ScriptEffect)); } } - + [Script] // 20473 - Holy Shock class spell_pal_holy_shock : SpellScript { @@ -812,8 +855,9 @@ namespace Scripts.Spells.Paladin SpellCastResult CheckCast() { Unit caster = GetCaster(); + Unit target = GetExplTargetUnit(); - if (target) + if (target != null) { if (!caster.IsFriendlyTo(target)) { @@ -821,7 +865,7 @@ namespace Scripts.Spells.Paladin return SpellCastResult.BadTargets; if (!caster.IsInFront(target)) - return SpellCastResult.NotInfront; + return SpellCastResult.UnitNotInfront; } } else @@ -833,63 +877,70 @@ namespace Scripts.Spells.Paladin void HandleDummy(uint effIndex) { Unit caster = GetCaster(); + Unit unitTarget = GetHitUnit(); - if (unitTarget != null) + if (unitTarget) { if (caster.IsFriendlyTo(unitTarget)) - caster.CastSpell(unitTarget, SpellIds.HolyShockHealing, new CastSpellExtraArgs(GetSpell())); + caster.CastSpell(unitTarget, SpellIds.HolyShockHealing, GetSpell()); else - caster.CastSpell(unitTarget, SpellIds.HolyShockDamage, new CastSpellExtraArgs(GetSpell())); + caster.CastSpell(unitTarget, SpellIds.HolyShockDamage, GetSpell()); } } public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnCheckCast.Add(new(CheckCast)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 25912 - Holy Shock class spell_pal_holy_shock_damage_visual : SpellScript { + const uint PaladinVisualSpellHolyShockDamage = 83731; + const uint PaladinVisualSpellHolyShockDamageCrit = 83881; + public override bool Validate(SpellInfo spellInfo) { - return CliDB.SpellVisualStorage.HasRecord(SpellVisual.HolyShockDamage) - && CliDB.SpellVisualStorage.HasRecord(SpellVisual.HolyShockDamageCrit); + return CliDB.SpellVisualStorage.HasRecord(PaladinVisualSpellHolyShockDamage) + && CliDB.SpellVisualStorage.HasRecord(PaladinVisualSpellHolyShockDamageCrit); } void PlayVisual() { - GetCaster().SendPlaySpellVisual(GetHitUnit(), IsHitCrit() ? SpellVisual.HolyShockDamageCrit : SpellVisual.HolyShockDamage, 0, 0, 0.0f, false); + GetCaster().SendPlaySpellVisual(GetHitUnit(), IsHitCrit() ? PaladinVisualSpellHolyShockDamageCrit : PaladinVisualSpellHolyShockDamage, 0, 0, 0.0f, false); } public override void Register() { - AfterHit.Add(new HitHandler(PlayVisual)); + AfterHit.Add(new(PlayVisual)); } } [Script] // 25914 - Holy Shock class spell_pal_holy_shock_heal_visual : SpellScript { + const uint PaladinVisualSpellHolyShockHeal = 83732; + const uint PaladinVisualSpellHolyShockHealCrit = 83880; + public override bool Validate(SpellInfo spellInfo) { - return CliDB.SpellVisualStorage.HasRecord(SpellVisual.HolyShockHeal) - && CliDB.SpellVisualStorage.HasRecord(SpellVisual.HolyShockHealCrit); + return CliDB.SpellVisualStorage.HasRecord(PaladinVisualSpellHolyShockHeal) + && CliDB.SpellVisualStorage.HasRecord(PaladinVisualSpellHolyShockHealCrit); } void PlayVisual() { - GetCaster().SendPlaySpellVisual(GetHitUnit(), IsHitCrit() ? SpellVisual.HolyShockHealCrit : SpellVisual.HolyShockHeal, 0, 0, 0.0f, false); + GetCaster().SendPlaySpellVisual(GetHitUnit(), IsHitCrit() ? PaladinVisualSpellHolyShockHealCrit : PaladinVisualSpellHolyShockHeal, 0, 0, 0.0f, false); } public override void Register() { - AfterHit.Add(new HitHandler(PlayVisual)); + AfterHit.Add(new(PlayVisual)); } } - + [Script] // 37705 - Healing Discount class spell_pal_item_healing_discount : AuraScript { @@ -901,12 +952,12 @@ namespace Scripts.Spells.Paladin void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.ItemHealingTrance, new CastSpellExtraArgs(aurEff)); + GetTarget().CastSpell(GetTarget(), SpellIds.ItemHealingTrance, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); } } @@ -929,13 +980,13 @@ namespace Scripts.Spells.Paladin int chance; // Holy Light & Flash of Light - if (spellInfo.SpellFamilyFlags[0].HasAnyFlag(0xC0000000)) + if ((spellInfo.SpellFamilyFlags[0] & 0xC0000000) != 0) { spellId = SpellIds.EnduringLight; chance = 15; } // Judgements - else if (spellInfo.SpellFamilyFlags[0].HasAnyFlag(0x00800000u)) + else if ((spellInfo.SpellFamilyFlags[0] & 0x00800000) != 0) { spellId = SpellIds.EnduringJudgement; chance = 50; @@ -944,12 +995,12 @@ namespace Scripts.Spells.Paladin return; if (RandomHelper.randChance(chance)) - eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), spellId, new CastSpellExtraArgs(aurEff)); + eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), spellId, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -958,8 +1009,7 @@ namespace Scripts.Spells.Paladin { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.Forbearance)//, SpellIds.ImmuneShieldMarker); - && spellInfo.ExcludeTargetAuraSpell == SpellIds.ImmuneShieldMarker; + return ValidateSpellInfo(SpellIds.Forbearance, SpellIds.ImmuneShieldMarker) && spellInfo.ExcludeTargetAuraSpell == SpellIds.ImmuneShieldMarker; } SpellCastResult CheckForbearance() @@ -974,7 +1024,7 @@ namespace Scripts.Spells.Paladin void TriggerForbearance() { Unit target = GetHitUnit(); - if (target) + if (target != null) { GetCaster().CastSpell(target, SpellIds.Forbearance, true); GetCaster().CastSpell(target, SpellIds.ImmuneShieldMarker, true); @@ -983,12 +1033,12 @@ namespace Scripts.Spells.Paladin public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckForbearance)); - AfterHit.Add(new HitHandler(TriggerForbearance)); + OnCheckCast.Add(new(CheckForbearance)); + AfterHit.Add(new(TriggerForbearance)); } } - [Script] // 53651 - Beacon of Light + [Script] // 53651 - Light's Beacon - Beacon of Light class spell_pal_light_s_beacon : AuraScript { public override bool Validate(SpellInfo spellInfo) @@ -1016,16 +1066,16 @@ namespace Scripts.Spells.Paladin uint heal = MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount()); var auras = GetCaster().GetSingleCastAuras(); - foreach (var eff in auras) + foreach (var aura in auras) { - if (eff.GetId() == SpellIds.BeaconOfLight) + if (aura.GetId() == SpellIds.BeaconOfLight) { - List applications = eff.GetApplicationList(); + List applications = aura.GetApplicationList(); if (!applications.Empty()) { CastSpellExtraArgs args = new(aurEff); args.AddSpellMod(SpellValueMod.BasePoint0, (int)heal); - eventInfo.GetActor().CastSpell(applications[0].GetTarget(), SpellIds.BeaconOfLightHeal, args); + eventInfo.GetActor().CastSpell(applications.FirstOrDefault().GetTarget(), SpellIds.BeaconOfLightHeal, args); } return; } @@ -1034,8 +1084,8 @@ namespace Scripts.Spells.Paladin public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1051,8 +1101,8 @@ namespace Scripts.Spells.Paladin { foreach (var summonedObject in GetSpell().GetExecuteLogEffect(SpellEffectName.Summon).GenericVictimTargets) { - Unit hammer = Global.ObjAccessor.GetUnit(GetCaster(), summonedObject.Victim); - if (hammer != null) + Unit hammer = ObjAccessor.GetUnit(GetCaster(), summonedObject.Victim); + if (hammer) { hammer.CastSpell(hammer, SpellIds.LightHammerCosmetic, new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress).SetTriggeringSpell(GetSpell())); @@ -1064,7 +1114,7 @@ namespace Scripts.Spells.Paladin public override void Register() { - AfterCast.Add(new CastHandler(InitSummon)); + AfterCast.Add(new(InitSummon)); } } @@ -1080,19 +1130,19 @@ namespace Scripts.Spells.Paladin { Unit lightHammer = GetTarget(); Unit originalCaster = lightHammer.GetOwner(); - if (originalCaster != null) + if (originalCaster) { - originalCaster.CastSpell(lightHammer.GetPosition(), SpellIds.LightHammerDamage, new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress)); - originalCaster.CastSpell(lightHammer.GetPosition(), SpellIds.LightHammerHealing, new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress)); + originalCaster.CastSpell(lightHammer.GetPosition(), SpellIds.LightHammerDamage, TriggerCastFlags.IgnoreCastInProgress); + originalCaster.CastSpell(lightHammer.GetPosition(), SpellIds.LightHammerHealing, TriggerCastFlags.IgnoreCastInProgress); } } public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); } } - + [Script] // 204074 - Righteous Protector class spell_pal_righteous_protector : AuraScript { @@ -1100,7 +1150,7 @@ namespace Scripts.Spells.Paladin public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.AvengingWrath, SpellIds.GuardianOfAcientKings); + return ValidateSpellInfo(SpellIds.AvengingWrath, SpellIds.GuardianOfAncientKings); } bool CheckEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -1119,13 +1169,13 @@ namespace Scripts.Spells.Paladin int value = aurEff.GetAmount() * 100 * _baseHolyPowerCost.Amount; GetTarget().GetSpellHistory().ModifyCooldown(SpellIds.AvengingWrath, TimeSpan.FromMilliseconds(-value)); - GetTarget().GetSpellHistory().ModifyCooldown(SpellIds.GuardianOfAcientKings, TimeSpan.FromMilliseconds(-value)); + GetTarget().GetSpellHistory().ModifyCooldown(SpellIds.GuardianOfAncientKings, TimeSpan.FromMilliseconds(-value)); } public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckEffectProc, 0, AuraType.Dummy)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); + DoCheckEffectProc.Add(new(CheckEffectProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.Dummy)); } } @@ -1144,7 +1194,7 @@ namespace Scripts.Spells.Paladin public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.Dummy)); } } @@ -1162,7 +1212,7 @@ namespace Scripts.Spells.Paladin public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckEffectProc, 0, AuraType.ProcTriggerSpell)); + DoCheckEffectProc.Add(new(CheckEffectProc, 0, AuraType.ProcTriggerSpell)); } } @@ -1194,11 +1244,11 @@ namespace Scripts.Spells.Paladin public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); - OnEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.SchoolAbsorb, AuraEffectHandleModes.Real)); + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.SchoolAbsorb)); + OnEffectRemove.Add(new(HandleRemove, 0, AuraType.SchoolAbsorb, AuraEffectHandleModes.Real)); } } - + [Script] // 85256 - Templar's Verdict class spell_pal_templar_s_verdict : SpellScript { @@ -1214,7 +1264,7 @@ namespace Scripts.Spells.Paladin public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleHitTarget, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleHitTarget, 0, SpellEffectName.Dummy)); } } @@ -1257,12 +1307,12 @@ namespace Scripts.Spells.Paladin return; } - caster.CastSpell(target, spellId, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(target, spellId, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1285,8 +1335,10 @@ namespace Scripts.Spells.Paladin Unit caster = eventInfo.GetActor(); Unit target = eventInfo.GetProcTarget(); - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.HolyMending, GetCastDifficulty()); - int amount = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount()); + SpellInfo spellInfo = SpellMgr.GetSpellInfo(SpellIds.HolyMending, GetCastDifficulty()); + int amount = MathFunctions.CalculatePct((int)(healInfo.GetHeal()), aurEff.GetAmount()); + + Cypher.Assert(spellInfo.GetMaxTicks() > 0); amount /= (int)spellInfo.GetMaxTicks(); CastSpellExtraArgs args = new(aurEff); @@ -1296,7 +1348,63 @@ namespace Scripts.Spells.Paladin public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); + } + } + + [Script] // 405547 - Paladin Protection 10.1 Class Set 2pc + class spell_pal_t30_2p_protection_bonus : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.T302PHeartfireDamage); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo procInfo) + { + PreventDefaultAction(); + + Unit caster = procInfo.GetActor(); + uint ticks = SpellMgr.GetSpellInfo(SpellIds.T302PHeartfireDamage, Difficulty.None).GetMaxTicks(); + uint damage = MathFunctions.CalculatePct(procInfo.GetDamageInfo().GetOriginalDamage(), aurEff.GetAmount()) / ticks; + + caster.CastSpell(procInfo.GetActionTarget(), SpellIds.T302PHeartfireDamage, new CastSpellExtraArgs(aurEff) + .SetTriggeringSpell(procInfo.GetProcSpell()) + .AddSpellMod(SpellValueMod.BasePoint0, (int)damage)); + } + + public override void Register() + { + OnEffectProc.Add(new(HandleProc, 1, AuraType.Dummy)); + } + } + + [Script] // 408461 - Heartfire + class spell_pal_t30_2p_protection_bonus_heal : AuraScript + { + const uint SpellLabelPaladinT302PHeartfire = 2598; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.T302PHeartfireHeal); + } + + bool CheckProc(AuraEffect aurEff, ProcEventInfo procInfo) + { + return procInfo.GetDamageInfo() != null && procInfo.GetSpellInfo() != null && procInfo.GetSpellInfo().HasLabel(SpellLabelPaladinT302PHeartfire); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo procInfo) + { + GetTarget().CastSpell(GetTarget(), SpellIds.T302PHeartfireHeal, new CastSpellExtraArgs(aurEff) + .SetTriggeringSpell(procInfo.GetProcSpell()) + .AddSpellMod(SpellValueMod.BasePoint0, (int)procInfo.GetDamageInfo().GetOriginalDamage())); + } + + public override void Register() + { + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1318,7 +1426,7 @@ namespace Scripts.Spells.Paladin public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.ProcTriggerSpell)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.ProcTriggerSpell)); } } -} +} \ No newline at end of file diff --git a/Source/Scripts/Spells/Pet.cs b/Source/Scripts/Spells/Pet.cs new file mode 100644 index 000000000..65496bed9 --- /dev/null +++ b/Source/Scripts/Spells/Pet.cs @@ -0,0 +1,1466 @@ +// Copyright (c) CypherCore All rights reserved. +// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. + +using Framework.Constants; +using Game; +using Game.Entities; +using Game.Scripting; +using Game.Spells; +using static Global; + +namespace Scripts.Spells.Pets +{ + + struct SpellIds + { + //HunterPetCalculate + public const uint TamedPetPassive06 = 19591; + public const uint TamedPetPassive07 = 20784; + public const uint TamedPetPassive08 = 34666; + public const uint TamedPetPassive09 = 34667; + public const uint TamedPetPassive10 = 34675; + public const uint HunterPetScaling01 = 34902; + public const uint HunterPetScaling02 = 34903; + public const uint HunterPetScaling03 = 34904; + public const uint HunterPetScaling04 = 61017; + public const uint HunterAnimalHandler = 34453; + + //WarlockPetCalculate + public const uint PetPassiveCrit = 35695; + public const uint PetPassiveDamageTaken = 35697; + public const uint WarlockPetScaling01 = 34947; + public const uint WarlockPetScaling02 = 34956; + public const uint WarlockPetScaling03 = 34957; + public const uint WarlockPetScaling04 = 34958; + public const uint WarlockPetScaling05 = 61013; + public const uint WarlockGlyphOfVoidwalker = 56247; + + //DKPetCalculate + public const uint DeathKnightRuneWeapon02 = 51906; + public const uint DeathKnightPetScaling01 = 54566; + public const uint DeathKnightPetScaling02 = 51996; + public const uint DeathKnightPetScaling03 = 61697; + public const uint NightOfTheDead = 55620; + + //ShamanPetCalculate + public const uint FeralSpiritPetUnk01 = 35674; + public const uint FeralSpiritPetUnk02 = 35675; + public const uint FeralSpiritPetUnk03 = 35676; + public const uint FeralSpiritPetScaling04 = 61783; + + //MiscPetCalculate + public const uint MagePetPassiveElemental = 44559; + public const uint PetHealthScaling = 61679; + public const uint PetUnk01 = 67561; + public const uint PetUnk02 = 67557; + } + + struct CreatureIds + { + //WarlockPetCalculate + public const uint EntryFelguard = 17252; + public const uint EntryVoidwalker = 1860; + public const uint EntryFelhunter = 417; + public const uint EntrySuccubus = 1863; + public const uint EntryImp = 416; + + //DKPetCalculate + public const uint EntryArmyOfTheDeadGhoul = 24207; + } + + [Script] + class spell_gen_pet_calculate : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateAmountCritSpell(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float critSpell = 5.0f; + // Increase crit from AuraType.ModSpellCritChance + critSpell += owner.GetTotalAuraModifier(AuraType.ModSpellCritChance); + // Increase crit from AuraType.ModCritPct + critSpell += owner.GetTotalAuraModifier(AuraType.ModCritPct); + // Increase crit spell from spell crit ratings + critSpell += owner.GetRatingBonusValue(CombatRating.CritSpell); + + amount += (int)critSpell; + } + } + + void CalculateAmountCritMelee(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float critMelee = 5.0f; + // Increase crit from AuraType.ModWeaponCritPercent + critMelee += owner.GetTotalAuraModifier(AuraType.ModWeaponCritPercent); + // Increase crit from AuraType.ModCritPct + critMelee += owner.GetTotalAuraModifier(AuraType.ModCritPct); + // Increase crit melee from melee crit ratings + critMelee += owner.GetRatingBonusValue(CombatRating.CritMelee); + + amount += (int)critMelee; + } + } + + void CalculateAmountMeleeHit(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float hitMelee = 0.0f; + // Increase hit from AuraType.ModHitChance + hitMelee += owner.GetTotalAuraModifier(AuraType.ModHitChance); + // Increase hit melee from meele hit ratings + hitMelee += owner.GetRatingBonusValue(CombatRating.HitMelee); + + amount += (int)hitMelee; + } + } + + void CalculateAmountSpellHit(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float hitSpell = 0.0f; + // Increase hit from AuraType.ModSpellHitChance + hitSpell += owner.GetTotalAuraModifier(AuraType.ModSpellHitChance); + // Increase hit spell from spell hit ratings + hitSpell += owner.GetRatingBonusValue(CombatRating.HitSpell); + + amount += (int)hitSpell; + } + } + + void CalculateAmountExpertise(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float expertise = 0.0f; + // Increase hit from AuraType.ModExpertise + expertise += owner.GetTotalAuraModifier(AuraType.ModExpertise); + // Increase Expertise from Expertise ratings + expertise += owner.GetRatingBonusValue(CombatRating.Expertise); + + amount += (int)expertise; + } + } + + public override void Register() + { + switch (m_scriptSpellId) + { + case SpellIds.TamedPetPassive06: + DoEffectCalcAmount.Add(new(CalculateAmountCritMelee, 0, AuraType.ModWeaponCritPercent)); + DoEffectCalcAmount.Add(new(CalculateAmountCritSpell, 1, AuraType.ModSpellCritChance)); + break; + case SpellIds.PetPassiveCrit: + DoEffectCalcAmount.Add(new(CalculateAmountCritSpell, 0, AuraType.ModSpellCritChance)); + DoEffectCalcAmount.Add(new(CalculateAmountCritMelee, 1, AuraType.ModWeaponCritPercent)); + break; + case SpellIds.WarlockPetScaling05: + case SpellIds.HunterPetScaling04: + DoEffectCalcAmount.Add(new(CalculateAmountMeleeHit, 0, AuraType.ModHitChance)); + DoEffectCalcAmount.Add(new(CalculateAmountSpellHit, 1, AuraType.ModSpellHitChance)); + DoEffectCalcAmount.Add(new(CalculateAmountExpertise, 2, AuraType.ModExpertise)); + break; + case SpellIds.DeathKnightPetScaling03: + // case SpellShamanPetHit: + DoEffectCalcAmount.Add(new(CalculateAmountMeleeHit, 0, AuraType.ModHitChance)); + DoEffectCalcAmount.Add(new(CalculateAmountSpellHit, 1, AuraType.ModSpellHitChance)); + break; + default: + break; + } + } + } + + [Script] + class spell_warl_pet_scaling_01 : AuraScript + { + uint _tempBonus; + + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateStaminaAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null && pet.IsPet()) + { + Unit owner = pet.ToPet().GetOwner(); + if (owner != null) + { + float ownerBonus = MathFunctions.CalculatePct(owner.GetStat(Stats.Stamina), 75); + + amount += (int)ownerBonus; + _tempBonus = (uint)ownerBonus; + } + } + } + + void ApplyEffect(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + if (_tempBonus != 0) + { + PetLevelInfo pInfo = ObjectMgr.GetPetLevelInfo(pet.GetEntry(), pet.GetLevel()); + uint healthMod; + uint baseHealth = pInfo.health; + switch (pet.GetEntry()) + { + case CreatureIds.EntryImp: + healthMod = (uint)(_tempBonus * 8.4f); + break; + case CreatureIds.EntryFelguard: + case CreatureIds.EntryVoidwalker: + healthMod = _tempBonus * 11; + break; + case CreatureIds.EntrySuccubus: + healthMod = (uint)(_tempBonus * 9.1f); + break; + case CreatureIds.EntryFelhunter: + healthMod = (uint)(_tempBonus * 9.5f); + break; + default: + healthMod = 0; + break; + } + if (healthMod != 0) + pet.ToPet().SetCreateHealth(baseHealth + healthMod); + } + } + } + + void RemoveEffect(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + if (pet.IsPet()) + { + PetLevelInfo pInfo = ObjectMgr.GetPetLevelInfo(pet.GetEntry(), pet.GetLevel()); + pet.ToPet().SetCreateHealth(pInfo.health); + } + } + } + + void CalculateAttackPowerAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null && pet.IsPet()) + { + Player owner = pet.ToPet().GetOwner(); + if (owner != null) + { + int fire = owner.m_activePlayerData.ModDamageDonePos[(int)SpellSchools.Fire] - owner.m_activePlayerData.ModDamageDoneNeg[(int)SpellSchools.Fire]; + int shadow = owner.m_activePlayerData.ModDamageDonePos[(int)SpellSchools.Shadow] - owner.m_activePlayerData.ModDamageDoneNeg[(int)SpellSchools.Shadow]; + int maximum = (fire > shadow) ? fire : shadow; + if (maximum < 0) + maximum = 0; + float bonusAP = maximum * 0.57f; + + amount += (int)bonusAP; + + // Glyph of felguard + if (pet.GetEntry() == CreatureIds.EntryFelguard) + { + AuraEffect aurEffect = owner.GetAuraEffect(56246, 0); + if (aurEffect != null) + { + float base_attPower = pet.GetFlatModifierValue(UnitMods.AttackPower, UnitModifierFlatType.Base) * pet.GetPctModifierValue(UnitMods.AttackPower, UnitModifierPctType.Base); + amount += (int)MathFunctions.CalculatePct(amount + base_attPower, aurEffect.GetAmount()); + } + } + } + } + } + + void CalculateDamageDoneAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null && pet.IsPet()) + { + Player owner = pet.ToPet().GetOwner(); + if (owner != null) + { + //the damage bonus used for pets is either fire or shadow damage, whatever is higher + int fire = owner.m_activePlayerData.ModDamageDonePos[(int)SpellSchools.Fire] - owner.m_activePlayerData.ModDamageDoneNeg[(int)SpellSchools.Fire]; + int shadow = owner.m_activePlayerData.ModDamageDonePos[(int)SpellSchools.Shadow] - owner.m_activePlayerData.ModDamageDoneNeg[(int)SpellSchools.Shadow]; + int maximum = (fire > shadow) ? fire : shadow; + float bonusDamage = 0.0f; + + if (maximum > 0) + bonusDamage = maximum * 0.15f; + + amount += (int)bonusDamage; + } + } + } + + public override void Register() + { + OnEffectRemove.Add(new(RemoveEffect, 0, AuraType.ModStat, AuraEffectHandleModes.ChangeAmountMask)); + AfterEffectApply.Add(new(ApplyEffect, 0, AuraType.ModStat, AuraEffectHandleModes.ChangeAmountMask)); + DoEffectCalcAmount.Add(new(CalculateStaminaAmount, 0, AuraType.ModStat)); + DoEffectCalcAmount.Add(new(CalculateAttackPowerAmount, 1, AuraType.ModAttackPower)); + DoEffectCalcAmount.Add(new(CalculateDamageDoneAmount, 2, AuraType.ModDamageDone)); + } + } + + [Script] + class spell_warl_pet_scaling_02 : AuraScript + { + uint _tempBonus; + + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateIntellectAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null && pet.IsPet()) + { + Unit owner = pet.ToPet().GetOwner(); + if (owner != null) + { + int ownerBonus = (int)MathFunctions.CalculatePct(owner.GetStat(Stats.Intellect), 30); + + amount += ownerBonus; + _tempBonus = (uint)ownerBonus; + } + } + + } + + void ApplyEffect(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + if (_tempBonus != 0) + { + PetLevelInfo pInfo = ObjectMgr.GetPetLevelInfo(pet.GetEntry(), pet.GetLevel()); + uint manaMod; + uint baseMana = pInfo.mana; + switch (pet.GetEntry()) + { + case CreatureIds.EntryImp: + manaMod = (uint)(_tempBonus * 4.9f); + break; + case CreatureIds.EntryVoidwalker: + case CreatureIds.EntrySuccubus: + case CreatureIds.EntryFelhunter: + case CreatureIds.EntryFelguard: + manaMod = (uint)(_tempBonus * 11.5f); + break; + default: + manaMod = 0; + break; + } + if (manaMod != 0) + pet.ToPet().SetCreateMana(baseMana + manaMod); + } + } + } + + void RemoveEffect(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + if (pet.IsPet()) + { + PetLevelInfo pInfo = ObjectMgr.GetPetLevelInfo(pet.GetEntry(), pet.GetLevel()); + pet.ToPet().SetCreateMana(pInfo.mana); + } + } + } + + void CalculateArmorAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + if (pet.IsPet()) + { + Unit owner = pet.ToPet().GetOwner(); + if (owner != null) + { + int ownerBonus = (int)MathFunctions.CalculatePct(owner.GetArmor(), 35); + amount += ownerBonus; + } + } + } + } + + void CalculateFireResistanceAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null && pet.IsPet()) + { + Unit owner = pet.ToPet().GetOwner(); + if (owner != null) + { + int ownerBonus = MathFunctions.CalculatePct(owner.GetResistance(SpellSchoolMask.Fire), 40); + amount += ownerBonus; + } + } + } + + public override void Register() + { + OnEffectRemove.Add(new(RemoveEffect, 0, AuraType.ModStat, AuraEffectHandleModes.ChangeAmountMask)); + AfterEffectApply.Add(new(ApplyEffect, 0, AuraType.ModStat, AuraEffectHandleModes.ChangeAmountMask)); + DoEffectCalcAmount.Add(new(CalculateIntellectAmount, 0, AuraType.ModStat)); + DoEffectCalcAmount.Add(new(CalculateArmorAmount, 1, AuraType.ModResistance)); + DoEffectCalcAmount.Add(new(CalculateFireResistanceAmount, 2, AuraType.ModResistance)); + } + } + + [Script] + class spell_warl_pet_scaling_03 : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateFrostResistanceAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null && pet.IsPet()) + { + Unit owner = pet.ToPet().GetOwner(); + if (owner != null) + { + int ownerBonus = MathFunctions.CalculatePct(owner.GetResistance(SpellSchoolMask.Frost), 40); + amount += ownerBonus; + } + } + } + + void CalculateArcaneResistanceAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null && pet.IsPet()) + { + Unit owner = pet.ToPet().GetOwner(); + if (owner != null) + { + int ownerBonus = MathFunctions.CalculatePct(owner.GetResistance(SpellSchoolMask.Arcane), 40); + amount += ownerBonus; + } + } + } + + void CalculateNatureResistanceAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null && pet.IsPet()) + { + Unit owner = pet.ToPet().GetOwner(); + if (owner != null) + { + int ownerBonus = MathFunctions.CalculatePct(owner.GetResistance(SpellSchoolMask.Nature), 40); + amount += ownerBonus; + } + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalculateFrostResistanceAmount, 0, AuraType.ModResistance)); + DoEffectCalcAmount.Add(new(CalculateArcaneResistanceAmount, 1, AuraType.ModResistance)); + DoEffectCalcAmount.Add(new(CalculateNatureResistanceAmount, 2, AuraType.ModResistance)); + } + } + + [Script] + class spell_warl_pet_scaling_04 : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateShadowResistanceAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null && pet.IsPet()) + { + Unit owner = pet.ToPet().GetOwner(); + if (owner != null) + { + int ownerBonus = MathFunctions.CalculatePct(owner.GetResistance(SpellSchoolMask.Shadow), 40); + amount += ownerBonus; + } + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalculateShadowResistanceAmount, 0, AuraType.ModResistance)); + } + } + + [Script] + class spell_warl_pet_scaling_05 : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateAmountMeleeHit(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float hitMelee = 0.0f; + // Increase hit from AuraType.ModSpellHitChance + hitMelee += owner.GetTotalAuraModifier(AuraType.ModSpellHitChance); + // Increase hit spell from spell hit ratings + hitMelee += owner.GetRatingBonusValue(CombatRating.HitSpell); + + amount += (int)hitMelee; + } + } + + void CalculateAmountSpellHit(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float hitSpell = 0.0f; + // Increase hit from AuraType.ModSpellHitChance + hitSpell += owner.GetTotalAuraModifier(AuraType.ModSpellHitChance); + // Increase hit spell from spell hit ratings + hitSpell += owner.GetRatingBonusValue(CombatRating.HitSpell); + + amount += (int)hitSpell; + } + } + + void CalculateAmountExpertise(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float expertise = 0.0f; + // Increase hit from AuraType.ModSpellHitChance + expertise += owner.GetTotalAuraModifier(AuraType.ModSpellHitChance); + // Increase hit spell from spell hit ratings + expertise += owner.GetRatingBonusValue(CombatRating.HitSpell); + + amount += (int)expertise; + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalculateAmountMeleeHit, 0, AuraType.ModHitChance)); + DoEffectCalcAmount.Add(new(CalculateAmountSpellHit, 1, AuraType.ModSpellHitChance)); + DoEffectCalcAmount.Add(new(CalculateAmountExpertise, 2, AuraType.ModExpertise)); + } + } + + [Script] + class spell_warl_pet_passive : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateAmountCritSpell(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float CritSpell = 5.0f; + // Increase crit from AuraType.ModSpellCritChance + CritSpell += owner.GetTotalAuraModifier(AuraType.ModSpellCritChance); + // Increase crit from AuraType.ModCritPct + CritSpell += owner.GetTotalAuraModifier(AuraType.ModCritPct); + // Increase crit spell from spell crit ratings + CritSpell += owner.GetRatingBonusValue(CombatRating.CritSpell); + + AuraApplication improvedDemonicTacticsApp = owner.GetAuraApplicationOfRankedSpell(54347); + if (improvedDemonicTacticsApp != null) + { + Aura improvedDemonicTactics = improvedDemonicTacticsApp.GetBase(); + if (improvedDemonicTactics != null) + { + AuraEffect improvedDemonicTacticsEffect = improvedDemonicTactics.GetEffect(0); + if (improvedDemonicTacticsEffect != null) + amount += (int)MathFunctions.CalculatePct(CritSpell, improvedDemonicTacticsEffect.GetAmount()); + } + } + } + } + + void CalculateAmountCritMelee(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float CritMelee = 5.0f; + // Increase crit from AuraType.ModWeaponCritPercent + CritMelee += owner.GetTotalAuraModifier(AuraType.ModWeaponCritPercent); + // Increase crit from AuraType.ModCritPct + CritMelee += owner.GetTotalAuraModifier(AuraType.ModCritPct); + // Increase crit melee from melee crit ratings + CritMelee += owner.GetRatingBonusValue(CombatRating.CritMelee); + + AuraApplication improvedDemonicTacticsApp = owner.GetAuraApplicationOfRankedSpell(54347); + if (improvedDemonicTacticsApp != null) + { + Aura improvedDemonicTactics = improvedDemonicTacticsApp.GetBase(); + if (improvedDemonicTactics != null) + { + AuraEffect improvedDemonicTacticsEffect = improvedDemonicTactics.GetEffect(0); + if (improvedDemonicTacticsEffect != null) + amount += (int)MathFunctions.CalculatePct(CritMelee, improvedDemonicTacticsEffect.GetAmount()); + } + } + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalculateAmountCritSpell, 0, AuraType.ModSpellCritChance)); + DoEffectCalcAmount.Add(new(CalculateAmountCritMelee, 1, AuraType.ModWeaponCritPercent)); + } + } + + [Script] // this doesnt actually fit in here + class spell_warl_pet_passive_damage_done : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateAmountDamageDone(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + if (GetCaster() == null || GetCaster().GetOwner() == null) + return; + + if (GetCaster().GetOwner().ToPlayer() != null) + { + switch (GetCaster().GetEntry()) + { + case CreatureIds.EntryVoidwalker: + amount += -16; + break; + case CreatureIds.EntryFelhunter: + amount += -20; + break; + case CreatureIds.EntrySuccubus: + case CreatureIds.EntryFelguard: + amount += 5; + break; + } + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalculateAmountDamageDone, 0, AuraType.ModDamagePercentDone)); + DoEffectCalcAmount.Add(new(CalculateAmountDamageDone, 1, AuraType.ModDamagePercentDone)); + } + } + + [Script] + class spell_warl_pet_passive_voidwalker : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null && pet.IsPet()) + { + Unit owner = pet.ToPet().GetOwner(); + if (owner != null) + { + AuraEffect aurEffect = owner.GetAuraEffect(SpellIds.WarlockGlyphOfVoidwalker, 0); + if (aurEffect != null) + amount += aurEffect.GetAmount(); + } + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.ModTotalStatPercentage)); + } + } + + [Script] + class spell_sha_pet_scaling_04 : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateAmountMeleeHit(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float hitMelee = 0.0f; + // Increase hit from AuraType.ModHitChance + hitMelee += owner.GetTotalAuraModifier(AuraType.ModHitChance); + // Increase hit melee from meele hit ratings + hitMelee += owner.GetRatingBonusValue(CombatRating.HitMelee); + + amount += (int)hitMelee; + } + } + + void CalculateAmountSpellHit(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float hitSpell = 0.0f; + // Increase hit from AuraType.ModSpellHitChance + hitSpell += owner.GetTotalAuraModifier(AuraType.ModSpellHitChance); + // Increase hit spell from spell hit ratings + hitSpell += owner.GetRatingBonusValue(CombatRating.HitSpell); + + amount += (int)hitSpell; + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalculateAmountMeleeHit, 0, AuraType.ModHitChance)); + DoEffectCalcAmount.Add(new(CalculateAmountSpellHit, 1, AuraType.ModSpellHitChance)); + } + } + + [Script] + class spell_hun_pet_scaling_01 : AuraScript + { + uint _tempHealth; + + void CalculateStaminaAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Pet pet = GetUnitOwner()?.ToPet(); + if (pet != null) + { + Unit owner = pet.GetOwner(); + if (owner != null) + { + float mod = 0.45f; + + SpellInfo spellInfo = SpellMgr.GetSpellInfo(62758, GetCastDifficulty()) ?? SpellMgr.GetSpellInfo(62762, GetCastDifficulty()); + if (spellInfo != null) // If pet has Wild Hunt + MathFunctions.AddPct(ref mod, spellInfo.GetEffect(0).CalcValue()); + + amount += (int)(owner.GetStat(Stats.Stamina) * mod); + } + } + } + + void ApplyEffect(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + if (_tempHealth != 0) + pet.SetHealth(_tempHealth); + } + } + + void RemoveEffect(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit pet = GetUnitOwner(); + if (pet != null) + _tempHealth = (uint)pet.GetHealth(); + } + + void CalculateAttackPowerAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + if (!pet.IsPet()) + return; + + Unit owner = pet.ToPet().GetOwner(); + if (owner == null) + return; + + float mod = 1.0f; //Hunter contribution modifier + + SpellInfo spellInfo = SpellMgr.GetSpellInfo(62758, GetCastDifficulty()) ?? SpellMgr.GetSpellInfo(62762, GetCastDifficulty()); + if (spellInfo != null) // If pet has Wild Hunt + mod += MathFunctions.CalculatePct(1.0f, spellInfo.GetEffect(1).CalcValue()); + + amount += (int)(owner.GetTotalAttackPowerValue(WeaponAttackType.RangedAttack) * 0.22f * mod); + } + } + + void CalculateDamageDoneAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + if (!pet.IsPet()) + return; + + Unit owner = pet.ToPet().GetOwner(); + if (owner == null) + return; + + float mod = 1.0f; //Hunter contribution modifier + + SpellInfo spellInfo = SpellMgr.GetSpellInfo(62758, GetCastDifficulty()) ?? SpellMgr.GetSpellInfo(62762, GetCastDifficulty()); + if (spellInfo != null) // If pet has Wild Hunt + mod += MathFunctions.CalculatePct(1.0f, spellInfo.GetEffect(1).CalcValue()); + + amount += (int)(owner.GetTotalAttackPowerValue(WeaponAttackType.RangedAttack) * 0.1287f * mod); + } + } + + public override void Register() + { + OnEffectRemove.Add(new(RemoveEffect, 0, AuraType.ModStat, AuraEffectHandleModes.ChangeAmountMask)); + AfterEffectApply.Add(new(ApplyEffect, 0, AuraType.ModStat, AuraEffectHandleModes.ChangeAmountMask)); + DoEffectCalcAmount.Add(new(CalculateStaminaAmount, 0, AuraType.ModStat)); + DoEffectCalcAmount.Add(new(CalculateAttackPowerAmount, 1, AuraType.ModAttackPower)); + DoEffectCalcAmount.Add(new(CalculateDamageDoneAmount, 2, AuraType.ModDamageDone)); + } + } + + [Script] + class spell_hun_pet_scaling_02 : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateFrostResistanceAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + if (!pet.IsPet()) + return; + + Unit owner = pet.ToPet().GetOwner(); + if (owner == null) + return; + + int ownerBonus = MathFunctions.CalculatePct(owner.GetResistance(SpellSchoolMask.Frost), 40); + amount += ownerBonus; + } + } + + void CalculateFireResistanceAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + if (!pet.IsPet()) + return; + + Unit owner = pet.ToPet().GetOwner(); + if (owner == null) + return; + + int ownerBonus = MathFunctions.CalculatePct(owner.GetResistance(SpellSchoolMask.Fire), 40); + amount += ownerBonus; + } + } + + void CalculateNatureResistanceAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + if (!pet.IsPet()) + return; + + Unit owner = pet.ToPet().GetOwner(); + if (owner == null) + return; + + int ownerBonus = MathFunctions.CalculatePct(owner.GetResistance(SpellSchoolMask.Nature), 40); + amount += ownerBonus; + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalculateFrostResistanceAmount, 1, AuraType.ModResistance)); + DoEffectCalcAmount.Add(new(CalculateFireResistanceAmount, 0, AuraType.ModResistance)); + DoEffectCalcAmount.Add(new(CalculateNatureResistanceAmount, 2, AuraType.ModResistance)); + } + } + + [Script] + class spell_hun_pet_scaling_03 : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateShadowResistanceAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + if (!pet.IsPet()) + return; + + Unit owner = pet.ToPet().GetOwner(); + if (owner == null) + return; + + int ownerBonus = MathFunctions.CalculatePct(owner.GetResistance(SpellSchoolMask.Shadow), 40); + amount += ownerBonus; + } + } + + void CalculateArcaneResistanceAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + if (!pet.IsPet()) + return; + + Unit owner = pet.ToPet().GetOwner(); + if (owner == null) + return; + + int ownerBonus = MathFunctions.CalculatePct(owner.GetResistance(SpellSchoolMask.Arcane), 40); + amount += ownerBonus; + } + } + + void CalculateArmorAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + if (!pet.IsPet()) + return; + + Unit owner = pet.ToPet().GetOwner(); + if (owner == null) + return; + + amount += (int)MathFunctions.CalculatePct(owner.GetArmor(), 35); + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalculateShadowResistanceAmount, 0, AuraType.ModResistance)); + DoEffectCalcAmount.Add(new(CalculateArcaneResistanceAmount, 1, AuraType.ModResistance)); + DoEffectCalcAmount.Add(new(CalculateArmorAmount, 2, AuraType.ModResistance)); + } + } + + [Script] + class spell_hun_pet_scaling_04 : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateAmountMeleeHit(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + if (GetCaster() == null || GetCaster().GetOwner() == null) + return; + + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float hitMelee = 0.0f; + // Increase hit from AuraType.ModHitChance + hitMelee += owner.GetTotalAuraModifier(AuraType.ModHitChance); + // Increase hit melee from meele hit ratings + hitMelee += owner.GetRatingBonusValue(CombatRating.HitMelee); + + amount += (int)hitMelee; + } + } + + void CalculateAmountSpellHit(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + if (GetCaster() == null || GetCaster().GetOwner() == null) + return; + + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float hitSpell = 0.0f; + // Increase hit from AuraType.ModSpellHitChance + hitSpell += owner.GetTotalAuraModifier(AuraType.ModSpellHitChance); + // Increase hit spell from spell hit ratings + hitSpell += owner.GetRatingBonusValue(CombatRating.HitSpell); + + amount += (int)hitSpell; + } + } + + void CalculateAmountExpertise(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + if (GetCaster() == null || GetCaster().GetOwner() == null) + return; + + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float expertise = 0.0f; + // Increase hit from AuraType.ModExpertise + expertise += owner.GetTotalAuraModifier(AuraType.ModExpertise); + // Increase Expertise from Expertise ratings + expertise += owner.GetRatingBonusValue(CombatRating.Expertise); + + amount += (int)expertise; + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalculateAmountMeleeHit, 0, AuraType.ModHitChance)); + DoEffectCalcAmount.Add(new(CalculateAmountSpellHit, 1, AuraType.ModSpellHitChance)); + DoEffectCalcAmount.Add(new(CalculateAmountExpertise, 2, AuraType.ModExpertise)); + } + } + + [Script] + class spell_hun_pet_passive_crit : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateAmountCritSpell(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + if (GetCaster() == null || GetCaster().GetOwner() == null) + return; + + if (GetCaster().GetOwner().ToPlayer() != null) + { + // For others recalculate it from: + float CritSpell = 5.0f; + // Increase crit from AuraType.ModSpellCritChance + // CritSpell += owner.GetTotalAuraModifier(AuraType.ModSpellCritChance); + // Increase crit from AuraType.ModCritPct + // CritSpell += owner.GetTotalAuraModifier(AuraType.ModCritPct); + // Increase crit spell from spell crit ratings + // CritSpell += owner.GetRatingBonusValue(CrCritSpell); + + amount += (int)(CritSpell * 0.8f); + } + } + + void CalculateAmountCritMelee(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + if (GetCaster() == null || GetCaster().GetOwner() == null) + return; + + if (GetCaster().GetOwner().ToPlayer() != null) + { + // For others recalculate it from: + float CritMelee = 5.0f; + // Increase crit from AuraType.ModWeaponCritPercent + // CritMelee += owner.GetTotalAuraModifier(AuraType.ModWeaponCritPercent); + // Increase crit from AuraType.ModCritPct + // CritMelee += owner.GetTotalAuraModifier(AuraType.ModCritPct); + // Increase crit melee from melee crit ratings + // CritMelee += owner.GetRatingBonusValue(CrCritMelee); + + amount += (int)(CritMelee * 0.8f); + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalculateAmountCritSpell, 1, AuraType.ModSpellCritChance)); + DoEffectCalcAmount.Add(new(CalculateAmountCritMelee, 0, AuraType.ModWeaponCritPercent)); + } + } + + [Script] + class spell_hun_pet_passive_damage_done : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateAmountDamageDone(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + if (GetCaster() == null || GetCaster().GetOwner() == null) + return; + + if (GetCaster().GetOwner().ToPlayer() != null) + { + // Cobra Reflexes + AuraEffect cobraReflexes = GetCaster().GetAuraEffectOfRankedSpell(61682, 0); + if (cobraReflexes != null) + amount -= cobraReflexes.GetAmount(); + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalculateAmountDamageDone, 0, AuraType.ModDamagePercentDone)); + } + } + + [Script] + class spell_hun_animal_handler : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateAmountDamageDone(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + if (GetCaster() == null || GetCaster().GetOwner() == null) + return; + + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + AuraEffect aurEffect = owner.GetAuraEffectOfRankedSpell(SpellIds.HunterAnimalHandler, 1); + if (aurEffect != null) + amount = aurEffect.GetAmount(); + else + amount = 0; + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalculateAmountDamageDone, 0, AuraType.ModAttackPowerPct)); + } + } + + [Script] + class spell_dk_avoidance_passive : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateAvoidanceAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + Unit owner = pet.GetOwner(); + if (owner != null) + { + // Army of the dead ghoul + if (pet.GetEntry() == CreatureIds.EntryArmyOfTheDeadGhoul) + amount = -90; + // Night of the dead + else + { + Aura aur = owner.GetAuraOfRankedSpell(SpellIds.NightOfTheDead); + if (aur != null) + amount = aur.GetSpellInfo().GetEffect(2).CalcValue(); + } + } + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalculateAvoidanceAmount, 0, AuraType.ModCreatureAoeDamageAvoidance)); + } + } + + [Script] + class spell_dk_pet_scaling_01 : AuraScript + { + uint _tempHealth; + + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateStaminaAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + if (pet.IsGuardian()) + { + Unit owner = pet.GetOwner(); + if (owner != null) + { + float ownerBonus = (float)(owner.GetStat(Stats.Stamina)) * 0.3f; + amount += (int)ownerBonus; + } + } + } + } + + void ApplyEffect(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit pet = GetUnitOwner(); + if (pet != null && _tempHealth != 0) + pet.SetHealth(_tempHealth); + } + + void RemoveEffect(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit pet = GetUnitOwner(); + if (pet != null) + _tempHealth = (uint)pet.GetHealth(); + } + + void CalculateStrengthAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + if (!pet.IsGuardian()) + return; + + Unit owner = pet.GetOwner(); + if (owner == null) + return; + + float ownerBonus = (float)(owner.GetStat(Stats.Strength)) * 0.7f; + amount += (int)ownerBonus; + } + } + + public override void Register() + { + OnEffectRemove.Add(new(RemoveEffect, 0, AuraType.ModStat, AuraEffectHandleModes.ChangeAmountMask)); + AfterEffectApply.Add(new(ApplyEffect, 0, AuraType.ModStat, AuraEffectHandleModes.ChangeAmountMask)); + DoEffectCalcAmount.Add(new(CalculateStaminaAmount, 0, AuraType.ModStat)); + DoEffectCalcAmount.Add(new(CalculateStrengthAmount, 1, AuraType.ModStat)); + } + } + + [Script] + class spell_dk_pet_scaling_02 : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateAmountMeleeHaste(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + if (GetCaster() == null || GetCaster().GetOwner() == null) + return; + + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float hasteMelee = 0.0f; + // Increase hit from AuraType.ModHitChance + hasteMelee += (1 - owner.m_modAttackSpeedPct[(int)WeaponAttackType.BaseAttack]) * 100; + + amount += (int)hasteMelee; + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalculateAmountMeleeHaste, 1, AuraType.MeleeSlow)); + } + } + + [Script] + class spell_dk_pet_scaling_03 : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateAmountMeleeHit(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + if (GetCaster() == null || GetCaster().GetOwner() == null) + return; + + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float hitMelee = 0.0f; + // Increase hit from AuraType.ModHitChance + hitMelee += owner.GetTotalAuraModifier(AuraType.ModHitChance); + // Increase hit melee from meele hit ratings + hitMelee += owner.GetRatingBonusValue(CombatRating.HitMelee); + + amount += (int)hitMelee; + } + } + + void CalculateAmountSpellHit(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + if (GetCaster() == null || GetCaster().GetOwner() == null) + return; + + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float hitSpell = 0.0f; + // Increase hit from AuraType.ModSpellHitChance + hitSpell += owner.GetTotalAuraModifier(AuraType.ModSpellHitChance); + // Increase hit spell from spell hit ratings + hitSpell += owner.GetRatingBonusValue(CombatRating.HitSpell); + + amount += (int)hitSpell; + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalculateAmountMeleeHit, 0, AuraType.ModHitChance)); + DoEffectCalcAmount.Add(new(CalculateAmountSpellHit, 1, AuraType.ModSpellHitChance)); + } + } + + [Script] + class spell_dk_rune_weapon_scaling_02 : AuraScript + { + public override bool Load() + { + if (GetCaster() == null || GetCaster().GetOwner() == null || !GetCaster().GetOwner().IsPlayer()) + return false; + return true; + } + + void CalculateDamageDoneAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit pet = GetUnitOwner(); + if (pet != null) + { + Unit owner = pet.GetOwner(); + if (owner == null) + return; + + if (pet.IsGuardian()) + ((Guardian)pet).SetBonusDamage((int)owner.GetTotalAttackPowerValue(WeaponAttackType.BaseAttack)); + + amount += (int)owner.CalculateDamage(WeaponAttackType.BaseAttack, true, true); + } + } + + void CalculateAmountMeleeHaste(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + if (GetCaster() == null || GetCaster().GetOwner() == null) + return; + + Player owner = GetCaster().GetOwner().ToPlayer(); + if (owner != null) + { + // For others recalculate it from: + float hasteMelee = 0.0f; + // Increase hit from AuraType.ModHitChance + hasteMelee += (1 - owner.m_modAttackSpeedPct[(int)WeaponAttackType.BaseAttack]) * 100; + + amount += (int)hasteMelee; + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new(CalculateDamageDoneAmount, 0, AuraType.ModDamageDone)); + DoEffectCalcAmount.Add(new(CalculateAmountMeleeHaste, 1, AuraType.MeleeSlow)); + } + } +} diff --git a/Source/Scripts/Spells/Priest.cs b/Source/Scripts/Spells/Priest.cs index 52c45dbdd..7357c768c 100644 --- a/Source/Scripts/Spells/Priest.cs +++ b/Source/Scripts/Spells/Priest.cs @@ -1,11 +1,10 @@ -// Copyright (c) CypherCore All rights reserved. +// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; using Framework.Dynamic; using Game.AI; using Game.Entities; -using Game.Maps; using Game.Movement; using Game.Scripting; using Game.Spells; @@ -13,28 +12,40 @@ using System; using System.Collections.Generic; using System.Linq; using System.Numerics; +using static Global; namespace Scripts.Spells.Priest { + struct SpellIds { + public const uint AbyssalReverie = 373054; public const uint AngelicFeatherAreatrigger = 158624; public const uint AngelicFeatherAura = 121557; + public const uint AnsweredPrayers = 394289; + public const uint Apotheosis = 200183; public const uint ArmorOfFaith = 28810; public const uint Atonement = 81749; + public const uint AtonementEffect = 194384; public const uint AtonementHeal = 81751; - public const uint AtonementTriggered = 194384; - public const uint AtonementTriggeredPowerTrinity = 214206; public const uint Benediction = 193157; + public const uint Benevolence = 415416; public const uint BlessedHealing = 70772; + public const uint BlessedLight = 196813; public const uint BodyAndSoul = 64129; public const uint BodyAndSoulSpeed = 65081; + public const uint CircleOfHealing = 204883; public const uint DarkReprimand = 400169; public const uint DarkReprimandChannelDamage = 373129; public const uint DarkReprimandChannelHealing = 400171; public const uint DarkReprimandDamage = 373130; public const uint DarkReprimandHealing = 400187; + public const uint DazzlingLight = 196810; public const uint DivineBlessing = 40440; + public const uint DivineHymnHeal = 64844; + public const uint DivineImageSummon = 392990; + public const uint DivineImageEmpower = 409387; + public const uint DivineImageEmpowerStack = 405963; public const uint DivineService = 391233; public const uint DivineStarHoly = 110744; public const uint DivineStarShadow = 122121; @@ -44,7 +55,13 @@ namespace Scripts.Spells.Priest public const uint DivineStarShadowHeal = 390981; public const uint DivineWrath = 40441; public const uint EmpoweredRenewHeal = 391359; + public const uint Epiphany = 414553; + public const uint EpiphanyHighlight = 414556; + public const uint EssenceDevourer = 415479; + public const uint EssenceDevourerShadowfiendHeal = 415673; + public const uint EssenceDevourerMindbenderHeal = 415676; public const uint FlashHeal = 2061; + public const uint GreaterHeal = 289666; public const uint FocusedMending = 372354; public const uint GuardianSpiritHeal = 48153; public const uint HaloHoly = 120517; @@ -54,32 +71,51 @@ namespace Scripts.Spells.Priest public const uint HaloShadowDamage = 390964; public const uint HaloShadowHeal = 390971; public const uint Heal = 2060; + public const uint HealingLight = 196809; + public const uint HolyFire = 14914; public const uint HolyMendingHeal = 391156; + public const uint HolyNova = 132157; public const uint HolyWordChastise = 88625; + public const uint HolyWordSalvation = 265202; public const uint HolyWordSanctify = 34861; public const uint HolyWordSerenity = 2050; - public const uint Holy101ClassSet2pChooser = 411097; + public const uint Holy101ClassSet2PChooser = 411097; + public const uint Holy101ClassSet4P = 405556; + public const uint Holy101ClassSet4PEffect = 409479; public const uint ItemEfficiency = 37595; public const uint LeapOfFaithEffect = 92832; public const uint LevitateEffect = 111759; + public const uint LightEruption = 196812; + public const uint LightsWrathVisual = 215795; public const uint MasochismTalent = 193063; public const uint MasochismPeriodicHeal = 193065; public const uint MasteryGrace = 271534; + public const uint MindbenderDisc = 123040; + public const uint MindbenderShadow = 200174; + public const uint Mindgames = 375901; + public const uint MindgamesVenthyr = 323673; public const uint MindBombStun = 226943; public const uint OracularHeal = 26170; public const uint Penance = 47540; public const uint PenanceChannelDamage = 47758; public const uint PenanceChannelHealing = 47757; public const uint PenanceDamage = 47666; - public const uint SPELL_PRIEST_PENANCE_HEALING = 47750; + public const uint PenanceHealing = 47750; + public const uint PowerLeechMindbenderMana = 123051; + public const uint PowerLeechMindbenderInsanity = 200010; + public const uint PowerLeechShadowfiendMana = 343727; + public const uint PowerLeechShadowfiendInsanity = 262485; public const uint PowerOfTheDarkSide = 198069; public const uint PowerOfTheDarkSideTint = 225795; + public const uint PowerWordLife = 373481; + public const uint PowerWordRadiance = 194509; public const uint PowerWordShield = 17; public const uint PowerWordSolaceEnergize = 129253; + public const uint PrayerOfHealing = 596; + public const uint PrayerOfMending = 33076; public const uint PrayerOfMendingAura = 41635; public const uint PrayerOfMendingHeal = 33110; public const uint PrayerOfMendingJump = 155793; - public const uint PrayerOfHealing = 596; public const uint PurgeTheWicked = 204197; public const uint PurgeTheWickedDummy = 204215; public const uint PurgeTheWickedPeriodic = 204213; @@ -89,24 +125,32 @@ namespace Scripts.Spells.Priest public const uint RenewedHopeEffect = 197470; public const uint RevelInPurity = 373003; public const uint SayYourPrayers = 391186; + public const uint SearingLight = 196811; public const uint ShadowMendDamage = 186439; + public const uint ShadowWordDeath = 32379; public const uint ShadowMendPeriodicDummy = 187464; public const uint ShadowWordPain = 589; - public const uint ShieldDisciplineEnergize = 47755; - public const uint ShieldDisciplinePassive = 197045; + public const uint ShieldDiscipline = 197045; + public const uint ShieldDisciplineEffect = 47755; public const uint SinsOfTheMany = 280398; public const uint Smite = 585; public const uint SpiritOfRedemption = 27827; public const uint StrengthOfSoul = 197535; public const uint StrengthOfSoulEffect = 197548; + public const uint TranquilLight = 196816; public const uint ThePenitentAura = 200347; + public const uint TrailOfLightHeal = 234946; public const uint Trinity = 214205; - public const uint VampiricEmbraceHeal = 15290; - public const uint VampiricTouchDispel = 64085; + public const uint TrinityEffect = 214206; + public const uint VapiricEmbraceHeal = 15290; + public const uint VapiricTouchDispel = 64085; public const uint VoidShield = 199144; public const uint VoidShieldEffect = 199145; public const uint WeakenedSoul = 6788; + public const uint PvpRulesEnabledHardcoded = 134735; + public const uint VisualPriestPowerWordRadiance = 52872; + public const uint VisualPriestPrayerOfMending = 38945; public const uint GenReplenishment = 57669; } @@ -138,11 +182,11 @@ namespace Scripts.Spells.Priest public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleEffectDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleEffectDummy, 0, SpellEffectName.Dummy)); } } - [Script] // Angelic Feather areatrigger - created by SPELL_PRIEST_ANGELIC_FEATHER_AREATRIGGER + [Script] // Angelic Feather areatrigger - created by SpellIds.AngelicFeatherAreatrigger class areatrigger_pri_angelic_feather : AreaTriggerAI { public areatrigger_pri_angelic_feather(AreaTrigger areatrigger) : base(areatrigger) { } @@ -151,19 +195,19 @@ namespace Scripts.Spells.Priest public override void OnInitialize() { Unit caster = at.GetCaster(); - if (caster) + if (caster != null) { - List areaTriggers = caster.GetAreaTriggers(SpellIds.AngelicFeatherAreatrigger); + var areaTriggers = caster.GetAreaTriggers(SpellIds.AngelicFeatherAreatrigger); if (areaTriggers.Count >= 3) - areaTriggers.First().SetDuration(0); + areaTriggers.FirstOrDefault().SetDuration(0); } } public override void OnUnitEnter(Unit unit) { Unit caster = at.GetCaster(); - if (caster) + if (caster != null) { if (caster.IsFriendlyTo(unit)) { @@ -175,6 +219,59 @@ namespace Scripts.Spells.Priest } } + [Script] // 391387 - Answered Prayers + class spell_pri_answered_prayers : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.AnsweredPrayers, SpellIds.Apotheosis) + && ValidateSpellEffect((spellInfo.Id, 1)); + } + + void HandleOnProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + TimeSpan extraDuration = TimeSpan.FromMilliseconds(0); + AuraEffect durationEffect = GetEffect(1); + if (durationEffect != null) + extraDuration = TimeSpan.FromSeconds(durationEffect.GetAmount()); + + Unit target = eventInfo.GetActor(); + + Aura answeredPrayers = target.GetAura(SpellIds.AnsweredPrayers); + + // Note: if caster has no aura, we must cast it first. + if (answeredPrayers == null) + target.CastSpell(target, SpellIds.AnsweredPrayers, TriggerCastFlags.IgnoreCastInProgress); + else + { + // Note: there's no BaseValue dummy that we can use as reference, so we hardcode the increasing stack value. + answeredPrayers.ModStackAmount(1); + + // Note: if current stacks match max. stacks, trigger Apotheosis. + if (answeredPrayers.GetStackAmount() != aurEff.GetAmount()) + return; + + answeredPrayers.Remove(); + + Aura apotheosis = GetTarget().GetAura(SpellIds.Apotheosis); + if (apotheosis != null) + { + apotheosis.SetDuration((int)(apotheosis.GetDuration() + extraDuration.TotalMilliseconds)); + apotheosis.SetMaxDuration((int)(apotheosis.GetMaxDuration() + extraDuration.TotalMilliseconds)); + } + else + target.CastSpell(target, SpellIds.Apotheosis, + new CastSpellExtraArgs(TriggerCastFlags.FullMask & ~TriggerCastFlags.CastDirectly) + .AddSpellMod(SpellValueMod.Duration, (int)extraDuration.TotalMilliseconds)); + } + } + + public override void Register() + { + OnEffectProc.Add(new(HandleOnProc, 0, AuraType.AddFlatModifierBySpellLabel)); + } + } + [Script] // 26169 - Oracle Healing Bonus class spell_pri_aq_3p_bonus : AuraScript { @@ -195,55 +292,41 @@ namespace Scripts.Spells.Priest return; CastSpellExtraArgs args = new(aurEff); - args.AddSpellMod(SpellValueMod.BasePoint0, (int)MathFunctions.CalculatePct(healInfo.GetHeal(), 10)); + args.AddSpellMod(SpellValueMod.BasePoint0, MathFunctions.CalculatePct((int)(healInfo.GetHeal()), 10)); caster.CastSpell(caster, SpellIds.OracularHeal, args); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } [Script] // 81749 - Atonement - public class spell_pri_atonement : AuraScript + class spell_pri_atonement : AuraScript { List _appliedAtonements = new(); public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.AtonementHeal, SpellIds.SinsOfTheMany) - && ValidateSpellEffect((spellInfo.Id, 1), (SpellIds.SinsOfTheMany, 2)); + && ValidateSpellEffect((spellInfo.Id, 1), (SpellIds.SinsOfTheMany, 2)); } - bool CheckProc(ProcEventInfo eventInfo) + static bool CheckProc(ProcEventInfo eventInfo) { return eventInfo.GetDamageInfo() != null; } - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + void HandleOnProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - DamageInfo damageInfo = eventInfo.GetDamageInfo(); - CastSpellExtraArgs args = new(aurEff); - args.AddSpellMod(SpellValueMod.BasePoint0, (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount())); - _appliedAtonements.RemoveAll(targetGuid => - { - Unit target = Global.ObjAccessor.GetUnit(GetTarget(), targetGuid); - if (target) - { - if (target.GetExactDist(GetTarget()) < GetEffectInfo(1).CalcValue()) - GetTarget().CastSpell(target, SpellIds.AtonementHeal, args); - - return false; - } - return true; - }); + TriggerAtonementHealOnTargets(aurEff, eventInfo); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleOnProc, 0, AuraType.Dummy)); } public void AddAtonementTarget(ObjectGuid target) @@ -260,6 +343,45 @@ namespace Scripts.Spells.Priest UpdateSinsOfTheManyValue(); } + public List GetAtonementTargets() + { + return _appliedAtonements; + } + + public class TriggerArgs + { + public SpellInfo TriggeredBy; + public SpellSchoolMask DamageSchoolMask; + } + + public void TriggerAtonementHealOnTargets(AuraEffect atonementEffect, ProcEventInfo eventInfo) + { + Unit priest = GetUnitOwner(); + DamageInfo damageInfo = eventInfo.GetDamageInfo(); + CastSpellExtraArgs args = new(TriggerCastFlags.IgnoreCastInProgress | TriggerCastFlags.DontReportCastError); + + // Note: atonementEffect holds the correct amount Since we passed the effect in the AuraScript that calls this method. + args.AddSpellMod(SpellValueMod.BasePoint0, (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), atonementEffect.GetAmount())); + + args.SetCustomArg(new TriggerArgs() { TriggeredBy = eventInfo.GetSpellInfo(), DamageSchoolMask = eventInfo.GetDamageInfo().GetSchoolMask() }); + + float distanceLimit = GetEffectInfo(1).CalcValue(); + + _appliedAtonements.RemoveAll(targetGuid => + { + Unit target = ObjAccessor.GetUnit(priest, targetGuid); + if (target != null) + { + if (target.IsInDist2d(priest, distanceLimit)) + priest.CastSpell(target, SpellIds.AtonementHeal, args); + + return false; + } + + return true; + }); + } + void UpdateSinsOfTheManyValue() { // Note: the damage dimish starts at the 6th application as of 10.0.5. @@ -274,8 +396,86 @@ namespace Scripts.Spells.Priest } } - [Script] // 194384, 214206 - Atonement - class spell_pri_atonement_triggered : AuraScript + [Script] // 81751 - Atonement (Heal) + class spell_pri_abyssal_reverie : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellEffect((SpellIds.AbyssalReverie, 0)); + } + + void CalculateHealingBonus(Unit victim, ref int healing, ref int flatMod, ref float pctMod) + { + spell_pri_atonement.TriggerArgs args = (spell_pri_atonement.TriggerArgs)GetSpell().m_customArg; + if (args == null || (args.DamageSchoolMask & SpellSchoolMask.Shadow) == 0) + return; + + AuraEffect abyssalReverieEffect = GetCaster().GetAuraEffect(SpellIds.AbyssalReverie, 0); + if (abyssalReverieEffect != null) + MathFunctions.AddPct(ref pctMod, abyssalReverieEffect.GetAmount()); + } + + public override void Register() + { + CalcHealing.Add(new(CalculateHealingBonus)); + } + } + + // 17 - Power Word: Shield + // 139 - Renew + // 2061 - Flash Heal + [Script] // 194509 - Power Word: Radiance + class spell_pri_atonement_effect : SpellScript + { + uint _effectSpellId = SpellIds.AtonementEffect; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.Atonement, SpellIds.AtonementEffect, SpellIds.Trinity, SpellIds.TrinityEffect, SpellIds.PowerWordRadiance, SpellIds.PowerWordShield) + && ValidateSpellEffect((SpellIds.PowerWordRadiance, 3)); + } + + public override bool Load() + { + Unit caster = GetCaster(); + if (!caster.HasAura(SpellIds.Atonement)) + return false; + + // only apply Trinity if the Priest has both Trinity and Atonement and the triggering spell is Power Word: Shield. + if (caster.HasAura(SpellIds.Trinity)) + { + if (GetSpellInfo().Id != SpellIds.PowerWordShield) + return false; + + _effectSpellId = SpellIds.TrinityEffect; + } + + return true; + } + + void HandleOnHitTarget() + { + Unit caster = GetCaster(); + Unit target = GetHitUnit(); + + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.SetTriggeringSpell(GetSpell()); + + // Power Word: Radiance applies Atonement at 60 % (without modifiers) of its total duration. + if (GetSpellInfo().Id == SpellIds.PowerWordRadiance) + args.AddSpellMod(SpellValueMod.DurationPct, GetSpellInfo().GetEffect(3).CalcValue(caster)); + + caster.CastSpell(target, _effectSpellId, args); + } + + public override void Register() + { + AfterHit.Add(new(HandleOnHitTarget)); + } + } + + [Script] // 194384 - Atonement (Buff), 214206 - Atonement [Trinity] (Buff) + class spell_pri_atonement_effect_AuraScript : AuraScript { public override bool Validate(SpellInfo spellInfo) { @@ -285,12 +485,12 @@ namespace Scripts.Spells.Priest void HandleOnApply(AuraEffect aurEff, AuraEffectHandleModes mode) { Unit caster = GetCaster(); - if (caster) + if (caster != null) { Aura atonement = caster.GetAura(SpellIds.Atonement); if (atonement != null) { - var script = atonement.GetScript(); + spell_pri_atonement script = atonement.GetScript(); if (script != null) script.AddAtonementTarget(GetTarget().GetGUID()); } @@ -300,12 +500,12 @@ namespace Scripts.Spells.Priest void HandleOnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { Unit caster = GetCaster(); - if (caster) + if (caster != null) { Aura atonement = caster.GetAura(SpellIds.Atonement); if (atonement != null) { - var script = atonement.GetScript(); + spell_pri_atonement script = atonement.GetScript(); if (script != null) script.RemoveAtonementTarget(GetTarget().GetGUID()); } @@ -314,8 +514,61 @@ namespace Scripts.Spells.Priest public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(HandleOnApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(HandleOnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(HandleOnApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(HandleOnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + } + } + + [Script] // 195178 - Atonement (Passive) + class spell_pri_atonement_passive : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellEffect((SpellIds.Atonement, 0)); + } + + void HandleOnProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + Unit target = GetTarget(); + Unit summoner = target.GetOwner(); + if (summoner == null) + return; + + AuraEffect atonementEffect = summoner.GetAuraEffect(SpellIds.Atonement, 0); + if (atonementEffect != null) + { + spell_pri_atonement script = atonementEffect.GetBase().GetScript(); + if (script != null) + script.TriggerAtonementHealOnTargets(atonementEffect, eventInfo); + } + } + + public override void Register() + { + OnEffectProc.Add(new(HandleOnProc, 0, AuraType.Dummy)); + } + } + + [Script] // 33110 - Prayer of Mending (Heal) + class spell_pri_benediction : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.Renew) + && ValidateSpellEffect((SpellIds.Benediction, 0)); + } + + void HandleEffectHitTarget(uint effIndex) + { + AuraEffect benediction = GetCaster().GetAuraEffect(SpellIds.Benediction, 0); + if (benediction != null) + if (RandomHelper.randChance(benediction.GetAmount())) + GetCaster().CastSpell(GetHitUnit(), SpellIds.Renew, TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreCastInProgress); + } + + public override void Register() + { + OnEffectHitTarget.Add(new(HandleEffectHitTarget, 0, SpellEffectName.Heal)); } } @@ -324,53 +577,219 @@ namespace Scripts.Spells.Priest { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 1); + return ValidateSpellEffect((spellInfo.Id, 1)); } void FilterTargets(List targets) { - // Note: we must remove one since target is always chosen. - uint maxTargets = (uint)(GetSpellInfo().GetEffect(1).CalcValue(GetCaster()) - 1); + // Note: we must Remove one Math.Since target is always chosen. + uint maxTargets = (uint)GetSpellInfo().GetEffect(1).CalcValue(GetCaster()) - 1; SelectRandomInjuredTargets(targets, maxTargets, true); Unit explicitTarget = GetExplTargetUnit(); if (explicitTarget != null) - targets.Insert(0, explicitTarget); + targets.Add(explicitTarget); } public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitDestAreaAlly)); } } - - [Script] // 64844 - Divine Hymn - class spell_pri_divine_hymn : SpellScript + + struct DivineImageHelpers { - void FilterTargets(List targets) + const uint NpcPriestDivineImage = 198236; + + public static Unit GetSummon(Unit owner) { - targets.RemoveAll(obj => + foreach (Unit summon in owner.m_Controlled) + if (summon.GetEntry() == NpcPriestDivineImage) + return summon; + + return null; + } + + public static uint? GetSpellToCast(uint spellId) + { + switch (spellId) { - Unit target = obj.ToUnit(); - if (target) - return !GetCaster().IsInRaidWith(target); + case SpellIds.Renew: + return SpellIds.TranquilLight; + case SpellIds.PowerWordShield: + case SpellIds.PowerWordLife: + case SpellIds.FlashHeal: + case SpellIds.Heal: + case SpellIds.GreaterHeal: + case SpellIds.HolyWordSerenity: + return SpellIds.HealingLight; + case SpellIds.PrayerOfMending: + case SpellIds.PrayerOfMendingHeal: + return SpellIds.BlessedLight; + case SpellIds.PrayerOfHealing: + case SpellIds.CircleOfHealing: + case SpellIds.HaloHoly: + case SpellIds.DivineStarHolyHeal: + case SpellIds.DivineHymnHeal: + case SpellIds.HolyWordSanctify: + case SpellIds.HolyWordSalvation: + return SpellIds.DazzlingLight; + case SpellIds.ShadowWordPain: + case SpellIds.Smite: + case SpellIds.HolyFire: + case SpellIds.ShadowWordDeath: + case SpellIds.HolyWordChastise: + case SpellIds.Mindgames: + case SpellIds.MindgamesVenthyr: + return SpellIds.SearingLight; + case SpellIds.HolyNova: + return SpellIds.LightEruption; + default: + break; + } - return true; - }); + return null; + } - uint maxTargets = 3; + public static void Trigger(AuraEffect aurEff, ProcEventInfo eventInfo) + { + Unit target = eventInfo.GetActor(); + if (target == null) + return; - if (targets.Count > maxTargets) + Unit divineImage = GetSummon(target); + if (divineImage == null) + return; + + var spellId = GetSpellToCast(eventInfo.GetSpellInfo().Id); + if (!spellId.HasValue) + return; + + divineImage.CastSpell(eventInfo.GetProcSpell().m_targets, spellId.Value, aurEff); + } + } + + [Script] // 392988 - Divine Image + class spell_pri_divine_image : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.DivineImageSummon, SpellIds.DivineImageEmpower, SpellIds.DivineImageEmpowerStack); + } + + static void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + Unit target = eventInfo.GetActor(); + if (target == null) + return; + + // Note: if target has an active Divine Image, we should empower it rather than summoning a new one. + Unit divineImage = DivineImageHelpers.GetSummon(target); + if (divineImage != null) { - targets.Sort(new HealthPctOrderPred()); - targets.Resize(maxTargets); + // Note: Divine Image now teleports near the target when they cast a Holy Word spell if the Divine Image is further than 15 yards away (Patch 10.1.0). + if (target.GetDistance(divineImage) > 15.0f) + divineImage.NearTeleportTo(target.GetRandomNearPosition(3.0f)); + + TempSummon tempSummon = divineImage.ToTempSummon(); + if (tempSummon != null) + tempSummon.RefreshTimer(); + + divineImage.CastSpell(divineImage, SpellIds.DivineImageEmpower, eventInfo.GetProcSpell()); + } + else + { + target.CastSpell(target, SpellIds.DivineImageSummon, new CastSpellExtraArgs() + .SetTriggeringAura(aurEff) + .SetTriggeringSpell(eventInfo.GetProcSpell()) + .SetTriggerFlags(TriggerCastFlags.IgnoreCastInProgress | TriggerCastFlags.DisallowProcEvents | TriggerCastFlags.DontReportCastError)); + + // Note: Divine Image triggers a cast immediately based on the Holy Word cast. + DivineImageHelpers.Trigger(aurEff, eventInfo); + } + + target.CastSpell(target, SpellIds.DivineImageEmpowerStack, new CastSpellExtraArgs() + .SetTriggeringAura(aurEff) + .SetTriggeringSpell(eventInfo.GetProcSpell()) + .SetTriggerFlags(TriggerCastFlags.IgnoreCastInProgress | TriggerCastFlags.DisallowProcEvents | TriggerCastFlags.DontReportCastError)); + } + + public override void Register() + { + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); + } + } + + [Script] // 405216 - Divine Image (Spell Cast Check) + class spell_pri_divine_image_spell_triggered : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.Renew, SpellIds.PowerWordShield, SpellIds.PowerWordLife, SpellIds.FlashHeal, SpellIds.HolyWordSerenity, SpellIds.PrayerOfMending, + SpellIds.PrayerOfMendingHeal, SpellIds.PrayerOfHealing, SpellIds.CircleOfHealing, SpellIds.HaloHoly, SpellIds.DivineStarHolyHeal, SpellIds.DivineHymnHeal, SpellIds.HolyWordSanctify, + SpellIds.HolyWordSalvation, SpellIds.Smite, SpellIds.HolyFire, SpellIds.ShadowWordDeath, SpellIds.ShadowWordPain, SpellIds.Mindgames, SpellIds.MindgamesVenthyr, SpellIds.HolyWordChastise, + SpellIds.HolyNova, SpellIds.TranquilLight, SpellIds.HealingLight, SpellIds.BlessedLight, SpellIds.DazzlingLight, SpellIds.SearingLight, SpellIds.LightEruption, SpellIds.DivineImageEmpowerStack); + } + + static bool CheckProc(ProcEventInfo eventInfo) + { + return DivineImageHelpers.GetSummon(eventInfo.GetActor()) != null; + } + + void HandleAfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + GetTarget().RemoveAurasDueToSpell(SpellIds.DivineImageEmpowerStack); + } + + public override void Register() + { + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(DivineImageHelpers.Trigger, 0, AuraType.Dummy)); + AfterEffectRemove.Add(new(HandleAfterRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + } + } + + // 405963 Divine Image + [Script] // 409387 Divine Image + class spell_pri_divine_image_stack_timer : AuraScript + { + void TrackStackApplicationTime(AuraEffect aurEff, AuraEffectHandleModes mode) + { + var spellId = GetId(); + var owner = GetUnitOwner(); + GetUnitOwner().m_Events.AddEventAtOffset(() => owner.RemoveAuraFromStack(spellId), TimeSpan.FromMilliseconds(GetMaxDuration())); + } + + public override void Register() + { + AfterEffectApply.Add(new(TrackStackApplicationTime, 0, AuraType.Any, AuraEffectHandleModes.RealOrReapplyMask)); + } + } + + [Script] // 33110 - Prayer of Mending (Heal) + class spell_pri_divine_service : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.PrayerOfMendingAura) + && ValidateSpellEffect((SpellIds.DivineService, 0)); + } + + void CalculateHealingBonus(Unit victim, ref int healing, ref int flatMod, ref float pctMod) + { + AuraEffect divineServiceEffect = GetCaster().GetAuraEffect(SpellIds.DivineService, 0); + if (divineServiceEffect != null) + { + Aura prayerOfMending = victim.GetAura(SpellIds.PrayerOfMendingAura, GetCaster().GetGUID()); + if (prayerOfMending != null) + MathFunctions.AddPct(ref pctMod, (int)(divineServiceEffect.GetAmount() * prayerOfMending.GetStackAmount())); } } public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, SpellConst.EffectAll, Targets.UnitSrcAreaAlly)); + CalcHealing.Add(new(CalculateHealingBonus)); } } @@ -381,22 +800,22 @@ namespace Scripts.Spells.Priest { Unit caster = GetCaster(); - if ((int)caster.GetPowerType() != GetEffectInfo().MiscValue) + if (caster.GetPowerType() != (PowerType)GetEffectInfo().MiscValue) PreventHitDefaultEffect(effIndex); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleHitTarget, 2, SpellEffectName.Energize)); + OnEffectHitTarget.Add(new(HandleHitTarget, 2, SpellEffectName.Energize)); } } - + // 110744 - Divine Star (Holy) [Script] // 122121 - Divine Star (Shadow) class areatrigger_pri_divine_star : AreaTriggerAI { TaskScheduler _scheduler = new(); - Position _casterCurrentPosition = new(); + Position _casterCurrentPosition; List _affectedUnits = new(); float _maxTravelDistance; @@ -404,7 +823,7 @@ namespace Scripts.Spells.Priest public override void OnInitialize() { - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(at.GetSpellId(), Difficulty.None); + SpellInfo spellInfo = SpellMgr.GetSpellInfo(at.GetSpellId(), Difficulty.None); if (spellInfo == null) return; @@ -417,8 +836,8 @@ namespace Scripts.Spells.Priest _casterCurrentPosition = caster.GetPosition(); - // Note: max. distance at which the Divine Star can travel to is EFFECT_1's BasePoints yards. - _maxTravelDistance = (float)spellInfo.GetEffect(1).CalcValue(caster); + // Note: max. distance at which the Divine Star can travel to is 1's BasePoints yards. + _maxTravelDistance = (float)(spellInfo.GetEffect(1).CalcValue(caster)); Position destPos = _casterCurrentPosition; at.MovePositionToFirstCollision(destPos, _maxTravelDistance, 0.0f); @@ -428,9 +847,8 @@ namespace Scripts.Spells.Priest Vector3 endPoint = firstPath.GetPath().Last(); - // Note: it takes 1000ms to reach EFFECT_1's BasePoints yards, so it takes (1000 / EFFECT_1's BasePoints)ms to run 1 yard. + // Note: it takes TimeSpan.FromMilliseconds(1000) to reach 1's BasePoints yards, so it takes (1000 / 1's BasePoints)ms to run 1 yard. at.InitSplines(firstPath.GetPath(), (uint)(at.GetDistance(endPoint.X, endPoint.Y, endPoint.Z) * (float)(1000 / _maxTravelDistance))); - } public override void OnUpdate(uint diff) @@ -445,6 +863,7 @@ namespace Scripts.Spells.Priest public override void OnUnitExit(Unit unit) { + // Note: this ensures any unit receives a second hit if they happen to be inside the At when Divine Star starts its return path. HandleUnitEnterExit(unit); } @@ -457,12 +876,14 @@ namespace Scripts.Spells.Priest if (_affectedUnits.Contains(unit.GetGUID())) return; - CastSpellExtraArgs castSpellExtraArgs = new(TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreCastInProgress); + TriggerCastFlags TriggerFlags = TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreCastInProgress; if (caster.IsValidAttackTarget(unit)) - caster.CastSpell(unit, at.GetSpellId() == SpellIds.DivineStarShadow ? SpellIds.DivineStarShadowDamage : SpellIds.DivineStarHolyDamage, castSpellExtraArgs); + caster.CastSpell(unit, at.GetSpellId() == SpellIds.DivineStarShadow ? SpellIds.DivineStarShadowDamage : SpellIds.DivineStarHolyDamage, + TriggerFlags); else if (caster.IsValidAssistTarget(unit)) - caster.CastSpell(unit, at.GetSpellId() == SpellIds.DivineStarShadow ? SpellIds.DivineStarShadowHeal : SpellIds.DivineStarHolyHeal, castSpellExtraArgs); + caster.CastSpell(unit, at.GetSpellId() == SpellIds.DivineStarShadow ? SpellIds.DivineStarShadowHeal : SpellIds.DivineStarHolyHeal, + TriggerFlags); _affectedUnits.Add(unit.GetGUID()); } @@ -486,25 +907,24 @@ namespace Scripts.Spells.Priest void ReturnToCaster() { _scheduler.Schedule(TimeSpan.FromMilliseconds(0), task => - { - Unit caster = at.GetCaster(); - if (caster == null) - return; + { + Unit caster = at.GetCaster(); + if (caster == null) + return; - _casterCurrentPosition = caster.GetPosition(); + _casterCurrentPosition = caster.GetPosition(); - Vector3[] returnSplinePoints = new Vector3[4]; + Vector3[] returnSplinePoints = new Vector3[4]; - returnSplinePoints[0] = at.GetPosition(); - returnSplinePoints[1] = at.GetPosition(); - returnSplinePoints[2] = caster.GetPosition(); - returnSplinePoints[3] = caster.GetPosition(); + returnSplinePoints[0] = at.GetPosition(); + returnSplinePoints[1] = at.GetPosition(); + returnSplinePoints[2] = caster.GetPosition(); + returnSplinePoints[3] = caster.GetPosition(); - at.InitSplines(returnSplinePoints, (uint)(at.GetDistance(caster) / _maxTravelDistance * 1000)); + at.InitSplines(returnSplinePoints, (uint)(at.GetDistance(caster) / _maxTravelDistance * 1000)); - task.Repeat(TimeSpan.FromMilliseconds(250)); - - }); + task.Repeat(TimeSpan.FromMilliseconds(250)); + }); } } @@ -514,8 +934,8 @@ namespace Scripts.Spells.Priest public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.Renew, SpellIds.EmpoweredRenewHeal) - && ValidateSpellEffect(SpellIds.Renew, 0) - && Global.SpellMgr.GetSpellInfo(SpellIds.Renew, Difficulty.None).GetEffect(0).IsAura(AuraType.PeriodicHeal); + && ValidateSpellEffect((SpellIds.Renew, 0)) + && SpellMgr.GetSpellInfo(SpellIds.Renew, Difficulty.None).GetEffect(0).IsAura(AuraType.PeriodicHeal); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -523,7 +943,7 @@ namespace Scripts.Spells.Priest Unit caster = eventInfo.GetActor(); Unit target = eventInfo.GetProcTarget(); - SpellInfo renewSpellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.Renew, GetCastDifficulty()); + SpellInfo renewSpellInfo = SpellMgr.GetSpellInfo(SpellIds.Renew, GetCastDifficulty()); SpellEffectInfo renewEffect = renewSpellInfo.GetEffect(0); int estimatedTotalHeal = (int)AuraEffect.CalculateEstimatedfTotalPeriodicAmount(caster, target, renewSpellInfo, renewEffect, renewEffect.CalcValue(caster), 1); int healAmount = MathFunctions.CalculatePct(estimatedTotalHeal, aurEff.GetAmount()); @@ -533,10 +953,111 @@ namespace Scripts.Spells.Priest public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } - + + [Script] // 414553 - Epiphany + class spell_pri_epiphany : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.PrayerOfMending, SpellIds.EpiphanyHighlight); + } + + static bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + return RandomHelper.randChance(aurEff.GetAmount()); + } + + void HandleOnProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + Unit target = GetTarget(); + + target.GetSpellHistory().ResetCooldown(SpellIds.PrayerOfMending, true); + + target.CastSpell(target, SpellIds.EpiphanyHighlight, aurEff); + } + + public override void Register() + { + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleOnProc, 0, AuraType.Dummy)); + } + } + + // 415673 - Essence Devourer (Heal) + [Script] // 415676 - Essence Devourer (Heal) + class spell_pri_essence_devourer_heal : SpellScript + { + void FilterTargets(List targets) + { + SelectRandomInjuredTargets(targets, 1, true); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitDestAreaAlly)); + } + } + + [Script] // 246287 - Evangelism + class spell_pri_evangelism : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.Trinity, SpellIds.AtonementEffect, SpellIds.TrinityEffect); + } + + void HandleScriptEffect(uint effIndex) + { + Unit caster = GetCaster(); + Unit target = GetHitUnit(); + + Aura atonementAura = caster.HasAura(SpellIds.Trinity) + ? target.GetAura(SpellIds.TrinityEffect, caster.GetGUID()) + : target.GetAura(SpellIds.AtonementEffect, caster.GetGUID()); + if (atonementAura == null) + return; + + TimeSpan extraDuration = TimeSpan.FromSeconds(GetEffectValue()); + + atonementAura.SetDuration((int)(atonementAura.GetDuration() + extraDuration.TotalMilliseconds)); + atonementAura.SetMaxDuration((int)(atonementAura.GetDuration() + extraDuration.TotalMilliseconds)); + } + + public override void Register() + { + OnEffectHitTarget.Add(new(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); + } + } + + [Script] // 33110 - Prayer of Mending (Heal) + class spell_pri_focused_mending : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellEffect((SpellIds.FocusedMending, 0)); + } + + void CalculateHealingBonus(Unit victim, ref int healing, ref int flatMod, ref float pctMod) + { + AuraEffect focusedMendingEffect = GetCaster().GetAuraEffect(SpellIds.FocusedMending, 0); + if (focusedMendingEffect != null) + { + bool isEmpoweredByFocusedMending = (bool)GetSpell().m_customArg; + + if (isEmpoweredByFocusedMending && isEmpoweredByFocusedMending) + MathFunctions.AddPct(ref pctMod, focusedMendingEffect.GetAmount()); + } + } + + public override void Register() + { + CalcHealing.Add(new(CalculateHealingBonus)); + } + } + [Script] // 47788 - Guardian Spirit class spell_pri_guardian_spirit : AuraScript { @@ -544,7 +1065,7 @@ namespace Scripts.Spells.Priest public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.GuardianSpiritHeal) && ValidateSpellEffect(spellInfo.Id, 1); + return ValidateSpellInfo(SpellIds.GuardianSpiritHeal) && ValidateSpellEffect((spellInfo.Id, 1)); } public override bool Load() @@ -576,8 +1097,8 @@ namespace Scripts.Spells.Priest public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 1, AuraType.SchoolAbsorb)); - OnEffectAbsorb.Add(new EffectAbsorbHandler(Absorb, 1)); + DoEffectCalcAmount.Add(new(CalculateAmount, 1, AuraType.SchoolAbsorb)); + OnEffectAbsorb.Add(new(Absorb, 1)); } } @@ -588,16 +1109,16 @@ namespace Scripts.Spells.Priest { Unit caster = GetCaster(); - if ((int)caster.GetPowerType() != GetEffectInfo().MiscValue) + if (caster.GetPowerType() != (PowerType)GetEffectInfo().MiscValue) PreventHitDefaultEffect(effIndex); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleHitTarget, 1, SpellEffectName.Energize)); + OnEffectHitTarget.Add(new(HandleHitTarget, 1, SpellEffectName.Energize)); } } - + // 120517 - Halo (Holy) [Script] // 120644 - Halo (Shadow) class areatrigger_pri_halo : AreaTriggerAI @@ -611,10 +1132,10 @@ namespace Scripts.Spells.Priest { if (caster.IsValidAttackTarget(unit)) caster.CastSpell(unit, at.GetSpellId() == SpellIds.HaloShadow ? SpellIds.HaloShadowDamage : SpellIds.HaloHolyDamage, - new CastSpellExtraArgs(TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreCastInProgress)); + TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreCastInProgress); else if (caster.IsValidAssistTarget(unit)) caster.CastSpell(unit, at.GetSpellId() == SpellIds.HaloShadow ? SpellIds.HaloShadowHeal : SpellIds.HaloHolyHeal, - new CastSpellExtraArgs(TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreCastInProgress)); + TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreCastInProgress); } } } @@ -639,11 +1160,11 @@ namespace Scripts.Spells.Priest public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckProc, 0, AuraType.ProcTriggerSpell)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.ProcTriggerSpell)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); } } - + [Script] // 63733 - Holy Words class spell_pri_holy_words : AuraScript { @@ -667,7 +1188,7 @@ namespace Scripts.Spells.Priest case SpellIds.FlashHeal: // reduce Holy Word: Serenity cd by 6 seconds targetSpellId = SpellIds.HolyWordSerenity; cdReductionEffIndex = 1; - // cdReduction = sSpellMgr.GetSpellInfo(SPELL_PRIEST_HOLY_WORD_SERENITY, GetCastDifficulty()).GetEffect(EFFECT_1).CalcValue(player); + // cdReduction = SpellMgr.GetSpellInfo(SpellIds.HolyWordSerenity, GetCastDifficulty()).GetEffect(1).CalcValue(player); break; case SpellIds.PrayerOfHealing: // reduce Holy Word: Sanctify cd by 6 seconds targetSpellId = SpellIds.HolyWordSanctify; @@ -686,14 +1207,87 @@ namespace Scripts.Spells.Priest return; } - SpellInfo targetSpellInfo = Global.SpellMgr.GetSpellInfo(targetSpellId, GetCastDifficulty()); + SpellInfo targetSpellInfo = SpellMgr.GetSpellInfo(targetSpellId, GetCastDifficulty()); int cdReduction = targetSpellInfo.GetEffect(cdReductionEffIndex).CalcValue(GetTarget()); GetTarget().GetSpellHistory().ModifyCooldown(targetSpellInfo, TimeSpan.FromSeconds(-cdReduction), true); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); + } + } + + [Script] // 265202 - Holy Word: Salvation + class spell_pri_holy_word_salvation : SpellScript + { + SpellInfo _spellInfoHeal; + SpellEffectInfo _healEffectDummy; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.PrayerOfMendingAura, SpellIds.Renew) + && ValidateSpellEffect((SpellIds.PrayerOfMendingHeal, 0), (spellInfo.Id, 1)) + && spellInfo.GetEffect(1).TargetB.GetTarget() == Targets.UnitSrcAreaAlly; + } + + public override bool Load() + { + _spellInfoHeal = SpellMgr.GetSpellInfo(SpellIds.PrayerOfMendingHeal, Difficulty.None); + _healEffectDummy = _spellInfoHeal.GetEffect(0); + return true; + } + + void HandleApplyBuffs(uint effIndex) + { + Unit caster = GetCaster(); + Unit target = GetHitUnit(); + + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + + // amount of Prayer of Mending is SpellIds.HolyWordSalvation's 1. + args.AddSpellMod(SpellValueMod.AuraStack, GetEffectValue()); + + int basePoints = caster.SpellHealingBonusDone(target, _spellInfoHeal, _healEffectDummy.CalcValue(caster), DamageEffectType.Heal, _healEffectDummy); + args.AddSpellMod(SpellValueMod.BasePoint0, basePoints); + caster.CastSpell(target, SpellIds.PrayerOfMendingAura, args); + + // a full duration Renew is triggered. + caster.CastSpell(target, SpellIds.Renew, new CastSpellExtraArgs(TriggerCastFlags.FullMask).SetTriggeringSpell(GetSpell())); + } + + public override void Register() + { + OnEffectHitTarget.Add(new(HandleApplyBuffs, 1, SpellEffectName.Dummy)); + } + } + + // 2050 - Holy Word: Serenity + [Script] // 34861 - Holy Word: Sanctify + class spell_pri_holy_word_salvation_cooldown_reduction : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.HolyWordSalvation) + && ValidateSpellEffect((SpellIds.HolyWordSalvation, 2)); + } + + public override bool Load() + { + return GetCaster().HasSpell(SpellIds.HolyWordSalvation); + } + + void ReduceCooldown() + { + // cooldown reduced by SpellIds.HolyWordSalvation's Seconds(2). + int cooldownReduction = SpellMgr.GetSpellInfo(SpellIds.HolyWordSalvation, GetCastDifficulty()).GetEffect(2).CalcValue(GetCaster()); + + GetCaster().GetSpellHistory().ModifyCooldown(SpellIds.HolyWordSalvation, TimeSpan.FromSeconds(-cooldownReduction), true); + } + + public override void Register() + { + AfterCast.Add(new(ReduceCooldown)); } } @@ -709,16 +1303,16 @@ namespace Scripts.Spells.Priest { PreventDefaultAction(); Unit caster = eventInfo.GetActor(); - if (eventInfo.GetSpellTypeMask().HasAnyFlag(ProcFlagsSpellType.Heal)) - caster.CastSpell((Unit)null, SpellIds.DivineBlessing, true); + if ((eventInfo.GetSpellTypeMask() & ProcFlagsSpellType.Heal) != 0) + caster.CastSpell(null, SpellIds.DivineBlessing, true); - if (eventInfo.GetSpellTypeMask().HasAnyFlag(ProcFlagsSpellType.Damage)) - caster.CastSpell((Unit)null, SpellIds.DivineWrath, true); + if ((eventInfo.GetSpellTypeMask() & ProcFlagsSpellType.Damage) != 0) + caster.CastSpell(null, SpellIds.DivineWrath, true); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -737,12 +1331,12 @@ namespace Scripts.Spells.Priest SpellCastTargets targets = new(); targets.SetDst(destPos); targets.SetUnitTarget(GetCaster()); - GetHitUnit().CastSpell(targets, (uint)GetEffectValue(), new CastSpellExtraArgs(GetCastDifficulty())); + GetHitUnit().CastSpell(targets, (uint)GetEffectValue(), GetCastDifficulty()); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleEffectDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleEffectDummy, 0, SpellEffectName.Dummy)); } } @@ -761,7 +1355,54 @@ namespace Scripts.Spells.Priest public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] // 373178 - Light's Wrath + class spell_pri_lights_wrath : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellEffect((spellInfo.Id, 1)); + } + + public override void OnPrecast() + { + Aura atonement = GetCaster().GetAura(SpellIds.Atonement); + if (atonement == null) + return; + + spell_pri_atonement script = atonement.GetScript(); + if (script == null) + return; + + foreach (ObjectGuid atonementTarget in script.GetAtonementTargets()) + { + Unit target = ObjAccessor.GetUnit(GetCaster(), atonementTarget); + if (target != null) + { + target.CancelSpellMissiles(SpellIds.LightsWrathVisual, false, false); + target.CastSpell(GetCaster(), SpellIds.LightsWrathVisual, TriggerCastFlags.IgnoreCastInProgress); + } + } + } + + void CalculateDamageBonus(Unit victim, ref int damage, ref int flatMod, ref float pctMod) + { + Aura atonement = GetCaster().GetAura(SpellIds.Atonement); + if (atonement == null) + return; + + // Atonement size may have changed when missile hits, we need to take an updated count of Atonement applications. + spell_pri_atonement script = atonement.GetScript(); + if (script != null) + MathFunctions.AddPct(ref pctMod, GetEffectInfo(1).CalcValue(GetCaster()) * script.GetAtonementTargets().Count); + } + + public override void Register() + { + CalcDamage.Add(new(CalculateDamageBonus)); } } @@ -776,12 +1417,16 @@ namespace Scripts.Spells.Priest void RemoveEffect(AuraEffect aurEff, AuraEffectHandleModes mode) { if (GetTargetApplication().GetRemoveMode() == AuraRemoveMode.Death || GetTargetApplication().GetRemoveMode() == AuraRemoveMode.Expire) - GetCaster()?.CastSpell(GetTarget().GetPosition(), SpellIds.MindBombStun, new CastSpellExtraArgs(true)); + { + Unit caster = GetCaster(); + if (caster != null) + caster.CastSpell(GetTarget().GetPosition(), SpellIds.MindBombStun, true); + } } public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(RemoveEffect, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(RemoveEffect, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -813,10 +1458,10 @@ namespace Scripts.Spells.Priest public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.Dummy)); } } - + [Script("spell_pri_penance", SpellIds.PenanceChannelDamage, SpellIds.PenanceChannelHealing)] // 47540 - Penance [Script("spell_pri_dark_reprimand", SpellIds.DarkReprimandChannelDamage, SpellIds.DarkReprimandChannelHealing)] // 400169 - Dark Reprimand class spell_pri_penance : SpellScript @@ -840,7 +1485,7 @@ namespace Scripts.Spells.Priest Unit caster = GetCaster(); Unit target = GetExplTargetUnit(); - if (target) + if (target != null) { if (!caster.IsFriendlyTo(target)) { @@ -848,9 +1493,10 @@ namespace Scripts.Spells.Priest return SpellCastResult.BadTargets; if (!caster.IsInFront(target)) - return SpellCastResult.NotInfront; + return SpellCastResult.UnitNotInfront; } } + return SpellCastResult.SpellCastOk; } @@ -859,19 +1505,21 @@ namespace Scripts.Spells.Priest Unit caster = GetCaster(); Unit target = GetHitUnit(); - if (target) + if (target != null) { if (caster.IsFriendlyTo(target)) - caster.CastSpell(target, _healingSpellId, new CastSpellExtraArgs(TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreSpellAndCategoryCD).SetTriggeringSpell(GetSpell())); + caster.CastSpell(target, _healingSpellId, new CastSpellExtraArgs(TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreSpellAndCategoryCD) + .SetTriggeringSpell(GetSpell())); else - caster.CastSpell(target, _damageSpellId, new CastSpellExtraArgs(TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreSpellAndCategoryCD).SetTriggeringSpell(GetSpell())); + caster.CastSpell(target, _damageSpellId, new CastSpellExtraArgs(TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreSpellAndCategoryCD) + .SetTriggeringSpell(GetSpell())); } } public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnCheckCast.Add(new(CheckCast)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -893,7 +1541,70 @@ namespace Scripts.Spells.Priest public override void Register() { - OnEffectRemove.Add(new EffectApplyHandler(HandleOnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(HandleOnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + } + } + + // 262484 - Power Leech (Passive for Shadowfiend) + [Script] // 284621 - Power Leech (Passive for Mindbender) + class spell_pri_power_leech_passive : AuraScript + { + const uint NpcPriestMindbender = 62982; + const uint NpcPriestShadowfiend = 19668; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.PowerLeechShadowfiendInsanity, SpellIds.PowerLeechShadowfiendMana, SpellIds.PowerLeechMindbenderInsanity, SpellIds.PowerLeechMindbenderMana, SpellIds.EssenceDevourer, SpellIds.EssenceDevourerShadowfiendHeal, SpellIds.EssenceDevourerMindbenderHeal) + && ValidateSpellEffect((SpellIds.PowerLeechShadowfiendInsanity, 0), (SpellIds.PowerLeechShadowfiendMana, 0), (SpellIds.PowerLeechMindbenderInsanity, 0), (SpellIds.PowerLeechMindbenderMana, 0)); + } + + static bool CheckProc(ProcEventInfo eventInfo) + { + return eventInfo.GetDamageInfo() != null; + } + + void HandleOnProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + Unit target = GetTarget(); + Player summoner = target.GetOwner()?.ToPlayer(); + if (summoner == null) + return; + + SpellInfo spellInfo; + int divisor = 1; + + if (summoner.GetPrimarySpecialization() != ChrSpecialization.PriestShadow) + { + if (target.GetEntry() == NpcPriestShadowfiend) + { + // Note: divisor is 100 because effect value is 5 and its supposed to restore 0.5% + spellInfo = SpellMgr.GetSpellInfo(SpellIds.PowerLeechShadowfiendMana, GetCastDifficulty()); + divisor = 10; + } + else + { + // Note: divisor is 100 because effect value is 20 and its supposed to restore 0.2% + spellInfo = SpellMgr.GetSpellInfo(SpellIds.PowerLeechMindbenderMana, GetCastDifficulty()); + divisor = 100; + } + } + else + spellInfo = SpellMgr.GetSpellInfo(target.GetEntry() == NpcPriestShadowfiend + ? SpellIds.PowerLeechShadowfiendInsanity + : SpellIds.PowerLeechMindbenderInsanity, GetCastDifficulty()); + + target.CastSpell(summoner, spellInfo.Id, new CastSpellExtraArgs(aurEff) + .AddSpellMod(SpellValueMod.BasePoint0, spellInfo.GetEffect(0).CalcValue() / divisor)); + + // Note: Essence Devourer talent. + if (summoner.HasAura(SpellIds.EssenceDevourer)) + summoner.CastSpell(null, target.GetEntry() == NpcPriestShadowfiend ? SpellIds.EssenceDevourerShadowfiendHeal : SpellIds.EssenceDevourerMindbenderHeal, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleOnProc, 0, AuraType.Dummy)); } } @@ -921,8 +1632,8 @@ namespace Scripts.Spells.Priest public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(HandleOnApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(HandleOnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(HandleOnApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(HandleOnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -944,7 +1655,7 @@ namespace Scripts.Spells.Priest public override void Register() { - CalcDamage.Add(new DamageAndHealingCalcHandler(CalculateDamageBonus)); + CalcDamage.Add(new(CalculateDamageBonus)); } } @@ -957,7 +1668,7 @@ namespace Scripts.Spells.Priest return ValidateSpellInfo(SpellIds.PowerOfTheDarkSide); } - void CalculateHealingBonus(Unit victim, ref int damage, ref int flatMod, ref float pctMod) + void CalculateHealingBonus(Unit victim, ref int healing, ref int flatMod, ref float pctMod) { AuraEffect powerOfTheDarkSide = GetCaster().GetAuraEffect(SpellIds.PowerOfTheDarkSide, 0); if (powerOfTheDarkSide != null) @@ -966,27 +1677,30 @@ namespace Scripts.Spells.Priest public override void Register() { - CalcHealing.Add(new DamageAndHealingCalcHandler(CalculateHealingBonus)); + CalcHealing.Add(new(CalculateHealingBonus)); } } - + [Script] // 194509 - Power Word: Radiance class spell_pri_power_word_radiance : SpellScript { + List _visualTargets = new(); + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.Atonement, SpellIds.AtonementTriggered, SpellIds.Trinity) && ValidateSpellEffect(spellInfo.Id, 3); + return ValidateSpellInfo(SpellIds.AtonementEffect); } - void OnTargetSelect(List targets) + void FilterTargets(List targets) { - uint maxTargets = (uint)(GetEffectInfo(2).CalcValue(GetCaster()) + 1); // adding 1 for explicit target unit + Unit explTarget = GetExplTargetUnit(); + + // we must add one Math.Since explicit target is always chosen. + uint maxTargets = (uint)GetEffectInfo(2).CalcValue(GetCaster()) + 1; + if (targets.Count > maxTargets) { - Unit explTarget = GetExplTargetUnit(); - - // Sort targets so units with no atonement are first, then units who are injured, then oher units - // Make sure explicit target unit is first + // priority is: a) no Atonement b) injured c) anything else (excluding explicit target which is always added). targets.Sort((lhs, rhs) => { if (lhs == explTarget) // explTarget > anything: always true @@ -999,89 +1713,59 @@ namespace Scripts.Spells.Priest targets.Resize(maxTargets); } + + foreach (WorldObject target in targets) + { + if (target == explTarget) + continue; + + _visualTargets.Add(target.GetGUID()); + } } void HandleEffectHitTarget(uint effIndex) { - Unit caster = GetCaster(); - if (caster.HasAura(SpellIds.Trinity)) - return; - - int durationPct = GetEffectInfo(3).CalcValue(caster); - if (caster.HasAura(SpellIds.Atonement)) - caster.CastSpell(GetHitUnit(), SpellIds.AtonementTriggered, new CastSpellExtraArgs(SpellValueMod.DurationPct, durationPct).SetTriggerFlags(TriggerCastFlags.FullMask)); + foreach (ObjectGuid guid in _visualTargets) + { + Unit target = ObjAccessor.GetUnit(GetHitUnit(), guid); + if (target != null) + GetHitUnit().SendPlaySpellVisual(target, SpellIds.VisualPriestPowerWordRadiance, 0, 0, 70.0f); + } } public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(OnTargetSelect, 1, Targets.UnitDestAreaAlly)); - OnEffectHitTarget.Add(new EffectHandler(HandleEffectHitTarget, 1, SpellEffectName.Heal)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 1, Targets.UnitDestAreaAlly)); + OnEffectHitTarget.Add(new(HandleEffectHitTarget, 0, SpellEffectName.Dummy)); } - Tuple MakeSortTuple(WorldObject obj) + (bool, bool) MakeSortTuple(WorldObject obj) { - return Tuple.Create(IsUnitWithNoAtonement(obj), IsUnitInjured(obj)); + return (IsUnitWithNoAtonement(obj), IsUnitInjured(obj)); } // Returns true if obj is a unit but has no atonement bool IsUnitWithNoAtonement(WorldObject obj) { Unit unit = obj.ToUnit(); - return unit != null && !unit.HasAura(SpellIds.AtonementTriggered, GetCaster().GetGUID()); + return unit != null && !unit.HasAura(SpellIds.AtonementEffect, GetCaster().GetGUID()); } // Returns true if obj is a unit and is injured static bool IsUnitInjured(WorldObject obj) { Unit unit = obj.ToUnit(); - return unit != null && unit.IsFullHealth(); + return unit != null && !unit.IsFullHealth(); } } [Script] // 17 - Power Word: Shield - class spell_pri_power_word_shield : SpellScript + class spell_pri_power_word_shield : AuraScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.WeakenedSoul); - } - - SpellCastResult CheckCast() - { - Unit caster = GetCaster(); - Unit target = GetExplTargetUnit(); - if (target != null) - if (!caster.HasAura(SpellIds.Rapture)) - if (target.HasAura(SpellIds.WeakenedSoul, caster.GetGUID())) - return SpellCastResult.BadTargets; - - return SpellCastResult.SpellCastOk; - } - - void HandleEffectHit() - { - Unit caster = GetCaster(); - Unit target = GetHitUnit(); - if (target != null) - if (!caster.HasAura(SpellIds.Rapture)) - caster.CastSpell(target, SpellIds.WeakenedSoul, true); - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - AfterHit.Add(new HitHandler(HandleEffectHit)); - } - } - - [Script] // 17 - Power Word: Shield Aura - class spell_pri_power_word_shield_aura : AuraScript - { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.BodyAndSoul, SpellIds.BodyAndSoulSpeed, SpellIds.StrengthOfSoul, SpellIds.StrengthOfSoulEffect, SpellIds.RenewedHope, SpellIds.RenewedHopeEffect, - SpellIds.VoidShield, SpellIds.VoidShieldEffect, SpellIds.Atonement, SpellIds.Trinity, SpellIds.AtonementTriggered, SpellIds.AtonementTriggeredPowerTrinity, SpellIds.ShieldDisciplinePassive, - SpellIds.ShieldDisciplineEnergize, SpellIds.Rapture, SpellIds.MasteryGrace); + return ValidateSpellInfo(SpellIds.StrengthOfSoul, SpellIds.StrengthOfSoulEffect, SpellIds.AtonementEffect, SpellIds.TrinityEffect, SpellIds.ShieldDiscipline, SpellIds.ShieldDisciplineEffect, SpellIds.PvpRulesEnabledHardcoded) + && ValidateSpellEffect((SpellIds.MasteryGrace, 0), (SpellIds.Rapture, 1), (SpellIds.Benevolence, 0)); } void CalculateAmount(AuraEffect auraEffect, ref int amount, ref bool canBeRecalculated) @@ -1091,60 +1775,68 @@ namespace Scripts.Spells.Priest Unit caster = GetCaster(); if (caster != null) { - float amountF = caster.SpellBaseDamageBonusDone(GetSpellInfo().GetSchoolMask()) * 1.65f; + float modifiedAmount = caster.SpellBaseDamageBonusDone(GetSpellInfo().GetSchoolMask()) * 3.36f; Player player = caster.ToPlayer(); if (player != null) { - MathFunctions.AddPct(ref amountF, player.GetRatingBonusValue(CombatRating.VersatilityDamageDone)); + MathFunctions.AddPct(ref modifiedAmount, player.GetRatingBonusValue(CombatRating.VersatilityDamageDone)); - AuraEffect mastery = caster.GetAuraEffect(SpellIds.MasteryGrace, 0); - if (mastery != null) - if (GetUnitOwner().HasAura(SpellIds.AtonementTriggered) || GetUnitOwner().HasAura(SpellIds.AtonementTriggeredPowerTrinity)) - MathFunctions.AddPct(ref amountF, mastery.GetAmount()); + // Mastery: Grace (Tbd: move into DoEffectCalcDamageAndHealing hook with a new SpellScript and AuraScript). + AuraEffect masteryGraceEffect = caster.GetAuraEffect(SpellIds.MasteryGrace, 0); + if (masteryGraceEffect != null) + if (GetUnitOwner().HasAura(SpellIds.AtonementEffect) || GetUnitOwner().HasAura(SpellIds.TrinityEffect)) + MathFunctions.AddPct(ref modifiedAmount, masteryGraceEffect.GetAmount()); + + if (player.GetPrimarySpecialization() != ChrSpecialization.PriestHoly) + { + modifiedAmount *= 1.25f; + if (caster.HasAura(SpellIds.PvpRulesEnabledHardcoded)) + modifiedAmount *= 0.8f; + } } - AuraEffect rapture = caster.GetAuraEffect(SpellIds.Rapture, 1); - if (rapture != null) - MathFunctions.AddPct(ref amountF, rapture.GetAmount()); + // Rapture talent (Tbd: move into DoEffectCalcDamageAndHealing hook). + AuraEffect raptureEffect = caster.GetAuraEffect(SpellIds.Rapture, 1); + if (raptureEffect != null) + MathFunctions.AddPct(ref modifiedAmount, raptureEffect.GetAmount()); - amount = (int)amountF; + // Benevolence talent + AuraEffect benevolenceEffect = caster.GetAuraEffect(SpellIds.Benevolence, 0); + if (benevolenceEffect != null) + MathFunctions.AddPct(ref modifiedAmount, benevolenceEffect.GetAmount()); + + amount = (int)modifiedAmount; } } void HandleOnApply(AuraEffect aurEff, AuraEffectHandleModes mode) { Unit caster = GetCaster(); - Unit target = GetTarget(); - if (!caster) + if (caster == null) return; - if (caster.HasAura(SpellIds.BodyAndSoul)) - caster.CastSpell(target, SpellIds.BodyAndSoulSpeed, true); + // Note: Strength of Soul PvP talent. if (caster.HasAura(SpellIds.StrengthOfSoul)) - caster.CastSpell(target, SpellIds.StrengthOfSoulEffect, true); - if (caster.HasAura(SpellIds.RenewedHope)) - caster.CastSpell(target, SpellIds.RenewedHopeEffect, true); - if (caster.HasAura(SpellIds.VoidShield) && caster == target) - caster.CastSpell(target, SpellIds.VoidShieldEffect, true); - if (caster.HasAura(SpellIds.Atonement)) - caster.CastSpell(target, caster.HasAura(SpellIds.Trinity) ? SpellIds.AtonementTriggeredPowerTrinity : SpellIds.AtonementTriggered, true); + caster.CastSpell(GetTarget(), SpellIds.StrengthOfSoulEffect, aurEff); } void HandleOnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { GetTarget().RemoveAura(SpellIds.StrengthOfSoulEffect); + + // Note: Shield Discipline talent. Unit caster = GetCaster(); - if (caster) - if (GetTargetApplication().GetRemoveMode() == AuraRemoveMode.EnemySpell && caster.HasAura(SpellIds.ShieldDisciplinePassive)) - caster.CastSpell(caster, SpellIds.ShieldDisciplineEnergize, true); + if (caster != null) + if (GetTargetApplication().GetRemoveMode() == AuraRemoveMode.EnemySpell && caster.HasAura(SpellIds.ShieldDiscipline)) + caster.CastSpell(caster, SpellIds.ShieldDisciplineEffect, aurEff); } public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); - AfterEffectApply.Add(new EffectApplyHandler(HandleOnApply, 0, AuraType.SchoolAbsorb, AuraEffectHandleModes.RealOrReapplyMask)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleOnRemove, 0, AuraType.SchoolAbsorb, AuraEffectHandleModes.Real)); + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.SchoolAbsorb)); + AfterEffectApply.Add(new(HandleOnApply, 0, AuraType.SchoolAbsorb, AuraEffectHandleModes.RealOrReapplyMask)); + AfterEffectRemove.Add(new(HandleOnRemove, 0, AuraType.SchoolAbsorb, AuraEffectHandleModes.Real)); } } @@ -1165,11 +1857,11 @@ namespace Scripts.Spells.Priest public override void Register() { - OnEffectLaunch.Add(new EffectHandler(RestoreMana, 1, SpellEffectName.Dummy)); + OnEffectLaunch.Add(new(RestoreMana, 1, SpellEffectName.Dummy)); } } - // 33076 - Prayer of Mending (Dummy) - [Script] // 411097 - Priest Holy 10.1 Class Set 2pc (Chooser) + + [Script] // 33076 - Prayer of Mending (Dummy) class spell_pri_prayer_of_mending_dummy : SpellScript { SpellInfo _spellInfoHeal; @@ -1177,38 +1869,48 @@ namespace Scripts.Spells.Priest public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.PrayerOfMendingHeal, SpellIds.PrayerOfMendingAura) - && ValidateSpellEffect(SpellIds.PrayerOfMendingHeal, 0); + return ValidateSpellInfo(SpellIds.PrayerOfMendingHeal, SpellIds.PrayerOfMendingAura, SpellIds.PrayerOfMendingAura, SpellIds.Epiphany, SpellIds.EpiphanyHighlight) + && ValidateSpellEffect((SpellIds.PrayerOfMendingHeal, 0)); } public override bool Load() { - _spellInfoHeal = Global.SpellMgr.GetSpellInfo(SpellIds.PrayerOfMendingHeal, Difficulty.None); + _spellInfoHeal = SpellMgr.GetSpellInfo(SpellIds.PrayerOfMendingHeal, Difficulty.None); _healEffectDummy = _spellInfoHeal.GetEffect(0); return true; } - void FilterTargets(List targets) - { - SelectRandomInjuredTargets(targets, 1, true); - } - void HandleEffectDummy(uint effIndex) { - // Note: we need to increase BasePoints by 1 since it's 4 as default. - uint basePoints = (uint)GetCaster().SpellHealingBonusDone(GetHitUnit(), _spellInfoHeal, _healEffectDummy.CalcValue(GetCaster()), DamageEffectType.Heal, _healEffectDummy); + Unit caster = GetCaster(); + Unit target = GetHitUnit(); + + // Note: we need to increase BasePoints by 1 Math.Since it's 4 as default. Also Hackfix, we shouldn't reduce it by 1 if the target has the aura already. + byte stackAmount = (byte)(target.HasAura(SpellIds.PrayerOfMendingAura, caster.GetGUID()) ? GetEffectValue() : GetEffectValue() + 1); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); - args.AddSpellMod(SpellValueMod.AuraStack, GetEffectValue()); - args.AddSpellMod(SpellValueMod.BasePoint0, (int)basePoints); + args.AddSpellMod(SpellValueMod.AuraStack, stackAmount); + + // Note: this line's purpose is to show the correct amount in Points field in SmsgAuraUpdate. + int basePoints = caster.SpellHealingBonusDone(target, _spellInfoHeal, _healEffectDummy.CalcValue(caster), DamageEffectType.Heal, _healEffectDummy); + args.AddSpellMod(SpellValueMod.BasePoint0, basePoints); + + // Note: Focused Mending talent. args.SetCustomArg(true); - GetCaster().CastSpell(GetHitUnit(), SpellIds.PrayerOfMendingAura, args); + + caster.CastSpell(target, SpellIds.PrayerOfMendingAura, args); + + // Note: the visualSender is the priest if it is first cast or the aura holder when the aura triggers. + caster.SendPlaySpellVisual(target, SpellIds.VisualPriestPrayerOfMending, 0, 0, 40.0f); + + // Note: Epiphany talent. + if (caster.HasAura(SpellIds.Epiphany)) + caster.RemoveAurasDueToSpell(SpellIds.EpiphanyHighlight); } public override void Register() { - if (m_scriptSpellId == SpellIds.Holy101ClassSet2pChooser) - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaEntry)); - OnEffectHitTarget.Add(new EffectHandler(HandleEffectDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleEffectDummy, 0, SpellEffectName.Dummy)); } } @@ -1219,13 +1921,15 @@ namespace Scripts.Spells.Priest public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.PrayerOfMendingHeal, SpellIds.PrayerOfMendingJump, SpellIds.SayYourPrayers) && ValidateSpellEffect(SpellIds.SayYourPrayers, 0); + return ValidateSpellInfo(SpellIds.PrayerOfMendingHeal, SpellIds.PrayerOfMendingJump) + && ValidateSpellEffect((SpellIds.SayYourPrayers, 0)); } void HandleHeal(AuraEffect aurEff, ProcEventInfo eventInfo) { // Note: caster is the priest who cast the spell and target is current holder of the aura. Unit target = GetTarget(); + Unit caster = GetCaster(); if (caster != null) { @@ -1255,15 +1959,15 @@ namespace Scripts.Spells.Priest } } + public override void Register() + { + OnEffectProc.Add(new(HandleHeal, 0, AuraType.Dummy)); + } + public void SetEmpoweredByFocusedMending(bool isEmpowered) { _isEmpoweredByFocusedMending = isEmpowered; } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleHeal, 0, AuraType.Dummy)); - } } [Script] @@ -1275,7 +1979,7 @@ namespace Scripts.Spells.Priest if (aura == null) return; - spell_pri_prayer_of_mending_AuraScript script = aura.GetScript(); + var script = aura.GetScript(); if (script == null) return; @@ -1286,11 +1990,11 @@ namespace Scripts.Spells.Priest public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleEffectDummy, 0, SpellEffectName.ApplyAura)); + OnEffectHitTarget.Add(new(HandleEffectDummy, 0, SpellEffectName.ApplyAura)); } } - - [Script] // 155793 - prayer of mending (Jump) - SPELL_PRIEST_PRAYER_OF_MENDING_JUMP + + [Script] // 155793 - Prayer of Mending (Jump) class spell_pri_prayer_of_mending_jump : SpellScript { SpellInfo _spellInfoHeal; @@ -1299,12 +2003,12 @@ namespace Scripts.Spells.Priest public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.PrayerOfMendingHeal, SpellIds.PrayerOfMendingAura) - && Global.SpellMgr.GetSpellInfo(SpellIds.PrayerOfMendingHeal, Difficulty.None).GetEffect(0) != null; + && ValidateSpellEffect((SpellIds.PrayerOfMendingHeal, 0)); } public override bool Load() { - _spellInfoHeal = Global.SpellMgr.GetSpellInfo(SpellIds.PrayerOfMendingHeal, Difficulty.None); + _spellInfoHeal = SpellMgr.GetSpellInfo(SpellIds.PrayerOfMendingHeal, Difficulty.None); _healEffectDummy = _spellInfoHeal.GetEffect(0); return true; } @@ -1318,94 +2022,160 @@ namespace Scripts.Spells.Priest void HandleJump(uint effIndex) { Unit origCaster = GetOriginalCaster(); - Unit target = GetHitUnit(); - if (origCaster != null) { - uint basePoints = (uint)origCaster.SpellHealingBonusDone(target, _spellInfoHeal, _healEffectDummy.CalcValue(origCaster), DamageEffectType.Heal, _healEffectDummy); CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); - args.AddSpellMod(SpellValueMod.AuraStack, GetEffectValue()); - args.AddSpellMod(SpellValueMod.BasePoint0, (int)basePoints); + args.AddSpellMod(SpellValueMod.AuraStack, (byte)GetEffectValue()); + + // Note: this line's purpose is to show the correct amount in Points field in SmsgAuraUpdate. + int basePoints = origCaster.SpellHealingBonusDone(GetHitUnit(), _spellInfoHeal, _healEffectDummy.CalcValue(origCaster), DamageEffectType.Heal, _healEffectDummy); + args.AddSpellMod(SpellValueMod.BasePoint0, basePoints); + + // Note: Focused Mending talent. args.SetCustomArg(false); - origCaster.CastSpell(target, SpellIds.PrayerOfMendingAura, args); + + origCaster.CastSpell(GetHitUnit(), SpellIds.PrayerOfMendingAura, args); + + // Note: the visualSender is the priest if it is first cast or the aura holder when the aura triggers. + GetCaster().SendPlaySpellVisual(GetHitUnit(), SpellIds.VisualPriestPrayerOfMending, 0, 0, 40.0f); } } public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaAlly)); - OnEffectHitTarget.Add(new EffectHandler(HandleJump, 0, SpellEffectName.Dummy)); - } - } - - // 33110 - Prayer of Mending (Heal) - class spell_pri_prayer_of_mending_heal : SpellScript - { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Renew, SpellIds.PrayerOfMendingAura) && ValidateSpellEffect((SpellIds.Benediction, 0), (SpellIds.FocusedMending, 0), (SpellIds.DivineService, 0)); - } - - void HandleEffectHitTarget(uint effIndex) - { - Unit caster = GetCaster(); - Unit target = GetHitUnit(); - - AuraEffect benediction = caster.GetAuraEffect(SpellIds.Benediction, 0); - if (benediction != null) - if (RandomHelper.randChance(benediction.GetAmount())) - caster.CastSpell(target, SpellIds.Renew, new CastSpellExtraArgs(TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreCastInProgress)); - - float healBonus = 1.0f; - - AuraEffect focusedMending = caster.GetAuraEffect(SpellIds.FocusedMending, 0); - if (focusedMending != null) - { - bool isEmpoweredByFocusedMending = (bool)GetSpell().m_customArg; - - if (isEmpoweredByFocusedMending && isEmpoweredByFocusedMending) - MathFunctions.AddPct(ref healBonus, focusedMending.GetAmount()); - } - - AuraEffect divineService = caster.GetAuraEffect(SpellIds.DivineService, 0); - if (divineService != null) - { - Aura prayerOfMending = target.GetAura(SpellIds.PrayerOfMendingAura, caster.GetGUID()); - if (prayerOfMending != null) - MathFunctions.AddPct(ref healBonus, (int)(divineService.GetAmount() * prayerOfMending.GetStackAmount())); - } - - SetHitHeal((int)(GetHitHeal() * healBonus)); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleEffectHitTarget, 0, SpellEffectName.Heal)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitSrcAreaAlly)); + OnEffectHitTarget.Add(new(HandleJump, 0, SpellEffectName.Dummy)); } } [Script] // 405554 - Priest Holy 10.1 Class Set 2pc class spell_pri_holy_10_1_class_set_2pc : AuraScript { - bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo) + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.Holy101ClassSet2PChooser) + && ValidateSpellEffect((SpellIds.PrayerOfMending, 0)); + } + + static bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo) { return RandomHelper.randChance(aurEff.GetAmount()); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - GetTarget().CastSpell(GetTarget(), SpellIds.Holy101ClassSet2pChooser, - new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress | TriggerCastFlags.IgnoreSpellAndCategoryCD) - .SetTriggeringSpell(eventInfo.GetProcSpell())); + CastSpellExtraArgs args = new(aurEff); + args.SetTriggeringSpell(eventInfo.GetProcSpell()); + args.AddSpellMod(SpellValueMod.BasePoint0, SpellMgr.GetSpellInfo(SpellIds.PrayerOfMending, GetCastDifficulty()).GetEffect(0).CalcValue(GetCaster())); + + GetTarget().CastSpell(GetTarget(), SpellIds.Holy101ClassSet2PChooser, args); } public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckProc, 0, AuraType.Dummy)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } - + + [Script] // 411097 - Priest Holy 10.1 Class Set 2pc (Chooser) + class spell_pri_holy_10_1_class_set_2pc_chooser : SpellScript + { + SpellInfo _spellInfoHeal; + SpellEffectInfo _healEffectDummy; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.PrayerOfMendingAura, SpellIds.PrayerOfMendingHeal, SpellIds.PrayerOfMendingAura) + && ValidateSpellEffect((SpellIds.PrayerOfMendingHeal, 0)); + } + + public override bool Load() + { + _spellInfoHeal = SpellMgr.GetSpellInfo(SpellIds.PrayerOfMendingHeal, Difficulty.None); + _healEffectDummy = _spellInfoHeal.GetEffect(0); + return true; + } + + void FilterTargets(List targets) + { + SelectRandomInjuredTargets(targets, 1, true); + } + + void HandleEffectDummy(uint effIndex) + { + Unit caster = GetCaster(); + Unit target = GetHitUnit(); + + // Note: we need to increase BasePoints by 1 Math.Since it's 4 as default. Also Hackfix, we shouldn't reduce it by 1 if the target has the aura already. + byte stackAmount = (byte)(target.HasAura(SpellIds.PrayerOfMendingAura, caster.GetGUID()) ? GetEffectValue() : GetEffectValue() + 1); + + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.AddSpellMod(SpellValueMod.AuraStack, stackAmount); + + // Note: this line's purpose is to show the correct amount in Points field in SmsgAuraUpdate. + int basePoints = caster.SpellHealingBonusDone(target, _spellInfoHeal, _healEffectDummy.CalcValue(caster), DamageEffectType.Heal, _healEffectDummy); + args.AddSpellMod(SpellValueMod.BasePoint0, basePoints); + + // Note: Focused Mending talent. + args.SetCustomArg(true); + + caster.CastSpell(target, SpellIds.PrayerOfMendingAura, args); + + // Note: the visualSender is the priest if it is first cast or the aura holder when the aura triggers. + caster.SendPlaySpellVisual(target, SpellIds.VisualPriestPrayerOfMending, 0, 0, 40.0f); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitDestAreaEntry)); + OnEffectHitTarget.Add(new(HandleEffectDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] // 155793 - Prayer of Mending (Jump) + class spell_pri_holy_10_1_class_set_4pc : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.Holy101ClassSet4P, SpellIds.Holy101ClassSet4PEffect); + } + + void HandleEffectDummy(uint effIndex) + { + if (GetOriginalCaster().HasAura(SpellIds.Holy101ClassSet4P)) + GetOriginalCaster().CastSpell(GetOriginalCaster(), SpellIds.Holy101ClassSet4PEffect, TriggerCastFlags.IgnoreGCD); + } + + public override void Register() + { + OnEffectHitTarget.Add(new(HandleEffectDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] // 41635 - Prayer of Mending (Aura) + class spell_pri_holy_10_1_class_set_4pc_AuraScript : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.Holy101ClassSet4P, SpellIds.Holy101ClassSet4PEffect); + } + + void HandleOnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire) + return; + + if (GetCaster().HasAura(SpellIds.Holy101ClassSet4P)) + GetCaster().CastSpell(GetCaster(), SpellIds.Holy101ClassSet4PEffect, new CastSpellExtraArgs(TriggerCastFlags.IgnoreGCD).SetTriggeringAura(aurEff)); + } + + public override void Register() + { + OnEffectRemove.Add(new(HandleOnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + } + } + // 204197 - Purge the Wicked [Script] // Called by Penance - 47540, Dark Reprimand - 400169 class spell_pri_purge_the_wicked : SpellScript @@ -1421,12 +2191,12 @@ namespace Scripts.Spells.Priest Unit target = GetHitUnit(); if (target.HasAura(SpellIds.PurgeTheWickedPeriodic, caster.GetGUID())) - caster.CastSpell(target, SpellIds.PurgeTheWickedDummy, new CastSpellExtraArgs(TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreCastInProgress)); + caster.CastSpell(target, SpellIds.PurgeTheWickedDummy, TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreCastInProgress); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -1436,7 +2206,7 @@ namespace Scripts.Spells.Priest public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.PurgeTheWickedPeriodic, SpellIds.RevelInPurity) - && ValidateSpellEffect(SpellIds.RevelInPurity, 1); + && ValidateSpellEffect((SpellIds.RevelInPurity, 1)); } void FilterTargets(List targets) @@ -1446,21 +2216,17 @@ namespace Scripts.Spells.Priest targets.RemoveAll(obj => { - // Note: we must remove any non-unit target, the explicit target and any other target that may be under any crowd control aura. + // Note: we must Remove any non-unit target, the explicit target and any other target that may be under any crowd control aura. Unit target = obj.ToUnit(); - return !target || target == explTarget || target.HasBreakableByDamageCrowdControlAura(); + return target == null || target == explTarget || target.HasBreakableByDamageCrowdControlAura(); }); if (targets.Empty()) return; - // Note: there's no SPELL_EFFECT_DUMMY with BasePoints 1 in any of the spells related to use as reference so we hardcode the value. + // Note: there's no SpellEffectDummy with BasePoints 1 in any of the spells related to use as reference so we hardcode the value. uint spreadCount = 1; - // Less than zero –x is less than y. - // Zero –x equals y. - // Greater than zero –x is greater than y. - // Note: we must sort our list of targets whose priority is 1) aura, 2) distance, and 3) duration. targets.Sort((lhs, rhs) => { @@ -1484,7 +2250,7 @@ namespace Scripts.Spells.Priest // Note: Revel in Purity talent. if (caster.HasAura(SpellIds.RevelInPurity)) - spreadCount += (uint)Global.SpellMgr.GetSpellInfo(SpellIds.RevelInPurity, Difficulty.None)?.GetEffect(1).CalcValue(GetCaster()); + spreadCount += (uint)SpellMgr.GetSpellInfo(SpellIds.RevelInPurity, Difficulty.None).GetEffect(1).CalcValue(GetCaster()); if (targets.Count > spreadCount) targets.Resize(spreadCount); @@ -1495,16 +2261,16 @@ namespace Scripts.Spells.Priest Unit caster = GetCaster(); Unit target = GetHitUnit(); - caster.CastSpell(target, SpellIds.PurgeTheWickedPeriodic, new CastSpellExtraArgs(TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreCastInProgress)); + caster.CastSpell(target, SpellIds.PurgeTheWickedPeriodic, TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreCastInProgress); } public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitDestAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 1, SpellEffectName.Dummy)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 1, Targets.UnitDestAreaEnemy)); + OnEffectHitTarget.Add(new(HandleDummy, 1, SpellEffectName.Dummy)); } } - + [Script] // 47536 - Rapture class spell_pri_rapture : SpellScript { @@ -1523,20 +2289,23 @@ namespace Scripts.Spells.Priest void HandleAfterCast() { Unit caster = GetCaster(); - Unit target = Global.ObjAccessor.GetUnit(caster, _raptureTarget); + + Unit target = ObjAccessor.GetUnit(caster, _raptureTarget); if (target != null) - caster.CastSpell(target, SpellIds.PowerWordShield, new CastSpellExtraArgs(TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnorePowerAndReagentCost | TriggerCastFlags.IgnoreCastInProgress).SetTriggeringSpell(GetSpell())); + caster.CastSpell(target, SpellIds.PowerWordShield, + new CastSpellExtraArgs(TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnorePowerAndReagentCost | TriggerCastFlags.IgnoreCastInProgress) + .SetTriggeringSpell(GetSpell())); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleEffectDummy, 0, SpellEffectName.Dummy)); - AfterCast.Add(new CastHandler(HandleAfterCast)); + OnEffectHitTarget.Add(new(HandleEffectDummy, 0, SpellEffectName.Dummy)); + AfterCast.Add(new(HandleAfterCast)); } } - [Script] // 280391 - Sins of the Many - class spell_pri_sins_of_the_many : AuraScript + [Script] // 280391 - Math.Sins of the Many + class spell_pri_Sins_of_the_many : AuraScript { public override bool Validate(SpellInfo spellInfo) { @@ -1555,11 +2324,11 @@ namespace Scripts.Spells.Priest public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(HandleOnApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(HandleOnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(HandleOnApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(HandleOnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } - + [Script] // 20711 - Spirit of Redemption class spell_pri_spirit_of_redemption : AuraScript { @@ -1571,13 +2340,42 @@ namespace Scripts.Spells.Priest void HandleAbsorb(AuraEffect aurEff, DamageInfo dmgInfo, ref uint absorbAmount) { Unit target = GetTarget(); - target.CastSpell(target, SpellIds.SpiritOfRedemption, new CastSpellExtraArgs(aurEff)); + target.CastSpell(target, SpellIds.SpiritOfRedemption, aurEff); target.SetFullHealth(); } public override void Register() { - OnEffectAbsorb.Add(new EffectAbsorbHandler(HandleAbsorb, 0, true)); + OnEffectAbsorb.Add(new(HandleAbsorb, 0)); + } + } + + [Script] // 314867 - Shadow Covenant + class spell_pri_shadow_covenant : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellEffect((spellInfo.Id, 2)); + } + + void FilterTargets(List targets) + { + // Remove explicit target (will be readded later) + targets.Remove(GetExplTargetWorldObject()); + + // we must Remove one Math.Since explicit target is always added. + uint maxTargets = (uint)GetEffectInfo(2).CalcValue(GetCaster()) - 1; + + SelectRandomInjuredTargets(targets, maxTargets, true); + + Unit explicitTarget = GetExplTargetUnit(); + if (explicitTarget != null) + targets.Add(explicitTarget); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new(FilterTargets, 1, Targets.UnitDestAreaAlly)); } } @@ -1586,7 +2384,7 @@ namespace Scripts.Spells.Priest { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.Atonement, SpellIds.AtonementTriggered, SpellIds.Trinity, SpellIds.MasochismTalent, SpellIds.MasochismPeriodicHeal, SpellIds.ShadowMendPeriodicDummy); + return ValidateSpellInfo(SpellIds.Atonement, SpellIds.AtonementEffect, SpellIds.Trinity, SpellIds.MasochismTalent, SpellIds.MasochismPeriodicHeal, SpellIds.ShadowMendPeriodicDummy); } void HandleEffectHit() @@ -1598,8 +2396,6 @@ namespace Scripts.Spells.Priest int periodicAmount = GetHitHeal() / 20; int damageForAuraRemoveAmount = periodicAmount * 10; - if (caster.HasAura(SpellIds.Atonement) && !caster.HasAura(SpellIds.Trinity)) - caster.CastSpell(target, SpellIds.AtonementTriggered, new CastSpellExtraArgs(GetSpell())); // Handle Masochism talent if (caster.HasAura(SpellIds.MasochismTalent) && caster.GetGUID() == target.GetGUID()) @@ -1617,7 +2413,7 @@ namespace Scripts.Spells.Priest public override void Register() { - AfterHit.Add(new HitHandler(HandleEffectHit)); + AfterHit.Add(new(HandleEffectHit)); } } @@ -1654,12 +2450,12 @@ namespace Scripts.Spells.Priest public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleDummyTick, 0, AuraType.PeriodicDummy)); - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); + OnEffectPeriodic.Add(new(HandleDummyTick, 0, AuraType.PeriodicDummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 1, AuraType.Dummy)); } } - + [Script] // 28809 - Greater Heal class spell_pri_t3_4p_bonus : AuraScript { @@ -1671,12 +2467,12 @@ namespace Scripts.Spells.Priest void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.ArmorOfFaith, new CastSpellExtraArgs(aurEff)); + eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.ArmorOfFaith, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1694,8 +2490,7 @@ namespace Scripts.Spells.Priest if (healInfo != null) { Unit healTarget = healInfo.GetTarget(); - if (healTarget) - // @todo: fix me later if (healInfo.GetEffectiveHeal()) + if (healTarget != null && healInfo.GetEffectiveHeal() != 0) if (healTarget.GetHealth() >= healTarget.GetMaxHealth()) return true; } @@ -1706,13 +2501,13 @@ namespace Scripts.Spells.Priest void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.ItemEfficiency, new CastSpellExtraArgs(aurEff)); + GetTarget().CastSpell(GetTarget(), SpellIds.ItemEfficiency, aurEff); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); } } @@ -1732,8 +2527,10 @@ namespace Scripts.Spells.Priest if (healInfo == null || healInfo.GetHeal() == 0) return; - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.BlessedHealing, GetCastDifficulty()); - int amount = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount()); + SpellInfo spellInfo = SpellMgr.GetSpellInfo(SpellIds.BlessedHealing, GetCastDifficulty()); + int amount = MathFunctions.CalculatePct((int)(healInfo.GetHeal()), aurEff.GetAmount()); + + Cypher.Assert(spellInfo.GetMaxTicks() > 0); amount /= (int)spellInfo.GetMaxTicks(); Unit caster = eventInfo.GetActor(); @@ -1746,7 +2543,62 @@ namespace Scripts.Spells.Priest public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); + } + } + + [Script] // 200128 - Trail of Light + class spell_pri_trail_of_light : AuraScript + { + Queue _healQueue = new(); + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.TrailOfLightHeal); + } + + bool CheckProc(ProcEventInfo eventInfo) + { + if (_healQueue.Count == 0 || _healQueue.Last() != eventInfo.GetActionTarget().GetGUID()) + _healQueue.Enqueue(eventInfo.GetActionTarget().GetGUID()); + + if (_healQueue.Count > 2) + _healQueue.Dequeue(); + + if (_healQueue.Count == 2) + return true; + + return false; + } + + void HandleOnProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + Unit caster = GetTarget(); + Unit oldTarget = ObjAccessor.GetUnit(caster, _healQueue.First()); + if (oldTarget == null) + return; + + // Note: old target may not be friendly anymore due to charm and faction change effects. + if (!caster.IsValidAssistTarget(oldTarget)) + return; + + SpellInfo healSpellInfo = SpellMgr.GetSpellInfo(SpellIds.TrailOfLightHeal, Difficulty.None); + if (healSpellInfo == null) + return; + + // Note: distance may be greater than the heal's spell range. + if (!caster.IsWithinDist(oldTarget, healSpellInfo.GetMaxRange(true, caster))) + return; + + uint healAmount = MathFunctions.CalculatePct(eventInfo.GetHealInfo().GetHeal(), aurEff.GetAmount()); + + caster.CastSpell(oldTarget, SpellIds.TrailOfLightHeal, new CastSpellExtraArgs(aurEff).AddSpellMod(SpellValueMod.BasePoint0, (int)healAmount)); + } + + public override void Register() + { + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleOnProc, 0, AuraType.Dummy)); } } @@ -1761,22 +2613,22 @@ namespace Scripts.Spells.Priest public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckProc, 0, AuraType.ProcTriggerSpell)); + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.ProcTriggerSpell)); } } - - [Script] // 15286 - Vampiric Embrace - class spell_pri_vampiric_embrace : AuraScript + + [Script] // 15286 - Vapiric Embrace + class spell_pri_vapiric_embrace : AuraScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.VampiricEmbraceHeal); + return ValidateSpellInfo(SpellIds.VapiricEmbraceHeal); } bool CheckProc(ProcEventInfo eventInfo) { // Not proc from Mind Sear - return !eventInfo.GetDamageInfo().GetSpellInfo().SpellFamilyFlags[1].HasAnyFlag(0x80000u); + return (eventInfo.GetDamageInfo().GetSpellInfo().SpellFamilyFlags[1] & 0x80000) == 0; } void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -1792,18 +2644,18 @@ namespace Scripts.Spells.Priest CastSpellExtraArgs args = new(aurEff); args.AddSpellMod(SpellValueMod.BasePoint0, teamHeal); args.AddSpellMod(SpellValueMod.BasePoint1, selfHeal); - GetTarget().CastSpell((Unit)null, SpellIds.VampiricEmbraceHeal, args); + GetTarget().CastSpell(null, SpellIds.VapiricEmbraceHeal, args); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.Dummy)); } } - [Script] // 15290 - Vampiric Embrace (heal) - class spell_pri_vampiric_embrace_target : SpellScript + [Script] // 15290 - Vapiric Embrace (heal) + class spell_pri_vapiric_embrace_target : SpellScript { void FilterTargets(List unitList) { @@ -1812,33 +2664,37 @@ namespace Scripts.Spells.Priest public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitCasterAreaParty)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitCasterAreaParty)); } } - [Script] // 34914 - Vampiric Touch - class spell_pri_vampiric_touch : AuraScript + [Script] // 34914 - VaMathF.PIric Touch + class spell_pri_vapiric_touch : AuraScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.VampiricTouchDispel, SpellIds.GenReplenishment); + return ValidateSpellInfo(SpellIds.VapiricTouchDispel, SpellIds.GenReplenishment); } void HandleDispel(DispelInfo dispelInfo) { Unit caster = GetCaster(); - if (caster) + if (caster != null) { Unit target = GetUnitOwner(); - if (target) + if (target != null) { AuraEffect aurEff = GetEffect(1); if (aurEff != null) { // backfire damage + int bp = aurEff.GetAmount(); + bp = target.SpellDamageBonusTaken(caster, aurEff.GetSpellInfo(), bp, DamageEffectType.DOT); + bp *= 8; + CastSpellExtraArgs args = new(aurEff); - args.AddSpellMod(SpellValueMod.BasePoint0, aurEff.GetAmount() * 8); - caster.CastSpell(target, SpellIds.VampiricTouchDispel, args); + args.AddSpellMod(SpellValueMod.BasePoint0, bp); + caster.CastSpell(target, SpellIds.VapiricTouchDispel, args); } } } @@ -1852,14 +2708,14 @@ namespace Scripts.Spells.Priest void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - eventInfo.GetProcTarget().CastSpell((Unit)null, SpellIds.GenReplenishment, new CastSpellExtraArgs(aurEff)); + eventInfo.GetProcTarget().CastSpell(null, SpellIds.GenReplenishment, aurEff); } public override void Register() { - AfterDispel.Add(new AuraDispelHandler(HandleDispel)); - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 2, AuraType.Dummy)); + AfterDispel.Add(new(HandleDispel)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleEffectProc, 2, AuraType.Dummy)); } } } \ No newline at end of file diff --git a/Source/Scripts/Spells/Quest.cs b/Source/Scripts/Spells/Quest.cs index f8aa5a952..9391ed267 100644 --- a/Source/Scripts/Spells/Quest.cs +++ b/Source/Scripts/Spells/Quest.cs @@ -1,413 +1,135 @@ -// Copyright (c) CypherCore All rights reserved. +// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; -using Game; using Game.Entities; using Game.Maps; using Game.Scripting; using Game.Spells; using System; using System.Collections.Generic; +using static Global; -namespace Scripts.Spells.Quest +namespace Scripts.Spells.Azerite { - struct SpellIds + struct GenericQuestUpdateEntryIds { - //Thaumaturgychannel - public const uint ThaumaturgyChannel = 21029; - - //Quest11396-11399 - public const uint ForceShieldArcanePurpleX3 = 43874; - public const uint ScourgingCrystalController = 43878; - - //Quest11730 - public const uint SummonScavengebot004a8 = 46063; - public const uint SummonSentrybot57k = 46068; - public const uint SummonDefendotank66d = 46058; - public const uint SummonScavengebot005b6 = 46066; - public const uint Summon55dCollectatron = 46034; - public const uint RobotKillCredit = 46027; - - //Quest12634 - public const uint BananasFallToGround = 51836; - public const uint OrangeFallsToGround = 51837; - public const uint PapayaFallsToGround = 51839; - public const uint SummonAdventurousDwarf = 52070; - - //Quest12851 - public const uint FrostgiantCredit = 58184; - public const uint FrostworgCredit = 58183; - public const uint Immolation = 54690; - public const uint Ablaze = 54683; - - //Quest12937 - public const uint TriggerAidOfTheEarthen = 55809; - - //Symboloflife - public const uint PermanentFeignDeath = 29266; - - //BattleStandard - public const uint PlantHordeBattleStandard = 59643; - public const uint HordeBattleStandardState = 59642; - public const uint AllianceBattleStandardState = 4339; - public const uint JumpRocketBlast = 4340; - - //BreakfastOfChampions - public const uint SummonDeepJormungar = 66510; - public const uint StormforgedMoleMachine = 66492; - - //Leavenothingtochance - public const uint UpperMineShaftCredit = 48744; - public const uint LowerMineShaftCredit = 48745; - - //Focusonthebeach - public const uint BunnyCreditBeam = 47390; - - //Defendingwyrmresttemple - public const uint SummonWyrmrestDefender = 49207; - - //Quest11010 11102 11023 - public const uint FlakCannonTrigger = 40110; - public const uint ChooseLoc = 40056; - public const uint AggroCheck = 40112; - - //Spellzuldrakrat - public const uint SummonGorgedLurkingBasilisk = 50928; - - //Quenchingmist - public const uint FlickeringFlames = 53504; - - //Quest13291 13292 13239 13261 - public const uint Ride = 59319; - - //Bearflankmaster - public const uint BearFlankMaster = 56565; - public const uint CreateBearFlank = 56566; - public const uint BearFlankFail = 56569; - - //BurstAtTheSeams - public const uint BloatedAbominationFeignDeath = 52593; - public const uint BurstAtTheSeamsBone = 52516; - public const uint ExplodeAbominationMeat = 52520; - public const uint ExplodeAbominationBloodyMeat = 52523; - public const uint TrollExplosion = 52565; - public const uint ExplodeTrollMeat = 52578; - public const uint ExplodeTrollBloodyMeat = 52580; - - public const uint BurstAtTheSeams59576 = 59576; //Script/Knockback; That'S Abominable - public const uint BurstAtTheSeams59579 = 59579; //Dummy - public const uint BurstAtTheSeams52510 = 52510; //Script/Knockback; Fuel For The Fire - public const uint BurstAtTheSeams52508 = 52508; //Damage 20000 - public const uint BurstAtTheSeams59580 = 59580; //Damage 50000 - - public const uint AssignGhoulKillCreditToMaster = 59590; - public const uint AssignGeistKillCreditToMaster = 60041; - public const uint AssignSkeletonKillCreditToMaster = 60039; - - public const uint DrakkariSkullcrusherCredit = 52590; - public const uint SummonDrakkariChieftain = 52616; - public const uint DrakkariChieftainkKillCredit = 52620; - - // Tamingthebeast - public const uint TameIceClawBear = 19548; - public const uint TameLargeCragBoar = 19674; - public const uint TameSnowLeopard = 19687; - public const uint TameAdultPlainstrider = 19688; - public const uint TamePrairieStalker = 19689; - public const uint TameSwoop = 19692; - public const uint TameWebwoodLurker = 19693; - public const uint TameDireMottledBoar = 19694; - public const uint TameSurfCrawler = 19696; - public const uint TameArmoredScorpid = 19697; - public const uint TameNightsaberStalker = 19699; - public const uint TameStrigidScreecher = 19700; - public const uint TameBarbedCrawler = 30646; - public const uint TameGreaterTimberstrider = 30653; - public const uint TameNightstalker = 30654; - public const uint TameCrazedDragonhawk = 30099; - public const uint TameElderSpringpaw = 30102; - public const uint TameMistbat = 30105; - public const uint TameIceClawBear1 = 19597; - public const uint TameLargeCragBoar1 = 19677; - public const uint TameSnowLeopard1 = 19676; - public const uint TameAdultPlainstrider1 = 19678; - public const uint TamePrairieStalker1 = 19679; - public const uint TameSwoop1 = 19680; - public const uint TameWebwoodLurker1 = 19684; - public const uint TameDireMottledBoar1 = 19681; - public const uint TameSurfCrawler1 = 19682; - public const uint TameArmoredScorpid1 = 19683; - public const uint TameNightsaberStalker1 = 19685; - public const uint TameStrigidScreecher1 = 19686; - public const uint TameBarbedCrawler1 = 30647; - public const uint TameGreaterTimberstrider1 = 30648; - public const uint TameNightstalker1 = 30652; - public const uint TameCrazedDragonhawk1 = 30100; - public const uint TameElderSpringpaw1 = 30103; - public const uint TameMistbat1 = 30104; - - //TributeSpells - public const uint GromsTrollTribute = 24101; - public const uint GromsTaurenTribute = 24102; - public const uint GromsUndeadTribute = 24103; - public const uint GromsOrcTribute = 24104; - public const uint GromsBloodelfTribute = 69530; - public const uint UthersHumanTribute = 24105; - public const uint UthersGnomeTribute = 24106; - public const uint UthersDwarfTribute = 24107; - public const uint UthersNightelfTribute = 24108; - public const uint UthersDraeneiTribute = 69533; - - //Escapefromsilverbrook - public const uint SummonWorgen = 48681; - - //Deathcomesfromonhigh - public const uint ForgeCredit = 51974; - public const uint TownHallCredit = 51977; - public const uint ScarletHoldCredit = 51980; - public const uint ChapelCredit = 51982; - - //RecallEyeOfAcherus - public const uint TheEyeOfAcherus = 51852; - - //QuestTheStormKing - public const uint RideGymer = 43671; - public const uint Grabbed = 55424; - - //QuestTheStormKingThrow - public const uint VargulExplosion = 55569; - - //QuestTheHunterAndThePrince - public const uint IllidanKillCredit = 61748; - - //Relicoftheearthenring - public const uint TotemOfTheEarthenRing = 66747; - - //Fumping - public const uint SummonSandGnome = 39240; - public const uint SummonBoneSlicer = 39241; - - //Fearnoevil - public const uint RenewedLife = 93097; - } - - struct CreatureIds - { - //Quest55 + // http://www.wowhead.com/quest=55 Morbent Fel public const uint Morbent = 1200; public const uint WeakenedMorbent = 24782; - //Quests6124 6129 - public const uint SicklyGazelle = 12296; - public const uint CuredGazelle = 12297; - public const uint SicklyDeer = 12298; - public const uint CuredDeer = 12299; - - //Quest10255 + // http://www.wowhead.com/quest=10255 Testing the Antidote public const uint Helboar = 16880; public const uint Dreadtusk = 16992; - //Quest11515 + // http://www.wowhead.com/quest=11515 Blood for Blood public const uint FelbloodInitiate = 24918; public const uint EmaciatedFelblood = 24955; - - //Quest11730 - public const uint Scavengebot004a8 = 25752; - public const uint Sentrybot57k = 25753; - public const uint Defendotank66d = 25758; - public const uint Scavengebot005b6 = 25792; - public const uint Npc55dCollectatron = 25793; - - //Quest12459 - public const uint ReanimatedFrostwyrm = 26841; - public const uint WeakReanimatedFrostwyrm = 27821; - public const uint Turgid = 27808; - public const uint WeakTurgid = 27809; - public const uint Deathgaze = 27122; - public const uint WeakDeathgaze = 27807; - - //Quest12851 - public const uint Frostgiant = 29351; - public const uint Frostworg = 29358; - - //Quest12937 - public const uint FallenEarthenDefender = 30035; - - //Quest12659 - public const uint ScalpsKcBunny = 28622; - - //Salvaginglifesstength - public const uint ShardKillCredit = 29303; - - //Battlestandard - public const uint KingOfTheMountaintKc = 31766; - - //Hodirshelm - public const uint Killcredit = 30210; // Hodir'S Helm Kc Bunny - public const uint IceSpikeBunny = 30215; - - //Leavenothingtochance - public const uint UpperMineShaft = 27436; - public const uint LowerMineShaft = 27437; - - //Quest12372 - public const uint WyrmrestTempleCredit = 27698; - - //Quest11010 11102 11023 - public const uint FelCannon2 = 23082; - - //Quest13291 13292 13239 13261 - public const uint Skytalon = 31583; - public const uint Decoy = 31578; - - //Burstattheseams - public const uint DrakkariChieftaink = 29099; - public const uint IcyGhoul = 31142; - public const uint ViciousGeist = 31147; - public const uint RisenAllianceSoldiers = 31205; - public const uint RenimatedAbomination = 31692; - - //Deathcomesfromonhigh - public const uint NewAvalonForge = 28525; - public const uint NewAvalonTownHall = 28543; - public const uint ScarletHold = 28542; - public const uint ChapelOfTheCrimsonFlame = 28544; - - //Fearnoevil - public const uint InjuredStormwindInfantry = 50047; } - struct Misc - { - //Quests6124 6129 - public static TimeSpan DespawnTime = TimeSpan.FromSeconds(30); - - //HodirsHelm - public const byte Say1 = 1; - public const byte Say2 = 2; - - //Acleansingsong - public const uint AreaIdBittertidelake = 4385; - public const uint AreaIdRiversheart = 4290; - public const uint AreaIdWintergraspriver = 4388; - - //Quest12372 - public const uint WhisperOnHitByForceWhisper = 1; - - //BurstAtTheSeams - public const uint AreaTheBrokenFront = 4507; - public const uint AreaMordRetharTheDeathGate = 4508; - public const uint QuestFuelForTheFire = 12690; - } - - // http://www.wowhead.com/quest=55 Morbent Fel - // 8913 Sacred Cleansing - // http://www.wowhead.com/quest=10255 Testing the Antidote - // 34665 Administer Antidote - // http://www.wowhead.com/quest=11515 Blood for Blood - // 44936 Quest - Fel Siphon Dummy - [Script("spell_q55_sacred_cleansing", SpellEffectName.Dummy, 1u, CreatureIds.Morbent, CreatureIds.WeakenedMorbent, true, 0)] - [Script("spell_q10255_administer_antidote", SpellEffectName.Dummy, 0u, CreatureIds.Helboar, CreatureIds.Dreadtusk, true, 0)] - [Script("spell_q11515_fel_siphon_dummy", SpellEffectName.Dummy, 0u, CreatureIds.FelbloodInitiate, CreatureIds.EmaciatedFelblood, true, 0)] + [Script("spell_q55_sacred_cleansing", SpellEffectName.Dummy, 1u, GenericQuestUpdateEntryIds.Morbent, GenericQuestUpdateEntryIds.WeakenedMorbent, true)] // 8913 - Sacred Cleansing + [Script("spell_q10255_administer_antidote", SpellEffectName.Dummy, 0u, GenericQuestUpdateEntryIds.Helboar, GenericQuestUpdateEntryIds.Dreadtusk, true)] // 34665 - Administer Antidote + [Script("spell_q11515_fel_siphon_dummy", SpellEffectName.Dummy, 0u, GenericQuestUpdateEntryIds.FelbloodInitiate, GenericQuestUpdateEntryIds.EmaciatedFelblood, true)] // 44936 - Quest - Fel Siphon Dummy class spell_generic_quest_update_entry : SpellScript { - public spell_generic_quest_update_entry(SpellEffectName spellEffect, uint effIndex, uint originalEntry, uint newEntry, bool shouldAttack, uint despawnTime) + SpellEffectName _spellEffect; + byte _effIndex; + uint _originalEntry; + uint _newEntry; + bool _shouldAttack; + + public spell_generic_quest_update_entry(SpellEffectName spellEffect, uint effIndex, uint originalEntry, uint newEntry, bool shouldAttack) { _spellEffect = spellEffect; _effIndex = (byte)effIndex; _originalEntry = originalEntry; _newEntry = newEntry; _shouldAttack = shouldAttack; - _despawnTime = despawnTime; } void HandleDummy(uint effIndex) { Creature creatureTarget = GetHitCreature(); - if (creatureTarget) + if (creatureTarget != null) { if (!creatureTarget.IsPet() && creatureTarget.GetEntry() == _originalEntry) { creatureTarget.UpdateEntry(_newEntry); if (_shouldAttack) creatureTarget.EngageWithTarget(GetCaster()); - - if (_despawnTime != 0) - creatureTarget.DespawnOrUnsummon(TimeSpan.FromMilliseconds(_despawnTime)); } } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, _effIndex, _spellEffect)); + OnEffectHitTarget.Add(new(HandleDummy, _effIndex, _spellEffect)); } - - SpellEffectName _spellEffect; - byte _effIndex; - uint _originalEntry; - uint _newEntry; - bool _shouldAttack; - uint _despawnTime; } - + [Script] // 9712 - Thaumaturgy Channel class spell_q2203_thaumaturgy_channel : AuraScript { + const uint SpellThaumaturgyChannel = 21029; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.ThaumaturgyChannel); + return ValidateSpellInfo(SpellThaumaturgyChannel); } void HandleEffectPeriodic(AuraEffect aurEff) { PreventDefaultAction(); Unit caster = GetCaster(); - if (caster) - caster.CastSpell(caster, SpellIds.ThaumaturgyChannel, false); + if (caster != null) + caster.CastSpell(caster, SpellThaumaturgyChannel, false); } public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicTriggerSpell)); + OnEffectPeriodic.Add(new(HandleEffectPeriodic, 0, AuraType.PeriodicTriggerSpell)); } } - // http://www.wowhead.com/quest=6124 Curing the Sick (A) - // http://www.wowhead.com/quest=6129 Curing the Sick (H) - [Script] // 19512 Apply Salve + [Script] // 19512 - Apply Salve class spell_q6124_6129_apply_salve : SpellScript { + const uint NpcSicklyGazelle = 12296; + const uint NpcCuredGazelle = 12297; + const uint NpcSicklyDeer = 12298; + const uint NpcCuredDeer = 12299; + + TimeSpan Quest6124_6129_DESPAWN_TIME = TimeSpan.FromSeconds(30); + public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } void HandleDummy(uint effIndex) { Player caster = GetCaster().ToPlayer(); - if (GetCastItem()) + if (GetCastItem() != null) { Creature creatureTarget = GetHitCreature(); - if (creatureTarget) + if (creatureTarget != null) { uint newEntry = 0; switch (caster.GetTeam()) { case Team.Horde: - if (creatureTarget.GetEntry() == CreatureIds.SicklyGazelle) - newEntry = CreatureIds.CuredGazelle; + if (creatureTarget.GetEntry() == NpcSicklyGazelle) + newEntry = NpcCuredGazelle; break; case Team.Alliance: - if (creatureTarget.GetEntry() == CreatureIds.SicklyDeer) - newEntry = CreatureIds.CuredDeer; + if (creatureTarget.GetEntry() == NpcSicklyDeer) + newEntry = NpcCuredDeer; break; } if (newEntry != 0) { creatureTarget.UpdateEntry(newEntry); - creatureTarget.DespawnOrUnsummon(Misc.DespawnTime); + creatureTarget.DespawnOrUnsummon(Quest6124_6129_DESPAWN_TIME); caster.KilledMonsterCredit(newEntry); } } @@ -416,11 +138,10 @@ namespace Scripts.Spells.Quest public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } - [Script] // 43874 - Scourge Mur'gul Camp: Force Shield Arcane Purple x3 class spell_q11396_11399_force_shield_arcane_purple_x3 : AuraScript { @@ -438,135 +159,150 @@ namespace Scripts.Spells.Quest public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(HandleEffectRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } [Script] // 50133 - Scourging Crystal Controller class spell_q11396_11399_scourging_crystal_controller : SpellScript { + const uint SpellForceShieldArcanePurpleX3 = 43874; + const uint SpellScourgingCrystalController = 43878; + public override bool Validate(SpellInfo spellEntry) { - return ValidateSpellInfo(SpellIds.ForceShieldArcanePurpleX3, SpellIds.ScourgingCrystalController); + return ValidateSpellInfo(SpellForceShieldArcanePurpleX3, SpellScourgingCrystalController); } void HandleDummy(uint effIndex) { Unit target = GetHitUnit(); - if (target) - if (target.IsTypeId(TypeId.Unit) && target.HasAura(SpellIds.ForceShieldArcanePurpleX3)) + if (target != null) + if (target.GetTypeId() == TypeId.Unit && target.HasAura(SpellForceShieldArcanePurpleX3)) // Make sure nobody else is channeling the same target - if (!target.HasAura(SpellIds.ScourgingCrystalController)) - GetCaster().CastSpell(target, SpellIds.ScourgingCrystalController, new CastSpellExtraArgs(GetCastItem())); + if (!target.HasAura(SpellScourgingCrystalController)) + GetCaster().CastSpell(target, SpellScourgingCrystalController, GetCastItem()); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 43882 - Scourging Crystal Controller Dummy class spell_q11396_11399_scourging_crystal_controller_dummy : SpellScript { + const uint SpellForceShieldArcanePurpleX3 = 43874; + public override bool Validate(SpellInfo spellEntry) { - return ValidateSpellInfo(SpellIds.ForceShieldArcanePurpleX3); + return ValidateSpellInfo(SpellForceShieldArcanePurpleX3); } void HandleDummy(uint effIndex) { Unit target = GetHitUnit(); - if (target) - if (target.IsTypeId(TypeId.Unit)) - target.RemoveAurasDueToSpell(SpellIds.ForceShieldArcanePurpleX3); + if (target != null) + if (target.GetTypeId() == TypeId.Unit) + target.RemoveAurasDueToSpell(SpellForceShieldArcanePurpleX3); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } - // http://www.wowhead.com/quest=11730 Master and Servant - [Script] // 46023 The Ultrasonic Screwdriver + [Script] // 46023 - The Ultrasonic Screwdriver class spell_q11730_ultrasonic_screwdriver : SpellScript { + const uint SpellSummonScavengebot004A8 = 46063; + const uint SpellSummonSentrybot57K = 46068; + const uint SpellSummonDefendotank66D = 46058; + const uint SpellSummonScavengebot005B6 = 46066; + const uint SpellSummon55DCollectatron = 46034; + const uint SpellRobotKillCredit = 46027; + const uint NpcScavengebot004A8 = 25752; + const uint NpcSentrybot57K = 25753; + const uint NpcDefendotank66D = 25758; + const uint NpcScavengebot005B6 = 25792; + const uint Npc55DCollectatron = 25793; + public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player) && GetCastItem(); + return GetCaster().IsPlayer() && GetCastItem() != null; } public override bool Validate(SpellInfo spellEntry) { - return ValidateSpellInfo(SpellIds.SummonScavengebot004a8, SpellIds.SummonSentrybot57k, SpellIds.SummonDefendotank66d, - SpellIds.SummonScavengebot005b6, SpellIds.Summon55dCollectatron, SpellIds.RobotKillCredit); + return ValidateSpellInfo(SpellSummonScavengebot004A8, + SpellSummonSentrybot57K, + SpellSummonDefendotank66D, + SpellSummonScavengebot005B6, + SpellSummon55DCollectatron, + SpellRobotKillCredit + ); } void HandleDummy(uint effIndex) { Item castItem = GetCastItem(); Unit caster = GetCaster(); - Creature target = GetHitCreature(); - if (target) + if (target != null) { - uint spellId; - switch (target.GetEntry()) + uint spellId = target.GetEntry() switch { - case CreatureIds.Scavengebot004a8: - spellId = SpellIds.SummonScavengebot004a8; - break; - case CreatureIds.Sentrybot57k: - spellId = SpellIds.SummonSentrybot57k; - break; - case CreatureIds.Defendotank66d: - spellId = SpellIds.SummonDefendotank66d; - break; - case CreatureIds.Scavengebot005b6: - spellId = SpellIds.SummonScavengebot005b6; - break; - case CreatureIds.Npc55dCollectatron: - spellId = SpellIds.Summon55dCollectatron; - break; - default: - return; - } - caster.CastSpell(caster, spellId, new CastSpellExtraArgs(castItem)); - caster.CastSpell(caster, SpellIds.RobotKillCredit, true); + NpcScavengebot004A8 => SpellSummonScavengebot004A8, + NpcSentrybot57K => SpellSummonSentrybot57K, + NpcDefendotank66D => SpellSummonDefendotank66D, + NpcScavengebot005B6 => SpellSummonScavengebot005B6, + Npc55DCollectatron => SpellSummon55DCollectatron, + _ => 0 + }; + + if (spellId == 0) + return; + + caster.CastSpell(caster, spellId, castItem); + caster.CastSpell(caster, SpellRobotKillCredit, true); target.DespawnOrUnsummon(); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } - // http://www.wowhead.com/quest=12459 That Which Creates Can Also Destroy - [Script] // 49587 Seeds of Nature's Wrath + [Script] // 49587 - Seeds of Nature's Wrath class spell_q12459_seeds_of_natures_wrath : SpellScript { + const uint NpcReanimatedFrostwyrm = 26841; + const uint NpcWeakReanimatedFrostwyrm = 27821; + + const uint NpcTurgid = 27808; + const uint NpcWeakTurgid = 27809; + + const uint NpcDeathgaze = 27122; + const uint NpcWeakDeathgaze = 27807; + void HandleDummy(uint effIndex) { Creature creatureTarget = GetHitCreature(); - if (creatureTarget) + if (creatureTarget != null) { - uint uiNewEntry = 0; - switch (creatureTarget.GetEntry()) + uint uiNewEntry = creatureTarget.GetEntry() switch { - case CreatureIds.ReanimatedFrostwyrm: - uiNewEntry = CreatureIds.WeakReanimatedFrostwyrm; - break; - case CreatureIds.Turgid: - uiNewEntry = CreatureIds.WeakTurgid; - break; - case CreatureIds.Deathgaze: - uiNewEntry = CreatureIds.WeakDeathgaze; - break; - } + NpcReanimatedFrostwyrm => NpcWeakReanimatedFrostwyrm, + NpcTurgid => NpcWeakTurgid, + NpcDeathgaze => NpcWeakDeathgaze, + _ => 0 + }; + if (uiNewEntry != 0) creatureTarget.UpdateEntry(uiNewEntry); } @@ -574,70 +310,85 @@ namespace Scripts.Spells.Quest public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } - // http://www.wowhead.com/quest=12634 Some Make Lemonade, Some Make Liquor - [Script] // 51840 Despawn Fruit Tosser + [Script] // 51840 - Despawn Fruit Tosser class spell_q12634_despawn_fruit_tosser : SpellScript { + const uint SpellBananasFallToGround = 51836; + const uint SpellOrangeFallsToGround = 51837; + const uint SpellPapayaFallsToGround = 51839; + const uint SpellSummonAdventurousDwarf = 52070; + public override bool Validate(SpellInfo spellEntry) { - return ValidateSpellInfo(SpellIds.BananasFallToGround, SpellIds.OrangeFallsToGround, SpellIds.PapayaFallsToGround, SpellIds.SummonAdventurousDwarf); + return ValidateSpellInfo(SpellBananasFallToGround, + SpellOrangeFallsToGround, + SpellPapayaFallsToGround, + SpellSummonAdventurousDwarf + ); } void HandleDummy(uint effIndex) { - uint spellId = SpellIds.BananasFallToGround; + uint spellId = SpellBananasFallToGround; switch (RandomHelper.URand(0, 3)) { case 1: - spellId = SpellIds.OrangeFallsToGround; + spellId = SpellOrangeFallsToGround; break; case 2: - spellId = SpellIds.PapayaFallsToGround; + spellId = SpellPapayaFallsToGround; break; } // sometimes, if you're lucky, you get a dwarf if (RandomHelper.randChance(5)) - spellId = SpellIds.SummonAdventurousDwarf; + spellId = SpellSummonAdventurousDwarf; GetCaster().CastSpell(GetCaster(), spellId, true); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } - // http://www.wowhead.com/quest=12851 Going Bearback - [Script] // 54798 FLAMING Arrow Triggered Effect + [Script] // 54798 - Flaming Arrow Triggered Effect class spell_q12851_going_bearback : AuraScript { + const uint NpcFrostgiant = 29351; + const uint NpcFrostworg = 29358; + const uint SpellFrostgiantCredit = 58184; + const uint SpellFrostworgCredit = 58183; + const uint SpellImmolation = 54690; + const uint SpellAblaze = 54683; + void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode) { Unit caster = GetCaster(); - if (caster) + if (caster != null) { Unit target = GetTarget(); // Already in fire - if (target.HasAura(SpellIds.Ablaze)) + if (target.HasAura(SpellAblaze)) return; + Player player = caster.GetCharmerOrOwnerPlayerOrPlayerItself(); - if (player) + if (player != null) { switch (target.GetEntry()) { - case CreatureIds.Frostworg: - target.CastSpell(player, SpellIds.FrostworgCredit, true); - target.CastSpell(target, SpellIds.Immolation, true); - target.CastSpell(target, SpellIds.Ablaze, true); + case NpcFrostworg: + target.CastSpell(player, SpellFrostworgCredit, true); + target.CastSpell(target, SpellImmolation, true); + target.CastSpell(target, SpellAblaze, true); break; - case CreatureIds.Frostgiant: - target.CastSpell(player, SpellIds.FrostgiantCredit, true); - target.CastSpell(target, SpellIds.Immolation, true); - target.CastSpell(target, SpellIds.Ablaze, true); + case NpcFrostgiant: + target.CastSpell(player, SpellFrostgiantCredit, true); + target.CastSpell(target, SpellImmolation, true); + target.CastSpell(target, SpellAblaze, true); break; } } @@ -646,53 +397,54 @@ namespace Scripts.Spells.Quest public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); + AfterEffectApply.Add(new(HandleEffectApply, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); } } - // http://www.wowhead.com/quest=12659 Scalps! - [Script] // 52090 Ahunae's Knife + [Script] // 52090 - Ahunae's Knife class spell_q12659_ahunaes_knife : SpellScript { + const uint NpcScalpsKcBunny = 28622; + public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } void HandleDummy(uint effIndex) { Player caster = GetCaster().ToPlayer(); - Creature target = GetHitCreature(); - if (target) + if (target != null) { target.DespawnOrUnsummon(); - caster.KilledMonsterCredit(CreatureIds.ScalpsKcBunny); + caster.KilledMonsterCredit(NpcScalpsKcBunny); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 54190 - Lifeblood Dummy class spell_q12805_lifeblood_dummy : SpellScript { + const uint NpcShardKillCredit = 29303; + public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } void HandleScript(uint effIndex) { Player caster = GetCaster().ToPlayer(); - Creature target = GetHitCreature(); - if (target) + if (target != null) { - caster.KilledMonsterCredit(CreatureIds.ShardKillCredit); + caster.KilledMonsterCredit(NpcShardKillCredit); target.CastSpell(target, (uint)GetEffectValue(), true); target.DespawnOrUnsummon(TimeSpan.FromSeconds(2)); } @@ -700,34 +452,35 @@ namespace Scripts.Spells.Quest public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } - /* - http://www.wowhead.com/quest=13283 King of the Mountain - http://www.wowhead.com/quest=13280 King of the Mountain - */ - // 59643 Plant Horde Battle Standard - [Script] // 4338 Plant Alliance Battle Standard + // 4338 - Plant Alliance Battle Standard + [Script] // 59643 - Plant Horde Battle Standard class spell_q13280_13283_plant_battle_standard : SpellScript { + const uint NpcKingOfTheMountaintKc = 31766; + const uint SpellPlantHordeBattleStandard = 59643; + const uint SpellHordeBattleStandardState = 59642; + const uint SpellAllianceBattleStandardState = 4339; + void HandleDummy(uint effIndex) { Unit caster = GetCaster(); Unit target = GetHitUnit(); - uint triggeredSpellID = SpellIds.AllianceBattleStandardState; + uint triggeredSpellID = SpellAllianceBattleStandardState; caster.HandleEmoteCommand(Emote.OneshotRoar); if (caster.IsVehicle()) { Unit player = caster.GetVehicleKit().GetPassenger(0); - if (player) - player.ToPlayer().KilledMonsterCredit(CreatureIds.KingOfTheMountaintKc); + if (player != null) + player.ToPlayer().KilledMonsterCredit(NpcKingOfTheMountaintKc); } - if (GetSpellInfo().Id == SpellIds.PlantHordeBattleStandard) - triggeredSpellID = SpellIds.HordeBattleStandardState; + if (GetSpellInfo().Id == SpellPlantHordeBattleStandard) + triggeredSpellID = SpellHordeBattleStandardState; target.RemoveAllAuras(); target.CastSpell(target, triggeredSpellID, true); @@ -735,13 +488,15 @@ namespace Scripts.Spells.Quest public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 4336 - Jump Jets class spell_q13280_13283_jump_jets : SpellScript { + const uint SpellJumpRocketBlast = 4340; + void HandleCast() { Unit caster = GetCaster(); @@ -749,80 +504,71 @@ namespace Scripts.Spells.Quest { Unit rocketBunny = caster.GetVehicleKit().GetPassenger(1); if (rocketBunny != null) - rocketBunny.CastSpell(rocketBunny, SpellIds.JumpRocketBlast, true); + rocketBunny.CastSpell(rocketBunny, SpellJumpRocketBlast, true); } } public override void Register() { - OnCast.Add(new CastHandler(HandleCast)); - } - } - - [Script] - class spell_q12279_cast_net : SpellScript - { - void HandleActiveObject(uint effIndex) - { - GetHitGObj().SetLootState(LootState.JustDeactivated); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleActiveObject, 1, SpellEffectName.ActivateObject)); + OnCast.Add(new(HandleCast)); } } [Script] // 50546 - The Focus on the Beach: Ley Line Focus Control Ring Effect class spell_q12066_bunny_kill_credit : SpellScript { + const uint SpellBunnyCreditBeam = 47390; + void HandleDummy(uint effIndex) { Creature target = GetHitCreature(); - if (target) - target.CastSpell(GetCaster(), SpellIds.BunnyCreditBeam, false); + if (target != null) + target.CastSpell(GetCaster(), SpellBunnyCreditBeam, false); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 49213 - Defending Wyrmrest Temple: Character Script Cast From Gossip class spell_q12372_cast_from_gossip_trigger : SpellScript { + const uint SpellSummonWyrmrestDefender = 49207; + void HandleScript(uint effIndex) { - GetCaster().CastSpell(GetCaster(), SpellIds.SummonWyrmrestDefender, true); + GetCaster().CastSpell(GetCaster(), SpellSummonWyrmrestDefender, true); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } - // http://www.wowhead.com/quest=12372 Defending Wyrmrest Temple [Script] // 49370 - Wyrmrest Defender: Destabilize Azure Dragonshrine Effect class spell_q12372_destabilize_azure_dragonshrine_dummy : SpellScript { + const uint NpcWyrmrestTempleCredit = 27698; + void HandleDummy(uint effIndex) { - if (GetHitCreature()) + if (GetHitCreature() != null) { Unit caster = GetOriginalCaster(); - if (caster) + if (caster != null) { Vehicle vehicle = caster.GetVehicleKit(); - if (vehicle) + if (vehicle != null) { Unit passenger = vehicle.GetPassenger(0); - if (passenger) + if (passenger != null) { Player player = passenger.ToPlayer(); - if (player) - player.KilledMonsterCredit(CreatureIds.WyrmrestTempleCredit); + if (player != null) + player.KilledMonsterCredit(NpcWyrmrestTempleCredit); } } } @@ -831,65 +577,73 @@ namespace Scripts.Spells.Quest public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } - [Script] // 40113 Knockdown Fel Cannon: The Aggro Check Aura - class spell_q11010_q11102_q11023_aggro_check_aura : AuraScript + [Script] // 40113 - Knockdown Fel Cannon: The Aggro Check Aura + class spell_q11010_q11102_q11023_aggro_check_AuraScript : AuraScript { + const uint SpellAggroCheck = 40112; + void HandleTriggerSpell(AuraEffect aurEff) { Unit target = GetTarget(); - if (target) + if (target != null) // On trigger proccing - target.CastSpell(target, SpellIds.AggroCheck); + target.CastSpell(target, SpellAggroCheck); } public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleTriggerSpell, 0, AuraType.PeriodicTriggerSpell)); + OnEffectPeriodic.Add(new(HandleTriggerSpell, 0, AuraType.PeriodicTriggerSpell)); } } - [Script] // 40112 Knockdown Fel Cannon: The Aggro Check + [Script] // 40112 - Knockdown Fel Cannon: The Aggro Check class spell_q11010_q11102_q11023_aggro_check : SpellScript { + const uint SpellFlakCannonTrigger = 40110; + void HandleDummy(uint effIndex) { Player playerTarget = GetHitPlayer(); - if (playerTarget) + if (playerTarget != null) // Check if found player target is on fly mount or using flying form if (playerTarget.HasAuraType(AuraType.Fly) || playerTarget.HasAuraType(AuraType.ModIncreaseMountedFlightSpeed)) - playerTarget.CastSpell(playerTarget, SpellIds.FlakCannonTrigger, new CastSpellExtraArgs(TriggerCastFlags.IgnoreCasterMountedOrOnVehicle)); + playerTarget.CastSpell(playerTarget, SpellFlakCannonTrigger, TriggerCastFlags.IgnoreCasterMountedOrOnVehicle); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } - - [Script] // 40119 Knockdown Fel Cannon: The Aggro Burst + + [Script] // 40119 - Knockdown Fel Cannon: The Aggro Burst class spell_q11010_q11102_q11023_aggro_burst : AuraScript { + const uint SpellChooseLoc = 40056; + void HandleEffectPeriodic(AuraEffect aurEff) { Unit target = GetTarget(); - if (target) + if (target != null) // On each tick cast Choose Loc to trigger summon - target.CastSpell(target, SpellIds.ChooseLoc); + target.CastSpell(target, SpellChooseLoc); } public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); } } - - [Script] // 40056 Knockdown Fel Cannon: Choose Loc + + [Script] // 40056 - Knockdown Fel Cannon: Choose Loc class spell_q11010_q11102_q11023_choose_loc : SpellScript { + const uint NpcFelCannon2 = 23082; + void HandleDummy(uint effIndex) { Unit caster = GetCaster(); @@ -898,18 +652,17 @@ namespace Scripts.Spells.Quest AnyPlayerInObjectRangeCheck checker = new(caster, 65.0f); PlayerListSearcher searcher = new(caster, playerList, checker); Cell.VisitWorldObjects(caster, searcher, 65.0f); - foreach (Player player in playerList) - { + + foreach (var player in playerList) // Check if found player target is on fly mount or using flying form if (player.HasAuraType(AuraType.Fly) || player.HasAuraType(AuraType.ModIncreaseMountedFlightSpeed)) // Summom Fel Cannon (bunny version) at found player - caster.SummonCreature(CreatureIds.FelCannon2, player.GetPositionX(), player.GetPositionY(), player.GetPositionZ()); - } + caster.SummonCreature(NpcFelCannon2, player.GetPositionX(), player.GetPositionY(), player.GetPositionZ()); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -928,35 +681,37 @@ namespace Scripts.Spells.Quest public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); + OnCheckCast.Add(new(CheckRequirement)); } } - + [Script] // 50894 - Zul'Drak Rat class spell_q12527_zuldrak_rat : SpellScript { + const uint SpellSummonGorgedLurkingBasilisk = 50928; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.SummonGorgedLurkingBasilisk); + return ValidateSpellInfo(SpellSummonGorgedLurkingBasilisk); } void HandleScriptEffect(uint effIndex) { if (GetHitAura() != null && GetHitAura().GetStackAmount() >= GetSpellInfo().StackAmount) { - GetHitUnit().CastSpell((Unit)null, SpellIds.SummonGorgedLurkingBasilisk, true); + GetHitUnit().CastSpell(null, SpellSummonGorgedLurkingBasilisk, true); Creature basilisk = GetHitUnit().ToCreature(); - if (basilisk) + if (basilisk != null) basilisk.DespawnOrUnsummon(); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); } } - + [Script] // 55368 - Summon Stefan class spell_q12661_q12669_q12676_q12677_q12713_summon_stefan : SpellScript { @@ -969,52 +724,58 @@ namespace Scripts.Spells.Quest public override void Register() { - OnDestinationTargetSelect.Add(new DestinationTargetSelectHandler(SetDest, 0, Targets.DestCasterBack)); + OnDestinationTargetSelect.Add(new(SetDest, 0, Targets.DestCasterBack)); } } [Script] // 53350 - Quenching Mist class spell_q12730_quenching_mist : AuraScript { + const uint SpellFlickeringFlames = 53504; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.FlickeringFlames); + return ValidateSpellInfo(SpellFlickeringFlames); } void HandleEffectPeriodic(AuraEffect aurEff) { - GetTarget().RemoveAurasDueToSpell(SpellIds.FlickeringFlames); + GetTarget().RemoveAurasDueToSpell(SpellFlickeringFlames); } public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicHeal)); + OnEffectPeriodic.Add(new(HandleEffectPeriodic, 0, AuraType.PeriodicHeal)); } } [Script] // 59318 - Grab Fake Soldier class spell_q13291_q13292_q13239_q13261_frostbrood_skytalon_grab_decoy : SpellScript { + const uint NpcSkytalon = 31583; + const uint NpcDecoy = 31578; + const uint SpellRide = 59319; + public override bool Validate(SpellInfo spell) { - return ValidateSpellInfo(SpellIds.Ride); + return ValidateSpellInfo(SpellRide); } void HandleDummy(uint effIndex) { - if (!GetHitCreature()) + if (GetHitCreature() == null) return; - // TO DO: Being triggered is hack, but in checkcast it doesn't pass aurastate requirements. + // To Do: Being triggered is hack, but in checkcast it doesn't pass aurastate requirements. // Beside that the decoy won't keep it's freeze animation state when enter. - GetHitCreature().CastSpell(GetCaster(), SpellIds.Ride, true); + GetHitCreature().CastSpell(GetCaster(), SpellRide, true); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } - + [Script] // 59303 - Summon Frost Wyrm class spell_q13291_q13292_q13239_q13261_armored_decoy_summon_skytalon : SpellScript { @@ -1027,10 +788,10 @@ namespace Scripts.Spells.Quest public override void Register() { - OnDestinationTargetSelect.Add(new DestinationTargetSelectHandler(SetDest, 0, Targets.DestCasterBack)); + OnDestinationTargetSelect.Add(new(SetDest, 0, Targets.DestCasterBack)); } } - + [Script] // 12601 - Second Chances: Summon Landgren's Soul Moveto Target Bunny class spell_q12847_summon_soul_moveto_bunny : SpellScript { @@ -1043,38 +804,76 @@ namespace Scripts.Spells.Quest public override void Register() { - OnDestinationTargetSelect.Add(new DestinationTargetSelectHandler(SetDest, 0, Targets.DestCaster)); + OnDestinationTargetSelect.Add(new(SetDest, 0, Targets.DestCaster)); } } - // 57385 - Argent Cannon + // 57385 - Argent Cannon [Script] // 57412 - Reckoning Bomb class spell_q13086_cannons_target : SpellScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 0) && ValidateSpellInfo((uint)spellInfo.GetEffect(0).CalcValue()); + return ValidateSpellEffect((spellInfo.Id, 0)) + && ValidateSpellInfo((uint)(spellInfo.GetEffect(0).CalcValue())); } void HandleEffectDummy(uint effIndex) { WorldLocation pos = GetExplTargetDest(); if (pos != null) - GetCaster().CastSpell(pos.GetPosition(), (uint)GetEffectValue(), new CastSpellExtraArgs(true)); + GetCaster().CastSpell(pos.GetPosition(), (uint)GetEffectValue(), true); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleEffectDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleEffectDummy, 0, SpellEffectName.Dummy)); } } + struct BurstAtTheSeamsIds + { + public const uint AreaTheBrokenFront = 4507; + public const uint AreaMordRetharTheDeathGate = 4508; + + public const uint NpcDrakkariChieftaink = 29099; + public const uint NpcIcyGhoul = 31142; + public const uint NpcViciousGeist = 31147; + public const uint NpcRisenAllianceSoldiers = 31205; + public const uint NpcRenimatedAbomination = 31692; + + public const uint QuestFuelForTheFire = 12690; + + public const uint SpellBloatedAbominationFeignDeath = 52593; + public const uint SpellBurstAtTheSeamsBone = 52516; + public const uint SpellExplodeAbominationMeat = 52520; + public const uint SpellExplodeAbominationBloodyMeat = 52523; + public const uint SpellTrollExplosion = 52565; + public const uint SpellExplodeTrollMeat = 52578; + public const uint SpellExplodeTrollBloodyMeat = 52580; + + public const uint SpellBurstAtTheSeams59576 = 59576; //script/knockback, That's Abominable + public const uint SpellBurstAtTheSeams59579 = 59579; //dummy + public const uint SpellBurstAtTheSeams52510 = 52510; //script/knockback, Fuel for the Fire + public const uint SpellBurstAtTheSeams52508 = 52508; //damage 20000 + public const uint SpellBurstAtTheSeams59580 = 59580; //damage 50000 + + public const uint SpellAssignGhoulKillCreditToMaster = 59590; + public const uint SpellAssignGeistKillCreditToMaster = 60041; + public const uint SpellAssignSkeletonKillCreditToMaster = 60039; + + public const uint SpellDrakkariSkullcrusherCredit = 52590; + public const uint SpellSummonDrakkariChieftain = 52616; + public const uint SpellDrakkariChieftainkKillCredit = 52620; + } + [Script] // 59576 - Burst at the Seams class spell_q13264_q13276_q13288_q13289_burst_at_the_seams_59576 : SpellScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.BurstAtTheSeams59576, SpellIds.BloatedAbominationFeignDeath, SpellIds.BurstAtTheSeams59579, SpellIds.BurstAtTheSeamsBone, SpellIds.ExplodeAbominationMeat, SpellIds.ExplodeAbominationBloodyMeat); + return ValidateSpellInfo(BurstAtTheSeamsIds.SpellBurstAtTheSeams59576, BurstAtTheSeamsIds.SpellBloatedAbominationFeignDeath, BurstAtTheSeamsIds.SpellBurstAtTheSeams59579, + BurstAtTheSeamsIds.SpellBurstAtTheSeamsBone, BurstAtTheSeamsIds.SpellExplodeAbominationMeat, BurstAtTheSeamsIds.SpellExplodeAbominationBloodyMeat); } void HandleScript(uint effIndex) @@ -1082,21 +881,21 @@ namespace Scripts.Spells.Quest Creature creature = GetCaster().ToCreature(); if (creature != null) { - creature.CastSpell(creature, SpellIds.BloatedAbominationFeignDeath, true); - creature.CastSpell(creature, SpellIds.BurstAtTheSeams59579, true); - creature.CastSpell(creature, SpellIds.BurstAtTheSeamsBone, true); - creature.CastSpell(creature, SpellIds.BurstAtTheSeamsBone, true); - creature.CastSpell(creature, SpellIds.BurstAtTheSeamsBone, true); - creature.CastSpell(creature, SpellIds.ExplodeAbominationMeat, true); - creature.CastSpell(creature, SpellIds.ExplodeAbominationBloodyMeat, true); - creature.CastSpell(creature, SpellIds.ExplodeAbominationBloodyMeat, true); - creature.CastSpell(creature, SpellIds.ExplodeAbominationBloodyMeat, true); + creature.CastSpell(creature, BurstAtTheSeamsIds.SpellBloatedAbominationFeignDeath, true); + creature.CastSpell(creature, BurstAtTheSeamsIds.SpellBurstAtTheSeams59579, true); + creature.CastSpell(creature, BurstAtTheSeamsIds.SpellBurstAtTheSeamsBone, true); + creature.CastSpell(creature, BurstAtTheSeamsIds.SpellBurstAtTheSeamsBone, true); + creature.CastSpell(creature, BurstAtTheSeamsIds.SpellBurstAtTheSeamsBone, true); + creature.CastSpell(creature, BurstAtTheSeamsIds.SpellExplodeAbominationMeat, true); + creature.CastSpell(creature, BurstAtTheSeamsIds.SpellExplodeAbominationBloodyMeat, true); + creature.CastSpell(creature, BurstAtTheSeamsIds.SpellExplodeAbominationBloodyMeat, true); + creature.CastSpell(creature, BurstAtTheSeamsIds.SpellExplodeAbominationBloodyMeat, true); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -1106,12 +905,12 @@ namespace Scripts.Spells.Quest void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode) { Unit target = GetTarget(); - target.CastSpell(target, SpellIds.TrollExplosion, true); - target.CastSpell(target, SpellIds.ExplodeAbominationMeat, true); - target.CastSpell(target, SpellIds.ExplodeTrollMeat, true); - target.CastSpell(target, SpellIds.ExplodeTrollMeat, true); - target.CastSpell(target, SpellIds.ExplodeTrollBloodyMeat, true); - target.CastSpell(target, SpellIds.BurstAtTheSeamsBone, true); + target.CastSpell(target, BurstAtTheSeamsIds.SpellTrollExplosion, true); + target.CastSpell(target, BurstAtTheSeamsIds.SpellExplodeAbominationMeat, true); + target.CastSpell(target, BurstAtTheSeamsIds.SpellExplodeTrollMeat, true); + target.CastSpell(target, BurstAtTheSeamsIds.SpellExplodeTrollMeat, true); + target.CastSpell(target, BurstAtTheSeamsIds.SpellExplodeTrollBloodyMeat, true); + target.CastSpell(target, BurstAtTheSeamsIds.SpellBurstAtTheSeamsBone, true); } void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) @@ -1122,24 +921,24 @@ namespace Scripts.Spells.Quest { switch (target.GetEntry()) { - case CreatureIds.IcyGhoul: - target.CastSpell(caster, SpellIds.AssignGhoulKillCreditToMaster, true); + case BurstAtTheSeamsIds.NpcIcyGhoul: + target.CastSpell(caster, BurstAtTheSeamsIds.SpellAssignGhoulKillCreditToMaster, true); break; - case CreatureIds.ViciousGeist: - target.CastSpell(caster, SpellIds.AssignGeistKillCreditToMaster, true); + case BurstAtTheSeamsIds.NpcViciousGeist: + target.CastSpell(caster, BurstAtTheSeamsIds.SpellAssignGeistKillCreditToMaster, true); break; - case CreatureIds.RisenAllianceSoldiers: - target.CastSpell(caster, SpellIds.AssignSkeletonKillCreditToMaster, true); + case BurstAtTheSeamsIds.NpcRisenAllianceSoldiers: + target.CastSpell(caster, BurstAtTheSeamsIds.SpellAssignSkeletonKillCreditToMaster, true); break; } } - target.CastSpell(target, SpellIds.BurstAtTheSeams59580, true); + target.CastSpell(target, BurstAtTheSeamsIds.SpellBurstAtTheSeams59580, true); } public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectApply.Add(new(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(HandleRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -1162,13 +961,13 @@ namespace Scripts.Spells.Quest Unit target = GetTarget(); Creature creature = target.ToCreature(); if (creature != null) - creature.DespawnOrUnsummon(); + creature.DespawnOrUnsummon(); } public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectApply.Add(new(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(HandleRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -1179,19 +978,19 @@ namespace Scripts.Spells.Quest { Creature creature = GetHitCreature(); if (creature != null) - { + { uint area = creature.GetAreaId(); - if (area != Misc.AreaTheBrokenFront && area != Misc.AreaMordRetharTheDeathGate) + if (area != BurstAtTheSeamsIds.AreaTheBrokenFront && area != BurstAtTheSeamsIds.AreaMordRetharTheDeathGate) creature.DespawnOrUnsummon(); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } - + // 59590 - Assign Ghoul Kill Credit to Master // 60039 - Assign Skeleton Kill Credit to Master [Script] // 60041 - Assign Geist Kill Credit to Master @@ -1212,7 +1011,7 @@ namespace Scripts.Spells.Quest public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -1221,8 +1020,8 @@ namespace Scripts.Spells.Quest { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.BurstAtTheSeams52510, SpellIds.BurstAtTheSeams52508, SpellIds.BurstAtTheSeams59580, - SpellIds.BurstAtTheSeamsBone, SpellIds.ExplodeAbominationMeat, SpellIds.ExplodeAbominationBloodyMeat); + return ValidateSpellInfo(BurstAtTheSeamsIds.SpellBurstAtTheSeams52510, BurstAtTheSeamsIds.SpellBurstAtTheSeams52508, BurstAtTheSeamsIds.SpellBurstAtTheSeams59580, + BurstAtTheSeamsIds.SpellBurstAtTheSeamsBone, BurstAtTheSeamsIds.SpellExplodeAbominationMeat, BurstAtTheSeamsIds.SpellExplodeAbominationBloodyMeat); } public override bool Load() @@ -1241,18 +1040,18 @@ namespace Scripts.Spells.Quest Player player = charmer.ToPlayer(); if (player != null) { - if (player.GetQuestStatus(Misc.QuestFuelForTheFire) == QuestStatus.Incomplete) + if (player.GetQuestStatus(BurstAtTheSeamsIds.QuestFuelForTheFire) == QuestStatus.Incomplete) { - creature.CastSpell(creature, SpellIds.BurstAtTheSeamsBone, true); - creature.CastSpell(creature, SpellIds.ExplodeAbominationMeat, true); - creature.CastSpell(creature, SpellIds.ExplodeAbominationBloodyMeat, true); - creature.CastSpell(creature, SpellIds.BurstAtTheSeams52508, true); - creature.CastSpell(creature, SpellIds.BurstAtTheSeams59580, true); + creature.CastSpell(creature, BurstAtTheSeamsIds.SpellBurstAtTheSeamsBone, true); + creature.CastSpell(creature, BurstAtTheSeamsIds.SpellExplodeAbominationMeat, true); + creature.CastSpell(creature, BurstAtTheSeamsIds.SpellExplodeAbominationBloodyMeat, true); + creature.CastSpell(creature, BurstAtTheSeamsIds.SpellBurstAtTheSeams52508, true); + creature.CastSpell(creature, BurstAtTheSeamsIds.SpellBurstAtTheSeams59580, true); - player.CastSpell(player, SpellIds.DrakkariSkullcrusherCredit, true); - ushort count = player.GetReqKillOrCastCurrentCount(Misc.QuestFuelForTheFire, (int)CreatureIds.DrakkariChieftaink); + player.CastSpell(player, BurstAtTheSeamsIds.SpellDrakkariSkullcrusherCredit, true); + ushort count = player.GetReqKillOrCastCurrentCount(BurstAtTheSeamsIds.QuestFuelForTheFire, (int)BurstAtTheSeamsIds.NpcDrakkariChieftaink); if ((count % 20) == 0) - player.CastSpell(player, SpellIds.SummonDrakkariChieftain, true); + player.CastSpell(player, BurstAtTheSeamsIds.SpellSummonDrakkariChieftain, true); } } } @@ -1266,12 +1065,453 @@ namespace Scripts.Spells.Quest public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleKnockBack, 1, SpellEffectName.KnockBack)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleKnockBack, 1, SpellEffectName.KnockBack)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } - [Script] + [Script] // 48682 - Escape from Silverbrook - Periodic Dummy + class spell_q12308_escape_from_silverbrook : SpellScript + { + const uint SpellSummonWorgen = 48681; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellSummonWorgen); + } + + void HandleDummy(uint effIndex) + { + GetCaster().CastSpell(GetCaster(), SpellSummonWorgen, true); + } + + public override void Register() + { + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] // 48681 - Summon Silverbrook Worgen + class spell_q12308_escape_from_silverbrook_summon_worgen : SpellScript + { + void ModDest(ref SpellDestination dest) + { + float dist = GetEffectInfo(0).CalcRadius(GetCaster()); + float angle = RandomHelper.FRand(0.75f, 1.25f) * (float)(MathF.PI); + + Position pos = GetCaster().GetNearPosition(dist, angle); + dest.Relocate(pos); + } + + public override void Register() + { + OnDestinationTargetSelect.Add(new(ModDest, 0, Targets.DestCasterSummon)); + } + } + + [Script] // 51858 - Siphon of Acherus + class spell_q12641_death_comes_from_on_high : SpellScript + { + const uint SpellForgeCredit = 51974; + const uint SpellTownHallCredit = 51977; + const uint SpellScarletHoldCredit = 51980; + const uint SpellChapelCredit = 51982; + + const uint NpcNewAvalonForge = 28525; + const uint NpcNewAvalonTownHall = 28543; + const uint NpcScarletHold = 28542; + const uint NpcChapelOfTheCrimsonFlame = 28544; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellForgeCredit, SpellTownHallCredit, SpellScarletHoldCredit, SpellChapelCredit); + } + + void HandleDummy(uint effIndex) + { + uint spellId = GetHitCreature().GetEntry() switch + { + NpcNewAvalonForge => SpellForgeCredit, + NpcNewAvalonTownHall => SpellTownHallCredit, + NpcScarletHold => SpellScarletHoldCredit, + NpcChapelOfTheCrimsonFlame => SpellChapelCredit, + _ => 0 + }; + + GetCaster().CastSpell(null, spellId, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] // 52694 - Recall Eye of Acherus + class spell_q12641_recall_eye_of_acherus : SpellScript + { + const uint TheEyeOfAcherus = 51852; + + void HandleDummy(uint effIndex) + { + Player player = GetCaster().GetCharmerOrOwner().ToPlayer(); + if (player != null) + { + player.StopCastingCharm(); + player.StopCastingBindSight(); + player.RemoveAura(TheEyeOfAcherus); + } + } + + public override void Register() + { + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.ScriptEffect)); + } + } + + [Script] // 51769 - Emblazon Runeblade + class spell_q12619_emblazon_runeblade : AuraScript + { + void HandleEffectPeriodic(AuraEffect aurEff) + { + PreventDefaultAction(); + Unit caster = GetCaster(); + if (caster != null) + caster.CastSpell(caster, aurEff.GetSpellEffectInfo().TriggerSpell, aurEff); + } + + public override void Register() + { + OnEffectPeriodic.Add(new(HandleEffectPeriodic, 0, AuraType.PeriodicTriggerSpell)); + } + } + + [Script] // 51770 - Emblazon Runeblade + class spell_q12619_emblazon_runeblade_effect : SpellScript + { + void HandleScript(uint effIndex) + { + GetCaster().CastSpell(GetCaster(), (uint)GetEffectValue(), false); + } + + public override void Register() + { + OnEffectHit.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); + } + } + + [Script] // 55516 - Gymer's Grab + class spell_q12919_gymers_grab : SpellScript + { + const uint SpellRideGymer = 43671; + const uint SpellGrabbed = 55424; + + public override bool Validate(SpellInfo spell) + { + return ValidateSpellInfo(SpellRideGymer); + } + + void HandleScript(uint effIndex) + { + if (GetHitCreature() == null) + return; + + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.AddSpellMod(SpellValueMod.BasePoint0, 2); + GetHitCreature().CastSpell(GetCaster(), SpellRideGymer, args); + GetHitCreature().CastSpell(GetHitCreature(), SpellGrabbed, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); + } + } + + [Script] // 55421 - Gymer's Throw + class spell_q12919_gymers_throw : SpellScript + { + const uint SpellVargulExplosion = 55569; + + void HandleScript(uint effIndex) + { + Unit caster = GetCaster(); + if (caster.IsVehicle()) + { + Unit passenger = caster.GetVehicleKit().GetPassenger(1); + if (passenger != null) + { + passenger.ExitVehicle(); + caster.CastSpell(passenger, SpellVargulExplosion, true); + } + } + } + + public override void Register() + { + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); + } + } + + [Script] // 61752 - Illidan Kill Credit Master + class spell_q13400_illidan_kill_master : SpellScript + { + const uint SpellIllidanKillCredit = 61748; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIllidanKillCredit); + } + + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + if (caster.IsVehicle()) + { + Unit passenger = caster.GetVehicleKit().GetPassenger(0); + if (passenger != null) + passenger.CastSpell(passenger, SpellIllidanKillCredit, true); + } + } + + public override void Register() + { + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] // 66744 - Make Player Destroy Totems + class spell_q14100_q14111_make_player_destroy_totems : SpellScript + { + const uint SpellTotemOfTheEarthenRing = 66747; + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellTotemOfTheEarthenRing); + } + + void HandleScriptEffect(uint effIndex) + { + Player player = GetHitPlayer(); + if (player != null) + player.CastSpell(player, SpellTotemOfTheEarthenRing, TriggerCastFlags.FullMask); // ignore reagent Cost, consumed by quest + } + + public override void Register() + { + OnEffectHitTarget.Add(new(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); + } + } + + [Script] // 39238 - Fuping + class spell_q10929_fuping : AuraScript + { + const uint SpellSummonSandGnome = 39240; + const uint SpellSummonBoneSlicer = 39241; + + public override bool Validate(SpellInfo spell) + { + return ValidateSpellInfo(SpellSummonSandGnome, SpellSummonBoneSlicer); + } + + void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire) + return; + + Unit caster = GetCaster(); + if (caster != null) + caster.CastSpell(caster, RandomHelper.URand(SpellSummonSandGnome, SpellSummonBoneSlicer), true); + } + + public override void Register() + { + OnEffectRemove.Add(new(HandleEffectRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + } + } + + [Script] // 93072 - Get Our Boys Back Dummy + class spell_q28813_get_our_boys_back_dummy : SpellScript + { + const uint SpellRenewedLife = 93097; + const uint NpcInjuredStormwindInfantry = 50047; + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellRenewedLife); + } + + void HandleDummyEffect() + { + Unit caster = GetCaster(); + + Creature injuredStormwindInfantry = caster.FindNearestCreature(NpcInjuredStormwindInfantry, 5.0f, true); + if (injuredStormwindInfantry != null) + { + injuredStormwindInfantry.SetCreatorGUID(caster.GetGUID()); + injuredStormwindInfantry.CastSpell(injuredStormwindInfantry, SpellRenewedLife, true); + } + } + + public override void Register() + { + OnCast.Add(new(HandleDummyEffect)); + } + } + + [Script] // 53034 - Set Health Random + class spell_q28813_set_health_random : SpellScript + { + void HandleDummyEffect() + { + Unit caster = GetCaster(); + caster.SetHealth(caster.CountPctFromMaxHealth(RandomHelper.IRand(3, 5) * 10)); + } + + public override void Register() + { + OnCast.Add(new(HandleDummyEffect)); + } + } + + [Script] // 49285 - Hand Over Reins + class spell_q12414_hand_over_reins : SpellScript + { + void HandleScript(uint effIndex) + { + Creature caster = GetCaster().ToCreature(); + GetHitUnit().ExitVehicle(); + + if (caster != null) + caster.DespawnOrUnsummon(); + } + + public override void Register() + { + OnEffectHitTarget.Add(new(HandleScript, 1, SpellEffectName.ScriptEffect)); + } + } + + // 13790 13793 13811 13814 - Among the ChaMathF.PIons + [Script] // 13665 13745 13750 13756 13761 13767 13772 13777 13782 13787 - The Grand Melee + class spell_q13665_q13790_bested_trigger : SpellScript + { + void HandleScript(uint effIndex) + { + Unit target = GetHitUnit().GetCharmerOrOwnerOrSelf(); + target.CastSpell(target, (uint)GetEffectValue(), true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); + } + } + + struct ApplyHeatAndStirIds + { + public const uint SpellSpurtsAndSmoke = 38594; + public const uint SpellFailedMix1 = 43376; + public const uint SpellFailedMix2 = 43378; + public const uint SpellFailedMix3 = 43970; + public const uint SpellSuccessfulMix = 43377; + + public const uint CreatureGenericTriggerLab = 24042; + + public const uint Talk0 = 0; + public const uint Talk1 = 1; + } + + [Script] // 43972 - Mixing Blood + class spell_q11306_mixing_blood : SpellScript + { + void HandleEffect(uint effIndex) + { + Unit caster = GetCaster(); + if (caster != null) + { + Creature trigger = caster.FindNearestCreature(ApplyHeatAndStirIds.CreatureGenericTriggerLab, 100.0f); + if (trigger != null) + trigger.GetAI().DoCastSelf(ApplyHeatAndStirIds.SpellSpurtsAndSmoke); + } + } + + public override void Register() + { + OnEffectHit.Add(new(HandleEffect, 1, SpellEffectName.SendEvent)); + } + } + + [Script] // 43375 - Mixing Vrykul Blood + class spell_q11306_mixing_vrykul_blood : SpellScript + { + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + if (caster != null) + { + uint chance = RandomHelper.URand(0, 99); + uint spellId = 0; + + // 90% chance of getting one out of three failure effects + if (chance < 30) + spellId = ApplyHeatAndStirIds.SpellFailedMix1; + else if (chance < 60) + spellId = ApplyHeatAndStirIds.SpellFailedMix2; + else if (chance < 90) + spellId = ApplyHeatAndStirIds.SpellFailedMix3; + else // 10% chance of successful cast + spellId = ApplyHeatAndStirIds.SpellSuccessfulMix; + + caster.CastSpell(caster, spellId, true); + } + } + + public override void Register() + { + OnEffectHitTarget.Add(new(HandleDummy, 1, SpellEffectName.Dummy)); + } + } + + [Script] // 43376 - Failed Mix + class spell_q11306_failed_mix_43376 : SpellScript + { + void HandleEffect(uint effIndex) + { + Unit caster = GetCaster(); + if (caster != null) + { + Creature trigger = caster.FindNearestCreature(ApplyHeatAndStirIds.CreatureGenericTriggerLab, 100.0f); + if (trigger != null) + trigger.GetAI().Talk(ApplyHeatAndStirIds.Talk0, caster); + } + } + + public override void Register() + { + OnEffectHit.Add(new(HandleEffect, 1, SpellEffectName.SendEvent)); + } + } + + [Script] // 43378 - Failed Mix + class spell_q11306_failed_mix_43378 : SpellScript + { + void HandleEffect(uint effIndex) + { + Unit caster = GetCaster(); + if (caster != null) + { + Creature trigger = caster.FindNearestCreature(ApplyHeatAndStirIds.CreatureGenericTriggerLab, 100.0f); + if (trigger != null) + trigger.GetAI().Talk(ApplyHeatAndStirIds.Talk1, caster); + } + } + + public override void Register() + { + OnEffectHit.Add(new(HandleEffect, 2, SpellEffectName.SendEvent)); + } + } + + [Script] // 46444 - Weakness to Lightning: Cast on Master Script Effect class spell_q11896_weakness_to_lightning_46444 : SpellScript { void HandleScript(uint effIndex) @@ -1289,23 +1529,79 @@ namespace Scripts.Spells.Quest public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } + struct TamingTheBeastIds + { + public const uint IceClawBear = 19548; + public const uint LargeCragBoar = 19674; + public const uint SnowLeopard = 19687; + public const uint AdultPlainstrider = 19688; + public const uint PrairieStalker = 19689; + public const uint Swoop = 19692; + public const uint WebwoodLurker = 19693; + public const uint DireMottledBoar = 19694; + public const uint SurfCrawler = 19696; + public const uint ArmoredScorpid = 19697; + public const uint NightsaberStalker = 19699; + public const uint StrigidScreecher = 19700; + public const uint BarbedCrawler = 30646; + public const uint GreaterTimberstrider = 30653; + public const uint Nightstalker = 30654; + public const uint CrazedDragonhawk = 30099; + public const uint ElderSpringpaw = 30102; + public const uint Mistbat = 30105; + public const uint IceClawBear1 = 19597; + public const uint LargeCragBoar1 = 19677; + public const uint SnowLeopard1 = 19676; + public const uint AdultPlainstrider1 = 19678; + public const uint PrairieStalker1 = 19679; + public const uint Swoop1 = 19680; + public const uint WebwoodLurker1 = 19684; + public const uint DireMottledBoar1 = 19681; + public const uint SurfCrawler1 = 19682; + public const uint ArmoredScorpid1 = 19683; + public const uint NightsaberStalker1 = 19685; + public const uint StrigidScreecher1 = 19686; + public const uint BarbedCrawler1 = 30647; + public const uint GreaterTimberstrider1 = 30648; + public const uint Nightstalker1 = 30652; + public const uint CrazedDragonhawk1 = 30100; + public const uint ElderSpringpaw1 = 30103; + public const uint Mistbat1 = 30104; + } + [Script] class spell_quest_taming_the_beast : AuraScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.TameIceClawBear, SpellIds.TameLargeCragBoar, SpellIds.TameSnowLeopard, SpellIds.TameAdultPlainstrider, SpellIds.TamePrairieStalker, SpellIds.TameSwoop, - SpellIds.TameWebwoodLurker, SpellIds.TameDireMottledBoar, SpellIds.TameSurfCrawler, SpellIds.TameArmoredScorpid, SpellIds.TameNightsaberStalker, SpellIds.TameStrigidScreecher, - SpellIds.TameBarbedCrawler, SpellIds.TameGreaterTimberstrider, SpellIds.TameNightstalker, SpellIds.TameCrazedDragonhawk, SpellIds.TameElderSpringpaw, SpellIds.TameMistbat); + return ValidateSpellInfo(TamingTheBeastIds.IceClawBear1, + TamingTheBeastIds.LargeCragBoar1, + TamingTheBeastIds.SnowLeopard1, + TamingTheBeastIds.AdultPlainstrider1, + TamingTheBeastIds.PrairieStalker1, + TamingTheBeastIds.Swoop1, + TamingTheBeastIds.WebwoodLurker1, + TamingTheBeastIds.DireMottledBoar1, + TamingTheBeastIds.SurfCrawler1, + TamingTheBeastIds.ArmoredScorpid1, + TamingTheBeastIds.NightsaberStalker1, + TamingTheBeastIds.StrigidScreecher1, + TamingTheBeastIds.BarbedCrawler1, + TamingTheBeastIds.GreaterTimberstrider1, + TamingTheBeastIds.Nightstalker1, + TamingTheBeastIds.CrazedDragonhawk1, + TamingTheBeastIds.ElderSpringpaw1, + TamingTheBeastIds.Mistbat1 + ); } void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - if (!GetCaster() || !GetCaster().IsAlive() || !GetTarget().IsAlive()) + if (GetCaster() == null || !GetCaster().IsAlive() || !GetTarget().IsAlive()) return; if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire) @@ -1313,24 +1609,24 @@ namespace Scripts.Spells.Quest uint finalSpellId = GetId() switch { - SpellIds.TameIceClawBear => SpellIds.TameIceClawBear1, - SpellIds.TameLargeCragBoar => SpellIds.TameLargeCragBoar1, - SpellIds.TameSnowLeopard => SpellIds.TameSnowLeopard1, - SpellIds.TameAdultPlainstrider => SpellIds.TameAdultPlainstrider1, - SpellIds.TamePrairieStalker => SpellIds.TamePrairieStalker1, - SpellIds.TameSwoop => SpellIds.TameSwoop1, - SpellIds.TameWebwoodLurker => SpellIds.TameWebwoodLurker1, - SpellIds.TameDireMottledBoar => SpellIds.TameDireMottledBoar1, - SpellIds.TameSurfCrawler => SpellIds.TameSurfCrawler1, - SpellIds.TameArmoredScorpid => SpellIds.TameArmoredScorpid1, - SpellIds.TameNightsaberStalker => SpellIds.TameNightsaberStalker1, - SpellIds.TameStrigidScreecher => SpellIds.TameStrigidScreecher1, - SpellIds.TameBarbedCrawler => SpellIds.TameBarbedCrawler1, - SpellIds.TameGreaterTimberstrider => SpellIds.TameGreaterTimberstrider1, - SpellIds.TameNightstalker => SpellIds.TameNightstalker1, - SpellIds.TameCrazedDragonhawk => SpellIds.TameCrazedDragonhawk1, - SpellIds.TameElderSpringpaw => SpellIds.TameElderSpringpaw1, - SpellIds.TameMistbat => SpellIds.TameMistbat1, + TamingTheBeastIds.IceClawBear => TamingTheBeastIds.IceClawBear1, + TamingTheBeastIds.LargeCragBoar => TamingTheBeastIds.LargeCragBoar1, + TamingTheBeastIds.SnowLeopard => TamingTheBeastIds.SnowLeopard1, + TamingTheBeastIds.AdultPlainstrider => TamingTheBeastIds.AdultPlainstrider1, + TamingTheBeastIds.PrairieStalker => TamingTheBeastIds.PrairieStalker1, + TamingTheBeastIds.Swoop => TamingTheBeastIds.Swoop1, + TamingTheBeastIds.WebwoodLurker => TamingTheBeastIds.WebwoodLurker1, + TamingTheBeastIds.DireMottledBoar => TamingTheBeastIds.DireMottledBoar1, + TamingTheBeastIds.SurfCrawler => TamingTheBeastIds.SurfCrawler1, + TamingTheBeastIds.ArmoredScorpid => TamingTheBeastIds.ArmoredScorpid1, + TamingTheBeastIds.NightsaberStalker => TamingTheBeastIds.NightsaberStalker1, + TamingTheBeastIds.StrigidScreecher => TamingTheBeastIds.StrigidScreecher1, + TamingTheBeastIds.BarbedCrawler => TamingTheBeastIds.BarbedCrawler1, + TamingTheBeastIds.GreaterTimberstrider => TamingTheBeastIds.GreaterTimberstrider1, + TamingTheBeastIds.Nightstalker => TamingTheBeastIds.Nightstalker1, + TamingTheBeastIds.CrazedDragonhawk => TamingTheBeastIds.CrazedDragonhawk1, + TamingTheBeastIds.ElderSpringpaw => TamingTheBeastIds.ElderSpringpaw1, + TamingTheBeastIds.Mistbat => TamingTheBeastIds.Mistbat1, _ => 0 }; @@ -1340,7 +1636,7 @@ namespace Scripts.Spells.Quest public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(OnRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -1349,9 +1645,9 @@ namespace Scripts.Spells.Quest { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 1) - && ValidateSpellInfo((uint)spellInfo.GetEffect(0).CalcValue()) - && Global.ObjectMgr.GetQuestTemplate((uint)spellInfo.GetEffect(1).CalcValue()) != null; + return ValidateSpellEffect((spellInfo.Id, 1)) + && ValidateSpellInfo((uint)spellInfo.GetEffect(0).CalcValue()) + && ObjectMgr.GetQuestTemplate((uint)spellInfo.GetEffect(1).CalcValue()) != null; } void HandleScriptEffect(uint effIndex) @@ -1370,39 +1666,56 @@ namespace Scripts.Spells.Quest public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } + struct TributeSpellIds + { + public const uint GromsTrollTribute = 24101; + public const uint GromsTaurenTribute = 24102; + public const uint GromsUndeadTribute = 24103; + public const uint GromsOrcTribute = 24104; + public const uint GromsBloodelfTribute = 69530; + public const uint UthersHumanTribute = 24105; + public const uint UthersGnomeTribute = 24106; + public const uint UthersDwarfTribute = 24107; + public const uint UthersNightelfTribute = 24108; + public const uint UthersDraeneiTribute = 69533; + } + // 24194 - Uther's Tribute [Script] // 24195 - Grom's Tribute class spell_quest_uther_grom_tribute : SpellScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.GromsTrollTribute, SpellIds.GromsTaurenTribute, SpellIds.GromsUndeadTribute, SpellIds.GromsOrcTribute, SpellIds.GromsBloodelfTribute, - SpellIds.UthersHumanTribute, SpellIds.UthersGnomeTribute, SpellIds.UthersDwarfTribute, SpellIds.UthersNightelfTribute, SpellIds.UthersDraeneiTribute); + return ValidateSpellInfo(TributeSpellIds.GromsTrollTribute, TributeSpellIds.UthersHumanTribute, + TributeSpellIds.GromsTaurenTribute, TributeSpellIds.UthersGnomeTribute, + TributeSpellIds.GromsUndeadTribute, TributeSpellIds.UthersDwarfTribute, + TributeSpellIds.GromsOrcTribute, TributeSpellIds.UthersNightelfTribute, + TributeSpellIds.GromsBloodelfTribute, TributeSpellIds.UthersDraeneiTribute); } void HandleScript(uint effIndex) { Player caster = GetCaster().ToPlayer(); - if (!caster) + if (caster == null) return; uint spell = caster.GetRace() switch { - Race.Troll => SpellIds.GromsTrollTribute, - Race.Tauren => SpellIds.GromsTaurenTribute, - Race.Undead => SpellIds.GromsUndeadTribute, - Race.Orc => SpellIds.GromsOrcTribute, - Race.BloodElf => SpellIds.GromsBloodelfTribute, - Race.Human => SpellIds.UthersHumanTribute, - Race.Gnome => SpellIds.UthersGnomeTribute, - Race.Dwarf => SpellIds.UthersDwarfTribute, - Race.NightElf => SpellIds.UthersNightelfTribute, - Race.Draenei => SpellIds.UthersDraeneiTribute, - _ => 0 + Race.Troll => TributeSpellIds.GromsTrollTribute, + Race.Tauren => TributeSpellIds.GromsTaurenTribute, + Race.Undead => TributeSpellIds.GromsUndeadTribute, + Race.Orc => TributeSpellIds.GromsOrcTribute, + Race.BloodElf => TributeSpellIds.GromsBloodelfTribute, + Race.Human => TributeSpellIds.UthersHumanTribute, + Race.Gnome => TributeSpellIds.UthersGnomeTribute, + Race.Dwarf => TributeSpellIds.UthersDwarfTribute, + Race.NightElf => TributeSpellIds.UthersNightelfTribute, + Race.Draenei => TributeSpellIds.UthersDraeneiTribute, + _ => 0, }; if (spell != 0) @@ -1411,310 +1724,32 @@ namespace Scripts.Spells.Quest public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } - } - - [Script] // 48682 - Escape from Silverbrook - Periodic Dummy - class spell_q12308_escape_from_silverbrook : SpellScript - { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.SummonWorgen); - } - - void HandleDummy(uint effIndex) - { - GetCaster().CastSpell(GetCaster(), SpellIds.SummonWorgen, true); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - } - - [Script] // 48681 - Summon Silverbrook Worgen - class spell_q12308_escape_from_silverbrook_summon_worgen : SpellScript - { - void ModDest(ref SpellDestination dest) - { - float dist = GetEffectInfo(0).CalcRadius(GetCaster()); - float angle = RandomHelper.FRand(0.75f, 1.25f) * MathFunctions.PI; - - Position pos = GetCaster().GetNearPosition(dist, angle); - dest.Relocate(pos); - } - - public override void Register() - { - OnDestinationTargetSelect.Add(new DestinationTargetSelectHandler(ModDest, 0, Targets.DestCasterSummon)); - } - } - - [Script] // 51858 - Siphon of Acherus - class spell_q12641_death_comes_from_on_high : SpellScript - { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ForgeCredit, SpellIds.TownHallCredit, SpellIds.ScarletHoldCredit, SpellIds.ChapelCredit); - } - - void HandleDummy(uint effIndex) - { - uint spellId; - - switch (GetHitCreature().GetEntry()) - { - case CreatureIds.NewAvalonForge: - spellId = SpellIds.ForgeCredit; - break; - case CreatureIds.NewAvalonTownHall: - spellId = SpellIds.TownHallCredit; - break; - case CreatureIds.ScarletHold: - spellId = SpellIds.ScarletHoldCredit; - break; - case CreatureIds.ChapelOfTheCrimsonFlame: - spellId = SpellIds.ChapelCredit; - break; - default: - return; - } - - GetCaster().CastSpell((Unit)null, spellId, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - } - - [Script] // 52694 - Recall Eye of Acherus - class spell_q12641_recall_eye_of_acherus : SpellScript - { - void HandleDummy(uint effIndex) - { - Player player = GetCaster().GetCharmerOrOwner().ToPlayer(); - if (player) - { - player.StopCastingCharm(); - player.StopCastingBindSight(); - player.RemoveAura(SpellIds.TheEyeOfAcherus); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ScriptEffect)); - } - } - - [Script] // 51769 - Emblazon Runeblade - class spell_q12619_emblazon_runeblade_AuraScript : AuraScript - { - void HandleEffectPeriodic(AuraEffect aurEff) - { - PreventDefaultAction(); - Unit caster = GetCaster(); - if (caster) - caster.CastSpell(caster, aurEff.GetSpellEffectInfo().TriggerSpell, new CastSpellExtraArgs(aurEff)); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicTriggerSpell)); - } - } - - [Script] // 51770 - Emblazon Runeblade - class spell_q12619_emblazon_runeblade : SpellScript - { - void HandleScript(uint effIndex) - { - GetCaster().CastSpell(GetCaster(), (uint)GetEffectValue(), false); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHit.Add(new(HandleScript, 0, SpellEffectName.ScriptEffect)); } } - [Script] // 55516 - Gymer's Grab - class spell_q12919_gymers_grab : SpellScript + [Script] // 68682 Call Attack Mastiffs + class spell_q14386_call_attack_mastiffs : SpellScript { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.RideGymer); - } + const uint NpcAttackMastiff = 36405; - void HandleScript(uint effIndex) - { - if (!GetHitCreature()) - return; - - CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); - args.AddSpellMod(SpellValueMod.BasePoint0, 2); - GetHitCreature().CastSpell(GetCaster(), SpellIds.RideGymer, args); - GetHitCreature().CastSpell(GetHitCreature(), SpellIds.Grabbed, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } - } - - [Script] // 55421 - Gymer's Throw - class spell_q12919_gymers_throw : SpellScript - { - void HandleScript(uint effIndex) + void HandleEffect(uint eff) { Unit caster = GetCaster(); - if (caster.IsVehicle()) - { - Unit passenger = caster.GetVehicleKit().GetPassenger(1); - if (passenger) - { - passenger.ExitVehicle(); - caster.CastSpell(passenger, SpellIds.VargulExplosion, true); - } - } + caster.SummonCreature(NpcAttackMastiff, -1944.573f, 2657.402f, 0.994939f, 1.691919f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(1)); + caster.SummonCreature(NpcAttackMastiff, -2005.65f, 2663.526f, -2.086935f, 0.5942355f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(1)); + caster.SummonCreature(NpcAttackMastiff, -1996.506f, 2651.347f, -1.011707f, 0.8185352f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(1)); + caster.SummonCreature(NpcAttackMastiff, -1972.352f, 2640.07f, 1.080288f, 1.217854f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(1)); + caster.SummonCreature(NpcAttackMastiff, -1949.322f, 2642.76f, 1.242482f, 1.58074f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(1)); + caster.SummonCreature(NpcAttackMastiff, -1993.94f, 2672.535f, -2.322549f, 0.5766209f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(1)); + caster.SummonCreature(NpcAttackMastiff, -1982.724f, 2662.8f, -1.773986f, 0.8628055f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(1)); + caster.SummonCreature(NpcAttackMastiff, -1973.301f, 2655.475f, -0.7831049f, 1.098415f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(1)); + caster.SummonCreature(NpcAttackMastiff, -1956.509f, 2650.655f, 1.350571f, 1.441473f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(1)); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHit.Add(new(HandleEffect, 1, SpellEffectName.SendEvent)); } } - - [Script] // 61752 - Illidan Kill Credit Master - class spell_q13400_illidan_kill_master : SpellScript - { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.IllidanKillCredit); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - if (caster.IsVehicle()) - { - Unit passenger = caster.GetVehicleKit().GetPassenger(0); - if (passenger) - passenger.CastSpell(passenger, SpellIds.IllidanKillCredit, true); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - } - - [Script] // 66744 - Make Player Destroy Totems - class spell_q14100_q14111_make_player_destroy_totems : SpellScript - { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.TotemOfTheEarthenRing); - } - - void HandleScriptEffect(uint effIndex) - { - Player player = GetHitPlayer(); - if (player) - player.CastSpell(player, SpellIds.TotemOfTheEarthenRing, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); // ignore reagent cost, consumed by quest - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); - } - } - - [Script] // 39238 - Fumping - class spell_q10929_fumping : AuraScript - { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.SummonSandGnome, SpellIds.SummonBoneSlicer); - } - - void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire) - return; - - Unit caster = GetCaster(); - if (caster) - caster.CastSpell(caster, RandomHelper.URand(SpellIds.SummonSandGnome, SpellIds.SummonBoneSlicer), true); - } - - public override void Register() - { - OnEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - } - } - - [Script] // 93072 - Get Our Boys Back Dummy - class spell_q28813_get_our_boys_back_dummy : SpellScript - { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.RenewedLife); - } - - void HandleDummyEffect() - { - Unit caster = GetCaster(); - Creature injuredStormwindInfantry = caster.FindNearestCreature(CreatureIds.InjuredStormwindInfantry, 5.0f, true); - if (injuredStormwindInfantry) - { - injuredStormwindInfantry.SetCreatorGUID(caster.GetGUID()); - injuredStormwindInfantry.CastSpell(injuredStormwindInfantry, SpellIds.RenewedLife, true); - } - } - - public override void Register() - { - OnCast.Add(new CastHandler(HandleDummyEffect)); - } - } - - [Script] // 53034 - Set Health Random - class spell_q28813_set_health_random : SpellScript - { - void HandleDummyEffect() - { - Unit caster = GetCaster(); - caster.SetHealth(caster.CountPctFromMaxHealth(RandomHelper.IRand(3, 5) * 10)); - } - - public override void Register() - { - OnCast.Add(new CastHandler(HandleDummyEffect)); - } - } - - [Script] // 49285 - Hand Over Reins - class spell_q12414_hand_over_reins : SpellScript - { - void HandleScript(uint effIndex) - { - Creature caster = GetCaster().ToCreature(); - GetHitUnit().ExitVehicle(); - - if (caster) - caster.DespawnOrUnsummon(); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.ScriptEffect)); - } - } -} +} \ No newline at end of file diff --git a/Source/Scripts/Spells/Rogue.cs b/Source/Scripts/Spells/Rogue.cs index a315d4b9c..215d2a570 100644 --- a/Source/Scripts/Spells/Rogue.cs +++ b/Source/Scripts/Spells/Rogue.cs @@ -1,4 +1,4 @@ -// Copyright (c) CypherCore All rights reserved. +// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; @@ -9,18 +9,24 @@ using Game.Scripting; using Game.Spells; using System; using System.Collections.Generic; -using System.Linq; +using static Global; namespace Scripts.Spells.Rogue { - public struct SpellIds + + struct SpellIds { public const uint AdrenalineRush = 13750; public const uint BetweenTheEyes = 199804; + public const uint BlackjackTalent = 379005; + public const uint Blackjack = 394119; public const uint BladeFlurry = 13877; public const uint BladeFlurryExtraAttack = 22482; public const uint Broadside = 193356; public const uint BuriedTreasure = 199600; + public const uint CheatDeathDummy = 31231; + public const uint CheatedDeath = 45181; + public const uint CheatingDeath = 45182; public const uint DeathFromAbove = 152150; public const uint GrandMelee = 193358; public const uint GrapplingHook = 195457; @@ -34,6 +40,8 @@ namespace Scripts.Spells.Rogue public const uint MainGauche = 86392; public const uint PremeditationPassive = 343160; public const uint PremeditationAura = 343173; + public const uint PreyOnTheWeakTalent = 131511; + public const uint PreyOnTheWeak = 255909; public const uint RuthlessPrecision = 193357; public const uint Sanctuary = 98877; public const uint SkullAndCrossbones = 199603; @@ -53,16 +61,27 @@ namespace Scripts.Spells.Rogue public const uint TricksOfTheTrade = 57934; public const uint TricksOfTheTradeProc = 59628; public const uint HonorAmongThievesEnergize = 51699; - public const uint T52pSetBonus = 37169; + public const uint T52PSetBonus = 37169; public const uint VenomousWounds = 79134; } + struct Misc + { + public static int? GetFinishingMoveCPCost(Spell spell) + { + if (spell == null) + return null; + + return spell.GetPowerTypeCostAmount(PowerType.ComboPoints); + } + } + [Script] // 53 - Backstab class spell_rog_backstab : SpellScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 3); + return ValidateSpellEffect((spellInfo.Id, 3)); } void HandleHitDamage(uint effIndex) @@ -74,21 +93,46 @@ namespace Scripts.Spells.Rogue Unit caster = GetCaster(); if (hitUnit.IsInBack(caster)) { - float currDamage = (float)GetHitDamage(); - float newDamage = MathFunctions.AddPct(ref currDamage, (float)GetEffectInfo(3).CalcValue(caster)); + float currDamage = (float)(GetHitDamage()); + float newDamage = MathFunctions.AddPct(ref currDamage, (float)(GetEffectInfo(3).CalcValue(caster))); SetHitDamage((int)newDamage); } } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleHitDamage, 1, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new(HandleHitDamage, 1, SpellEffectName.SchoolDamage)); + } + } + + // 379005 - Blackjack + [Script] // Called by Sap - 6770 and Blind - 2094 + class spell_rog_blackjack : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.BlackjackTalent, SpellIds.Blackjack); + } + + void EffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit caster = GetCaster(); + if (caster != null) + if (caster.HasAura(SpellIds.BlackjackTalent)) + caster.CastSpell(GetTarget(), SpellIds.Blackjack, true); + } + + public override void Register() + { + AfterEffectRemove.Add(new(EffectRemove, 0, AuraType.Any, AuraEffectHandleModes.Real)); } } [Script] // 13877, 33735, (check 51211, 65956) - Blade Flurry - class spell_rog_blade_flurry_AuraScript : AuraScript + class spell_rog_blade_flurry : AuraScript { + Unit _procTarget; + public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.BladeFlurryExtraAttack); @@ -115,19 +159,52 @@ namespace Scripts.Spells.Rogue public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); + DoCheckProc.Add(new(CheckProc)); if (m_scriptSpellId == SpellIds.BladeFlurry) - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ModPowerRegenPercent)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ModPowerRegenPercent)); else - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ModMeleeHaste)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ModMeleeHaste)); + } + } + + [Script] // 31230 - Cheat Death + class spell_rog_cheat_death : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.CheatDeathDummy, SpellIds.CheatedDeath, SpellIds.CheatingDeath) + && ValidateSpellEffect((spellInfo.Id, 1)); } - Unit _procTarget = null; + void HandleAbsorb(AuraEffect aurEff, DamageInfo dmgInfo, ref uint absorbAmount) + { + Unit target = GetTarget(); + if (target.HasAura(SpellIds.CheatedDeath)) + { + absorbAmount = 0; + return; + } + + PreventDefaultAction(); + + target.CastSpell(target, SpellIds.CheatDeathDummy, TriggerCastFlags.IgnoreCastInProgress | TriggerCastFlags.DontReportCastError); + target.CastSpell(target, SpellIds.CheatedDeath, TriggerCastFlags.DontReportCastError); + target.CastSpell(target, SpellIds.CheatingDeath, TriggerCastFlags.DontReportCastError); + + target.SetHealth(target.CountPctFromMaxHealth(GetEffectInfo(1).CalcValue(target))); + } + + public override void Register() + { + OnEffectAbsorb.Add(new(HandleAbsorb, 0)); + } } [Script] // 2818 - Deadly Poison - class spell_rog_deadly_poison_SpellScript : SpellScript + class spell_rog_deadly_poison : SpellScript { + byte _stackAmount; + public override bool Load() { // at this point CastItem must already be initialized @@ -143,7 +220,7 @@ namespace Scripts.Spells.Rogue if (target != null) { // Deadly Poison - AuraEffect aurEff = target.GetAuraEffect(AuraType.PeriodicDummy, SpellFamilyNames.Rogue, new FlagArray128(0x10000, 0x80000, 0), GetCaster().GetGUID()); + AuraEffect aurEff = target.GetAuraEffect(AuraType.PeriodicDamage, SpellFamilyNames.Rogue, new FlagArray128(0x10000, 0x80000, 0), GetCaster().GetGUID()); if (aurEff != null) _stackAmount = aurEff.GetBase().GetStackAmount(); } @@ -155,11 +232,13 @@ namespace Scripts.Spells.Rogue return; Player player = GetCaster().ToPlayer(); + Unit target = GetHitUnit(); if (target != null) { Item item = player.GetItemByPos(InventorySlots.Bag0, EquipmentSlot.MainHand); + if (item == GetCastItem()) item = player.GetItemByPos(InventorySlots.Bag0, EquipmentSlot.OffHand); @@ -167,9 +246,9 @@ namespace Scripts.Spells.Rogue return; // item combat enchantments - for (byte slot = 0; slot < (int)EnchantmentSlot.Max; ++slot) + for (EnchantmentSlot slot = 0; slot < EnchantmentSlot.Max; ++slot) { - var enchant = CliDB.SpellItemEnchantmentStorage.LookupByKey(item.GetEnchantmentId((EnchantmentSlot)slot)); + SpellItemEnchantmentRecord enchant = CliDB.SpellItemEnchantmentStorage.LookupByKey(item.GetEnchantmentId(slot)); if (enchant == null) continue; @@ -178,10 +257,10 @@ namespace Scripts.Spells.Rogue if (enchant.Effect[s] != ItemEnchantmentType.CombatSpell) continue; - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(enchant.EffectArg[s], Difficulty.None); + SpellInfo spellInfo = SpellMgr.GetSpellInfo(enchant.EffectArg[s], Difficulty.None); if (spellInfo == null) { - Log.outError(LogFilter.Spells, $"Player::CastItemCombatSpell Enchant {enchant.Id}, player (Name: {player.GetName()}, {player.GetGUID()}) cast unknown spell {enchant.EffectArg[s]}"); + Log.outError(LogFilter.Spells, $"Player.CastItemCombatSpell Enchant {enchant.Id}, player (Name: {player.GetName()}, {player.GetGUID().ToString()})cast unknown spell {enchant.EffectArg[s]}"); continue; } @@ -204,63 +283,47 @@ namespace Scripts.Spells.Rogue public override void Register() { - BeforeHit.Add(new BeforeHitHandler(HandleBeforeHit)); - AfterHit.Add(new HitHandler(HandleAfterHit)); + BeforeHit.Add(new(HandleBeforeHit)); + AfterHit.Add(new(HandleAfterHit)); } - - byte _stackAmount = 0; } [Script] // 32645 - Envenom class spell_rog_envenom : SpellScript { - void CalculateDamage(uint effIndex) + void CalculateDamage(Unit victim, ref int damage, ref int flatMod, ref float pctMod) { - int damagePerCombo = GetHitDamage(); - AuraEffect t5 = GetCaster().GetAuraEffect(SpellIds.T52pSetBonus, 0); + pctMod *= GetSpell().GetPowerTypeCostAmount(PowerType.ComboPoints).GetValueOrDefault(0); + + AuraEffect t5 = GetCaster().GetAuraEffect(SpellIds.T52PSetBonus, 0); if (t5 != null) - damagePerCombo += t5.GetAmount(); - - int finalDamage = damagePerCombo; - var costs = GetSpell().GetPowerCost(); - var c = costs.Find(cost => cost.Power == PowerType.ComboPoints); - if (c != null) - finalDamage *= c.Amount; - - SetHitDamage(finalDamage); + flatMod += t5.GetAmount(); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(CalculateDamage, 0, SpellEffectName.SchoolDamage)); + CalcDamage.Add(new(CalculateDamage)); } } [Script] // 196819 - Eviscerate class spell_rog_eviscerate : SpellScript { - void CalculateDamage(uint effIndex) + void CalculateDamage(Unit victim, ref int damage, ref int flatMod, ref float pctMod) { - int damagePerCombo = GetHitDamage(); - AuraEffect t5 = GetCaster().GetAuraEffect(SpellIds.T52pSetBonus, 0); + pctMod *= GetSpell().GetPowerTypeCostAmount(PowerType.ComboPoints).GetValueOrDefault(0); + + AuraEffect t5 = GetCaster().GetAuraEffect(SpellIds.T52PSetBonus, 0); if (t5 != null) - damagePerCombo += t5.GetAmount(); - - int finalDamage = damagePerCombo; - var costs = GetSpell().GetPowerCost(); - var c = costs.Find(cost => cost.Power == PowerType.ComboPoints); - if (c != null) - finalDamage *= c.Amount; - - SetHitDamage(finalDamage); + flatMod += t5.GetAmount(); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(CalculateDamage, 0, SpellEffectName.SchoolDamage)); + CalcDamage.Add(new(CalculateDamage)); } } - + [Script] // 193358 - Grand Melee class spell_rog_grand_melee : AuraScript { @@ -272,7 +335,7 @@ namespace Scripts.Spells.Rogue bool HandleCheckProc(ProcEventInfo eventInfo) { Spell procSpell = eventInfo.GetProcSpell(); - return procSpell && procSpell.HasPowerTypeCost(PowerType.ComboPoints); + return procSpell != null && procSpell.HasPowerTypeCost(PowerType.ComboPoints); } void HandleProc(AuraEffect aurEff, ProcEventInfo procInfo) @@ -297,13 +360,13 @@ namespace Scripts.Spells.Rogue public override void Register() { - DoCheckProc.Add(new CheckProcHandler(HandleCheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckProc.Add(new(HandleCheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } // 198031 - Honor Among Thieves - [Script] /// 7.1.5 + [Script] // 7.1.5 class spell_rog_honor_among_thieves : AuraScript { public override bool Validate(SpellInfo spellInfo) @@ -316,17 +379,70 @@ namespace Scripts.Spells.Rogue PreventDefaultAction(); Unit target = GetTarget(); - target.CastSpell(target, SpellIds.HonorAmongThievesEnergize, new CastSpellExtraArgs(aurEff)); + target.CastSpell(target, SpellIds.HonorAmongThievesEnergize, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } - + [Script] // 51690 - Killing Spree - class spell_rog_killing_spree_SpellScript : SpellScript + class spell_rog_killing_spree_AuraScript : AuraScript + { + List _targets = new(); + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.KillingSpreeTeleport, + SpellIds.KillingSpreeWeaponDmg, + SpellIds.KillingSpreeDmgBuff + ); + } + + void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + GetTarget().CastSpell(GetTarget(), SpellIds.KillingSpreeDmgBuff, true); + } + + void HandleEffectPeriodic(AuraEffect aurEff) + { + while (!_targets.Empty()) + { + ObjectGuid guid = _targets.SelectRandom(); + Unit target = ObjAccessor.GetUnit(GetTarget(), guid); + if (target != null) + { + GetTarget().CastSpell(target, SpellIds.KillingSpreeTeleport, true); + GetTarget().CastSpell(target, SpellIds.KillingSpreeWeaponDmg, true); + break; + } + else + _targets.Remove(guid); + } + } + + void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + GetTarget().RemoveAurasDueToSpell(SpellIds.KillingSpreeDmgBuff); + } + + public override void Register() + { + AfterEffectApply.Add(new(HandleApply, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); + OnEffectPeriodic.Add(new(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); + AfterEffectRemove.Add(new(HandleRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); + } + + public void AddTarget(Unit target) + { + _targets.Add(target.GetGUID()); + } + } + + [Script] + class spell_rog_killing_spree : SpellScript { void FilterTargets(List targets) { @@ -347,58 +463,22 @@ namespace Scripts.Spells.Rogue public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitDestAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 1, SpellEffectName.Dummy)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 1, Targets.UnitDestAreaEnemy)); + OnEffectHitTarget.Add(new(HandleDummy, 1, SpellEffectName.Dummy)); } } - [Script] - class spell_rog_killing_spree_AuraScript : AuraScript + [Script] // 385627 - Kingsbane + class spell_rog_kingsbane : AuraScript { - List _targets = new(); - - public override bool Validate(SpellInfo spellInfo) + bool CheckProc(AuraEffect aurEff, ProcEventInfo procInfo) { - return ValidateSpellInfo(SpellIds.KillingSpreeTeleport, SpellIds.KillingSpreeWeaponDmg, SpellIds.KillingSpreeDmgBuff); - } - - void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - GetTarget().CastSpell(GetTarget(), SpellIds.KillingSpreeDmgBuff, true); - } - - void HandleEffectPeriodic(AuraEffect aurEff) - { - while (!_targets.Empty()) - { - ObjectGuid guid = _targets.SelectRandom(); - Unit target = Global.ObjAccessor.GetUnit(GetTarget(), guid); - if (target != null) - { - GetTarget().CastSpell(target, SpellIds.KillingSpreeTeleport, true); - GetTarget().CastSpell(target, SpellIds.KillingSpreeWeaponDmg, true); - break; - } - else - _targets.Remove(guid); - } - } - - void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - GetTarget().RemoveAurasDueToSpell(SpellIds.KillingSpreeDmgBuff); + return procInfo.GetActionTarget().HasAura(GetId(), GetCasterGUID()); } public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); - } - - public void AddTarget(Unit target) - { - _targets.Add(target.GetGUID()); + DoCheckEffectProc.Add(new(CheckProc, 4, AuraType.ProcTriggerSpell)); } } @@ -412,20 +492,20 @@ namespace Scripts.Spells.Rogue bool HandleCheckProc(ProcEventInfo eventInfo) { - return eventInfo.GetDamageInfo() != null && eventInfo.GetDamageInfo().GetVictim() != null; + return eventInfo.GetDamageInfo()?.GetVictim(); } void HandleProc(AuraEffect aurEff, ProcEventInfo procInfo) { Unit target = GetTarget(); if (target != null) - target.CastSpell(procInfo.GetDamageInfo().GetVictim(), SpellIds.MainGauche, new CastSpellExtraArgs(aurEff)); + target.CastSpell(procInfo.GetDamageInfo().GetVictim(), SpellIds.MainGauche, aurEff); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(HandleCheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckProc.Add(new(HandleCheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -442,14 +522,37 @@ namespace Scripts.Spells.Rogue public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); + OnCheckCast.Add(new(CheckCast)); } } - + + // 131511 - Prey on the Weak + [Script] // Called by Cheap Shot - 1833 and Kidney Shot - 408 + class spell_rog_prey_on_the_weak : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.PreyOnTheWeakTalent, SpellIds.PreyOnTheWeak); + } + + void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit caster = GetCaster(); + if (caster != null) + if (caster.HasAura(SpellIds.PreyOnTheWeakTalent)) + caster.CastSpell(GetTarget(), SpellIds.PreyOnTheWeak, true); + } + + public override void Register() + { + AfterEffectApply.Add(new(OnApply, 0, AuraType.ModStun, AuraEffectHandleModes.Real)); + } + } + [Script] // 79096 - Restless Blades class spell_rog_restless_blades : AuraScript { - static uint[] Spells = { SpellIds.AdrenalineRush, SpellIds.BetweenTheEyes, SpellIds.Sprint, SpellIds.GrapplingHook, SpellIds.Vanish, SpellIds.KillingSpree, SpellIds.MarkedForDeath, SpellIds.DeathFromAbove }; + uint[] Spells = { SpellIds.AdrenalineRush, SpellIds.BetweenTheEyes, SpellIds.Sprint, SpellIds.GrapplingHook, SpellIds.Vanish, SpellIds.KillingSpree, SpellIds.MarkedForDeath, SpellIds.DeathFromAbove }; public override bool Validate(SpellInfo spellInfo) { @@ -458,10 +561,10 @@ namespace Scripts.Spells.Rogue void HandleProc(AuraEffect aurEff, ProcEventInfo procInfo) { - int? spentCP = procInfo.GetProcSpell()?.GetPowerTypeCostAmount(PowerType.ComboPoints); + var spentCP = Misc.GetFinishingMoveCPCost(procInfo.GetProcSpell()); if (spentCP.HasValue) { - int cdExtra = (int)-((float)(aurEff.GetAmount() * spentCP.Value) * 0.1f); + int cdExtra = -(int)((float)(aurEff.GetAmount() * spentCP.Value) * 0.1f); SpellHistory history = GetTarget().GetSpellHistory(); foreach (uint spellId in Spells) @@ -471,14 +574,14 @@ namespace Scripts.Spells.Rogue public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } [Script] // 315508 - Roll the Bones class spell_rog_roll_the_bones : SpellScript { - static uint[] Spells = { SpellIds.SkullAndCrossbones, SpellIds.GrandMelee, SpellIds.RuthlessPrecision, SpellIds.TrueBearing, SpellIds.BuriedTreasure, SpellIds.Broadside }; + uint[] Spells = { SpellIds.SkullAndCrossbones, SpellIds.GrandMelee, SpellIds.RuthlessPrecision, SpellIds.TrueBearing, SpellIds.BuriedTreasure, SpellIds.Broadside }; public override bool Validate(SpellInfo spellInfo) { @@ -498,7 +601,8 @@ namespace Scripts.Spells.Rogue } } - var possibleBuffs = Spells.Shuffle().ToArray(); + List possibleBuffs = new(Spells); + possibleBuffs.Shuffle(); // https://www.icy-veins.com/wow/outlaw-rogue-pve-dps-rotation-cooldowns-abilities // 1 Roll the Bones buff : 100.0 % chance; @@ -522,43 +626,18 @@ namespace Scripts.Spells.Rogue public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ApplyAura)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.ApplyAura)); } } [Script] // 1943 - Rupture - class spell_rog_rupture_AuraScript : AuraScript + class spell_rog_rupture : AuraScript { public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.VenomousWounds); } - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - Unit caster = GetCaster(); - if (caster != null) - { - canBeRecalculated = false; - - float[] attackpowerPerCombo = - { - 0.0f, - 0.015f, // 1 point: ${($m1 + $b1*1 + 0.015 * $AP) * 4} damage over 8 secs - 0.024f, // 2 points: ${($m1 + $b1*2 + 0.024 * $AP) * 5} damage over 10 secs - 0.03f, // 3 points: ${($m1 + $b1*3 + 0.03 * $AP) * 6} damage over 12 secs - 0.03428571f, // 4 points: ${($m1 + $b1*4 + 0.03428571 * $AP) * 7} damage over 14 secs - 0.0375f // 5 points: ${($m1 + $b1*5 + 0.0375 * $AP) * 8} damage over 16 secs - }; - - int cp = caster.GetPower(PowerType.ComboPoints); - if (cp > 5) - cp = 5; - - amount += (int)(caster.GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * attackpowerPerCombo[cp]); - } - } - void OnEffectRemoved(AuraEffect aurEff, AuraEffectHandleModes mode) { if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Death) @@ -566,7 +645,7 @@ namespace Scripts.Spells.Rogue Aura aura = GetAura(); Unit caster = aura.GetCaster(); - if (!caster) + if (caster == null) return; Aura auraVenomousWounds = caster.GetAura(SpellIds.VenomousWounds); @@ -574,19 +653,18 @@ namespace Scripts.Spells.Rogue return; // Venomous Wounds: if unit dies while being affected by rupture, regain energy based on remaining duration - SpellPowerCost cost = GetSpellInfo().CalcPowerCost(PowerType.Energy, false, caster, GetSpellInfo().GetSchoolMask(), null); + var cost = GetSpellInfo().CalcPowerCost(PowerType.Energy, false, caster, GetSpellInfo().GetSchoolMask(), null); if (cost == null) return; - float pct = (float)aura.GetDuration() / (float)aura.GetMaxDuration(); - int extraAmount = (int)((float)cost.Amount * pct); + float pct = (float)(aura.GetDuration()) / (float)(aura.GetMaxDuration()); + int extraAmount = (int)((float)(cost.Amount) * pct); caster.ModifyPower(PowerType.Energy, extraAmount); } public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.PeriodicDummy)); - OnEffectRemove.Add(new EffectApplyHandler(OnEffectRemoved, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(OnEffectRemoved, 0, AuraType.PeriodicDamage, AuraEffectHandleModes.Real)); } } @@ -597,30 +675,32 @@ namespace Scripts.Spells.Rogue { Unit target = GetTarget(); - int? cost = procInfo.GetProcSpell()?.GetPowerTypeCostAmount(PowerType.ComboPoints); + var cost = Misc.GetFinishingMoveCPCost(procInfo.GetProcSpell()); if (cost.HasValue) - if (RandomHelper.randChance(aurEff.GetSpellEffectInfo().PointsPerResource * (cost.Value))) + if (RandomHelper.randChance(aurEff.GetSpellEffectInfo().PointsPerResource * cost.Value)) target.ModifyPower(PowerType.ComboPoints, 1); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } [Script] // 185438 - Shadowstrike class spell_rog_shadowstrike : SpellScript { + bool _hasPremeditationAura; + public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.PremeditationAura, SpellIds.SliceAndDice, SpellIds.PremeditationPassive) - && ValidateSpellEffect(SpellIds.PremeditationPassive, 0); + && ValidateSpellEffect((SpellIds.PremeditationPassive, 0)); } SpellCastResult HandleCheckCast() { - // Because the premeditation aura is removed when we're out of stealth, + // Because the premeditation aura is Removed when we're out of stealth, // when we reach HandleEnergize the aura won't be there, even if it was when player launched the spell _hasPremeditationAura = GetCaster().HasAura(SpellIds.PremeditationAura); return SpellCastResult.Success; @@ -643,7 +723,7 @@ namespace Scripts.Spells.Rogue } // Grant 10 seconds of slice and dice - int duration = Global.SpellMgr.GetSpellInfo(SpellIds.PremeditationPassive, Difficulty.None).GetEffect(0).CalcValue(GetCaster()); + int duration = SpellMgr.GetSpellInfo(SpellIds.PremeditationPassive, Difficulty.None).GetEffect(0).CalcValue(GetCaster()); CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); args.AddSpellMod(SpellValueMod.Duration, duration * Time.InMilliseconds); @@ -653,11 +733,9 @@ namespace Scripts.Spells.Rogue public override void Register() { - OnCheckCast.Add(new CheckCastHandler(HandleCheckCast)); - OnEffectHitTarget.Add(new EffectHandler(HandleEnergize, 1, SpellEffectName.Energize)); + OnCheckCast.Add(new(HandleCheckCast)); + OnEffectHitTarget.Add(new(HandleEnergize, 1, SpellEffectName.Energize)); } - - bool _hasPremeditationAura = false; } [Script] // 193315 - Sinister Strike @@ -665,28 +743,28 @@ namespace Scripts.Spells.Rogue { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.T52pSetBonus); + return ValidateSpellInfo(SpellIds.T52PSetBonus); } void HandleDummy(uint effIndex) { int damagePerCombo = GetHitDamage(); - AuraEffect t5 = GetCaster().GetAuraEffect(SpellIds.T52pSetBonus, 0); + AuraEffect t5 = GetCaster().GetAuraEffect(SpellIds.T52PSetBonus, 0); if (t5 != null) damagePerCombo += t5.GetAmount(); int finalDamage = damagePerCombo; - var costs = GetSpell().GetPowerCost(); - var c = costs.Find(cost => cost.Power == PowerType.ComboPoints); - if (c != null) - finalDamage *= c.Amount; + List cost = GetSpell().GetPowerCost(); + var c = cost.Find(cost => cost.Power == PowerType.ComboPoints); + if (c != null) + finalDamage *= c.Amount; - SetHitDamage(finalDamage); - } + SetHitDamage(finalDamage); + } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 2, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 2, SpellEffectName.Dummy)); } } @@ -695,58 +773,65 @@ namespace Scripts.Spells.Rogue { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.MasterOfSubtletyPassive, SpellIds.MasterOfSubtletyDamagePercent, SpellIds.Sanctuary, SpellIds.ShadowFocus, SpellIds.ShadowFocusEffect, SpellIds.StealthStealthAura, SpellIds.StealthShapeshiftAura); - } + return ValidateSpellInfo(SpellIds.MasterOfSubtletyPassive, + SpellIds.MasterOfSubtletyDamagePercent, + SpellIds.Sanctuary, + SpellIds.ShadowFocus, + SpellIds.ShadowFocusEffect, + SpellIds.StealthStealthAura, + SpellIds.StealthShapeshiftAura + ); + } - void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode) + void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit target = GetTarget(); + + // Master of Subtlety + if (target.HasAura(SpellIds.MasterOfSubtletyPassive)) + target.CastSpell(target, SpellIds.MasterOfSubtletyDamagePercent, TriggerCastFlags.FullMask); + + // Shadow Focus + if (target.HasAura(SpellIds.ShadowFocus)) + target.CastSpell(target, SpellIds.ShadowFocusEffect, TriggerCastFlags.FullMask); + + // Premeditation + if (target.HasAura(SpellIds.PremeditationPassive)) + target.CastSpell(target, SpellIds.PremeditationAura, true); + + target.CastSpell(target, SpellIds.Sanctuary, TriggerCastFlags.FullMask); + target.CastSpell(target, SpellIds.StealthStealthAura, TriggerCastFlags.FullMask); + target.CastSpell(target, SpellIds.StealthShapeshiftAura, TriggerCastFlags.FullMask); + } + + void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit target = GetTarget(); + + // Master of Subtlety + AuraEffect masterOfSubtletyPassive = GetTarget().GetAuraEffect(SpellIds.MasterOfSubtletyPassive, 0); + if (masterOfSubtletyPassive != null) { - Unit target = GetTarget(); - - // Master of Subtlety - if (target.HasAura(SpellIds.MasterOfSubtletyPassive)) - target.CastSpell(target, SpellIds.MasterOfSubtletyDamagePercent, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); - - // Shadow Focus - if (target.HasAura(SpellIds.ShadowFocus)) - target.CastSpell(target, SpellIds.ShadowFocusEffect, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); - - // Premeditation - if (target.HasAura(SpellIds.PremeditationPassive)) - target.CastSpell(target, SpellIds.PremeditationAura, true); - - target.CastSpell(target, SpellIds.Sanctuary, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); - target.CastSpell(target, SpellIds.StealthStealthAura, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); - target.CastSpell(target, SpellIds.StealthShapeshiftAura, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); - } - - void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit target = GetTarget(); - - // Master of Subtlety - AuraEffect masterOfSubtletyPassive = GetTarget().GetAuraEffect(SpellIds.MasterOfSubtletyPassive, 0); - if (masterOfSubtletyPassive != null) + Aura masterOfSubtletyAura = GetTarget().GetAura(SpellIds.MasterOfSubtletyDamagePercent); + if (masterOfSubtletyAura != null) { - Aura masterOfSubtletyAura = GetTarget().GetAura(SpellIds.MasterOfSubtletyDamagePercent); - if (masterOfSubtletyAura != null) - { - masterOfSubtletyAura.SetMaxDuration(masterOfSubtletyPassive.GetAmount()); - masterOfSubtletyAura.RefreshDuration(); - } + masterOfSubtletyAura.SetMaxDuration(masterOfSubtletyPassive.GetAmount()); + masterOfSubtletyAura.RefreshDuration(); } - - // Premeditation - target.RemoveAura(SpellIds.PremeditationAura); - - target.RemoveAurasDueToSpell(SpellIds.ShadowFocusEffect); - target.RemoveAurasDueToSpell(SpellIds.StealthStealthAura); - target.RemoveAurasDueToSpell(SpellIds.StealthShapeshiftAura); } + // Premeditation + target.RemoveAura(SpellIds.PremeditationAura); + + target.RemoveAurasDueToSpell(SpellIds.ShadowFocusEffect); + target.RemoveAurasDueToSpell(SpellIds.StealthStealthAura); + target.RemoveAurasDueToSpell(SpellIds.StealthShapeshiftAura); + } + public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectApply.Add(new(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(HandleEffectRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -766,13 +851,15 @@ namespace Scripts.Spells.Rogue public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleEffectHitTarget, 0, SpellEffectName.ApplyAura)); + OnEffectHitTarget.Add(new(HandleEffectHitTarget, 0, SpellEffectName.ApplyAura)); } } [Script] // 57934 - Tricks of the Trade - class spell_rog_tricks_of_the_trade_aura : AuraScript + class spell_rog_tricks_of_the_trade_AuraScript : AuraScript { + ObjectGuid _redirectTarget; + public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.TricksOfTheTradeProc); @@ -789,19 +876,17 @@ namespace Scripts.Spells.Rogue PreventDefaultAction(); Unit rogue = GetTarget(); - if (Global.ObjAccessor.GetUnit(rogue, _redirectTarget)) - rogue.CastSpell(rogue, SpellIds.TricksOfTheTradeProc, new CastSpellExtraArgs(aurEff)); + if (ObjAccessor.GetUnit(rogue, _redirectTarget) != null) + rogue.CastSpell(rogue, SpellIds.TricksOfTheTradeProc, aurEff); Remove(AuraRemoveMode.Default); } public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); + AfterEffectRemove.Add(new(OnRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectProc.Add(new(HandleProc, 1, AuraType.Dummy)); } - ObjectGuid _redirectTarget; - public void SetRedirectTarget(ObjectGuid guid) { _redirectTarget = guid; } } @@ -813,11 +898,11 @@ namespace Scripts.Spells.Rogue Aura aura = GetHitAura(); if (aura != null) { - spell_rog_tricks_of_the_trade_aura script = aura.GetScript(); + var script = aura.GetScript(); if (script != null) { Unit explTarget = GetExplTargetUnit(); - if (explTarget != null) + if (explTarget) script.SetRedirectTarget(explTarget.GetGUID()); else script.SetRedirectTarget(ObjectGuid.Empty); @@ -827,7 +912,7 @@ namespace Scripts.Spells.Rogue public override void Register() { - AfterHit.Add(new HitHandler(DoAfterHit)); + AfterHit.Add(new(DoAfterHit)); } } @@ -841,7 +926,7 @@ namespace Scripts.Spells.Rogue public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(HandleRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } @@ -850,12 +935,12 @@ namespace Scripts.Spells.Rogue { bool CheckForStun(AuraEffect aurEff, ProcEventInfo eventInfo) { - return eventInfo.GetProcSpell() && eventInfo.GetProcSpell().GetSpellInfo().HasAura(AuraType.ModStun); + return eventInfo.GetProcSpell() != null && eventInfo.GetProcSpell().GetSpellInfo().HasAura(AuraType.ModStun); } public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckForStun, 0, AuraType.ProcTriggerSpell)); + DoCheckEffectProc.Add(new(CheckForStun, 0, AuraType.ProcTriggerSpell)); } } @@ -872,7 +957,7 @@ namespace Scripts.Spells.Rogue Unit target = GetTarget(); if (!target.HasAuraType(AuraType.ModStun)) { - target.CastSpell(target, SpellIds.TurnTheTablesBuff, new CastSpellExtraArgs(aurEff)); + target.CastSpell(target, SpellIds.TurnTheTablesBuff, aurEff); PreventDefaultAction(); Remove(); } @@ -880,11 +965,11 @@ namespace Scripts.Spells.Rogue public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(CheckForStun, 0, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(CheckForStun, 0, AuraType.PeriodicDummy)); } } - [Script] // 1856 - Vanish - SPELL_ROGUE_VANISH + [Script] // 1856 - Vanish - SpellIds.Vanish class spell_rog_vanish : SpellScript { public override bool Validate(SpellInfo spellInfo) @@ -905,18 +990,18 @@ namespace Scripts.Spells.Rogue if (target.HasAura(SpellIds.VanishAura)) return; - target.CastSpell(target, SpellIds.VanishAura, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); - target.CastSpell(target, SpellIds.StealthShapeshiftAura, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + target.CastSpell(target, SpellIds.VanishAura, TriggerCastFlags.FullMask); + target.CastSpell(target, SpellIds.StealthShapeshiftAura, TriggerCastFlags.FullMask); } public override void Register() { - OnEffectLaunchTarget.Add(new EffectHandler(OnLaunchTarget, 1, SpellEffectName.TriggerSpell)); + OnEffectLaunchTarget.Add(new(OnLaunchTarget, 1, SpellEffectName.TriggerSpell)); } } [Script] // 11327 - Vanish - class spell_rog_vanish_aura : AuraScript + class spell_rog_vanish_AuraScript : AuraScript { public override bool Validate(SpellInfo spellInfo) { @@ -925,16 +1010,16 @@ namespace Scripts.Spells.Rogue void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - GetTarget().CastSpell(GetTarget(), SpellIds.Stealth, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + GetTarget().CastSpell(GetTarget(), SpellIds.Stealth, TriggerCastFlags.FullMask); } public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(HandleEffectRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } - [Script] // 79134 - Venomous Wounds - SPELL_ROGUE_VENOMOUS_WOUNDS + [Script] // 79134 - Venomous Wounds - SpellIds.VenomousWounds class spell_rog_venomous_wounds : AuraScript { void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -945,7 +1030,7 @@ namespace Scripts.Spells.Rogue public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 1, AuraType.Dummy)); } } -} +} \ No newline at end of file diff --git a/Source/Scripts/Spells/Shaman.cs b/Source/Scripts/Spells/Shaman.cs index 6bca76806..abd5d88d3 100644 --- a/Source/Scripts/Spells/Shaman.cs +++ b/Source/Scripts/Spells/Shaman.cs @@ -1,29 +1,35 @@ -// Copyright (c) CypherCore All rights reserved. +// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; using Framework.Dynamic; using Game.AI; using Game.Entities; -using Game.Maps; using Game.Scripting; using Game.Spells; using System; using System.Collections.Generic; +using static Global; + namespace Scripts.Spells.Shaman { + struct SpellIds { public const uint AftershockEnergize = 210712; public const uint AncestralGuidance = 108281; public const uint AncestralGuidanceHeal = 114911; + public const uint AscendanceElemental = 114050; + public const uint AscendanceEnhancement = 114051; + public const uint AscendanceRestoration = 114052; public const uint ChainLightning = 188443; public const uint ChainLightningEnergize = 195897; public const uint ChainLightningOverload = 45297; public const uint ChainLightningOverloadEnergize = 218558; public const uint ChainedHeal = 70809; public const uint CrashLightningCleave = 187878; + public const uint DoomWindsLegendaryCooldown = 335904; public const uint Earthquake = 61882; public const uint EarthquakeKnockingDown = 77505; public const uint EarthquakeTick = 77478; @@ -31,6 +37,8 @@ namespace Scripts.Spells.Shaman public const uint EarthenRagePassive = 170374; public const uint EarthenRagePeriodic = 170377; public const uint EarthenRageDamage = 170379; + public const uint EchoesOfGreatSunderingLegendary = 336217; + public const uint EchoesOfGreatSunderingTalent = 384088; public const uint Electrified = 64930; public const uint ElementalBlast = 117014; public const uint ElementalBlastCrit = 118522; @@ -72,25 +80,28 @@ namespace Scripts.Spells.Shaman public const uint PathOfFlamesSpread = 210621; public const uint PathOfFlamesTalent = 201909; public const uint PowerSurge = 40466; + public const uint RestorativeMists = 114083; + public const uint RestorativeMistsInitial = 294020; + public const uint Riptide = 61295; public const uint SpiritWolfTalent = 260878; public const uint SpiritWolfPeriodic = 260882; public const uint SpiritWolfAura = 260881; public const uint Stormkeeper = 191634; + public const uint Stormstrike = 17364; + public const uint T292PElementalDamageBuff = 394651; public const uint TidalWaves = 53390; + public const uint TotemicPowerArmor = 28827; + public const uint TotemicPowerAttackPower = 28826; public const uint TotemicPowerMp5 = 28824; public const uint TotemicPowerSpellPower = 28825; - public const uint TotemicPowerAttackPower = 28826; - public const uint TotemicPowerArmor = 28827; public const uint UndulationProc = 216251; public const uint UnlimitedPowerBuff = 272737; + public const uint VolcanicSurge = 408572; public const uint WindfuryAttack = 25504; public const uint WindfuryEnchantment = 334302; public const uint WindRush = 192082; - } - struct CreatureIds - { - public const uint HealingRainInvisibleStalker = 73400; + public const uint LabelShamanWindfuryTotem = 1038; } [Script] // 273221 - Aftershock @@ -106,9 +117,9 @@ namespace Scripts.Spells.Shaman Spell procSpell = eventInfo.GetProcSpell(); if (procSpell != null) { - int? cost = procSpell.GetPowerTypeCostAmount(PowerType.Maelstrom); + var cost = procSpell.GetPowerTypeCostAmount(PowerType.Maelstrom); if (cost.HasValue) - return cost > 0 && RandomHelper.randChance(aurEff.GetAmount()); + return cost.Value > 0 && RandomHelper.randChance(aurEff.GetAmount()); } return false; @@ -119,14 +130,14 @@ namespace Scripts.Spells.Shaman Spell procSpell = eventInfo.GetProcSpell(); int? energize = procSpell.GetPowerTypeCostAmount(PowerType.Maelstrom); - eventInfo.GetActor().CastSpell(eventInfo.GetActor(), SpellIds.AftershockEnergize, new CastSpellExtraArgs(energize != 0) + eventInfo.GetActor().CastSpell(eventInfo.GetActor(), SpellIds.AftershockEnergize, new CastSpellExtraArgs(energize.HasValue) .AddSpellMod(SpellValueMod.BasePoint0, energize.Value)); } public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckProc, 0, AuraType.Dummy)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.Dummy)); } } @@ -140,15 +151,19 @@ namespace Scripts.Spells.Shaman bool CheckProc(ProcEventInfo eventInfo) { - if (eventInfo.GetHealInfo().GetSpellInfo().Id == SpellIds.AncestralGuidanceHeal) + if (eventInfo.GetHealInfo() != null && eventInfo.GetSpellInfo() != null && eventInfo.GetSpellInfo().Id == SpellIds.AncestralGuidanceHeal) return false; + + if (eventInfo.GetHealInfo() == null && eventInfo.GetDamageInfo() == null) + return false; + return true; } void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - int bp0 = MathFunctions.CalculatePct((int)eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()); + int bp0 = MathFunctions.CalculatePct((int)(eventInfo.GetDamageInfo() != null ? eventInfo.GetDamageInfo().GetDamage() : eventInfo.GetHealInfo().GetHeal()), aurEff.GetAmount()); if (bp0 != 0) { CastSpellExtraArgs args = new(aurEff); @@ -159,8 +174,8 @@ namespace Scripts.Spells.Shaman public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.PeriodicDummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.PeriodicDummy)); } } @@ -179,7 +194,46 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(ResizeTargets, 0, Targets.UnitDestAreaAlly)); + OnObjectAreaTargetSelect.Add(new(ResizeTargets, 0, Targets.UnitDestAreaAlly)); + } + } + + [Script] // 114052 - Ascendance (Restoration) + class spell_sha_ascendance_restoration : AuraScript + { + uint _healToDistribute; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.RestorativeMists); + } + + bool CheckProc(ProcEventInfo procInfo) + { + return procInfo.GetHealInfo() != null && procInfo.GetHealInfo().GetOriginalHeal() != 0 && procInfo.GetSpellInfo().Id != SpellIds.RestorativeMistsInitial; + } + + void OnProcHeal(AuraEffect aurEff, ProcEventInfo procInfo) + { + _healToDistribute += procInfo.GetHealInfo().GetOriginalHeal(); + } + + void HandleEffectPeriodic(AuraEffect aurEff) + { + if (_healToDistribute == 0) + return; + + CastSpellExtraArgs args = new(aurEff); + args.AddSpellMod(SpellValueMod.BasePoint0, (int)_healToDistribute); + GetTarget().CastSpell(null, SpellIds.RestorativeMists, args); + _healToDistribute = 0; + } + + public override void Register() + { + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(OnProcHeal, 1, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandleEffectPeriodic, 1, AuraType.PeriodicDummy)); } } @@ -189,7 +243,7 @@ namespace Scripts.Spells.Shaman public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.ChainLightningEnergize, SpellIds.MaelstromController) - && ValidateSpellEffect(SpellIds.MaelstromController, 4); + && ValidateSpellEffect((SpellIds.MaelstromController, 4)); } void HandleScript(uint effIndex) @@ -202,7 +256,7 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnEffectLaunch.Add(new EffectHandler(HandleScript, 0, SpellEffectName.SchoolDamage)); + OnEffectLaunch.Add(new(HandleScript, 0, SpellEffectName.SchoolDamage)); } } @@ -212,7 +266,7 @@ namespace Scripts.Spells.Shaman public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.ChainLightningOverloadEnergize, SpellIds.MaelstromController) - && ValidateSpellEffect(SpellIds.MaelstromController, 5); + && ValidateSpellEffect((SpellIds.MaelstromController, 5)); } void HandleScript(uint effIndex) @@ -225,16 +279,18 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnEffectLaunch.Add(new EffectHandler(HandleScript, 0, SpellEffectName.SchoolDamage)); + OnEffectLaunch.Add(new(HandleScript, 0, SpellEffectName.SchoolDamage)); } } [Script] // 187874 - Crash Lightning class spell_sha_crash_lightning : SpellScript { + int _targetsHit; + public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.CrashLightningCleave); + return ValidateSpellInfo(SpellIds.CrashLightningCleave, SpellIds.GatheringStorms, SpellIds.GatheringStormsBuff); } void CountTargets(List targets) @@ -251,28 +307,128 @@ namespace Scripts.Spells.Shaman if (gatheringStorms != null) { CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); - args.AddSpellMod(SpellValueMod.BasePoint0, (int)(gatheringStorms.GetAmount() * _targetsHit)); + args.AddSpellMod(SpellValueMod.BasePoint0, gatheringStorms.GetAmount() * _targetsHit); GetCaster().CastSpell(GetCaster(), SpellIds.GatheringStormsBuff, args); } } public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(CountTargets, 0, Targets.UnitConeCasterToDestEnemy)); - AfterCast.Add(new CastHandler(TriggerCleaveBuff)); + OnObjectAreaTargetSelect.Add(new(CountTargets, 0, Targets.UnitConeCasterToDestEnemy)); + AfterCast.Add(new(TriggerCleaveBuff)); + } + } + + [Script] // 378270 - Deeply Rooted Elements + class spell_sha_deeply_rooted_elements : AuraScript + { + uint requiredSpellId; + uint ascendanceSpellId; + int _procAttempts; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.LavaBurst, SpellIds.Stormstrike, SpellIds.Riptide, SpellIds.AscendanceElemental, SpellIds.AscendanceEnhancement, SpellIds.AscendanceRestoration) + && ValidateSpellEffect((spellInfo.Id, 0)) + && spellInfo.GetEffect(0).IsAura(); } - int _targetsHit; + public override bool Load() + { + return GetUnitOwner().IsPlayer(); + } + + bool CheckProc(AuraEffect aurEff, ProcEventInfo procInfo) + { + if (procInfo.GetSpellInfo() == null) + return false; + + if (procInfo.GetSpellInfo().Id != requiredSpellId) + return false; + + return RandomHelper.randChance(_procAttempts++ - 2); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + _procAttempts = 0; + + Unit target = eventInfo.GetActor(); + + int duration = GetEffect(0).GetAmount(); + Aura ascendanceAura = target.GetAura(ascendanceSpellId); + if (ascendanceAura != null) + duration += ascendanceAura.GetDuration(); + + target.CastSpell(target, ascendanceSpellId, + new CastSpellExtraArgs(TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreSpellAndCategoryCD | TriggerCastFlags.IgnoreCastInProgress) + .SetTriggeringAura(aurEff) + .SetTriggeringSpell(eventInfo.GetProcSpell()) + .AddSpellMod(SpellValueMod.Duration, duration)); + } + + public override void Register() + { + if (GetAura() == null || GetUnitOwner().ToPlayer().GetPrimarySpecialization() == ChrSpecialization.ShamanElemental) + { + requiredSpellId = SpellIds.LavaBurst; + ascendanceSpellId = SpellIds.AscendanceElemental; + DoCheckEffectProc.Add(new(CheckProc, 1, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 1, AuraType.Dummy)); + } + + if (GetAura() == null || GetUnitOwner().ToPlayer().GetPrimarySpecialization() == ChrSpecialization.ShamanEnhancement) + { + requiredSpellId = SpellIds.Stormstrike; + ascendanceSpellId = SpellIds.AscendanceEnhancement; + DoCheckEffectProc.Add(new(CheckProc, 2, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 2, AuraType.Dummy)); + } + + if (GetAura() == null || GetUnitOwner().ToPlayer().GetPrimarySpecialization() == ChrSpecialization.ShamanRestoration) + { + requiredSpellId = SpellIds.Riptide; + ascendanceSpellId = SpellIds.AscendanceRestoration; + DoCheckEffectProc.Add(new(CheckProc, 3, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 3, AuraType.Dummy)); + } + } + } + + [Script] // 335902 - Doom Winds + class spell_sha_doom_winds_legendary : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.DoomWindsLegendaryCooldown); + } + + bool CheckProc(AuraEffect aurEff, ProcEventInfo procInfo) + { + if (GetTarget().HasAura(SpellIds.DoomWindsLegendaryCooldown)) + return false; + + SpellInfo spellInfo = procInfo.GetSpellInfo(); + if (spellInfo == null) + return false; + + return spellInfo.HasLabel(SpellIds.LabelShamanWindfuryTotem); + } + + public override void Register() + { + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.ProcTriggerSpell)); + } } [Script] // 207778 - Downpour class spell_sha_downpour : SpellScript { - int _healedTargets = 0; + int _healedTargets; public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellEffect(spellInfo.Id, 1); + return ValidateSpellEffect((spellInfo.Id, 1)); } void FilterTargets(List targets) @@ -295,9 +451,9 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); - AfterHit.Add(new HitHandler(CountEffectivelyHealedTarget)); - AfterCast.Add(new CastHandler(HandleCooldown)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitDestAreaAlly)); + AfterHit.Add(new(CountEffectivelyHealedTarget)); + AfterCast.Add(new(HandleCooldown)); } } @@ -320,18 +476,43 @@ namespace Scripts.Spells.Shaman { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.EarthShieldHeal, new CastSpellExtraArgs(aurEff).SetOriginalCaster(GetCasterGUID())); + GetTarget().CastSpell(GetTarget(), SpellIds.EarthShieldHeal, new CastSpellExtraArgs(aurEff) + .SetOriginalCaster(GetCasterGUID())); } public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 1, AuraType.Dummy)); + } + } + + [Script] // 8042 - Earth Shock + class spell_sha_earth_shock : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellEffect((SpellIds.T292PElementalDamageBuff, 0)); + } + + void AddScriptedDamageMods() + { + AuraEffect t29 = GetCaster().GetAuraEffect(SpellIds.T292PElementalDamageBuff, 0); + if (t29 != null) + { + SetHitDamage(MathFunctions.CalculatePct(GetHitDamage(), 100 + t29.GetAmount())); + t29.GetBase().Remove(); + } + } + + public override void Register() + { + OnHit.Add(new(AddScriptedDamageMods)); } } [Script] // 170374 - Earthen Rage (Passive) - public class spell_sha_earthen_rage_passive : AuraScript + class spell_sha_earthen_rage_passive : AuraScript { public override bool Validate(SpellInfo spellInfo) { @@ -352,20 +533,20 @@ namespace Scripts.Spells.Shaman public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.Dummy)); } + ObjectGuid _procTargetGuid; + public ObjectGuid GetProcTargetGuid() { return _procTargetGuid; } - - ObjectGuid _procTargetGuid; } [Script] // 170377 - Earthen Rage (Proc Aura) - class spell_sha_earthen_rage_proc_aura : AuraScript + class spell_sha_earthen_rage_proc_AuraScript : AuraScript { public override bool Validate(SpellInfo spellInfo) { @@ -378,20 +559,19 @@ namespace Scripts.Spells.Shaman Aura aura = GetCaster().GetAura(SpellIds.EarthenRagePassive); if (aura != null) { - var earthen_rage_script = aura.GetScript(); - if (earthen_rage_script != null) + spell_sha_earthen_rage_passive script = aura.GetScript(); + if (script != null) { - Unit procTarget = Global.ObjAccessor.GetUnit(GetCaster(), earthen_rage_script.GetProcTargetGuid()); - if (procTarget) + Unit procTarget = ObjAccessor.GetUnit(GetCaster(), script.GetProcTargetGuid()); + if (procTarget != null) GetTarget().CastSpell(procTarget, SpellIds.EarthenRageDamage, true); - } } } public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); } } @@ -402,11 +582,13 @@ namespace Scripts.Spells.Shaman TimeSpan _refreshTimer; TimeSpan _period; HashSet _stunnedUnits = new(); + float _damageMultiplier; public areatrigger_sha_earthquake(AreaTrigger areatrigger) : base(areatrigger) { - _refreshTimer = TimeSpan.Zero; + _refreshTimer = TimeSpan.FromSeconds(0); _period = TimeSpan.FromSeconds(1); + _damageMultiplier = 1.0f; } public override void OnCreate(Spell creatingSpell) @@ -418,17 +600,25 @@ namespace Scripts.Spells.Shaman if (earthquake != null) _period = TimeSpan.FromMilliseconds(earthquake.GetPeriod()); } + + if (creatingSpell != null) + { + float damageMultiplier = (float)creatingSpell.m_customArg; + if (damageMultiplier != 0) + _damageMultiplier = damageMultiplier; + } } public override void OnUpdate(uint diff) { _refreshTimer -= TimeSpan.FromMilliseconds(diff); - while (_refreshTimer <= TimeSpan.Zero) + while (_refreshTimer <= TimeSpan.FromSeconds(0)) { Unit caster = at.GetCaster(); if (caster != null) caster.CastSpell(at.GetPosition(), SpellIds.EarthquakeTick, new CastSpellExtraArgs(TriggerCastFlags.FullMask) - .SetOriginalCaster(at.GetGUID())); + .SetOriginalCaster(at.GetGUID()) + .AddSpellMod(SpellValueMod.BasePoint0, (int)(caster.SpellBaseDamageBonusDone(SpellSchoolMask.Nature) * 0.213f * _damageMultiplier))); _refreshTimer += _period; } @@ -441,17 +631,51 @@ namespace Scripts.Spells.Shaman } } + [Script] // 61882 - Earthquake + class spell_sha_earthquake : SpellScript + { + (uint, uint)[] DamageBuffs = + { + (SpellIds.EchoesOfGreatSunderingLegendary, 1), + (SpellIds.EchoesOfGreatSunderingTalent, 0), + (SpellIds.T292PElementalDamageBuff, 0) + }; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellEffect(DamageBuffs); + } + + void SnapshotDamageMultiplier(uint effIndex) + { + float damageMultiplier = 1.0f; + foreach (var (spellId, effect) in DamageBuffs) + { + AuraEffect buff = GetCaster().GetAuraEffect(spellId, effect); + if (buff != null) + { + MathFunctions.AddPct(ref damageMultiplier, buff.GetAmount()); + buff.GetBase().Remove(); + } + } + + if (damageMultiplier != 1.0f) + GetSpell().m_customArg = damageMultiplier; + } + + public override void Register() + { + OnEffectLaunch.Add(new(SnapshotDamageMultiplier, 2, SpellEffectName.CreateAreaTrigger)); + } + } + [Script] // 77478 - Earthquake tick class spell_sha_earthquake_tick : SpellScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.EarthquakeKnockingDown) && ValidateSpellEffect(spellInfo.Id, 1); - } - - void HandleDamageCalc(uint effIndex) - { - SetEffectValue((int)(GetCaster().SpellBaseDamageBonusDone(SpellSchoolMask.Nature) * 0.391f)); + return ValidateSpellInfo(SpellIds.EarthquakeKnockingDown) + && ValidateSpellEffect((spellInfo.Id, 1)); } void HandleOnHit() @@ -461,11 +685,11 @@ namespace Scripts.Spells.Shaman { if (RandomHelper.randChance(GetEffectInfo(1).CalcValue())) { - var areaTriggers = GetCaster().GetAreaTriggers(SpellIds.Earthquake); - var foundAreaTrigger = areaTriggers.Find(at => at.GetGUID() == GetSpell().GetOriginalCasterGUID()); - if (foundAreaTrigger != null) + List areaTriggers = GetCaster().GetAreaTriggers(SpellIds.Earthquake); + var areaTrigger = areaTriggers.Find(at => at.GetGUID() == GetSpell().GetOriginalCasterGUID()); + if (areaTrigger != null) { - areatrigger_sha_earthquake eq = foundAreaTrigger.GetAI(); + areatrigger_sha_earthquake eq = areaTrigger.GetAI(); if (eq != null) if (eq.AddStunnedTarget(target.GetGUID())) GetCaster().CastSpell(target, SpellIds.EarthquakeKnockingDown, true); @@ -476,11 +700,10 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnEffectLaunchTarget.Add(new EffectHandler(HandleDamageCalc, 0, SpellEffectName.SchoolDamage)); - OnHit.Add(new HitHandler(HandleOnHit)); + OnHit.Add(new(HandleOnHit)); } } - + // 117014 - Elemental Blast [Script] // 120588 - Elemental Blast Overload class spell_sha_elemental_blast : SpellScript @@ -489,8 +712,8 @@ namespace Scripts.Spells.Shaman public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.ElementalBlastCrit, SpellIds.ElementalBlastHaste, SpellIds.ElementalBlastMastery, SpellIds.MaelstromController) - && ValidateSpellEffect(SpellIds.MaelstromController, 10); + return ValidateSpellInfo(SpellIds.ElementalBlastCrit, SpellIds.ElementalBlastHaste, SpellIds.ElementalBlastMastery, SpellIds.ElementalBlastEnergize, SpellIds.MaelstromController) + && ValidateSpellEffect((SpellIds.MaelstromController, 10), (SpellIds.T292PElementalDamageBuff, 0)); } void HandleEnergize(uint effIndex) @@ -504,18 +727,26 @@ namespace Scripts.Spells.Shaman void TriggerBuff() { Unit caster = GetCaster(); - uint spellId = BuffSpells.SelectRandomElementByWeight(buffSpellId => - { - return !caster.HasAura(buffSpellId) ? 1.0f : 0.0f; - }); + uint spellId = BuffSpells.SelectRandomElementByWeight(buffSpellId => !caster.HasAura(buffSpellId) ? 1.0f : 0.0f); - GetCaster().CastSpell(GetCaster(), spellId, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + GetCaster().CastSpell(GetCaster(), spellId, TriggerCastFlags.FullMask); + } + + void AddScriptedDamageMods() + { + AuraEffect t29 = GetCaster().GetAuraEffect(SpellIds.T292PElementalDamageBuff, 0); + if (t29 != null) + { + SetHitDamage(MathFunctions.CalculatePct(GetHitDamage(), 100 + t29.GetAmount())); + t29.GetBase().Remove(); + } } public override void Register() { - OnEffectLaunch.Add(new EffectHandler(HandleEnergize, 0, SpellEffectName.SchoolDamage)); - AfterCast.Add(new CastHandler(TriggerBuff)); + OnEffectLaunch.Add(new(HandleEnergize, 0, SpellEffectName.SchoolDamage)); + AfterCast.Add(new(TriggerBuff)); + OnHit.Add(new(AddScriptedDamageMods)); } } @@ -529,14 +760,13 @@ namespace Scripts.Spells.Shaman public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } - void HandleEffectHitTarget(uint index) + void HandleEffectHitTarget(uint effIndex) { Player player = GetCaster().ToPlayer(); byte slot = EquipmentSlot.MainHand; - if (player.GetPrimarySpecialization() == ChrSpecialization.ShamanEnhancement) slot = EquipmentSlot.OffHand; @@ -544,16 +774,16 @@ namespace Scripts.Spells.Shaman if (targetItem == null || !targetItem.GetTemplate().IsWeapon()) return; - GetCaster().CastSpell(targetItem, SpellIds.FlametongueWeaponEnchant, true); + player.CastSpell(targetItem, SpellIds.FlametongueWeaponEnchant, true); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleEffectHitTarget, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleEffectHitTarget, 0, SpellEffectName.Dummy)); } } - [Script] // 319778 - Flametongue + [Script] // 319778 - Flametongue - SpellIds.FlametongueWeaponAura class spell_sha_flametongue_weapon_AuraScript : AuraScript { public override bool Validate(SpellInfo spellInfo) @@ -573,38 +803,7 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); - } - } - - [Script] // 73920 - Healing Rain - class spell_sha_healing_rain : SpellScript - { - void InitializeVisualStalker() - { - Aura aura = GetHitAura(); - if (aura != null) - { - WorldLocation dest = GetExplTargetDest(); - if (dest != null) - { - TimeSpan duration = TimeSpan.FromMilliseconds(GetSpellInfo().CalcDuration(GetOriginalCaster())); - TempSummon summon = GetCaster().GetMap().SummonCreature(CreatureIds.HealingRainInvisibleStalker, dest, null, duration, GetOriginalCaster()); - if (summon == null) - return; - - summon.CastSpell(summon, SpellIds.HealingRainVisual, true); - - var script = aura.GetScript(); - if (script != null) - script.SetVisualDummy(summon); - } - } - } - - public override void Register() - { - AfterHit.Add(new HitHandler(InitializeVisualStalker)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.Dummy)); } } @@ -612,19 +811,17 @@ namespace Scripts.Spells.Shaman class spell_sha_healing_rain_AuraScript : AuraScript { ObjectGuid _visualDummy; - float _x; - float _y; - float _z; + Position _dest; public void SetVisualDummy(TempSummon summon) { _visualDummy = summon.GetGUID(); - summon.GetPosition(out _x, out _y, out _z); + _dest = summon.GetPosition(); } void HandleEffectPeriodic(AuraEffect aurEff) { - GetTarget().CastSpell(new Position(_x, _y, _z), SpellIds.HealingRainHeal, new CastSpellExtraArgs(aurEff)); + GetTarget().CastSpell(_dest, SpellIds.HealingRainHeal, aurEff); } void HandleEffecRemoved(AuraEffect aurEff, AuraEffectHandleModes mode) @@ -636,8 +833,41 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnEffectRemove.Add(new EffectApplyHandler(HandleEffecRemoved, 1, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 1, AuraType.PeriodicDummy)); + OnEffectRemove.Add(new(HandleEffecRemoved, 1, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); + OnEffectPeriodic.Add(new(HandleEffectPeriodic, 1, AuraType.PeriodicDummy)); + } + } + + [Script] // 73920 - Healing Rain + class spell_sha_healing_rain : SpellScript + { + const uint NpcHealingRainInvisibleStalker = 73400; + + void InitializeVisualStalker() + { + Aura aura = GetHitAura(); + if (aura != null) + { + WorldLocation dest = GetExplTargetDest(); + if (dest != null) + { + var duration = TimeSpan.FromMilliseconds(GetSpellInfo().CalcDuration(GetOriginalCaster())); + TempSummon summon = GetCaster().GetMap().SummonCreature(NpcHealingRainInvisibleStalker, dest, null, duration, GetOriginalCaster()); + if (summon == null) + return; + + summon.CastSpell(summon, SpellIds.HealingRainVisual, true); + + spell_sha_healing_rain_AuraScript script = aura.GetScript(); + if (script != null) + script.SetVisualDummy(summon); + } + } + } + + public override void Register() + { + AfterHit.Add(new(InitializeVisualStalker)); } } @@ -651,7 +881,7 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(SelectTargets, 0, Targets.UnitDestAreaAlly)); + OnObjectAreaTargetSelect.Add(new(SelectTargets, 0, Targets.UnitDestAreaAlly)); } } @@ -665,7 +895,7 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(SelectTargets, 0, Targets.UnitDestAreaAlly)); + OnObjectAreaTargetSelect.Add(new(SelectTargets, 0, Targets.UnitDestAreaAlly)); } } @@ -681,15 +911,15 @@ namespace Scripts.Spells.Shaman { Unit caster = GetCaster(); if (caster != null) - caster.CastSpell(caster, SpellIds.FrostShockEnergize, new CastSpellExtraArgs(TriggerCastFlags.IgnoreCastInProgress)); + caster.CastSpell(caster, SpellIds.FrostShockEnergize, TriggerCastFlags.IgnoreCastInProgress); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 1, AuraType.AddPctModifier)); + OnEffectProc.Add(new(HandleEffectProc, 1, AuraType.AddPctModifier)); } } - + [Script] // 23551 - Lightning Shield T2 Bonus class spell_sha_item_lightning_shield : AuraScript { @@ -701,12 +931,12 @@ namespace Scripts.Spells.Shaman void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.ItemLightningShield, new CastSpellExtraArgs(aurEff)); + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.ItemLightningShield, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); } } @@ -721,12 +951,12 @@ namespace Scripts.Spells.Shaman void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.ItemLightningShieldDamage, new CastSpellExtraArgs(aurEff)); + GetTarget().CastSpell(GetTarget(), SpellIds.ItemLightningShieldDamage, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); } } @@ -747,7 +977,7 @@ namespace Scripts.Spells.Shaman { PreventDefaultAction(); - var costs = eventInfo.GetProcSpell().GetPowerCost(); + List costs = eventInfo.GetProcSpell().GetPowerCost(); var m = costs.Find(cost => cost.Power == PowerType.Mana); if (m != null) { @@ -763,8 +993,8 @@ namespace Scripts.Spells.Shaman public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.ProcTriggerSpell)); } } @@ -808,12 +1038,12 @@ namespace Scripts.Spells.Shaman return; if (RandomHelper.randChance(chance)) - eventInfo.GetActor().CastSpell((Unit)null, spellId, true); + eventInfo.GetActor().CastSpell(null, spellId, true); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -829,13 +1059,13 @@ namespace Scripts.Spells.Shaman { PreventDefaultAction(); Player target = GetTarget().ToPlayer(); - if (target) + if (target != null) target.GetSpellHistory().ModifyCooldown(SpellIds.ElementalMastery, TimeSpan.FromMilliseconds(-aurEff.GetAmount())); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.Dummy)); } } @@ -852,7 +1082,7 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(DiminishHaste, 1, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(DiminishHaste, 1, AuraType.PeriodicDummy)); } } @@ -867,11 +1097,9 @@ namespace Scripts.Spells.Shaman void HandleScript(uint effIndex) { Unit caster = GetCaster(); - if (caster) - { + if (caster != null) if (caster.HasAura(SpellIds.PathOfFlamesTalent)) - caster.CastSpell(GetHitUnit(), SpellIds.PathOfFlamesSpread, new CastSpellExtraArgs(GetSpell())); - } + caster.CastSpell(GetHitUnit(), SpellIds.PathOfFlamesSpread, GetSpell()); } void EnsureLavaSurgeCanBeImmediatelyConsumed() @@ -894,8 +1122,8 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.TriggerMissile)); - AfterCast.Add(new CastHandler(EnsureLavaSurgeCanBeImmediatelyConsumed)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.TriggerMissile)); + AfterCast.Add(new(EnsureLavaSurgeCanBeImmediatelyConsumed)); } } @@ -922,7 +1150,7 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnCalcCritChance.Add(new OnCalcCritChanceHandler(CalcCritChance)); + OnCalcCritChance.Add(new(CalcCritChance)); } } @@ -952,8 +1180,8 @@ namespace Scripts.Spells.Shaman public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckProcChance, 0, AuraType.Dummy)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); + DoCheckEffectProc.Add(new(CheckProcChance, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.Dummy)); } } @@ -967,17 +1195,17 @@ namespace Scripts.Spells.Shaman public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } void ResetCooldown() { - GetCaster().GetSpellHistory().RestoreCharge(Global.SpellMgr.GetSpellInfo(SpellIds.LavaBurst, GetCastDifficulty()).ChargeCategoryId); + GetCaster().GetSpellHistory().RestoreCharge(SpellMgr.GetSpellInfo(SpellIds.LavaBurst, GetCastDifficulty()).ChargeCategoryId); } public override void Register() { - AfterHit.Add(new HitHandler(ResetCooldown)); + AfterHit.Add(new(ResetCooldown)); } } @@ -987,7 +1215,7 @@ namespace Scripts.Spells.Shaman public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.LightningBoltEnergize, SpellIds.MaelstromController) - && ValidateSpellEffect(SpellIds.MaelstromController, 0); + && ValidateSpellEffect((SpellIds.MaelstromController, 0)); } void HandleScript(uint effIndex) @@ -1000,7 +1228,7 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnEffectLaunch.Add(new EffectHandler(HandleScript, 0, SpellEffectName.SchoolDamage)); + OnEffectLaunch.Add(new(HandleScript, 0, SpellEffectName.SchoolDamage)); } } @@ -1010,7 +1238,7 @@ namespace Scripts.Spells.Shaman public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.LightningBoltOverloadEnergize, SpellIds.MaelstromController) - && ValidateSpellEffect(SpellIds.MaelstromController, 1); + && ValidateSpellEffect((SpellIds.MaelstromController, 1)); } void HandleScript(uint effIndex) @@ -1023,7 +1251,7 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnEffectLaunch.Add(new EffectHandler(HandleScript, 0, SpellEffectName.SchoolDamage)); + OnEffectLaunch.Add(new(HandleScript, 0, SpellEffectName.SchoolDamage)); } } @@ -1055,8 +1283,8 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(HandleTargetSelect, 0, Targets.UnitDestAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(HandleEffectHitTarget, 0, SpellEffectName.Dummy)); + OnObjectAreaTargetSelect.Add(new(HandleTargetSelect, 0, Targets.UnitDestAreaEnemy)); + OnEffectHitTarget.Add(new(HandleEffectHitTarget, 0, SpellEffectName.Dummy)); } } @@ -1065,14 +1293,14 @@ namespace Scripts.Spells.Shaman { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.LightningBolt, SpellIds.LightningBoltOverload, SpellIds.ElementalBlast, SpellIds.ElementalBlastOverload, SpellIds.Icefury, SpellIds.IcefuryOverload, SpellIds.LavaBurst, SpellIds.LavaBurstOverload, - SpellIds.ChainLightning, SpellIds.ChainLightningOverload, SpellIds.LavaBeam, SpellIds.LavaBeamOverload, SpellIds.Stormkeeper); + return ValidateSpellInfo(SpellIds.LightningBolt, SpellIds.LightningBoltOverload, SpellIds.ElementalBlast, SpellIds.ElementalBlastOverload, SpellIds.Icefury, SpellIds.IcefuryOverload, + SpellIds.LavaBurst, SpellIds.LavaBurstOverload, SpellIds.ChainLightning, SpellIds.ChainLightningOverload, SpellIds.LavaBeam, SpellIds.LavaBeamOverload, SpellIds.Stormkeeper); } bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo) { SpellInfo spellInfo = eventInfo.GetSpellInfo(); - if (spellInfo == null || !eventInfo.GetProcSpell()) + if (spellInfo == null || eventInfo.GetProcSpell() == null) return false; if (GetTriggeredSpellId(spellInfo.Id) == 0) @@ -1100,7 +1328,6 @@ namespace Scripts.Spells.Shaman var targets = new CastSpellTargetArg(procInfo.GetProcTarget()); var overloadSpellId = GetTriggeredSpellId(procInfo.GetSpellInfo().Id); var originalCastId = procInfo.GetProcSpell().m_castId; - caster.m_Events.AddEventAtOffset(() => { if (targets.Targets == null) @@ -1116,8 +1343,8 @@ namespace Scripts.Spells.Shaman public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckProc, 0, AuraType.Dummy)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } uint GetTriggeredSpellId(uint triggeringSpellId) @@ -1165,7 +1392,7 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(ApplyDamageModifier, 0, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new(ApplyDamageModifier, 0, SpellEffectName.SchoolDamage)); } } @@ -1179,7 +1406,7 @@ namespace Scripts.Spells.Shaman public override void Register() { - DoCheckEffectProc.Add(new CheckEffectProcHandler(CheckProc, 0, AuraType.ProcTriggerSpell)); + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.ProcTriggerSpell)); } } @@ -1194,13 +1421,13 @@ namespace Scripts.Spells.Shaman void FilterTargets(List targets) { targets.Remove(GetExplTargetUnit()); - targets.RandomResize(target => target.IsTypeId(TypeId.Unit) && !target.ToUnit().HasAura(SpellIds.FlameShock, GetCaster().GetGUID()), 1); + targets.RandomResize(target => target.GetTypeId() == TypeId.Unit && !target.ToUnit().HasAura(SpellIds.FlameShock, GetCaster().GetGUID()), 1); } void HandleScript(uint effIndex) { Unit mainTarget = GetExplTargetUnit(); - if (mainTarget) + if (mainTarget != null) { Aura flameShock = mainTarget.GetAura(SpellIds.FlameShock, GetCaster().GetGUID()); if (flameShock != null) @@ -1217,8 +1444,32 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitDestAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.Dummy)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 1, Targets.UnitDestAreaEnemy)); + OnEffectHitTarget.Add(new(HandleScript, 1, SpellEffectName.Dummy)); + } + } + + // 114083 - Restorative Mists + [Script] // 294020 - Restorative Mists + class spell_sha_restorative_mists : SpellScript + { + int _targetCount; + + void FilterTargets(List targets) + { + _targetCount = targets.Count; + } + + void HandleHeal(uint effIndex) + { + if (_targetCount != 0) + SetHitHeal(GetHitHeal() / _targetCount); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitSrcAreaAlly)); + OnEffectHitTarget.Add(new(HandleHeal, 0, SpellEffectName.Heal)); } } @@ -1235,7 +1486,7 @@ namespace Scripts.Spells.Shaman { Unit target = GetTarget(); if (target.HasAura(SpellIds.SpiritWolfTalent) && target.HasAura(SpellIds.GhostWolf)) - target.CastSpell(target, SpellIds.SpiritWolfPeriodic, new CastSpellExtraArgs(aurEff)); + target.CastSpell(target, SpellIds.SpiritWolfPeriodic, aurEff); } void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) @@ -1246,12 +1497,12 @@ namespace Scripts.Spells.Shaman public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.Any, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Any, AuraEffectHandleModes.Real)); + AfterEffectApply.Add(new(OnApply, 0, AuraType.Any, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(OnRemove, 0, AuraType.Any, AuraEffectHandleModes.Real)); } } - [Script] // 51562 - Tidal Waves + [Script] // 51564 - Tidal Waves class spell_sha_tidal_waves : AuraScript { public override bool Validate(SpellInfo spellInfo) @@ -1271,7 +1522,7 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.Dummy)); } } @@ -1314,12 +1565,12 @@ namespace Scripts.Spells.Shaman return; } - caster.CastSpell(target, spellId, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(target, spellId, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1330,14 +1581,14 @@ namespace Scripts.Spells.Shaman { PreventDefaultAction(); - // Need remove self if Lightning Shield not active + // Need Remove self if Lightning Shield not active if (GetTarget().GetAuraEffect(AuraType.ProcTriggerSpell, SpellFamilyNames.Shaman, new FlagArray128(0x400), GetCaster().GetGUID()) == null) Remove(); } public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(PeriodicTick, 1, AuraType.PeriodicTriggerSpell)); + OnEffectPeriodic.Add(new(PeriodicTick, 1, AuraType.PeriodicTriggerSpell)); } } @@ -1357,8 +1608,10 @@ namespace Scripts.Spells.Shaman if (damageInfo == null || damageInfo.GetDamage() == 0) return; - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.Electrified, GetCastDifficulty()); + SpellInfo spellInfo = SpellMgr.GetSpellInfo(SpellIds.Electrified, GetCastDifficulty()); int amount = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); + + Cypher.Assert(spellInfo.GetMaxTicks() > 0); amount /= (int)spellInfo.GetMaxTicks(); Unit caster = eventInfo.GetActor(); @@ -1371,7 +1624,7 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1391,8 +1644,10 @@ namespace Scripts.Spells.Shaman if (damageInfo == null || damageInfo.GetDamage() == 0) return; - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.LavaBurstBonusDamage, GetCastDifficulty()); + SpellInfo spellInfo = SpellMgr.GetSpellInfo(SpellIds.LavaBurstBonusDamage, GetCastDifficulty()); int amount = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); + + Cypher.Assert(spellInfo.GetMaxTicks() > 0); amount /= (int)spellInfo.GetMaxTicks(); Unit caster = eventInfo.GetActor(); @@ -1405,7 +1660,7 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1430,14 +1685,14 @@ namespace Scripts.Spells.Shaman int newDuration = flameShockAura.GetDuration() + aurEff.GetAmount() * Time.InMilliseconds; flameShockAura.SetDuration(newDuration); - // is it blizzlike to change max duration for FS? + // is it blizzlike to change max duration for Fs? if (newDuration > maxDuration) flameShockAura.SetMaxDuration(newDuration); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1457,8 +1712,10 @@ namespace Scripts.Spells.Shaman if (healInfo == null || healInfo.GetHeal() == 0) return; - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.ChainedHeal, GetCastDifficulty()); + SpellInfo spellInfo = SpellMgr.GetSpellInfo(SpellIds.ChainedHeal, GetCastDifficulty()); int amount = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount()); + + Cypher.Assert(spellInfo.GetMaxTicks() > 0); amount /= (int)spellInfo.GetMaxTicks(); Unit caster = eventInfo.GetActor(); @@ -1471,7 +1728,7 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1495,7 +1752,7 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -1520,10 +1777,10 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } - + [Script] // 33757 - Windfury Weapon class spell_sha_windfury_weapon : SpellScript { @@ -1548,7 +1805,7 @@ namespace Scripts.Spells.Shaman public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleEffect, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleEffect, 0, SpellEffectName.Dummy)); } } @@ -1565,12 +1822,39 @@ namespace Scripts.Spells.Shaman PreventDefaultAction(); for (uint i = 0; i < 2; ++i) - eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.WindfuryAttack, new CastSpellExtraArgs(aurEff)); + eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.WindfuryAttack, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleEffectProc, 0, AuraType.Dummy)); + } + } + + [Script] // 378269 - Windspeaker's Lava Resurgence + class spell_sha_windspeakers_lava_resurgence : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.VolcanicSurge); + } + + void PreventLavaSurge(uint effIndex) + { + if (GetCaster().HasAura(SpellIds.VolcanicSurge)) + PreventHitDefaultEffect(effIndex); + } + + void PreventVolcanicSurge(uint effIndex) + { + if (!GetCaster().HasAura(SpellIds.VolcanicSurge)) + PreventHitDefaultEffect(effIndex); + } + + public override void Register() + { + OnEffectLaunch.Add(new(PreventLavaSurge, 1, SpellEffectName.TriggerSpell)); + OnEffectLaunch.Add(new(PreventVolcanicSurge, 2, SpellEffectName.TriggerSpell)); } } @@ -1578,18 +1862,18 @@ namespace Scripts.Spells.Shaman [Script] // 12676 - AreaTriggerId class areatrigger_sha_wind_rush_totem : AreaTriggerAI { - static int REFRESH_TIME = 4500; + uint RefreshTime = 4500; - int _refreshTimer; + uint _refreshTimer; public areatrigger_sha_wind_rush_totem(AreaTrigger areatrigger) : base(areatrigger) { - _refreshTimer = REFRESH_TIME; + _refreshTimer = RefreshTime; } public override void OnUpdate(uint diff) { - _refreshTimer -= (int)diff; + _refreshTimer -= diff; if (_refreshTimer <= 0) { Unit caster = at.GetCaster(); @@ -1597,7 +1881,7 @@ namespace Scripts.Spells.Shaman { foreach (ObjectGuid guid in at.GetInsideUnits()) { - Unit unit = Global.ObjAccessor.GetUnit(caster, guid); + Unit unit = ObjAccessor.GetUnit(caster, guid); if (unit != null) { if (!caster.IsFriendlyTo(unit)) @@ -1607,7 +1891,7 @@ namespace Scripts.Spells.Shaman } } } - _refreshTimer += REFRESH_TIME; + _refreshTimer += RefreshTime; } } diff --git a/Source/Scripts/Spells/Warlock.cs b/Source/Scripts/Spells/Warlock.cs index 6df3ee84a..ca5b54e0c 100644 --- a/Source/Scripts/Spells/Warlock.cs +++ b/Source/Scripts/Spells/Warlock.cs @@ -1,4 +1,4 @@ -// Copyright (c) CypherCore All rights reserved. +// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; @@ -6,8 +6,8 @@ using Framework.Dynamic; using Game.Entities; using Game.Scripting; using Game.Spells; -using System; using System.Collections.Generic; +using static Global; namespace Scripts.Spells.Warlock { @@ -32,7 +32,7 @@ namespace Scripts.Spells.Warlock public const uint SeedOfCorruptionDamage = 27285; public const uint SeedOfCorruptionGeneric = 32865; public const uint ShadowBoltEnergize = 194192; - public const uint Soulshatter = 32835; + public const uint SoulshatterEffect = 32835; public const uint SoulSwapCdMarker = 94229; public const uint SoulSwapOverride = 86211; public const uint SoulSwapModCost = 92794; @@ -55,13 +55,15 @@ namespace Scripts.Spells.Warlock [Script] // 710 - Banish class spell_warl_banish : SpellScript { + public spell_warl_banish() { } + void HandleBanish(SpellMissInfo missInfo) { if (missInfo != SpellMissInfo.Immune) return; Unit target = GetHitUnit(); - if (target) + if (target != null) { // Casting Banish on a banished target will Remove applied aura Aura banishAura = target.GetAura(GetSpellInfo().Id, GetCaster().GetGUID()); @@ -72,7 +74,7 @@ namespace Scripts.Spells.Warlock public override void Register() { - BeforeHit.Add(new BeforeHitHandler(HandleBanish)); + BeforeHit.Add(new(HandleBanish)); } } @@ -87,7 +89,8 @@ namespace Scripts.Spells.Warlock SpellCastResult CheckApplyAura() { Unit caster = GetCaster(); - if (caster.GetHealthPct() <= GetEffectInfo(1).CalcValue(caster)) + + if (caster.GetHealthPct() <= (float)(GetEffectInfo(1).CalcValue(caster))) { SetCustomCastResultMessage(SpellCustomErrors.YouDontHaveEnoughHealth); return SpellCastResult.CustomError; @@ -98,16 +101,16 @@ namespace Scripts.Spells.Warlock public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckApplyAura)); + OnCheckCast.Add(new(CheckApplyAura)); } } [Script] // 111400 - Burning Rush - class spell_warl_burning_rush_aura : AuraScript + class spell_warl_burning_rush_AuraScript : AuraScript { void PeriodicTick(AuraEffect aurEff) { - if (GetTarget().GetHealthPct() <= aurEff.GetAmount()) + if (GetTarget().GetHealthPct() <= (float)(aurEff.GetAmount())) { PreventDefaultAction(); Remove(); @@ -116,10 +119,10 @@ namespace Scripts.Spells.Warlock public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(PeriodicTick, 1, AuraType.PeriodicDamagePercent)); + OnEffectPeriodic.Add(new(PeriodicTick, 1, AuraType.PeriodicDamagePercent)); } } - + [Script] // 116858 - Chaos Bolt class spell_warl_chaos_bolt : SpellScript { @@ -140,8 +143,8 @@ namespace Scripts.Spells.Warlock public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.SchoolDamage)); - OnCalcCritChance.Add(new OnCalcCritChanceHandler(CalcCritChance)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.SchoolDamage)); + OnCalcCritChance.Add(new(CalcCritChance)); } } @@ -150,15 +153,15 @@ namespace Scripts.Spells.Warlock { void HandleAbsorb(AuraEffect aurEff, DamageInfo dmgInfo, ref uint absorbAmount) { - AuraEffect auraEffect = GetEffect(1); - if (auraEffect == null || !GetTargetApplication().HasEffect(1)) + AuraEffect effect1 = GetEffect(1); + if (effect1 == null || !GetTargetApplication().HasEffect(1)) { PreventDefaultAction(); return; } // You take ${$s2/3}% reduced damage - float damageReductionPct = (float)auraEffect.GetAmount() / 3; + float damageReductionPct = (float)(effect1.GetAmount()) / 3; // plus a random amount of up to ${$s2/3}% additional reduced damage damageReductionPct += RandomHelper.FRand(0.0f, damageReductionPct); @@ -167,7 +170,7 @@ namespace Scripts.Spells.Warlock public override void Register() { - OnEffectAbsorb.Add(new EffectAbsorbHandler(HandleAbsorb, 2)); + OnEffectAbsorb.Add(new(HandleAbsorb, 2)); } } @@ -181,7 +184,7 @@ namespace Scripts.Spells.Warlock public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } void HandleScriptEffect(uint effIndex) @@ -191,7 +194,7 @@ namespace Scripts.Spells.Warlock public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } @@ -218,17 +221,17 @@ namespace Scripts.Spells.Warlock public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); + DoEffectCalcAmount.Add(new(CalculateAmount, 0, AuraType.SchoolAbsorb)); } } - + [Script] // 48018 - Demonic Circle: Summon class spell_warl_demonic_circle_summon : AuraScript { void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { // If effect is Removed by expire Remove the summoned demonic circle too. - if (!mode.HasAnyFlag(AuraEffectHandleModes.Reapply)) + if (!mode.HasFlag(AuraEffectHandleModes.Reapply)) GetTarget().RemoveGameObject(GetId(), true); GetTarget().RemoveAura(SpellIds.DemonicCircleAllowCast); @@ -237,13 +240,13 @@ namespace Scripts.Spells.Warlock void HandleDummyTick(AuraEffect aurEff) { GameObject circle = GetTarget().GetGameObject(GetId()); - if (circle) + if (circle != null) { // Here we check if player is in demonic circle teleport range, if so add - // WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST; allowing him to cast the WARLOCK_DEMONIC_CIRCLE_TELEPORT. - // If not in range Remove the WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST. + // WarlockDemonicCircleAllowCast; allowing him to cast the WarlockDemonicCircleTeleport. + // If not in range Remove the WarlockDemonicCircleAllowCast. - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.DemonicCircleTeleport, GetCastDifficulty()); + SpellInfo spellInfo = SpellMgr.GetSpellInfo(SpellIds.DemonicCircleTeleport, GetCastDifficulty()); if (GetTarget().IsWithinDist(circle, spellInfo.GetMaxRange(true))) { @@ -257,8 +260,8 @@ namespace Scripts.Spells.Warlock public override void Register() { - OnEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleDummyTick, 0, AuraType.PeriodicDummy)); + OnEffectRemove.Add(new(HandleRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); + OnEffectPeriodic.Add(new(HandleDummyTick, 0, AuraType.PeriodicDummy)); } } @@ -268,10 +271,10 @@ namespace Scripts.Spells.Warlock void HandleTeleport(AuraEffect aurEff, AuraEffectHandleModes mode) { Player player = GetTarget().ToPlayer(); - if (player) + if (player != null) { GameObject circle = player.GetGameObject(SpellIds.DemonicCircleSummon); - if (circle) + if (circle != null) { player.NearTeleportTo(circle.GetPositionX(), circle.GetPositionY(), circle.GetPositionZ(), circle.GetOrientation()); player.RemoveMovementImpairingAuras(false); @@ -281,7 +284,7 @@ namespace Scripts.Spells.Warlock public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(HandleTeleport, 0, AuraType.MechanicImmunity, AuraEffectHandleModes.Real)); + OnEffectApply.Add(new(HandleTeleport, 0, AuraType.MechanicImmunity, AuraEffectHandleModes.Real)); } } @@ -290,7 +293,8 @@ namespace Scripts.Spells.Warlock { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.GlyphOfDemonTraining, SpellIds.DevourMagicHeal) && ValidateSpellEffect(spellInfo.Id, 1); + return ValidateSpellInfo(SpellIds.GlyphOfDemonTraining, SpellIds.DevourMagicHeal) + && ValidateSpellEffect((spellInfo.Id, 1)); } void OnSuccessfulDispel(uint effIndex) @@ -303,14 +307,13 @@ namespace Scripts.Spells.Warlock // Glyph of Felhunter Unit owner = caster.GetOwner(); - if (owner) - if (owner.GetAura(SpellIds.GlyphOfDemonTraining) != null) - owner.CastSpell(owner, SpellIds.DevourMagicHeal, args); + if (owner?.GetAura(SpellIds.GlyphOfDemonTraining) != null) + owner.CastSpell(owner, SpellIds.DevourMagicHeal, args); } public override void Register() { - OnEffectSuccessfulDispel.Add(new EffectHandler(OnSuccessfulDispel, 0, SpellEffectName.Dispel)); + OnEffectSuccessfulDispel.Add(new(OnSuccessfulDispel, 0, SpellEffectName.Dispel)); } } @@ -334,7 +337,7 @@ namespace Scripts.Spells.Warlock public override void Register() { - AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.PeriodicDamage, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new(HandleRemove, 0, AuraType.PeriodicDamage, AuraEffectHandleModes.Real)); } } @@ -354,7 +357,7 @@ namespace Scripts.Spells.Warlock public override void Register() { - AfterHit.Add(new HitHandler(HandleAfterHit)); + AfterHit.Add(new(HandleAfterHit)); } } @@ -364,7 +367,7 @@ namespace Scripts.Spells.Warlock void ApplyEffect(AuraEffect aurEff, AuraEffectHandleModes mode) { Unit caster = GetCaster(); - if (!caster) + if (caster == null) return; Unit target = GetTarget(); @@ -384,13 +387,13 @@ namespace Scripts.Spells.Warlock void OnPeriodic(AuraEffect aurEff) { Unit caster = GetCaster(); - if (!caster) + if (caster == null) return; - //! HACK for self damage, is not blizz :/ + //! Hack for self damage, is not blizz :/ uint damage = (uint)caster.CountPctFromMaxHealth(aurEff.GetBaseAmount()); Player modOwner = caster.GetSpellModOwner(); - if (modOwner) + if (modOwner != null) modOwner.ApplySpellMod(GetSpellInfo(), SpellModOp.PowerCost0, ref damage); SpellNonMeleeDamage damageInfo = new(caster, caster, GetSpellInfo(), GetAura().GetSpellVisual(), GetSpellInfo().SchoolMask, GetAura().GetCastId()); @@ -402,9 +405,9 @@ namespace Scripts.Spells.Warlock public override void Register() { - OnEffectApply.Add(new EffectApplyHandler(ApplyEffect, 0, AuraType.ObsModHealth, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(RemoveEffect, 0, AuraType.ObsModHealth, AuraEffectHandleModes.Real)); - OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 0, AuraType.ObsModHealth)); + OnEffectApply.Add(new(ApplyEffect, 0, AuraType.ObsModHealth, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new(RemoveEffect, 0, AuraType.ObsModHealth, AuraEffectHandleModes.Real)); + OnEffectPeriodic.Add(new(OnPeriodic, 0, AuraType.ObsModHealth)); } } @@ -419,7 +422,7 @@ namespace Scripts.Spells.Warlock public override void Register() { - OnHit.Add(new HitHandler(HandleOnHit)); + OnHit.Add(new(HandleOnHit)); } } @@ -438,7 +441,7 @@ namespace Scripts.Spells.Warlock public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleOnEffectHit, 0, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new(HandleOnEffectHit, 0, SpellEffectName.SchoolDamage)); } } @@ -458,7 +461,7 @@ namespace Scripts.Spells.Warlock caster.RemoveAurasDueToSpell(SpellIds.IncubusPact); Player player = GetCaster().ToPlayer(); - if (!player) + if (player == null) return; Pet pet = player.GetPet(); @@ -471,7 +474,7 @@ namespace Scripts.Spells.Warlock public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -482,19 +485,19 @@ namespace Scripts.Spells.Warlock { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SharedConst.PetSummoningDisorientation); + return ValidateSpellInfo(SharedConst.SpellPetSummoningDisorientation); } - // Note: this is a special case in which the warlock's minion pet must also cast Summon Disorientation at the beginning since this is only handled by SPELL_EFFECT_SUMMON_PET in Spell::CheckCast. + // Note: this is a special case in which the warlock's minion pet must also cast Summon Disorientation at the beginning Math.Since this is only handled by SpellEffectSummonPet in Spell.CheckCast. public override void OnPrecast() { Player player = GetCaster().ToPlayer(); - if (!player) + if (player == null) return; Pet pet = player.GetPet(); if (pet != null) - pet.CastSpell(pet, SharedConst.PetSummoningDisorientation, new CastSpellExtraArgs(TriggerCastFlags.FullMask) + pet.CastSpell(pet, SharedConst.SpellPetSummoningDisorientation, new CastSpellExtraArgs(TriggerCastFlags.FullMask) .SetOriginalCaster(pet.GetGUID()) .SetTriggeringSpell(GetSpell())); } @@ -514,11 +517,11 @@ namespace Scripts.Spells.Warlock { Unit caster = GetCaster(); Unit target = GetHitUnit(); - if (target) + if (target != null) { - if (caster.GetOwner() && caster.GetOwner().HasAura(SpellIds.GlyphOfSuccubus)) + if (caster.GetOwner() != null && caster.GetOwner().HasAura(SpellIds.GlyphOfSuccubus)) { - target.RemoveAurasByType(AuraType.PeriodicDamage, ObjectGuid.Empty, target.GetAura(SpellIds.PriestShadowWordDeath)); // SW:D shall not be Removed. + target.RemoveAurasByType(AuraType.PeriodicDamage, ObjectGuid.Empty, target.GetAura(SpellIds.PriestShadowWordDeath)); // Sw:D shall not be Removed. target.RemoveAurasByType(AuraType.PeriodicDamagePercent); target.RemoveAurasByType(AuraType.PeriodicLeech); } @@ -527,7 +530,7 @@ namespace Scripts.Spells.Warlock public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ApplyAura)); + OnEffectHitTarget.Add(new(HandleScriptEffect, 0, SpellEffectName.ApplyAura)); } } @@ -536,13 +539,13 @@ namespace Scripts.Spells.Warlock { void FilterTargets(List targets) { - if (GetExplTargetUnit()) + if (GetExplTargetUnit() != null) targets.Remove(GetExplTargetUnit()); } public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaEnemy)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitDestAreaEnemy)); } } @@ -581,16 +584,16 @@ namespace Scripts.Spells.Warlock Remove(); Unit caster = GetCaster(); - if (!caster) + if (caster == null) return; - caster.CastSpell(eventInfo.GetActionTarget(), SpellIds.SeedOfCorruptionDamage, true); + caster.CastSpell(eventInfo.GetActionTarget(), SpellIds.SeedOfCorruptionDamage, aurEff); } public override void Register() { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateBuffer, 2, AuraType.Dummy)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 2, AuraType.Dummy)); + DoEffectCalcAmount.Add(new(CalculateBuffer, 2, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 2, AuraType.Dummy)); } } @@ -615,7 +618,7 @@ namespace Scripts.Spells.Warlock if (damageInfo == null || damageInfo.GetDamage() == 0) return; - int amount = aurEff.GetAmount() - (int)damageInfo.GetDamage(); + int amount = (int)(aurEff.GetAmount() - damageInfo.GetDamage()); if (amount > 0) { aurEff.SetAmount(amount); @@ -625,15 +628,15 @@ namespace Scripts.Spells.Warlock Remove(); Unit caster = GetCaster(); - if (!caster) + if (caster == null) return; - caster.CastSpell(eventInfo.GetActionTarget(), SpellIds.SeedOfCorruptionGeneric, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(eventInfo.GetActionTarget(), SpellIds.SeedOfCorruptionGeneric, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 1, AuraType.Dummy)); } } @@ -652,7 +655,7 @@ namespace Scripts.Spells.Warlock public override void Register() { - AfterCast.Add(new CastHandler(HandleAfterCast)); + AfterCast.Add(new(HandleAfterCast)); } } @@ -672,22 +675,26 @@ namespace Scripts.Spells.Warlock public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleHit, 0, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new(HandleHit, 0, SpellEffectName.SchoolDamage)); } } - [Script] // 86211 - Soul Swap - Also acts as a dot container - public class spell_warl_soul_swap_override : AuraScript + [Script] // 86211 - Soul Swap Override - Also acts as a dot container + class spell_warl_soul_swap_override : AuraScript { + List _dotList = new(); + Unit _swapCaster; + //! Forced to, pure virtual functions must have a body when linking public override void Register() { } public void AddDot(uint id) { _dotList.Add(id); } + public List GetDotList() { return _dotList; } + public Unit GetOriginalSwapSource() { return _swapCaster; } + public void SetOriginalSwapSource(Unit victim) { _swapCaster = victim; } - List _dotList = new(); - Unit _swapCaster; } [Script] //! Soul Swap Copy Spells - 92795 - Simply copies spell IDs. @@ -697,7 +704,7 @@ namespace Scripts.Spells.Warlock { Unit swapVictim = GetCaster(); Unit warlock = GetHitUnit(); - if (!warlock || !swapVictim) + if (warlock == null || swapVictim == null) return; var appliedAuras = swapVictim.GetAppliedAuras(); @@ -711,12 +718,12 @@ namespace Scripts.Spells.Warlock FlagArray128 classMask = GetEffectInfo().SpellClassMask; - foreach (var itr in appliedAuras) + foreach (var (id, aurApp) in appliedAuras) { - SpellInfo spellProto = itr.Value.GetBase().GetSpellInfo(); - if (itr.Value.GetBase().GetCaster() == warlock) + SpellInfo spellProto = aurApp.GetBase().GetSpellInfo(); + if (aurApp.GetBase().GetCaster() == warlock) if (spellProto.SpellFamilyName == SpellFamilyNames.Warlock && (spellProto.SpellFamilyFlags & classMask)) - swapSpellScript.AddDot(itr.Key); + swapSpellScript.AddDot(id); } swapSpellScript.SetOriginalSwapSource(swapVictim); @@ -724,7 +731,7 @@ namespace Scripts.Spells.Warlock public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleHit, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleHit, 0, SpellEffectName.Dummy)); } } @@ -749,13 +756,13 @@ namespace Scripts.Spells.Warlock } // Soul Swap Exhale can't be cast on the same target than Soul Swap - if (swapTarget && currentTarget && swapTarget == currentTarget) + if (swapTarget != null && currentTarget != null && swapTarget == currentTarget) return SpellCastResult.BadTargets; return SpellCastResult.SpellCastOk; } - void onEffectHit(uint effIndex) + void OnEffectHitTargetTemp(uint effIndex) { GetCaster().CastSpell(GetCaster(), SpellIds.SoulSwapModCost, true); bool hasGlyph = GetCaster().HasAura(SpellIds.GlyphOfSoulSwap); @@ -775,11 +782,11 @@ namespace Scripts.Spells.Warlock if (dotList.Empty()) return; - foreach (var itr in dotList) + foreach (var spellId in dotList) { - GetCaster().AddAura(itr, GetHitUnit()); - if (!hasGlyph && swapSource) - swapSource.RemoveAurasDueToSpell(itr); + GetCaster().AddAura(spellId, GetHitUnit()); + if (!hasGlyph && swapSource != null) + swapSource.RemoveAurasDueToSpell(spellId); } // Remove Soul Swap Exhale buff @@ -791,8 +798,8 @@ namespace Scripts.Spells.Warlock public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnEffectHitTarget.Add(new EffectHandler(onEffectHit, 0, SpellEffectName.SchoolDamage)); + OnCheckCast.Add(new(CheckCast)); + OnEffectHitTarget.Add(new(OnEffectHitTargetTemp, 0, SpellEffectName.SchoolDamage)); } } @@ -801,21 +808,21 @@ namespace Scripts.Spells.Warlock { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.Soulshatter); + return ValidateSpellInfo(SpellIds.SoulshatterEffect); } void HandleDummy(uint effIndex) { Unit caster = GetCaster(); Unit target = GetHitUnit(); - if (target) - if (target.CanHaveThreatList() && target.GetThreatManager().GetThreat(caster) > 0.0f) - caster.CastSpell(target, SpellIds.Soulshatter, true); + if (target != null) + if (target.GetThreatManager().IsThreatenedBy(caster, true)) + caster.CastSpell(target, SpellIds.SoulshatterEffect, true); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -831,13 +838,13 @@ namespace Scripts.Spells.Warlock { Unit caster = GetCaster(); - caster.CastSpell((WorldObject)null, SpellIds.SuccubusPact, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); - caster.CastSpell((WorldObject)null, SpellIds.SummonSuccubus, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + caster.CastSpell(null, SpellIds.SuccubusPact, TriggerCastFlags.FullMask); + caster.CastSpell(null, SpellIds.SummonSuccubus, TriggerCastFlags.FullMask); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -853,13 +860,13 @@ namespace Scripts.Spells.Warlock { Unit caster = GetCaster(); - caster.CastSpell((WorldObject)null, SpellIds.IncubusPact, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); - caster.CastSpell((WorldObject)null, SpellIds.SummonIncubus, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + caster.CastSpell(null, SpellIds.IncubusPact, TriggerCastFlags.FullMask); + caster.CastSpell(null, SpellIds.SummonIncubus, TriggerCastFlags.FullMask); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -873,42 +880,44 @@ namespace Scripts.Spells.Warlock void HandleDummy(uint effIndex) { - GetCaster().CastSpell((WorldObject)null, RandomHelper.randChance(50) ? SpellIds.SummonSuccubus : SpellIds.SummonIncubus, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + GetCaster().CastSpell(null, RandomHelper.randChance(50) ? SpellIds.SummonSuccubus : SpellIds.SummonIncubus, TriggerCastFlags.FullMask); } public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } - [Script("spell_warl_t4_2p_bonus_shadow", SpellIds.Flameshadow)]// 37377 - Shadowflame - [Script("spell_warl_t4_2p_bonus_fire", SpellIds.Shadowflame)]// 39437 - Shadowflame Hellfire and RoF + // 37377 - Shadowflame + // 39437 - Shadowflame Hellfire and RoF + [Script("spell_warl_t4_2p_bonus_shadow", SpellIds.Flameshadow)] + [Script("spell_warl_t4_2p_bonus_fire", SpellIds.Shadowflame)] class spell_warl_t4_2p_bonus : AuraScript { - public spell_warl_t4_2p_bonus(uint triggerSpell) + uint _triggerId; + + public spell_warl_t4_2p_bonus(uint triggerId) { - _triggerSpell = triggerSpell; + _triggerId = triggerId; } public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(_triggerSpell); + return ValidateSpellInfo(_triggerId); } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); Unit caster = eventInfo.GetActor(); - caster.CastSpell(caster, _triggerSpell, new CastSpellExtraArgs(aurEff)); + caster.CastSpell(caster, _triggerId, aurEff); } public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } - - uint _triggerSpell; } [Script] // 30108, 34438, 34439, 35183 - Unstable Affliction @@ -922,26 +931,35 @@ namespace Scripts.Spells.Warlock void HandleDispel(DispelInfo dispelInfo) { Unit caster = GetCaster(); - if (caster) + if (caster != null) { AuraEffect aurEff = GetEffect(1); if (aurEff != null) { - // backfire damage and silence - CastSpellExtraArgs args = new(aurEff); - args.AddSpellMod(SpellValueMod.BasePoint0, aurEff.GetAmount() * 9); - caster.CastSpell(dispelInfo.GetDispeller(), SpellIds.UnstableAfflictionDispel, args); + Unit target = dispelInfo.GetDispeller().ToUnit(); + if (target != null) + { + int bp = aurEff.GetAmount(); + bp = target.SpellDamageBonusTaken(caster, aurEff.GetSpellInfo(), bp, DamageEffectType.DOT); + bp *= 9; + + // backfire damage and silence + CastSpellExtraArgs args = new(aurEff); + args.AddSpellMod(SpellValueMod.BasePoint0, bp); + caster.CastSpell(target, SpellIds.UnstableAfflictionDispel, args); + } } } } public override void Register() { - AfterDispel.Add(new AuraDispelHandler(HandleDispel)); + AfterDispel.Add(new(HandleDispel)); } } - [Script] // 5740 - Rain of Fire Updated 7.1.5 + // 5740 - Rain of Fire + [Script] /// Updated 7.1.5 class spell_warl_rain_of_fire : AuraScript { void HandleDummyTick(AuraEffect aurEff) @@ -951,14 +969,14 @@ namespace Scripts.Spells.Warlock foreach (AreaTrigger rainOfFireAreaTrigger in rainOfFireAreaTriggers) { - var insideTargets = rainOfFireAreaTrigger.GetInsideUnits(); + List insideTargets = rainOfFireAreaTrigger.GetInsideUnits(); targetsInRainOfFire.AddRange(insideTargets); } foreach (ObjectGuid insideTargetGuid in targetsInRainOfFire) { - Unit insideTarget = Global.ObjAccessor.GetUnit(GetTarget(), insideTargetGuid); - if (insideTarget) + Unit insideTarget = ObjAccessor.GetUnit(GetTarget(), insideTargetGuid); + if (insideTarget != null) if (!GetTarget().IsFriendlyTo(insideTarget)) GetTarget().CastSpell(insideTarget, SpellIds.RainOfFireDamage, true); } @@ -966,7 +984,7 @@ namespace Scripts.Spells.Warlock public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleDummyTick, 3, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandleDummyTick, 3, AuraType.PeriodicDummy)); } } -} +} \ No newline at end of file diff --git a/Source/Scripts/Spells/Warrior.cs b/Source/Scripts/Spells/Warrior.cs index d17a8691b..9e540c36a 100644 --- a/Source/Scripts/Spells/Warrior.cs +++ b/Source/Scripts/Spells/Warrior.cs @@ -1,4 +1,4 @@ -// Copyright (c) CypherCore All rights reserved. +// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; @@ -9,6 +9,7 @@ using Game.Spells; using System; using System.Collections.Generic; using System.Numerics; +using static Global; namespace Scripts.Spells.Warrior { @@ -42,21 +43,21 @@ namespace Scripts.Spells.Warrior public const uint RallyingCry = 97463; public const uint ShieldBlockAura = 132404; public const uint ShieldChargeEffect = 385953; + public const uint ShieldSlam = 23922; + public const uint ShieldSlamMarker = 224324; public const uint Shockwave = 46968; public const uint ShockwaveStun = 132168; public const uint Stoicism = 70845; public const uint StormBoltStun = 132169; + public const uint Strategist = 384041; public const uint SweepingStrikesExtraAttack1 = 12723; public const uint SweepingStrikesExtraAttack2 = 26654; public const uint Taunt = 355; public const uint TraumaEffect = 215537; public const uint Victorious = 32216; - public const uint VictoriousRushHeal = 118779; - } + public const uint VictoryRushHeal = 118779; - struct Misc - { - public const uint SpellVisualBlazingCharge = 26423; + public const uint VisualBlazingCharge = 26423; } [Script] // 23881 - Bloodthirst @@ -74,7 +75,7 @@ namespace Scripts.Spells.Warrior public override void Register() { - OnEffectHit.Add(new EffectHandler(HandleDummy, 3, SpellEffectName.Dummy)); + OnEffectHit.Add(new(HandleDummy, 3, SpellEffectName.Dummy)); } } @@ -107,11 +108,11 @@ namespace Scripts.Spells.Warrior public override void Register() { - AfterEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicDummy)); - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleDummyTick, 0, AuraType.PeriodicDummy)); + AfterEffectProc.Add(new(HandleProc, 0, AuraType.PeriodicDummy)); + OnEffectPeriodic.Add(new(HandleDummyTick, 0, AuraType.PeriodicDummy)); } } - + [Script] // 100 - Charge class spell_warr_charge : SpellScript { @@ -131,7 +132,7 @@ namespace Scripts.Spells.Warrior public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -143,18 +144,18 @@ namespace Scripts.Spells.Warrior PreventDefaultAction(); if (GetTarget().IsSplineEnabled()) { - for (uint i = 0; i < 5; ++i) + for (int i = 0; i < 5; ++i) { int timeOffset = (int)(6 * i * aurEff.GetPeriod() / 25); Vector4 loc = GetTarget().MoveSpline.ComputePosition(timeOffset); - GetTarget().SendPlaySpellVisual(new Position(loc.X, loc.Y, loc.Z), Misc.SpellVisualBlazingCharge, 0, 0, 1.0f, true); + GetTarget().SendPlaySpellVisual(new Position(loc.X, loc.Y, loc.Z), SpellIds.VisualBlazingCharge, 0, 0, 1.0f, true); } } } public override void Register() { - OnEffectPeriodic.Add(new EffectPeriodicHandler(DropFireVisual, 0, AuraType.PeriodicTriggerSpell)); + OnEffectPeriodic.Add(new(DropFireVisual, 0, AuraType.PeriodicTriggerSpell)); } } @@ -178,7 +179,7 @@ namespace Scripts.Spells.Warrior public override void Register() { - OnEffectLaunchTarget.Add(new EffectHandler(HandleCharge, 0, SpellEffectName.Charge)); + OnEffectLaunchTarget.Add(new(HandleCharge, 0, SpellEffectName.Charge)); } } @@ -191,7 +192,7 @@ namespace Scripts.Spells.Warrior public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.ColossusSmashAura, SpellIds.InForTheKill, SpellIds.InForTheKillHaste) - && ValidateSpellEffect(SpellIds.InForTheKill, 2); + && ValidateSpellEffect((SpellIds.InForTheKill, 2)); } void HandleHit() @@ -203,7 +204,7 @@ namespace Scripts.Spells.Warrior if (caster.HasAura(SpellIds.InForTheKill)) { - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.InForTheKill, Difficulty.None); + SpellInfo spellInfo = SpellMgr.GetSpellInfo(SpellIds.InForTheKill, Difficulty.None); if (spellInfo != null) { if (target.HealthBelowPct(spellInfo.GetEffect(2).CalcValue(caster))) @@ -215,7 +216,7 @@ namespace Scripts.Spells.Warrior void HandleAfterCast() { Unit caster = GetCaster(); - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.InForTheKill, Difficulty.None); + SpellInfo spellInfo = SpellMgr.GetSpellInfo(SpellIds.InForTheKill, Difficulty.None); if (spellInfo == null) return; @@ -228,8 +229,8 @@ namespace Scripts.Spells.Warrior public override void Register() { - OnHit.Add(new HitHandler(HandleHit)); - AfterCast.Add(new CastHandler(HandleAfterCast)); + OnHit.Add(new(HandleHit)); + AfterCast.Add(new(HandleAfterCast)); } } @@ -245,20 +246,46 @@ namespace Scripts.Spells.Warrior { int? rageCost = eventInfo.GetProcSpell().GetPowerTypeCostAmount(PowerType.Rage); if (rageCost.HasValue) - GetTarget().CastSpell((WorldObject)null, SpellIds.CriticalThinkingEnergize, new CastSpellExtraArgs(TriggerCastFlags.FullMask) + GetTarget().CastSpell(null, SpellIds.CriticalThinkingEnergize, new CastSpellExtraArgs(TriggerCastFlags.FullMask) .AddSpellMod(SpellValueMod.BasePoint0, MathFunctions.CalculatePct(rageCost.Value, aurEff.GetAmount()))); } public override void Register() { - AfterEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); + AfterEffectProc.Add(new(HandleProc, 1, AuraType.Dummy)); } } - + + [Script] // 236279 - Devastator + class spell_warr_devastator : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellEffect((spellInfo.Id, 1)) && ValidateSpellInfo(SpellIds.ShieldSlam, SpellIds.ShieldSlamMarker); + } + + void OnProcSpell(AuraEffect aurEff, ProcEventInfo eventInfo) + { + if (GetTarget().GetSpellHistory().HasCooldown(SpellIds.ShieldSlam)) + { + if (RandomHelper.randChance(GetEffectInfo(1).CalcValue())) + { + GetTarget().GetSpellHistory().ResetCooldown(SpellIds.ShieldSlam, true); + GetTarget().CastSpell(GetTarget(), SpellIds.ShieldSlamMarker, TriggerCastFlags.IgnoreCastInProgress); + } + } + } + + public override void Register() + { + OnEffectProc.Add(new(OnProcSpell, 0, AuraType.ProcTriggerSpell)); + } + } + [Script] // 383103 - Fueled by Violence class spell_warr_fueled_by_violence : AuraScript { - int _nextHealAmount; + uint _nextHealAmount = 0; public override bool Validate(SpellInfo spellInfo) { @@ -269,7 +296,7 @@ namespace Scripts.Spells.Warrior { PreventDefaultAction(); - _nextHealAmount += (int)MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), GetEffectInfo(0).CalcValue(GetTarget())); + _nextHealAmount += MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), GetEffectInfo(0).CalcValue(GetTarget())); } void HandlePeriodic(AuraEffect aurEff) @@ -279,7 +306,7 @@ namespace Scripts.Spells.Warrior Unit target = GetTarget(); CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); - args.AddSpellMod(SpellValueMod.BasePoint0, _nextHealAmount); + args.AddSpellMod(SpellValueMod.BasePoint0, (int)_nextHealAmount); target.CastSpell(target, SpellIds.FueledByViolenceHeal, args); _nextHealAmount = 0; @@ -287,12 +314,12 @@ namespace Scripts.Spells.Warrior public override void Register() { - OnProc.Add(new AuraProcHandler(HandleProc)); - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodic, 0, AuraType.PeriodicDummy)); + OnProc.Add(new(HandleProc)); + OnEffectPeriodic.Add(new(HandlePeriodic, 0, AuraType.PeriodicDummy)); } } - - [Script] // 6544 Heroic leap + + [Script] // 6544 - Heroic leap class spell_warr_heroic_leap : SpellScript { public override bool Validate(SpellInfo spellInfo) @@ -316,9 +343,9 @@ namespace Scripts.Spells.Warrior generatedPath.SetPathLengthLimit(range); bool result = generatedPath.CalculatePath(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), false); - if (generatedPath.GetPathType().HasAnyFlag(PathType.Short)) + if (generatedPath.GetPathType().HasFlag(PathType.Short)) return SpellCastResult.OutOfRange; - else if (!result || generatedPath.GetPathType().HasAnyFlag(PathType.NoPath)) + else if (!result || generatedPath.GetPathType().HasFlag(PathType.NoPath)) return SpellCastResult.NoPath; } else if (dest.GetPositionZ() > GetCaster().GetPositionZ() + 4.0f) @@ -334,13 +361,13 @@ namespace Scripts.Spells.Warrior { WorldLocation dest = GetHitDest(); if (dest != null) - GetCaster().CastSpell(dest.GetPosition(), SpellIds.HeroicLeapJump, new CastSpellExtraArgs(true)); + GetCaster().CastSpell(dest, SpellIds.HeroicLeapJump, true); } public override void Register() { - OnCheckCast.Add(new CheckCastHandler(CheckElevation)); - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnCheckCast.Add(new(CheckElevation)); + OnEffectHit.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -349,10 +376,7 @@ namespace Scripts.Spells.Warrior { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.GlyphOfHeroicLeap, - SpellIds.GlyphOfHeroicLeapBuff, - SpellIds.ImprovedHeroicLeap, - SpellIds.Taunt); + return ValidateSpellInfo(SpellIds.GlyphOfHeroicLeap, SpellIds.GlyphOfHeroicLeapBuff, SpellIds.ImprovedHeroicLeap, SpellIds.Taunt); } void AfterJump(uint effIndex) @@ -365,7 +389,7 @@ namespace Scripts.Spells.Warrior public override void Register() { - OnEffectHit.Add(new EffectHandler(AfterJump, 1, SpellEffectName.JumpDest)); + OnEffectHit.Add(new(AfterJump, 1, SpellEffectName.JumpDest)); } } @@ -386,12 +410,11 @@ namespace Scripts.Spells.Warrior public override void Register() { - AfterCast.Add(new CastHandler(HandleAfterCast)); + AfterCast.Add(new(HandleAfterCast)); } } - // 5246 - Intimidating Shout - [Script] + [Script] // 5246 - Intimidating Shout class spell_warr_intimidating_shout : SpellScript { void FilterTargets(List unitList) @@ -401,18 +424,18 @@ namespace Scripts.Spells.Warrior public override void Register() { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitSrcAreaEnemy)); - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 2, Targets.UnitSrcAreaEnemy)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 1, Targets.UnitSrcAreaEnemy)); + OnObjectAreaTargetSelect.Add(new(FilterTargets, 2, Targets.UnitSrcAreaEnemy)); } } - // 70844 - Item - Warrior T10 Protection 4P Bonus - [Script] // 7.1.5 + [Script] // 70844 - Item - Warrior T10 Protection 4P Bonus class spell_warr_item_t10_prot_4p_bonus : AuraScript { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.Stoicism) && ValidateSpellEffect(spellInfo.Id, 1); + return ValidateSpellInfo(SpellIds.Stoicism) + && ValidateSpellEffect((spellInfo.Id, 1)); } void HandleProc(ProcEventInfo eventInfo) @@ -423,12 +446,12 @@ namespace Scripts.Spells.Warrior int bp0 = (int)MathFunctions.CalculatePct(target.GetMaxHealth(), GetEffectInfo(1).CalcValue()); CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); args.AddSpellMod(SpellValueMod.BasePoint0, bp0); - target.CastSpell((Unit)null, SpellIds.Stoicism, args); + target.CastSpell(null, SpellIds.Stoicism, args); } public override void Register() { - OnProc.Add(new AuraProcHandler(HandleProc)); + OnProc.Add(new(HandleProc)); } } @@ -443,13 +466,13 @@ namespace Scripts.Spells.Warrior void HandleDummy(uint effIndex) { Unit target = GetHitUnit(); - if (target) + if (target != null) GetCaster().CastSpell(target, SpellIds.MortalWounds, true); } public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -463,7 +486,7 @@ namespace Scripts.Spells.Warrior public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } void HandleScript(uint effIndex) @@ -476,7 +499,7 @@ namespace Scripts.Spells.Warrior public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleScript, 0, SpellEffectName.Dummy)); } } @@ -495,10 +518,10 @@ namespace Scripts.Spells.Warrior public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleHitTarget, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleHitTarget, 0, SpellEffectName.Dummy)); } } - + [Script] // 385952 - Shield Charge class spell_warr_shield_charge : SpellScript { @@ -514,21 +537,24 @@ namespace Scripts.Spells.Warrior public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleDummy, 0, SpellEffectName.Dummy)); } } - + [Script] // 46968 - Shockwave class spell_warr_shockwave : SpellScript { + uint _targetCount; + public override bool Validate(SpellInfo spellInfo) { - return !ValidateSpellInfo(SpellIds.Shockwave, SpellIds.ShockwaveStun) && ValidateSpellEffect(spellInfo.Id, 3); + return !ValidateSpellInfo(SpellIds.Shockwave, SpellIds.ShockwaveStun) + && ValidateSpellEffect((spellInfo.Id, 3)); } public override bool Load() { - return GetCaster().IsTypeId(TypeId.Player); + return GetCaster().IsPlayer(); } void HandleStun(uint effIndex) @@ -546,11 +572,9 @@ namespace Scripts.Spells.Warrior public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleStun, 0, SpellEffectName.Dummy)); - AfterCast.Add(new CastHandler(HandleAfterCast)); + OnEffectHitTarget.Add(new(HandleStun, 0, SpellEffectName.Dummy)); + AfterCast.Add(new(HandleAfterCast)); } - - uint _targetCount; } [Script] // 107570 - Storm Bolt @@ -568,12 +592,39 @@ namespace Scripts.Spells.Warrior public override void Register() { - OnEffectHitTarget.Add(new EffectHandler(HandleOnHit, 1, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new(HandleOnHit, 1, SpellEffectName.Dummy)); } } - // 52437 - Sudden Death - [Script] + [Script] // 384041 - Strategist + class spell_warr_strategist : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.ShieldSlam, SpellIds.ShieldSlamMarker) + && ValidateSpellEffect((SpellIds.Strategist, 0)); + } + + static bool CheckProc(AuraEffect aurEff, ProcEventInfo procEvent) + { + return RandomHelper.randChance(aurEff.GetAmount()); + } + + void HandleCooldown(AuraEffect aurEff, ProcEventInfo procEvent) + { + Unit caster = GetTarget(); + caster.GetSpellHistory().ResetCooldown(SpellIds.ShieldSlam, true); + caster.CastSpell(caster, SpellIds.ShieldSlamMarker, TriggerCastFlags.IgnoreCastInProgress); + } + + public override void Register() + { + DoCheckEffectProc.Add(new(CheckProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleCooldown, 0, AuraType.Dummy)); + } + } + + [Script] // 52437 - Sudden Death class spell_warr_sudden_death : AuraScript { public override bool Validate(SpellInfo spellInfo) @@ -585,20 +636,21 @@ namespace Scripts.Spells.Warrior { // Remove cooldown on Colossus Smash Player player = GetTarget().ToPlayer(); - if (player) + if (player != null) player.GetSpellHistory().ResetCooldown(SpellIds.ColossusSmash, true); } public override void Register() { - AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); // correct? + AfterEffectApply.Add(new(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); // correct? } } - // 12328, 18765, 35429 - Sweeping Strikes - [Script] + [Script] // 12328, 18765, 35429 - Sweeping Strikes class spell_warr_sweeping_strikes : AuraScript { + Unit _procTarget; + public override bool Validate(SpellInfo spellInfo) { return ValidateSpellInfo(SpellIds.SweepingStrikesExtraAttack1, SpellIds.SweepingStrikesExtraAttack2); @@ -607,7 +659,7 @@ namespace Scripts.Spells.Warrior bool CheckProc(ProcEventInfo eventInfo) { _procTarget = eventInfo.GetActor().SelectNearbyTarget(eventInfo.GetProcTarget()); - return _procTarget; + return _procTarget != null; } void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -620,7 +672,7 @@ namespace Scripts.Spells.Warrior if (spellInfo != null && (spellInfo.Id == SpellIds.BladestormPeriodicWhirlwind || (spellInfo.Id == SpellIds.Execute && !_procTarget.HasAuraState(AuraStateType.Wounded20Percent)))) { // If triggered by Execute (while target is not under 20% hp) or Bladestorm deals normalized weapon damage - GetTarget().CastSpell(_procTarget, SpellIds.SweepingStrikesExtraAttack2, new CastSpellExtraArgs(aurEff)); + GetTarget().CastSpell(_procTarget, SpellIds.SweepingStrikesExtraAttack2, aurEff); } else { @@ -633,11 +685,9 @@ namespace Scripts.Spells.Warrior public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + DoCheckProc.Add(new(CheckProc)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } - - Unit _procTarget; } [Script] // 215538 - Trauma @@ -652,7 +702,7 @@ namespace Scripts.Spells.Warrior { Unit target = eventInfo.GetActionTarget(); //Get 25% of damage from the spell casted (Slam & Whirlwind) plus Remaining Damage from Aura - int damage = (int)(MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()) / Global.SpellMgr.GetSpellInfo(SpellIds.TraumaEffect, GetCastDifficulty()).GetMaxTicks()); + int damage = (int)(MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()) / SpellMgr.GetSpellInfo(SpellIds.TraumaEffect, GetCastDifficulty()).GetMaxTicks()); CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); args.AddSpellMod(SpellValueMod.BasePoint0, damage); GetCaster().CastSpell(target, SpellIds.TraumaEffect, args); @@ -660,7 +710,7 @@ namespace Scripts.Spells.Warrior public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new(HandleProc, 0, AuraType.Dummy)); } } @@ -682,7 +732,7 @@ namespace Scripts.Spells.Warrior public override void Register() { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); + DoCheckProc.Add(new(CheckProc)); } } @@ -696,7 +746,7 @@ namespace Scripts.Spells.Warrior void HandleOnProc(AuraEffect aurEff, ProcEventInfo procInfo) { - if (procInfo.GetActor().GetTypeId() == TypeId.Player && procInfo.GetActor().ToPlayer().GetPrimarySpecialization() == ChrSpecialization.WarriorFury) + if (procInfo.GetActor().IsPlayer() && procInfo.GetActor().ToPlayer().GetPrimarySpecialization() == ChrSpecialization.WarriorFury) PreventDefaultAction(); procInfo.GetActor().GetSpellHistory().ResetCooldown(SpellIds.ImpendingVictory, true); @@ -704,7 +754,7 @@ namespace Scripts.Spells.Warrior public override void Register() { - OnEffectProc.Add(new EffectProcHandler(HandleOnProc, 0, AuraType.ProcTriggerSpell)); + OnEffectProc.Add(new(HandleOnProc, 0, AuraType.ProcTriggerSpell)); } } @@ -713,20 +763,19 @@ namespace Scripts.Spells.Warrior { public override bool Validate(SpellInfo spellInfo) { - return ValidateSpellInfo(SpellIds.Victorious, SpellIds.VictoriousRushHeal); + return ValidateSpellInfo(SpellIds.Victorious, SpellIds.VictoryRushHeal); } void HandleHeal() { Unit caster = GetCaster(); - - caster.CastSpell(caster, SpellIds.VictoriousRushHeal, true); + caster.CastSpell(caster, SpellIds.VictoryRushHeal, true); caster.RemoveAurasDueToSpell(SpellIds.Victorious); } public override void Register() { - AfterCast.Add(new CastHandler(HandleHeal)); + AfterCast.Add(new(HandleHeal)); } } -} +} \ No newline at end of file