refactor(Scripts/Hodir): spellscripts use registry macros (#19126)

This commit is contained in:
Jelle Meeus
2024-06-22 20:22:24 +02:00
committed by GitHub
parent 2555dbd727
commit 9c7cf93cd8
4 changed files with 231 additions and 302 deletions
@@ -0,0 +1,5 @@
--
UPDATE `spell_script_names` SET `ScriptName`='spell_hodir_storm_power_aura' WHERE `spell_id` IN (63711,65134);
UPDATE `spell_script_names` SET `ScriptName`='spell_hodir_storm_cloud_aura' WHERE `spell_id` IN (65123,65133);
UPDATE `spell_script_names` SET `ScriptName`='spell_hodir_toasty_fire_aura' WHERE `spell_id`=62821;
UPDATE `spell_script_names` SET `ScriptName`='spell_hodir_starlight_aura' WHERE `spell_id`=62807;
@@ -1180,16 +1180,11 @@ public:
}; };
}; };
class spell_hodir_shatter_chest : public SpellScriptLoader class spell_hodir_shatter_chest : public SpellScript
{ {
public: PrepareSpellScript(spell_hodir_shatter_chest);
spell_hodir_shatter_chest() : SpellScriptLoader("spell_hodir_shatter_chest") { }
class spell_hodir_shatter_chestSpellScript : public SpellScript void DestroyWinterCache(SpellEffIndex effIndex)
{
PrepareSpellScript(spell_hodir_shatter_chestSpellScript)
void destroyWinterCache(SpellEffIndex effIndex)
{ {
PreventHitDefaultEffect(effIndex); PreventHitDefaultEffect(effIndex);
@@ -1199,24 +1194,18 @@ public:
void Register() override void Register() override
{ {
OnEffectHit += SpellEffectFn(spell_hodir_shatter_chestSpellScript::destroyWinterCache, EFFECT_0, SPELL_EFFECT_TRIGGER_MISSILE); OnEffectHit += SpellEffectFn(spell_hodir_shatter_chest::DestroyWinterCache, EFFECT_0, SPELL_EFFECT_TRIGGER_MISSILE);
}; };
}; };
SpellScript* GetSpellScript() const override class spell_hodir_biting_cold_main_aura : public AuraScript
{ {
return new spell_hodir_shatter_chestSpellScript(); PrepareAuraScript(spell_hodir_biting_cold_main_aura);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_BITING_COLD_PLAYER_AURA, SPELL_MAGE_TOASTY_FIRE_AURA });
} }
};
class spell_hodir_biting_cold_main_aura : public SpellScriptLoader
{
public:
spell_hodir_biting_cold_main_aura() : SpellScriptLoader("spell_hodir_biting_cold_main_aura") { }
class spell_hodir_biting_cold_main_aura_AuraScript : public AuraScript
{
PrepareAuraScript(spell_hodir_biting_cold_main_aura_AuraScript)
void HandleEffectPeriodic(AuraEffect const* aurEff) void HandleEffectPeriodic(AuraEffect const* aurEff)
{ {
@@ -1231,27 +1220,25 @@ public:
void Register() override void Register() override
{ {
OnEffectPeriodic += AuraEffectPeriodicFn(spell_hodir_biting_cold_main_aura_AuraScript::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); OnEffectPeriodic += AuraEffectPeriodicFn(spell_hodir_biting_cold_main_aura::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
} }
}; };
AuraScript* GetAuraScript() const override class spell_hodir_biting_cold_player_aura : public AuraScript
{ {
return new spell_hodir_biting_cold_main_aura_AuraScript(); PrepareAuraScript(spell_hodir_biting_cold_player_aura);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_FLASH_FREEZE_TRAPPED_PLAYER, SPELL_MAGE_TOASTY_FIRE_AURA, SPELL_BITING_COLD_DAMAGE });
} }
};
class spell_hodir_biting_cold_player_aura : public SpellScriptLoader bool Load() override
{ {
public: _counter = 0;
spell_hodir_biting_cold_player_aura() : SpellScriptLoader("spell_hodir_biting_cold_player_aura") { } _prev = false;
return true;
class spell_hodir_biting_cold_player_aura_AuraScript : public AuraScript }
{
PrepareAuraScript(spell_hodir_biting_cold_player_aura_AuraScript)
uint8 counter {0};
bool prev {false};
void HandleEffectPeriodic(AuraEffect const* /*aurEff*/) void HandleEffectPeriodic(AuraEffect const* /*aurEff*/)
{ {
@@ -1263,31 +1250,31 @@ public:
return; return;
if (target->isMoving() || target->HasAura(SPELL_MAGE_TOASTY_FIRE_AURA)) if (target->isMoving() || target->HasAura(SPELL_MAGE_TOASTY_FIRE_AURA))
{ {
if (prev) if (_prev)
{ {
ModStackAmount(-1); ModStackAmount(-1);
prev = false; _prev = false;
} }
else else
prev = true; _prev = true;
if (counter >= 2) if (_counter >= 2)
counter -= 2; _counter -= 2;
else if (counter) else if (_counter)
--counter; --_counter;
} }
else else
{ {
prev = false; _prev = false;
++counter; ++_counter;
if (counter >= 4) if (_counter >= 4)
{ {
if (GetStackAmount() == 2) // increasing from 2 to 3 (not checking >= to improve performance) if (GetStackAmount() == 2) // increasing from 2 to 3 (not checking >= to improve performance)
if (InstanceScript* pInstance = target->GetInstanceScript()) if (InstanceScript* pInstance = target->GetInstanceScript())
if (Creature* hodir = pInstance->instance->GetCreature(pInstance->GetGuidData(TYPE_HODIR))) if (Creature* hodir = pInstance->instance->GetCreature(pInstance->GetGuidData(TYPE_HODIR)))
hodir->AI()->SetData(2, 1); hodir->AI()->SetData(2, 1);
ModStackAmount(1); ModStackAmount(1);
counter = 0; _counter = 0;
} }
} }
@@ -1298,24 +1285,17 @@ public:
void Register() override void Register() override
{ {
OnEffectPeriodic += AuraEffectPeriodicFn(spell_hodir_biting_cold_player_aura_AuraScript::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); OnEffectPeriodic += AuraEffectPeriodicFn(spell_hodir_biting_cold_player_aura::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
} }
private:
uint8 _counter;
bool _prev;
}; };
AuraScript* GetAuraScript() const override class spell_hodir_periodic_icicle : public SpellScript
{ {
return new spell_hodir_biting_cold_player_aura_AuraScript(); PrepareSpellScript(spell_hodir_periodic_icicle);
}
};
class spell_hodir_periodic_icicle : public SpellScriptLoader
{
public:
spell_hodir_periodic_icicle() : SpellScriptLoader("spell_hodir_periodic_icicle") { }
class spell_hodir_periodic_icicle_SpellScript : public SpellScript
{
PrepareSpellScript(spell_hodir_periodic_icicle_SpellScript);
void FilterTargets(std::list<WorldObject*>& targets) void FilterTargets(std::list<WorldObject*>& targets)
{ {
@@ -1326,13 +1306,7 @@ public:
void Register() override void Register() override
{ {
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_hodir_periodic_icicle_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_hodir_periodic_icicle::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_hodir_periodic_icicle_SpellScript();
} }
}; };
@@ -1349,14 +1323,9 @@ public:
} }
}; };
class spell_hodir_flash_freeze : public SpellScriptLoader class spell_hodir_flash_freeze : public SpellScript
{ {
public: PrepareSpellScript(spell_hodir_flash_freeze);
spell_hodir_flash_freeze() : SpellScriptLoader("spell_hodir_flash_freeze") { }
class spell_hodir_flash_freeze_SpellScript : public SpellScript
{
PrepareSpellScript(spell_hodir_flash_freeze_SpellScript);
void FilterTargets(std::list<WorldObject*>& targets) void FilterTargets(std::list<WorldObject*>& targets)
{ {
@@ -1365,14 +1334,19 @@ public:
void Register() override void Register() override
{ {
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_hodir_flash_freeze_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_hodir_flash_freeze::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_hodir_flash_freeze_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_hodir_flash_freeze::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY);
} }
}; };
class spell_hodir_flash_freeze_AuraScript : public AuraScript class spell_hodir_flash_freeze_aura : public AuraScript
{ {
PrepareAuraScript(spell_hodir_flash_freeze_AuraScript) PrepareAuraScript(spell_hodir_flash_freeze_aura);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_FLASH_FREEZE_INSTAKILL, SPELL_FLASH_FREEZE_TRAPPED_PLAYER, SPELL_FLASH_FREEZE_TRAPPED_NPC });
}
void HandleEffectPeriodic(AuraEffect const* aurEff) void HandleEffectPeriodic(AuraEffect const* aurEff)
{ {
@@ -1417,29 +1391,13 @@ public:
void Register() override void Register() override
{ {
OnEffectPeriodic += AuraEffectPeriodicFn(spell_hodir_flash_freeze_AuraScript::HandleEffectPeriodic, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY); OnEffectPeriodic += AuraEffectPeriodicFn(spell_hodir_flash_freeze_aura::HandleEffectPeriodic, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY);
} }
}; };
SpellScript* GetSpellScript() const override class spell_hodir_storm_power_aura : public AuraScript
{ {
return new spell_hodir_flash_freeze_SpellScript(); PrepareAuraScript(spell_hodir_storm_power_aura);
}
AuraScript* GetAuraScript() const override
{
return new spell_hodir_flash_freeze_AuraScript();
}
};
class spell_hodir_storm_power : public SpellScriptLoader
{
public:
spell_hodir_storm_power() : SpellScriptLoader("spell_hodir_storm_power") { }
class spell_hodir_storm_power_AuraScript : public AuraScript
{
PrepareAuraScript(spell_hodir_storm_power_AuraScript)
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {
@@ -1457,25 +1415,19 @@ public:
void Register() override void Register() override
{ {
OnEffectApply += AuraEffectApplyFn(spell_hodir_storm_power_AuraScript::OnApply, EFFECT_0, SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, AURA_EFFECT_HANDLE_REAL); OnEffectApply += AuraEffectApplyFn(spell_hodir_storm_power_aura::OnApply, EFFECT_0, SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, AURA_EFFECT_HANDLE_REAL);
AfterEffectApply += AuraEffectApplyFn(spell_hodir_storm_power_AuraScript::HandleAfterEffectApply, EFFECT_0, SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK); AfterEffectApply += AuraEffectApplyFn(spell_hodir_storm_power_aura::HandleAfterEffectApply, EFFECT_0, SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK);
} }
}; };
AuraScript* GetAuraScript() const override class spell_hodir_storm_cloud_aura : public AuraScript
{ {
return new spell_hodir_storm_power_AuraScript(); PrepareAuraScript(spell_hodir_storm_cloud_aura);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_SHAMAN_STORM_CLOUD_10, SPELL_SHAMAN_STORM_POWER_10, SPELL_SHAMAN_STORM_POWER_25 });
} }
};
class spell_hodir_storm_cloud : public SpellScriptLoader
{
public:
spell_hodir_storm_cloud() : SpellScriptLoader("spell_hodir_storm_cloud") { }
class spell_hodir_storm_cloud_AuraScript : public AuraScript
{
PrepareAuraScript(spell_hodir_storm_cloud_AuraScript)
void HandleEffectPeriodic(AuraEffect const* /*aurEff*/) void HandleEffectPeriodic(AuraEffect const* /*aurEff*/)
{ {
@@ -1486,13 +1438,41 @@ public:
void Register() override void Register() override
{ {
OnEffectPeriodic += AuraEffectPeriodicFn(spell_hodir_storm_cloud_AuraScript::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); OnEffectPeriodic += AuraEffectPeriodicFn(spell_hodir_storm_cloud_aura::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
} }
}; };
AuraScript* GetAuraScript() const override class spell_hodir_toasty_fire_aura : public AuraScript
{ {
return new spell_hodir_storm_cloud_AuraScript(); PrepareAuraScript(spell_hodir_toasty_fire_aura);
void HandleAfterEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Unit* target = GetTarget())
if (target->GetTypeId() == TYPEID_PLAYER)
target->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2, SPELL_MAGE_TOASTY_FIRE_AURA, 0, GetCaster());
}
void Register() override
{
AfterEffectApply += AuraEffectApplyFn(spell_hodir_toasty_fire_aura::HandleAfterEffectApply, EFFECT_0, SPELL_AURA_MOD_STAT, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK);
}
};
class spell_hodir_starlight_aura : public AuraScript
{
PrepareAuraScript(spell_hodir_starlight_aura);
void HandleAfterEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Unit* target = GetTarget())
if (target->GetTypeId() == TYPEID_PLAYER)
target->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2, SPELL_DRUID_STARLIGHT_AREA_AURA, 0, GetCaster());
}
void Register() override
{
AfterEffectApply += AuraEffectApplyFn(spell_hodir_starlight_aura::HandleAfterEffectApply, EFFECT_0, SPELL_AURA_MELEE_SLOW, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK);
} }
}; };
@@ -1562,62 +1542,6 @@ public:
} }
}; };
class spell_hodir_toasty_fire : public SpellScriptLoader
{
public:
spell_hodir_toasty_fire() : SpellScriptLoader("spell_hodir_toasty_fire") { }
class spell_hodir_toasty_fire_AuraScript : public AuraScript
{
PrepareAuraScript(spell_hodir_toasty_fire_AuraScript);
void HandleAfterEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Unit* target = GetTarget())
if (target->GetTypeId() == TYPEID_PLAYER)
target->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2, SPELL_MAGE_TOASTY_FIRE_AURA, 0, GetCaster());
}
void Register() override
{
AfterEffectApply += AuraEffectApplyFn(spell_hodir_toasty_fire_AuraScript::HandleAfterEffectApply, EFFECT_0, SPELL_AURA_MOD_STAT, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_hodir_toasty_fire_AuraScript();
}
};
class spell_hodir_starlight : public SpellScriptLoader
{
public:
spell_hodir_starlight() : SpellScriptLoader("spell_hodir_starlight") { }
class spell_hodir_starlight_AuraScript : public AuraScript
{
PrepareAuraScript(spell_hodir_starlight_AuraScript);
void HandleAfterEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Unit* target = GetTarget())
if (target->GetTypeId() == TYPEID_PLAYER)
target->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2, SPELL_DRUID_STARLIGHT_AREA_AURA, 0, GetCaster());
}
void Register() override
{
AfterEffectApply += AuraEffectApplyFn(spell_hodir_starlight_AuraScript::HandleAfterEffectApply, EFFECT_0, SPELL_AURA_MELEE_SLOW, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_hodir_starlight_AuraScript();
}
};
void AddSC_boss_hodir() void AddSC_boss_hodir()
{ {
new boss_hodir(); new boss_hodir();
@@ -1630,13 +1554,15 @@ void AddSC_boss_hodir()
new npc_ulduar_hodir_shaman(); new npc_ulduar_hodir_shaman();
new npc_ulduar_hodir_mage(); new npc_ulduar_hodir_mage();
new spell_hodir_biting_cold_main_aura(); RegisterSpellScript(spell_hodir_shatter_chest);
new spell_hodir_biting_cold_player_aura(); RegisterSpellScript(spell_hodir_biting_cold_main_aura);
new spell_hodir_periodic_icicle(); RegisterSpellScript(spell_hodir_biting_cold_player_aura);
new spell_hodir_flash_freeze(); RegisterSpellScript(spell_hodir_periodic_icicle);
new spell_hodir_storm_power(); RegisterSpellAndAuraScriptPair(spell_hodir_flash_freeze, spell_hodir_flash_freeze_aura);
new spell_hodir_storm_cloud(); RegisterSpellScript(spell_hodir_storm_power_aura);
new spell_hodir_shatter_chest(); RegisterSpellScript(spell_hodir_storm_cloud_aura);
RegisterSpellScript(spell_hodir_toasty_fire_aura);
RegisterSpellScript(spell_hodir_starlight_aura);
new achievement_cheese_the_freeze(); new achievement_cheese_the_freeze();
new achievement_getting_cold_in_here(); new achievement_getting_cold_in_here();
@@ -1644,6 +1570,4 @@ void AddSC_boss_hodir()
new achievement_i_have_the_coolest_friends(); new achievement_i_have_the_coolest_friends();
new achievement_staying_buffed_all_winter_10(); new achievement_staying_buffed_all_winter_10();
new achievement_staying_buffed_all_winter_25(); new achievement_staying_buffed_all_winter_25();
new spell_hodir_toasty_fire();
new spell_hodir_starlight();
} }
@@ -882,7 +882,7 @@ class spell_xt002_tympanic_tantrum : public SpellScript
// 64234, 63024 - Gravity Bomb // 64234, 63024 - Gravity Bomb
enum GravityBomb enum GravityBomb
{ {
SPELL_GRAVTY_BOMB_10 = 63025 SPELL_GRAVITY_BOMB_TRIGGER_10 = 63025
}; };
class spell_xt002_gravity_bomb : public SpellScript class spell_xt002_gravity_bomb : public SpellScript
@@ -917,7 +917,7 @@ class spell_xt002_gravity_bomb_aura : public AuraScript
if (xt002->HasAura(aurEff->GetAmount())) // Heartbreak aura indicating hard mode if (xt002->HasAura(aurEff->GetAmount())) // Heartbreak aura indicating hard mode
if (Creature* creature = xt002->SummonCreature(NPC_VOID_ZONE, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 180000)) if (Creature* creature = xt002->SummonCreature(NPC_VOID_ZONE, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 180000))
{ {
int32 damage = GetSpellInfo()->Id == SPELL_GRAVTY_BOMB_10 ? 5000 : 7500; int32 damage = GetSpellInfo()->Id == SPELL_GRAVITY_BOMB_TRIGGER_10 ? 5000 : 7500;
creature->CastCustomSpell(creature, SPELL_VOID_ZONE_DAMAGE, &damage, 0, 0, true); creature->CastCustomSpell(creature, SPELL_VOID_ZONE_DAMAGE, &damage, 0, 0, true);
} }
} }