refactor(Scripts/Naxxramas): Spell Scripts use registry macros (#19034)

* ktz frost blast

* ktz detonate mana

* thaddius pos_neg_charge

* thaddius polarity shift

* sapph frost explosion

* grobbulus poison

* grobbulus mutating injection

* gothik shadow bolt volley

* gluth decimate

* horsemen mark

* add sql

* trigger ci

* Revert "trigger ci"

This reverts commit d8b18d5c5c37d12da1deab0be50941bfe96641a6.

* add validate horsemen mark

* add validate gluth decimate

* add validate gothik shadow mark

* add validate ktz frost blast

* add validate thaddius pos_neg_charge
This commit is contained in:
Jelle Meeus
2024-06-09 13:39:16 +02:00
committed by GitHub
parent d77b3ac110
commit 415f52d662
8 changed files with 241 additions and 321 deletions

View File

@@ -0,0 +1,4 @@
--
UPDATE `spell_script_names` SET `ScriptName`='spell_four_horsemen_mark_aura' WHERE `spell_id` IN (28832, 28833, 28834, 28835);
UPDATE `spell_script_names` SET `ScriptName`='spell_grobbulus_mutating_injection_aura' WHERE `spell_id`=28169;
UPDATE `spell_script_names` SET `ScriptName`='spell_kelthuzad_detonate_mana_aura' WHERE `spell_id`=27819;

View File

@@ -380,66 +380,60 @@ public:
}; };
}; };
class spell_four_horsemen_mark : public SpellScriptLoader class spell_four_horsemen_mark_aura : public AuraScript
{ {
public: PrepareAuraScript(spell_four_horsemen_mark_aura);
spell_four_horsemen_mark() : SpellScriptLoader("spell_four_horsemen_mark") { }
class spell_four_horsemen_mark_AuraScript : public AuraScript bool Validate(SpellInfo const* /*spellInfo*/) override
{ {
PrepareAuraScript(spell_four_horsemen_mark_AuraScript); return ValidateSpellInfo({ SPELL_MARK_DAMAGE });
}
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Unit* caster = GetCaster())
{ {
if (Unit* caster = GetCaster()) int32 damage;
switch (GetStackAmount())
{ {
int32 damage; case 1:
switch (GetStackAmount()) damage = 0;
{ break;
case 1: case 2:
damage = 0; damage = 500;
break; break;
case 2: case 3:
damage = 500; damage = 1500;
break; break;
case 3: case 4:
damage = 1500; damage = 4000;
break; break;
case 4: case 5:
damage = 4000; damage = 12500;
break; break;
case 5: case 6:
damage = 12500; damage = 20000;
break; break;
case 6: default:
damage = 20000; damage = 20000 + 1000 * (GetStackAmount() - 7);
break; break;
default: }
damage = 20000 + 1000 * (GetStackAmount() - 7); if (damage)
break; {
} caster->CastCustomSpell(SPELL_MARK_DAMAGE, SPELLVALUE_BASE_POINT0, damage, GetTarget());
if (damage)
{
caster->CastCustomSpell(SPELL_MARK_DAMAGE, SPELLVALUE_BASE_POINT0, damage, GetTarget());
}
} }
} }
}
void Register() override void Register() override
{
AfterEffectApply += AuraEffectApplyFn(spell_four_horsemen_mark_AuraScript::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
}
};
AuraScript* GetAuraScript() const override
{ {
return new spell_four_horsemen_mark_AuraScript(); AfterEffectApply += AuraEffectApplyFn(spell_four_horsemen_mark_aura::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
} }
}; };
void AddSC_boss_four_horsemen() void AddSC_boss_four_horsemen()
{ {
new boss_four_horsemen(); new boss_four_horsemen();
new spell_four_horsemen_mark(); RegisterSpellScript(spell_four_horsemen_mark_aura);
} }

View File

