AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
spell_pal_ardent_defender Class Reference
Inheritance diagram for spell_pal_ardent_defender:
AuraScript _SpellScript

Public Member Functions

 spell_pal_ardent_defender ()
 
- Public Member Functions inherited from AuraScript
 AuraScript ()
 
bool _Validate (SpellInfo const *entry) override
 
bool _Load (Aura *aura)
 
void _PrepareScriptCall (AuraScriptHookType hookType, AuraApplication const *aurApp=nullptr)
 
void _FinishScriptCall ()
 
bool _IsDefaultActionPrevented ()
 
void PreventDefaultAction ()
 
SpellInfo const * GetSpellInfo () const
 
uint32 GetId () const
 
ObjectGuid GetCasterGUID () const
 
UnitGetCaster () const
 
WorldObjectGetOwner () const
 
UnitGetUnitOwner () const
 
DynamicObjectGetDynobjOwner () const
 
void Remove (uint32 removeMode=0)
 
AuraGetAura () const
 
AuraObjectType GetType () const
 
int32 GetDuration () const
 
void SetDuration (int32 duration, bool withMods=false)
 
void RefreshDuration ()
 
time_t GetApplyTime () const
 
int32 GetMaxDuration () const
 
void SetMaxDuration (int32 duration)
 
int32 CalcMaxDuration () const
 
bool IsExpired () const
 
bool IsPermanent () const
 
uint8 GetCharges () const
 
void SetCharges (uint8 charges)
 
uint8 CalcMaxCharges () const
 
