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

Private Member Functions

 PrepareAuraScript (spell_dk_pet_scaling)
 
void CalculateStatAmount (AuraEffect const *aurEff, int32 &amount, bool &)
 
void CalculateSPAmount (AuraEffect const *, int32 &amount, bool &)
 
void CalculateHasteAmount (AuraEffect const *, int32 &amount, bool &)
 
void HandleEffectApply (AuraEffect const *aurEff, AuraEffectHandleModes)
 
void CalcPeriodic (AuraEffect const *, bool &isPeriodic, int32 &amplitude)
 
void HandlePeriodic (AuraEffect const *aurEff)
 
void Register () override
 

Additional Inherited Members

- 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
 
Unit * GetCaster () const
 
GameObject * GetGObjCaster () const
 
WorldObject * GetOwner () const
 
Unit * GetUnitOwner () const
 
DynamicObject * GetDynobjOwner () const
 
void Remove (AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
Aura * GetAura () 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
 
AuraEffect * GetEffect (uint8 effIndex) const
 
bool HasEffectType (AuraType type) const
 
Unit * GetTarget () 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 bool Validate (SpellInfo const *)
 
virtual bool Load ()
 
virtual void Unload ()
 
- 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< CheckAreaTargetHandler > DoCheckAreaTarget
 
HookList< AuraDispelHandler > OnDispel
 
HookList< AuraDispelHandler > AfterDispel
 
HookList< EffectApplyHandler > OnEffectApply
 
HookList< EffectApplyHandler > AfterEffectApply
 
HookList< EffectApplyHandler > OnEffectRemove
 
HookList< EffectApplyHandler > AfterEffectRemove
 
HookList< EffectPeriodicHandler > OnEffectPeriodic
 
HookList< EffectUpdatePeriodicHandler > OnEffectUpdatePeriodic
 
HookList< EffectCalcAmountHandler > DoEffectCalcAmount
 
HookList< EffectCalcPeriodicHandler > DoEffectCalcPeriodic
 
HookList< EffectCalcSpellModHandler > DoEffectCalcSpellMod
 
HookList< EffectAbsorbHandler > OnEffectAbsorb
 
HookList< EffectAbsorbHandler > AfterEffectAbsorb
 
HookList< EffectManaShieldHandler > OnEffectManaShield
 
HookList< EffectManaShieldHandler > AfterEffectManaShield
 
HookList< EffectSplitHandler > OnEffectSplit
 
HookList< CheckProcHandler > DoCheckProc
 
HookList< CheckEffectProcHandler > DoCheckEffectProc
 
HookList< AuraProcHandler > DoPrepareProc
 
HookList< AuraProcHandler > OnProc
 
HookList< AuraProcHandler > AfterProc
 
HookList< EffectProcHandler > OnEffectProc
 
HookList< EffectProcHandler > AfterEffectProc
 
- Protected Attributes inherited from _SpellScript
uint8 m_currentScriptState
 
std::string const * m_scriptName
 
uint32 m_scriptSpellId
 

Detailed Description

Member Function Documentation

◆ CalcPeriodic()

void spell_dk_pet_scaling::CalcPeriodic ( AuraEffect const *  ,
bool &  isPeriodic,
int32 &  amplitude 
)
inlineprivate
878 {
879 if (!GetUnitOwner()->IsPet())
880 return;
881
882 isPeriodic = true;
883 amplitude = 2 * IN_MILLISECONDS;
884 }
constexpr auto IN_MILLISECONDS
Definition Common.h:53
Unit * GetUnitOwner() const
Definition SpellScript.cpp:1043

References AuraScript::GetUnitOwner(), and IN_MILLISECONDS.

Referenced by Register().

◆ CalculateHasteAmount()

void spell_dk_pet_scaling::CalculateHasteAmount ( AuraEffect const *  ,
int32 &  amount,
bool &   
)
inlineprivate
849 {
850 // xinef: scale haste with owners melee haste
851 if (Unit* owner = GetUnitOwner()->GetOwner())
852 {
853 float modSpeed = owner->m_modAttackSpeedPct[BASE_ATTACK];
854 modSpeed = std::ranges::clamp(modSpeed, 1e-6f, 1.0f);
855 amount = static_cast<int32>(((1.0f / modSpeed) - 1.0f) * 100.0f);
856 }
857 }
std::int32_t int32
Definition Define.h:103
@ BASE_ATTACK
Definition Unit.h:223
WorldObject * GetOwner() const
Definition SpellScript.cpp:1038
Definition Unit.h:670

References BASE_ATTACK, AuraScript::GetOwner(), and AuraScript::GetUnitOwner().

Referenced by Register().

◆ CalculateSPAmount()

void spell_dk_pet_scaling::CalculateSPAmount ( AuraEffect const *  ,
int32 &  amount,
bool &   
)
inlineprivate
827 {
828 if (GetUnitOwner()->GetEntry() != NPC_EBON_GARGOYLE)
829 return;
830
831 if (Unit* owner = GetUnitOwner()->GetOwner())
832 {
833 // Percentage of the owner's attack power to be inherited as spell power
834 // This value was chosen based on experimental damage of Gargoyle Strike
835 int32 modifier = 75;
836
837 if (AuraEffect* impurityEff = owner->GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, 1986, EFFECT_0))
838 AddPct(modifier, impurityEff->GetAmount());
839
840 amount = CalculatePct(std::max<int32>(0, static_cast<int32>(owner->GetTotalAttackPowerValue(BASE_ATTACK))), modifier);
841
842 // xinef: Update appropriate player field
843 if (owner->IsPlayer())
844 owner->SetUInt32Value(PLAYER_PET_SPELL_POWER, (uint32)amount);
845 }
846 }
std::uint32_t uint32
Definition Define.h:107
@ NPC_EBON_GARGOYLE
Definition PetDefines.h:124
@ EFFECT_0
Definition SharedDefines.h:31
@ SPELLFAMILY_DEATHKNIGHT
Definition SharedDefines.h:3799
@ PLAYER_PET_SPELL_POWER
Definition UpdateFields.h:391
T AddPct(T &base, U pct)
Definition Util.h:58
T CalculatePct(T base, U pct)
Definition Util.h:52
Definition SpellAuraEffects.h:39

