SC2Mapster.com Wiki

PointsInRange

bool PointsInRange(fixed a, fixed b, fixed distance);

Are both points in distance range.

Parameters

fixed a

First point

fixed b

Second point

fixed distance

Maximal distance between a and b

Return value

bool - Is the distance between both points smaller or equal than the distance.

Examples

Example #1: Sample Usage
PointInRange(Point(0, 0), Point(1, 1), 1) // true
PointInRange(Point(0, 0), Point(0, 10), 15) // false
Example #2: Recode It
bool PointsInRange(point a, point b, fixed distance) {
  if (distance < 0) {
    return false;
  }
  return DistanceBetweenPoints(a, b) <= distance;
}
Example #3: IsPlayerWatching
// Tell if the player camera can see the unit
bool IsPlayerWatching(int player, unit u) {
  point cameraPos = CameraGetTarget(player);
  point unitPos = UnitGetPosition(u);

  return PointsInRange(cameraPos, unitPos, 20);
}
  • distance.jpg

You must login to post a comment. Don't have an account? Register to get one!

Facts

Date created
Mar 12, 2010
Last updated
Mar 12, 2010

Author