CheckIfCloser

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

Note: This feature is for ZScript only.

Usage

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.

Parameters

  • 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.

Examples

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))));
}

This article is issued from Zdoom. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.