refactor(Scripts/Spells): Spell Scripts registry macros, rogue killing spree (#19226)

* spell_rogue pair:spell_rog_killing_spree move public AddTarget up

spell_rogue pair:spell_rog_killing_spree

* fixup! spell_rogue pair:spell_rog_killing_spree
This commit is contained in:
Jelle Meeus
2024-06-29 11:11:50 +02:00
committed by GitHub
parent 8601425c3e
commit 64e92b9bb5
+54 -69
View File
@@ -281,66 +281,9 @@ class spell_rog_deadly_poison : public SpellScript
}; };
// 51690 - Killing Spree // 51690 - Killing Spree
#define KillingSpreeScriptName "spell_rog_killing_spree" class spell_rog_killing_spree_aura : public AuraScript
class spell_rog_killing_spree : public SpellScriptLoader
{ {
public: PrepareAuraScript(spell_rog_killing_spree_aura);
spell_rog_killing_spree() : SpellScriptLoader(KillingSpreeScriptName) { }
class spell_rog_killing_spree_SpellScript : public SpellScript
{
PrepareSpellScript(spell_rog_killing_spree_SpellScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_ROGUE_KILLING_SPREE });
}
SpellCastResult CheckCast()
{
// Kologarn area, Killing Spree should not work
if (GetCaster()->GetMapId() == 603 /*Ulduar*/ && GetCaster()->GetDistance2d(1766.936f, -24.748f) < 50.0f)
return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW;
return SPELL_CAST_OK;
}
void FilterTargets(std::list<WorldObject*>& targets)
{
if (targets.empty() || GetCaster()->GetVehicleBase() || GetCaster()->HasUnitState(UNIT_STATE_ROOT))
FinishCast(SPELL_FAILED_OUT_OF_RANGE);
else
{
// Added attribute not breaking stealth, removes auras here
GetCaster()->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CAST);
GetCaster()->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_SPELL_ATTACK);
}
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
if (Aura* aura = GetCaster()->GetAura(SPELL_ROGUE_KILLING_SPREE))
{
if (spell_rog_killing_spree_AuraScript* script = dynamic_cast<spell_rog_killing_spree_AuraScript*>(aura->GetScriptByName(KillingSpreeScriptName)))
script->AddTarget(GetHitUnit());
}
}
void Register() override
{
OnCheckCast += SpellCheckCastFn(spell_rog_killing_spree_SpellScript::CheckCast);
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_rog_killing_spree_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_DEST_AREA_ENEMY);
OnEffectHitTarget += SpellEffectFn(spell_rog_killing_spree_SpellScript::HandleDummy, EFFECT_1, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_rog_killing_spree_SpellScript();
}
class spell_rog_killing_spree_AuraScript : public AuraScript
{
PrepareAuraScript(spell_rog_killing_spree_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override bool Validate(SpellInfo const* /*spellInfo*/) override
{ {
@@ -390,26 +333,68 @@ public:
GetTarget()->RemoveAurasDueToSpell(SPELL_ROGUE_KILLING_SPREE_DMG_BUFF); GetTarget()->RemoveAurasDueToSpell(SPELL_ROGUE_KILLING_SPREE_DMG_BUFF);
} }
void Register() override
{
AfterEffectApply += AuraEffectApplyFn(spell_rog_killing_spree_AuraScript::HandleApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_rog_killing_spree_AuraScript::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
AfterEffectRemove += AuraEffectRemoveFn(spell_rog_killing_spree_AuraScript::HandleRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
public: public:
void AddTarget(Unit* target) void AddTarget(Unit* target)
{ {
_targets.push_back(target->GetGUID()); _targets.push_back(target->GetGUID());
} }
void Register() override
{
AfterEffectApply += AuraEffectApplyFn(spell_rog_killing_spree_aura::HandleApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_rog_killing_spree_aura::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
AfterEffectRemove += AuraEffectRemoveFn(spell_rog_killing_spree_aura::HandleRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
private: private:
GuidList _targets; GuidList _targets;
}; };
AuraScript* GetAuraScript() const override #define KillingSpreeScriptName "spell_rog_killing_spree"
typedef spell_rog_killing_spree_aura spell_rog_killing_spree_aura_script;
class spell_rog_killing_spree : public SpellScript
{ {
return new spell_rog_killing_spree_AuraScript(); PrepareSpellScript(spell_rog_killing_spree);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_ROGUE_KILLING_SPREE });
}
SpellCastResult CheckCast()
{
// Kologarn area, Killing Spree should not work
if (GetCaster()->GetMapId() == 603 /*Ulduar*/ && GetCaster()->GetDistance2d(1766.936f, -24.748f) < 50.0f)
return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW;
return SPELL_CAST_OK;
}
void FilterTargets(std::list<WorldObject*>& targets)
{
if (targets.empty() || GetCaster()->GetVehicleBase() || GetCaster()->HasUnitState(UNIT_STATE_ROOT))
FinishCast(SPELL_FAILED_OUT_OF_RANGE);
else
{
// Added attribute not breaking stealth, removes auras here
GetCaster()->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CAST);
GetCaster()->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_SPELL_ATTACK);
}
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
if (Aura* aura = GetCaster()->GetAura(SPELL_ROGUE_KILLING_SPREE))
{
if (spell_rog_killing_spree_aura* script = dynamic_cast<spell_rog_killing_spree_aura_script*>(aura->GetScriptByName(KillingSpreeScriptName)))
script->AddTarget(GetHitUnit());
}
}
void Register() override
{
OnCheckCast += SpellCheckCastFn(spell_rog_killing_spree::CheckCast);
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_rog_killing_spree::FilterTargets, EFFECT_1, TARGET_UNIT_DEST_AREA_ENEMY);
OnEffectHitTarget += SpellEffectFn(spell_rog_killing_spree::HandleDummy, EFFECT_1, SPELL_EFFECT_DUMMY);
} }
}; };
@@ -774,7 +759,7 @@ void AddSC_rogue_spell_scripts()
RegisterSpellScript(spell_rog_blade_flurry); RegisterSpellScript(spell_rog_blade_flurry);
RegisterSpellScript(spell_rog_cheat_death); RegisterSpellScript(spell_rog_cheat_death);
RegisterSpellScript(spell_rog_deadly_poison); RegisterSpellScript(spell_rog_deadly_poison);
new spell_rog_killing_spree(); RegisterSpellAndAuraScriptPair(spell_rog_killing_spree, spell_rog_killing_spree_aura);
RegisterSpellScript(spell_rog_nerves_of_steel); RegisterSpellScript(spell_rog_nerves_of_steel);
RegisterSpellScript(spell_rog_preparation); RegisterSpellScript(spell_rog_preparation);
RegisterSpellScript(spell_rog_prey_on_the_weak); RegisterSpellScript(spell_rog_prey_on_the_weak);