From 2576fded97c4f8c008cf0cb92f93fd79608e74b9 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 2 Jun 2021 18:53:39 -0400 Subject: [PATCH] Scripts/Spells: Implement mage Alter Time Port From (https://github.com/TrinityCore/TrinityCore/commit/28c075765bdf33a4444a0e13253da7e9f9e0f447) --- Source/Scripts/Spells/Mage.cs | 70 +++++++++++++++++++ ...1_05_27_00_world_mage_spell_alter_time.sql | 7 ++ 2 files changed, 77 insertions(+) create mode 100644 sql/updates/world/master/2021_05_27_00_world_mage_spell_alter_time.sql diff --git a/Source/Scripts/Spells/Mage.cs b/Source/Scripts/Spells/Mage.cs index c5d565a1d..4eda49943 100644 --- a/Source/Scripts/Spells/Mage.cs +++ b/Source/Scripts/Spells/Mage.cs @@ -29,11 +29,15 @@ namespace Scripts.Spells.Mage { struct SpellIds { + public const uint AlterTimeAura = 110909; + public const uint AlterTimeVisual = 347402; + public const uint ArcaneAlterTimeAura = 342246; public const uint ArcaneBarrageEnergize = 321529; public const uint ArcaneBarrageR3 = 321526; public const uint ArcaneCharge = 36032; public const uint ArcaneMage = 137021; public const uint BlazingBarrierTrigger = 235314; + public const uint Blink = 1953; public const uint Cauterized = 87024; public const uint CauterizeDot = 87023; public const uint ConeOfCold = 120; @@ -50,6 +54,7 @@ namespace Scripts.Spells.Mage public const uint LivingBombExplosion = 44461; public const uint LivingBombPeriodic = 217694; public const uint ManaSurge = 37445; + public const uint MasterOfTime = 342249; public const uint Reverberate = 281482; public const uint RingOfFrostDummy = 91264; public const uint RingOfFrostFreeze = 82691; @@ -74,6 +79,71 @@ namespace Scripts.Spells.Mage public const uint PetNetherwindsFatigued = 160455; } + // 110909 - Alter Time Aura + [Script] // 342246 - Alter Time Aura + class spell_mage_alter_time_aura : AuraScript + { + ulong _health; + Position _pos; + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.AlterTimeVisual, SpellIds.MasterOfTime, SpellIds.Blink); + } + + void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit unit = GetTarget(); + _health = unit.GetHealth(); + _pos = unit.GetPosition(); + } + + void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit unit = GetTarget(); + if (unit.GetDistance(_pos) <= 100.0f && GetTargetApplication().GetRemoveMode() == AuraRemoveMode.Expire) + { + unit.SetHealth(_health); + unit.NearTeleportTo(_pos); + + if (unit.HasAura(SpellIds.MasterOfTime)) + { + SpellInfo blink = Global.SpellMgr.GetSpellInfo(SpellIds.Blink, Difficulty.None); + unit.GetSpellHistory().ResetCharges(blink.ChargeCategoryId); + } + unit.CastSpell(unit, SpellIds.AlterTimeVisual); + } + } + + public override void Register() + { + OnEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.OverrideActionbarSpells, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 0, AuraType.OverrideActionbarSpells, AuraEffectHandleModes.Real)); + } + } + + // 127140 - Alter Time Active + [Script] // 342247 - Alter Time Active + class spell_mage_alter_time_active : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.AlterTimeAura, SpellIds.ArcaneAlterTimeAura); + } + + void RemoveAlterTimeAura(uint effIndex) + { + Unit unit = GetCaster(); + unit.RemoveAura(SpellIds.AlterTimeAura, ObjectGuid.Empty, 0, AuraRemoveMode.Expire); + unit.RemoveAura(SpellIds.ArcaneAlterTimeAura, ObjectGuid.Empty, 0, AuraRemoveMode.Expire); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(RemoveAlterTimeAura, 0, SpellEffectName.Dummy)); + } + } + [Script] // 44425 - Arcane Barrage class spell_mage_arcane_barrage : SpellScript { diff --git a/sql/updates/world/master/2021_05_27_00_world_mage_spell_alter_time.sql b/sql/updates/world/master/2021_05_27_00_world_mage_spell_alter_time.sql new file mode 100644 index 000000000..bceb4d56b --- /dev/null +++ b/sql/updates/world/master/2021_05_27_00_world_mage_spell_alter_time.sql @@ -0,0 +1,7 @@ +-- mage Alter Time spell +DELETE FROM `spell_script_names` WHERE `ScriptName` IN ('spell_mage_alter_time_aura', 'spell_mage_alter_time_active'); +INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES +(110909,'spell_mage_alter_time_aura'), +(127140,'spell_mage_alter_time_active'), +(342246,'spell_mage_alter_time_aura'), +(342247,'spell_mage_alter_time_active');