thaddius pos_neg_charge

This commit is contained in:
Jelle Meeus
2024-06-08 17:47:49 +02:00
parent c8812c94d6
commit f8c35bc067

View File

@@ -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<WorldObject*>& targets)
{
PrepareSpellScript(spell_thaddius_pos_neg_charge_SpellScript);
void HandleTargets(std::list<WorldObject*>& 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();
}