Skip to content

Commit

Permalink
refactor(Scripts/Outland): spell scripts use registry macros (#19132)
Browse files Browse the repository at this point in the history
* zone_terokkar_forest pair:spell_q10930_big_bone_worm

* zone_terokkar_forest spell:spell_q10036_torgos

* zone_terokkar_forest spell:spell_q10923_evil_draws_near_summon

* zone_terokkar_forest aura:spell_q10923_evil_draws_near_periodic_aura

* zone_terokkar_forest spell:spell_q10923_evil_draws_near_visual

* zone_terokkar_forest spell:spell_q10898_skywing

* zone_hellfire_peninsula spell:spell_q10935_the_exorcism_of_colonel_jules

* boss_doomlord_kazzak aura:spell_mark_of_kazzak_aura

* zone_blades_edge_mountains aura:spell_npc22275_crystal_prison_aura

* zone_blades_edge_mountains spell:spell_oscillating_field

* zone_shadowmoon_valley spell:spell_q10612_10613_the_fel_and_the_furious

* zone_shadowmoon_valley aura:spell_q10563_q10596_to_legion_hold_aura

* fixup! zone_hellfire_peninsula spell:spell_q10935_the_exorcism_of_colonel_jules

fixup! zone_hellfire_peninsula spell:spell_q10935_the_exorcism_of_colonel_jules

* fixup! zone_blades_edge_mountains aura:spell_npc22275_crystal_prison_aura

* fixup! zone_shadowmoon_valley spell:spell_q10612_10613_the_fel_and_the_furious

* fixup! zone_blades_edge_mountains spell:spell_oscillating_field

* zone_terokkar_forest pair:spell_q10929_fumping
  • Loading branch information
sogladev authored Jun 25, 2024
1 parent 24c8f3c commit 7a77a3e
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 335 deletions.
5 changes: 5 additions & 0 deletions data/sql/updates/pending_db_world/rev_1719134265835105342.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--
UPDATE `spell_script_names` SET `ScriptName`='spell_q10923_evil_draws_near_periodic_aura' WHERE `spell_id`=39259;
UPDATE `spell_script_names` SET `ScriptName`='spell_mark_of_kazzak_aura' WHERE `spell_id`=32960;
UPDATE `spell_script_names` SET `ScriptName`='spell_npc22275_crystal_prison_aura' WHERE `spell_id`=40846;
UPDATE `spell_script_names` SET `ScriptName`='spell_q10563_q10596_to_legion_hold_aura' WHERE `spell_id`=37097;
53 changes: 21 additions & 32 deletions src/server/scripts/Outland/boss_doomlord_kazzak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,54 +150,43 @@ class boss_doomlord_kazzak : public CreatureScript
}
};

class spell_mark_of_kazzak : public SpellScriptLoader
class spell_mark_of_kazzak_aura : public AuraScript
{
public:
spell_mark_of_kazzak() : SpellScriptLoader("spell_mark_of_kazzak") { }
PrepareAuraScript(spell_mark_of_kazzak_aura);

class spell_mark_of_kazzak_AuraScript : public AuraScript
bool Validate(SpellInfo const* /*spell*/) override
{
PrepareAuraScript(spell_mark_of_kazzak_AuraScript);

bool Validate(SpellInfo const* /*spell*/) override
{
return ValidateSpellInfo({ SPELL_MARK_OF_KAZZAK_DAMAGE });
}

void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* owner = GetUnitOwner())
{
amount = CalculatePct(owner->GetPower(POWER_MANA), 5);
}
}
return ValidateSpellInfo({ SPELL_MARK_OF_KAZZAK_DAMAGE });
}

void OnPeriodic(AuraEffect const* aurEff)
void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* owner = GetUnitOwner())
{
Unit* target = GetTarget();
if (target->GetPower(POWER_MANA) == 0)
{
target->CastSpell(target, SPELL_MARK_OF_KAZZAK_DAMAGE, true, nullptr, aurEff);
SetDuration(0); // Remove aura
}
amount = CalculatePct(owner->GetPower(POWER_MANA), 5);
}
}

