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
1250 {
1251 if (IsTargetValid(eventInfo.GetSpellInfo(), eventInfo.GetProcTarget()))
1252 {
1253 Unit* caster = eventInfo.GetActor();
1254 caster->CastSpell(caster, SPELL_LOCK_AND_LOAD_MARKER, true);
1255 }
1256 }
@ SPELL_LOCK_AND_LOAD_MARKER
Definition: spell_hunter.cpp:72
SpellInfo const * GetSpellInfo() const
Definition: Unit.cpp:184
Unit * GetActor()
Definition: Unit.h:439
Unit * GetProcTarget() const
Definition: Unit.h:441
Definition: Unit.h:630
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:1167
bool IsTargetValid(SpellInfo const *spellInfo, Unit *target)
Definition: spell_hunter.cpp:1190

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
1173 {
1174 SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
1175 if (!spellInfo || !eventInfo.GetActor())
1176 {
1177 return false;
1178 }
1179
1180 // Black Arrow and Fire traps may trigger on periodic tick only.
1181 if (((spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_FIRE) || (spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_SHADOW))
1182 && (spellInfo->Effects[0].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE || spellInfo->Effects[1].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE))
1183 {
1184 return true;
1185 }
1186
1187 return IsTargetValid(spellInfo, eventInfo.GetProcTarget()) && !eventInfo.GetActor()->HasAura(SPELL_LOCK_AND_LOAD_MARKER);
1188 }
@ SPELL_SCHOOL_MASK_SHADOW
Definition: SharedDefines.h:302
@ SPELL_SCHOOL_MASK_FIRE
Definition: SharedDefines.h:299
@ SPELL_AURA_PERIODIC_DAMAGE
Definition: SpellAuraDefines.h:66
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5698
Definition: SpellInfo.h:316
SpellSchoolMask GetSchoolMask() const
Definition: SpellInfo.cpp:1987
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition: SpellInfo.h:393

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
1221 {
1223
1224 SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
1225
1226 if (!(eventInfo.GetTypeMask() & mask) || !spellInfo)
1227 {
1228 return;
1229 }
1230
1231 // Also check if the proc from the fire traps and black arrow actually comes from the periodic ticks here.
1232 // Normally this wouldn't be required, but we are circumventing the current proc system limitations.
1233 if (((spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_FIRE) || (spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_SHADOW))
1234 && (spellInfo->Effects[0].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE || spellInfo->Effects[1].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE)
1235 && !(mask & PROC_FLAG_DONE_PERIODIC))
1236 {
1237 return;
1238 }
1239
1240 if (!roll_chance_i(aurEff->GetAmount()))
1241 {
1242 return;
1243 }
1244
1245 Unit* caster = eventInfo.GetActor();
1246 caster->CastSpell(caster, SPELL_LOCK_AND_LOAD_TRIGGER, true);
1247 }
bool roll_chance_i(int chance)
Definition: Random.h:59
@ SPELL_LOCK_AND_LOAD_TRIGGER
Definition: spell_hunter.cpp:71
@ PROC_FLAG_DONE_PERIODIC
Definition: SpellMgr.h:134
uint32 GetTypeMask() const
Definition: Unit.h:442
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
1191 {
1192 if (!spellInfo || !target)
1193 {
1194 return false;
1195 }
1196
1197 // Don't check it for fire traps and black arrow, they proc on periodic only and not spell hit.
1198 // So it's wrong to check for immunity, it was already checked when the spell was applied.
1199 if ((spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_FIRE) || (spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_SHADOW))
1200 {
1201 return false;
1202 }
1203
1204 // HitMask for Frost Trap can't be checked correctly as it is.
1205 // That's because the talent is triggered by the spell that fires the trap (63487)...
1206 // ...and not the actual spell that applies the slow effect (67035).
1207 // So the IMMUNE result is never sent by the spell that triggers this.
1208 if (spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_NATURE)
1209 {
1210 if (SpellInfo const* triggerSpell = sSpellMgr->GetSpellInfo(SPELL_FROST_TRAP_SLOW))
1211 {
1212 return !target->IsImmunedToSpell(triggerSpell);
1213 }
1214 }
1215
1216 return true;
1217 }
@ SPELL_FROST_TRAP_SLOW
Definition: spell_hunter.cpp:1159
@ SPELL_SCHOOL_MASK_NATURE
Definition: SharedDefines.h:300
#define sSpellMgr
Definition: SpellMgr.h:825
virtual bool IsImmunedToSpell(SpellInfo const *spellInfo, Spell const *spell=nullptr)
Definition: Unit.cpp:12916

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.

1259 {
1261
1262 OnEffectProc += AuraEffectProcFn(spell_hun_lock_and_load::HandleProcs<PROC_FLAG_DONE_TRAP_ACTIVATION>, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL);
1263 OnEffectProc += AuraEffectProcFn(spell_hun_lock_and_load::HandleProcs<PROC_FLAG_DONE_PERIODIC>, EFFECT_1, SPELL_AURA_DUMMY);
1264
1266 }
@ EFFECT_1
Definition: SharedDefines.h:32
@ EFFECT_0
Definition: SharedDefines.h:31
#define AuraProcFn(F)
Definition: SpellScript.h:837
#define AuraEffectProcFn(F, I, N)
Definition: SpellScript.h:847
#define AuraCheckProcFn(F)
Definition: SpellScript.h:818
@ SPELL_AURA_PROC_TRIGGER_SPELL
Definition: SpellAuraDefines.h:105
@ SPELL_AURA_DUMMY
Definition: SpellAuraDefines.h:67
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:1172
void ApplyMarker(ProcEventInfo &eventInfo)
Definition: spell_hunter.cpp:1249

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.

1168 {
1170 }
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().