refactor(Scripts/Karazhan): Spell Scripts registry macros (#19184)

* instance_karazhan aura:spell_karazhan_brittle_bones_aura

* instance_karazhan aura:spell_karazhan_overload_aura

* instance_karazhan spell:spell_karazhan_blink
This commit is contained in:
Jelle Meeus
2024-06-26 22:26:19 +02:00
committed by GitHub
parent 40b63666ad
commit b259ec6df7
2 changed files with 56 additions and 71 deletions

View File

@@ -0,0 +1,3 @@
--
UPDATE `spell_script_names` SET `ScriptName`='spell_karazhan_brittle_bones_aura' WHERE `spell_id`=32441;
UPDATE `spell_script_names` SET `ScriptName`='spell_karazhan_overload_aura' WHERE `spell_id`=29768;

View File

@@ -528,103 +528,85 @@ public:
};
};
class spell_karazhan_brittle_bones : public SpellScriptLoader
class spell_karazhan_brittle_bones_aura : public AuraScript
{
public:
spell_karazhan_brittle_bones() : SpellScriptLoader("spell_karazhan_brittle_bones") { }
PrepareAuraScript(spell_karazhan_brittle_bones_aura);
class spell_karazhan_brittle_bones_AuraScript : public AuraScript
bool Validate(SpellInfo const* /*spellInfo*/) override
{
PrepareAuraScript(spell_karazhan_brittle_bones_AuraScript);
return ValidateSpellInfo({ SPELL_RATTLED });
}
void CalcPeriodic(AuraEffect const* /*effect*/, bool& isPeriodic, int32& amplitude)
{
isPeriodic = true;
amplitude = 5000;
}
void Update(AuraEffect const* /*effect*/)
{
PreventDefaultAction();
if (roll_chance_i(35))
GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_RATTLED, true);
}
void Register() override
{
DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_karazhan_brittle_bones_AuraScript::CalcPeriodic, EFFECT_0, SPELL_AURA_DUMMY);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_karazhan_brittle_bones_AuraScript::Update, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
void CalcPeriodic(AuraEffect const* /*effect*/, bool& isPeriodic, int32& amplitude)
{
return new spell_karazhan_brittle_bones_AuraScript();
isPeriodic = true;
amplitude = 5000;
}
void Update(AuraEffect const* /*effect*/)
{
PreventDefaultAction();
if (roll_chance_i(35))
GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_RATTLED, true);
}
void Register() override
{
DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_karazhan_brittle_bones_aura::CalcPeriodic, EFFECT_0, SPELL_AURA_DUMMY);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_karazhan_brittle_bones_aura::Update, EFFECT_0, SPELL_AURA_DUMMY);
}
};
class spell_karazhan_overload : public SpellScriptLoader
class spell_karazhan_overload_aura : public AuraScript
{
public:
spell_karazhan_overload() : SpellScriptLoader("spell_karazhan_overload") { }
PrepareAuraScript(spell_karazhan_overload_aura);
class spell_karazhan_overload_AuraScript : public AuraScript
bool Validate(SpellInfo const* /*spellInfo*/) override
{
PrepareAuraScript(spell_karazhan_overload_AuraScript);
return ValidateSpellInfo({ SPELL_OVERLOAD });
}
void PeriodicTick(AuraEffect const* auraEffect)
{
PreventDefaultAction();
//Should stop at 3200 damage, maybe check needed(?)
GetUnitOwner()->CastCustomSpell(SPELL_OVERLOAD, SPELLVALUE_BASE_POINT0, int32(auraEffect->GetAmount() * pow(2.0, auraEffect->GetTickNumber())), GetUnitOwner(), true);
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_karazhan_overload_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
}
};
AuraScript* GetAuraScript() const override
void PeriodicTick(AuraEffect const* auraEffect)
{
return new spell_karazhan_overload_AuraScript();
PreventDefaultAction();
//Should stop at 3200 damage, maybe check needed(?)
GetUnitOwner()->CastCustomSpell(SPELL_OVERLOAD, SPELLVALUE_BASE_POINT0, int32(auraEffect->GetAmount() * pow(2.0, auraEffect->GetTickNumber())), GetUnitOwner(), true);
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_karazhan_overload_aura::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
}
};
class spell_karazhan_blink : public SpellScriptLoader
class spell_karazhan_blink : public SpellScript
{
public:
spell_karazhan_blink() : SpellScriptLoader("spell_karazhan_blink") { }
PrepareSpellScript(spell_karazhan_blink);
class spell_karazhan_blink_SpellScript : public SpellScript
bool Validate(SpellInfo const* /*spellInfo*/) override
{
PrepareSpellScript(spell_karazhan_blink_SpellScript);
return ValidateSpellInfo({ SPELL_BLINK });
}
void HandleDummy(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetCaster()->GetThreatMgr().ResetAllThreat();
if (Unit* target = GetHitUnit())
GetCaster()->CastSpell(target, SPELL_BLINK, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_karazhan_blink_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
void HandleDummy(SpellEffIndex effIndex)
{
return new spell_karazhan_blink_SpellScript();
PreventHitDefaultEffect(effIndex);
GetCaster()->GetThreatMgr().ResetAllThreat();
if (Unit* target = GetHitUnit())
GetCaster()->CastSpell(target, SPELL_BLINK, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_karazhan_blink::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
void AddSC_instance_karazhan()
{
new instance_karazhan();
new spell_karazhan_brittle_bones();
new spell_karazhan_overload();
new spell_karazhan_blink();
RegisterSpellScript(spell_karazhan_brittle_bones_aura);
RegisterSpellScript(spell_karazhan_overload_aura);
RegisterSpellScript(spell_karazhan_blink);
}