From 1a562948a67128b8931c9d034fb151d5c439ab29 Mon Sep 17 00:00:00 2001 From: Skjalf <47818697+Nyeriah@users.noreply.github.com> Date: Mon, 20 Mar 2023 13:16:58 -0300 Subject: [PATCH] =?UTF-8?q?fix(Core/Object):=20Permanently=20invisible=20c?= =?UTF-8?q?reatures=20should=20be=20able=20to=20e=E2=80=A6=20(#15498)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/game/Entities/Object/Object.cpp | 35 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 7d8f75a61..a4b218b36 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1863,7 +1863,9 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo return false; if (!CanDetect(obj, ignoreStealth, !distanceCheck, checkAlert)) + { return false; + } return true; } @@ -1890,7 +1892,9 @@ bool WorldObject::CanDetect(WorldObject const* obj, bool ignoreStealth, bool che if (!ignoreStealth) { if (!seer->CanDetectInvisibilityOf(obj)) // xinef: added ignoreStealth, allow AoE spells to hit invisible targets! + { return false; + } if (!seer->CanDetectStealthOf(obj, checkAlert)) { @@ -1923,11 +1927,32 @@ bool WorldObject::CanDetectInvisibilityOf(WorldObject const* obj) const // It seems like that only Units are affected by this check (couldn't see arena doors with preparation invisibility) if (obj->ToUnit()) { - uint32 objMask = m_invisibility.GetFlags() & obj->m_invisibilityDetect.GetFlags(); - // xinef: include invisible flags of caster in the mask, 2 invisible objects should be able to detect eachother - objMask |= m_invisibility.GetFlags() & obj->m_invisibility.GetFlags(); - if (objMask != m_invisibility.GetFlags()) - return false; + // Permanently invisible creatures should be able to engage non-invisible targets. + // ex. Skulking Witch (20882) / Greater Invisibility (16380) + bool isPermInvisibleCreature = false; + if (Creature const* baseObj = ToCreature()) + { + auto auraEffects = baseObj->GetAuraEffectsByType(SPELL_AURA_MOD_INVISIBILITY); + for (auto const effect : auraEffects) + { + if (SpellInfo const* spell = effect->GetSpellInfo()) + { + if (spell->GetMaxDuration() == -1) + { + isPermInvisibleCreature = true; + } + } + } + } + + if (!isPermInvisibleCreature) + { + uint32 objMask = m_invisibility.GetFlags() & obj->m_invisibilityDetect.GetFlags(); + // xinef: include invisible flags of caster in the mask, 2 invisible objects should be able to detect eachother + objMask |= m_invisibility.GetFlags() & obj->m_invisibility.GetFlags(); + if (objMask != m_invisibility.GetFlags()) + return false; + } } for (uint32 i = 0; i < TOTAL_INVISIBILITY_TYPES; ++i)