diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp index 4fe7831ca..7b58718db 100644 --- a/src/server/scripts/Spells/spell_paladin.cpp +++ b/src/server/scripts/Spells/spell_paladin.cpp @@ -88,695 +88,144 @@ enum PaladinSpellIcons PALADIN_ICON_ID_RETRIBUTION_AURA = 555 }; -// Ours -class spell_pal_seal_of_command : public SpellScriptLoader +class spell_pal_seal_of_command_aura : public AuraScript { -public: - spell_pal_seal_of_command() : SpellScriptLoader("spell_pal_seal_of_command") { } + PrepareAuraScript(spell_pal_seal_of_command_aura); - class spell_pal_seal_of_command_AuraScript : public AuraScript + bool CheckProc(ProcEventInfo& eventInfo) { - PrepareAuraScript(spell_pal_seal_of_command_AuraScript); - - bool CheckProc(ProcEventInfo& eventInfo) + if (const SpellInfo* procSpell = eventInfo.GetSpellInfo()) { - if (const SpellInfo* procSpell = eventInfo.GetSpellInfo()) + if (procSpell->SpellIconID == 3025) // Righteous Vengeance, should not proc SoC { - if (procSpell->SpellIconID == 3025) // Righteous Vengeance, should not proc SoC - { - return false; - } - } - - return true; - } - - void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); - int32 targets = 3; - if (const SpellInfo* procSpell = eventInfo.GetSpellInfo()) - { - if (procSpell->IsAffectingArea()) - { - targets = 1; - } - } - - if (Unit* target = eventInfo.GetActionTarget()) - { - if (target->IsAlive()) - { - eventInfo.GetActor()->CastCustomSpell(aurEff->GetSpellInfo()->Effects[EFFECT_0].TriggerSpell, SPELLVALUE_MAX_TARGETS, targets, target, false, nullptr, aurEff); - } + return false; } } - void Register() override - { - if (m_scriptSpellId == 20375) - { - DoCheckProc += AuraCheckProcFn(spell_pal_seal_of_command_AuraScript::CheckProc); - OnEffectProc += AuraEffectProcFn(spell_pal_seal_of_command_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); - } - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_pal_seal_of_command_AuraScript(); + return true; } - class spell_pal_seal_of_command_SpellScript : public SpellScript + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) { - PrepareSpellScript(spell_pal_seal_of_command_SpellScript); - - void FilterTargets(std::list& targets) + PreventDefaultAction(); + int32 targets = 3; + if (const SpellInfo* procSpell = eventInfo.GetSpellInfo()) { - if (const SpellValue* spellValue = GetSpellValue()) - if (spellValue->MaxAffectedTargets == 1) - targets.clear(); + if (procSpell->IsAffectingArea()) + { + targets = 1; + } } - void Register() override + if (Unit* target = eventInfo.GetActionTarget()) { - if (m_scriptSpellId == 20424) - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_pal_seal_of_command_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_TARGET_ENEMY); + if (target->IsAlive()) + { + eventInfo.GetActor()->CastCustomSpell(aurEff->GetSpellInfo()->Effects[EFFECT_0].TriggerSpell, SPELLVALUE_MAX_TARGETS, targets, target, false, nullptr, aurEff); + } } - }; + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_pal_seal_of_command_SpellScript(); + if (m_scriptSpellId == 20375) + { + DoCheckProc += AuraCheckProcFn(spell_pal_seal_of_command_aura::CheckProc); + OnEffectProc += AuraEffectProcFn(spell_pal_seal_of_command_aura::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); + } } }; -class spell_pal_divine_intervention : public SpellScriptLoader +class spell_pal_seal_of_command : public SpellScript { -public: - spell_pal_divine_intervention() : SpellScriptLoader("spell_pal_divine_intervention") { } + PrepareSpellScript(spell_pal_seal_of_command); - class spell_pal_divine_intervention_AuraScript : public AuraScript + void FilterTargets(std::list& targets) { - PrepareAuraScript(spell_pal_divine_intervention_AuraScript); + if (const SpellValue* spellValue = GetSpellValue()) + if (spellValue->MaxAffectedTargets == 1) + targets.clear(); + } - void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (!GetTarget()->IsInCombat() && GetTarget()->GetTypeId() == TYPEID_PLAYER) - GetTarget()->RemoveAurasDueToSpell(GetTarget()->ToPlayer()->GetTeamId() == TEAM_ALLIANCE ? 57723 : 57724); - } - - void Register() override - { - OnEffectRemove += AuraEffectRemoveFn(spell_pal_divine_intervention_AuraScript::HandleRemove, EFFECT_0, SPELL_AURA_SCHOOL_IMMUNITY, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_pal_divine_intervention_AuraScript(); + if (m_scriptSpellId == 20424) + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_pal_seal_of_command::FilterTargets, EFFECT_0, TARGET_UNIT_TARGET_ENEMY); } }; -class spell_pal_seal_of_light : public SpellScriptLoader +class spell_pal_divine_intervention : public AuraScript { -public: - spell_pal_seal_of_light() : SpellScriptLoader("spell_pal_seal_of_light") { } + PrepareAuraScript(spell_pal_divine_intervention); - class spell_pal_seal_of_light_AuraScript : public AuraScript + void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - PrepareAuraScript(spell_pal_seal_of_light_AuraScript); + if (!GetTarget()->IsInCombat() && GetTarget()->GetTypeId() == TYPEID_PLAYER) + GetTarget()->RemoveAurasDueToSpell(GetTarget()->ToPlayer()->GetTeamId() == TEAM_ALLIANCE ? 57723 : 57724); + } - bool CheckProc(ProcEventInfo& eventInfo) - { - // xinef: skip divine storm self hit (dummy) and righteous vengeance (0x20000000= - return eventInfo.GetActor() != eventInfo.GetProcTarget() && (!eventInfo.GetSpellInfo() || !eventInfo.GetSpellInfo()->SpellFamilyFlags.HasFlag(0x20000000)); - } - - void Register() override - { - DoCheckProc += AuraCheckProcFn(spell_pal_seal_of_light_AuraScript::CheckProc); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_pal_seal_of_light_AuraScript(); + OnEffectRemove += AuraEffectRemoveFn(spell_pal_divine_intervention::HandleRemove, EFFECT_0, SPELL_AURA_SCHOOL_IMMUNITY, AURA_EFFECT_HANDLE_REAL); } }; -class spell_pal_sacred_shield_base : public SpellScriptLoader +class spell_pal_seal_of_light : public AuraScript { -public: - spell_pal_sacred_shield_base() : SpellScriptLoader("spell_pal_sacred_shield_base") { } + PrepareAuraScript(spell_pal_seal_of_light); - class spell_pal_sacred_shield_base_AuraScript : public AuraScript + bool CheckProc(ProcEventInfo& eventInfo) { - PrepareAuraScript(spell_pal_sacred_shield_base_AuraScript); + // xinef: skip divine storm self hit (dummy) and righteous vengeance (0x20000000= + return eventInfo.GetActor() != eventInfo.GetProcTarget() && (!eventInfo.GetSpellInfo() || !eventInfo.GetSpellInfo()->SpellFamilyFlags.HasFlag(0x20000000)); + } - void CalculateAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/) + void Register() override + { + DoCheckProc += AuraCheckProcFn(spell_pal_seal_of_light::CheckProc); + } +}; + +class spell_pal_sacred_shield_base : public AuraScript +{ + PrepareAuraScript(spell_pal_sacred_shield_base); + + void CalculateAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/) + { + if (Unit* caster = GetCaster()) { - if (Unit* caster = GetCaster()) + const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell); + amount = spellInfo->Effects[EFFECT_0].CalcValue(); + + // +75.00% from sp bonus + amount += CalculatePct(caster->SpellBaseDamageBonusDone(spellInfo->GetSchoolMask()), 75.0f); + + // Xinef: removed divine guardian because it will affect triggered spell with increased amount + // Arena - Dampening + if (AuraEffect const* dampening = caster->GetAuraEffect(SPELL_GENERIC_ARENA_DAMPENING, EFFECT_0)) { - const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell); - amount = spellInfo->Effects[EFFECT_0].CalcValue(); - - // +75.00% from sp bonus - amount += CalculatePct(caster->SpellBaseDamageBonusDone(spellInfo->GetSchoolMask()), 75.0f); - - // Xinef: removed divine guardian because it will affect triggered spell with increased amount - // Arena - Dampening - if (AuraEffect const* dampening = caster->GetAuraEffect(SPELL_GENERIC_ARENA_DAMPENING, EFFECT_0)) - { - AddPct(amount, dampening->GetAmount()); - } - // Battleground - Dampening - else if (AuraEffect const* dampening2 = caster->GetAuraEffect(SPELL_GENERIC_BATTLEGROUND_DAMPENING, EFFECT_0)) - { - AddPct(amount, dampening2->GetAmount()); - } + AddPct(amount, dampening->GetAmount()); + } + // Battleground - Dampening + else if (AuraEffect const* dampening2 = caster->GetAuraEffect(SPELL_GENERIC_BATTLEGROUND_DAMPENING, EFFECT_0)) + { + AddPct(amount, dampening2->GetAmount()); } } - - bool CheckProc(ProcEventInfo& eventInfo) - { - return !(eventInfo.GetHitMask() & PROC_EX_INTERNAL_HOT) && eventInfo.GetDamageInfo() && eventInfo.GetDamageInfo()->GetDamage() > 0; - } - - void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); - - if (eventInfo.GetTypeMask() & PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_POS) - { - Unit* caster = eventInfo.GetActor(); - - DamageInfo* damageInfo = eventInfo.GetDamageInfo(); - - if (!damageInfo || !damageInfo->GetDamage()) - { - return; - } - - const SpellInfo* procSpell = damageInfo->GetSpellInfo(); - if (!procSpell) - { - return; - } - - if (caster && procSpell->SpellFamilyName == SPELLFAMILY_PALADIN && - procSpell->SpellFamilyFlags.HasFlag(0x40000000) && caster->GetAuraEffect(SPELL_AURA_PROC_TRIGGER_SPELL, SPELLFAMILY_PALADIN, 3021, 0)) // need infusion of light - { - int32 basepoints = int32(float(damageInfo->GetDamage()) / 12.0f); - // Item - Paladin T9 Holy 4P Bonus (Flash of Light) - if (AuraEffect const* aurEffect = caster->GetAuraEffect(67191, EFFECT_0)) - AddPct(basepoints, aurEffect->GetAmount()); - - caster->CastCustomSpell(eventInfo.GetActionTarget(), 66922, &basepoints, nullptr, nullptr, true, 0, aurEff, caster->GetGUID()); - return; - } - - return; - } - - uint32 triggered_spell_id = GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell; - if (eventInfo.GetActionTarget()->HasSpellCooldown(triggered_spell_id)) - return; - - uint32 cooldown = eventInfo.GetProcCooldown(); - int32 basepoints = aurEff->GetAmount(); - - // Item - Paladin T8 Holy 4P Bonus - if (Unit* caster = aurEff->GetCaster()) - if (AuraEffect const* aurEffect = caster->GetAuraEffect(64895, 0)) - cooldown = aurEffect->GetAmount() * IN_MILLISECONDS; - - eventInfo.GetActionTarget()->AddSpellCooldown(triggered_spell_id, 0, cooldown); - eventInfo.GetActionTarget()->CastCustomSpell(eventInfo.GetActionTarget(), triggered_spell_id, &basepoints, nullptr, nullptr, true, nullptr, aurEff, eventInfo.GetActionTarget()->GetGUID()); - } - - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_pal_sacred_shield_base_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_DUMMY); - DoCheckProc += AuraCheckProcFn(spell_pal_sacred_shield_base_AuraScript::CheckProc); - OnEffectProc += AuraEffectProcFn(spell_pal_sacred_shield_base_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_pal_sacred_shield_base_AuraScript(); } -}; -// Theirs -// 31850 - Ardent Defender -class spell_pal_ardent_defender : public SpellScriptLoader -{ -public: - spell_pal_ardent_defender() : SpellScriptLoader("spell_pal_ardent_defender") { } - - class spell_pal_ardent_defender_AuraScript : public AuraScript + bool CheckProc(ProcEventInfo& eventInfo) { - PrepareAuraScript(spell_pal_ardent_defender_AuraScript); - - public: - spell_pal_ardent_defender_AuraScript() - { - absorbPct = 0; - healPct = 0; - } - - private: - uint32 absorbPct, healPct; - - enum Spell - { - PAL_SPELL_ARDENT_DEFENDER_HEAL = 66235 - }; - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ PAL_SPELL_ARDENT_DEFENDER_HEAL }); - } - - bool Load() override - { - healPct = GetSpellInfo()->Effects[EFFECT_1].CalcValue(); - absorbPct = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); - return GetUnitOwner()->GetTypeId() == TYPEID_PLAYER; - } - - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) - { - // Set absorbtion amount to unlimited - amount = -1; - } - - void Absorb(AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount) - { - Unit* victim = GetTarget(); - int32 remainingHealth = victim->GetHealth() - dmgInfo.GetDamage(); - uint32 allowedHealth = victim->CountPctFromMaxHealth(35); - // If damage kills us - if (remainingHealth <= 0 && !victim->ToPlayer()->HasSpellCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL)) - { - // Cast healing spell, completely avoid damage - absorbAmount = dmgInfo.GetDamage(); - - uint32 defenseSkillValue = victim->GetDefenseSkillValue(); - // Max heal when defense skill denies critical hits from raid bosses - // Formula: max defense at level + 140 (raiting from gear) - uint32 reqDefForMaxHeal = victim->getLevel() * 5 + 140; - float pctFromDefense = (defenseSkillValue >= reqDefForMaxHeal) - ? 1.0f - : float(defenseSkillValue) / float(reqDefForMaxHeal); - - int32 healAmount = int32(victim->CountPctFromMaxHealth(uint32(healPct * pctFromDefense))); - victim->CastCustomSpell(PAL_SPELL_ARDENT_DEFENDER_HEAL, SPELLVALUE_BASE_POINT0, healAmount, victim, true, nullptr, aurEff); - victim->ToPlayer()->AddSpellCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL, 0, 120000); - } - else if (remainingHealth < int32(allowedHealth)) - { - // Reduce damage that brings us under 35% (or full damage if we are already under 35%) by x% - uint32 damageToReduce = (victim->GetHealth() < allowedHealth) - ? dmgInfo.GetDamage() - : allowedHealth - remainingHealth; - absorbAmount = CalculatePct(damageToReduce, absorbPct); - } - } - - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_pal_ardent_defender_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB); - OnEffectAbsorb += AuraEffectAbsorbFn(spell_pal_ardent_defender_AuraScript::Absorb, EFFECT_0); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_pal_ardent_defender_AuraScript(); + return !(eventInfo.GetHitMask() & PROC_EX_INTERNAL_HOT) && eventInfo.GetDamageInfo() && eventInfo.GetDamageInfo()->GetDamage() > 0; } -}; -// 31884 - Avenging Wrath -class spell_pal_avenging_wrath : public SpellScriptLoader -{ -public: - spell_pal_avenging_wrath() : SpellScriptLoader("spell_pal_avenging_wrath") { } - - class spell_pal_avenging_wrath_AuraScript : public AuraScript + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) { - PrepareAuraScript(spell_pal_avenging_wrath_AuraScript); + PreventDefaultAction(); - bool Validate(SpellInfo const* /*spellInfo*/) override + if (eventInfo.GetTypeMask() & PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_POS) { - return ValidateSpellInfo({ SPELL_PALADIN_SANCTIFIED_WRATH, SPELL_PALADIN_SANCTIFIED_WRATH_TALENT_R1 }); - } - - void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Unit* target = GetTarget(); - if (AuraEffect const* aurEff = target->GetAuraEffectOfRankedSpell(SPELL_PALADIN_SANCTIFIED_WRATH_TALENT_R1, EFFECT_2)) - { - int32 basepoints = aurEff->GetAmount(); - target->CastCustomSpell(target, SPELL_PALADIN_SANCTIFIED_WRATH, &basepoints, &basepoints, nullptr, true, nullptr, aurEff); - } - } - - void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - GetTarget()->RemoveAurasDueToSpell(SPELL_PALADIN_SANCTIFIED_WRATH); - } - - void Register() override - { - OnEffectApply += AuraEffectApplyFn(spell_pal_avenging_wrath_AuraScript::HandleApply, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL); - AfterEffectRemove += AuraEffectRemoveFn(spell_pal_avenging_wrath_AuraScript::HandleRemove, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_pal_avenging_wrath_AuraScript(); - } -}; - -// 37877 - Blessing of Faith -class spell_pal_blessing_of_faith : public SpellScriptLoader -{ -public: - spell_pal_blessing_of_faith() : SpellScriptLoader("spell_pal_blessing_of_faith") { } - - class spell_pal_blessing_of_faith_SpellScript : public SpellScript - { - PrepareSpellScript(spell_pal_blessing_of_faith_SpellScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo( - { - SPELL_PALADIN_BLESSING_OF_LOWER_CITY_DRUID, - SPELL_PALADIN_BLESSING_OF_LOWER_CITY_PALADIN, - SPELL_PALADIN_BLESSING_OF_LOWER_CITY_PRIEST, - SPELL_PALADIN_BLESSING_OF_LOWER_CITY_SHAMAN - }); - } - - void HandleDummy(SpellEffIndex /*effIndex*/) - { - if (Unit* unitTarget = GetHitUnit()) - { - uint32 spell_id = 0; - switch (unitTarget->getClass()) - { - case CLASS_DRUID: - spell_id = SPELL_PALADIN_BLESSING_OF_LOWER_CITY_DRUID; - break; - case CLASS_PALADIN: - spell_id = SPELL_PALADIN_BLESSING_OF_LOWER_CITY_PALADIN; - break; - case CLASS_PRIEST: - spell_id = SPELL_PALADIN_BLESSING_OF_LOWER_CITY_PRIEST; - break; - case CLASS_SHAMAN: - spell_id = SPELL_PALADIN_BLESSING_OF_LOWER_CITY_SHAMAN; - break; - default: - return; // ignore for non-healing classes - } - Unit* caster = GetCaster(); - caster->CastSpell(caster, spell_id, true); - } - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_pal_blessing_of_faith_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_pal_blessing_of_faith_SpellScript(); - } -}; - -// 20911 - Blessing of Sanctuary -// 25899 - Greater Blessing of Sanctuary -class spell_pal_blessing_of_sanctuary : public SpellScriptLoader -{ -public: - spell_pal_blessing_of_sanctuary() : SpellScriptLoader("spell_pal_blessing_of_sanctuary") { } - - class spell_pal_blessing_of_sanctuary_AuraScript : public AuraScript - { - PrepareAuraScript(spell_pal_blessing_of_sanctuary_AuraScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_PALADIN_BLESSING_OF_SANCTUARY_BUFF, SPELL_PALADIN_BLESSING_OF_SANCTUARY_ENERGIZE }); - } - - void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Unit* target = GetTarget(); - if (Unit* caster = GetCaster()) - { - // xinef: hack - int32 value = 9; - caster->CastCustomSpell(target, SPELL_PALADIN_BLESSING_OF_SANCTUARY_BUFF, &value, &value, 0, true); - } - } - - void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Unit* target = GetTarget(); - target->RemoveAura(SPELL_PALADIN_BLESSING_OF_SANCTUARY_BUFF, GetCasterGUID()); - } - - bool CheckProc(ProcEventInfo& /*eventInfo*/) - { - return GetTarget()->getPowerType() == POWER_MANA; - } - - void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) - { - PreventDefaultAction(); - GetTarget()->CastSpell(GetTarget(), SPELL_PALADIN_BLESSING_OF_SANCTUARY_ENERGIZE, true, nullptr, aurEff); - } - - void Register() override - { - AfterEffectApply += AuraEffectApplyFn(spell_pal_blessing_of_sanctuary_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); - AfterEffectRemove += AuraEffectRemoveFn(spell_pal_blessing_of_sanctuary_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); - DoCheckProc += AuraCheckProcFn(spell_pal_blessing_of_sanctuary_AuraScript::CheckProc); - OnEffectProc += AuraEffectProcFn(spell_pal_blessing_of_sanctuary_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_pal_blessing_of_sanctuary_AuraScript(); - } -}; - -// 64205 - Divine Sacrifice -class spell_pal_divine_sacrifice : public SpellScriptLoader -{ -public: - spell_pal_divine_sacrifice() : SpellScriptLoader("spell_pal_divine_sacrifice") { } - - class spell_pal_divine_sacrifice_AuraScript : public AuraScript - { - PrepareAuraScript(spell_pal_divine_sacrifice_AuraScript); - - uint32 groupSize, minHpPct; - int32 remainingAmount; - - bool Load() override - { - if (Unit* caster = GetCaster()) - { - if (caster->GetTypeId() == TYPEID_PLAYER) - { - if (caster->ToPlayer()->GetGroup()) - groupSize = caster->ToPlayer()->GetGroup()->GetMembersCount(); - else - groupSize = 1; - } - else - return false; - - remainingAmount = (caster->CountPctFromMaxHealth(GetSpellInfo()->Effects[EFFECT_2].CalcValue(caster)) * groupSize); - minHpPct = GetSpellInfo()->Effects[EFFECT_1].CalcValue(caster); - return true; - } - return false; - } - - void Split(AuraEffect* /*aurEff*/, DamageInfo& /*dmgInfo*/, uint32& splitAmount) - { - remainingAmount -= splitAmount; - // break when absorbed everything it could, or if the casters hp drops below 20% - if (Unit* caster = GetCaster()) - if (remainingAmount <= 0 || (caster->GetHealthPct() < minHpPct)) - caster->RemoveAura(SPELL_PALADIN_DIVINE_SACRIFICE); - } - - void Register() override - { - OnEffectSplit += AuraEffectSplitFn(spell_pal_divine_sacrifice_AuraScript::Split, EFFECT_0); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_pal_divine_sacrifice_AuraScript(); - } -}; - -// 53385 - Divine Storm -class spell_pal_divine_storm : public SpellScriptLoader -{ -public: - spell_pal_divine_storm() : SpellScriptLoader("spell_pal_divine_storm") { } - - class spell_pal_divine_storm_SpellScript : public SpellScript - { - PrepareSpellScript(spell_pal_divine_storm_SpellScript); - - uint32 healPct; - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_PALADIN_DIVINE_STORM_DUMMY }); - } - - bool Load() override - { - healPct = GetSpellInfo()->Effects[EFFECT_1].CalcValue(GetCaster()); - return true; - } - - void TriggerHeal() - { - Unit* caster = GetCaster(); - if (GetHitUnit() != caster) - caster->CastCustomSpell(SPELL_PALADIN_DIVINE_STORM_DUMMY, SPELLVALUE_BASE_POINT0, (GetHitDamage() * healPct) / 100, caster, true); - } - - void Register() override - { - AfterHit += SpellHitFn(spell_pal_divine_storm_SpellScript::TriggerHeal); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_pal_divine_storm_SpellScript(); - } -}; - -// 54171 - Divine Storm (Dummy) -class spell_pal_divine_storm_dummy : public SpellScriptLoader -{ -public: - spell_pal_divine_storm_dummy() : SpellScriptLoader("spell_pal_divine_storm_dummy") { } - - class spell_pal_divine_storm_dummy_SpellScript : public SpellScript - { - PrepareSpellScript(spell_pal_divine_storm_dummy_SpellScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_PALADIN_DIVINE_STORM_HEAL }); - } - - void CountTargets(std::list& targetList) - { - Acore::Containers::RandomResize(targetList, GetSpellValue()->MaxAffectedTargets); - _targetCount = targetList.size(); - } - - void HandleDummy(SpellEffIndex /*effIndex*/) - { - if (!_targetCount || ! GetHitUnit()) - return; - - int32 heal = GetEffectValue() / _targetCount; - GetCaster()->CastCustomSpell(GetHitUnit(), SPELL_PALADIN_DIVINE_STORM_HEAL, &heal, nullptr, nullptr, true); - } - private: - uint32 _targetCount; - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_pal_divine_storm_dummy_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_pal_divine_storm_dummy_SpellScript::CountTargets, EFFECT_0, TARGET_UNIT_CASTER_AREA_RAID); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_pal_divine_storm_dummy_SpellScript(); - } -}; - -// 33695 - Exorcism and Holy Wrath Damage -class spell_pal_exorcism_and_holy_wrath_damage : public SpellScriptLoader -{ -public: - spell_pal_exorcism_and_holy_wrath_damage() : SpellScriptLoader("spell_pal_exorcism_and_holy_wrath_damage") { } - - class spell_pal_exorcism_and_holy_wrath_damage_AuraScript : public AuraScript - { - PrepareAuraScript(spell_pal_exorcism_and_holy_wrath_damage_AuraScript); - - void HandleEffectCalcSpellMod(AuraEffect const* aurEff, SpellModifier*& spellMod) - { - if (!spellMod) - { - spellMod = new SpellModifier(aurEff->GetBase()); - spellMod->op = SPELLMOD_DAMAGE; - spellMod->type = SPELLMOD_FLAT; - spellMod->spellId = GetId(); - spellMod->mask[1] = 0x200002; - } - - spellMod->value = aurEff->GetAmount(); - } - - void Register() override - { - DoEffectCalcSpellMod += AuraEffectCalcSpellModFn(spell_pal_exorcism_and_holy_wrath_damage_AuraScript::HandleEffectCalcSpellMod, EFFECT_0, SPELL_AURA_DUMMY); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_pal_exorcism_and_holy_wrath_damage_AuraScript(); - } -}; - -// -9799 - Eye for an Eye -class spell_pal_eye_for_an_eye : public SpellScriptLoader -{ -public: - spell_pal_eye_for_an_eye() : SpellScriptLoader("spell_pal_eye_for_an_eye") { } - - class spell_pal_eye_for_an_eye_AuraScript : public AuraScript - { - PrepareAuraScript(spell_pal_eye_for_an_eye_AuraScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_PALADIN_EYE_FOR_AN_EYE_DAMAGE }); - } - - void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); + Unit* caster = eventInfo.GetActor(); DamageInfo* damageInfo = eventInfo.GetDamageInfo(); @@ -785,319 +234,646 @@ public: return; } - // return damage % to attacker but < 50% own total health - int32 damage = std::min(CalculatePct(static_cast(damageInfo->GetDamage()), aurEff->GetAmount()), static_cast(GetTarget()->GetMaxHealth()) / 2); - GetTarget()->CastCustomSpell(SPELL_PALADIN_EYE_FOR_AN_EYE_DAMAGE, SPELLVALUE_BASE_POINT0, damage, eventInfo.GetProcTarget(), true, nullptr, aurEff); + const SpellInfo* procSpell = damageInfo->GetSpellInfo(); + if (!procSpell) + { + return; + } + + if (caster && procSpell->SpellFamilyName == SPELLFAMILY_PALADIN && + procSpell->SpellFamilyFlags.HasFlag(0x40000000) && caster->GetAuraEffect(SPELL_AURA_PROC_TRIGGER_SPELL, SPELLFAMILY_PALADIN, 3021, 0)) // need infusion of light + { + int32 basepoints = int32(float(damageInfo->GetDamage()) / 12.0f); + // Item - Paladin T9 Holy 4P Bonus (Flash of Light) + if (AuraEffect const* aurEffect = caster->GetAuraEffect(67191, EFFECT_0)) + AddPct(basepoints, aurEffect->GetAmount()); + + caster->CastCustomSpell(eventInfo.GetActionTarget(), 66922, &basepoints, nullptr, nullptr, true, 0, aurEff, caster->GetGUID()); + return; + } + + return; } - void Register() override - { - OnEffectProc += AuraEffectProcFn(spell_pal_eye_for_an_eye_AuraScript::OnProc, EFFECT_0, SPELL_AURA_DUMMY); - } + uint32 triggered_spell_id = GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell; + if (eventInfo.GetActionTarget()->HasSpellCooldown(triggered_spell_id)) + return; + + uint32 cooldown = eventInfo.GetProcCooldown(); + int32 basepoints = aurEff->GetAmount(); + + // Item - Paladin T8 Holy 4P Bonus + if (Unit* caster = aurEff->GetCaster()) + if (AuraEffect const* aurEffect = caster->GetAuraEffect(64895, 0)) + cooldown = aurEffect->GetAmount() * IN_MILLISECONDS; + + eventInfo.GetActionTarget()->AddSpellCooldown(triggered_spell_id, 0, cooldown); + eventInfo.GetActionTarget()->CastCustomSpell(eventInfo.GetActionTarget(), triggered_spell_id, &basepoints, nullptr, nullptr, true, nullptr, aurEff, eventInfo.GetActionTarget()->GetGUID()); + } + + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_pal_sacred_shield_base::CalculateAmount, EFFECT_0, SPELL_AURA_DUMMY); + DoCheckProc += AuraCheckProcFn(spell_pal_sacred_shield_base::CheckProc); + OnEffectProc += AuraEffectProcFn(spell_pal_sacred_shield_base::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); + } +}; + +// 31850 - Ardent Defender +class spell_pal_ardent_defender : public AuraScript +{ + PrepareAuraScript(spell_pal_ardent_defender); + +public: + spell_pal_ardent_defender() + { + absorbPct = 0; + healPct = 0; + } + +private: + uint32 absorbPct, healPct; + + enum Spell + { + PAL_SPELL_ARDENT_DEFENDER_HEAL = 66235 }; - AuraScript* GetAuraScript() const override + bool Validate(SpellInfo const* /*spellInfo*/) override { - return new spell_pal_eye_for_an_eye_AuraScript(); + return ValidateSpellInfo({ PAL_SPELL_ARDENT_DEFENDER_HEAL }); + } + + bool Load() override + { + healPct = GetSpellInfo()->Effects[EFFECT_1].CalcValue(); + absorbPct = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); + return GetUnitOwner()->GetTypeId() == TYPEID_PLAYER; + } + + void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + { + // Set absorbtion amount to unlimited + amount = -1; + } + + void Absorb(AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount) + { + Unit* victim = GetTarget(); + int32 remainingHealth = victim->GetHealth() - dmgInfo.GetDamage(); + uint32 allowedHealth = victim->CountPctFromMaxHealth(35); + // If damage kills us + if (remainingHealth <= 0 && !victim->ToPlayer()->HasSpellCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL)) + { + // Cast healing spell, completely avoid damage + absorbAmount = dmgInfo.GetDamage(); + + uint32 defenseSkillValue = victim->GetDefenseSkillValue(); + // Max heal when defense skill denies critical hits from raid bosses + // Formula: max defense at level + 140 (raiting from gear) + uint32 reqDefForMaxHeal = victim->getLevel() * 5 + 140; + float pctFromDefense = (defenseSkillValue >= reqDefForMaxHeal) + ? 1.0f + : float(defenseSkillValue) / float(reqDefForMaxHeal); + + int32 healAmount = int32(victim->CountPctFromMaxHealth(uint32(healPct * pctFromDefense))); + victim->CastCustomSpell(PAL_SPELL_ARDENT_DEFENDER_HEAL, SPELLVALUE_BASE_POINT0, healAmount, victim, true, nullptr, aurEff); + victim->ToPlayer()->AddSpellCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL, 0, 120000); + } + else if (remainingHealth < int32(allowedHealth)) + { + // Reduce damage that brings us under 35% (or full damage if we are already under 35%) by x% + uint32 damageToReduce = (victim->GetHealth() < allowedHealth) + ? dmgInfo.GetDamage() + : allowedHealth - remainingHealth; + absorbAmount = CalculatePct(damageToReduce, absorbPct); + } + } + + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_pal_ardent_defender::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB); + OnEffectAbsorb += AuraEffectAbsorbFn(spell_pal_ardent_defender::Absorb, EFFECT_0); + } +}; + +// 31884 - Avenging Wrath +class spell_pal_avenging_wrath : public AuraScript +{ + PrepareAuraScript(spell_pal_avenging_wrath); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_PALADIN_SANCTIFIED_WRATH, SPELL_PALADIN_SANCTIFIED_WRATH_TALENT_R1 }); + } + + void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + if (AuraEffect const* aurEff = target->GetAuraEffectOfRankedSpell(SPELL_PALADIN_SANCTIFIED_WRATH_TALENT_R1, EFFECT_2)) + { + int32 basepoints = aurEff->GetAmount(); + target->CastCustomSpell(target, SPELL_PALADIN_SANCTIFIED_WRATH, &basepoints, &basepoints, nullptr, true, nullptr, aurEff); + } + } + + void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + GetTarget()->RemoveAurasDueToSpell(SPELL_PALADIN_SANCTIFIED_WRATH); + } + + void Register() override + { + OnEffectApply += AuraEffectApplyFn(spell_pal_avenging_wrath::HandleApply, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_pal_avenging_wrath::HandleRemove, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL); + } +}; + +// 37877 - Blessing of Faith +class spell_pal_blessing_of_faith : public SpellScript +{ + PrepareSpellScript(spell_pal_blessing_of_faith); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo( + { + SPELL_PALADIN_BLESSING_OF_LOWER_CITY_DRUID, + SPELL_PALADIN_BLESSING_OF_LOWER_CITY_PALADIN, + SPELL_PALADIN_BLESSING_OF_LOWER_CITY_PRIEST, + SPELL_PALADIN_BLESSING_OF_LOWER_CITY_SHAMAN + }); + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + if (Unit* unitTarget = GetHitUnit()) + { + uint32 spell_id = 0; + switch (unitTarget->getClass()) + { + case CLASS_DRUID: + spell_id = SPELL_PALADIN_BLESSING_OF_LOWER_CITY_DRUID; + break; + case CLASS_PALADIN: + spell_id = SPELL_PALADIN_BLESSING_OF_LOWER_CITY_PALADIN; + break; + case CLASS_PRIEST: + spell_id = SPELL_PALADIN_BLESSING_OF_LOWER_CITY_PRIEST; + break; + case CLASS_SHAMAN: + spell_id = SPELL_PALADIN_BLESSING_OF_LOWER_CITY_SHAMAN; + break; + default: + return; // ignore for non-healing classes + } + Unit* caster = GetCaster(); + caster->CastSpell(caster, spell_id, true); + } + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_pal_blessing_of_faith::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } +}; + +// 20911 - Blessing of Sanctuary +// 25899 - Greater Blessing of Sanctuary +class spell_pal_blessing_of_sanctuary : public AuraScript +{ + PrepareAuraScript(spell_pal_blessing_of_sanctuary); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_PALADIN_BLESSING_OF_SANCTUARY_BUFF, SPELL_PALADIN_BLESSING_OF_SANCTUARY_ENERGIZE }); + } + + void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + if (Unit* caster = GetCaster()) + { + // xinef: hack + int32 value = 9; + caster->CastCustomSpell(target, SPELL_PALADIN_BLESSING_OF_SANCTUARY_BUFF, &value, &value, 0, true); + } + } + + void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + target->RemoveAura(SPELL_PALADIN_BLESSING_OF_SANCTUARY_BUFF, GetCasterGUID()); + } + + bool CheckProc(ProcEventInfo& /*eventInfo*/) + { + return GetTarget()->getPowerType() == POWER_MANA; + } + + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) + { + PreventDefaultAction(); + GetTarget()->CastSpell(GetTarget(), SPELL_PALADIN_BLESSING_OF_SANCTUARY_ENERGIZE, true, nullptr, aurEff); + } + + void Register() override + { + AfterEffectApply += AuraEffectApplyFn(spell_pal_blessing_of_sanctuary::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + AfterEffectRemove += AuraEffectRemoveFn(spell_pal_blessing_of_sanctuary::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + DoCheckProc += AuraCheckProcFn(spell_pal_blessing_of_sanctuary::CheckProc); + OnEffectProc += AuraEffectProcFn(spell_pal_blessing_of_sanctuary::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); + } +}; + +// 64205 - Divine Sacrifice +class spell_pal_divine_sacrifice : public AuraScript +{ + PrepareAuraScript(spell_pal_divine_sacrifice); + + uint32 groupSize, minHpPct; + int32 remainingAmount; + + bool Load() override + { + if (Unit* caster = GetCaster()) + { + if (caster->GetTypeId() == TYPEID_PLAYER) + { + if (caster->ToPlayer()->GetGroup()) + groupSize = caster->ToPlayer()->GetGroup()->GetMembersCount(); + else + groupSize = 1; + } + else + return false; + + remainingAmount = (caster->CountPctFromMaxHealth(GetSpellInfo()->Effects[EFFECT_2].CalcValue(caster)) * groupSize); + minHpPct = GetSpellInfo()->Effects[EFFECT_1].CalcValue(caster); + return true; + } + return false; + } + + void Split(AuraEffect* /*aurEff*/, DamageInfo& /*dmgInfo*/, uint32& splitAmount) + { + remainingAmount -= splitAmount; + // break when absorbed everything it could, or if the casters hp drops below 20% + if (Unit* caster = GetCaster()) + if (remainingAmount <= 0 || (caster->GetHealthPct() < minHpPct)) + caster->RemoveAura(SPELL_PALADIN_DIVINE_SACRIFICE); + } + + void Register() override + { + OnEffectSplit += AuraEffectSplitFn(spell_pal_divine_sacrifice::Split, EFFECT_0); + } +}; + +// 53385 - Divine Storm +class spell_pal_divine_storm : public SpellScript +{ + PrepareSpellScript(spell_pal_divine_storm); + + uint32 healPct; + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_PALADIN_DIVINE_STORM_DUMMY }); + } + + bool Load() override + { + healPct = GetSpellInfo()->Effects[EFFECT_1].CalcValue(GetCaster()); + return true; + } + + void TriggerHeal() + { + Unit* caster = GetCaster(); + if (GetHitUnit() != caster) + caster->CastCustomSpell(SPELL_PALADIN_DIVINE_STORM_DUMMY, SPELLVALUE_BASE_POINT0, (GetHitDamage() * healPct) / 100, caster, true); + } + + void Register() override + { + AfterHit += SpellHitFn(spell_pal_divine_storm::TriggerHeal); + } +}; + +// 54171 - Divine Storm (Dummy) +class spell_pal_divine_storm_dummy : public SpellScript +{ + PrepareSpellScript(spell_pal_divine_storm_dummy); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_PALADIN_DIVINE_STORM_HEAL }); + } + + void CountTargets(std::list& targetList) + { + Acore::Containers::RandomResize(targetList, GetSpellValue()->MaxAffectedTargets); + _targetCount = targetList.size(); + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + if (!_targetCount || ! GetHitUnit()) + return; + + int32 heal = GetEffectValue() / _targetCount; + GetCaster()->CastCustomSpell(GetHitUnit(), SPELL_PALADIN_DIVINE_STORM_HEAL, &heal, nullptr, nullptr, true); + } +private: + uint32 _targetCount; + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_pal_divine_storm_dummy::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_pal_divine_storm_dummy::CountTargets, EFFECT_0, TARGET_UNIT_CASTER_AREA_RAID); + } +}; + +// 33695 - Exorcism and Holy Wrath Damage +class spell_pal_exorcism_and_holy_wrath_damage : public AuraScript +{ + PrepareAuraScript(spell_pal_exorcism_and_holy_wrath_damage); + + void HandleEffectCalcSpellMod(AuraEffect const* aurEff, SpellModifier*& spellMod) + { + if (!spellMod) + { + spellMod = new SpellModifier(aurEff->GetBase()); + spellMod->op = SPELLMOD_DAMAGE; + spellMod->type = SPELLMOD_FLAT; + spellMod->spellId = GetId(); + spellMod->mask[1] = 0x200002; + } + + spellMod->value = aurEff->GetAmount(); + } + + void Register() override + { + DoEffectCalcSpellMod += AuraEffectCalcSpellModFn(spell_pal_exorcism_and_holy_wrath_damage::HandleEffectCalcSpellMod, EFFECT_0, SPELL_AURA_DUMMY); + } +}; + +// -9799 - Eye for an Eye +class spell_pal_eye_for_an_eye : public AuraScript +{ + PrepareAuraScript(spell_pal_eye_for_an_eye); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_PALADIN_EYE_FOR_AN_EYE_DAMAGE }); + } + + void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + + DamageInfo* damageInfo = eventInfo.GetDamageInfo(); + + if (!damageInfo || !damageInfo->GetDamage()) + { + return; + } + + // return damage % to attacker but < 50% own total health + int32 damage = std::min(CalculatePct(static_cast(damageInfo->GetDamage()), aurEff->GetAmount()), static_cast(GetTarget()->GetMaxHealth()) / 2); + GetTarget()->CastCustomSpell(SPELL_PALADIN_EYE_FOR_AN_EYE_DAMAGE, SPELLVALUE_BASE_POINT0, damage, eventInfo.GetProcTarget(), true, nullptr, aurEff); + } + + void Register() override + { + OnEffectProc += AuraEffectProcFn(spell_pal_eye_for_an_eye::OnProc, EFFECT_0, SPELL_AURA_DUMMY); } }; // 54968 - Glyph of Holy Light -class spell_pal_glyph_of_holy_light : public SpellScriptLoader +class spell_pal_glyph_of_holy_light : public SpellScript { -public: - spell_pal_glyph_of_holy_light() : SpellScriptLoader("spell_pal_glyph_of_holy_light") { } + PrepareSpellScript(spell_pal_glyph_of_holy_light); - class spell_pal_glyph_of_holy_light_SpellScript : public SpellScript + void FilterTargets(std::list& targets) { - PrepareSpellScript(spell_pal_glyph_of_holy_light_SpellScript); + uint32 const maxTargets = GetSpellInfo()->MaxAffectedTargets; - void FilterTargets(std::list& targets) + if (targets.size() > maxTargets) { - uint32 const maxTargets = GetSpellInfo()->MaxAffectedTargets; - - if (targets.size() > maxTargets) - { - targets.sort(Acore::HealthPctOrderPred()); - targets.resize(maxTargets); - } + targets.sort(Acore::HealthPctOrderPred()); + targets.resize(maxTargets); } + } - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_pal_glyph_of_holy_light_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ALLY); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_pal_glyph_of_holy_light_SpellScript(); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_pal_glyph_of_holy_light::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ALLY); } }; // 63521 - Guarded by The Light -class spell_pal_guarded_by_the_light : public SpellScriptLoader +class spell_pal_guarded_by_the_light : public SpellScript { -public: - spell_pal_guarded_by_the_light() : SpellScriptLoader("spell_pal_guarded_by_the_light") { } + PrepareSpellScript(spell_pal_guarded_by_the_light); - class spell_pal_guarded_by_the_light_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_pal_guarded_by_the_light_SpellScript); + return ValidateSpellInfo({ SPELL_PALADIN_DIVINE_PLEA }); + } - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_PALADIN_DIVINE_PLEA }); - } - - void HandleScriptEffect(SpellEffIndex /*effIndex*/) - { - // Divine Plea - if (Aura* aura = GetCaster()->GetAura(SPELL_PALADIN_DIVINE_PLEA)) - aura->RefreshDuration(); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_pal_guarded_by_the_light_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void HandleScriptEffect(SpellEffIndex /*effIndex*/) { - return new spell_pal_guarded_by_the_light_SpellScript(); + // Divine Plea + if (Aura* aura = GetCaster()->GetAura(SPELL_PALADIN_DIVINE_PLEA)) + aura->RefreshDuration(); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_pal_guarded_by_the_light::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; // 6940 - Hand of Sacrifice -class spell_pal_hand_of_sacrifice : public SpellScriptLoader +class spell_pal_hand_of_sacrifice_aura : public AuraScript { -public: - spell_pal_hand_of_sacrifice() : SpellScriptLoader("spell_pal_hand_of_sacrifice") { } + PrepareAuraScript(spell_pal_hand_of_sacrifice_aura); - class spell_pal_hand_of_sacrifice_AuraScript : public AuraScript + int32 remainingAmount; + + bool Load() override { - PrepareAuraScript(spell_pal_hand_of_sacrifice_AuraScript); - - int32 remainingAmount; - - bool Load() override + if (Unit* caster = GetCaster()) { - if (Unit* caster = GetCaster()) - { - remainingAmount = caster->GetMaxHealth(); - return true; - } - return false; + remainingAmount = caster->GetMaxHealth(); + return true; } - - void Split(AuraEffect* /*aurEff*/, DamageInfo& /*dmgInfo*/, uint32& splitAmount) - { - remainingAmount -= splitAmount; - - if (remainingAmount <= 0) - { - GetTarget()->RemoveAura(SPELL_PALADIN_HAND_OF_SACRIFICE); - } - } - - void Register() override - { - OnEffectSplit += AuraEffectSplitFn(spell_pal_hand_of_sacrifice_AuraScript::Split, EFFECT_0); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_pal_hand_of_sacrifice_AuraScript(); + return false; } - class spell_pal_hand_of_sacrifice_SpellScript : public SpellScript + void Split(AuraEffect* /*aurEff*/, DamageInfo& /*dmgInfo*/, uint32& splitAmount) { - PrepareSpellScript(spell_pal_hand_of_sacrifice_SpellScript); + remainingAmount -= splitAmount; - SpellCastResult CheckTarget() + if (remainingAmount <= 0) { - Unit* target = GetExplTargetUnit(); - if (!target || target->HasAura(SPELL_PALADIN_DIVINE_SACRIFICE)) - return SPELL_FAILED_TARGET_AURASTATE; - - return SPELL_CAST_OK; + GetTarget()->RemoveAura(SPELL_PALADIN_HAND_OF_SACRIFICE); } + } - void Register() override - { - OnCheckCast += SpellCheckCastFn(spell_pal_hand_of_sacrifice_SpellScript::CheckTarget); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_pal_hand_of_sacrifice_SpellScript(); - }; + OnEffectSplit += AuraEffectSplitFn(spell_pal_hand_of_sacrifice_aura::Split, EFFECT_0); + } +}; + +class spell_pal_hand_of_sacrifice : public SpellScript +{ + PrepareSpellScript(spell_pal_hand_of_sacrifice); + + SpellCastResult CheckTarget() + { + Unit* target = GetExplTargetUnit(); + if (!target || target->HasAura(SPELL_PALADIN_DIVINE_SACRIFICE)) + return SPELL_FAILED_TARGET_AURASTATE; + + return SPELL_CAST_OK; + } + + void Register() override + { + OnCheckCast += SpellCheckCastFn(spell_pal_hand_of_sacrifice::CheckTarget); + } }; // 1038 - Hand of Salvation -class spell_pal_hand_of_salvation : public SpellScriptLoader +class spell_pal_hand_of_salvation : public AuraScript { -public: - spell_pal_hand_of_salvation() : SpellScriptLoader("spell_pal_hand_of_salvation") { } + PrepareAuraScript(spell_pal_hand_of_salvation); - class spell_pal_hand_of_salvation_AuraScript : public AuraScript + void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) { - PrepareAuraScript(spell_pal_hand_of_salvation_AuraScript); - - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + if (Unit* caster = GetCaster()) { - if (Unit* caster = GetCaster()) - { - // Glyph of Salvation - if (caster->GetGUID() == GetUnitOwner()->GetGUID()) - if (AuraEffect const* aurEff = caster->GetAuraEffect(SPELL_PALADIN_GLYPH_OF_SALVATION, EFFECT_0)) - amount -= aurEff->GetAmount(); - } + // Glyph of Salvation + if (caster->GetGUID() == GetUnitOwner()->GetGUID()) + if (AuraEffect const* aurEff = caster->GetAuraEffect(SPELL_PALADIN_GLYPH_OF_SALVATION, EFFECT_0)) + amount -= aurEff->GetAmount(); } + } - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_pal_hand_of_salvation_AuraScript::CalculateAmount, EFFECT_1, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_pal_hand_of_salvation_AuraScript(); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_pal_hand_of_salvation::CalculateAmount, EFFECT_1, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); } }; // -20473 - Holy Shock -class spell_pal_holy_shock : public SpellScriptLoader +class spell_pal_holy_shock : public SpellScript { -public: - spell_pal_holy_shock() : SpellScriptLoader("spell_pal_holy_shock") { } + PrepareSpellScript(spell_pal_holy_shock); - class spell_pal_holy_shock_SpellScript : public SpellScript + bool Validate(SpellInfo const* spellInfo) override { - PrepareSpellScript(spell_pal_holy_shock_SpellScript); + SpellInfo const* firstRankSpellInfo = sSpellMgr->GetSpellInfo(SPELL_PALADIN_HOLY_SHOCK_R1); + if (!firstRankSpellInfo) + return false; - bool Validate(SpellInfo const* spellInfo) override + // can't use other spell than holy shock due to spell_ranks dependency + if (!spellInfo->IsRankOf(firstRankSpellInfo)) + return false; + + uint8 rank = spellInfo->GetRank(); + if (!sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_DAMAGE, rank, true) || !sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_HEALING, rank, true)) + return false; + + return true; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + if (Unit* unitTarget = GetHitUnit()) { - SpellInfo const* firstRankSpellInfo = sSpellMgr->GetSpellInfo(SPELL_PALADIN_HOLY_SHOCK_R1); - if (!firstRankSpellInfo) - return false; - - // can't use other spell than holy shock due to spell_ranks dependency - if (!spellInfo->IsRankOf(firstRankSpellInfo)) - return false; - - uint8 rank = spellInfo->GetRank(); - if (!sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_DAMAGE, rank, true) || !sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_HEALING, rank, true)) - return false; - - return true; - } - - void HandleDummy(SpellEffIndex /*effIndex*/) - { - Unit* caster = GetCaster(); - if (Unit* unitTarget = GetHitUnit()) - { - uint8 rank = GetSpellInfo()->GetRank(); - if (caster->IsFriendlyTo(unitTarget)) - caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_HEALING, rank), true); - else - caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_DAMAGE, rank), true); - } - } - - SpellCastResult CheckCast() - { - Unit* caster = GetCaster(); - if (Unit* target = GetExplTargetUnit()) - { - if (!caster->IsFriendlyTo(target)) - { - if (!caster->IsValidAttackTarget(target)) - return SPELL_FAILED_BAD_TARGETS; - - if (!caster->isInFront(target)) - return SPELL_FAILED_UNIT_NOT_INFRONT; - } - } + uint8 rank = GetSpellInfo()->GetRank(); + if (caster->IsFriendlyTo(unitTarget)) + caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_HEALING, rank), true); else - return SPELL_FAILED_BAD_TARGETS; - return SPELL_CAST_OK; + caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_DAMAGE, rank), true); } + } - void Register() override - { - OnCheckCast += SpellCheckCastFn(spell_pal_holy_shock_SpellScript::CheckCast); - OnEffectHitTarget += SpellEffectFn(spell_pal_holy_shock_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; - - SpellScript* GetSpellScript() const override + SpellCastResult CheckCast() { - return new spell_pal_holy_shock_SpellScript(); + Unit* caster = GetCaster(); + if (Unit* target = GetExplTargetUnit()) + { + if (!caster->IsFriendlyTo(target)) + { + if (!caster->IsValidAttackTarget(target)) + return SPELL_FAILED_BAD_TARGETS; + + if (!caster->isInFront(target)) + return SPELL_FAILED_UNIT_NOT_INFRONT; + } + } + else + return SPELL_FAILED_BAD_TARGETS; + return SPELL_CAST_OK; + } + + void Register() override + { + OnCheckCast += SpellCheckCastFn(spell_pal_holy_shock::CheckCast); + OnEffectHitTarget += SpellEffectFn(spell_pal_holy_shock::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; // 53407 - Judgement of Justice // 20271 - Judgement of Light // 53408 - Judgement of Wisdom -class spell_pal_judgement : public SpellScriptLoader +class spell_pal_judgement : public SpellScript { + PrepareSpellScript(spell_pal_judgement); + public: - spell_pal_judgement(char const* scriptName, uint32 spellId) : SpellScriptLoader(scriptName), _spellId(spellId) { } + spell_pal_judgement(uint32 spellId) : SpellScript(), _spellId(spellId) { } - class spell_pal_judgement_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_pal_judgement_SpellScript); + return ValidateSpellInfo({ SPELL_PALADIN_JUDGEMENT_DAMAGE, _spellId }); + } - public: - spell_pal_judgement_SpellScript(uint32 spellId) : SpellScript(), _spellId(spellId) { } - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_PALADIN_JUDGEMENT_DAMAGE, _spellId }); - } - - void HandleScriptEffect(SpellEffIndex /*effIndex*/) - { - uint32 spellId2 = SPELL_PALADIN_JUDGEMENT_DAMAGE; - - // some seals have SPELL_AURA_DUMMY in EFFECT_2 - Unit::AuraEffectList const& auras = GetCaster()->GetAuraEffectsByType(SPELL_AURA_DUMMY); - for (Unit::AuraEffectList::const_iterator i = auras.begin(); i != auras.end(); ++i) - { - if ((*i)->GetSpellInfo()->GetSpellSpecific() == SPELL_SPECIFIC_SEAL && (*i)->GetEffIndex() == EFFECT_2) - if (sSpellMgr->GetSpellInfo((*i)->GetAmount())) - { - spellId2 = (*i)->GetAmount(); - break; - } - } - - GetCaster()->CastSpell(GetHitUnit(), _spellId, true); - GetCaster()->CastSpell(GetHitUnit(), spellId2, true); - - // Judgement of the Just - if (GetCaster()->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_PALADIN, 3015, 0)) - GetCaster()->CastSpell(GetHitUnit(), 68055, true); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_pal_judgement_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - - private: - uint32 const _spellId; - }; - - SpellScript* GetSpellScript() const override + void HandleScriptEffect(SpellEffIndex /*effIndex*/) { - return new spell_pal_judgement_SpellScript(_spellId); + uint32 spellId2 = SPELL_PALADIN_JUDGEMENT_DAMAGE; + + // some seals have SPELL_AURA_DUMMY in EFFECT_2 + Unit::AuraEffectList const& auras = GetCaster()->GetAuraEffectsByType(SPELL_AURA_DUMMY); + for (Unit::AuraEffectList::const_iterator i = auras.begin(); i != auras.end(); ++i) + { + if ((*i)->GetSpellInfo()->GetSpellSpecific() == SPELL_SPECIFIC_SEAL && (*i)->GetEffIndex() == EFFECT_2) + if (sSpellMgr->GetSpellInfo((*i)->GetAmount())) + { + spellId2 = (*i)->GetAmount(); + break; + } + } + + GetCaster()->CastSpell(GetHitUnit(), _spellId, true); + GetCaster()->CastSpell(GetHitUnit(), spellId2, true); + + // Judgement of the Just + if (GetCaster()->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_PALADIN, 3015, 0)) + GetCaster()->CastSpell(GetHitUnit(), 68055, true); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_pal_judgement::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } private: @@ -1105,262 +881,215 @@ private: }; // 20425 - Judgement of Command -class spell_pal_judgement_of_command : public SpellScriptLoader +class spell_pal_judgement_of_command : public SpellScript { -public: - spell_pal_judgement_of_command() : SpellScriptLoader("spell_pal_judgement_of_command") { } + PrepareSpellScript(spell_pal_judgement_of_command); - class spell_pal_judgement_of_command_SpellScript : public SpellScript + void HandleDummy(SpellEffIndex /*effIndex*/) { - PrepareSpellScript(spell_pal_judgement_of_command_SpellScript); + if (Unit* unitTarget = GetHitUnit()) + if (SpellInfo const* spell_proto = sSpellMgr->GetSpellInfo(GetEffectValue())) + GetCaster()->CastSpell(unitTarget, spell_proto, true, nullptr); + } - void HandleDummy(SpellEffIndex /*effIndex*/) - { - if (Unit* unitTarget = GetHitUnit()) - if (SpellInfo const* spell_proto = sSpellMgr->GetSpellInfo(GetEffectValue())) - GetCaster()->CastSpell(unitTarget, spell_proto, true, nullptr); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_pal_judgement_of_command_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_pal_judgement_of_command_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_pal_judgement_of_command::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; // -633 - Lay on Hands -class spell_pal_lay_on_hands : public SpellScriptLoader +class spell_pal_lay_on_hands : public SpellScript { -public: - spell_pal_lay_on_hands() : SpellScriptLoader("spell_pal_lay_on_hands") { } + PrepareSpellScript(spell_pal_lay_on_hands); - class spell_pal_lay_on_hands_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareSpellScript(spell_pal_lay_on_hands_SpellScript); - - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo( - { - SPELL_PALADIN_FORBEARANCE, - SPELL_PALADIN_AVENGING_WRATH_MARKER, - SPELL_PALADIN_IMMUNE_SHIELD_MARKER - }); - } - - bool Load() override - { - _manaAmount = 0; - return true; - } - - SpellCastResult CheckCast() - { - Unit* caster = GetCaster(); - if (Unit* target = GetExplTargetUnit()) - if (caster == target) - if (target->HasAura(SPELL_PALADIN_FORBEARANCE) || target->HasAura(SPELL_PALADIN_AVENGING_WRATH_MARKER) || target->HasAura(SPELL_PALADIN_IMMUNE_SHIELD_MARKER)) - return SPELL_FAILED_TARGET_AURASTATE; - - // Xinef: Glyph of Divinity - if (Unit* target = GetExplTargetUnit()) - if (target->getPowerType() == POWER_MANA) - _manaAmount = target->GetPower(POWER_MANA); - - return SPELL_CAST_OK; - } - - void HandleScript() - { - Unit* caster = GetCaster(); - Unit* target = GetHitUnit(); - if (caster == target) + return ValidateSpellInfo( { - caster->CastSpell(caster, SPELL_PALADIN_FORBEARANCE, true); - caster->CastSpell(caster, SPELL_PALADIN_AVENGING_WRATH_MARKER, true); - caster->CastSpell(caster, SPELL_PALADIN_IMMUNE_SHIELD_MARKER, true); - } - // Xinef: Glyph of Divinity - else if (target && caster->HasAura(54939) && GetSpellInfo()->Id != 633 && _manaAmount > 0) // excluding first rank - { - _manaAmount = target->GetPower(POWER_MANA) - _manaAmount; - if (_manaAmount > 0) - caster->CastCustomSpell(54986 /*Energize*/, SPELLVALUE_BASE_POINT1, _manaAmount, caster, true); - } - } - - void Register() override - { - OnCheckCast += SpellCheckCastFn(spell_pal_lay_on_hands_SpellScript::CheckCast); - AfterHit += SpellHitFn(spell_pal_lay_on_hands_SpellScript::HandleScript); - } - - int32 _manaAmount; - }; - - SpellScript* GetSpellScript() const override - { - return new spell_pal_lay_on_hands_SpellScript(); + SPELL_PALADIN_FORBEARANCE, + SPELL_PALADIN_AVENGING_WRATH_MARKER, + SPELL_PALADIN_IMMUNE_SHIELD_MARKER + }); } + + bool Load() override + { + _manaAmount = 0; + return true; + } + + SpellCastResult CheckCast() + { + Unit* caster = GetCaster(); + if (Unit* target = GetExplTargetUnit()) + if (caster == target) + if (target->HasAura(SPELL_PALADIN_FORBEARANCE) || target->HasAura(SPELL_PALADIN_AVENGING_WRATH_MARKER) || target->HasAura(SPELL_PALADIN_IMMUNE_SHIELD_MARKER)) + return SPELL_FAILED_TARGET_AURASTATE; + + // Xinef: Glyph of Divinity + if (Unit* target = GetExplTargetUnit()) + if (target->getPowerType() == POWER_MANA) + _manaAmount = target->GetPower(POWER_MANA); + + return SPELL_CAST_OK; + } + + void HandleScript() + { + Unit* caster = GetCaster(); + Unit* target = GetHitUnit(); + if (caster == target) + { + caster->CastSpell(caster, SPELL_PALADIN_FORBEARANCE, true); + caster->CastSpell(caster, SPELL_PALADIN_AVENGING_WRATH_MARKER, true); + caster->CastSpell(caster, SPELL_PALADIN_IMMUNE_SHIELD_MARKER, true); + } + // Xinef: Glyph of Divinity + else if (target && caster->HasAura(54939) && GetSpellInfo()->Id != 633 && _manaAmount > 0) // excluding first rank + { + _manaAmount = target->GetPower(POWER_MANA) - _manaAmount; + if (_manaAmount > 0) + caster->CastCustomSpell(54986 /*Energize*/, SPELLVALUE_BASE_POINT1, _manaAmount, caster, true); + } + } + + void Register() override + { + OnCheckCast += SpellCheckCastFn(spell_pal_lay_on_hands::CheckCast); + AfterHit += SpellHitFn(spell_pal_lay_on_hands::HandleScript); + } + + int32 _manaAmount; }; // 31789 - Righteous Defense -class spell_pal_righteous_defense : public SpellScriptLoader +class spell_pal_righteous_defense : public SpellScript { -public: - spell_pal_righteous_defense() : SpellScriptLoader("spell_pal_righteous_defense") { } + PrepareSpellScript(spell_pal_righteous_defense); - class spell_pal_righteous_defense_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_pal_righteous_defense_SpellScript); + return ValidateSpellInfo({ SPELL_PALADIN_RIGHTEOUS_DEFENSE_TAUNT }); + } - bool Validate(SpellInfo const* /*spellInfo*/) override + SpellCastResult CheckCast() + { + Unit* caster = GetCaster(); + if (caster->GetTypeId() != TYPEID_PLAYER) + return SPELL_FAILED_DONT_REPORT; + + if (Unit* target = GetExplTargetUnit()) { - return ValidateSpellInfo({ SPELL_PALADIN_RIGHTEOUS_DEFENSE_TAUNT }); - } - - SpellCastResult CheckCast() - { - Unit* caster = GetCaster(); - if (caster->GetTypeId() != TYPEID_PLAYER) - return SPELL_FAILED_DONT_REPORT; - - if (Unit* target = GetExplTargetUnit()) - { - if (!target->IsFriendlyTo(caster) || target->getAttackers().empty()) - return SPELL_FAILED_BAD_TARGETS; - } - else + if (!target->IsFriendlyTo(caster) || target->getAttackers().empty()) return SPELL_FAILED_BAD_TARGETS; - - return SPELL_CAST_OK; } + else + return SPELL_FAILED_BAD_TARGETS; - void HandleTriggerSpellLaunch(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - } + return SPELL_CAST_OK; + } - void HandleTriggerSpellHit(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (Unit* target = GetHitUnit()) - GetCaster()->CastSpell(target, SPELL_PALADIN_RIGHTEOUS_DEFENSE_TAUNT, true); - } - - void Register() override - { - OnCheckCast += SpellCheckCastFn(spell_pal_righteous_defense_SpellScript::CheckCast); - //! WORKAROUND - //! target select will be executed in hitphase of effect 0 - //! so we must handle trigger spell also in hit phase (default execution in launch phase) - //! see issue #3718 - OnEffectLaunchTarget += SpellEffectFn(spell_pal_righteous_defense_SpellScript::HandleTriggerSpellLaunch, EFFECT_1, SPELL_EFFECT_TRIGGER_SPELL); - OnEffectHitTarget += SpellEffectFn(spell_pal_righteous_defense_SpellScript::HandleTriggerSpellHit, EFFECT_1, SPELL_EFFECT_TRIGGER_SPELL); - } - }; - - SpellScript* GetSpellScript() const override + void HandleTriggerSpellLaunch(SpellEffIndex effIndex) { - return new spell_pal_righteous_defense_SpellScript(); + PreventHitDefaultEffect(effIndex); + } + + void HandleTriggerSpellHit(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + if (Unit* target = GetHitUnit()) + GetCaster()->CastSpell(target, SPELL_PALADIN_RIGHTEOUS_DEFENSE_TAUNT, true); + } + + void Register() override + { + OnCheckCast += SpellCheckCastFn(spell_pal_righteous_defense::CheckCast); + //! WORKAROUND + //! target select will be executed in hitphase of effect 0 + //! so we must handle trigger spell also in hit phase (default execution in launch phase) + //! see issue #3718 + OnEffectLaunchTarget += SpellEffectFn(spell_pal_righteous_defense::HandleTriggerSpellLaunch, EFFECT_1, SPELL_EFFECT_TRIGGER_SPELL); + OnEffectHitTarget += SpellEffectFn(spell_pal_righteous_defense::HandleTriggerSpellHit, EFFECT_1, SPELL_EFFECT_TRIGGER_SPELL); } }; // 20154, 21084 - Seal of Righteousness - melee proc dummy (addition ${$MWS*(0.022*$AP+0.044*$SPH)} damage) -class spell_pal_seal_of_righteousness : public SpellScriptLoader +class spell_pal_seal_of_righteousness : public AuraScript { -public: - spell_pal_seal_of_righteousness() : SpellScriptLoader("spell_pal_seal_of_righteousness") { } + PrepareAuraScript(spell_pal_seal_of_righteousness); - class spell_pal_seal_of_righteousness_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_pal_seal_of_righteousness_AuraScript); + return ValidateSpellInfo({ SPELL_PALADIN_SEAL_OF_RIGHTEOUSNESS }); + } - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_PALADIN_SEAL_OF_RIGHTEOUSNESS }); - } - - bool CheckProc(ProcEventInfo& eventInfo) - { - Unit* target = eventInfo.GetProcTarget(); - if (!target) - return false; - - DamageInfo* damageInfo = eventInfo.GetDamageInfo(); - - if (!damageInfo || !damageInfo->GetDamage()) - { - return false; - } - - return target->IsAlive() && !eventInfo.GetTriggerAuraSpell() && (damageInfo->GetDamage() || (eventInfo.GetHitMask() & PROC_EX_ABSORB)); - } - - void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); - - float ap = GetTarget()->GetTotalAttackPowerValue(BASE_ATTACK); - int32 holy = GetTarget()->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_HOLY); - holy += eventInfo.GetProcTarget()->SpellBaseDamageBonusTaken(SPELL_SCHOOL_MASK_HOLY); - - // Xinef: Libram of Divine Purpose - if (AuraEffect* aurEffPaladin = GetTarget()->GetDummyAuraEffect(SPELLFAMILY_PALADIN, 2025, EFFECT_0)) - { - holy += aurEffPaladin->GetAmount(); - } - - int32 bp = std::max(0, int32((ap * 0.022f + 0.044f * holy) * GetTarget()->GetAttackTime(BASE_ATTACK) / 1000)); - GetTarget()->CastCustomSpell(SPELL_PALADIN_SEAL_OF_RIGHTEOUSNESS, SPELLVALUE_BASE_POINT0, bp, eventInfo.GetProcTarget(), true, nullptr, aurEff); - } - - void Register() override - { - DoCheckProc += AuraCheckProcFn(spell_pal_seal_of_righteousness_AuraScript::CheckProc); - OnEffectProc += AuraEffectProcFn(spell_pal_seal_of_righteousness_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); - } - }; - - AuraScript* GetAuraScript() const override + bool CheckProc(ProcEventInfo& eventInfo) { - return new spell_pal_seal_of_righteousness_AuraScript(); + Unit* target = eventInfo.GetProcTarget(); + if (!target) + return false; + + DamageInfo* damageInfo = eventInfo.GetDamageInfo(); + + if (!damageInfo || !damageInfo->GetDamage()) + { + return false; + } + + return target->IsAlive() && !eventInfo.GetTriggerAuraSpell() && (damageInfo->GetDamage() || (eventInfo.GetHitMask() & PROC_EX_ABSORB)); + } + + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + + float ap = GetTarget()->GetTotalAttackPowerValue(BASE_ATTACK); + int32 holy = GetTarget()->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_HOLY); + holy += eventInfo.GetProcTarget()->SpellBaseDamageBonusTaken(SPELL_SCHOOL_MASK_HOLY); + + // Xinef: Libram of Divine Purpose + if (AuraEffect* aurEffPaladin = GetTarget()->GetDummyAuraEffect(SPELLFAMILY_PALADIN, 2025, EFFECT_0)) + { + holy += aurEffPaladin->GetAmount(); + } + + int32 bp = std::max(0, int32((ap * 0.022f + 0.044f * holy) * GetTarget()->GetAttackTime(BASE_ATTACK) / 1000)); + GetTarget()->CastCustomSpell(SPELL_PALADIN_SEAL_OF_RIGHTEOUSNESS, SPELLVALUE_BASE_POINT0, bp, eventInfo.GetProcTarget(), true, nullptr, aurEff); + } + + void Register() override + { + DoCheckProc += AuraCheckProcFn(spell_pal_seal_of_righteousness::CheckProc); + OnEffectProc += AuraEffectProcFn(spell_pal_seal_of_righteousness::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); } }; void AddSC_paladin_spell_scripts() { - // Ours - new spell_pal_seal_of_command(); - new spell_pal_divine_intervention(); - new spell_pal_seal_of_light(); - new spell_pal_sacred_shield_base(); - - // Theirs - new spell_pal_ardent_defender(); - new spell_pal_avenging_wrath(); - new spell_pal_blessing_of_faith(); - new spell_pal_blessing_of_sanctuary(); - new spell_pal_divine_sacrifice(); - new spell_pal_divine_storm(); - new spell_pal_divine_storm_dummy(); - new spell_pal_exorcism_and_holy_wrath_damage(); - new spell_pal_eye_for_an_eye(); - new spell_pal_glyph_of_holy_light(); - new spell_pal_guarded_by_the_light(); - new spell_pal_hand_of_sacrifice(); - new spell_pal_hand_of_salvation(); - new spell_pal_holy_shock(); - new spell_pal_judgement("spell_pal_judgement_of_justice", SPELL_PALADIN_JUDGEMENT_OF_JUSTICE); - new spell_pal_judgement("spell_pal_judgement_of_light", SPELL_PALADIN_JUDGEMENT_OF_LIGHT); - new spell_pal_judgement("spell_pal_judgement_of_wisdom", SPELL_PALADIN_JUDGEMENT_OF_WISDOM); - new spell_pal_judgement_of_command(); - new spell_pal_lay_on_hands(); - new spell_pal_righteous_defense(); - new spell_pal_seal_of_righteousness(); + RegisterSpellAndAuraScriptPair(spell_pal_seal_of_command, spell_pal_seal_of_command_aura); + RegisterSpellScript(spell_pal_divine_intervention); + RegisterSpellScript(spell_pal_seal_of_light); + RegisterSpellScript(spell_pal_sacred_shield_base); + RegisterSpellScript(spell_pal_ardent_defender); + RegisterSpellScript(spell_pal_avenging_wrath); + RegisterSpellScript(spell_pal_blessing_of_faith); + RegisterSpellScript(spell_pal_blessing_of_sanctuary); + RegisterSpellScript(spell_pal_divine_sacrifice); + RegisterSpellScript(spell_pal_divine_storm); + RegisterSpellScript(spell_pal_divine_storm_dummy); + RegisterSpellScript(spell_pal_exorcism_and_holy_wrath_damage); + RegisterSpellScript(spell_pal_eye_for_an_eye); + RegisterSpellScript(spell_pal_glyph_of_holy_light); + RegisterSpellScript(spell_pal_guarded_by_the_light); + RegisterSpellAndAuraScriptPair(spell_pal_hand_of_sacrifice, spell_pal_hand_of_sacrifice_aura); + RegisterSpellScript(spell_pal_hand_of_salvation); + RegisterSpellScript(spell_pal_holy_shock); + RegisterSpellScriptWithArgs(spell_pal_judgement, "spell_pal_judgement_of_justice", SPELL_PALADIN_JUDGEMENT_OF_JUSTICE); + RegisterSpellScriptWithArgs(spell_pal_judgement, "spell_pal_judgement_of_light", SPELL_PALADIN_JUDGEMENT_OF_LIGHT); + RegisterSpellScriptWithArgs(spell_pal_judgement, "spell_pal_judgement_of_wisdom", SPELL_PALADIN_JUDGEMENT_OF_WISDOM); + RegisterSpellScript(spell_pal_judgement_of_command); + RegisterSpellScript(spell_pal_lay_on_hands); + RegisterSpellScript(spell_pal_righteous_defense); + RegisterSpellScript(spell_pal_seal_of_righteousness); }