References AddPct(), BASE_ATTACK, CalculatePct(), EFFECT_0, AuraScript::GetOwner(), AuraScript::GetUnitOwner(), NPC_EBON_GARGOYLE, PLAYER_PET_SPELL_POWER, and SPELLFAMILY_DEATHKNIGHT.

Referenced by Register().

◆ CalculateStatAmount()

void spell_dk_pet_scaling::CalculateStatAmount ( AuraEffect const *  aurEff,
int32 &  amount,
bool &   
)
inlineprivate
794 {
795 Stats stat = Stats(aurEff->GetSpellInfo()->Effects[aurEff->GetEffIndex()].MiscValue);
796
797 // xinef: dk ghoul inherits 70% of strength and 30% of stamina
798 if (GetUnitOwner()->GetEntry() != NPC_RISEN_GHOUL)
799 {
800 // xinef: ebon garogyle - inherit 30% of stamina
801 if (GetUnitOwner()->GetEntry() == NPC_EBON_GARGOYLE && stat == STAT_STAMINA)
802 if (Unit* owner = GetUnitOwner()->GetOwner())
803 amount = CalculatePct(std::max<int32>(0, owner->GetStat(stat)), 30);
804 return;
805 }
806
807 if (Unit* owner = GetUnitOwner()->GetOwner())
808 {
809 int32 modifier = stat == STAT_STRENGTH ? 70 : 30;
810
811 // Check just if owner has Ravenous Dead since it's effect is not an aura
812 if (AuraEffect const* rdEff = owner->GetAuraEffect(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, SPELLFAMILY_DEATHKNIGHT, 3010, 0))
813 {
814 SpellInfo const* spellInfo = rdEff->GetSpellInfo(); // Then get the SpellProto and add the dummy effect value
815 AddPct(modifier, spellInfo->Effects[EFFECT_1].CalcValue()); // Ravenous Dead edits the original scale
816 }
817
818 // xinef: Glyph of the Ghoul
819 if (AuraEffect const* glyphEff = owner->GetAuraEffect(SPELL_DK_GLYPH_OF_THE_GHOUL, EFFECT_0))
820 modifier += glyphEff->GetAmount();
821
822 amount = CalculatePct(std::max<int32>(0, owner->GetStat(stat)), modifier);
823 }
824 }
@ NPC_RISEN_GHOUL
Definition PetDefines.h:121
@ EFFECT_1
Definition SharedDefines.h:32
Stats
Definition SharedDefines.h:245
@ STAT_STRENGTH
Definition SharedDefines.h:246
@ STAT_STAMINA
Definition SharedDefines.h:248
@ SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE
Definition SpellAuraDefines.h:200
Definition SpellInfo.h:340
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition SpellInfo.h:417
@ SPELL_DK_GLYPH_OF_THE_GHOUL
Definition spell_dk.cpp:39

