From f8c35bc06797dcdeaae8b8561521fe0a58c908dc Mon Sep 17 00:00:00 2001 From: Jelle Meeus Date: Sat, 8 Jun 2024 17:47:49 +0200 Subject: [PATCH] thaddius pos_neg_charge --- .../Northrend/Naxxramas/boss_thaddius.cpp | 83 ++++++++----------- 1 file changed, 36 insertions(+), 47 deletions(-) diff --git a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp index b2bf2a7273..5b40c5ba47 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp @@ -606,68 +606,57 @@ public: }; }; -class spell_thaddius_pos_neg_charge : public SpellScriptLoader +class spell_thaddius_pos_neg_charge : public SpellScript { -public: - spell_thaddius_pos_neg_charge() : SpellScriptLoader("spell_thaddius_pos_neg_charge") { } + PrepareSpellScript(spell_thaddius_pos_neg_charge); - class spell_thaddius_pos_neg_charge_SpellScript : public SpellScript + void HandleTargets(std::list& targets) { - PrepareSpellScript(spell_thaddius_pos_neg_charge_SpellScript); - - void HandleTargets(std::list& targets) + uint8 count = 0; + for (auto& ihit : targets) { - uint8 count = 0; - for (auto& ihit : targets) + if (ihit->GetGUID() != GetCaster()->GetGUID()) { - 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()) - 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); - } + uint32 spellId = GetSpellInfo()->Id == SPELL_POSITIVE_CHARGE ? SPELL_POSITIVE_CHARGE_STACK : SPELL_NEGATIVE_CHARGE_STACK; + GetCaster()->SetAuraStack(spellId, GetCaster(), count); } + } - void Register() override - { - 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 + void HandleDamage(SpellEffIndex /*effIndex*/) { - 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); } }; @@ -771,7 +760,7 @@ void AddSC_boss_thaddius() new boss_thaddius(); new boss_thaddius_summon(); new npc_tesla(); - new spell_thaddius_pos_neg_charge(); + RegisterSpellScript(spell_thaddius_pos_neg_charge); new spell_thaddius_polarity_shift(); new at_thaddius_entrance(); }