fix(Core/Spells): correct hunter's Lock and Load procs (#8177)

- Move related code to spell scripts
- Fixes it proc'ing when the target is immune to snares
- Partial port of 746b838870
This commit is contained in:
Skjalf
2021-10-04 10:49:16 -03:00
committed by GitHub
parent 495ca76628
commit a61d7c2bc8
3 changed files with 80 additions and 20 deletions

View File

@@ -26,6 +26,7 @@
#include "GridNotifiers.h"
#include "Pet.h"
#include "ScriptMgr.h"
#include "SpellAuras.h"
#include "SpellAuraEffects.h"
#include "SpellScript.h"
@@ -64,7 +65,9 @@ enum HunterSpells
SPELL_HUNTER_VICIOUS_VIPER = 61609,
SPELL_HUNTER_VIPER_ATTACK_SPEED = 60144,
SPELL_DRAENEI_GIFT_OF_THE_NAARU = 59543,
SPELL_HUNTER_GLYPH_OF_ARCANE_SHOT = 61389
SPELL_HUNTER_GLYPH_OF_ARCANE_SHOT = 61389,
SPELL_LOCK_AND_LOAD_TRIGGER = 56453,
SPELL_LOCK_AND_LOAD_MARKER = 67544
};
// Ours
@@ -1367,6 +1370,76 @@ public:
}
};
// -56342 - Lock and Load
class spell_hun_lock_and_load : public SpellScriptLoader
{
public:
spell_hun_lock_and_load() : SpellScriptLoader("spell_hun_lock_and_load") { }
class spell_hun_lock_and_load_AuraScript : public AuraScript
{
PrepareAuraScript(spell_hun_lock_and_load_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_LOCK_AND_LOAD_TRIGGER, SPELL_LOCK_AND_LOAD_MARKER });
}
bool CheckTrapProc(ProcEventInfo& eventInfo)
{
// Do not proc on traps for immolation/explosive trap.
SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
if (!spellInfo || !(spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_FROST))
{
return false;
}
return !eventInfo.GetActor()->HasAura(SPELL_LOCK_AND_LOAD_MARKER);
}
template <uint32 mask>
void HandleProcs(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
if (!(eventInfo.GetTypeMask() & mask))
{
return;
}
if (!roll_chance_i(aurEff->GetAmount()))
{
return;
}
Unit* caster = eventInfo.GetActor();
caster->CastSpell(caster, SPELL_LOCK_AND_LOAD_TRIGGER, true);
}
void ApplyMarker(ProcEventInfo& eventInfo)
{
Unit* caster = eventInfo.GetActor();
caster->CastSpell(caster, SPELL_LOCK_AND_LOAD_MARKER, true);
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_hun_lock_and_load_AuraScript::CheckTrapProc);
OnEffectProc += AuraEffectProcFn(spell_hun_lock_and_load_AuraScript::HandleProcs<PROC_FLAG_DONE_TRAP_ACTIVATION>, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL);
OnEffectProc += AuraEffectProcFn(spell_hun_lock_and_load_AuraScript::HandleProcs<PROC_FLAG_DONE_PERIODIC>, EFFECT_1, SPELL_AURA_DUMMY);
AfterProc += AuraProcFn(spell_hun_lock_and_load_AuraScript::ApplyMarker);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_hun_lock_and_load_AuraScript();
}
};
void AddSC_hunter_spell_scripts()
{
// Ours
@@ -1397,4 +1470,5 @@ void AddSC_hunter_spell_scripts()
new spell_hun_tame_beast();
new spell_hun_viper_attack_speed();
new spell_hun_volley_trigger();
new spell_hun_lock_and_load();
}