mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-06 04:52:16 +00:00
b0c48eec25
Previously, the C function clipmove() returned negative values when hit a wall (32768+wallnum) or sprite (49152+spritenum) because internally, these values were encoded into a *signed* 16-bit integer. This made no difference to C code using it, since it always proceeded by bit checks, but was inconsistent with documentation on CON 'clipmove' on the wiki. The following commands are affected too, since they use the value returned by clipmove(): 'clipmovenoslide', 'movesprite'. Also, the value of actor[].movflag ('htmovflag' from CON). Also, fix 'clipmove*' in LunaCON and add lunatic/test/checknearwall.con as an example of how to implement a being-close-to-a-wall checker as requested in http://forums.duke4.net/topic/7869-determining-closeness-to-a-wall/ git-svn-id: https://svn.eduke32.com/eduke32@4874 1a8010ca-5511-0410-912e-c29ae57300e0
86 lines
1.9 KiB
Text
86 lines
1.9 KiB
Text
|
|
// Inputs to "state checknearwall".
|
|
gamevar wd 128 0 // wall distance
|
|
gamevar cfd 1024 0 // ceiling/floor distance
|
|
|
|
// Outputs of "state checknearwall".
|
|
gamevar hitwall -1 0
|
|
|
|
// Temporary variables.
|
|
gamevar tmp 0 0
|
|
gamevar ret 0 0
|
|
gamevar x 0 0
|
|
gamevar y 0 0
|
|
gamevar z 0 0
|
|
gamevar sectnum 0 0
|
|
|
|
define CM_BLK_WAL 1
|
|
|
|
state getcoords
|
|
setvarvar x sprite[THISACTOR].x
|
|
setvarvar y sprite[THISACTOR].y
|
|
setvarvar z sprite[THISACTOR].z
|
|
setvarvar sectnum sprite[THISACTOR].sectnum
|
|
ends
|
|
|
|
// Inputs: (wd, cfd)
|
|
// Returns: hitwall
|
|
// -1: hit no wall
|
|
// >=0: hit that wall
|
|
state checknearwall
|
|
setvar hitwall -1
|
|
|
|
setvarvar tmp wd, shiftvarl tmp 14
|
|
|
|
state getcoords
|
|
clipmovenoslide ret (x, y, z, sectnum) (tmp, 0) (wd, cfd, cfd) CM_BLK_WAL
|
|
ifvarn ret 0 { setvarvar hitwall ret, subvar hitwall 32768, break }
|
|
|
|
state getcoords
|
|
clipmovenoslide ret (x, y, z, sectnum) (0, tmp) (wd, cfd, cfd) CM_BLK_WAL
|
|
ifvarn ret 0 { setvarvar hitwall ret, subvar hitwall 32768, break }
|
|
|
|
mulvar tmp -1
|
|
|
|
state getcoords
|
|
clipmovenoslide ret (x, y, z, sectnum) (tmp, 0) (wd, cfd, cfd) CM_BLK_WAL
|
|
ifvarn ret 0 { setvarvar hitwall ret, subvar hitwall 32768, break }
|
|
|
|
state getcoords
|
|
clipmovenoslide ret (x, y, z, sectnum) (0, tmp) (wd, cfd, cfd) CM_BLK_WAL
|
|
ifvarn ret 0 { setvarvar hitwall ret, subvar hitwall 32768, break }
|
|
ends
|
|
|
|
////////// Example usage //////////
|
|
|
|
onevent EVENT_PROCESSINPUT
|
|
state checknearwall
|
|
endevent
|
|
|
|
|
|
define Q_tmp 500
|
|
definequote Q_tmp <write on me>
|
|
|
|
define Q_no 501
|
|
definequote Q_no Hit no wall
|
|
|
|
define Q_yes 502
|
|
definequote Q_yes Hit wall %d
|
|
|
|
define Q_info 503
|
|
definequote Q_info pos: %d %d %d sect: %d
|
|
|
|
onevent EVENT_DISPLAYREST
|
|
qsprintf Q_tmp Q_info, x y z sectnum
|
|
minitext (100, 8) Q_tmp (0, 0)
|
|
|
|
ifvarn hitwall -1
|
|
{
|
|
qsprintf Q_tmp Q_yes hitwall
|
|
minitext (100, 16) Q_tmp (0, 0)
|
|
}
|
|
else
|
|
{
|
|
minitext (100, 16) Q_no (0, 0)
|
|
}
|
|
endevent
|