From EDukeWiki
(Redirected from Findnearactorzvar)
Jump to navigation Jump to search

findnearactor <tile number> <distance> <gamevar>
findnearactorvar <tile number> <distance> <gamevar>
findnearactorz <tile number> <xydistance> <zdistance> <gamevar>
findnearactorzvar <tile number> <xydistance> <zdistance> <gamevar>
findnearactor3d <tile number> <distance> <gamevar>
findnearactor3dvar <tile number> <distance> <gamevar>
findnearsprite <tile number> <distance> <gamevar>
findnearspritevar <tile number> <distance> <gamevar>
findnearspritez <tile number> <xydistance> <zdistance> <gamevar>
findnearspritezvar <tile number> <xydistance> <zdistance> <gamevar>
findnearsprite3d <tile number> <distance> <gamevar>
findnearsprite3dvar <tile number> <distance> <gamevar>

These commands get the sprite ID of one <tile number> with distance strictly less than <distance> into a <gamevar>. Note that this does not have to be the closest such <tile number>. If no sprite within range is found, the gamevar is set to -1. The input for <tile number> may be its tile number (example: 2000) or its defined label (example: PIGCOP).

By getting the actor ID of a nearby actor, the current actor can use getactor/setactor to edit the properties of the target actor or getangle to face the target actor, among other potential uses.

The actor finding commands work on a subset of sprites: currently awake, valid actors. The sprite finding commands work on a superset of actors: all sprites, including non-actor sprites or sleeping actors.

The normal finding commands limit distance on the x and y plane only. If you were to visualize its range, it would be an infinitely tall/deep vertical cylinder, with a radius of <distance>. The "z" commands work within a finite cylinder, with a radius of <xydistance> and a height extending <zdistance> both above and below. The "3d" commands work within a sphere, with a radius of <distance>.

Commands with an additional "var" suffix take gamevars rather than constants or defined labels for their inputs. As an alternate short form, "varvar" can be dropped from these commands; for example ife serves an an alias for ifvarvare.