diff --git a/data/sql/updates/pending_db_world/rev_1687394707485668400.sql b/data/sql/updates/pending_db_world/rev_1687394707485668400.sql new file mode 100644 index 000000000..7624eea5a --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1687394707485668400.sql @@ -0,0 +1,5 @@ +-- +DELETE FROM `spell_script_names` WHERE `ScriptName` = 'spell_capacitus_polarity_charge_aura'; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(39088, 'spell_capacitus_polarity_charge_aura'), +(39091, 'spell_capacitus_polarity_charge_aura'); diff --git a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp index 5638bcbb3..79568a64b 100644 --- a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp +++ b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp @@ -144,17 +144,21 @@ class spell_capacitus_polarity_charge : public SpellScript void HandleTargets(std::list& targetList) { uint8 count = 0; - for (std::list::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); }