References AddPct(), CalculatePct(), EFFECT_0, EFFECT_1, SpellInfo::Effects, AuraEffect::GetEffIndex(), AuraScript::GetOwner(), AuraEffect::GetSpellInfo(), AuraScript::GetUnitOwner(), NPC_EBON_GARGOYLE, NPC_RISEN_GHOUL, SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, SPELL_DK_GLYPH_OF_THE_GHOUL, SPELLFAMILY_DEATHKNIGHT, STAT_STAMINA, and STAT_STRENGTH.

Referenced by Register().

◆ HandleEffectApply()

void spell_dk_pet_scaling::HandleEffectApply ( AuraEffect const *  aurEff,
AuraEffectHandleModes   
)
inlineprivate
860 {
861 if (aurEff->GetAuraType() != SPELL_AURA_MELEE_SLOW)
862 return;
863
867
868 if (GetUnitOwner()->IsPet())
869 return;
870
875 }
@ IMMUNITY_STATE
Definition SharedDefines.h:1399
@ SPELL_AURA_MOD_ATTACK_POWER
Definition SpellAuraDefines.h:162
@ SPELL_AURA_MELEE_SLOW
Definition SpellAuraDefines.h:256
@ SPELL_AURA_MOD_STAT
Definition SpellAuraDefines.h:92
@ SPELL_AURA_MOD_MELEE_RANGED_HASTE
Definition SpellAuraDefines.h:255
@ SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK
Definition SpellAuraDefines.h:128
@ SPELL_AURA_MOD_ATTACK_POWER_PCT
Definition SpellAuraDefines.h:229
@ SPELL_BLOCK_TYPE_POSITIVE
Definition SpellDefines.h:169
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply, SpellImmuneBlockType blockType=SPELL_BLOCK_TYPE_ALL)
Definition Unit.cpp:10247

References Unit::ApplySpellImmune(), AuraEffect::GetAuraType(), AuraScript::GetUnitOwner(), IMMUNITY_STATE, SPELL_AURA_MELEE_SLOW, SPELL_AURA_MOD_ATTACK_POWER, SPELL_AURA_MOD_ATTACK_POWER_PCT, SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK, SPELL_AURA_MOD_MELEE_RANGED_HASTE, SPELL_AURA_MOD_STAT, SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, and SPELL_BLOCK_TYPE_POSITIVE.

Referenced by Register().

◆ HandlePeriodic()

void spell_dk_pet_scaling::HandlePeriodic ( AuraEffect const *  aurEff)
inlineprivate
887 {
889 if (aurEff->GetAuraType() == SPELL_AURA_MOD_STAT && (aurEff->GetMiscValue() == STAT_STAMINA || aurEff->GetMiscValue() == STAT_INTELLECT))
890 {
891 int32 currentAmount = aurEff->GetAmount();
892 int32 newAmount = GetEffect(aurEff->GetEffIndex())->CalculateAmount(GetCaster());
893 if (newAmount != currentAmount)
894 {
895 if (aurEff->GetMiscValue() == STAT_STAMINA)
896 {
897 uint32 actStat = GetUnitOwner()->GetHealth();
898 GetEffect(aurEff->GetEffIndex())->ChangeAmount(newAmount, false);
899 GetUnitOwner()->SetHealth(std::min<uint32>(GetUnitOwner()->GetMaxHealth(), actStat));
900 }
901 else
902 {
904 GetEffect(aurEff->GetEffIndex())->ChangeAmount(newAmount, false);
905 GetUnitOwner()->SetPower(POWER_MANA, std::min<uint32>(GetUnitOwner()->GetMaxPower(POWER_MANA), actStat));
906 }
907 }
908 }
909 else
910 GetEffect(aurEff->GetEffIndex())->RecalculateAmount();
911 }
@ POWER_MANA
Definition SharedDefines.h:257
@ STAT_INTELLECT
Definition SharedDefines.h:249
void ChangeAmount(int32 newAmount, bool mark=true, bool onStackOrReapply=false)
Definition SpellAuraEffects.cpp:713
int32 CalculateAmount(Unit *caster)
Definition SpellAuraEffects.cpp:452
void RecalculateAmount()
Definition SpellAuraEffects.h:76
void PreventDefaultAction()
Definition SpellScript.cpp:991
Unit * GetCaster() const
Definition SpellScript.cpp:1026
AuraEffect * GetEffect(uint8 effIndex) const
Definition SpellScript.cpp:1168
void SetPower(Powers power, uint32 val, bool withPowerUpdate=true, bool fromRegenerate=false)
Definition Unit.cpp:12108
void SetHealth(uint32 val)
Definition Unit.cpp:12020
uint32 GetHealth() const
Definition Unit.h:1122
uint32 GetPower(Powers power) const
Definition Unit.h:1149

