Difference between revisions of "Hitscan"

From EDukeWiki
Jump to navigation Jump to search
m
m (Reverted edits by Ularedmond (talk) to last revision by One)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
hitscan <x1> <y1> <z1> <sect1> <cos of ang> <sin of ang> <zvel> <hit sector return var> <hit wall return var> <hit sprite return var> <hit x return var> <hit y return var> <hit z return var> <clip mask>
+
'''hitscan''' <x1> <y1> <z1> <sect1> <cos of ang> <sin of ang> <zvel> <hit sector return var> <hit wall return var> <hit sprite return var> <hit x return var> <hit y return var> <hit z return var> <clip mask>
  
 
Hitscan returns the values of what would be hit if one travelled in a straight line from a set of coordinates in a specified direction.
 
Hitscan returns the values of what would be hit if one travelled in a straight line from a set of coordinates in a specified direction.
  
All parameters are [[gamevar | gamevars]].  The first three are the coordinates from which the hitscan occurs, followed by the scanning sector.  The [[cos]], then the [[sin]] of an angle (typically the [[ang]] of the actor performing the scan) come next, followed by the z angle, which must be calculated before the hitscan.  The six return gamevars hold the values of what the hitscan hits.  The value of clip mask tells hitscan which sorts of things it can hit.  A clip mask of 4294901808 is useful for most purposes.
+
All parameters are [[gamevar | gamevars]].  The first three are the coordinates from which the hitscan occurs, followed by the scanning sector.  The [[cos]], then the [[sin]] of an angle (typically the [[ang]] of the actor performing the scan) come next, followed by the z angle, which must be calculated before the hitscan.  The six return gamevars hold the values of what the hitscan hits.  The value of [[clipmask]] tells hitscan which sorts of things it can hit.  A [[clipmask]] of 4294901808 is useful for most purposes.
 +
 
 +
Example of hitscan:
 +
<pre>
 +
//  This state will return the sector, wall, and sprite(id, x ,y, and z data)currently under the crosshair.
 +
 +
state checkhitscan
 +
getplayer[THISACTOR].posx MY_X
 +
getplayer[THISACTOR].posy MY_Y
 +
getplayer[THISACTOR].posz MY_Z
 +
getplayer[THISACTOR].cursectnum MY_SECTOR
 +
getplayer[THISACTOR].ang MY_ANGLE
 +
getplayer[THISACTOR].horiz MY_ZDIST
 +
subvar MY_ZDIST 100
 +
mulvar MY_ZDIST -2048
 +
cos MY_COS MY_ANGLE
 +
sin MY_SIN MY_ANGLE
 +
 
 +
hitscan MY_X MY_Y MY_Z MY_SECTOR MY_COS MY_SIN MY_ZDIST HITSECTOR HITWALL HITSPRITE HITX HITY HITZ 4294901808
 +
ends
 +
</pre>
  
 
[[Category:EDuke32 specific commands]]
 
[[Category:EDuke32 specific commands]]
 
[[Category:Gamevar manipulation]]
 
[[Category:Gamevar manipulation]]

Latest revision as of 05:03, 23 September 2011

hitscan <x1> <y1> <z1> <sect1> <cos of ang> <sin of ang> <zvel> <hit sector return var> <hit wall return var> <hit sprite return var> <hit x return var> <hit y return var> <hit z return var> <clip mask>

Hitscan returns the values of what would be hit if one travelled in a straight line from a set of coordinates in a specified direction.

All parameters are gamevars. The first three are the coordinates from which the hitscan occurs, followed by the scanning sector. The cos, then the sin of an angle (typically the ang of the actor performing the scan) come next, followed by the z angle, which must be calculated before the hitscan. The six return gamevars hold the values of what the hitscan hits. The value of clipmask tells hitscan which sorts of things it can hit. A clipmask of 4294901808 is useful for most purposes.

Example of hitscan:

//  This state will return the sector, wall, and sprite(id, x ,y, and z data)currently under the crosshair.
 
state checkhitscan
	getplayer[THISACTOR].posx MY_X
	getplayer[THISACTOR].posy MY_Y
	getplayer[THISACTOR].posz MY_Z
	getplayer[THISACTOR].cursectnum MY_SECTOR
	getplayer[THISACTOR].ang MY_ANGLE
	getplayer[THISACTOR].horiz MY_ZDIST
	subvar MY_ZDIST 100
	mulvar MY_ZDIST -2048
	cos MY_COS MY_ANGLE
	sin MY_SIN MY_ANGLE

	hitscan MY_X MY_Y MY_Z MY_SECTOR MY_COS MY_SIN MY_ZDIST HITSECTOR HITWALL HITSPRITE HITX HITY HITZ 4294901808
ends