From 0fa4a90aa8f07919989fdc15b638e99237fd6c2d Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Thu, 10 Feb 2022 15:34:00 +0100 Subject: [PATCH] =?UTF-8?q?fix(Core/Spells):=20Added=20some=20exceptions?= =?UTF-8?q?=20to=20`SPELL=5FAURA=5FPREVENT=5FREGENE=E2=80=A6=20(#9844)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(Core/Spells): Added some exceptions to `SPELL_AURA_PREVENT_REGENERATE_POWER` auras. Fixes #2042 --- src/server/game/Entities/Unit/Unit.cpp | 40 ++++++++++++++++++++-- src/server/game/Entities/Unit/Unit.h | 2 ++ src/server/scripts/Spells/spell_hunter.cpp | 2 +- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 005b92517..852332959 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -12324,8 +12324,12 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) cons uint32 effect = spellInfo->Effects[index].Effect; SpellImmuneList const& effectList = m_spellImmune[IMMUNITY_EFFECT]; for (SpellImmuneList::const_iterator itr = effectList.begin(); itr != effectList.end(); ++itr) - if (itr->type == effect && (itr->spellId != 62692 || spellInfo->Effects[index].MiscValue == POWER_MANA)) + { + if (itr->type == effect && (itr->spellId != 62692 || (spellInfo->Effects[index].MiscValue == POWER_MANA && !CanRestoreMana(spellInfo)))) + { return true; + } + } if (uint32 mechanic = spellInfo->Effects[index].Mechanic) { @@ -12339,10 +12343,18 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) cons { SpellImmuneList const& list = m_spellImmune[IMMUNITY_STATE]; for (SpellImmuneList::const_iterator itr = list.begin(); itr != list.end(); ++itr) - if (itr->type == aura && (itr->spellId != 64848 || spellInfo->Effects[index].MiscValue == POWER_MANA)) + { + if (itr->type == aura && (itr->spellId != 64848 || (spellInfo->Effects[index].MiscValue == POWER_MANA && !CanRestoreMana(spellInfo)))) + { if (!spellInfo->HasAttribute(SPELL_ATTR3_ALWAYS_HIT)) + { if (itr->blockType == SPELL_BLOCK_TYPE_ALL || spellInfo->IsPositive()) // xinef: added for pet scaling + { return true; + } + } + } + } if (!spellInfo->HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES)) { @@ -20454,3 +20466,27 @@ void Unit::Whisper(uint32 textId, Player* target, bool isBossWhisper /*= false*/ ChatHandler::BuildChatPacket(data, isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, this, target, bct->GetText(locale, getGender()), 0, "", locale); target->SendDirectMessage(&data); } + +bool Unit::CanRestoreMana(SpellInfo const* spellInfo) const +{ + // Aura of Despair exceptions + switch (spellInfo->Id) + { + case 30824: // Shamanistic Rage + case 31786: // Spiritual Attunement + case 31930: // Judgements of the Wise + case 34075: // Aspect of the Viper + case 34720: // Thrill of the hunt + case 47755: // Rapture + case 63337: // Saronite Vapors (regenerate mana) + case 63375: // Improved stormstrike + case 64372: // Lifebloom + return true; + case 54428: // Divine Plea - only with talent Guarded by the Light + return HasSpell(53583); + default: + break; + } + + return false; +} diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 983776833..fce3d96ae 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -2377,6 +2377,8 @@ public: void ProcessPositionDataChanged(PositionFullTerrainStatus const& data) override; virtual void ProcessTerrainStatusUpdate(); + [[nodiscard]] bool CanRestoreMana(SpellInfo const* spellInfo) const; + protected: explicit Unit (bool isWorldObject); diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index 961528844..33a7b5e5e 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -410,7 +410,7 @@ class spell_hun_ascpect_of_the_viper : public AuraScript void Register() override { DoCheckProc += AuraCheckProcFn(spell_hun_ascpect_of_the_viper::CheckProc); - OnEffectProc += AuraEffectProcFn(spell_hun_ascpect_of_the_viper::HandleProc, EFFECT_0, SPELL_AURA_OBS_MOD_POWER); + OnEffectProc += AuraEffectProcFn(spell_hun_ascpect_of_the_viper::HandleProc, EFFECT_2, SPELL_AURA_DUMMY); AfterEffectApply += AuraEffectApplyFn(spell_hun_ascpect_of_the_viper::OnApply, EFFECT_0, SPELL_AURA_OBS_MOD_POWER, AURA_EFFECT_HANDLE_REAL); AfterEffectRemove += AuraEffectRemoveFn(spell_hun_ascpect_of_the_viper::OnRemove, EFFECT_0, SPELL_AURA_OBS_MOD_POWER, AURA_EFFECT_HANDLE_REAL); }