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

Private Member Functions

 PrepareAuraScript (spell_hun_lock_and_load)
 
bool Validate (SpellInfo const *) override
 
bool CheckTrapProc (ProcEventInfo &eventInfo)
 
bool IsTargetValid (SpellInfo const *spellInfo, Unit *target)
 
template<uint32 mask>
void HandleProcs (AuraEffect const *aurEff, ProcEventInfo &eventInfo)
 
void ApplyMarker (ProcEventInfo &eventInfo)
 
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

◆ ApplyMarker()

void spell_hun_lock_and_load::ApplyMarker ( ProcEventInfo eventInfo)
inlineprivate
1237 {
1238 if (IsTargetValid(eventInfo.GetSpellInfo(), eventInfo.GetProcTarget()))
1239 {
1240 Unit* caster = eventInfo.GetActor();
1241 caster->CastSpell(caster, SPELL_LOCK_AND_LOAD_MARKER, true);
1242 }
1243 }
@ SPELL_LOCK_AND_LOAD_MARKER
Definition: spell_hunter.cpp:72
SpellInfo const * GetSpellInfo() const
Definition: Unit.cpp:187
Unit * GetActor()
Definition: Unit.h:858
Unit * GetProcTarget() const
Definition: Unit.h:860
Definition: Unit.h:1290
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1169
bool IsTargetValid(SpellInfo const *spellInfo, Unit *target)
Definition: spell_hunter.cpp:1177

References Unit::CastSpell(), ProcEventInfo::GetActor(), ProcEventInfo::GetProcTarget(), ProcEventInfo::GetSpellInfo(), IsTargetValid(), and SPELL_LOCK_AND_LOAD_MARKER.

Referenced by Register().

◆ CheckTrapProc()

bool spell_hun_lock_and_load::CheckTrapProc ( ProcEventInfo eventInfo)
inlineprivate
1160 {
1161 SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
1162 if (!spellInfo || !eventInfo.GetActor())
1163 {
1164 return false;
1165 }
1166
1167 // Black Arrow and Fire traps may trigger on periodic tick only.
1168 if (((spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_FIRE) || (spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_SHADOW))
1169 && (spellInfo->Effects[0].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE || spellInfo->Effects[1].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE))
1170 {
1171 return true;
1172 }
1173
1174 return IsTargetValid(spellInfo, eventInfo.GetProcTarget()) && !eventInfo.GetActor()->HasAura(SPELL_LOCK_AND_LOAD_MARKER);
1175 }
@ SPELL_AURA_PERIODIC_DAMAGE
Definition: SpellAuraDefines.h:66
@ SPELL_SCHOOL_MASK_SHADOW
Definition: SharedDefines.h:274
@ SPELL_SCHOOL_MASK_FIRE
Definition: SharedDefines.h:271
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5610
Definition: SpellInfo.h:314
SpellSchoolMask GetSchoolMask() const
Definition: SpellInfo.cpp:1972
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition: SpellInfo.h:391

References SpellInfo::Effects, ProcEventInfo::GetActor(), ProcEventInfo::GetProcTarget(), SpellInfo::GetSchoolMask(), ProcEventInfo::GetSpellInfo(), Unit::HasAura(), IsTargetValid(), SPELL_AURA_PERIODIC_DAMAGE, SPELL_LOCK_AND_LOAD_MARKER, SPELL_SCHOOL_MASK_FIRE, and SPELL_SCHOOL_MASK_SHADOW.

Referenced by Register().

◆ HandleProcs()

template<uint32 mask>
void spell_hun_lock_and_load::HandleProcs ( AuraEffect const *  aurEff,
ProcEventInfo eventInfo 
)
inlineprivate
1208 {
1210
1211 SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
1212
1213 if (!(eventInfo.GetTypeMask() & mask) || !spellInfo)
1214 {
1215 return;
1216 }
1217
1218 // Also check if the proc from the fire traps and black arrow actually comes from the periodic ticks here.
1219 // Normally this wouldn't be required, but we are circumventing the current proc system limitations.
1220 if (((spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_FIRE) || (spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_SHADOW))
1221 && (spellInfo->Effects[0].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE || spellInfo->Effects[1].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE)
1222 && !(mask & PROC_FLAG_DONE_PERIODIC))
1223 {
1224 return;
1225 }
1226
1227 if (!roll_chance_i(aurEff->GetAmount()))
1228 {
1229 return;
1230 }
1231
1232 Unit* caster = eventInfo.GetActor();
1233 caster->CastSpell(caster, SPELL_LOCK_AND_LOAD_TRIGGER, true);
1234 }
bool roll_chance_i(int chance)
Definition: Random.h:59
@ PROC_FLAG_DONE_PERIODIC
Definition: SpellMgr.h:134
@ SPELL_LOCK_AND_LOAD_TRIGGER
Definition: spell_hunter.cpp:71
uint32 GetTypeMask() const
Definition: Unit.h:861
void PreventDefaultAction()
Definition: SpellScript.cpp:985

