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

Private Member Functions

 PrepareAuraScript (spell_warl_generic_scaling)
 
void CalculateResistanceAmount (AuraEffect const *aurEff, int32 &amount, bool &)
 
void CalculateStatAmount (AuraEffect const *aurEff, int32 &amount, bool &)
 
void CalculateAPAmount (AuraEffect const *, int32 &amount, bool &)
 
void CalculateSPAmount (AuraEffect const *, int32 &amount, bool &)
 
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
 
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 ()
 
- 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 Function Documentation

◆ CalcPeriodic()

void spell_warl_generic_scaling::CalcPeriodic ( AuraEffect const *  ,
bool &  isPeriodic,
int32 amplitude 
)
inlineprivate
330 {
331 isPeriodic = true;
332 amplitude = 2 * IN_MILLISECONDS;
333 }
constexpr auto IN_MILLISECONDS
Definition: Common.h:62

References IN_MILLISECONDS.

Referenced by Register().

◆ CalculateAPAmount()

void spell_warl_generic_scaling::CalculateAPAmount ( AuraEffect const *  ,
int32 amount,
bool &   
)
inlineprivate
302 {
303 // xinef: by default warlock pet inherits 57% of max(SP FIRE, SP SHADOW) as AP
304 if (Unit* owner = GetUnitOwner()->GetOwner())
305 {
306 int32 fire = owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FIRE);
307 int32 shadow = owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW);
308 int32 maximum = (fire > shadow) ? fire : shadow;
309 amount = CalculatePct(std::max<int32>(0, maximum), 57);
310 }
311 }
std::int32_t int32
Definition: Define.h:104
T CalculatePct(T base, U pct)
Definition: Util.h:61
@ SPELL_SCHOOL_MASK_SHADOW
Definition: SharedDefines.h:274
@ SPELL_SCHOOL_MASK_FIRE
Definition: SharedDefines.h:271
Definition: Unit.h:1290
WorldObject * GetOwner() const
Definition: SpellScript.cpp:1025
Unit * GetUnitOwner() const
Definition: SpellScript.cpp:1030

References CalculatePct(), AuraScript::GetOwner(), AuraScript::GetUnitOwner(), SPELL_SCHOOL_MASK_FIRE, and SPELL_SCHOOL_MASK_SHADOW.

Referenced by Register().

◆ CalculateResistanceAmount()

void spell_warl_generic_scaling::CalculateResistanceAmount ( AuraEffect const *  aurEff,
int32 amount,
bool &   
)
inlineprivate
280 {
281 // xinef: pet inherits 40% of resistance from owner and 35% of armor
282 if (Unit* owner = GetUnitOwner()->GetOwner())
283 {
284 SpellSchoolMask schoolMask = SpellSchoolMask(aurEff->GetSpellInfo()->Effects[aurEff->GetEffIndex()].MiscValue);
285 int32 modifier = schoolMask == SPELL_SCHOOL_MASK_NORMAL ? 35 : 40;
286 amount = CalculatePct(std::max<int32>(0, owner->GetResistance(schoolMask)), modifier);
287 }
288 }
SpellSchoolMask
Definition: SharedDefines.h:267
@ SPELL_SCHOOL_MASK_NORMAL
Definition: SharedDefines.h:269

References CalculatePct(), SpellInfo::Effects, AuraEffect::GetEffIndex(), AuraScript::GetOwner(), AuraEffect::GetSpellInfo(), AuraScript::GetUnitOwner(), and SPELL_SCHOOL_MASK_NORMAL.

Referenced by Register().

◆ CalculateSPAmount()

void spell_warl_generic_scaling::CalculateSPAmount ( AuraEffect const *  ,
int32 amount,
bool &   
)
inlineprivate
314 {
315 // xinef: by default warlock pet inherits 15% of max(SP FIRE, SP SHADOW) as SP
316 if (Unit* owner = GetUnitOwner()->GetOwner())
317 {
318 int32 fire = owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FIRE);
319 int32 shadow = owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW);
320 int32 maximum = (fire > shadow) ? fire : shadow;
321 amount = CalculatePct(std::max<int32>(0, maximum), 15);
322
323 // xinef: Update appropriate player field
324 if (owner->GetTypeId() == TYPEID_PLAYER)
325 owner->SetUInt32Value(PLAYER_PET_SPELL_POWER, (uint32)amount);
326 }
327 }
std::uint32_t uint32
Definition: Define.h:108
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38
@ PLAYER_PET_SPELL_POWER
Definition: UpdateFields.h:391

References CalculatePct(), AuraScript::GetOwner(), AuraScript::GetUnitOwner(), PLAYER_PET_SPELL_POWER, SPELL_SCHOOL_MASK_FIRE, SPELL_SCHOOL_MASK_SHADOW, and TYPEID_PLAYER.

Referenced by Register().

◆ CalculateStatAmount()

void spell_warl_generic_scaling::CalculateStatAmount ( AuraEffect const *  aurEff,
int32 amount,
bool &   
)
inlineprivate
291 {
292 // xinef: by default warlock pet inherits 75% of stamina and 30% of intellect
293 if (Unit* owner = GetUnitOwner()->GetOwner())
294 {
295 Stats stat = Stats(aurEff->GetSpellInfo()->Effects[aurEff->GetEffIndex()].MiscValue);
296 int32 modifier = stat == STAT_STAMINA ? 75 : 30;
297 amount = CalculatePct(std::max<int32>(0, owner->GetStat(stat)), modifier);
298 }
299 }
Stats
Definition: SharedDefines.h:229
@ STAT_STAMINA
Definition: SharedDefines.h:232