void Register() override
void OnPeriodic(AuraEffect const* aurEff)
{
Unit* target = GetTarget();
if (target->GetPower(POWER_MANA) == 0)
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_mark_of_kazzak_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_PERIODIC_MANA_LEECH);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_mark_of_kazzak_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_MANA_LEECH);
target->CastSpell(target, SPELL_MARK_OF_KAZZAK_DAMAGE, true, nullptr, aurEff);
SetDuration(0); // Remove aura
}
};
}

AuraScript* GetAuraScript() const override
void Register() override
{
return new spell_mark_of_kazzak_AuraScript();
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_mark_of_kazzak_aura::CalculateAmount, EFFECT_0, SPELL_AURA_PERIODIC_MANA_LEECH);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_mark_of_kazzak_aura::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_MANA_LEECH);
}
};

void AddSC_boss_doomlordkazzak()
{
new boss_doomlord_kazzak();
new spell_mark_of_kazzak();
RegisterSpellScript(spell_mark_of_kazzak_aura);
}

73 changes: 33 additions & 40 deletions src/server/scripts/Outland/zone_blades_edge_mountains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,31 +223,30 @@ class npc_deaths_fel_cannon : public CreatureScript
}
};

class spell_npc22275_crystal_prison : public SpellScriptLoader
enum CrystalPrison
{
public:
spell_npc22275_crystal_prison() : SpellScriptLoader("spell_npc22275_crystal_prison") { }
SPELL_CRYSTAL_SHATTER = 40898
};

class spell_npc22275_crystal_prison_AuraScript : public AuraScript
{
PrepareAuraScript(spell_npc22275_crystal_prison_AuraScript);
class spell_npc22275_crystal_prison_aura : public AuraScript
{
PrepareAuraScript(spell_npc22275_crystal_prison_aura);

void OnPeriodic(AuraEffect const* /*aurEff*/)
{
PreventDefaultAction();
SetDuration(0);
GetTarget()->CastSpell(GetTarget(), 40898, true);
}
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_CRYSTAL_SHATTER });
}

void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_npc22275_crystal_prison_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
}
};
void OnPeriodic(AuraEffect const* /*aurEff*/)
{
PreventDefaultAction();
SetDuration(0);
GetTarget()->CastSpell(GetTarget(), SPELL_CRYSTAL_SHATTER, true);
}

AuraScript* GetAuraScript() const override
void Register() override
{
return new spell_npc22275_crystal_prison_AuraScript();
OnEffectPeriodic += AuraEffectPeriodicFn(spell_npc22275_crystal_prison_aura::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
}
};

Expand Down Expand Up @@ -1139,31 +1138,25 @@ class npc_oscillating_frequency_scanner_master_bunny : public CreatureScript
}
};

class spell_oscillating_field : public SpellScriptLoader
class spell_oscillating_field : public SpellScript
{
public:
spell_oscillating_field() : SpellScriptLoader("spell_oscillating_field") { }
PrepareSpellScript(spell_oscillating_field);

class spell_oscillating_field_SpellScript : public SpellScript
bool Validate(SpellInfo const* /*spellInfo*/) override
{
PrepareSpellScript(spell_oscillating_field_SpellScript);

void HandleEffect(SpellEffIndex /*effIndex*/)
{
if (Player* player = GetHitPlayer())
if (player->GetAuraCount(SPELL_OSCILLATION_FIELD) == 5 && player->GetQuestStatus(QUEST_GAUGING_THE_RESONANT_FREQUENCY) == QUEST_STATUS_INCOMPLETE)
player->CompleteQuest(QUEST_GAUGING_THE_RESONANT_FREQUENCY);
}
return ValidateSpellInfo({ SPELL_OSCILLATION_FIELD });
}

void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_oscillating_field_SpellScript::HandleEffect, EFFECT_0, SPELL_EFFECT_APPLY_AURA);
}
};
void HandleEffect(SpellEffIndex /*effIndex*/)
{
if (Player* player = GetHitPlayer())
if (player->GetAuraCount(SPELL_OSCILLATION_FIELD) == 5 && player->GetQuestStatus(QUEST_GAUGING_THE_RESONANT_FREQUENCY) == QUEST_STATUS_INCOMPLETE)
player->CompleteQuest(QUEST_GAUGING_THE_RESONANT_FREQUENCY);
}

