diff options
author | Shauren <shauren.trinity@gmail.com> | 2022-03-11 15:37:13 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-03-11 15:37:13 +0100 |
commit | 8a1e635e6a4a3497b029da88488687e811894b83 (patch) | |
tree | 9defd19bcaf43ce8bddea75b34b0897017ef704d /src | |
parent | 54974d3113e694f6ccd1299d23ff1a36006f83df (diff) |
Scripts/Spells: Update warlock scripts to new register model
Diffstat (limited to 'src')
-rw-r--r-- | src/server/scripts/Spells/spell_warlock.cpp | 1160 |
1 files changed, 465 insertions, 695 deletions
diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp index 085b1d81575..b5ab487628a 100644 --- a/src/server/scripts/Spells/spell_warlock.cpp +++ b/src/server/scripts/Spells/spell_warlock.cpp @@ -72,42 +72,31 @@ enum MiscSpells }; // 710 - Banish -class spell_warl_banish : public SpellScriptLoader +class spell_warl_banish : public SpellScript { - public: - spell_warl_banish() : SpellScriptLoader("spell_warl_banish") { } + PrepareSpellScript(spell_warl_banish); - class spell_warl_banish_SpellScript : public SpellScript - { - PrepareSpellScript(spell_warl_banish_SpellScript); - - public: - spell_warl_banish_SpellScript() {} - - private: - void HandleBanish(SpellMissInfo missInfo) - { - if (missInfo != SPELL_MISS_IMMUNE) - return; - - if (Unit* target = GetHitUnit()) - { - // Casting Banish on a banished target will remove applied aura - if (Aura * banishAura = target->GetAura(GetSpellInfo()->Id, GetCaster()->GetGUID())) - banishAura->Remove(); - } - } +public: + spell_warl_banish() {} - void Register() override - { - BeforeHit += BeforeSpellHitFn(spell_warl_banish_SpellScript::HandleBanish); - } - }; +private: + void HandleBanish(SpellMissInfo missInfo) + { + if (missInfo != SPELL_MISS_IMMUNE) + return; - SpellScript* GetSpellScript() const override + if (Unit* target = GetHitUnit()) { - return new spell_warl_banish_SpellScript(); + // Casting Banish on a banished target will remove applied aura + if (Aura * banishAura = target->GetAura(GetSpellInfo()->Id, GetCaster()->GetGUID())) + banishAura->Remove(); } + } + + void Register() override + { + BeforeHit += BeforeSpellHitFn(spell_warl_banish::HandleBanish); + } }; // 116858 - Chaos Bolt @@ -166,171 +155,125 @@ class spell_warl_chaotic_energies : public AuraScript }; // 6201 - Create Healthstone -class spell_warl_create_healthstone : public SpellScriptLoader +class spell_warl_create_healthstone : public SpellScript { - public: - spell_warl_create_healthstone() : SpellScriptLoader("spell_warl_create_healthstone") { } + PrepareSpellScript(spell_warl_create_healthstone); - class spell_warl_create_healthstone_SpellScript : public SpellScript - { - PrepareSpellScript(spell_warl_create_healthstone_SpellScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_WARLOCK_CREATE_HEALTHSTONE }); - } - - bool Load() override - { - return GetCaster()->GetTypeId() == TYPEID_PLAYER; - } + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_WARLOCK_CREATE_HEALTHSTONE }); + } - void HandleScriptEffect(SpellEffIndex /*effIndex*/) - { - GetCaster()->CastSpell(GetCaster(), SPELL_WARLOCK_CREATE_HEALTHSTONE, true); - } + bool Load() override + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_warl_create_healthstone_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + void HandleScriptEffect(SpellEffIndex /*effIndex*/) + { + GetCaster()->CastSpell(GetCaster(), SPELL_WARLOCK_CREATE_HEALTHSTONE, true); + } - SpellScript* GetSpellScript() const override - { - return new spell_warl_create_healthstone_SpellScript(); - } + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_warl_create_healthstone::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } }; // 48018 - Demonic Circle: Summon -/// Updated 4.3.4 -class spell_warl_demonic_circle_summon : public SpellScriptLoader +class spell_warl_demonic_circle_summon : public AuraScript { - public: - spell_warl_demonic_circle_summon() : SpellScriptLoader("spell_warl_demonic_circle_summon") { } + PrepareAuraScript(spell_warl_demonic_circle_summon); - class spell_warl_demonic_circle_summon_AuraScript : public AuraScript - { - PrepareAuraScript(spell_warl_demonic_circle_summon_AuraScript); + void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes mode) + { + // If effect is removed by expire remove the summoned demonic circle too. + if (!(mode & AURA_EFFECT_HANDLE_REAPPLY)) + GetTarget()->RemoveGameObject(GetId(), true); - void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes mode) - { - // If effect is removed by expire remove the summoned demonic circle too. - if (!(mode & AURA_EFFECT_HANDLE_REAPPLY)) - GetTarget()->RemoveGameObject(GetId(), true); + GetTarget()->RemoveAura(SPELL_WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST); + } - GetTarget()->RemoveAura(SPELL_WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST); - } + void HandleDummyTick(AuraEffect const* /*aurEff*/) + { + if (GameObject* circle = GetTarget()->GetGameObject(GetId())) + { + // Here we check if player is in demonic circle teleport range, if so add + // WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST; allowing him to cast the WARLOCK_DEMONIC_CIRCLE_TELEPORT. + // If not in range remove the WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST. - void HandleDummyTick(AuraEffect const* /*aurEff*/) - { - if (GameObject* circle = GetTarget()->GetGameObject(GetId())) - { - // Here we check if player is in demonic circle teleport range, if so add - // WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST; allowing him to cast the WARLOCK_DEMONIC_CIRCLE_TELEPORT. - // If not in range remove the WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST. - - SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(SPELL_WARLOCK_DEMONIC_CIRCLE_TELEPORT, GetCastDifficulty()); - - if (GetTarget()->IsWithinDist(circle, spellInfo->GetMaxRange(true))) - { - if (!GetTarget()->HasAura(SPELL_WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST)) - GetTarget()->CastSpell(GetTarget(), SPELL_WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST, true); - } - else - GetTarget()->RemoveAura(SPELL_WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST); - } - } + SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(SPELL_WARLOCK_DEMONIC_CIRCLE_TELEPORT, GetCastDifficulty()); - void Register() override + if (GetTarget()->IsWithinDist(circle, spellInfo->GetMaxRange(true))) { - OnEffectRemove += AuraEffectApplyFn(spell_warl_demonic_circle_summon_AuraScript::HandleRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); - OnEffectPeriodic += AuraEffectPeriodicFn(spell_warl_demonic_circle_summon_AuraScript::HandleDummyTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); + if (!GetTarget()->HasAura(SPELL_WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST)) + GetTarget()->CastSpell(GetTarget(), SPELL_WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST, true); } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_warl_demonic_circle_summon_AuraScript(); + else + GetTarget()->RemoveAura(SPELL_WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST); } + } + + void Register() override + { + OnEffectRemove += AuraEffectApplyFn(spell_warl_demonic_circle_summon::HandleRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_warl_demonic_circle_summon::HandleDummyTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); + } }; // 48020 - Demonic Circle: Teleport -/// Updated 4.3.4 -class spell_warl_demonic_circle_teleport : public SpellScriptLoader +class spell_warl_demonic_circle_teleport : public AuraScript { - public: - spell_warl_demonic_circle_teleport() : SpellScriptLoader("spell_warl_demonic_circle_teleport") { } + PrepareAuraScript(spell_warl_demonic_circle_teleport); - class spell_warl_demonic_circle_teleport_AuraScript : public AuraScript + void HandleTeleport(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Player* player = GetTarget()->ToPlayer()) { - PrepareAuraScript(spell_warl_demonic_circle_teleport_AuraScript); - - void HandleTeleport(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (Player* player = GetTarget()->ToPlayer()) - { - if (GameObject* circle = player->GetGameObject(SPELL_WARLOCK_DEMONIC_CIRCLE_SUMMON)) - { - player->NearTeleportTo(circle->GetPositionX(), circle->GetPositionY(), circle->GetPositionZ(), circle->GetOrientation()); - player->RemoveMovementImpairingAuras(false); - } - } - } - - void Register() override + if (GameObject* circle = player->GetGameObject(SPELL_WARLOCK_DEMONIC_CIRCLE_SUMMON)) { - OnEffectApply += AuraEffectApplyFn(spell_warl_demonic_circle_teleport_AuraScript::HandleTeleport, EFFECT_0, SPELL_AURA_MECHANIC_IMMUNITY, AURA_EFFECT_HANDLE_REAL); + player->NearTeleportTo(circle->GetPositionX(), circle->GetPositionY(), circle->GetPositionZ(), circle->GetOrientation()); + player->RemoveMovementImpairingAuras(false); } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_warl_demonic_circle_teleport_AuraScript(); } + } + + void Register() override + { + OnEffectApply += AuraEffectApplyFn(spell_warl_demonic_circle_teleport::HandleTeleport, EFFECT_0, SPELL_AURA_MECHANIC_IMMUNITY, AURA_EFFECT_HANDLE_REAL); + } }; // 67518, 19505 - Devour Magic -class spell_warl_devour_magic : public SpellScriptLoader +class spell_warl_devour_magic : public SpellScript { - public: - spell_warl_devour_magic() : SpellScriptLoader("spell_warl_devour_magic") { } - - class spell_warl_devour_magic_SpellScript : public SpellScript - { - PrepareSpellScript(spell_warl_devour_magic_SpellScript); - - bool Validate(SpellInfo const* spellInfo) override - { - return ValidateSpellInfo({ SPELL_WARLOCK_GLYPH_OF_DEMON_TRAINING, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL }) - && spellInfo->GetEffects().size() > EFFECT_1; - } + PrepareSpellScript(spell_warl_devour_magic); - void OnSuccessfulDispel(SpellEffIndex /*effIndex*/) - { - Unit* caster = GetCaster(); - CastSpellExtraArgs args; - args.TriggerFlags = TRIGGERED_FULL_MASK; - args.AddSpellBP0(GetEffectInfo(EFFECT_1).CalcValue(caster)); + bool Validate(SpellInfo const* spellInfo) override + { + return ValidateSpellInfo({ SPELL_WARLOCK_GLYPH_OF_DEMON_TRAINING, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL }) + && spellInfo->GetEffects().size() > EFFECT_1; + } - caster->CastSpell(caster, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL, args); + void OnSuccessfulDispel(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + CastSpellExtraArgs args; + args.TriggerFlags = TRIGGERED_FULL_MASK; + args.AddSpellBP0(GetEffectInfo(EFFECT_1).CalcValue(caster)); - // Glyph of Felhunter - if (Unit* owner = caster->GetOwner()) - if (owner->GetAura(SPELL_WARLOCK_GLYPH_OF_DEMON_TRAINING)) - owner->CastSpell(owner, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL, args); - } + caster->CastSpell(caster, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL, args); - void Register() override - { - OnEffectSuccessfulDispel += SpellEffectFn(spell_warl_devour_magic_SpellScript::OnSuccessfulDispel, EFFECT_0, SPELL_EFFECT_DISPEL); - } - }; + // Glyph of Felhunter + if (Unit* owner = caster->GetOwner()) + if (owner->GetAura(SPELL_WARLOCK_GLYPH_OF_DEMON_TRAINING)) + owner->CastSpell(owner, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL, args); + } - SpellScript* GetSpellScript() const override - { - return new spell_warl_devour_magic_SpellScript(); - } + void Register() override + { + OnEffectSuccessfulDispel += SpellEffectFn(spell_warl_devour_magic::OnSuccessfulDispel, EFFECT_0, SPELL_EFFECT_DISPEL); + } }; // 198590 - Drain Soul @@ -359,124 +302,89 @@ class spell_warl_drain_soul : public AuraScript }; // 48181 - Haunt -/// Updated 4.3.4 -class spell_warl_haunt : public SpellScriptLoader +class spell_warl_haunt : public SpellScript { - public: - spell_warl_haunt() : SpellScriptLoader("spell_warl_haunt") { } + PrepareSpellScript(spell_warl_haunt); - class spell_warl_haunt_SpellScript : public SpellScript - { - PrepareSpellScript(spell_warl_haunt_SpellScript); - - void HandleAfterHit() - { - if (Aura* aura = GetHitAura()) - if (AuraEffect* aurEff = aura->GetEffect(EFFECT_1)) - aurEff->SetAmount(CalculatePct(GetHitDamage(), aurEff->GetAmount())); - } - - void Register() override - { - AfterHit += SpellHitFn(spell_warl_haunt_SpellScript::HandleAfterHit); - } - }; + void HandleAfterHit() + { + if (Aura* aura = GetHitAura()) + if (AuraEffect* aurEff = aura->GetEffect(EFFECT_1)) + aurEff->SetAmount(CalculatePct(GetHitDamage(), aurEff->GetAmount())); + } - SpellScript* GetSpellScript() const override - { - return new spell_warl_haunt_SpellScript(); - } + void Register() override + { + AfterHit += SpellHitFn(spell_warl_haunt::HandleAfterHit); + } }; // 755 - Health Funnel -/// Updated 4.3.4 -class spell_warl_health_funnel : public SpellScriptLoader +class spell_warl_health_funnel : public AuraScript { - public: - spell_warl_health_funnel() : SpellScriptLoader("spell_warl_health_funnel") { } + PrepareAuraScript(spell_warl_health_funnel); - class spell_warl_health_funnel_AuraScript : public AuraScript - { - PrepareAuraScript(spell_warl_health_funnel_AuraScript); + void ApplyEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* caster = GetCaster(); + if (!caster) + return; - void ApplyEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Unit* caster = GetCaster(); - if (!caster) - return; - - Unit* target = GetTarget(); - if (caster->HasAura(SPELL_WARLOCK_IMPROVED_HEALTH_FUNNEL_R2)) - target->CastSpell(target, SPELL_WARLOCK_IMPROVED_HEALTH_FUNNEL_BUFF_R2, true); - else if (caster->HasAura(SPELL_WARLOCK_IMPROVED_HEALTH_FUNNEL_R1)) - target->CastSpell(target, SPELL_WARLOCK_IMPROVED_HEALTH_FUNNEL_BUFF_R1, true); - } + Unit* target = GetTarget(); + if (caster->HasAura(SPELL_WARLOCK_IMPROVED_HEALTH_FUNNEL_R2)) + target->CastSpell(target, SPELL_WARLOCK_IMPROVED_HEALTH_FUNNEL_BUFF_R2, true); + else if (caster->HasAura(SPELL_WARLOCK_IMPROVED_HEALTH_FUNNEL_R1)) + target->CastSpell(target, SPELL_WARLOCK_IMPROVED_HEALTH_FUNNEL_BUFF_R1, true); + } - void RemoveEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Unit* target = GetTarget(); - target->RemoveAurasDueToSpell(SPELL_WARLOCK_IMPROVED_HEALTH_FUNNEL_BUFF_R1); - target->RemoveAurasDueToSpell(SPELL_WARLOCK_IMPROVED_HEALTH_FUNNEL_BUFF_R2); - } + void RemoveEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + target->RemoveAurasDueToSpell(SPELL_WARLOCK_IMPROVED_HEALTH_FUNNEL_BUFF_R1); + target->RemoveAurasDueToSpell(SPELL_WARLOCK_IMPROVED_HEALTH_FUNNEL_BUFF_R2); + } - void OnPeriodic(AuraEffect const* aurEff) - { - Unit* caster = GetCaster(); - if (!caster) - return; - //! HACK for self damage, is not blizz :/ - uint32 damage = caster->CountPctFromMaxHealth(aurEff->GetBaseAmount()); - - if (Player* modOwner = caster->GetSpellModOwner()) - modOwner->ApplySpellMod(GetSpellInfo(), SpellModOp::PowerCost0, damage); - - SpellNonMeleeDamage damageInfo(caster, caster, GetSpellInfo(), GetAura()->GetSpellVisual(), GetSpellInfo()->SchoolMask, GetAura()->GetCastId()); - damageInfo.periodicLog = true; - damageInfo.damage = damage; - caster->DealSpellDamage(&damageInfo, false); - caster->SendSpellNonMeleeDamageLog(&damageInfo); - } + void OnPeriodic(AuraEffect const* aurEff) + { + Unit* caster = GetCaster(); + if (!caster) + return; + //! HACK for self damage, is not blizz :/ + uint32 damage = caster->CountPctFromMaxHealth(aurEff->GetBaseAmount()); - void Register() override - { - OnEffectApply += AuraEffectApplyFn(spell_warl_health_funnel_AuraScript::ApplyEffect, EFFECT_0, SPELL_AURA_OBS_MOD_HEALTH, AURA_EFFECT_HANDLE_REAL); - OnEffectRemove += AuraEffectRemoveFn(spell_warl_health_funnel_AuraScript::RemoveEffect, EFFECT_0, SPELL_AURA_OBS_MOD_HEALTH, AURA_EFFECT_HANDLE_REAL); - OnEffectPeriodic += AuraEffectPeriodicFn(spell_warl_health_funnel_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_OBS_MOD_HEALTH); - } - }; + if (Player* modOwner = caster->GetSpellModOwner()) + modOwner->ApplySpellMod(GetSpellInfo(), SpellModOp::PowerCost0, damage); - AuraScript* GetAuraScript() const override - { - return new spell_warl_health_funnel_AuraScript(); - } + SpellNonMeleeDamage damageInfo(caster, caster, GetSpellInfo(), GetAura()->GetSpellVisual(), GetSpellInfo()->SchoolMask, GetAura()->GetCastId()); + damageInfo.periodicLog = true; + damageInfo.damage = damage; + caster->DealSpellDamage(&damageInfo, false); + caster->SendSpellNonMeleeDamageLog(&damageInfo); + } + + void Register() override + { + OnEffectApply += AuraEffectApplyFn(spell_warl_health_funnel::ApplyEffect, EFFECT_0, SPELL_AURA_OBS_MOD_HEALTH, AURA_EFFECT_HANDLE_REAL); + OnEffectRemove += AuraEffectRemoveFn(spell_warl_health_funnel::RemoveEffect, EFFECT_0, SPELL_AURA_OBS_MOD_HEALTH, AURA_EFFECT_HANDLE_REAL); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_warl_health_funnel::OnPeriodic, EFFECT_0, SPELL_AURA_OBS_MOD_HEALTH); + } }; // 6262 - Healthstone -class spell_warl_healthstone_heal : public SpellScriptLoader +class spell_warl_healthstone_heal : public SpellScript { - public: - spell_warl_healthstone_heal() : SpellScriptLoader("spell_warl_healthstone_heal") { } - - class spell_warl_healthstone_heal_SpellScript : public SpellScript - { - PrepareSpellScript(spell_warl_healthstone_heal_SpellScript); - - void HandleOnHit() - { - int32 heal = int32(CalculatePct(GetCaster()->GetCreateHealth(), GetHitHeal())); - SetHitHeal(heal); - } + PrepareSpellScript(spell_warl_healthstone_heal); - void Register() override - { - OnHit += SpellHitFn(spell_warl_healthstone_heal_SpellScript::HandleOnHit); - } - }; + void HandleOnHit() + { + int32 heal = int32(CalculatePct(GetCaster()->GetCreateHealth(), GetHitHeal())); + SetHitHeal(heal); + } - SpellScript* GetSpellScript() const override - { - return new spell_warl_healthstone_heal_SpellScript(); - } + void Register() override + { + OnHit += SpellHitFn(spell_warl_healthstone_heal::HandleOnHit); + } }; // 348 - Immolate @@ -501,134 +409,100 @@ class spell_warl_immolate : public SpellScript }; // 6358 - Seduction (Special Ability) -class spell_warl_seduction : public SpellScriptLoader +class spell_warl_seduction : public SpellScript { - public: - spell_warl_seduction() : SpellScriptLoader("spell_warl_seduction") { } - - class spell_warl_seduction_SpellScript : public SpellScript - { - PrepareSpellScript(spell_warl_seduction_SpellScript); + PrepareSpellScript(spell_warl_seduction); - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_WARLOCK_GLYPH_OF_SUCCUBUS, SPELL_PRIEST_SHADOW_WORD_DEATH }); - } - - void HandleScriptEffect(SpellEffIndex /*effIndex*/) - { - Unit* caster = GetCaster(); - if (Unit* target = GetHitUnit()) - { - if (caster->GetOwner() && caster->GetOwner()->HasAura(SPELL_WARLOCK_GLYPH_OF_SUCCUBUS)) - { - target->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE, ObjectGuid::Empty, target->GetAura(SPELL_PRIEST_SHADOW_WORD_DEATH)); // SW:D shall not be removed. - target->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE_PERCENT); - target->RemoveAurasByType(SPELL_AURA_PERIODIC_LEECH); - } - } - } + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_WARLOCK_GLYPH_OF_SUCCUBUS, SPELL_PRIEST_SHADOW_WORD_DEATH }); + } - void Register() override + void HandleScriptEffect(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) + { + if (caster->GetOwner() && caster->GetOwner()->HasAura(SPELL_WARLOCK_GLYPH_OF_SUCCUBUS)) { - OnEffectHitTarget += SpellEffectFn(spell_warl_seduction_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_APPLY_AURA); + target->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE, ObjectGuid::Empty, target->GetAura(SPELL_PRIEST_SHADOW_WORD_DEATH)); // SW:D shall not be removed. + target->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE_PERCENT); + target->RemoveAurasByType(SPELL_AURA_PERIODIC_LEECH); } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_warl_seduction_SpellScript(); } + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_warl_seduction::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_APPLY_AURA); + } }; // 27285 - Seed of Corruption -/// Updated 4.3.4 -class spell_warl_seed_of_corruption : public SpellScriptLoader +class spell_warl_seed_of_corruption : public SpellScript { - public: - spell_warl_seed_of_corruption() : SpellScriptLoader("spell_warl_seed_of_corruption") { } - - class spell_warl_seed_of_corruption_SpellScript : public SpellScript - { - PrepareSpellScript(spell_warl_seed_of_corruption_SpellScript); - - void FilterTargets(std::list<WorldObject*>& targets) - { - if (GetExplTargetUnit()) - targets.remove(GetExplTargetUnit()); - } + PrepareSpellScript(spell_warl_seed_of_corruption); - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_warl_seed_of_corruption_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); - } - }; + void FilterTargets(std::list<WorldObject*>& targets) + { + if (GetExplTargetUnit()) + targets.remove(GetExplTargetUnit()); + } - SpellScript* GetSpellScript() const override - { - return new spell_warl_seed_of_corruption_SpellScript(); - } + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_warl_seed_of_corruption::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); + } }; // 27243 - Seed of Corruption -class spell_warl_seed_of_corruption_dummy : public SpellScriptLoader +class spell_warl_seed_of_corruption_dummy : public AuraScript { - public: - spell_warl_seed_of_corruption_dummy() : SpellScriptLoader("spell_warl_seed_of_corruption_dummy") { } + PrepareAuraScript(spell_warl_seed_of_corruption_dummy); - class spell_warl_seed_of_corruption_dummy_AuraScript : public AuraScript - { - PrepareAuraScript(spell_warl_seed_of_corruption_dummy_AuraScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_WARLOCK_SEED_OF_CORRUPTION_DAMAGE }); - } - - void CalculateBuffer(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) - { - Unit* caster = GetCaster(); - if (!caster) - return; + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_WARLOCK_SEED_OF_CORRUPTION_DAMAGE }); + } - amount = caster->SpellBaseDamageBonusDone(GetSpellInfo()->GetSchoolMask()) * GetEffectInfo(EFFECT_0).CalcValue(caster) / 100; - } + void CalculateBuffer(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + { + Unit* caster = GetCaster(); + if (!caster) + return; - void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); - DamageInfo* damageInfo = eventInfo.GetDamageInfo(); - if (!damageInfo || !damageInfo->GetDamage()) - return; + amount = caster->SpellBaseDamageBonusDone(GetSpellInfo()->GetSchoolMask()) * GetEffectInfo(EFFECT_0).CalcValue(caster) / 100; + } - int32 amount = aurEff->GetAmount() - damageInfo->GetDamage(); - if (amount > 0) - { - const_cast<AuraEffect*>(aurEff)->SetAmount(amount); - if (!GetTarget()->HealthBelowPctDamaged(1, damageInfo->GetDamage())) - return; - } + void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + DamageInfo* damageInfo = eventInfo.GetDamageInfo(); + if (!damageInfo || !damageInfo->GetDamage()) + return; - Remove(); + int32 amount = aurEff->GetAmount() - damageInfo->GetDamage(); + if (amount > 0) + { + const_cast<AuraEffect*>(aurEff)->SetAmount(amount); + if (!GetTarget()->HealthBelowPctDamaged(1, damageInfo->GetDamage())) + return; + } - Unit* caster = GetCaster(); - if (!caster) - return; + Remove(); - caster->CastSpell(eventInfo.GetActionTarget(), SPELL_WARLOCK_SEED_OF_CORRUPTION_DAMAGE, aurEff); - } + Unit* caster = GetCaster(); + if (!caster) + return; - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_seed_of_corruption_dummy_AuraScript::CalculateBuffer, EFFECT_2, SPELL_AURA_DUMMY); - OnEffectProc += AuraEffectProcFn(spell_warl_seed_of_corruption_dummy_AuraScript::HandleProc, EFFECT_2, SPELL_AURA_DUMMY); - } - }; + caster->CastSpell(eventInfo.GetActionTarget(), SPELL_WARLOCK_SEED_OF_CORRUPTION_DAMAGE, aurEff); + } - AuraScript* GetAuraScript() const override - { - return new spell_warl_seed_of_corruption_dummy_AuraScript(); - } + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_seed_of_corruption_dummy::CalculateBuffer, EFFECT_2, SPELL_AURA_DUMMY); + OnEffectProc += AuraEffectProcFn(spell_warl_seed_of_corruption_dummy::HandleProc, EFFECT_2, SPELL_AURA_DUMMY); + } }; // 32863 - Seed of Corruption @@ -638,53 +512,42 @@ class spell_warl_seed_of_corruption_dummy : public SpellScriptLoader // 44141 - Seed of Corruption // 70388 - Seed of Corruption // Monster spells, triggered only on amount drop (not on death) -class spell_warl_seed_of_corruption_generic : public SpellScriptLoader +class spell_warl_seed_of_corruption_generic : public AuraScript { - public: - spell_warl_seed_of_corruption_generic() : SpellScriptLoader("spell_warl_seed_of_corruption_generic") { } - - class spell_warl_seed_of_corruption_generic_AuraScript : public AuraScript - { - PrepareAuraScript(spell_warl_seed_of_corruption_generic_AuraScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_WARLOCK_SEED_OF_CORRUPTION_GENERIC }); - } + PrepareAuraScript(spell_warl_seed_of_corruption_generic); - void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); - DamageInfo* damageInfo = eventInfo.GetDamageInfo(); - if (!damageInfo || !damageInfo->GetDamage()) - return; + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_WARLOCK_SEED_OF_CORRUPTION_GENERIC }); + } - int32 amount = aurEff->GetAmount() - damageInfo->GetDamage(); - if (amount > 0) - { - const_cast<AuraEffect*>(aurEff)->SetAmount(amount); - return; - } + void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + DamageInfo* damageInfo = eventInfo.GetDamageInfo(); + if (!damageInfo || !damageInfo->GetDamage()) + return; - Remove(); + int32 amount = aurEff->GetAmount() - damageInfo->GetDamage(); + if (amount > 0) + { + const_cast<AuraEffect*>(aurEff)->SetAmount(amount); + return; + } - Unit* caster = GetCaster(); - if (!caster) - return; + Remove(); - caster->CastSpell(eventInfo.GetActionTarget(), SPELL_WARLOCK_SEED_OF_CORRUPTION_GENERIC, aurEff); - } + Unit* caster = GetCaster(); + if (!caster) + return; - void Register() override - { - OnEffectProc += AuraEffectProcFn(spell_warl_seed_of_corruption_generic_AuraScript::HandleProc, EFFECT_1, SPELL_AURA_DUMMY); - } - }; + caster->CastSpell(eventInfo.GetActionTarget(), SPELL_WARLOCK_SEED_OF_CORRUPTION_GENERIC, aurEff); + } - AuraScript* GetAuraScript() const override - { - return new spell_warl_seed_of_corruption_generic_AuraScript(); - } + void Register() override + { + OnEffectProc += AuraEffectProcFn(spell_warl_seed_of_corruption_generic::HandleProc, EFFECT_1, SPELL_AURA_DUMMY); + } }; // 686 - Shadow Bolt @@ -709,389 +572,296 @@ class spell_warl_shadow_bolt : public SpellScript }; // 86121 - Soul Swap -class spell_warl_soul_swap : public SpellScriptLoader +class spell_warl_soul_swap : public SpellScript { - public: - spell_warl_soul_swap() : SpellScriptLoader("spell_warl_soul_swap") { } + PrepareSpellScript(spell_warl_soul_swap); - class spell_warl_soul_swap_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo( { - PrepareSpellScript(spell_warl_soul_swap_SpellScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo( - { - SPELL_WARLOCK_GLYPH_OF_SOUL_SWAP, - SPELL_WARLOCK_SOUL_SWAP_CD_MARKER, - SPELL_WARLOCK_SOUL_SWAP_OVERRIDE - }); - } - - void HandleHit(SpellEffIndex /*effIndex*/) - { - GetCaster()->CastSpell(GetCaster(), SPELL_WARLOCK_SOUL_SWAP_OVERRIDE, true); - GetHitUnit()->CastSpell(GetCaster(), SPELL_WARLOCK_SOUL_SWAP_DOT_MARKER, true); - } + SPELL_WARLOCK_GLYPH_OF_SOUL_SWAP, + SPELL_WARLOCK_SOUL_SWAP_CD_MARKER, + SPELL_WARLOCK_SOUL_SWAP_OVERRIDE + }); + } - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_warl_soul_swap_SpellScript::HandleHit, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); - } - }; + void HandleHit(SpellEffIndex /*effIndex*/) + { + GetCaster()->CastSpell(GetCaster(), SPELL_WARLOCK_SOUL_SWAP_OVERRIDE, true); + GetHitUnit()->CastSpell(GetCaster(), SPELL_WARLOCK_SOUL_SWAP_DOT_MARKER, true); + } - SpellScript* GetSpellScript() const override - { - return new spell_warl_soul_swap_SpellScript(); - } + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_warl_soul_swap::HandleHit, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); + } }; // 86211 - Soul Swap Override - Also acts as a dot container -class spell_warl_soul_swap_override : public SpellScriptLoader +class spell_warl_soul_swap_override : public AuraScript { - public: - spell_warl_soul_swap_override() : SpellScriptLoader("spell_warl_soul_swap_override") { } - - class spell_warl_soul_swap_override_AuraScript : public AuraScript - { - PrepareAuraScript(spell_warl_soul_swap_override_AuraScript); - - //! Forced to, pure virtual functions must have a body when linking - void Register() override { } - - public: - void AddDot(uint32 id) { _dotList.push_back(id); } - std::list<uint32> const GetDotList() const { return _dotList; } - Unit* GetOriginalSwapSource() const { return _swapCaster; } - void SetOriginalSwapSource(Unit* victim) { _swapCaster = victim; } + PrepareAuraScript(spell_warl_soul_swap_override); - private: - std::list<uint32> _dotList; - Unit* _swapCaster = nullptr; - }; + //! Forced to, pure virtual functions must have a body when linking + void Register() override { } - AuraScript* GetAuraScript() const override - { - return new spell_warl_soul_swap_override_AuraScript(); - } +public: + void AddDot(uint32 id) { _dotList.push_back(id); } + std::list<uint32> const GetDotList() const { return _dotList; } + Unit* GetOriginalSwapSource() const { return _swapCaster; } + void SetOriginalSwapSource(Unit* victim) { _swapCaster = victim; } + +private: + std::list<uint32> _dotList; + Unit* _swapCaster = nullptr; }; -typedef spell_warl_soul_swap_override::spell_warl_soul_swap_override_AuraScript SoulSwapOverrideAuraScript; - //! Soul Swap Copy Spells - 92795 - Simply copies spell IDs. -class spell_warl_soul_swap_dot_marker : public SpellScriptLoader +class spell_warl_soul_swap_dot_marker : public SpellScript { - public: - spell_warl_soul_swap_dot_marker() : SpellScriptLoader("spell_warl_soul_swap_dot_marker") { } - - class spell_warl_soul_swap_dot_marker_SpellScript : public SpellScript - { - PrepareSpellScript(spell_warl_soul_swap_dot_marker_SpellScript); + PrepareSpellScript(spell_warl_soul_swap_dot_marker); - void HandleHit(SpellEffIndex /*effIndex*/) - { - Unit* swapVictim = GetCaster(); - Unit* warlock = GetHitUnit(); - if (!warlock || !swapVictim) - return; - - Unit::AuraApplicationMap const& appliedAuras = swapVictim->GetAppliedAuras(); - SoulSwapOverrideAuraScript* swapSpellScript = nullptr; - if (Aura* swapOverrideAura = warlock->GetAura(SPELL_WARLOCK_SOUL_SWAP_OVERRIDE)) - swapSpellScript = swapOverrideAura->GetScript<SoulSwapOverrideAuraScript>(); - - if (!swapSpellScript) - return; + void HandleHit(SpellEffIndex /*effIndex*/) + { + Unit* swapVictim = GetCaster(); + Unit* warlock = GetHitUnit(); + if (!warlock || !swapVictim) + return; - flag128 classMask = GetEffectInfo().SpellClassMask; + Unit::AuraApplicationMap const& appliedAuras = swapVictim->GetAppliedAuras(); + spell_warl_soul_swap_override* swapSpellScript = nullptr; + if (Aura* swapOverrideAura = warlock->GetAura(SPELL_WARLOCK_SOUL_SWAP_OVERRIDE)) + swapSpellScript = swapOverrideAura->GetScript<spell_warl_soul_swap_override>(); - for (Unit::AuraApplicationMap::const_iterator itr = appliedAuras.begin(); itr != appliedAuras.end(); ++itr) - { - SpellInfo const* spellProto = itr->second->GetBase()->GetSpellInfo(); - if (itr->second->GetBase()->GetCaster() == warlock) - if (spellProto->SpellFamilyName == SPELLFAMILY_WARLOCK && (spellProto->SpellFamilyFlags & classMask)) - swapSpellScript->AddDot(itr->first); - } - - swapSpellScript->SetOriginalSwapSource(swapVictim); - } + if (!swapSpellScript) + return; - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_warl_soul_swap_dot_marker_SpellScript::HandleHit, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + flag128 classMask = GetEffectInfo().SpellClassMask; - SpellScript* GetSpellScript() const override + for (Unit::AuraApplicationMap::const_iterator itr = appliedAuras.begin(); itr != appliedAuras.end(); ++itr) { - return new spell_warl_soul_swap_dot_marker_SpellScript(); + SpellInfo const* spellProto = itr->second->GetBase()->GetSpellInfo(); + if (itr->second->GetBase()->GetCaster() == warlock) + if (spellProto->SpellFamilyName == SPELLFAMILY_WARLOCK && (spellProto->SpellFamilyFlags & classMask)) + swapSpellScript->AddDot(itr->first); } + + swapSpellScript->SetOriginalSwapSource(swapVictim); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_warl_soul_swap_dot_marker::HandleHit, EFFECT_0, SPELL_EFFECT_DUMMY); + } }; // 86213 - Soul Swap Exhale -class spell_warl_soul_swap_exhale : public SpellScriptLoader +class spell_warl_soul_swap_exhale : public SpellScript { -public: - spell_warl_soul_swap_exhale() : SpellScriptLoader("spell_warl_soul_swap_exhale") { } + PrepareSpellScript(spell_warl_soul_swap_exhale); - class spell_warl_soul_swap_exhale_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_warl_soul_swap_exhale_SpellScript); + return ValidateSpellInfo({ SPELL_WARLOCK_SOUL_SWAP_MOD_COST, SPELL_WARLOCK_SOUL_SWAP_OVERRIDE }); + } - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_WARLOCK_SOUL_SWAP_MOD_COST, SPELL_WARLOCK_SOUL_SWAP_OVERRIDE }); - } + SpellCastResult CheckCast() + { + Unit* currentTarget = GetExplTargetUnit(); + Unit* swapTarget = nullptr; + if (Aura const* swapOverride = GetCaster()->GetAura(SPELL_WARLOCK_SOUL_SWAP_OVERRIDE)) + if (spell_warl_soul_swap_override* swapScript = swapOverride->GetScript<spell_warl_soul_swap_override>()) + swapTarget = swapScript->GetOriginalSwapSource(); - SpellCastResult CheckCast() - { - Unit* currentTarget = GetExplTargetUnit(); - Unit* swapTarget = nullptr; - if (Aura const* swapOverride = GetCaster()->GetAura(SPELL_WARLOCK_SOUL_SWAP_OVERRIDE)) - if (SoulSwapOverrideAuraScript* swapScript = swapOverride->GetScript<SoulSwapOverrideAuraScript>()) - swapTarget = swapScript->GetOriginalSwapSource(); + // Soul Swap Exhale can't be cast on the same target than Soul Swap + if (swapTarget && currentTarget && swapTarget == currentTarget) + return SPELL_FAILED_BAD_TARGETS; - // Soul Swap Exhale can't be cast on the same target than Soul Swap - if (swapTarget && currentTarget && swapTarget == currentTarget) - return SPELL_FAILED_BAD_TARGETS; + return SPELL_CAST_OK; + } - return SPELL_CAST_OK; - } + void OnEffectHit(SpellEffIndex /*effIndex*/) + { + GetCaster()->CastSpell(GetCaster(), SPELL_WARLOCK_SOUL_SWAP_MOD_COST, true); + bool hasGlyph = GetCaster()->HasAura(SPELL_WARLOCK_GLYPH_OF_SOUL_SWAP); - void OnEffectHit(SpellEffIndex /*effIndex*/) + std::list<uint32> dotList; + Unit* swapSource = nullptr; + if (Aura const* swapOverride = GetCaster()->GetAura(SPELL_WARLOCK_SOUL_SWAP_OVERRIDE)) { - GetCaster()->CastSpell(GetCaster(), SPELL_WARLOCK_SOUL_SWAP_MOD_COST, true); - bool hasGlyph = GetCaster()->HasAura(SPELL_WARLOCK_GLYPH_OF_SOUL_SWAP); - - std::list<uint32> dotList; - Unit* swapSource = nullptr; - if (Aura const* swapOverride = GetCaster()->GetAura(SPELL_WARLOCK_SOUL_SWAP_OVERRIDE)) - { - SoulSwapOverrideAuraScript* swapScript = swapOverride->GetScript<SoulSwapOverrideAuraScript>(); - if (!swapScript) - return; - dotList = swapScript->GetDotList(); - swapSource = swapScript->GetOriginalSwapSource(); - } - - if (dotList.empty()) + spell_warl_soul_swap_override* swapScript = swapOverride->GetScript<spell_warl_soul_swap_override>(); + if (!swapScript) return; - - for (std::list<uint32>::const_iterator itr = dotList.begin(); itr != dotList.end(); ++itr) - { - GetCaster()->AddAura(*itr, GetHitUnit()); - if (!hasGlyph && swapSource) - swapSource->RemoveAurasDueToSpell(*itr); - } - - // Remove Soul Swap Exhale buff - GetCaster()->RemoveAurasDueToSpell(SPELL_WARLOCK_SOUL_SWAP_OVERRIDE); - - if (hasGlyph) // Add a cooldown on Soul Swap if caster has the glyph - GetCaster()->CastSpell(GetCaster(), SPELL_WARLOCK_SOUL_SWAP_CD_MARKER, false); + dotList = swapScript->GetDotList(); + swapSource = swapScript->GetOriginalSwapSource(); } - void Register() override + if (dotList.empty()) + return; + + for (std::list<uint32>::const_iterator itr = dotList.begin(); itr != dotList.end(); ++itr) { - OnCheckCast += SpellCheckCastFn(spell_warl_soul_swap_exhale_SpellScript::CheckCast); - OnEffectHitTarget += SpellEffectFn(spell_warl_soul_swap_exhale_SpellScript::OnEffectHit, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); + GetCaster()->AddAura(*itr, GetHitUnit()); + if (!hasGlyph && swapSource) + swapSource->RemoveAurasDueToSpell(*itr); } - }; - SpellScript* GetSpellScript() const override + // Remove Soul Swap Exhale buff + GetCaster()->RemoveAurasDueToSpell(SPELL_WARLOCK_SOUL_SWAP_OVERRIDE); + + if (hasGlyph) // Add a cooldown on Soul Swap if caster has the glyph + GetCaster()->CastSpell(GetCaster(), SPELL_WARLOCK_SOUL_SWAP_CD_MARKER, false); + } + + void Register() override { - return new spell_warl_soul_swap_exhale_SpellScript(); + OnCheckCast += SpellCheckCastFn(spell_warl_soul_swap_exhale::CheckCast); + OnEffectHitTarget += SpellEffectFn(spell_warl_soul_swap_exhale::OnEffectHit, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); } }; // 29858 - Soulshatter -/// Updated 4.3.4 -class spell_warl_soulshatter : public SpellScriptLoader +class spell_warl_soulshatter : public SpellScript { - public: - spell_warl_soulshatter() : SpellScriptLoader("spell_warl_soulshatter") { } - - class spell_warl_soulshatter_SpellScript : public SpellScript - { - PrepareSpellScript(spell_warl_soulshatter_SpellScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_WARLOCK_SOULSHATTER_EFFECT }); - } + PrepareSpellScript(spell_warl_soulshatter); - void HandleDummy(SpellEffIndex /*effIndex*/) - { - Unit* caster = GetCaster(); - if (Unit* target = GetHitUnit()) - if (target->GetThreatManager().IsThreatenedBy(caster, true)) - caster->CastSpell(target, SPELL_WARLOCK_SOULSHATTER_EFFECT, true); - } + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_WARLOCK_SOULSHATTER_EFFECT }); + } - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_warl_soulshatter_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) + if (target->GetThreatManager().IsThreatenedBy(caster, true)) + caster->CastSpell(target, SPELL_WARLOCK_SOULSHATTER_EFFECT, true); + } - SpellScript* GetSpellScript() const override - { - return new spell_warl_soulshatter_SpellScript(); - } + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_warl_soulshatter::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } }; // 37377 - Shadowflame // 39437 - Shadowflame Hellfire and RoF -template <uint32 TriggerSpellId> -class spell_warl_t4_2p_bonus : public SpellScriptLoader +template <uint32 Trigger> +class spell_warl_t4_2p_bonus : public AuraScript { - public: - spell_warl_t4_2p_bonus(char const* ScriptName) : SpellScriptLoader(ScriptName) { } - - template <uint32 Trigger> - class spell_warl_t4_2p_bonus_AuraScript : public AuraScript - { - PrepareAuraScript(spell_warl_t4_2p_bonus_AuraScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ Trigger }); - } + PrepareAuraScript(spell_warl_t4_2p_bonus); - void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); - Unit* caster = eventInfo.GetActor(); - caster->CastSpell(caster, Trigger, aurEff); - } + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ Trigger }); + } - void Register() override - { - OnEffectProc += AuraEffectProcFn(spell_warl_t4_2p_bonus_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); - } - }; + void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + Unit* caster = eventInfo.GetActor(); + caster->CastSpell(caster, Trigger, aurEff); + } - AuraScript* GetAuraScript() const override - { - return new spell_warl_t4_2p_bonus_AuraScript<TriggerSpellId>(); - } + void Register() override + { + OnEffectProc += AuraEffectProcFn(spell_warl_t4_2p_bonus::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); + } }; // 30108, 34438, 34439, 35183 - Unstable Affliction -/// Updated 4.3.4 -class spell_warl_unstable_affliction : public SpellScriptLoader +class spell_warl_unstable_affliction : public AuraScript { - public: - spell_warl_unstable_affliction() : SpellScriptLoader("spell_warl_unstable_affliction") { } + PrepareAuraScript(spell_warl_unstable_affliction); - class spell_warl_unstable_affliction_AuraScript : public AuraScript - { - PrepareAuraScript(spell_warl_unstable_affliction_AuraScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_WARLOCK_UNSTABLE_AFFLICTION_DISPEL }); - } + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_WARLOCK_UNSTABLE_AFFLICTION_DISPEL }); + } - void HandleDispel(DispelInfo* dispelInfo) + void HandleDispel(DispelInfo* dispelInfo) + { + if (Unit* caster = GetCaster()) + { + if (AuraEffect const* aurEff = GetEffect(EFFECT_1)) { - if (Unit* caster = GetCaster()) + if (Unit* target = dispelInfo->GetDispeller()->ToUnit()) { - if (AuraEffect const* aurEff = GetEffect(EFFECT_1)) - { - if (Unit* target = dispelInfo->GetDispeller()->ToUnit()) - { - int32 bp = aurEff->GetAmount(); - bp = target->SpellDamageBonusTaken(caster, aurEff->GetSpellInfo(), bp, DOT); - bp *= 9; - - // backfire damage and silence - CastSpellExtraArgs args(aurEff); - args.AddSpellBP0(bp); - caster->CastSpell(target, SPELL_WARLOCK_UNSTABLE_AFFLICTION_DISPEL, args); - } - } + int32 bp = aurEff->GetAmount(); + bp = target->SpellDamageBonusTaken(caster, aurEff->GetSpellInfo(), bp, DOT); + bp *= 9; + + // backfire damage and silence + CastSpellExtraArgs args(aurEff); + args.AddSpellBP0(bp); + caster->CastSpell(target, SPELL_WARLOCK_UNSTABLE_AFFLICTION_DISPEL, args); } } - - void Register() override - { - AfterDispel += AuraDispelFn(spell_warl_unstable_affliction_AuraScript::HandleDispel); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_warl_unstable_affliction_AuraScript(); } + } + + void Register() override + { + AfterDispel += AuraDispelFn(spell_warl_unstable_affliction::HandleDispel); + } }; // 5740 - Rain of Fire /// Updated 7.1.5 -class spell_warl_rain_of_fire : public SpellScriptLoader +class spell_warl_rain_of_fire : public AuraScript { -public: - spell_warl_rain_of_fire() : SpellScriptLoader("spell_warl_rain_of_fire") { } + PrepareAuraScript(spell_warl_rain_of_fire); - class spell_warl_rain_of_fire_AuraScript : public AuraScript + void HandleDummyTick(AuraEffect const* /*aurEff*/) { - PrepareAuraScript(spell_warl_rain_of_fire_AuraScript); + std::vector<AreaTrigger*> rainOfFireAreaTriggers = GetTarget()->GetAreaTriggers(SPELL_WARLOCK_RAIN_OF_FIRE); + GuidUnorderedSet targetsInRainOfFire; - void HandleDummyTick(AuraEffect const* /*aurEff*/) + for (AreaTrigger* rainOfFireAreaTrigger : rainOfFireAreaTriggers) { - std::vector<AreaTrigger*> rainOfFireAreaTriggers = GetTarget()->GetAreaTriggers(SPELL_WARLOCK_RAIN_OF_FIRE); - GuidUnorderedSet targetsInRainOfFire; - - for (AreaTrigger* rainOfFireAreaTrigger : rainOfFireAreaTriggers) - { - GuidUnorderedSet const& insideTargets = rainOfFireAreaTrigger->GetInsideUnits(); - targetsInRainOfFire.insert(insideTargets.begin(), insideTargets.end()); - } - - for (ObjectGuid insideTargetGuid : targetsInRainOfFire) - if (Unit* insideTarget = ObjectAccessor::GetUnit(*GetTarget(), insideTargetGuid)) - if (!GetTarget()->IsFriendlyTo(insideTarget)) - GetTarget()->CastSpell(insideTarget, SPELL_WARLOCK_RAIN_OF_FIRE_DAMAGE, true); + GuidUnorderedSet const& insideTargets = rainOfFireAreaTrigger->GetInsideUnits(); + targetsInRainOfFire.insert(insideTargets.begin(), insideTargets.end()); } - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_warl_rain_of_fire_AuraScript::HandleDummyTick, EFFECT_3, SPELL_AURA_PERIODIC_DUMMY); - } - }; + for (ObjectGuid insideTargetGuid : targetsInRainOfFire) + if (Unit* insideTarget = ObjectAccessor::GetUnit(*GetTarget(), insideTargetGuid)) + if (!GetTarget()->IsFriendlyTo(insideTarget)) + GetTarget()->CastSpell(insideTarget, SPELL_WARLOCK_RAIN_OF_FIRE_DAMAGE, true); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_warl_rain_of_fire_AuraScript(); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_warl_rain_of_fire::HandleDummyTick, EFFECT_3, SPELL_AURA_PERIODIC_DUMMY); } }; void AddSC_warlock_spell_scripts() { - new spell_warl_banish(); + RegisterSpellScript(spell_warl_banish); RegisterSpellScript(spell_warl_chaos_bolt); RegisterSpellScript(spell_warl_chaotic_energies); - new spell_warl_create_healthstone(); - new spell_warl_demonic_circle_summon(); - new spell_warl_demonic_circle_teleport(); - new spell_warl_devour_magic(); + RegisterSpellScript(spell_warl_create_healthstone); + RegisterSpellScript(spell_warl_demonic_circle_summon); + RegisterSpellScript(spell_warl_demonic_circle_teleport); + RegisterSpellScript(spell_warl_devour_magic); RegisterSpellScript(spell_warl_drain_soul); - new spell_warl_haunt(); - new spell_warl_health_funnel(); - new spell_warl_healthstone_heal(); + RegisterSpellScript(spell_warl_haunt); + RegisterSpellScript(spell_warl_health_funnel); + RegisterSpellScript(spell_warl_healthstone_heal); RegisterSpellScript(spell_warl_immolate); - new spell_warl_seduction(); - new spell_warl_seed_of_corruption(); - new spell_warl_seed_of_corruption_dummy(); - new spell_warl_seed_of_corruption_generic(); + RegisterSpellScript(spell_warl_seduction); + RegisterSpellScript(spell_warl_seed_of_corruption); + RegisterSpellScript(spell_warl_seed_of_corruption_dummy); + RegisterSpellScript(spell_warl_seed_of_corruption_generic); RegisterSpellScript(spell_warl_shadow_bolt); - new spell_warl_soul_swap(); - new spell_warl_soul_swap_dot_marker(); - new spell_warl_soul_swap_exhale(); - new spell_warl_soul_swap_override(); - new spell_warl_soulshatter(); - new spell_warl_t4_2p_bonus<SPELL_WARLOCK_FLAMESHADOW>("spell_warl_t4_2p_bonus_shadow"); - new spell_warl_t4_2p_bonus<SPELL_WARLOCK_SHADOWFLAME>("spell_warl_t4_2p_bonus_fire"); - new spell_warl_unstable_affliction(); - new spell_warl_rain_of_fire(); + RegisterSpellScript(spell_warl_soul_swap); + RegisterSpellScript(spell_warl_soul_swap_dot_marker); + RegisterSpellScript(spell_warl_soul_swap_exhale); + RegisterSpellScript(spell_warl_soul_swap_override); + RegisterSpellScript(spell_warl_soulshatter); + RegisterSpellScriptWithArgs(spell_warl_t4_2p_bonus<SPELL_WARLOCK_FLAMESHADOW>, "spell_warl_t4_2p_bonus_shadow"); + RegisterSpellScriptWithArgs(spell_warl_t4_2p_bonus<SPELL_WARLOCK_SHADOWFLAME>, "spell_warl_t4_2p_bonus_fire"); + RegisterSpellScript(spell_warl_unstable_affliction); + RegisterSpellScript(spell_warl_rain_of_fire); } |