diff options
-rw-r--r-- | sql/updates/world/cata_classic/2024_11_28_00_world.sql | 7 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_hunter.cpp | 66 |
2 files changed, 73 insertions, 0 deletions
diff --git a/sql/updates/world/cata_classic/2024_11_28_00_world.sql b/sql/updates/world/cata_classic/2024_11_28_00_world.sql new file mode 100644 index 00000000000..434aeef98c6 --- /dev/null +++ b/sql/updates/world/cata_classic/2024_11_28_00_world.sql @@ -0,0 +1,7 @@ +DELETE FROM `spell_script_names` WHERE `ScriptName`= 'spell_hun_improved_steady_shot'; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(-53221, 'spell_hun_improved_steady_shot'); + +DELETE FROM `spell_proc` WHERE `SpellId`= -53221; +INSERT INTO `spell_proc` (`SpellId`, `SpellFamilyName`, `SpellTypeMask`, `SpellPhaseMask`) VALUES +(-53221, 9, 0x1, 0x1); diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index d1f231563b4..a3ebb2a2bfc 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -22,7 +22,73 @@ */ #include "ScriptMgr.h" +#include "SpellAuraEffects.h" +#include "SpellAuras.h" +#include "SpellScript.h" +#include "Unit.h" + +namespace Scripts::Spells::Hunter +{ + enum HunterSpells + { + SPELL_HUN_IMPROVED_STEADY_SHOT_TRIGGERED = 53220 + }; + + enum HunterSpellFamilies + { + SPELL_FAMILY_HUN_STEADY_SHOT = 0x1 + }; + + // -53221 - Improved Steady Shot + class spell_hun_improved_steady_shot : public AuraScript + { + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_HUN_IMPROVED_STEADY_SHOT_TRIGGERED }); + } + + // If a ranged spell with spell_family_hunter is being cast, check if it's a steady shot ability. If not, reset the counter back to zero + bool CheckEffectProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo) + { + if (!eventInfo.GetSpellInfo() || eventInfo.GetSpellInfo()->IsAutoRepeatRangedSpell() || !eventInfo.GetSpellInfo()->IsRangedWeaponSpell()) + return false; + + if (!eventInfo.GetSpellInfo()->SpellFamilyFlags.HasFlag(0, SPELL_FAMILY_HUN_STEADY_SHOT, 0, 0)) + { + _steadyShotCount = 0; + return false; + } + + return true; + } + + // Increment the steady shot counter. If the counter is at 2 or higher, trigger the haste bonus spell cast and reset the counter back to zero + void HandleEffectProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) + { + ++_steadyShotCount; + if (_steadyShotCount >= 2) + { + eventInfo.GetActor()->CastSpell(nullptr, SPELL_HUN_IMPROVED_STEADY_SHOT_TRIGGERED, CastSpellExtraArgs(TRIGGERED_FULL_MASK) + .SetTriggeringAura(aurEff) + .AddSpellBP0(aurEff->GetAmount())); + + _steadyShotCount = 0; + } + } + + void Register() override + { + DoCheckEffectProc += AuraCheckEffectProcFn(spell_hun_improved_steady_shot::CheckEffectProc, EFFECT_0, SPELL_AURA_DUMMY); + OnEffectProc += AuraEffectProcFn(spell_hun_improved_steady_shot::HandleEffectProc, EFFECT_0, SPELL_AURA_DUMMY); + } + + private: + uint8 _steadyShotCount = 0; + }; +} void AddSC_hunter_spell_scripts() { + using namespace Scripts::Spells::Hunter; + RegisterSpellScript(spell_hun_improved_steady_shot); } |