diff options
author | Muru <timurdelimin@gmail.com> | 2025-01-12 03:35:23 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-11 21:35:23 +0100 |
commit | 575e37859b2a7b76f3af92893b1a1f35a8a2057d (patch) | |
tree | db9bc8c7bf350f03b9e7a23950f533a28d68353d /src | |
parent | a855cc8decf942c94985edb5219a57eae0755c5e (diff) |
Scripts/Spells: Implement racial spell "Spatial Rift" (#30583)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/scripts/Spells/spell_generic.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 3e8fc531ac7..c414d8100eb 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -23,6 +23,8 @@ */ #include "ScriptMgr.h" +#include "AreaTrigger.h" +#include "AreaTriggerAI.h" #include "Battleground.h" #include "BattlePetMgr.h" #include "CellImpl.h" @@ -40,6 +42,7 @@ #include "ObjectMgr.h" #include "Pet.h" #include "ReputationMgr.h" +#include "PathGenerator.h" #include "SkillDiscovery.h" #include "SpellAuraEffects.h" #include "SpellHistory.h" @@ -5496,6 +5499,62 @@ class spell_gen_saddlechute : public AuraScript } }; +enum SpatialRiftSpells +{ + SPELL_SPATIAL_RIFT_TELEPORT = 257034, + SPELL_SPATIAL_RIFT_AREATRIGGER = 256948 +}; + +// 257040 - Spatial Rift +class spell_gen_spatial_rift : public SpellScript +{ + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_SPATIAL_RIFT_TELEPORT, SPELL_SPATIAL_RIFT_AREATRIGGER }); + } + + void HandleDummy(SpellEffIndex /*effIndex*/) const + { + Unit* caster = GetCaster(); + + AreaTrigger* at = caster->GetAreaTrigger(SPELL_SPATIAL_RIFT_AREATRIGGER); + if (!at) + return; + + caster->CastSpell(at->GetPosition(), SPELL_SPATIAL_RIFT_TELEPORT, CastSpellExtraArgsInit{ + .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, + .TriggeringSpell = GetSpell() + }); + + at->SetDuration(0); + } + + void Register() override + { + OnEffectHit += SpellEffectFn(spell_gen_spatial_rift::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } +}; + +struct at_gen_spatial_rift : AreaTriggerAI +{ + using AreaTriggerAI::AreaTriggerAI; + + void OnInitialize() override + { + SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(at->GetSpellId(), DIFFICULTY_NONE); + if (!spellInfo) + return; + + Position destPos = at->GetPosition(); + at->MovePositionToFirstCollision(destPos, spellInfo->GetMaxRange(), 0.0f); + + PathGenerator path(at); + path.CalculatePath(destPos.GetPositionX(), destPos.GetPositionY(), destPos.GetPositionZ(), true); + + at->InitSplines(path.GetPath()); + } +}; + void AddSC_generic_spell_scripts() { RegisterSpellScript(spell_gen_absorb0_hitlimit1); @@ -5679,4 +5738,6 @@ void AddSC_generic_spell_scripts() RegisterSpellAndAuraScriptPair(spell_bg_defending_cart_aura, spell_bg_defending_cart_aura_AuraScript); RegisterSpellScript(spell_gen_comfortable_riders_barding); RegisterSpellScript(spell_gen_saddlechute); + RegisterSpellScript(spell_gen_spatial_rift); + RegisterAreaTriggerAI(at_gen_spatial_rift); } |