References CalculatePct(), SpellInfo::Effects, AuraEffect::GetEffIndex(), AuraScript::GetOwner(), AuraEffect::GetSpellInfo(), AuraScript::GetUnitOwner(), and STAT_STAMINA.

Referenced by Register().

◆ HandlePeriodic()

void spell_warl_generic_scaling::HandlePeriodic ( AuraEffect const *  aurEff)
inlineprivate
336 {
338 if (aurEff->GetAuraType() == SPELL_AURA_MOD_STAT && (aurEff->GetMiscValue() == STAT_STAMINA || aurEff->GetMiscValue() == STAT_INTELLECT))
339 {
340 int32 currentAmount = aurEff->GetAmount();
341 int32 newAmount = GetEffect(aurEff->GetEffIndex())->CalculateAmount(GetCaster());
342 if (newAmount != currentAmount)
343 {
344 if (aurEff->GetMiscValue() == STAT_STAMINA)
345 {
346 uint32 actStat = GetUnitOwner()->GetHealth();
347 GetEffect(aurEff->GetEffIndex())->ChangeAmount(newAmount, false);
348 GetUnitOwner()->SetHealth(std::min<uint32>(GetUnitOwner()->GetMaxHealth(), actStat));
349 }
350 else
351 {
353 GetEffect(aurEff->GetEffIndex())->ChangeAmount(newAmount, false);
354 GetUnitOwner()->SetPower(POWER_MANA, std::min<uint32>(GetUnitOwner()->GetMaxPower(POWER_MANA), actStat));
355 }
356 }
357 }
358 else
359 GetEffect(aurEff->GetEffIndex())->RecalculateAmount();
360 }
@ SPELL_AURA_MOD_STAT
Definition: SpellAuraDefines.h:92
@ POWER_MANA
Definition: SharedDefines.h:241
@ STAT_INTELLECT
Definition: SharedDefines.h:233
void SetPower(Powers power, uint32 val, bool withPowerUpdate=true, bool fromRegenerate=false)
Definition: Unit.cpp:15458
void SetHealth(uint32 val)
Definition: Unit.cpp:15370
uint32 GetHealth() const
Definition: Unit.h:1440
uint32 GetPower(Powers power) const
Definition: Unit.h:1461
void ChangeAmount(int32 newAmount, bool mark=true, bool onStackOrReapply=false)
Definition: SpellAuraEffects.cpp:702
int32 CalculateAmount(Unit *caster)
Definition: SpellAuraEffects.cpp:452
void RecalculateAmount()
Definition: SpellAuraEffects.h:75
void PreventDefaultAction()
Definition: SpellScript.cpp:985
Unit * GetCaster() const
Definition: SpellScript.cpp:1020
AuraEffect * GetEffect(uint8 effIndex) const
Definition: SpellScript.cpp:1155

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_warl_generic_scaling::PrepareAuraScript ( spell_warl_generic_scaling  )
private

◆ Register()

void spell_warl_generic_scaling::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

363 {
364 if (m_scriptSpellId != 34947)
366
367 if (m_scriptSpellId == 34947 || m_scriptSpellId == 34956)
369
370 if (m_scriptSpellId == 34947)
371 {
374 }
375
378 }
@ SPELL_AURA_MOD_ATTACK_POWER
Definition: SpellAuraDefines.h:162
@ SPELL_AURA_MOD_RESISTANCE
Definition: SpellAuraDefines.h:85
@ SPELL_AURA_MOD_DAMAGE_DONE
Definition: SpellAuraDefines.h:76
#define AuraEffectCalcAmountFn(F, I, N)
Definition: SpellScript.h:772
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:760
#define AuraEffectCalcPeriodicFn(F, I, N)
Definition: SpellScript.h:778
#define SPELL_AURA_ANY
Definition: SpellScript.h:43
#define EFFECT_ALL
Definition: SharedDefines.h:37
uint32 m_scriptSpellId
Definition: SpellScript.h:107
HookList< EffectCalcPeriodicHandler > DoEffectCalcPeriodic
Definition: SpellScript.h:777
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:759
HookList< EffectCalcAmountHandler > DoEffectCalcAmount
Definition: SpellScript.h:771
void CalculateSPAmount(AuraEffect const *, int32 &amount, bool &)
Definition: spell_warlock.cpp:313
void CalculateResistanceAmount(AuraEffect const *aurEff, int32 &amount, bool &)
Definition: spell_warlock.cpp:279
void CalculateAPAmount(AuraEffect const *, int32 &amount, bool &)
Definition: spell_warlock.cpp:301
void CalculateStatAmount(AuraEffect const *aurEff, int32 &amount, bool &)
Definition: spell_warlock.cpp:290
void CalcPeriodic(AuraEffect const *, bool &isPeriodic, int32 &amplitude)
Definition: spell_warlock.cpp:329
void HandlePeriodic(AuraEffect const *aurEff)
Definition: spell_warlock.cpp:335

References AuraEffectCalcAmountFn, AuraEffectCalcPeriodicFn, AuraEffectPeriodicFn, CalcPeriodic(), CalculateAPAmount(), CalculateResistanceAmount(), CalculateSPAmount(), CalculateStatAmount(), AuraScript::DoEffectCalcAmount, AuraScript::DoEffectCalcPeriodic, EFFECT_ALL, HandlePeriodic(), _SpellScript::m_scriptSpellId, AuraScript::OnEffectPeriodic, SPELL_AURA_ANY, SPELL_AURA_MOD_ATTACK_POWER, SPELL_AURA_MOD_DAMAGE_DONE, SPELL_AURA_MOD_RESISTANCE, and SPELL_AURA_MOD_STAT.