@@ -29,6 +29,7 @@ enum Spells
SPELL_ENRAGE_25 = 54427, SPELL_ENRAGE_25 = 54427,
SPELL_DECIMATE_10 = 28374, SPELL_DECIMATE_10 = 28374,
SPELL_DECIMATE_25 = 54426, SPELL_DECIMATE_25 = 54426,
SPELL_DECIMATE_DAMAGE = 28375,
SPELL_BERSERK = 26662, SPELL_BERSERK = 26662,
SPELL_INFECTED_WOUND = 29306, SPELL_INFECTED_WOUND = 29306,
SPELL_CHOW_SEARCHER = 28404 SPELL_CHOW_SEARCHER = 28404
@@ -237,50 +238,44 @@ public:
}; };
}; };
class spell_gluth_decimate : public SpellScriptLoader class spell_gluth_decimate : public SpellScript
{ {
public: PrepareSpellScript(spell_gluth_decimate);
spell_gluth_decimate() : SpellScriptLoader("spell_gluth_decimate") { }
class spell_gluth_decimate_SpellScript : public SpellScript bool Validate(SpellInfo const* /*spellInfo*/) override
{ {
PrepareSpellScript(spell_gluth_decimate_SpellScript); return ValidateSpellInfo({ SPELL_DECIMATE_DAMAGE });
}
void HandleScriptEffect(SpellEffIndex /*effIndex*/) void HandleScriptEffect(SpellEffIndex /*effIndex*/)
{
if (Unit* unitTarget = GetHitUnit())
{ {
if (Unit* unitTarget = GetHitUnit()) int32 damage = int32(unitTarget->GetHealth()) - int32(unitTarget->CountPctFromMaxHealth(5));
if (damage <= 0)
return;
if (Creature* cTarget = unitTarget->ToCreature())
{ {
int32 damage = int32(unitTarget->GetHealth()) - int32(unitTarget->CountPctFromMaxHealth(5)); cTarget->SetWalk(true);
if (damage <= 0) cTarget->GetMotionMaster()->MoveFollow(GetCaster(), 0.0f, 0.0f, MOTION_SLOT_CONTROLLED);
return; cTarget->SetReactState(REACT_PASSIVE);
Unit::DealDamage(GetCaster(), cTarget, damage);
if (Creature* cTarget = unitTarget->ToCreature()) return;
{
cTarget->SetWalk(true);
cTarget->GetMotionMaster()->MoveFollow(GetCaster(), 0.0f, 0.0f, MOTION_SLOT_CONTROLLED);
cTarget->SetReactState(REACT_PASSIVE);
Unit::DealDamage(GetCaster(), cTarget, damage);
return;
}
GetCaster()->CastCustomSpell(28375, SPELLVALUE_BASE_POINT0, damage, unitTarget);
} }
GetCaster()->CastCustomSpell(SPELL_DECIMATE_DAMAGE, SPELLVALUE_BASE_POINT0, damage, unitTarget);
} }
}
void Register() override void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_gluth_decimate_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
{ {
return new spell_gluth_decimate_SpellScript(); OnEffectHitTarget += SpellEffectFn(spell_gluth_decimate::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
} }
}; };
void AddSC_boss_gluth() void AddSC_boss_gluth()
{ {
new boss_gluth(); new boss_gluth();
new spell_gluth_decimate(); RegisterSpellScript(spell_gluth_decimate);
} }

View File

@@ -688,29 +688,23 @@ public:
}; };
}; };
class spell_gothik_shadow_bolt_volley : public SpellScriptLoader class spell_gothik_shadow_bolt_volley : public SpellScript
{ {
public: PrepareSpellScript(spell_gothik_shadow_bolt_volley);
spell_gothik_shadow_bolt_volley() : SpellScriptLoader("spell_gothik_shadow_bolt_volley") { }
class spell_gothik_shadow_bolt_volley_SpellScript : public SpellScript bool Validate(SpellInfo const* /*spellInfo*/) override
{ {
PrepareSpellScript(spell_gothik_shadow_bolt_volley_SpellScript); return ValidateSpellInfo({ SPELL_SHADOW_MARK });
}
void FilterTargets(std::list<WorldObject*>& targets) void FilterTargets(std::list<WorldObject*>& targets)
{
targets.remove_if(Acore::UnitAuraCheck(false, SPELL_SHADOW_MARK));
}
void Register() override
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_gothik_shadow_bolt_volley_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
}
};
SpellScript* GetSpellScript() const override
{ {
return new spell_gothik_shadow_bolt_volley_SpellScript(); targets.remove_if(Acore::UnitAuraCheck(false, SPELL_SHADOW_MARK));
}
void Register() override
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_gothik_shadow_bolt_volley::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
} }
}; };
@@ -718,6 +712,6 @@ void AddSC_boss_gothik()
{ {
new boss_gothik(); new boss_gothik();
new npc_boss_gothik_minion(); new npc_boss_gothik_minion();
new spell_gothik_shadow_bolt_volley(); RegisterSpellScript(spell_gothik_shadow_bolt_volley);
} }

View File

@@ -240,91 +240,69 @@ public:
}; };
}; };
class spell_grobbulus_poison : public SpellScriptLoader class spell_grobbulus_poison : public SpellScript
{ {
public: PrepareSpellScript(spell_grobbulus_poison);
spell_grobbulus_poison() : SpellScriptLoader("spell_grobbulus_poison") { }
class spell_grobbulus_poison_SpellScript : public SpellScript void FilterTargets(std::list<WorldObject*>& targets)
{ {
PrepareSpellScript(spell_grobbulus_poison_SpellScript); std::list<WorldObject*> tmplist;
for (auto& target : targets)
void FilterTargets(std::list<WorldObject*>& targets)
{ {
std::list<WorldObject*> tmplist; if (GetCaster()->IsWithinDist3d(target, 0.0f))
for (auto& target : targets)
{ {
if (GetCaster()->IsWithinDist3d(target, 0.0f)) tmplist.push_back(target);
{
tmplist.push_back(target);
}
}
targets.clear();
for (auto& itr : tmplist)
{
targets.push_back(itr);
} }
} }
targets.clear();
void Register() override for (auto& itr : tmplist)
{ {
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_grobbulus_poison_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); targets.push_back(itr);
} }
}; }
SpellScript* GetSpellScript() const override void Register() override
{ {
return new spell_grobbulus_poison_SpellScript(); OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_grobbulus_poison::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
} }
}; };
class spell_grobbulus_mutating_injection : public SpellScriptLoader class spell_grobbulus_mutating_injection_aura : public AuraScript
{ {
public: PrepareAuraScript(spell_grobbulus_mutating_injection_aura);
spell_grobbulus_mutating_injection() : SpellScriptLoader("spell_grobbulus_mutating_injection") { }
class spell_grobbulus_mutating_injection_AuraScript : public AuraScript bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_MUTATING_EXPLOSION });
}
void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
switch (GetTargetApplication()->GetRemoveMode())
{ {
PrepareAuraScript(spell_grobbulus_mutating_injection_AuraScript); case AURA_REMOVE_BY_ENEMY_SPELL:
case AURA_REMOVE_BY_EXPIRE:
bool Validate(SpellInfo const* /*spellInfo*/) override if (auto caster = GetCaster())
{
return ValidateSpellInfo({ SPELL_MUTATING_EXPLOSION });
}
void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
switch (GetTargetApplication()->GetRemoveMode())
{ {
case AURA_REMOVE_BY_ENEMY_SPELL: caster->CastSpell(GetTarget(), SPELL_MUTATING_EXPLOSION, true);
case AURA_REMOVE_BY_EXPIRE:
if (auto caster = GetCaster())
{
caster->CastSpell(GetTarget(), SPELL_MUTATING_EXPLOSION, true);
}
break;
default:
return;
} }
} break;
default:
void Register() override return;
{
AfterEffectRemove += AuraEffectRemoveFn(spell_grobbulus_mutating_injection_AuraScript::HandleRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_grobbulus_mutating_injection_AuraScript();
} }
}
void Register() override
{
AfterEffectRemove += AuraEffectRemoveFn(spell_grobbulus_mutating_injection_aura::HandleRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
}; };
void AddSC_boss_grobbulus() void AddSC_boss_grobbulus()
{ {
new boss_grobbulus(); new boss_grobbulus();
new boss_grobbulus_poison_cloud(); new boss_grobbulus_poison_cloud();
new spell_grobbulus_mutating_injection(); RegisterSpellScript(spell_grobbulus_mutating_injection_aura);
new spell_grobbulus_poison(); RegisterSpellScript(spell_grobbulus_poison);
} }

View File

@@ -665,82 +665,65 @@ public:
}; };
}; };
class spell_kelthuzad_frost_blast : public SpellScriptLoader class spell_kelthuzad_frost_blast : public SpellScript
{ {
public: PrepareSpellScript(spell_kelthuzad_frost_blast);
spell_kelthuzad_frost_blast() : SpellScriptLoader("spell_kelthuzad_frost_blast") { }
class spell_kelthuzad_frost_blast_SpellScript : public SpellScript bool Validate(SpellInfo const* /*spell*/) override
{ {
PrepareSpellScript(spell_kelthuzad_frost_blast_SpellScript); return ValidateSpellInfo({ SPELL_FROST_BLAST });
}
void FilterTargets(std::list<WorldObject*>& targets) void FilterTargets(std::list<WorldObject*>& targets)
{
Unit* caster = GetCaster();
if (!caster || !caster->ToCreature())
return;
std::list<WorldObject*> tmplist;
for (auto& target : targets)
{ {
Unit* caster = GetCaster(); if (!target->ToUnit()->HasAura(SPELL_FROST_BLAST))
if (!caster || !caster->ToCreature())
return;
std::list<WorldObject*> tmplist;
for (auto& target : targets)
{ {
if (!target->ToUnit()->HasAura(SPELL_FROST_BLAST)) tmplist.push_back(target);
{
tmplist.push_back(target);
}
}
targets.clear();
for (auto& itr : tmplist)
{
targets.push_back(itr);
} }
} }
targets.clear();
void Register() override for (auto& itr : tmplist)
{ {
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_kelthuzad_frost_blast_SpellScript::FilterTargets, EFFECT_ALL, TARGET_UNIT_DEST_AREA_ENEMY); targets.push_back(itr);
} }
}; }
SpellScript* GetSpellScript() const override void Register() override
{ {
return new spell_kelthuzad_frost_blast_SpellScript(); OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_kelthuzad_frost_blast::FilterTargets, EFFECT_ALL, TARGET_UNIT_DEST_AREA_ENEMY);
} }
}; };
class spell_kelthuzad_detonate_mana : public SpellScriptLoader class spell_kelthuzad_detonate_mana_aura : public AuraScript
{ {
public: PrepareAuraScript(spell_kelthuzad_detonate_mana_aura);
spell_kelthuzad_detonate_mana() : SpellScriptLoader("spell_kelthuzad_detonate_mana") { }
class spell_kelthuzad_detonate_mana_AuraScript : public AuraScript bool Validate(SpellInfo const* /*spell*/) override
{ {
PrepareAuraScript(spell_kelthuzad_detonate_mana_AuraScript); return ValidateSpellInfo({ SPELL_MANA_DETONATION_DAMAGE });
}
bool Validate(SpellInfo const* /*spell*/) override void HandleScript(AuraEffect const* aurEff)
{
return ValidateSpellInfo({ SPELL_MANA_DETONATION_DAMAGE });
}
void HandleScript(AuraEffect const* aurEff)
{
PreventDefaultAction();
Unit* target = GetTarget();
if (auto mana = int32(target->GetMaxPower(POWER_MANA) / 10))
{
mana = target->ModifyPower(POWER_MANA, -mana);
target->CastCustomSpell(SPELL_MANA_DETONATION_DAMAGE, SPELLVALUE_BASE_POINT0, -mana * 10, target, true, nullptr, aurEff);
}
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_kelthuzad_detonate_mana_AuraScript::HandleScript, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
}
};
AuraScript* GetAuraScript() const override
{ {
return new spell_kelthuzad_detonate_mana_AuraScript(); PreventDefaultAction();
Unit* target = GetTarget();
if (auto mana = int32(target->GetMaxPower(POWER_MANA) / 10))
{
mana = target->ModifyPower(POWER_MANA, -mana);
target->CastCustomSpell(SPELL_MANA_DETONATION_DAMAGE, SPELLVALUE_BASE_POINT0, -mana * 10, target, true, nullptr, aurEff);
}
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_kelthuzad_detonate_mana_aura::HandleScript, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
} }
}; };
@@ -748,7 +731,7 @@ void AddSC_boss_kelthuzad()
{ {
new boss_kelthuzad(); new boss_kelthuzad();
new boss_kelthuzad_minion(); new boss_kelthuzad_minion();
new spell_kelthuzad_frost_blast(); RegisterSpellScript(spell_kelthuzad_frost_blast);
new spell_kelthuzad_detonate_mana(); RegisterSpellScript(spell_kelthuzad_detonate_mana_aura);
} }

View File

