Core/Objects: Refactor private object checks into separate function
Port From (https://github.com/TrinityCore/TrinityCore/commit/f21270b987211041b95d6befa7192d313692920d)
This commit is contained in:
@@ -87,8 +87,8 @@ namespace Game.Combat
|
|||||||
uint redirectThreadPct = victim.GetRedirectThreatPercent();
|
uint redirectThreadPct = victim.GetRedirectThreatPercent();
|
||||||
Unit redirectTarget = victim.GetRedirectThreatTarget();
|
Unit redirectTarget = victim.GetRedirectThreatTarget();
|
||||||
|
|
||||||
// If victim is personnal spawn, redirect all aggro to summoner
|
// If victim is personal spawn, redirect all aggro to summoner
|
||||||
if (victim.IsPrivateObject() && GetOwner().IsPrivateObject() && GetOwner().CanSeeOrDetect(victim))
|
if (victim.IsPrivateObject() && (!GetOwner().IsPrivateObject() || !GetOwner().CheckPrivateObjectOwnerVisibility(victim)))
|
||||||
{
|
{
|
||||||
redirectThreadPct = 100;
|
redirectThreadPct = 100;
|
||||||
redirectTarget = Global.ObjAccessor.GetUnit(GetOwner(), victim.GetPrivateObjectOwner());
|
redirectTarget = Global.ObjAccessor.GetUnit(GetOwner(), victim.GetPrivateObjectOwner());
|
||||||
|
|||||||
@@ -1100,20 +1100,36 @@ namespace Game.Entities
|
|||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CheckPrivateObjectOwnerVisibility(WorldObject seer)
|
||||||
|
{
|
||||||
|
if (!IsPrivateObject())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Owner of this private object
|
||||||
|
if (_privateObjectOwner == seer.GetGUID())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Another private object of the same owner
|
||||||
|
if (_privateObjectOwner == seer.GetPrivateObjectOwner())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public bool CanSeeOrDetect(WorldObject obj, bool ignoreStealth = false, bool distanceCheck = false, bool checkAlert = false)
|
public bool CanSeeOrDetect(WorldObject obj, bool ignoreStealth = false, bool distanceCheck = false, bool checkAlert = false)
|
||||||
{
|
{
|
||||||
if (this == obj)
|
if (this == obj)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!obj.GetPrivateObjectOwner().IsEmpty())
|
|
||||||
return GetGUID() == obj.GetPrivateObjectOwner() || GetPrivateObjectOwner() == obj.GetPrivateObjectOwner();
|
|
||||||
|
|
||||||
if (obj.IsNeverVisibleFor(this) || CanNeverSee(obj))
|
if (obj.IsNeverVisibleFor(this) || CanNeverSee(obj))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (obj.IsAlwaysVisibleFor(this) || CanAlwaysSee(obj))
|
if (obj.IsAlwaysVisibleFor(this) || CanAlwaysSee(obj))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (!obj.CheckPrivateObjectOwnerVisibility(this))
|
||||||
|
return false;
|
||||||
|
|
||||||
bool corpseVisibility = false;
|
bool corpseVisibility = false;
|
||||||
if (distanceCheck)
|
if (distanceCheck)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2300,7 +2300,7 @@ namespace Game.Maps
|
|||||||
|
|
||||||
public bool Invoke(Creature u)
|
public bool Invoke(Creature u)
|
||||||
{
|
{
|
||||||
if (u.GetDeathState() != DeathState.Dead && u.GetEntry() == i_entry && u.IsAlive() == i_alive && i_obj.IsWithinDistInMap(u, i_range) && u.CanSeeOrDetect(i_obj))
|
if (u.GetDeathState() != DeathState.Dead && u.GetEntry() == i_entry && u.IsAlive() == i_alive && i_obj.IsWithinDistInMap(u, i_range) && u.CheckPrivateObjectOwnerVisibility(i_obj))
|
||||||
{
|
{
|
||||||
i_range = i_obj.GetDistance(u); // use found unit range as new range limit for next check
|
i_range = i_obj.GetDistance(u); // use found unit range as new range limit for next check
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user