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 | |
parent | a855cc8decf942c94985edb5219a57eae0755c5e (diff) |
Scripts/Spells: Implement racial spell "Spatial Rift" (#30583)
-rw-r--r-- | sql/updates/world/master/2025_01_11_01_world.sql | 11 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_generic.cpp | 61 |
2 files changed, 72 insertions, 0 deletions
diff --git a/sql/updates/world/master/2025_01_11_01_world.sql b/sql/updates/world/master/2025_01_11_01_world.sql new file mode 100644 index 00000000000..0988d8dbba8 --- /dev/null +++ b/sql/updates/world/master/2025_01_11_01_world.sql @@ -0,0 +1,11 @@ +DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_gen_spatial_rift'; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(257040, 'spell_gen_spatial_rift'); + +DELETE FROM `areatrigger_template` WHERE `Id` = 16670; +INSERT INTO `areatrigger_template` (`Id`, `IsCustom`, `Flags`, `ActionSetId`, `ActionSetFlags`, `VerifiedBuild`) VALUES +(16670, 0, 0, 0, 0, 58238); + +DELETE FROM `areatrigger_create_properties` WHERE `Id` = 11983; +INSERT INTO `areatrigger_create_properties` (`Id`, `IsCustom`, `AreaTriggerId`, `IsAreaTriggerCustom`, `Flags`, `MoveCurveId`, `ScaleCurveId`, `MorphCurveId`, `FacingCurveId`, `AnimId`, `AnimKitId`, `DecalPropertiesId`, `SpellForVisuals`, `TimeToTargetScale`, `Speed`, `Shape`, `ShapeData0`, `ShapeData1`, `ShapeData2`, `ShapeData3`, `ShapeData4`, `ShapeData5`, `ShapeData6`, `ShapeData7`, `ScriptName`, `VerifiedBuild`) VALUES +(11983, 0, 16670, 0, 0, 0, 0, 0, 0, 0, -1, 0, 256948, 8000, 18, 0, 3, 3, 0, 0, 0, 0, 0, 0, 'at_gen_spatial_rift', 58238); -- SpellForVisuals: 256948 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); } |