PDA

View Full Version : Moving Duke trough the cons?


DarkShark
01-17-2006, 10:15 AM
Hi All, I know this is possible but I can't figure out how to do it.
From what i understood reading the eduke wiki, the player structure
has three members containing the player x,y and z position on the map.
posx posy and posz that is.

However when i try manipulating these variables nothing seem to happen.
I have put the following lines in the APLAYER actor code:


ifhitspace
{
getplayer[THISACTOR].posz z
addvar z 1
setplayer[THISACTOR].posz z
}


Iīve tried to google for it, read trough the wiki plus various post on the
board, but i canīt seem to solve this problem. Help would be much appreciated.

Thanks in advance

/DarkShark

Mblackwell
01-17-2006, 10:53 AM
First off, in Duke negative values mean up.

The player's z is updated every frame for the velocity that's occuring, so it can be quite a challenge manipulate by z alone. If you are simply trying to move the player upwards, a better solution would be to set poszv to negative values.

DarkShark
01-17-2006, 11:43 AM
Hi Mblackwell, thanks for the quick reply.

I thought that the Z axis moved into the screen, but I remember my highscool math book saying that it is the Y axis which moves into the screen.
However in every 3d tutorial I have read, the Y axis goes up/down. As for the negative values I think that has something to do with me being used to the "left-handed" 3d coordinate system.
Anyway I was actually trying to do something a little more complicated than simply moving the player upwards.
I have this sprite that I want to behave as a magnet, atracting the player. Once I get this to work, it should not be that hard implementing a grapplinghook, or something similar.

edit:
Okay I tried updating my CON code, but now the CON parser spits out warnings http://forums.3drealms.com/ubbthreads/images/graemlins/frown.gif

My current code looks like this


ifhitspace
{

findnearactor magnet 8000 TEMP
ifvarn TEMP -1
{
getplayer[THISACTOR].posx PlayerX
getplayer[THISACTOR].posy PlayerY
getplayer[THISACTOR].posz PlayerZ
getactor[TEMP].x x
getactor[TEMP].y y
getactor[TEMP].z z

ifvarg x PlayerX { setvar tmp 20 setplayer[THISACTOR].posxv tmp } else { ifvarl x PlayerX { setvar tmp -20 setplayer[THISACTOR].posxv tmp } }
ifvarg y PlayerY { setvar tmp 20 setplayer[THISACTOR].posyv tmp } else { ifvarl y PlayerY { setvar tmp -20 setplayer[THISACTOR].posyv tmp } }
ifvarg z PlayerZ { setvar tmp 20 setplayer[THISACTOR].poszv tmp } else { ifvarl z PlayerZ { setvar tmp -20 setplayer[THISACTOR].poszv tmp } }

}

}


I get a warning, like this "* ERROR!(L3894 GAME.CON) Parameter 'PlayerX' is undefined."
for each of my gamevars (PlayerX,Y,Z). I have put this outside of the actorcode

gamevar PlayerX 0 GAMEVAR_FLAG_PERPLAYER
gamevar PlayerY 0 GAMEVAR_FLAG_PERPLAYER
gamevar PlayerZ 0 GAMEVAR_FLAG_PERPLAYER

so I do not understand why my gamevars aren't defined.

I also tried to put a addlogvar in my code, and verified that the gamevars hold the players current map position.
Once again help would be much appreciated.

/DarkShark

Mblackwell
01-17-2006, 01:03 PM
You have to use "ifvarvarl" and ""ifvarvarg".


In Duke, as far as cardinal direction goes, Y is north/south, X is east/west, and Z is up/down. The basic unit is 1024, and the player's gun is 16 units high. This equates to a 64x64 tile. Two 64x64 tiles stacked gives you complete height clearance (with some room to spare).

Just so you have a good reference.

Usurper
01-17-2006, 04:57 PM
I get a warning, like this "* ERROR!(L3894 GAME.CON) Parameter 'PlayerX' is undefined."
for each of my gamevars (PlayerX,Y,Z). I have put this outside of the actorcode

gamevar PlayerX 0 GAMEVAR_FLAG_PERPLAYER
gamevar PlayerY 0 GAMEVAR_FLAG_PERPLAYER
gamevar PlayerZ 0 GAMEVAR_FLAG_PERPLAYER

so I do not understand why my gamevars aren't defined.




Just a tip, but you'll save yourself a lot of typing if you learn the shorthand for the gamevar flags.

0 global
1 per-player
2 per-actor

It's a lot faster to type "gamevar PlayerX 0 1". I don't even define the long names in my cons anymore. (I assume you've defined them; else I presume you'd get an error about GAMEVAR_FLAG_PERPLAYER being undefined rather than the gamevar itself.)