From 5831c336df5ea9013fefbc314dc74478bb575c84 Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Sat, 7 Aug 2021 00:28:07 +0200 Subject: [PATCH] fix(Scripts/Spells): Windfury Weapon should not consume Flurry stacks. (#7151) * fix(Scripts/Spells): Windfury Weapon should not consume Flurry stacks. Fixed #6234 * Update src/server/scripts/Spells/spell_shaman.cpp --- .../rev_1627403306832649400.sql | 5 +++ src/server/game/Entities/Unit/Unit.cpp | 18 ++++++++- src/server/game/Entities/Unit/Unit.h | 4 +- src/server/scripts/Spells/spell_shaman.cpp | 37 +++++++++++++++++++ 4 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1627403306832649400.sql diff --git a/data/sql/updates/pending_db_world/rev_1627403306832649400.sql b/data/sql/updates/pending_db_world/rev_1627403306832649400.sql new file mode 100644 index 000000000..d6f44440c --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1627403306832649400.sql @@ -0,0 +1,5 @@ +INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1627403306832649400'); + +DELETE FROM `spell_script_names` WHERE `spell_id`=-16257; +INSERT INTO `spell_script_names` VALUES +(-16257,'spell_sha_flurry_proc'); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index fd0d8f06d..2127c3ded 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -142,12 +142,26 @@ void DamageInfo::BlockDamage(uint32 amount) m_damage -= amount; } -ProcEventInfo::ProcEventInfo(Unit* actor, Unit* actionTarget, Unit* procTarget, uint32 typeMask, uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* /*spell*/, DamageInfo* damageInfo, HealInfo* healInfo, SpellInfo const* triggeredByAuraSpell, int8 procAuraEffectIndex) +ProcEventInfo::ProcEventInfo(Unit* actor, Unit* actionTarget, Unit* procTarget, uint32 typeMask, uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell, DamageInfo* damageInfo, HealInfo* healInfo, SpellInfo const* triggeredByAuraSpell, int8 procAuraEffectIndex) : _actor(actor), _actionTarget(actionTarget), _procTarget(procTarget), _typeMask(typeMask), _spellTypeMask(spellTypeMask), _spellPhaseMask(spellPhaseMask), - _hitMask(hitMask), _damageInfo(damageInfo), _healInfo(healInfo), _triggeredByAuraSpell(triggeredByAuraSpell), _procAuraEffectIndex(procAuraEffectIndex) + _hitMask(hitMask), _spell(spell), _damageInfo(damageInfo), _healInfo(healInfo), _triggeredByAuraSpell(triggeredByAuraSpell), _procAuraEffectIndex(procAuraEffectIndex) { } +SpellInfo const* ProcEventInfo::GetSpellInfo() const +{ + if (_spell) + return _spell->GetSpellInfo(); + + if (_damageInfo) + return _damageInfo->GetSpellInfo(); + + if (_healInfo) + return _healInfo->GetSpellInfo(); + + return nullptr; +} + // we can disable this warning for this since it only // causes undefined behavior when passed to the base class constructor #ifdef _MSC_VER diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 98dc064c9..081d1e989 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -955,6 +955,7 @@ private: uint32 _spellPhaseMask; uint32 _hitMask; uint32 _cooldown; + Spell* _spell; DamageInfo* _damageInfo; HealInfo* _healInfo; SpellInfo const* const _triggeredByAuraSpell; @@ -969,8 +970,9 @@ public: [[nodiscard]] uint32 GetSpellTypeMask() const { return _spellTypeMask; } [[nodiscard]] uint32 GetSpellPhaseMask() const { return _spellPhaseMask; } [[nodiscard]] uint32 GetHitMask() const { return _hitMask; } - [[nodiscard]] SpellInfo const* GetSpellInfo() const { return nullptr; } + [[nodiscard]] SpellInfo const* GetSpellInfo() const; [[nodiscard]] SpellSchoolMask GetSchoolMask() const { return SPELL_SCHOOL_MASK_NONE; } + [[nodiscard]] Spell* GetProcSpell() const { return _spell; } [[nodiscard]] DamageInfo* GetDamageInfo() const { return _damageInfo; } [[nodiscard]] HealInfo* GetHealInfo() const { return _healInfo; } [[nodiscard]] SpellInfo const* GetTriggerAuraSpell() const { return _triggeredByAuraSpell; } diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp index b201b0f82..846e4240c 100644 --- a/src/server/scripts/Spells/spell_shaman.cpp +++ b/src/server/scripts/Spells/spell_shaman.cpp @@ -1354,6 +1354,42 @@ public: } }; +// -16257 - SpellName +class spell_sha_flurry_proc : public SpellScriptLoader +{ +public: + spell_sha_flurry_proc() : SpellScriptLoader("spell_sha_flurry_proc") {} + + class spell_sha_flurry_proc_AuraScript : public AuraScript + { + PrepareAuraScript(spell_sha_flurry_proc_AuraScript); + + bool CheckProc(ProcEventInfo& eventInfo) + { + // Should not proc from Windfury Attack + if (SpellInfo const* spellInfo = eventInfo.GetSpellInfo()) + { + if (spellInfo->SpellFamilyName == SPELLFAMILY_SHAMAN && (spellInfo->SpellFamilyFlags[0] & 0x00800000) != 0) + { + return false; + } + } + + return true; + } + + void Register() override + { + DoCheckProc += AuraCheckProcFn(spell_sha_flurry_proc_AuraScript::CheckProc); + } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_sha_flurry_proc_AuraScript(); + } +}; + void AddSC_shaman_spell_scripts() { // ours @@ -1387,4 +1423,5 @@ void AddSC_shaman_spell_scripts() new spell_sha_mana_tide_totem(); new spell_sha_sentry_totem(); new spell_sha_thunderstorm(); + new spell_sha_flurry_proc(); }