From ZDoom Wiki
Jump to navigation Jump to search
Note: This feature is for ZScript only.

bool CheckIfCloser(Actor targ, double dist[, bool noz])


Checks if the specified actor is within the provided range of the calling Actor. By default this check is only on the xy axis but z checking can also be enabled.


  • targ - The actor to check the distance to.
  • dist - The distance to check against.
  • no - False by default. If true, allows an additional height check to be done as well.

Return value

Returns true if the specified actor was in range of the calling Actor.


Nuvolachalk.png Note: This article lists no examples. If you make use of this feature in your own project(s) or know of any basic examples that could be shared, please add them. This will make it easier to understand for future authors seeking assistance. Your contributions are greatly appreciated.

Internal Code

bool CheckIfCloser(Actor targ, double dist, bool noz = false)
    if (!targ) return false;

    return (Distance2D(targ) < dist && (noz || 
           ((pos.z > targ.pos.z && pos.z - targ.pos.z - targ.height < dist) ||
           (pos.z <= targ.pos.z && targ.pos.z - pos.z - height < dist))));