path_scan(ENTITY* ent, VECTOR* pos, ANGLE* dir, VECTOR* sector)

Finds all nodes of any path within the scan cone, and returns the closest one.

path_scanpath(ENTITY* ent, VECTOR* pos, ANGLE* dir, VECTOR* sector)

A7.7 Like path_scan, but finds only nodes belonging to the path the entity is already attached to.

Parameters:

ent entity pointer.
pos scan origin.
dir scan direction angle.
sector.x horizontal scan sector, or scan cone width in degrees.
sector.y vertical scan sector in degrees, or 0 for a circular scan cone.
sector.z scan range in quants.

Returns:

The number of the closest node found, or 0 if none is found.

Speed:

Slow

Modifies:

ent is attached to the path belonging to the closest node.

Remarks:

Example:

 // move along a closed path, with sharp turns (for smoother movement use path_spline)
 action patrol_path()
 {
 // attach entity to nearest path
  result = path_scan(me,my.x,my.pan,vector(360,180,1000));
  if (result == 0) { return; } // no path found
 
 // find first waypoint
  var node = 1; // start at first node
  path_getnode(my,node,my.skill20,NULL);
 
  while (1)
  {
    var angle[3];
 // find direction
    result = vec_to_angle(angle,vec_diff(temp,my.skill20,my.x));
 
 // near target? Find next waypoint of the path
    if (result < 25) {
      node = path_nextnode(my,node,1);
      path_getnode(my,node,my.skill20,NULL);
    }
 
 // turn and walk towards target
    my.pan = angle[0];
    c_move(me,vector(3*time_step,0,0),NULL,GLIDE); // walk ahead...
    wait(1);
  }
}    

See also:

path_set, path_next, path_nextnode, path_scannode, path_spline, c_scan

► latest version online