References AuraEffect::CalculateAmount(), AuraEffect::ChangeAmount(), AuraEffect::GetAmount(), AuraEffect::GetAuraType(), AuraScript::GetCaster(), AuraScript::GetEffect(), AuraEffect::GetEffIndex(), Unit::GetHealth(), AuraEffect::GetMiscValue(), Unit::GetPower(), AuraScript::GetUnitOwner(), POWER_MANA, AuraScript::PreventDefaultAction(), AuraEffect::RecalculateAmount(), Unit::SetHealth(), Unit::SetPower(), SPELL_AURA_MOD_STAT, STAT_INTELLECT, and STAT_STAMINA.

Referenced by Register().

◆ PrepareAuraScript()

spell_dk_pet_scaling::PrepareAuraScript ( spell_dk_pet_scaling  )
private

◆ Register()

void spell_dk_pet_scaling::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

914 {
916 {
919 }
920
923
927 }
@ SPELL_DK_PET_SCALING_01
Definition PetDefines.h:197
@ SPELL_DK_PET_SCALING_02
Definition PetDefines.h:198
#define EFFECT_ALL
Definition SharedDefines.h:38
@ SPELL_AURA_MOD_DAMAGE_DONE
Definition SpellAuraDefines.h:76
@ AURA_EFFECT_HANDLE_REAL
Definition SpellAuraDefines.h:42
#define AuraEffectCalcAmountFn(F, I, N)
Definition SpellScript.h:773
#define AuraEffectPeriodicFn(F, I, N)
Definition SpellScript.h:761
#define AuraEffectCalcPeriodicFn(F, I, N)
Definition SpellScript.h:779
#define AuraEffectApplyFn(F, I, N, M)
Definition SpellScript.h:744
#define SPELL_AURA_ANY
Definition SpellScript.h:43
HookList< EffectCalcPeriodicHandler > DoEffectCalcPeriodic
Definition SpellScript.h:778
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition SpellScript.h:760
HookList< EffectCalcAmountHandler > DoEffectCalcAmount
Definition SpellScript.h:772
HookList< EffectApplyHandler > OnEffectApply
Definition SpellScript.h:739
uint32 m_scriptSpellId
Definition SpellScript.h:107
void CalcPeriodic(AuraEffect const *, bool &isPeriodic, int32 &amplitude)
Definition spell_dk.cpp:877
void CalculateHasteAmount(AuraEffect const *, int32 &amount, bool &)
Definition spell_dk.cpp:848
void CalculateStatAmount(AuraEffect const *aurEff, int32 &amount, bool &)
Definition spell_dk.cpp:793
void CalculateSPAmount(AuraEffect const *, int32 &amount, bool &)
Definition spell_dk.cpp:826
void HandlePeriodic(AuraEffect const *aurEff)
Definition spell_dk.cpp:886
void HandleEffectApply(AuraEffect const *aurEff, AuraEffectHandleModes)
Definition spell_dk.cpp:859

References AURA_EFFECT_HANDLE_REAL, AuraEffectApplyFn, AuraEffectCalcAmountFn, AuraEffectCalcPeriodicFn, AuraEffectPeriodicFn, CalcPeriodic(), CalculateHasteAmount(), CalculateSPAmount(), CalculateStatAmount(), AuraScript::DoEffectCalcAmount, AuraScript::DoEffectCalcPeriodic, EFFECT_ALL, HandleEffectApply(), HandlePeriodic(), _SpellScript::m_scriptSpellId, AuraScript::OnEffectApply, AuraScript::OnEffectPeriodic, SPELL_AURA_ANY, SPELL_AURA_MELEE_SLOW, SPELL_AURA_MOD_DAMAGE_DONE, SPELL_AURA_MOD_STAT, SPELL_DK_PET_SCALING_01, and SPELL_DK_PET_SCALING_02.


The documentation for this class was generated from the following file: