Difference between revisions of "Findnearactor"

From EDukeWiki
Jump to navigation Jump to search
(Fix findnear* semantics. If they returned the closest sprite, there would be no point having the <distance> argument.)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
'''findnearactor''' <[[tile number]]> <distance> <[[gamevar]]><br>
 
'''findnearactor''' <[[tile number]]> <distance> <[[gamevar]]><br>
'''findnearactorvar''' <[[tile number]]> <distancevar> <[[gamevar]]><br>
+
'''findnearactorvar''' <[[tile number]]> <distance> <[[gamevar]]><br>
 
'''findnearactorz''' <[[tile number]]> <xydistance> <zdistance> <[[gamevar]]><br>
 
'''findnearactorz''' <[[tile number]]> <xydistance> <zdistance> <[[gamevar]]><br>
'''findnearactorzvar''' <[[tile number]]> <xydistancevar> <zdistancevar> <[[gamevar]]><br>
+
'''findnearactorzvar''' <[[tile number]]> <xydistance> <zdistance> <[[gamevar]]><br>
 
'''findnearactor3d''' <[[tile number]]> <distance> <[[gamevar]]><br>
 
'''findnearactor3d''' <[[tile number]]> <distance> <[[gamevar]]><br>
'''findnearactor3dvar''' <[[tile number]]> <distancevar> <[[gamevar]]><br>
+
'''findnearactor3dvar''' <[[tile number]]> <distance> <[[gamevar]]><br>
 
'''findnearsprite''' <[[tile number]]> <distance> <[[gamevar]]><br>
 
'''findnearsprite''' <[[tile number]]> <distance> <[[gamevar]]><br>
'''findnearspritevar''' <[[tile number]]> <distancevar> <[[gamevar]]><br>
+
'''findnearspritevar''' <[[tile number]]> <distance> <[[gamevar]]><br>
 
'''findnearspritez''' <[[tile number]]> <xydistance> <zdistance> <[[gamevar]]><br>
 
'''findnearspritez''' <[[tile number]]> <xydistance> <zdistance> <[[gamevar]]><br>
'''findnearspritezvar''' <[[tile number]]> <xydistancevar> <zdistancevar> <[[gamevar]]><br>
+
'''findnearspritezvar''' <[[tile number]]> <xydistance> <zdistance> <[[gamevar]]><br>
 
'''findnearsprite3d''' <[[tile number]]> <distance> <[[gamevar]]><br>
 
'''findnearsprite3d''' <[[tile number]]> <distance> <[[gamevar]]><br>
'''findnearsprite3dvar''' <[[tile number]]> <distancevar> <[[gamevar]]>
+
'''findnearsprite3dvar''' <[[tile number]]> <distance> <[[gamevar]]>
  
These commands get the sprite ID of the closest <[[tile number]]> within <distance> into a <[[gamevar]]>.  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).
+
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.
 
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.
Line 18: Line 18:
 
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 ''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 of 2 times <zdistance>.  The "3d" commands work within a sphere, with a radius of <distance>.
+
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 a "var" suffix take [[gamevar]]s rather than constants for their distance value(s).
+
{{varsuffix}}
  
 
[[Category:EDuke commands]]
 
[[Category:EDuke commands]]
 
[[Category:Sprite manipulation]]
 
[[Category:Sprite manipulation]]

Latest revision as of 05:55, 17 February 2013

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.