Entities/GO: FindNearestGameObject no longer incorrectly returns despawned gameobjects.
Port From (https://github.com/TrinityCore/TrinityCore/commit/6de4c3cd72de1c7ae6e467b09ec181445b397338)
This commit is contained in:
@@ -2481,7 +2481,7 @@ namespace Game.Maps
|
||||
|
||||
public class AllCreaturesOfEntryInRange : ICheck<Creature>
|
||||
{
|
||||
public AllCreaturesOfEntryInRange(WorldObject obj, uint entry, float maxRange)
|
||||
public AllCreaturesOfEntryInRange(WorldObject obj, uint entry, float maxRange = 0f)
|
||||
{
|
||||
m_pObject = obj;
|
||||
m_uiEntry = entry;
|
||||
@@ -2490,10 +2490,20 @@ namespace Game.Maps
|
||||
|
||||
public bool Invoke(Creature creature)
|
||||
{
|
||||
if (m_uiEntry == 0 || creature.GetEntry() == m_uiEntry && m_pObject.IsWithinDist(creature, m_fRange, false))
|
||||
return true;
|
||||
if (m_uiEntry != 0)
|
||||
{
|
||||
if (creature.GetEntry() != m_uiEntry)
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
if (m_fRange != 0f)
|
||||
{
|
||||
if (m_fRange > 0.0f && !m_pObject.IsWithinDist(creature, m_fRange, false))
|
||||
return false;
|
||||
if (m_fRange < 0.0f && m_pObject.IsWithinDist(creature, m_fRange, false))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
WorldObject m_pObject;
|
||||
@@ -2740,7 +2750,7 @@ namespace Game.Maps
|
||||
|
||||
public bool Invoke(GameObject go)
|
||||
{
|
||||
if (go.GetEntry() == i_entry && go.GetGUID() != i_obj.GetGUID() && i_obj.IsWithinDistInMap(go, i_range))
|
||||
if (go.IsSpawned() && go.GetEntry() == i_entry && go.GetGUID() != i_obj.GetGUID() && i_obj.IsWithinDistInMap(go, i_range))
|
||||
{
|
||||
i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user