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

Private Member Functions

 PrepareAuraScript (spell_mage_master_of_elements)
 
bool Validate (SpellInfo const *) override
 
bool AfterCheckProc (ProcEventInfo &eventInfo, bool isTriggeredAtSpellProcEvent)
 
void HandleProc (AuraEffect const *aurEff, ProcEventInfo &eventInfo)
 
void Register () override
 

Private Attributes

SpellInfo const * _spellInfo = nullptr
 
uint8 _ticksModifier = 0
 

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

◆ AfterCheckProc()

bool spell_mage_master_of_elements::AfterCheckProc ( ProcEventInfo eventInfo,
bool  isTriggeredAtSpellProcEvent 
)
inlineprivate
791 {
792 if (!isTriggeredAtSpellProcEvent || !eventInfo.GetActor() || !eventInfo.GetActionTarget())
793 {
794 return false;
795 }
796
797 _spellInfo = eventInfo.GetSpellInfo();
798
799 bool selectCaster = false;
800 // Triggered spells cost no mana so we need triggering spellInfo
801 if (SpellInfo const* triggeredByAuraSpellInfo = eventInfo.GetTriggerAuraSpell())
802 {
803 _spellInfo = triggeredByAuraSpellInfo;
804 selectCaster = true;
805 }
806
807 if (!_spellInfo)
808 {
809 return false;
810 }
811
812 _ticksModifier = 1;
813
814 // If spell is periodic, mana amount is divided by tick number
815 if (eventInfo.GetTriggerAuraEffectIndex() >= EFFECT_0)
816 {
817 if (Unit* caster = GetCaster())
818 {
819 if (Unit* target = (selectCaster ? eventInfo.GetActor() : eventInfo.GetActionTarget()))
820 {
821 if (AuraEffect const* aurEff = target->GetAuraEffect(_spellInfo->Id, eventInfo.GetTriggerAuraEffectIndex(), caster->GetGUID()))
822 {
823 _ticksModifier = std::max(1, aurEff->GetTotalTicks());
824 }
825 }
826 }
827 }
828
829 return true;
830 }
@ EFFECT_0
Definition: SharedDefines.h:31
SpellInfo const * GetTriggerAuraSpell() const
Definition: Unit.h:882
Unit * GetActionTarget() const
Definition: Unit.h:871
SpellInfo const * GetSpellInfo() const
Definition: Unit.cpp:187
int8 GetTriggerAuraEffectIndex() const
Definition: Unit.h:883
Unit * GetActor()
Definition: Unit.h:870
Definition: Unit.h:1302
Definition: SpellAuraEffects.h:39
Definition: SpellInfo.h:314
uint32 Id
Definition: SpellInfo.h:318
Unit * GetCaster() const
Definition: SpellScript.cpp:1020
SpellInfo const * _spellInfo
Definition: spell_mage.cpp:858
uint8 _ticksModifier
Definition: spell_mage.cpp:859

References _spellInfo, _ticksModifier, EFFECT_0, ProcEventInfo::GetActionTarget(), ProcEventInfo::GetActor(), AuraScript::GetCaster(), ProcEventInfo::GetSpellInfo(), ProcEventInfo::GetTriggerAuraEffectIndex(), ProcEventInfo::GetTriggerAuraSpell(), and SpellInfo::Id.

Referenced by Register().

◆ HandleProc()

void spell_mage_master_of_elements::HandleProc ( AuraEffect const *  aurEff,
ProcEventInfo eventInfo 
)
inlineprivate
833 {
835
836 if (!_spellInfo)
837 return;
838
839 if (Unit* target = GetTarget())
840 {
841 int32 mana = int32(_spellInfo->CalcPowerCost(target, eventInfo.GetSchoolMask()) / _ticksModifier);
842 mana = CalculatePct(mana, aurEff->GetAmount());
843
844 if (mana > 0)
845 {
846 target->CastCustomSpell(SPELL_MAGE_MASTER_OF_ELEMENTS_ENERGIZE, SPELLVALUE_BASE_POINT0, mana, target, true, nullptr, aurEff);
847 }
848 }
849 }
std::int32_t int32
Definition: Define.h:104
T CalculatePct(T base, U pct)
Definition: Util.h:61
@ SPELLVALUE_BASE_POINT0
Definition: SpellDefines.h:114
@ SPELL_MAGE_MASTER_OF_ELEMENTS_ENERGIZE
Definition: spell_mage.cpp:47
SpellSchoolMask GetSchoolMask() const
Definition: Unit.h:878
int32 CalcPowerCost(Unit const *caster, SpellSchoolMask schoolMask, Spell *spell=nullptr) const
Definition: SpellInfo.cpp:2387
void PreventDefaultAction()
Definition: SpellScript.cpp:985
Unit * GetTarget() const
Definition: SpellScript.cpp:1165

References _spellInfo, _ticksModifier, SpellInfo::CalcPowerCost(), CalculatePct(), AuraEffect::GetAmount(), ProcEventInfo::GetSchoolMask(), AuraScript::GetTarget(), AuraScript::PreventDefaultAction(), SPELL_MAGE_MASTER_OF_ELEMENTS_ENERGIZE, and SPELLVALUE_BASE_POINT0.

Referenced by Register().

◆ PrepareAuraScript()

spell_mage_master_of_elements::PrepareAuraScript ( spell_mage_master_of_elements  )
private

◆ Register()

void spell_mage_master_of_elements::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

852 {
855 }
@ SPELL_AURA_DUMMY
Definition: SpellAuraDefines.h:67
#define AuraEffectProcFn(F, I, N)
Definition: SpellScript.h:847
#define AuraAfterCheckProcFn(F)
Definition: SpellScript.h:823
HookList< AfterCheckProcHandler > DoAfterCheckProc
Definition: SpellScript.h:822
HookList< EffectProcHandler > OnEffectProc
Definition: SpellScript.h:842
void HandleProc(AuraEffect const *aurEff, ProcEventInfo &eventInfo)
Definition: spell_mage.cpp:832
bool AfterCheckProc(ProcEventInfo &eventInfo, bool isTriggeredAtSpellProcEvent)
Definition: spell_mage.cpp:790

References AfterCheckProc(), AuraAfterCheckProcFn, AuraEffectProcFn, AuraScript::DoAfterCheckProc, EFFECT_0, HandleProc(), AuraScript::OnEffectProc, and SPELL_AURA_DUMMY.

◆ Validate()

bool spell_mage_master_of_elements::Validate ( SpellInfo const *  )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

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

References SPELL_MAGE_MASTER_OF_ELEMENTS_ENERGIZE, and _SpellScript::ValidateSpellInfo().

Member Data Documentation

◆ _spellInfo

SpellInfo const* spell_mage_master_of_elements::_spellInfo = nullptr
private

Referenced by AfterCheckProc(), and HandleProc().

◆ _ticksModifier

uint8 spell_mage_master_of_elements::_ticksModifier = 0
private

Referenced by AfterCheckProc(), and HandleProc().