References Unit::CastSpell(), SpellInfo::Effects, ProcEventInfo::GetActor(), AuraEffect::GetAmount(), SpellInfo::GetSchoolMask(), ProcEventInfo::GetSpellInfo(), ProcEventInfo::GetTypeMask(), AuraScript::PreventDefaultAction(), PROC_FLAG_DONE_PERIODIC, roll_chance_i(), SPELL_AURA_PERIODIC_DAMAGE, SPELL_LOCK_AND_LOAD_TRIGGER, SPELL_SCHOOL_MASK_FIRE, and SPELL_SCHOOL_MASK_SHADOW.

◆ IsTargetValid()

bool spell_hun_lock_and_load::IsTargetValid ( SpellInfo const *  spellInfo,
Unit target 
)
inlineprivate
1178 {
1179 if (!spellInfo || !target)
1180 {
1181 return false;
1182 }
1183
1184 // Don't check it for fire traps and black arrow, they proc on periodic only and not spell hit.
1185 // So it's wrong to check for immunity, it was already checked when the spell was applied.
1186 if ((spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_FIRE) || (spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_SHADOW))
1187 {
1188 return false;
1189 }
1190
1191 // HitMask for Frost Trap can't be checked correctly as it is.
1192 // That's because the talent is triggered by the spell that fires the trap (63487)...
1193 // ...and not the actual spell that applies the slow effect (67035).
1194 // So the IMMUNE result is never sent by the spell that triggers this.
1195 if (spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_NATURE)
1196 {
1197 if (SpellInfo const* triggerSpell = sSpellMgr->GetSpellInfo(SPELL_FROST_TRAP_SLOW))
1198 {
1199 return !target->IsImmunedToSpell(triggerSpell);
1200 }
1201 }
1202
1203 return true;
1204 }
#define sSpellMgr
Definition: SpellMgr.h:818
@ SPELL_FROST_TRAP_SLOW
Definition: spell_hunter.cpp:1146
@ SPELL_SCHOOL_MASK_NATURE
Definition: SharedDefines.h:272
virtual bool IsImmunedToSpell(SpellInfo const *spellInfo, Spell const *spell=nullptr)
Definition: Unit.cpp:12827

References SpellInfo::GetSchoolMask(), Unit::IsImmunedToSpell(), SPELL_FROST_TRAP_SLOW, SPELL_SCHOOL_MASK_FIRE, SPELL_SCHOOL_MASK_NATURE, SPELL_SCHOOL_MASK_SHADOW, and sSpellMgr.

Referenced by ApplyMarker(), and CheckTrapProc().

◆ PrepareAuraScript()

spell_hun_lock_and_load::PrepareAuraScript ( spell_hun_lock_and_load  )
private

◆ Register()

void spell_hun_lock_and_load::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

1246 {
1248
1249 OnEffectProc += AuraEffectProcFn(spell_hun_lock_and_load::HandleProcs<PROC_FLAG_DONE_TRAP_ACTIVATION>, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL);
1250 OnEffectProc += AuraEffectProcFn(spell_hun_lock_and_load::HandleProcs<PROC_FLAG_DONE_PERIODIC>, EFFECT_1, SPELL_AURA_DUMMY);
1251
1253 }
@ SPELL_AURA_PROC_TRIGGER_SPELL
Definition: SpellAuraDefines.h:105
@ SPELL_AURA_DUMMY
Definition: SpellAuraDefines.h:67
#define AuraProcFn(F)
Definition: SpellScript.h:837
#define AuraEffectProcFn(F, I, N)
Definition: SpellScript.h:847
#define AuraCheckProcFn(F)
Definition: SpellScript.h:818
@ EFFECT_1
Definition: SharedDefines.h:31
@ EFFECT_0
Definition: SharedDefines.h:30
HookList< AuraProcHandler > AfterProc
Definition: SpellScript.h:836
HookList< CheckProcHandler > DoCheckProc
Definition: SpellScript.h:817
HookList< EffectProcHandler > OnEffectProc
Definition: SpellScript.h:842
bool CheckTrapProc(ProcEventInfo &eventInfo)
Definition: spell_hunter.cpp:1159
void ApplyMarker(ProcEventInfo &eventInfo)
Definition: spell_hunter.cpp:1236

References AuraScript::AfterProc, ApplyMarker(), AuraCheckProcFn, AuraEffectProcFn, AuraProcFn, CheckTrapProc(), AuraScript::DoCheckProc, EFFECT_0, EFFECT_1, AuraScript::OnEffectProc, SPELL_AURA_DUMMY, and SPELL_AURA_PROC_TRIGGER_SPELL.

◆ Validate()

bool spell_hun_lock_and_load::Validate ( SpellInfo const *  )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

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

References SPELL_FROST_TRAP_SLOW, SPELL_LOCK_AND_LOAD_MARKER, SPELL_LOCK_AND_LOAD_TRIGGER, and _SpellScript::ValidateSpellInfo().