diff options
author | Sorikoff <46191832+Sorikoff@users.noreply.github.com> | 2019-08-18 13:56:27 +0000 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-12-18 21:11:58 +0100 |
commit | 568e60ef517ea28b17d6d404bb1dfcc49c88bc4f (patch) | |
tree | 8ce5dc08138594aca32288f2880985806f19f6a1 /src | |
parent | a995e5fda47c5c8302cb6784b9e5f289fde5695f (diff) |
Scripts/Spells: Port druid scripts to new script registration syntax (2 of 3) (#23696)
* Scripts/Spells: Port Druid Scripts to New Script Registration
* Revert
* Revert 2
* Revert 3
* Revert 4
(cherry picked from commit 9a8a01925ae0a02f565fb317a2786e82b20cc298)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/scripts/Spells/spell_druid.cpp | 822 |
1 files changed, 331 insertions, 491 deletions
diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp index a5ba07e3ccc..ab6c31ae210 100644 --- a/src/server/scripts/Spells/spell_druid.cpp +++ b/src/server/scripts/Spells/spell_druid.cpp @@ -946,31 +946,20 @@ class spell_dru_omen_of_clarity : public AuraScript }; // -16972 - Predatory Strikes -class spell_dru_predatory_strikes : public SpellScriptLoader +class spell_dru_predatory_strikes : public AuraScript { -public: - spell_dru_predatory_strikes() : SpellScriptLoader("spell_dru_predatory_strikes") { } + PrepareAuraScript(spell_dru_predatory_strikes); - class spell_dru_predatory_strikes_AuraScript : public AuraScript + void UpdateAmount(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - PrepareAuraScript(spell_dru_predatory_strikes_AuraScript); - - void UpdateAmount(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (Player* target = GetTarget()->ToPlayer()) - target->UpdateAttackPowerAndDamage(); - } - - void Register() override - { - AfterEffectApply += AuraEffectApplyFn(spell_dru_predatory_strikes_AuraScript::UpdateAmount, EFFECT_ALL, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK); - AfterEffectRemove += AuraEffectRemoveFn(spell_dru_predatory_strikes_AuraScript::UpdateAmount, EFFECT_ALL, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK); - } - }; + if (Player* target = GetTarget()->ToPlayer()) + target->UpdateAttackPowerAndDamage(); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_dru_predatory_strikes_AuraScript(); + AfterEffectApply += AuraEffectApplyFn(spell_dru_predatory_strikes::UpdateAmount, EFFECT_ALL, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK); + AfterEffectRemove += AuraEffectRemoveFn(spell_dru_predatory_strikes::UpdateAmount, EFFECT_ALL, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK); } }; @@ -982,50 +971,39 @@ protected: }; // 1079 - Rip -class spell_dru_rip : public SpellScriptLoader +class spell_dru_rip : public AuraScript { -public: - spell_dru_rip() : SpellScriptLoader("spell_dru_rip") { } + PrepareAuraScript(spell_dru_rip); - class spell_dru_rip_AuraScript : public AuraScript + bool Load() override { - PrepareAuraScript(spell_dru_rip_AuraScript); + Unit* caster = GetCaster(); + return caster && caster->GetTypeId() == TYPEID_PLAYER; + } - bool Load() override - { - Unit* caster = GetCaster(); - return caster && caster->GetTypeId() == TYPEID_PLAYER; - } + void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + { + canBeRecalculated = false; - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + if (Unit* caster = GetCaster()) { - canBeRecalculated = false; - - if (Unit* caster = GetCaster()) - { - // 0.01 * $AP * cp - uint32 cp = caster->ToPlayer()->GetComboPoints(); + // 0.01 * $AP * cp + uint32 cp = caster->ToPlayer()->GetComboPoints(); - // Idol of Feral Shadows. Can't be handled as SpellMod due its dependency from CPs - if (AuraEffect const* auraEffIdolOfFeralShadows = caster->GetAuraEffect(SPELL_DRUID_IDOL_OF_FERAL_SHADOWS, EFFECT_0)) - amount += cp * auraEffIdolOfFeralShadows->GetAmount(); - // Idol of Worship. Can't be handled as SpellMod due its dependency from CPs - else if (AuraEffect const* auraEffIdolOfWorship = caster->GetAuraEffect(SPELL_DRUID_IDOL_OF_WORSHIP, EFFECT_0)) - amount += cp * auraEffIdolOfWorship->GetAmount(); + // Idol of Feral Shadows. Can't be handled as SpellMod due its dependency from CPs + if (AuraEffect const* auraEffIdolOfFeralShadows = caster->GetAuraEffect(SPELL_DRUID_IDOL_OF_FERAL_SHADOWS, EFFECT_0)) + amount += cp * auraEffIdolOfFeralShadows->GetAmount(); + // Idol of Worship. Can't be handled as SpellMod due its dependency from CPs + else if (AuraEffect const* auraEffIdolOfWorship = caster->GetAuraEffect(SPELL_DRUID_IDOL_OF_WORSHIP, EFFECT_0)) + amount += cp * auraEffIdolOfWorship->GetAmount(); - amount += int32(CalculatePct(caster->GetTotalAttackPowerValue(BASE_ATTACK), cp)); - } + amount += int32(CalculatePct(caster->GetTotalAttackPowerValue(BASE_ATTACK), cp)); } + } - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dru_rip_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_dru_rip_AuraScript(); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dru_rip::CalculateAmount, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE); } }; @@ -1100,56 +1078,45 @@ class spell_dru_skull_bash : public SpellScript }; // -78892 - Stampede -class spell_dru_stampede : public SpellScriptLoader +class spell_dru_stampede : public AuraScript { -public: - spell_dru_stampede() : SpellScriptLoader("spell_dru_stampede") { } + PrepareAuraScript(spell_dru_stampede); - class spell_dru_stampede_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_dru_stampede_AuraScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo( - { - SPELL_DRUID_STAMPEDE_BAER_RANK_1, - SPELL_DRUID_STAMPEDE_CAT_RANK_1, - SPELL_DRUID_STAMPEDE_CAT_STATE, - SPELL_DRUID_FERAL_CHARGE_CAT, - SPELL_DRUID_FERAL_CHARGE_BEAR - }); - } - - void HandleEffectCatProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) + return ValidateSpellInfo( { - PreventDefaultAction(); - if (GetTarget()->GetShapeshiftForm() != FORM_CAT_FORM || eventInfo.GetDamageInfo()->GetSpellInfo()->Id != SPELL_DRUID_FERAL_CHARGE_CAT) - return; + SPELL_DRUID_STAMPEDE_BAER_RANK_1, + SPELL_DRUID_STAMPEDE_CAT_RANK_1, + SPELL_DRUID_STAMPEDE_CAT_STATE, + SPELL_DRUID_FERAL_CHARGE_CAT, + SPELL_DRUID_FERAL_CHARGE_BEAR + }); + } - GetTarget()->CastSpell(GetTarget(), sSpellMgr->GetSpellWithRank(SPELL_DRUID_STAMPEDE_CAT_RANK_1, GetSpellInfo()->GetRank()), aurEff); - GetTarget()->CastSpell(GetTarget(), SPELL_DRUID_STAMPEDE_CAT_STATE, aurEff); - } + void HandleEffectCatProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + if (GetTarget()->GetShapeshiftForm() != FORM_CAT_FORM || eventInfo.GetDamageInfo()->GetSpellInfo()->Id != SPELL_DRUID_FERAL_CHARGE_CAT) + return; - void HandleEffectBearProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); - if (GetTarget()->GetShapeshiftForm() != FORM_BEAR_FORM || eventInfo.GetDamageInfo()->GetSpellInfo()->Id != SPELL_DRUID_FERAL_CHARGE_BEAR) - return; + GetTarget()->CastSpell(GetTarget(), sSpellMgr->GetSpellWithRank(SPELL_DRUID_STAMPEDE_CAT_RANK_1, GetSpellInfo()->GetRank()), aurEff); + GetTarget()->CastSpell(GetTarget(), SPELL_DRUID_STAMPEDE_CAT_STATE, aurEff); + } - GetTarget()->CastSpell(GetTarget(), sSpellMgr->GetSpellWithRank(SPELL_DRUID_STAMPEDE_BAER_RANK_1, GetSpellInfo()->GetRank()), aurEff); - } + void HandleEffectBearProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + if (GetTarget()->GetShapeshiftForm() != FORM_BEAR_FORM || eventInfo.GetDamageInfo()->GetSpellInfo()->Id != SPELL_DRUID_FERAL_CHARGE_BEAR) + return; - void Register() override - { - OnEffectProc += AuraEffectProcFn(spell_dru_stampede_AuraScript::HandleEffectCatProc, EFFECT_0, SPELL_AURA_DUMMY); - OnEffectProc += AuraEffectProcFn(spell_dru_stampede_AuraScript::HandleEffectBearProc, EFFECT_1, SPELL_AURA_DUMMY); - } - }; + GetTarget()->CastSpell(GetTarget(), sSpellMgr->GetSpellWithRank(SPELL_DRUID_STAMPEDE_BAER_RANK_1, GetSpellInfo()->GetRank()), aurEff); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_dru_stampede_AuraScript(); + OnEffectProc += AuraEffectProcFn(spell_dru_stampede::HandleEffectCatProc, EFFECT_0, SPELL_AURA_DUMMY); + OnEffectProc += AuraEffectProcFn(spell_dru_stampede::HandleEffectBearProc, EFFECT_1, SPELL_AURA_DUMMY); } }; @@ -1161,76 +1128,53 @@ protected: }; // 50286 - Starfall (Dummy) -class spell_dru_starfall_dummy : public SpellScriptLoader +class spell_dru_starfall_dummy : public SpellScript { -public: - spell_dru_starfall_dummy() : SpellScriptLoader("spell_dru_starfall_dummy") { } + PrepareSpellScript(spell_dru_starfall_dummy); - class spell_dru_starfall_dummy_SpellScript : public SpellScript + void FilterTargets(std::list<WorldObject*>& targets) { - PrepareSpellScript(spell_dru_starfall_dummy_SpellScript); + Trinity::Containers::RandomResize(targets, 2); + } - void FilterTargets(std::list<WorldObject*>& targets) + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + // Shapeshifting into an animal form or mounting cancels the effect + if (caster->GetCreatureType() == CREATURE_TYPE_BEAST || caster->IsMounted()) { - Trinity::Containers::RandomResize(targets, 2); + if (SpellInfo const* spellInfo = GetTriggeringSpell()) + caster->RemoveAurasDueToSpell(spellInfo->Id); + return; } - void HandleDummy(SpellEffIndex /*effIndex*/) - { - Unit* caster = GetCaster(); - // Shapeshifting into an animal form or mounting cancels the effect - if (caster->GetCreatureType() == CREATURE_TYPE_BEAST || caster->IsMounted()) - { - if (SpellInfo const* spellInfo = GetTriggeringSpell()) - caster->RemoveAurasDueToSpell(spellInfo->Id); - return; - } - - // Any effect which causes you to lose control of your character will supress the starfall effect. - if (caster->HasUnitState(UNIT_STATE_CONTROLLED)) - return; - - caster->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true); - } + // Any effect which causes you to lose control of your character will supress the starfall effect. + if (caster->HasUnitState(UNIT_STATE_CONTROLLED)) + return; - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_dru_starfall_dummy_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnEffectHitTarget += SpellEffectFn(spell_dru_starfall_dummy_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + caster->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_dru_starfall_dummy_SpellScript(); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_dru_starfall_dummy::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnEffectHitTarget += SpellEffectFn(spell_dru_starfall_dummy::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; // 93402 - Sunfire -class spell_dru_sunfire : public SpellScriptLoader +class spell_dru_sunfire : public SpellScript { -public: - spell_dru_sunfire() : SpellScriptLoader("spell_dru_sunfire") { } + PrepareSpellScript(spell_dru_sunfire); - class spell_dru_sunfire_SpellScript : public SpellScript + void HandleOnHit(SpellEffIndex /*effIndex*/) { - PrepareSpellScript(spell_dru_sunfire_SpellScript); - - - void HandleOnHit(SpellEffIndex /*effIndex*/) - { - GetCaster()->CastSpell(GetHitUnit(), SPELL_DRUID_SUNFIRE_DAMAGE, true); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_dru_sunfire_SpellScript::HandleOnHit, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + GetCaster()->CastSpell(GetHitUnit(), SPELL_DRUID_SUNFIRE_DAMAGE, true); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_dru_sunfire_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_dru_sunfire::HandleOnHit, EFFECT_0, SPELL_EFFECT_DUMMY); } }; @@ -1265,307 +1209,230 @@ class spell_dru_survival_instincts : public AuraScript }; // 40121 - Swift Flight Form (Passive) -class spell_dru_swift_flight_passive : public SpellScriptLoader +class spell_dru_swift_flight_passive : public AuraScript { -public: - spell_dru_swift_flight_passive() : SpellScriptLoader("spell_dru_swift_flight_passive") { } + PrepareAuraScript(spell_dru_swift_flight_passive); - class spell_dru_swift_flight_passive_AuraScript : public AuraScript + bool Load() override { - PrepareAuraScript(spell_dru_swift_flight_passive_AuraScript); - - bool Load() override - { - return GetCaster()->GetTypeId() == TYPEID_PLAYER; - } - - void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) - { - if (Player* caster = GetCaster()->ToPlayer()) - if (caster->GetSkillValue(SKILL_RIDING) >= 375) - amount = 310; - } + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dru_swift_flight_passive_AuraScript::CalculateAmount, EFFECT_1, SPELL_AURA_MOD_INCREASE_VEHICLE_FLIGHT_SPEED); - } - }; + void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) + { + if (Player* caster = GetCaster()->ToPlayer()) + if (caster->GetSkillValue(SKILL_RIDING) >= 375) + amount = 310; + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_dru_swift_flight_passive_AuraScript(); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dru_swift_flight_passive::CalculateAmount, EFFECT_1, SPELL_AURA_MOD_INCREASE_VEHICLE_FLIGHT_SPEED); } }; // 28744 - Regrowth -class spell_dru_t3_6p_bonus : public SpellScriptLoader +class spell_dru_t3_6p_bonus : public AuraScript { - public: - spell_dru_t3_6p_bonus() : SpellScriptLoader("spell_dru_t3_6p_bonus") { } - - class spell_dru_t3_6p_bonus_AuraScript : public AuraScript - { - PrepareAuraScript(spell_dru_t3_6p_bonus_AuraScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_DRUID_BLESSING_OF_THE_CLAW }); - } + PrepareAuraScript(spell_dru_t3_6p_bonus); - void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); - eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_DRUID_BLESSING_OF_THE_CLAW, aurEff); - } + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_DRUID_BLESSING_OF_THE_CLAW }); + } - void Register() override - { - OnEffectProc += AuraEffectProcFn(spell_dru_t3_6p_bonus_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - } - }; + void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + eventInfo.GetActor()->CastSpell(eventInfo.GetProcTarget(), SPELL_DRUID_BLESSING_OF_THE_CLAW, aurEff); + } - AuraScript* GetAuraScript() const override - { - return new spell_dru_t3_6p_bonus_AuraScript(); - } + void Register() override + { + OnEffectProc += AuraEffectProcFn(spell_dru_t3_6p_bonus::HandleProc, EFFECT_0, SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + } }; // 28719 - Healing Touch -class spell_dru_t3_8p_bonus : public SpellScriptLoader +class spell_dru_t3_8p_bonus : public AuraScript { - public: - spell_dru_t3_8p_bonus() : SpellScriptLoader("spell_dru_t3_8p_bonus") { } + PrepareAuraScript(spell_dru_t3_8p_bonus); - class spell_dru_t3_8p_bonus_AuraScript : public AuraScript - { - PrepareAuraScript(spell_dru_t3_8p_bonus_AuraScript); + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_DRUID_EXHILARATE }); + } - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_DRUID_EXHILARATE }); - } + void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + Spell const* spell = eventInfo.GetProcSpell(); + if (!spell) + return; - void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); - Spell const* spell = eventInfo.GetProcSpell(); - if (!spell) - return; - - Unit* caster = eventInfo.GetActor(); - std::vector<SpellPowerCost> const& costs = spell->GetPowerCost(); - auto m = std::find_if(costs.begin(), costs.end(), [](SpellPowerCost const& cost) { return cost.Power == POWER_MANA; }); - if (m == costs.end()) - return; - - int32 amount = CalculatePct(m->Amount, aurEff->GetAmount()); - CastSpellExtraArgs args(aurEff); - args.AddSpellBP0(amount); - caster->CastSpell(nullptr, SPELL_DRUID_EXHILARATE, args); - } + Unit* caster = eventInfo.GetActor(); + std::vector<SpellPowerCost> const& costs = spell->GetPowerCost(); + auto m = std::find_if(costs.begin(), costs.end(), [](SpellPowerCost const& cost) { return cost.Power == POWER_MANA; }); + if (m == costs.end()) + return; - void Register() override - { - OnEffectProc += AuraEffectProcFn(spell_dru_t3_8p_bonus_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); - } - }; + int32 amount = CalculatePct(m->Amount, aurEff->GetAmount()); + CastSpellExtraArgs args(aurEff); + args.AddSpellBP0(amount); + caster->CastSpell(nullptr, SPELL_DRUID_EXHILARATE, args); + } - AuraScript* GetAuraScript() const override - { - return new spell_dru_t3_8p_bonus_AuraScript(); - } + void Register() override + { + OnEffectProc += AuraEffectProcFn(spell_dru_t3_8p_bonus::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); + } }; // 37288 - Mana Restore // 37295 - Mana Restore -class spell_dru_t4_2p_bonus : public SpellScriptLoader +class spell_dru_t4_2p_bonus : public AuraScript { - public: - spell_dru_t4_2p_bonus() : SpellScriptLoader("spell_dru_t4_2p_bonus") { } - - class spell_dru_t4_2p_bonus_AuraScript : public AuraScript - { - PrepareAuraScript(spell_dru_t4_2p_bonus_AuraScript); + PrepareAuraScript(spell_dru_t4_2p_bonus); - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_DRUID_INFUSION }); - } - - void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); - eventInfo.GetActor()->CastSpell(nullptr, SPELL_DRUID_INFUSION, aurEff); - } + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_DRUID_INFUSION }); + } - void Register() override - { - OnEffectProc += AuraEffectProcFn(spell_dru_t4_2p_bonus_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); - } - }; + void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + eventInfo.GetActor()->CastSpell(nullptr, SPELL_DRUID_INFUSION, aurEff); + } - AuraScript* GetAuraScript() const override - { - return new spell_dru_t4_2p_bonus_AuraScript(); - } + void Register() override + { + OnEffectProc += AuraEffectProcFn(spell_dru_t4_2p_bonus::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); + } }; // 70723 - Item - Druid T10 Balance 4P Bonus -class spell_dru_t10_balance_4p_bonus : public SpellScriptLoader +class spell_dru_t10_balance_4p_bonus : public AuraScript { -public: - spell_dru_t10_balance_4p_bonus() : SpellScriptLoader("spell_dru_t10_balance_4p_bonus") { } + PrepareAuraScript(spell_dru_t10_balance_4p_bonus); - class spell_dru_t10_balance_4p_bonus_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_dru_t10_balance_4p_bonus_AuraScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_DRUID_LANGUISH }); - } - - void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); + return ValidateSpellInfo({ SPELL_DRUID_LANGUISH }); + } - DamageInfo* damageInfo = eventInfo.GetDamageInfo(); - if (!damageInfo || !damageInfo->GetDamage()) - return; + void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); - Unit* caster = eventInfo.GetActor(); - Unit* target = eventInfo.GetProcTarget(); + DamageInfo* damageInfo = eventInfo.GetDamageInfo(); + if (!damageInfo || !damageInfo->GetDamage()) + return; - SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(SPELL_DRUID_LANGUISH, GetCastDifficulty()); - int32 amount = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount()); + Unit* caster = eventInfo.GetActor(); + Unit* target = eventInfo.GetProcTarget(); - ASSERT(spellInfo->GetMaxTicks() > 0); - amount /= spellInfo->GetMaxTicks(); + SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(SPELL_DRUID_LANGUISH, GetCastDifficulty()); + int32 amount = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount()); - CastSpellExtraArgs args(aurEff); - args.AddSpellMod(SPELLVALUE_BASE_POINT0, amount); - caster->CastSpell(target, SPELL_DRUID_LANGUISH, args); - } + ASSERT(spellInfo->GetMaxTicks() > 0); + amount /= spellInfo->GetMaxTicks(); - void Register() override - { - OnEffectProc += AuraEffectProcFn(spell_dru_t10_balance_4p_bonus_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); - } - }; + CastSpellExtraArgs args(aurEff); + args.AddSpellMod(SPELLVALUE_BASE_POINT0, amount); + caster->CastSpell(target, SPELL_DRUID_LANGUISH, args); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_dru_t10_balance_4p_bonus_AuraScript(); + OnEffectProc += AuraEffectProcFn(spell_dru_t10_balance_4p_bonus::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); } }; // 70691 - Item T10 Restoration 4P Bonus -class spell_dru_t10_restoration_4p_bonus : public SpellScriptLoader +class spell_dru_t10_restoration_4p_bonus : public SpellScript { -public: - spell_dru_t10_restoration_4p_bonus() : SpellScriptLoader("spell_dru_t10_restoration_4p_bonus") { } + PrepareSpellScript(spell_dru_t10_restoration_4p_bonus); - class spell_dru_t10_restoration_4p_bonus_SpellScript : public SpellScript + bool Load() override { - PrepareSpellScript(spell_dru_t10_restoration_4p_bonus_SpellScript); + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } - bool Load() override + void FilterTargets(std::list<WorldObject*>& targets) + { + if (!GetCaster()->ToPlayer()->GetGroup()) { - return GetCaster()->GetTypeId() == TYPEID_PLAYER; + targets.clear(); + targets.push_back(GetCaster()); } - - void FilterTargets(std::list<WorldObject*>& targets) + else { - if (!GetCaster()->ToPlayer()->GetGroup()) - { - targets.clear(); - targets.push_back(GetCaster()); - } - else + targets.remove(GetExplTargetUnit()); + std::list<Unit*> tempTargets; + for (std::list<WorldObject*>::const_iterator itr = targets.begin(); itr != targets.end(); ++itr) + if ((*itr)->GetTypeId() == TYPEID_PLAYER && GetCaster()->IsInRaidWith((*itr)->ToUnit())) + tempTargets.push_back((*itr)->ToUnit()); + + if (tempTargets.empty()) { - targets.remove(GetExplTargetUnit()); - std::list<Unit*> tempTargets; - for (std::list<WorldObject*>::const_iterator itr = targets.begin(); itr != targets.end(); ++itr) - if ((*itr)->GetTypeId() == TYPEID_PLAYER && GetCaster()->IsInRaidWith((*itr)->ToUnit())) - tempTargets.push_back((*itr)->ToUnit()); - - if (tempTargets.empty()) - { - targets.clear(); - FinishCast(SPELL_FAILED_DONT_REPORT); - return; - } - - Unit* target = Trinity::Containers::SelectRandomContainerElement(tempTargets); targets.clear(); - targets.push_back(target); + FinishCast(SPELL_FAILED_DONT_REPORT); + return; } - } - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_dru_t10_restoration_4p_bonus_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ALLY); + Unit* target = Trinity::Containers::SelectRandomContainerElement(tempTargets); + targets.clear(); + targets.push_back(target); } - }; + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_dru_t10_restoration_4p_bonus_SpellScript(); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_dru_t10_restoration_4p_bonus::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ALLY); } }; // 70664 - Druid T10 Restoration 4P Bonus (Rejuvenation) -class spell_dru_t10_restoration_4p_bonus_dummy : public SpellScriptLoader +class spell_dru_t10_restoration_4p_bonus_dummy : public AuraScript { -public: - spell_dru_t10_restoration_4p_bonus_dummy() : SpellScriptLoader("spell_dru_t10_restoration_4p_bonus_dummy") { } + PrepareAuraScript(spell_dru_t10_restoration_4p_bonus_dummy); - class spell_dru_t10_restoration_4p_bonus_dummy_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_dru_t10_restoration_4p_bonus_dummy_AuraScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_DRUID_REJUVENATION_T10_PROC }); - } - - bool CheckProc(ProcEventInfo& eventInfo) - { - SpellInfo const* spellInfo = eventInfo.GetSpellInfo(); - if (!spellInfo || spellInfo->Id == SPELL_DRUID_REJUVENATION_T10_PROC) - return false; + return ValidateSpellInfo({ SPELL_DRUID_REJUVENATION_T10_PROC }); + } - HealInfo* healInfo = eventInfo.GetHealInfo(); - if (!healInfo || !healInfo->GetHeal()) - return false; + bool CheckProc(ProcEventInfo& eventInfo) + { + SpellInfo const* spellInfo = eventInfo.GetSpellInfo(); + if (!spellInfo || spellInfo->Id == SPELL_DRUID_REJUVENATION_T10_PROC) + return false; - Player* caster = eventInfo.GetActor()->ToPlayer(); - if (!caster) - return false; + HealInfo* healInfo = eventInfo.GetHealInfo(); + if (!healInfo || !healInfo->GetHeal()) + return false; - return caster->GetGroup() || caster != eventInfo.GetProcTarget(); - } + Player* caster = eventInfo.GetActor()->ToPlayer(); + if (!caster) + return false; - void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); + return caster->GetGroup() || caster != eventInfo.GetProcTarget(); + } - CastSpellExtraArgs args(aurEff); - args.AddSpellMod(SPELLVALUE_BASE_POINT0, eventInfo.GetHealInfo()->GetHeal()); - eventInfo.GetActor()->CastSpell(nullptr, SPELL_DRUID_REJUVENATION_T10_PROC, args); - } + void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); - void Register() override - { - DoCheckProc += AuraCheckProcFn(spell_dru_t10_restoration_4p_bonus_dummy_AuraScript::CheckProc); - OnEffectProc += AuraEffectProcFn(spell_dru_t10_restoration_4p_bonus_dummy_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); - } - }; + CastSpellExtraArgs args(aurEff); + args.AddSpellMod(SPELLVALUE_BASE_POINT0, eventInfo.GetHealInfo()->GetHeal()); + eventInfo.GetActor()->CastSpell(nullptr, SPELL_DRUID_REJUVENATION_T10_PROC, args); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_dru_t10_restoration_4p_bonus_dummy_AuraScript(); + DoCheckProc += AuraCheckProcFn(spell_dru_t10_restoration_4p_bonus_dummy::CheckProc); + OnEffectProc += AuraEffectProcFn(spell_dru_t10_restoration_4p_bonus_dummy::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); } }; @@ -1622,70 +1489,57 @@ class spell_dru_thrash_aura : public AuraScript // 33943 - Flight Form // 40120 - Swift Flight Form // 165961 - Stag Form -class spell_dru_travel_form : public SpellScriptLoader +class spell_dru_travel_form : public AuraScript { -public: - spell_dru_travel_form() : SpellScriptLoader("spell_dru_travel_form") { } + PrepareAuraScript(spell_dru_travel_form); - class spell_dru_travel_form_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_dru_travel_form_AuraScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_DRUID_FORM_STAG, SPELL_DRUID_FORM_AQUATIC_PASSIVE, SPELL_DRUID_FORM_AQUATIC, SPELL_DRUID_FORM_FLIGHT, SPELL_DRUID_FORM_SWIFT_FLIGHT }); - } - - bool Load() override - { - return GetCaster()->GetTypeId() == TYPEID_PLAYER; - } - - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - // If it stays 0, it removes Travel Form dummy in AfterRemove. - triggeredSpellId = 0; + return ValidateSpellInfo({ SPELL_DRUID_FORM_STAG, SPELL_DRUID_FORM_AQUATIC_PASSIVE, SPELL_DRUID_FORM_AQUATIC, SPELL_DRUID_FORM_FLIGHT, SPELL_DRUID_FORM_SWIFT_FLIGHT }); + } - // We should only handle aura interrupts. - if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_INTERRUPT) - return; + bool Load() override + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } - // Check what form is appropriate - triggeredSpellId = spell_dru_travel_form::GetFormSpellId(GetTarget()->ToPlayer(), GetCastDifficulty(), true); + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + // If it stays 0, it removes Travel Form dummy in AfterRemove. + triggeredSpellId = 0; - // If chosen form is current aura, just don't remove it. - if (triggeredSpellId == m_scriptSpellId) - PreventDefaultAction(); - } + // We should only handle aura interrupts. + if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_INTERRUPT) + return; - void AfterRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) - { - if (triggeredSpellId == m_scriptSpellId) - return; + // Check what form is appropriate + triggeredSpellId = GetFormSpellId(GetTarget()->ToPlayer(), GetCastDifficulty(), true); - Player* player = GetTarget()->ToPlayer(); + // If chosen form is current aura, just don't remove it. + if (triggeredSpellId == m_scriptSpellId) + PreventDefaultAction(); + } - if (triggeredSpellId) // Apply new form - player->CastSpell(player, triggeredSpellId, aurEff); - else // If not set, simply remove Travel Form dummy - player->RemoveAura(SPELL_DRUID_TRAVEL_FORM); - } + void AfterRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + if (triggeredSpellId == m_scriptSpellId) + return; - void Register() override - { - OnEffectRemove += AuraEffectRemoveFn(spell_dru_travel_form_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_MOD_SHAPESHIFT, AURA_EFFECT_HANDLE_REAL); - AfterEffectRemove += AuraEffectRemoveFn(spell_dru_travel_form_AuraScript::AfterRemove, EFFECT_0, SPELL_AURA_MOD_SHAPESHIFT, AURA_EFFECT_HANDLE_REAL); - } + Player* player = GetTarget()->ToPlayer(); - private: - uint32 triggeredSpellId = 0; - }; + if (triggeredSpellId) // Apply new form + player->CastSpell(player, triggeredSpellId, aurEff); + else // If not set, simply remove Travel Form dummy + player->RemoveAura(SPELL_DRUID_TRAVEL_FORM); + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_dru_travel_form_AuraScript(); + OnEffectRemove += AuraEffectRemoveFn(spell_dru_travel_form::OnRemove, EFFECT_0, SPELL_AURA_MOD_SHAPESHIFT, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_dru_travel_form::AfterRemove, EFFECT_0, SPELL_AURA_MOD_SHAPESHIFT, AURA_EFFECT_HANDLE_REAL); } +public: static uint32 GetFormSpellId(Player const* player, Difficulty difficulty, bool requiresOutdoor) { // Check what form is appropriate @@ -1711,89 +1565,75 @@ private: return spellInfo->CheckLocation(targetPlayer->GetMapId(), targetPlayer->GetZoneId(), targetPlayer->GetAreaId(), targetPlayer); } + + uint32 triggeredSpellId = 0; }; // 783 - Travel Form (dummy) -class spell_dru_travel_form_dummy : public SpellScriptLoader +class spell_dru_travel_form_dummy : public SpellScript { -public: - spell_dru_travel_form_dummy() : SpellScriptLoader("spell_dru_travel_form_dummy") { } + PrepareSpellScript(spell_dru_travel_form_dummy); - class spell_dru_travel_form_dummy_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_dru_travel_form_dummy_SpellScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_DRUID_FORM_AQUATIC_PASSIVE, SPELL_DRUID_FORM_AQUATIC, SPELL_DRUID_FORM_STAG }); - } - - SpellCastResult CheckCast() - { - Player* player = GetCaster()->ToPlayer(); - if (!player) - return SPELL_FAILED_CUSTOM_ERROR; + return ValidateSpellInfo({ SPELL_DRUID_FORM_AQUATIC_PASSIVE, SPELL_DRUID_FORM_AQUATIC, SPELL_DRUID_FORM_STAG }); + } - uint32 spellId = (player->HasSpell(SPELL_DRUID_FORM_AQUATIC_PASSIVE) && player->IsInWater()) ? SPELL_DRUID_FORM_AQUATIC : SPELL_DRUID_FORM_STAG; + SpellCastResult CheckCast() + { + Player* player = GetCaster()->ToPlayer(); + if (!player) + return SPELL_FAILED_CUSTOM_ERROR; - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, GetCastDifficulty()); - return spellInfo->CheckLocation(player->GetMapId(), player->GetZoneId(), player->GetAreaId(), player); - } + uint32 spellId = (player->HasSpell(SPELL_DRUID_FORM_AQUATIC_PASSIVE) && player->IsInWater()) ? SPELL_DRUID_FORM_AQUATIC : SPELL_DRUID_FORM_STAG; - void Register() override - { - OnCheckCast += SpellCheckCastFn(spell_dru_travel_form_dummy_SpellScript::CheckCast); - } - }; + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, GetCastDifficulty()); + return spellInfo->CheckLocation(player->GetMapId(), player->GetZoneId(), player->GetAreaId(), player); + } - class spell_dru_travel_form_dummy_AuraScript : public AuraScript + void Register() override { - PrepareAuraScript(spell_dru_travel_form_dummy_AuraScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_DRUID_FORM_STAG, SPELL_DRUID_FORM_AQUATIC, SPELL_DRUID_FORM_FLIGHT, SPELL_DRUID_FORM_SWIFT_FLIGHT }); - } + OnCheckCast += SpellCheckCastFn(spell_dru_travel_form_dummy::CheckCast); + } +}; - bool Load() override - { - return GetCaster()->GetTypeId() == TYPEID_PLAYER; - } +class spell_dru_travel_form_dummy_aura : public AuraScript +{ + PrepareAuraScript(spell_dru_travel_form_dummy_aura); - void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) - { - Player* player = GetTarget()->ToPlayer(); + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_DRUID_FORM_STAG, SPELL_DRUID_FORM_AQUATIC, SPELL_DRUID_FORM_FLIGHT, SPELL_DRUID_FORM_SWIFT_FLIGHT }); + } - // Outdoor check already passed - Travel Form (dummy) has SPELL_ATTR0_OUTDOORS_ONLY attribute. - uint32 triggeredSpellId = spell_dru_travel_form::GetFormSpellId(player, GetCastDifficulty(), false); + bool Load() override + { + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } - player->CastSpell(player, triggeredSpellId, aurEff); - } + void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + Player* player = GetTarget()->ToPlayer(); - void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - // No need to check remove mode, it's safe for auras to remove each other in AfterRemove hook. - GetTarget()->RemoveAura(SPELL_DRUID_FORM_STAG); - GetTarget()->RemoveAura(SPELL_DRUID_FORM_AQUATIC); - GetTarget()->RemoveAura(SPELL_DRUID_FORM_FLIGHT); - GetTarget()->RemoveAura(SPELL_DRUID_FORM_SWIFT_FLIGHT); - } + // Outdoor check already passed - Travel Form (dummy) has SPELL_ATTR0_OUTDOORS_ONLY attribute. + uint32 triggeredSpellId = spell_dru_travel_form::GetFormSpellId(player, GetCastDifficulty(), false); - void Register() override - { - OnEffectApply += AuraEffectApplyFn(spell_dru_travel_form_dummy_AuraScript::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - AfterEffectRemove += AuraEffectRemoveFn(spell_dru_travel_form_dummy_AuraScript::AfterRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; + player->CastSpell(player, triggeredSpellId, aurEff); + } - SpellScript* GetSpellScript() const override + void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - return new spell_dru_travel_form_dummy_SpellScript(); + // No need to check remove mode, it's safe for auras to remove each other in AfterRemove hook. + GetTarget()->RemoveAura(SPELL_DRUID_FORM_STAG); + GetTarget()->RemoveAura(SPELL_DRUID_FORM_AQUATIC); + GetTarget()->RemoveAura(SPELL_DRUID_FORM_FLIGHT); + GetTarget()->RemoveAura(SPELL_DRUID_FORM_SWIFT_FLIGHT); } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_dru_travel_form_dummy_AuraScript(); + OnEffectApply += AuraEffectApplyFn(spell_dru_travel_form_dummy_aura::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_dru_travel_form_dummy_aura::AfterRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); } }; @@ -1925,27 +1765,27 @@ void AddSC_druid_spell_scripts() RegisterAuraScript(spell_dru_living_seed_proc); RegisterSpellScript(spell_dru_moonfire); RegisterAuraScript(spell_dru_omen_of_clarity); - new spell_dru_predatory_strikes(); + RegisterAuraScript(spell_dru_predatory_strikes); RegisterSpellScript(spell_dru_prowl); - new spell_dru_rip(); + RegisterAuraScript(spell_dru_rip); RegisterSpellAndAuraScriptPair(spell_dru_savage_roar, spell_dru_savage_roar_aura); RegisterSpellScript(spell_dru_skull_bash); - new spell_dru_stampede(); + RegisterAuraScript(spell_dru_stampede); RegisterSpellScript(spell_dru_stampeding_roar); - new spell_dru_starfall_dummy(); - new spell_dru_sunfire(); + RegisterSpellScript(spell_dru_starfall_dummy); + RegisterSpellScript(spell_dru_sunfire); RegisterAuraScript(spell_dru_survival_instincts); - new spell_dru_swift_flight_passive(); - new spell_dru_t3_6p_bonus(); - new spell_dru_t3_8p_bonus(); - new spell_dru_t4_2p_bonus(); - new spell_dru_t10_balance_4p_bonus(); - new spell_dru_t10_restoration_4p_bonus(); - new spell_dru_t10_restoration_4p_bonus_dummy(); + RegisterAuraScript(spell_dru_swift_flight_passive); + RegisterAuraScript(spell_dru_t3_6p_bonus); + RegisterAuraScript(spell_dru_t3_8p_bonus); + RegisterAuraScript(spell_dru_t4_2p_bonus); + RegisterAuraScript(spell_dru_t10_balance_4p_bonus); + RegisterSpellScript(spell_dru_t10_restoration_4p_bonus); + RegisterAuraScript(spell_dru_t10_restoration_4p_bonus_dummy); RegisterSpellScript(spell_dru_thrash); RegisterAuraScript(spell_dru_thrash_aura); - new spell_dru_travel_form(); - new spell_dru_travel_form_dummy(); + RegisterAuraScript(spell_dru_travel_form); + RegisterSpellAndAuraScriptPair(spell_dru_travel_form_dummy, spell_dru_travel_form_dummy_aura); RegisterSpellAndAuraScriptPair(spell_dru_tiger_dash, spell_dru_tiger_dash_aura); RegisterSpellAndAuraScriptPair(spell_dru_wild_growth, spell_dru_wild_growth_aura); } |