bool ModCharges (int8 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
bool DropCharge (AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
uint8 GetStackAmount () const
 
void SetStackAmount (uint8 num)
 
bool ModStackAmount (int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
bool IsPassive () const
 
bool IsDeathPersistent () const
 
bool HasEffect (uint8 effIndex) const
 
AuraEffectGetEffect (uint8 effIndex) const
 
bool HasEffectType (AuraType type) const
 
UnitGetTarget () const
 
AuraApplication const * GetTargetApplication () const
 
- Public Member Functions inherited from _SpellScript
 _SpellScript ()
 
virtual ~_SpellScript ()
 
virtual void _Register ()
 
virtual void _Unload ()
 
virtual void _Init (std::string const *scriptname, uint32 spellId)
 
std::string const * _GetScriptName () const
 
virtual void Register ()=0
 
virtual bool Validate (SpellInfo const *)
 
virtual bool Load ()
 
virtual void Unload ()
 

Private Types

enum  Spell {
  PAL_SPELL_ARDENT_DEFENDER_DEBUFF = 66233 ,
  PAL_SPELL_ARDENT_DEFENDER_HEAL = 66235
}
 

Private Member Functions

 PrepareAuraScript (spell_pal_ardent_defender)
 
bool Validate (SpellInfo const *) override
 
bool Load () override
 
void CalculateAmount (AuraEffect const *, int32 &amount, bool &)
 
void Absorb (AuraEffect *aurEff, DamageInfo &dmgInfo, uint32 &absorbAmount)
 
void Register () override
 

Private Attributes

uint32 absorbPct
 
uint32 healPct
 

Additional Inherited Members

- Static Public Member Functions inherited from _SpellScript
static bool ValidateSpellInfo (std::initializer_list< uint32 > spellIds)
 
template<class T >
static bool ValidateSpellInfo (T const &spellIds)
 
- Public Attributes inherited from AuraScript
HookList< CheckAreaTargetHandlerDoCheckAreaTarget
 
HookList< AuraDispelHandlerOnDispel
 
HookList< AuraDispelHandlerAfterDispel
 
HookList< EffectApplyHandlerOnEffectApply
 
HookList< EffectApplyHandlerAfterEffectApply
 
HookList< EffectApplyHandlerOnEffectRemove
 
HookList< EffectApplyHandlerAfterEffectRemove
 
HookList< EffectPeriodicHandlerOnEffectPeriodic
 
HookList< EffectUpdatePeriodicHandlerOnEffectUpdatePeriodic
 
HookList< EffectCalcAmountHandlerDoEffectCalcAmount
 
HookList< EffectCalcPeriodicHandlerDoEffectCalcPeriodic
 
HookList< EffectCalcSpellModHandlerDoEffectCalcSpellMod
 
HookList< EffectAbsorbHandlerOnEffectAbsorb
 
HookList< EffectAbsorbHandlerAfterEffectAbsorb
 
HookList< EffectManaShieldHandlerOnEffectManaShield
 
HookList< EffectManaShieldHandlerAfterEffectManaShield
 
HookList< EffectSplitHandlerOnEffectSplit
 
HookList< CheckProcHandlerDoCheckProc
 
HookList< AfterCheckProcHandlerDoAfterCheckProc
 
HookList< AuraProcHandlerDoPrepareProc
 
HookList< AuraProcHandlerOnProc
 
HookList< AuraProcHandlerAfterProc
 
HookList< EffectProcHandlerOnEffectProc
 
HookList< EffectProcHandlerAfterEffectProc
 
virtual bool _Validate (SpellInfo const *entry)
 
- Protected Attributes inherited from _SpellScript
uint8 m_currentScriptState
 
std::string const * m_scriptName
 
uint32 m_scriptSpellId
 

Detailed Description

Member Enumeration Documentation

◆ Spell

Enumerator
PAL_SPELL_ARDENT_DEFENDER_DEBUFF 
PAL_SPELL_ARDENT_DEFENDER_HEAL 
318 {
321 };
@ PAL_SPELL_ARDENT_DEFENDER_HEAL
Definition: spell_paladin.cpp:320
@ PAL_SPELL_ARDENT_DEFENDER_DEBUFF
Definition: spell_paladin.cpp:319

Constructor & Destructor Documentation

◆ spell_pal_ardent_defender()

spell_pal_ardent_defender::spell_pal_ardent_defender ( )
inline
309 {
310 absorbPct = 0;
311 healPct = 0;
312 }
uint32 healPct
Definition: spell_paladin.cpp:315
uint32 absorbPct
Definition: spell_paladin.cpp:315

References absorbPct, and healPct.

Member Function Documentation

◆ Absorb()

void spell_pal_ardent_defender::Absorb ( AuraEffect aurEff,
DamageInfo dmgInfo,
uint32 absorbAmount 
)
inlineprivate
342 {
343 Unit* victim = GetTarget();
344 int32 remainingHealth = victim->GetHealth() - dmgInfo.GetDamage();
345 uint32 allowedHealth = victim->CountPctFromMaxHealth(35);
346 // If damage kills us
347 if (remainingHealth <= 0 && !victim->ToPlayer()->HasAura(PAL_SPELL_ARDENT_DEFENDER_DEBUFF))
348 {
349 // Cast healing spell, completely avoid damage
350 absorbAmount = dmgInfo.GetDamage();
351
352 uint32 defenseSkillValue = victim->GetDefenseSkillValue();
353 // Max heal when defense skill denies critical hits from raid bosses
354 // Formula: max defense at level + 140 (raiting from gear)
355 uint32 reqDefForMaxHeal = victim->GetLevel() * 5 + 140;
356 float pctFromDefense = (defenseSkillValue >= reqDefForMaxHeal)
357 ? 1.0f
358 : float(defenseSkillValue) / float(reqDefForMaxHeal);
359
360 int32 healAmount = int32(victim->CountPctFromMaxHealth(uint32(healPct * pctFromDefense)));
361 victim->CastCustomSpell(PAL_SPELL_ARDENT_DEFENDER_HEAL, SPELLVALUE_BASE_POINT0, healAmount, victim, true, nullptr, aurEff);
362 }
363 else if (remainingHealth < int32(allowedHealth))
364 {
365 // Reduce damage that brings us under 35% (or full damage if we are already under 35%) by x%
366 uint32 damageToReduce = (victim->GetHealth() < allowedHealth)
367 ? dmgInfo.GetDamage()
368 : allowedHealth - remainingHealth;
369 absorbAmount = CalculatePct(damageToReduce, absorbPct);
370 }
371 }
T CalculatePct(T base, U pct)
Definition: Util.h:61
std::int32_t int32
Definition: Define.h:103
std::uint32_t uint32
Definition: Define.h:107
@ SPELLVALUE_BASE_POINT0
Definition: SpellDefines.h:113
uint32 GetDamage() const
Definition: Unit.h:364
Definition: Unit.h:630
uint32 GetDefenseSkillValue(Unit const *target=nullptr) const
Definition: Unit.cpp:3625
SpellCastResult CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1224
uint32 GetHealth() const
Definition: Unit.h:1029
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1042
uint8 GetLevel() const
Definition: Unit.h:1024
Unit * GetTarget() const
Definition: SpellScript.cpp:1165

References absorbPct, CalculatePct(), Unit::CastCustomSpell(), Unit::CountPctFromMaxHealth(), DamageInfo::GetDamage(), Unit::GetDefenseSkillValue(), Unit::GetHealth(), Unit::GetLevel(), AuraScript::GetTarget(), healPct, PAL_SPELL_ARDENT_DEFENDER_DEBUFF, PAL_SPELL_ARDENT_DEFENDER_HEAL, and SPELLVALUE_BASE_POINT0.

Referenced by Register().

◆ CalculateAmount()

void spell_pal_ardent_defender::CalculateAmount ( AuraEffect const *  ,
int32 amount,
bool &   
)
inlineprivate
336 {
337 // Set absorbtion amount to unlimited
338 amount = -1;
339 }

Referenced by Register().

◆ Load()

bool spell_pal_ardent_defender::Load ( )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

329 {
330 healPct = GetSpellInfo()->Effects[EFFECT_1].CalcValue();
331 absorbPct = GetSpellInfo()->Effects[EFFECT_0].CalcValue();
332 return GetUnitOwner()->IsPlayer();
333 }
@ EFFECT_1
Definition: SharedDefines.h:32
@ EFFECT_0
Definition: SharedDefines.h:31
bool IsPlayer() const
Definition: Object.h:200
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition: SpellInfo.h:393
SpellInfo const * GetSpellInfo() const
Definition: SpellScript.cpp:1005
Unit * GetUnitOwner() const
Definition: SpellScript.cpp:1030

References absorbPct, EFFECT_0, EFFECT_1, SpellInfo::Effects, AuraScript::GetSpellInfo(), AuraScript::GetUnitOwner(), healPct, and Object::IsPlayer().

◆ PrepareAuraScript()

spell_pal_ardent_defender::PrepareAuraScript ( spell_pal_ardent_defender  )
private

◆ Register()

void spell_pal_ardent_defender::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

374 {
377 }
#define AuraEffectCalcAmountFn(F, I, N)
Definition: SpellScript.h:772
#define AuraEffectAbsorbFn(F, I)
Definition: SpellScript.h:790
@ SPELL_AURA_SCHOOL_ABSORB
Definition: SpellAuraDefines.h:132
HookList< EffectCalcAmountHandler > DoEffectCalcAmount
Definition: SpellScript.h:771
HookList< EffectAbsorbHandler > OnEffectAbsorb
Definition: SpellScript.h:789
void CalculateAmount(AuraEffect const *, int32 &amount, bool &)
Definition: spell_paladin.cpp:335
void Absorb(AuraEffect *aurEff, DamageInfo &dmgInfo, uint32 &absorbAmount)
Definition: spell_paladin.cpp:341

References Absorb(), AuraEffectAbsorbFn, AuraEffectCalcAmountFn, CalculateAmount(), AuraScript::DoEffectCalcAmount, EFFECT_0, AuraScript::OnEffectAbsorb, and SPELL_AURA_SCHOOL_ABSORB.

◆ Validate()

bool spell_pal_ardent_defender::Validate ( SpellInfo const *  )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

324 {
326 }
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:125

References PAL_SPELL_ARDENT_DEFENDER_HEAL, and _SpellScript::ValidateSpellInfo().

Member Data Documentation

◆ absorbPct

uint32 spell_pal_ardent_defender::absorbPct
private

◆ healPct

uint32 spell_pal_ardent_defender::healPct
private