Core/Objects: Units possessing another ones must use the detection of the latter

Port From (https://github.com/TrinityCore/TrinityCore/commit/74645553be9213e366a62c6967db1d9933f3d7a7)
This commit is contained in:
hondacrx
2022-05-29 16:22:01 -04:00
parent 988dc2b99c
commit d0c767cfdf
@@ -1243,14 +1243,24 @@ namespace Game.Entities
{ {
WorldObject seer = this; WorldObject seer = this;
// If a unit is possessing another one, it uses the detection of the latter
// Pets don't have detection, they use the detection of their masters // Pets don't have detection, they use the detection of their masters
Unit thisUnit = ToUnit(); Unit thisUnit = ToUnit();
if (thisUnit != null) if (thisUnit != null)
{
if (thisUnit.IsPossessing())
{
Unit charmed = thisUnit.GetCharmed();
if (charmed != null)
seer = charmed;
}
else
{ {
Unit controller = thisUnit.GetCharmerOrOwner(); Unit controller = thisUnit.GetCharmerOrOwner();
if (controller != null) if (controller != null)
seer = controller; seer = controller;
} }
}
if (obj.IsAlwaysDetectableFor(seer)) if (obj.IsAlwaysDetectableFor(seer))
return true; return true;