@@ -417,51 +417,40 @@ public:
}; };
}; };
class spell_sapphiron_frost_explosion : public SpellScriptLoader class spell_sapphiron_frost_explosion : public SpellScript
{ {
public: PrepareSpellScript(spell_sapphiron_frost_explosion);
spell_sapphiron_frost_explosion() : SpellScriptLoader("spell_sapphiron_frost_explosion") { }
class spell_sapphiron_frost_explosion_SpellScript : public SpellScript void FilterTargets(std::list<WorldObject*>& targets)
{ {
PrepareSpellScript(spell_sapphiron_frost_explosion_SpellScript); Unit* caster = GetCaster();
if (!caster || !caster->ToCreature())
return;
void FilterTargets(std::list<WorldObject*>& targets) std::list<WorldObject*> tmplist;
for (auto& target : targets)
{ {
Unit* caster = GetCaster(); if (CAST_AI(boss_sapphiron::boss_sapphironAI, caster->ToCreature()->AI())->IsValidExplosionTarget(target))
if (!caster || !caster->ToCreature())
return;
std::list<WorldObject*> tmplist;
for (auto& target : targets)
{ {
if (CAST_AI(boss_sapphiron::boss_sapphironAI, caster->ToCreature()->AI())->IsValidExplosionTarget(target)) tmplist.push_back(target);
{
tmplist.push_back(target);
}
}
targets.clear();
for (auto& itr : tmplist)
{
targets.push_back(itr);
} }
} }
targets.clear();
void Register() override for (auto& itr : tmplist)
{ {
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sapphiron_frost_explosion_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); targets.push_back(itr);
} }
}; }
SpellScript* GetSpellScript() const override void Register() override
{ {
return new spell_sapphiron_frost_explosion_SpellScript(); OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sapphiron_frost_explosion::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY);
} }
}; };
void AddSC_boss_sapphiron() void AddSC_boss_sapphiron()
{ {
new boss_sapphiron(); new boss_sapphiron();
new spell_sapphiron_frost_explosion(); RegisterSpellScript(spell_sapphiron_frost_explosion);
} }

View File

