diff --git a/Source/Scripts/Spells/Evoker.cs b/Source/Scripts/Spells/Evoker.cs new file mode 100644 index 000000000..71a908468 --- /dev/null +++ b/Source/Scripts/Spells/Evoker.cs @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2012-2020 CypherCore + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +using Framework.Constants; +using Game.Entities; +using Game.Scripting; +using Game.Spells; +using System; + +namespace Scripts.Spells.Evoker +{ + struct SpellIds + { + public const uint GlideKnockback = 358736; + public const uint Hover = 358267; + public const uint SoarRacial = 369536; + } + + [Script] // 358733 - Glide (Racial) + class spell_evo_glide : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.GlideKnockback, SpellIds.Hover, SpellIds.SoarRacial); + } + + SpellCastResult CheckCast() + { + Unit caster = GetCaster(); + + if (!caster.IsFalling()) + return SpellCastResult.NotOnGround; + + return SpellCastResult.SpellCastOk; + } + + void HandleCast() + { + Player caster = GetCaster().ToPlayer(); + if (caster == null) + return; + + 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)); + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckCast)); + OnCast.Add(new CastHandler(HandleCast)); + } + } +}