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 
314 {
317 };
@ PAL_SPELL_ARDENT_DEFENDER_HEAL
Definition: spell_paladin.cpp:316
@ PAL_SPELL_ARDENT_DEFENDER_DEBUFF
Definition: spell_paladin.cpp:315

Constructor & Destructor Documentation

◆ spell_pal_ardent_defender()

spell_pal_ardent_defender::spell_pal_ardent_defender ( )
inline
305 {
306 absorbPct = 0;
307 healPct = 0;
308 }
uint32 healPct
Definition: spell_paladin.cpp:311
uint32 absorbPct
Definition: spell_paladin.cpp:311

References absorbPct, and healPct.

Member Function Documentation

◆ Absorb()

void spell_pal_ardent_defender::Absorb ( AuraEffect aurEff,
DamageInfo dmgInfo,
uint32 absorbAmount 
)
inlineprivate
338 {
339 Unit* victim = GetTarget();
340 int32 remainingHealth = victim->GetHealth() - dmgInfo.GetDamage();
341 uint32 allowedHealth = victim->CountPctFromMaxHealth(35);
342 // If damage kills us
343 if (remainingHealth <= 0 && !victim->ToPlayer()->HasAura(PAL_SPELL_ARDENT_DEFENDER_DEBUFF))
344 {
345 // Cast healing spell, completely avoid damage
346 absorbAmount = dmgInfo.GetDamage();
347
348 uint32 defenseSkillValue = victim->GetDefenseSkillValue();
349 // Max heal when defense skill denies critical hits from raid bosses
350 // Formula: max defense at level + 140 (raiting from gear)
351 uint32 reqDefForMaxHeal = victim->GetLevel() * 5 + 140;
352 float pctFromDefense = (defenseSkillValue >= reqDefForMaxHeal)
353 ? 1.0f
354 : float(defenseSkillValue) / float(reqDefForMaxHeal);
355
356 int32 healAmount = int32(victim->CountPctFromMaxHealth(uint32(healPct * pctFromDefense)));
357 victim->CastCustomSpell(PAL_SPELL_ARDENT_DEFENDER_HEAL, SPELLVALUE_BASE_POINT0, healAmount, victim, true, nullptr, aurEff);
358 }
359 else if (remainingHealth < int32(allowedHealth))
360 {
361 // Reduce damage that brings us under 35% (or full damage if we are already under 35%) by x%
362 uint32 damageToReduce = (victim->GetHealth() < allowedHealth)
363 ? dmgInfo.GetDamage()
364 : allowedHealth - remainingHealth;
365 absorbAmount = CalculatePct(damageToReduce, absorbPct);
366 }
367 }
std::int32_t int32
Definition: Define.h:104
std::uint32_t uint32
Definition: Define.h:108
T CalculatePct(T base, U pct)
Definition: Util.h:61
@ SPELLVALUE_BASE_POINT0
Definition: SpellDefines.h:114
uint32 GetDamage() const
Definition: Unit.h:795
Definition: Unit.h:1302
uint32 GetDefenseSkillValue(Unit const *target=nullptr) const
Definition: Unit.cpp:3588
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:1226
uint32 GetHealth() const
Definition: Unit.h:1454
uint32 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:1463
uint8 GetLevel() const
Definition: Unit.h:1432
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
332 {
333 // Set absorbtion amount to unlimited
334 amount = -1;
335 }

Referenced by Register().

◆ Load()

bool spell_pal_ardent_defender::Load ( )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

325 {
326 healPct = GetSpellInfo()->Effects[EFFECT_1].CalcValue();
327 absorbPct = GetSpellInfo()->Effects[EFFECT_0].CalcValue();
328 return GetUnitOwner()->GetTypeId() == TYPEID_PLAYER;
329 }
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38
@ EFFECT_1
Definition: SharedDefines.h:32
@ EFFECT_0
Definition: SharedDefines.h:31
TypeID GetTypeId() const
Definition: Object.h:121
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition: SpellInfo.h:391
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(), Object::GetTypeId(), AuraScript::GetUnitOwner(), healPct, and TYPEID_PLAYER.

◆ PrepareAuraScript()

spell_pal_ardent_defender::PrepareAuraScript ( spell_pal_ardent_defender  )
private

◆ Register()

void spell_pal_ardent_defender::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

370 {
373 }
@ SPELL_AURA_SCHOOL_ABSORB
Definition: SpellAuraDefines.h:132
#define AuraEffectCalcAmountFn(F, I, N)
Definition: SpellScript.h:772
#define AuraEffectAbsorbFn(F, I)
Definition: SpellScript.h:790
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:331
void Absorb(AuraEffect *aurEff, DamageInfo &dmgInfo, uint32 &absorbAmount)
Definition: spell_paladin.cpp:337

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.

320 {
322 }
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