diff options
author | Aqua Deus <95978183+aquadeus@users.noreply.github.com> | 2025-01-13 22:21:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-13 22:21:09 +0100 |
commit | 210daa31cd8598cf49159a00ea27a102ba3b2262 (patch) | |
tree | c602a0d312cac3a5f767b8b1c53cfdbfac5c3dc1 | |
parent | 55dda32225a653d1ecdd44d88e8566f8dd2f4121 (diff) |
Scripts/Spells: Implement evoker talent "Snapfire" (#30580)
Co-authored-by: Shauren <shauren.trinity@gmail.com>
-rw-r--r-- | sql/updates/world/master/2025_01_13_06_world.sql | 9 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_evoker.cpp | 64 |
2 files changed, 71 insertions, 2 deletions
diff --git a/sql/updates/world/master/2025_01_13_06_world.sql b/sql/updates/world/master/2025_01_13_06_world.sql new file mode 100644 index 00000000000..05362893cd7 --- /dev/null +++ b/sql/updates/world/master/2025_01_13_06_world.sql @@ -0,0 +1,9 @@ +DELETE FROM `spell_script_names` WHERE `ScriptName`IN ('spell_evo_snapfire', 'spell_evo_snapfire_bonus_damage'); +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(368847, 'spell_evo_snapfire'), +(369374, 'spell_evo_snapfire_bonus_damage'); + +DELETE FROM `spell_proc` WHERE `SpellId` IN (370783,370818); +INSERT INTO `spell_proc` (`SpellId`,`SchoolMask`,`SpellFamilyName`,`SpellFamilyMask0`,`SpellFamilyMask1`,`SpellFamilyMask2`,`SpellFamilyMask3`,`ProcFlags`,`ProcFlags2`,`SpellTypeMask`,`SpellPhaseMask`,`HitMask`,`AttributesMask`,`DisableEffectsMask`,`ProcsPerMinute`,`Chance`,`Cooldown`,`Charges`) VALUES +(370783,0x00,224,0x00000020,0x00040000,0x00000000,0x00000000,0x00000000,0x0,0x1,0x2,0x0,0x0,0x0,0,0,0,0), -- Snapfire +(370818,0x00,224,0x00000000,0x00000000,0x00000000,0x00000000,0x20000000,0x0,0x0,0x0,0x0,0x8,0x0,0,100,0,1); -- Snapfire diff --git a/src/server/scripts/Spells/spell_evoker.cpp b/src/server/scripts/Spells/spell_evoker.cpp index cd79566aa81..54f62d3624a 100644 --- a/src/server/scripts/Spells/spell_evoker.cpp +++ b/src/server/scripts/Spells/spell_evoker.cpp @@ -62,6 +62,7 @@ enum EvokerSpells SPELL_EVOKER_PYRE_DAMAGE = 357212, SPELL_EVOKER_RUBY_EMBERS = 365937, SPELL_EVOKER_SCOURING_FLAME = 378438, + SPELL_EVOKER_SNAPFIRE = 370818, SPELL_EVOKER_SOAR_RACIAL = 369536, SPELL_EVOKER_VERDANT_EMBRACE_HEAL = 361195, SPELL_EVOKER_VERDANT_EMBRACE_JUMP = 373514 @@ -229,15 +230,33 @@ struct at_evo_firestorm : AreaTriggerAI { using AreaTriggerAI::AreaTriggerAI; - void OnCreate(Spell const* /*creatingSpell*/) override + struct extra_create_data { + float SnapshotDamageMultipliers = 1.0f; + }; + + static extra_create_data& GetOrCreateExtraData(Spell* firestorm) + { + if (firestorm->m_customArg.type() != typeid(extra_create_data)) + return firestorm->m_customArg.emplace<extra_create_data>(); + + return *std::any_cast<extra_create_data>(&firestorm->m_customArg); + } + + void OnCreate(Spell const* creatingSpell) override + { + _damageSpellCustomArg = creatingSpell->m_customArg; + _scheduler.Schedule(0ms, [this](TaskContext task) { std::chrono::duration<float> period = 2s; // 2s, affected by haste if (Unit* caster = at->GetCaster()) { period *= *caster->m_unitData->ModCastingSpeed; - caster->CastSpell(at->GetPosition(), SPELL_EVOKER_FIRESTORM_DAMAGE, TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR); + caster->CastSpell(at->GetPosition(), SPELL_EVOKER_FIRESTORM_DAMAGE, CastSpellExtraArgsInit{ + .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, + .CustomArg = _damageSpellCustomArg + }); } task.Repeat(duration_cast<Milliseconds>(period)); @@ -251,6 +270,7 @@ struct at_evo_firestorm : AreaTriggerAI private: TaskScheduler _scheduler; + std::any _damageSpellCustomArg; }; // 358733 - Glide (Racial) @@ -434,6 +454,44 @@ class spell_evo_scouring_flame : public SpellScript } }; +// Called by 368847 - Firestorm (Red) +class spell_evo_snapfire : public SpellScript +{ + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellEffect({ { SPELL_EVOKER_SNAPFIRE, EFFECT_1 } }); + } + + bool Load() override + { + return GetCaster()->HasAura(SPELL_EVOKER_SNAPFIRE); + } + + void OnPrecast() override + { + if (AuraEffect const* snapfire = GetCaster()->GetAuraEffect(SPELL_EVOKER_SNAPFIRE, EFFECT_1)) + if (GetSpell()->m_appliedMods.contains(snapfire->GetBase())) + AddPct(at_evo_firestorm::GetOrCreateExtraData(GetSpell()).SnapshotDamageMultipliers, snapfire->GetAmount()); + } + + void Register() override { } +}; + +// Called by 369374 - Firestorm (Red) +class spell_evo_snapfire_bonus_damage : public SpellScript +{ + void CalculateDamageBonus(SpellEffectInfo const& /*spellEffectInfo*/, Unit* /*victim*/, int32& /*damage*/, int32& /*flatMod*/, float& pctMod) const + { + if (at_evo_firestorm::extra_create_data const* bonus = std::any_cast<at_evo_firestorm::extra_create_data>(&GetSpell()->m_customArg)) + pctMod *= bonus->SnapshotDamageMultipliers; + } + + void Register() override + { + CalcDamage += SpellCalcDamageFn(spell_evo_snapfire_bonus_damage::CalculateDamageBonus); + } +}; + // 360995 - Verdant Embrace (Green) class spell_evo_verdant_embrace : public SpellScript { @@ -502,6 +560,8 @@ void AddSC_evoker_spell_scripts() RegisterSpellScript(spell_evo_pyre); RegisterSpellScript(spell_evo_ruby_embers); RegisterSpellScript(spell_evo_scouring_flame); + RegisterSpellScript(spell_evo_snapfire); + RegisterSpellScript(spell_evo_snapfire_bonus_damage); RegisterSpellScript(spell_evo_verdant_embrace); RegisterSpellScript(spell_evo_verdant_embrace_trigger_heal); } |