You know sometimes new codes emerges when Eduke32 updates.
How about we try to add ifwalldistl xxxx { do something else } like when the actor get soo close to the wall and then does something else.
Page 1 of 1
Determining closeness to a wall
#1 Posted 03 January 2015 - 05:57 AM
#2 Posted 03 January 2015 - 09:28 AM
iffloordistl and ifceilingdistl have been around since the DOS days because they are basically the same as
Modern CON is powerful enough that you can make your own ifwalldistl with a whilevarvarn loop and a little math to calculate the shortest distance between the sprite point and the wall line segment. The key question is: Are you counting redwalls or not? Maybe only masked and blocking redwalls?
getflorzofslope sprite[THISACTOR].sectnum sprite[THISACTOR].x sprite[THISACTOR].y temp1 subvarvar temp1 sprite[THISACTOR].z ifvarl temp1 0 mulvar temp1 -1 ifvarl temp1 <value> { // do whatever }
Modern CON is powerful enough that you can make your own ifwalldistl with a whilevarvarn loop and a little math to calculate the shortest distance between the sprite point and the wall line segment. The key question is: Are you counting redwalls or not? Maybe only masked and blocking redwalls?
#3 Posted 03 January 2015 - 10:06 AM
Calculating the distance from walls is way more complicated. And like Hendricks pointed out, it raises the questions of how to achieve the effect, or what counts as a wall or not. With iffloordistl/Ifceilingdistl the game merely calculates the difference beetween the the z coordinates, and it has some flaws compared to a real 3D engine.
#4 Posted 03 January 2015 - 10:14 AM
Hendricks266, on 03 January 2015 - 09:28 AM, said:
Maybe only masked and blocking redwalls?
That's indeed the central question -- which semantics do you want for your new "command" exactly? As Hendricks noted, it makes little sense to add commands when they can be emulated relatively efficiently with existing functionality. I'll just point out an inaccuracy in Hendricks' reply and mention an existing related command.
Quote
iffloordistl and ifceilingdistl have been around since the DOS days because they are basically the same as
getflorzofslope sprite[THISACTOR].sectnum sprite[THISACTOR].x sprite[THISACTOR].y temp1 subvarvar temp1 sprite[THISACTOR].z ifvarl temp1 0 mulvar temp1 -1 ifvarl temp1 <value> { // do whatever }
Not quite. iffloordistl and ifceildistl consult the actor[].floorz and actor[].ceilingz members, respectively, and scale the number to compare with 256. That is, a unit for these commands
corresponds to 256 Build z units, or 16 Build x/y units. Here's the relevant excerpt from gameexec.c:
case CON_IFFLOORDISTL: insptr++; VM_CONDITIONAL((actor[vm.g_i].floorz - vm.g_sp->z) <= ((*insptr)<<8)); continue; case CON_IFCEILINGDISTL: insptr++; VM_CONDITIONAL((vm.g_sp->z - actor[vm.g_i].ceilingz) <= ((*insptr)<<8)); continue;
----------
CON (since Duke3D) already has a conditional ifawayfromwall. What it does is to check whether each of the four points located at an offset of (+-108, +-108) Build x/y units from the sprite is in the same sector as the sprite. Sadly, that's probably too limted for your needs: there's no way to use a different distance, and white and red walls are implicitly handled the same.
#5 Posted 04 January 2015 - 12:25 PM
Thinking about it some more, I came up with an implementation using clipmovenoslide. The idea is to try to move the actor box[1] to each of the four cardinal directions by the same amount as the distance that it should be kept from a wall.[2] The result can be found in lunatic/test/checknearwall.con. During coding, I found that it was possible for the <return> value from clipmove and some other commands to be negative, contrary to what the wiki says. Revision 4874 remedies this, and is required for checknearwall.con to function correctly.
[1]I'm not sure whether it's really a box with its sides parallel to the world coordinate axes as with getzrange here, but it should not be of major importance.
[2]How this walldist that is ultimately used for the movement of a particular actor relates to sprite[].clipdist is a separate question. An initial attempt at documenting this is here.
[1]I'm not sure whether it's really a box with its sides parallel to the world coordinate axes as with getzrange here, but it should not be of major importance.
[2]How this walldist that is ultimately used for the movement of a particular actor relates to sprite[].clipdist is a separate question. An initial attempt at documenting this is here.
Share this topic:
Page 1 of 1