fix(Scripts/Mechanar): Fix Polarity shift mechanic (#16601)

This commit is contained in:
Angelo Venturini
2023-06-24 15:47:37 -03:00
committed by GitHub
parent ff27c3d166
commit facbebdf8d
2 changed files with 37 additions and 4 deletions

View File

@@ -144,17 +144,21 @@ class spell_capacitus_polarity_charge : public SpellScript
void HandleTargets(std::list<WorldObject*>& targetList)
{
uint8 count = 0;
for (std::list<WorldObject*>::iterator ihit = targetList.begin(); ihit != targetList.end(); ++ihit)
if ((*ihit)->GetGUID() != GetCaster()->GetGUID())
if (Player* target = (*ihit)->ToPlayer())
for (auto& ihit : targetList)
if (ihit->GetGUID() != GetCaster()->GetGUID())
if (Player* target = ihit->ToPlayer())
if (target->HasAura(GetTriggeringSpell()->Id))
++count;
uint32 spellId = GetSpellInfo()->Id == SPELL_POSITIVE_CHARGE ? SPELL_POSITIVE_CHARGE_STACK : SPELL_NEGATIVE_CHARGE_STACK;
if (count)
{
uint32 spellId = GetSpellInfo()->Id == SPELL_POSITIVE_CHARGE ? SPELL_POSITIVE_CHARGE_STACK : SPELL_NEGATIVE_CHARGE_STACK;
GetCaster()->SetAuraStack(spellId, GetCaster(), count);
}
else
{
GetCaster()->RemoveAurasDueToSpell(spellId);
}
}
void HandleDamage(SpellEffIndex /*effIndex*/)
@@ -174,6 +178,29 @@ class spell_capacitus_polarity_charge : public SpellScript
}
};
class spell_capacitus_polarity_charge_aura : public AuraScript
{
PrepareAuraScript(spell_capacitus_polarity_charge_aura);
void HandleAfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE)
{
Unit* target = GetTarget();
if (!target)
return;
target->RemoveAurasDueToSpell(SPELL_POSITIVE_CHARGE_STACK);
target->RemoveAurasDueToSpell(SPELL_NEGATIVE_CHARGE_STACK);
}
}
void Register() override
{
AfterEffectRemove += AuraEffectRemoveFn(spell_capacitus_polarity_charge_aura::HandleAfterRemove, EFFECT_1, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
}
};
class spell_capacitus_polarity_shift : public SpellScript
{
PrepareSpellScript(spell_capacitus_polarity_shift);
@@ -194,5 +221,6 @@ void AddSC_boss_mechano_lord_capacitus()
{
RegisterMechanarCreatureAI(boss_mechano_lord_capacitus);
RegisterSpellScript(spell_capacitus_polarity_charge);
RegisterSpellScript(spell_capacitus_polarity_charge_aura);
RegisterSpellScript(spell_capacitus_polarity_shift);
}