@@ -606,121 +606,104 @@ public:
}; };
}; };
class spell_thaddius_pos_neg_charge : public SpellScriptLoader class spell_thaddius_pos_neg_charge : public SpellScript
{ {
public: PrepareSpellScript(spell_thaddius_pos_neg_charge);
spell_thaddius_pos_neg_charge() : SpellScriptLoader("spell_thaddius_pos_neg_charge") { }
class spell_thaddius_pos_neg_charge_SpellScript : public SpellScript bool Validate(SpellInfo const* /*spellInfo*/) override
{ {
PrepareSpellScript(spell_thaddius_pos_neg_charge_SpellScript); return ValidateSpellInfo({ SPELL_POSITIVE_CHARGE, SPELL_POSITIVE_CHARGE_STACK });
}
void HandleTargets(std::list<WorldObject*>& targets) void HandleTargets(std::list<WorldObject*>& targets)
{
uint8 count = 0;
for (auto& ihit : targets)
{ {
uint8 count = 0; if (ihit->GetGUID() != GetCaster()->GetGUID())
for (auto& ihit : targets)
{ {
if (ihit->GetGUID() != GetCaster()->GetGUID()) if (Player* target = ihit->ToPlayer())
{ {
if (Player* target = ihit->ToPlayer()) if (target->HasAura(GetTriggeringSpell()->Id))
{ {
if (target->HasAura(GetTriggeringSpell()->Id)) ++count;
{
++count;
}
} }
} }
} }
if (count)
{
uint32 spellId = GetSpellInfo()->Id == SPELL_POSITIVE_CHARGE ? SPELL_POSITIVE_CHARGE_STACK : SPELL_NEGATIVE_CHARGE_STACK;
GetCaster()->SetAuraStack(spellId, GetCaster(), count);
}
} }
void HandleDamage(SpellEffIndex /*effIndex*/) if (count)
{ {
if (!GetTriggeringSpell()) uint32 spellId = GetSpellInfo()->Id == SPELL_POSITIVE_CHARGE ? SPELL_POSITIVE_CHARGE_STACK : SPELL_NEGATIVE_CHARGE_STACK;
return; GetCaster()->SetAuraStack(spellId, GetCaster(), count);
Unit* target = GetHitUnit();
if (!target)
return;
if (target->HasAura(GetTriggeringSpell()->Id) || target->GetTypeId() != TYPEID_PLAYER)
{
SetHitDamage(0);
}
else if (target->GetInstanceScript())
{
target->GetInstanceScript()->SetData(DATA_CHARGES_CROSSED, 0);
}
} }
}
void Register() override void HandleDamage(SpellEffIndex /*effIndex*/)
{
OnEffectHitTarget += SpellEffectFn(spell_thaddius_pos_neg_charge_SpellScript::HandleDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_thaddius_pos_neg_charge_SpellScript::HandleTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY);
}
};
SpellScript* GetSpellScript() const override
{ {
return new spell_thaddius_pos_neg_charge_SpellScript(); if (!GetTriggeringSpell())
return;
Unit* target = GetHitUnit();
if (!target)
return;
if (target->HasAura(GetTriggeringSpell()->Id) || target->GetTypeId() != TYPEID_PLAYER)
{
SetHitDamage(0);
}
else if (target->GetInstanceScript())
{
target->GetInstanceScript()->SetData(DATA_CHARGES_CROSSED, 0);
}
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_thaddius_pos_neg_charge::HandleDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_thaddius_pos_neg_charge::HandleTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY);
} }
}; };
class spell_thaddius_polarity_shift : public SpellScriptLoader class spell_thaddius_polarity_shift : public SpellScript
{ {
public: PrepareSpellScript(spell_thaddius_polarity_shift);
spell_thaddius_polarity_shift() : SpellScriptLoader("spell_thaddius_polarity_shift") { }
class spell_thaddius_polarity_shift_SpellScript : public SpellScript bool Validate(SpellInfo const* /*spell*/) override
{ {
PrepareSpellScript(spell_thaddius_polarity_shift_SpellScript); return ValidateSpellInfo({ SPELL_POSITIVE_POLARITY, SPELL_NEGATIVE_POLARITY });
}
bool Validate(SpellInfo const* /*spell*/) override void HandleDummy(SpellEffIndex /* effIndex */)
{
Unit* caster = GetCaster();
if (Unit* target = GetHitUnit())
{ {
return ValidateSpellInfo({ SPELL_POSITIVE_POLARITY, SPELL_NEGATIVE_POLARITY }); target->RemoveAurasDueToSpell(SPELL_POSITIVE_CHARGE_STACK);
target->RemoveAurasDueToSpell(SPELL_NEGATIVE_CHARGE_STACK);
target->CastSpell(target, roll_chance_i(50) ? SPELL_POSITIVE_POLARITY : SPELL_NEGATIVE_POLARITY, true, nullptr, nullptr, caster->GetGUID());
} }
}
void HandleDummy(SpellEffIndex /* effIndex */) void HandleAfterCast()
{
if (GetCaster())
{ {
Unit* caster = GetCaster(); if (Creature* caster = GetCaster()->ToCreature())
if (Unit* target = GetHitUnit())
{ {
target->RemoveAurasDueToSpell(SPELL_POSITIVE_CHARGE_STACK); if (caster->GetEntry() == NPC_THADDIUS)
target->RemoveAurasDueToSpell(SPELL_NEGATIVE_CHARGE_STACK);
target->CastSpell(target, roll_chance_i(50) ? SPELL_POSITIVE_POLARITY : SPELL_NEGATIVE_POLARITY, true, nullptr, nullptr, caster->GetGUID());
}
}
void HandleAfterCast()
{
if (GetCaster())
{
if (Creature* caster = GetCaster()->ToCreature())
{ {
if (caster->GetEntry() == NPC_THADDIUS) caster->AI()->Talk(SAY_ELECT);
{ caster->AI()->Talk(EMOTE_POLARITY_SHIFTED);
caster->AI()->Talk(SAY_ELECT);
caster->AI()->Talk(EMOTE_POLARITY_SHIFTED);
}
} }
} }
} }
}
void Register() override void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_thaddius_polarity_shift_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
AfterCast += SpellCastFn(spell_thaddius_polarity_shift_SpellScript::HandleAfterCast);
}
};
SpellScript* GetSpellScript() const override
{ {
return new spell_thaddius_polarity_shift_SpellScript(); OnEffectHitTarget += SpellEffectFn(spell_thaddius_polarity_shift::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
AfterCast += SpellCastFn(spell_thaddius_polarity_shift::HandleAfterCast);
} }
}; };
@@ -771,7 +754,7 @@ void AddSC_boss_thaddius()
new boss_thaddius(); new boss_thaddius();
new boss_thaddius_summon(); new boss_thaddius_summon();
new npc_tesla(); new npc_tesla();
new spell_thaddius_pos_neg_charge(); RegisterSpellScript(spell_thaddius_pos_neg_charge);
new spell_thaddius_polarity_shift(); RegisterSpellScript(spell_thaddius_polarity_shift);
new at_thaddius_entrance(); new at_thaddius_entrance();
} }