[Core/Spells]: Fix glyph of arcane shot not refunding mana. (#7395)

* [Core/Spells]: Fix glyph of arcane shot not refunding mana.

* chore: add newline at the end of file

* Update rev_1629141434760979400.sql

* Update spell_hunter.cpp

* Update rev_1629141434760979400.sql

* Update spell_hunter.cpp

* Update data/sql/updates/pending_db_world/rev_1629141434760979400.sql

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
lineagedr
2021-08-20 20:18:25 +03:00
committed by GitHub
parent 888549bcdc
commit 8f39bc101c
2 changed files with 76 additions and 1 deletions

View File

@@ -0,0 +1,8 @@
INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1629141434760979400');
DELETE FROM `spell_proc_event` WHERE `entry` = 56841;
INSERT INTO `spell_proc_event` (`entry`, `SchoolMask`, `SpellFamilyName`, `SpellFamilyMask0`, `SpellFamilyMask1`, `SpellFamilyMask2`, `procFlags`, `procEx`, `ppmRate`, `CustomChance`, `Cooldown`) VALUES
(56841, 0, 9, 0x800, 0x800, 0x800, 0x100, 0, 0, 0, 0);
DELETE FROM `spell_script_names` WHERE `spell_id` = 56841 AND `ScriptName` = 'spell_hun_glyph_of_arcane_shot';
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES (56841,'spell_hun_glyph_of_arcane_shot');

View File

@@ -52,7 +52,8 @@ enum HunterSpells
SPELL_HUNTER_SNIPER_TRAINING_BUFF_R1 = 64418,
SPELL_HUNTER_VICIOUS_VIPER = 61609,
SPELL_HUNTER_VIPER_ATTACK_SPEED = 60144,
SPELL_DRAENEI_GIFT_OF_THE_NAARU = 59543
SPELL_DRAENEI_GIFT_OF_THE_NAARU = 59543,
SPELL_HUNTER_GLYPH_OF_ARCANE_SHOT = 61389
};
// Ours
@@ -1229,6 +1230,71 @@ public:
}
};
// 56841 - Glyph of Arcane Shot
class spell_hun_glyph_of_arcane_shot : public SpellScriptLoader
{
public:
spell_hun_glyph_of_arcane_shot() : SpellScriptLoader("spell_hun_glyph_of_arcane_shot") {}
class spell_hun_glyph_of_arcane_shot_AuraScript : public AuraScript
{
PrepareAuraScript(spell_hun_glyph_of_arcane_shot_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_HUNTER_GLYPH_OF_ARCANE_SHOT });
}
bool CheckProc(ProcEventInfo& eventInfo)
{
if (Unit* procTarget = eventInfo.GetProcTarget())
{
// Find Serpent Sting, Viper Sting, Scorpid Sting, Wyvern Sting
const auto found = std::find_if(std::begin(procTarget->GetAppliedAuras()), std::end(procTarget->GetAppliedAuras()),
[&](std::pair<uint32, AuraApplication*> pair)
{
Aura const* aura = pair.second->GetBase();
return ((aura->GetCasterGUID() == GetTarget()->GetGUID())
&& aura->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_HUNTER
&& aura->GetSpellInfo()->SpellFamilyFlags.HasFlag(0xC000, 0x1080));
});
if (found != std::end(procTarget->GetAppliedAuras()))
{
return true;
}
}
return false;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
SpellInfo const* procSpell = eventInfo.GetSpellInfo();
if (!procSpell)
{
return;
}
int32 mana = procSpell->CalcPowerCost(GetTarget(), procSpell->GetSchoolMask());
ApplyPct(mana, aurEff->GetAmount());
GetTarget()->CastCustomSpell(SPELL_HUNTER_GLYPH_OF_ARCANE_SHOT, SPELLVALUE_BASE_POINT0, mana, GetTarget());
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_hun_glyph_of_arcane_shot_AuraScript::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_hun_glyph_of_arcane_shot_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_hun_glyph_of_arcane_shot_AuraScript();
}
};
void AddSC_hunter_spell_scripts()
{
// Ours
@@ -1238,6 +1304,7 @@ void AddSC_hunter_spell_scripts()
new spell_hun_animal_handler();
new spell_hun_generic_scaling();
new spell_hun_taming_the_beast();
new spell_hun_glyph_of_arcane_shot();
// Theirs
new spell_hun_aspect_of_the_beast();