SpellScript* GetSpellScript() const override
void Register() override
{
return new spell_oscillating_field_SpellScript();
OnEffectHitTarget += SpellEffectFn(spell_oscillating_field::HandleEffect, EFFECT_0, SPELL_EFFECT_APPLY_AURA);
}
};

Expand All @@ -1172,13 +1165,13 @@ void AddSC_blades_edge_mountains()
// Ours
new npc_deaths_door_fell_cannon_target_bunny();
new npc_deaths_fel_cannon();
new spell_npc22275_crystal_prison();
RegisterSpellScript(spell_npc22275_crystal_prison_aura);
// Theirs
new npc_nether_drake();
new npc_daranelle();
new npc_simon_bunny();
new go_simon_cluster();
new go_apexis_relic();
new npc_oscillating_frequency_scanner_master_bunny();
new spell_oscillating_field();
RegisterSpellScript(spell_oscillating_field);
}
52 changes: 25 additions & 27 deletions src/server/scripts/Outland/zone_hellfire_peninsula.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,37 @@
#include "SpellScript.h"
#include "SpellScriptLoader.h"

// Ours
enum q10935Exorcism
{
SPELL_HOLY_FIRE = 39323,
SPELL_HEAL_BARADA = 39322
};

class spell_q10935_the_exorcism_of_colonel_jules : public SpellScriptLoader
class spell_q10935_the_exorcism_of_colonel_jules : public SpellScript
{
public:
spell_q10935_the_exorcism_of_colonel_jules() : SpellScriptLoader("spell_q10935_the_exorcism_of_colonel_jules") { }
PrepareSpellScript(spell_q10935_the_exorcism_of_colonel_jules);

class spell_q10935_the_exorcism_of_colonel_jules_SpellScript : public SpellScript
bool Validate(SpellInfo const* /*spellInfo*/) override
{
PrepareSpellScript(spell_q10935_the_exorcism_of_colonel_jules_SpellScript);

void HandleDummy(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
Creature* target = GetHitCreature();
if (!target)
return;

if (GetCaster()->IsHostileTo(target))
GetCaster()->CastSpell(target, 39323 /*SPELL_HOLY_FIRE*/, true);
else
GetCaster()->CastSpell(target, 39322 /*SPELL_HEAL_BARADA*/, true);
}
return ValidateSpellInfo({ SPELL_HOLY_FIRE, SPELL_HEAL_BARADA });
}

void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_q10935_the_exorcism_of_colonel_jules_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
void HandleDummy(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
Creature* target = GetHitCreature();
if (!target)
return;

if (GetCaster()->IsHostileTo(target))
GetCaster()->CastSpell(target, SPELL_HOLY_FIRE, true);
else
GetCaster()->CastSpell(target, SPELL_HEAL_BARADA, true);
}

SpellScript* GetSpellScript() const override
void Register() override
{
return new spell_q10935_the_exorcism_of_colonel_jules_SpellScript();
OnEffectHitTarget += SpellEffectFn(spell_q10935_the_exorcism_of_colonel_jules::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};

Expand Down Expand Up @@ -607,7 +605,7 @@ class go_beacon : public GameObjectScript
void AddSC_hellfire_peninsula()
{
// Ours
new spell_q10935_the_exorcism_of_colonel_jules();
RegisterSpellScript(spell_q10935_the_exorcism_of_colonel_jules);

// Theirs
new npc_aeranas();
Expand Down
Loading

0 comments on commit 7a77a3e

Please sign in to comment.