Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
spell_paladin.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6/*
7 * Scripts for spells with SPELLFAMILY_PALADIN and SPELLFAMILY_GENERIC spells used by paladin players.
8 * Ordered alphabetically using scriptname.
9 * Scriptnames of files in this file should be prefixed with "spell_pal_".
10 */
11
12#include "Player.h"
13#include "ScriptMgr.h"
14#include "SpellScript.h"
15#include "SpellAuraEffects.h"
16#include "Group.h"
17
49
84
119
154
197
199{
200public:
201 spell_pal_selfless_healer() : SpellScriptLoader("spell_pal_selfless_healer") { }
203 {
205
206 bool Validate(SpellInfo const* /*spellInfo*/) override
207 {
208 if (!sSpellMgr->GetSpellInfo(SPELL_PALADIN_SELFLESS_HEALER_BUFF) ||
210 return false;
211 return true;
212 }
213
214 void HandleEffectStackProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
215 {
217
219 return;
220
222
223 if (GetTarget()->GetAffectingPlayer()->GetTalentSpecialization(SPEC_PALADIN_HOLY))
225 }
230 };
231
232 AuraScript* GetAuraScript() const override
233 {
235 }
236};
237
238
239/*
240// 31850 - Ardent Defender
241class spell_pal_ardent_defender : public SpellScriptLoader
242{
243 public:
244 spell_pal_ardent_defender() : SpellScriptLoader("spell_pal_ardent_defender") { }
245
246 class spell_pal_ardent_defender_AuraScript : public AuraScript
247 {
248 PrepareAuraScript(spell_pal_ardent_defender_AuraScript);
249
250 uint32 absorbPct, healPct;
251
252 enum Spell
253 {
254 PAL_SPELL_ARDENT_DEFENDER_HEAL = 66235,
255 };
256
257 bool Load() override
258 {
259 healPct = GetSpellInfo()->Effects[EFFECT_1].CalcValue();
260 absorbPct = GetSpellInfo()->Effects[EFFECT_0].CalcValue();
261 return GetUnitOwner()->GetTypeId() == TYPEID_PLAYER;
262 }
263
264 void CalculateAmount(AuraEffect const* aurEff, int32 & amount, bool & canBeRecalculated)
265 {
266 // Set absorbtion amount to unlimited
267 amount = -1;
268 }
269
270 void Absorb(AuraEffect* aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount)
271 {
272 Unit* victim = GetTarget();
273 int32 remainingHealth = victim->GetHealth() - dmgInfo.GetDamage();
274 uint32 allowedHealth = victim->CountPctFromMaxHealth(35);
275 // If damage kills us
276 if (remainingHealth <= 0 && !victim->ToPlayer()->HasSpellCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL))
277 {
278 // Cast healing spell, completely avoid damage
279 absorbAmount = dmgInfo.GetDamage();
280
281 uint32 defenseSkillValue = victim->GetDefenseSkillValue();
282 // Max heal when defense skill denies critical hits from raid bosses
283 // Formula: max defense at level + 140 (raiting from gear)
284 uint32 reqDefForMaxHeal = victim->getLevel() * 5 + 140;
285 float pctFromDefense = (defenseSkillValue >= reqDefForMaxHeal)
286 ? 1.0f
287 : float(defenseSkillValue) / float(reqDefForMaxHeal);
288
289 int32 healAmount = int32(victim->CountPctFromMaxHealth(uint32(healPct * pctFromDefense)));
290 victim->CastCustomSpell(victim, PAL_SPELL_ARDENT_DEFENDER_HEAL, &healAmount, NULL, NULL, true, NULL, aurEff);
291 victim->ToPlayer()->AddSpellCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL, 0, time(NULL) + 120);
292 }
293 else if (remainingHealth < int32(allowedHealth))
294 {
295 // Reduce damage that brings us under 35% (or full damage if we are already under 35%) by x%
296 uint32 damageToReduce = (victim->GetHealth() < allowedHealth)
297 ? dmgInfo.GetDamage()
298 : allowedHealth - remainingHealth;
299 absorbAmount = CalculatePct(damageToReduce, absorbPct);
300 }
301 }
302
303 void Register() override
304 {
305 DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_pal_ardent_defender_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB);
306 OnEffectAbsorb += AuraEffectAbsorbFn(spell_pal_ardent_defender_AuraScript::Absorb, EFFECT_0);
307 }
308 };
309
310 AuraScript* GetAuraScript() const override
311 {
312 return new spell_pal_ardent_defender_AuraScript();
313 }
314};
315*/
316
317// 31821 - Aura Mastery
356
357// 64364 - Aura Mastery Immune
359{
360public:
361 spell_pal_aura_mastery_immune() : SpellScriptLoader("spell_pal_aura_mastery_immune") { }
362
364 {
366
367 bool Validate(SpellInfo const* /*spellInfo*/) override
368 {
370 return false;
371 return true;
372 }
373
374 bool CheckAreaTarget(Unit* target)
375 {
377 }
378
383 };
384
385 AuraScript* GetAuraScript() const override
386 {
388 }
389};
390
391// 53651 - Beacon of Light
393{
394public:
395 spell_pal_beacon_of_light() : SpellScriptLoader("spell_pal_beacon_of_light") { }
396
398 {
400
401 bool Validate(SpellInfo const* /*spellInfo*/) override
402 {
404 return false;
405 return true;
406 }
407
408 bool CheckProc(ProcEventInfo& eventInfo)
409 {
411 return false;
412 return true;
413 }
414
415 void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
416 {
418 int32 heal = eventInfo.GetHealInfo()->GetHeal();
419
421 heal = int32(CalculatePct(heal, aurEff->GetAmount()));
422
423 Unit::AuraList const& auras = GetCaster()->GetSingleCastAuras();
424 for (Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
425 {
426 if ((*itr)->GetId() == SPELL_PALADIN_BEACON_OF_LIGHT_MARKER)
427 {
428 std::list<AuraApplication*> applications;
429 (*itr)->GetApplicationList(applications);
430 if (applications.empty())
431 return;
432
433 GetCaster()->CastCustomSpell(SPELL_PALADIN_BEACON_OF_LIGHT_HEAL, SPELLVALUE_BASE_POINT0, heal, applications.front()->GetTarget(), true, NULL, aurEff);
434 return;
435 }
436 }
437 }
438
444 };
445
446 AuraScript* GetAuraScript() const override
447 {
449 }
450};
451
452// 37877 - Blessing of Faith
454{
455public:
456 spell_pal_blessing_of_faith() : SpellScriptLoader("spell_pal_blessing_of_faith") { }
457
459 {
461
462 bool Validate(SpellInfo const* /*spellInfo*/) override
463 {
465 return false;
466 return true;
467 }
468
469 void HandleDummy(SpellEffIndex /*effIndex*/)
470 {
471 if (Unit* unitTarget = GetHitUnit())
472 {
473 uint32 spell_id = 0;
474 switch (unitTarget->getClass())
475 {
476 case CLASS_DRUID:
478 break;
479 case CLASS_PALADIN:
481 break;
482 case CLASS_PRIEST:
484 break;
485 case CLASS_SHAMAN:
487 break;
488 default:
489 return; // ignore for non-healing classes
490 }
491 Unit* caster = GetCaster();
492 caster->CastSpell(caster, spell_id, true);
493 }
494 }
495
500 };
501
502 SpellScript* GetSpellScript() const override
503 {
505 }
506};
507
508// -75806 - Grand Crusader
510{
511public:
512 spell_pal_grand_crusader() : SpellScriptLoader("spell_pal_grand_crusader") { }
513
541
542 AuraScript* GetAuraScript() const override
543 {
545 }
546};
547
548// -9799 - Eye for an Eye
550{
551public:
552 spell_pal_eye_for_an_eye() : SpellScriptLoader("spell_pal_eye_for_an_eye") { }
553
577
578 AuraScript* GetAuraScript() const override
579 {
581 }
582};
583
584// 6940 - Hand of Sacrifice
586{
587public:
588 spell_pal_hand_of_sacrifice() : SpellScriptLoader("spell_pal_hand_of_sacrifice") { }
589
591 {
593
595
596 bool Load() override
597 {
598 if (Unit* caster = GetCaster())
599 {
600 remainingAmount = caster->GetMaxHealth();
601 return true;
602 }
603 return false;
604 }
605
606 void Split(AuraEffect* /*aurEff*/, DamageInfo& /*dmgInfo*/, uint32& splitAmount)
607 {
608 remainingAmount -= splitAmount;
609
610 if (remainingAmount <= 0)
611 {
613 }
614 }
615
620 };
621
622 AuraScript* GetAuraScript() const override
623 {
625 }
626};
627
628// 20473 - Holy Shock
630{
631public:
632 spell_pal_holy_shock() : SpellScriptLoader("spell_pal_holy_shock") { }
633
635 {
637
638 bool Validate(SpellInfo const* spellInfo) override
639 {
640 SpellInfo const* firstRankSpellInfo = sSpellMgr->GetSpellInfo(SPELL_PALADIN_HOLY_SHOCK_R1);
641 if (!firstRankSpellInfo)
642 return false;
643
644 // can't use other spell than holy shock due to spell_ranks dependency
645 if (!spellInfo->IsRankOf(firstRankSpellInfo))
646 return false;
647
648 uint8 rank = spellInfo->GetRank();
649 if (!sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_DAMAGE, rank, true) || !sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_HEALING, rank, true))
650 return false;
651
652 return true;
653 }
654
655 void HandleDummy(SpellEffIndex /*effIndex*/)
656 {
657 Unit* caster = GetCaster();
658 if (Unit* unitTarget = GetHitUnit())
659 {
660 uint8 rank = GetSpellInfo()->GetRank();
661 if (caster->IsFriendlyTo(unitTarget))
662 caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_HEALING, rank), true);
663 else
664 caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(SPELL_PALADIN_HOLY_SHOCK_R1_DAMAGE, rank), true);
665 }
666 }
667
669 {
670 Unit* caster = GetCaster();
671 if (Unit* target = GetExplTargetUnit())
672 {
673 if (!caster->IsFriendlyTo(target))
674 {
675 if (!caster->IsValidAttackTarget(target))
677
678 if (!caster->isInFront(target))
680 }
681 }
682 else
685 }
686
692 };
693
694 SpellScript* GetSpellScript() const override
695 {
697 }
698};
699
700// 37705 - Healing Discount
702{
703public:
704 spell_pal_item_healing_discount() : SpellScriptLoader("spell_pal_item_healing_discount") { }
705
707 {
709
710 bool Validate(SpellInfo const* /*spellInfo*/) override
711 {
713 return false;
714 return true;
715 }
716
717 void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
718 {
721 }
722
727 };
728
729 AuraScript* GetAuraScript() const override
730 {
732 }
733};
734
735// 31789 - Righteous Defense
737{
738public:
739 spell_pal_righteous_defense() : SpellScriptLoader("spell_pal_righteous_defense") { }
740
742 {
744
745 bool Validate(SpellInfo const* /*spellInfo*/) override
746 {
748 return false;
749 return true;
750 }
751
753 {
754 Unit* caster = GetCaster();
755 if (caster->GetTypeId() != TypeID::TYPEID_PLAYER)
757
758 if (Unit* target = GetExplTargetUnit())
759 {
760 if (!target->IsFriendlyTo(caster) || target->getAttackers().empty())
762 }
763 else
765
767 }
768
770 {
771 PreventHitDefaultEffect(effIndex);
772 }
773
775 {
776 PreventHitDefaultEffect(effIndex);
777 if (Unit* target = GetHitUnit())
779 }
780
791 };
792
793 SpellScript* GetSpellScript() const override
794 {
796 }
797};
798
799// 85285 - Sacred Shield
832
833// 85256 - Templar's Verdict
836{
837public:
838 spell_pal_templar_s_verdict() : SpellScriptLoader("spell_pal_templar_s_verdict") { }
839
841 {
843
844 bool Validate(SpellInfo const* /*spellEntry*/) override
845 {
847 return false;
848
849 return true;
850 }
851
852 bool Load() override
853 {
854 if (GetCaster()->GetTypeId() != TypeID::TYPEID_PLAYER)
855 return false;
856
857 if (GetCaster()->ToPlayer()->getClass() != CLASS_PALADIN)
858 return false;
859
860 return true;
861 }
862
863 void ChangeDamage(SpellEffIndex /*effIndex*/)
864 {
865 Unit* caster = GetCaster();
866 int32 damage = GetHitDamage();
867
869 damage *= 7.5; // 7.5*30% = 225%
870 else
871 {
872 switch (caster->GetPower(POWER_HOLY_POWER))
873 {
874 case 0: // 1 Holy Power
875 damage = damage;
876 break;
877 case 1: // 2 Holy Power
878 damage *= 3; // 3*30 = 90%
879 break;
880 case 2: // 3 Holy Power
881 damage *= 7.5; // 7.5*30% = 225%
882 break;
883 }
884 }
885
886 SetHitDamage(damage);
887 }
888
893 };
894
895 SpellScript* GetSpellScript() const override
896 {
898 }
899};
900
901// 20154, 21084 - Seal of Righteousness - melee proc dummy (addition ${$MWS*(0.022*$AP+0.044*$SPH)} damage)
903{
904public:
905 spell_pal_seal_of_righteousness() : SpellScriptLoader("spell_pal_seal_of_righteousness") { }
906
940
941 AuraScript* GetAuraScript() const override
942 {
944 }
945};
946
947
std::int32_t int32
Definition Define.h:73
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
@ TYPEID_PLAYER
Definition Object.h:55
@ SPEC_PALADIN_HOLY
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ POWER_HOLY_POWER
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_HEAL
@ SPELL_EFFECT_TRIGGER_SPELL
@ SPELL_EFFECT_WEAPON_PERCENT_DAMAGE
@ SPELL_EFFECT_SCHOOL_DAMAGE
@ CLASS_DRUID
@ CLASS_SHAMAN
@ CLASS_PRIEST
@ CLASS_PALADIN
@ SPELL_SCHOOL_MASK_HOLY
SpellCastResult
@ SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW
@ SPELL_AURA_ADD_PCT_MODIFIER
@ SPELL_AURA_PROC_TRIGGER_SPELL
@ SPELL_AURA_DUMMY
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
#define sSpellMgr
Definition SpellMgr.h:744
#define SpellCheckCastFn(F)
#define AuraEffectProcFn(F, I, N)
#define SpellEffectFn(F, I, N)
#define AuraEffectApplyFn(F, I, N, M)
#define AuraEffectSplitFn(F, I)
#define AuraCheckProcFn(F)
#define AuraCheckAreaTargetFn(F)
#define AuraEffectRemoveFn(F, I, N, M)
@ SPELLVALUE_BASE_POINT0
Definition Unit.h:114
T CalculatePct(T base, U pct)
Definition Util.h:103
uint32 m_scriptSpellId
Definition SpellScript.h:95
int32 GetAmount() const
void PreventDefaultAction()
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectApplyHandler > AfterEffectApply
uint64 GetCasterGUID() const
Unit * GetCaster() const
HookList< CheckAreaTargetHandler > DoCheckAreaTarget
Unit * GetTarget() const
HookList< CheckProcHandler > DoCheckProc
HookList< EffectProcHandler > OnEffectProc
HookList< EffectSplitHandler > OnEffectSplit
SpellInfo const * GetSpellInfo() const
Definition Unit.h:907
uint32 GetDamage() const
Definition Unit.h:923
uint32 GetHeal() const
Definition Unit.h:959
Player * ToPlayer()
Definition Object.h:204
TypeID GetTypeId() const
Definition Object.h:131
void RemoveSpellCooldown(uint32 spell_id, bool update=false)
Definition Player.cpp:4284
HealInfo * GetHealInfo() const
Definition Unit.h:986
Unit * GetActionTarget() const
Definition Unit.h:973
DamageInfo * GetDamageInfo() const
Definition Unit.h:985
Unit * GetProcTarget() const
Definition Unit.h:974
bool IsRankOf(SpellInfo const *spellInfo) const
uint32 Id
Definition SpellInfo.h:160
uint8 GetRank() const
Unit * GetExplTargetUnit()
HookList< CheckCastHandler > OnCheckCast
SpellInfo const * GetSpellInfo()
void PreventHitDefaultEffect(SpellEffIndex effIndex)
HookList< EffectHandler > OnEffectHitTarget
Unit * GetHitUnit()
HookList< EffectHandler > OnEffectLaunchTarget
void SetHitDamage(int32 damage)
Unit * GetCaster()
int32 GetHitDamage()
SpellScriptLoader(const char *name)
Definition Unit.h:1367
void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
bool IsValidAttackTarget(Unit const *target) const
Definition Unit.cpp:3810
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
std::list< Aura * > AuraList
Definition Unit.h:1384
Aura * GetAura(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
bool HasAura(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
bool HealthBelowPct(int32 pct) const
Definition Unit.h:1613
int32 SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask) const
Definition Unit.cpp:3099
int32 GetPower(Powers power) const
Definition Unit.cpp:5237
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
bool IsFriendlyTo(Unit const *unit) const
Definition Unit.cpp:2283
AuraList & GetSingleCastAuras()
Definition Unit.h:2247
int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) const
Definition Unit.cpp:3055
float GetTotalAttackPowerValue(WeaponAttackType attType) const
Definition Unit.cpp:5118
bool isInFront(WorldObject const *target, float arc=M_PI) const
Definition Object.cpp:1940
PrepareAuraScript(spell_pal_aura_mastery_AuraScript)
void HandleEffectRemove(AuraEffect const *, AuraEffectHandleModes)
void HandleEffectApply(AuraEffect const *, AuraEffectHandleModes)
AuraScript * GetAuraScript() const override
AuraScript * GetAuraScript() const override
void HandleProc(AuraEffect const *aurEff, ProcEventInfo &eventInfo)
PrepareAuraScript(spell_pal_beacon_of_light_AuraScript)
AuraScript * GetAuraScript() const override
PrepareSpellScript(spell_pal_blessing_of_faith_SpellScript)
SpellScript * GetSpellScript() const override
PrepareSpellScript(spell_pal_divine_light_SpellScript)
SpellScript * GetSpellScript() const override
void HandleEffectProc(AuraEffect const *aurEff, ProcEventInfo &eventInfo)
PrepareAuraScript(spell_pal_eye_for_an_eye_AuraScript)
AuraScript * GetAuraScript() const override
PrepareSpellScript(spell_pal_flash_of_light_SpellScript)
SpellScript * GetSpellScript() const override
void HandleEffectProc(AuraEffect const *, ProcEventInfo &)
PrepareAuraScript(spell_pal_grand_crusader_AuraScript)
AuraScript * GetAuraScript() const override
void Split(AuraEffect *, DamageInfo &, uint32 &splitAmount)
AuraScript * GetAuraScript() const override
PrepareSpellScript(spell_pal_holy_radiance_SpellScript)
SpellScript * GetSpellScript() const override
bool Validate(SpellInfo const *spellInfo) override
PrepareSpellScript(spell_pal_holy_shock_SpellScript)
SpellScript * GetSpellScript() const override
AuraScript * GetAuraScript() const override
PrepareSpellScript(spell_pal_judgment_SpellScript)
SpellScript * GetSpellScript() const override
PrepareSpellScript(spell_pal_righteous_defense_SpellScript)
SpellScript * GetSpellScript() const override
PrepareSpellScript(spell_pal_sacred_shield_SpellScript)
SpellScript * GetSpellScript() const override
void HandleProc(AuraEffect const *aurEff, ProcEventInfo &eventInfo)
AuraScript * GetAuraScript() const override
PrepareAuraScript(spell_pal_selfless_healer_AuraScript)
void HandleEffectStackProc(AuraEffect const *aurEff, ProcEventInfo &eventInfo)
AuraScript * GetAuraScript() const override
PrepareSpellScript(spell_pal_templar_s_verdict_SpellScript)
SpellScript * GetSpellScript() const override
PaladinSpells
@ SPELL_PALADIN_HOLY_SHOCK_R1_DAMAGE
@ SPELL_PALADIN_AURA_MASTERY_IMMUNE
@ SPELL_PALADIN_BEACON_OF_LIGHT_MARKER
@ SPELL_PALADIN_HOLY_SHOCK_R1_HEALING
@ SPELL_PALADIN_LONG_ARM_OF_THE_LAW_SPEEDBUFF
@ SPELL_PALADIN_LONG_ARM_OF_THE_LAW_TALENT
@ SPELL_PALADIN_SELFLESS_HEALER_CHECKER
@ SPELL_PALADIN_EYE_FOR_AN_EYE_DAMAGE
@ SPELL_PALADIN_BEACON_OF_LIGHT_HEAL
@ SPELL_PALADIN_SELFLESS_HEALER_ENERGIZE
@ SPELL_PALADIN_BLESSING_OF_LOWER_CITY_SHAMAN
@ SPELL_PALADIN_SELFLESS_HEALER_BUFF
@ SPELL_PALADIN_SEAL_OF_RIGHTEOUSNESS
@ SPELL_PALADIN_EYE_FOR_AN_EYE_RANK_1
@ SPELL_PALADIN_BLESSING_OF_LOWER_CITY_PALADIN
@ SPELL_PALADIN_BLESSING_OF_LOWER_CITY_DRUID
@ SPELL_PALADIN_RIGHTEOUS_DEFENSE_TAUNT
@ SPELL_PALADIN_CONCENTRACTION_AURA
@ SPELL_PALADIN_SELFLESS_HEALER_TALENT
@ SPELL_PALADIN_HAND_OF_SACRIFICE
@ SPELL_PALADIN_AVENGERS_SHIELD
@ SPELL_PALADIN_ITEM_HEALING_TRANCE
@ SPELL_PALADIN_BLESSING_OF_LOWER_CITY_PRIEST
@ SPELL_PALADIN_DIVINE_PURPOSE_PROC
@ SPELL_PALADIN_HOLY_LIGHT
@ SPELL_PALADIN_HOLY_SHOCK_R1
void AddSC_paladin_spell_scripts()