to give the player a make another jump in mid air? im trying to figure how, ( o btw where i can find more info about the jump in zdoom? i know i can change the height of the jump, but i dont know if its possible to make another jump after the first one its executed)
Re: its possible?
Posted: Sun Feb 22, 2009 9:46 pm
by Xaser
I hereby declare this thread to be definitive and the other one a cheap clone. Even though judging from its higher position it came second... whatever. Anyone who posts in the other one, do so at your own risk. ;P
What you achieve can probably be done well using [wiki]GetPlayerInput[/wiki] and [wiki]ThrustThingZ[/wiki] along with [wiki]GetActorZ[/wiki] and [wiki]GetActorFloorZ[/wiki] to check if the player's off the ground.
This was brought up long ago and was impossible to do correctly then, but I never thought of this again until now... crazy how well GetPlayerInput has changed the face of ZDoom. :o
Re: its possible?
Posted: Sun Feb 22, 2009 9:52 pm
by XutaWoo
You could also pull a walljump and combine the jump key with a script key, but that'd mean the users would have to rebind their jump key.
Re: its possible?
Posted: Sun Feb 22, 2009 9:57 pm
by Macil
XutaWoo wrote:You could also pull a walljump and combine the jump key with a script key, but that'd mean the users would have to rebind their jump key.
By using GetPlayerInput you don't need to change any bindings.
Re: its possible?
Posted: Sun Feb 22, 2009 9:58 pm
by XutaWoo
Yeah but by using bindings you don't need a constantly running script.
Re: its possible?
Posted: Sun Feb 22, 2009 10:09 pm
by Xaser
We could always make the user define a custom keybinding which starts a constantly running script so we could get the worst of both worlds. D:
Re: its possible?
Posted: Sun Feb 22, 2009 10:56 pm
by Zok
Xaser wrote:I hereby declare this thread to be definitive and the other one a cheap clone. Even though judging from its higher position it came second... whatever. Anyone who posts in the other one, do so at your own risk. ;P
What you achieve can probably be done well using [wiki]GetPlayerInput[/wiki] and [wiki]ThrustThingZ[/wiki] along with [wiki]GetActorZ[/wiki] and [wiki]GetActorFloorZ[/wiki] to check if the player's off the ground.
This was brought up long ago and was impossible to do correctly then, but I never thought of this again until now... crazy how well GetPlayerInput has changed the face of ZDoom.
oh i didnt notice the other topic, since i must disable the antivirus to post... maybe when i refresh the window when i deactivated the antivirus make another post, so im sorry for that. someone can delete the other topic x3??.
thanks for the orientation guys.
Re: its possible?
Posted: Sun Feb 22, 2009 10:57 pm
by Macil
A constantly running script isn't a performance problem at all if the only thing being done in the loop is checking if a control was pressed. The game itself does the equivalent code many times over in different places every tic; waiting on another control isn't bad.
Load with zdoom and this enables double-jump. Feel free to use/edit/share/use in your own mods as long as you give credit.
(1.2 KiB) Downloaded 786 times
Attached is a pk3, that autoloads the script and enables double-jumping in-game. Should work with any level, mod, or game that doesn't use script #300. Completely multiplayer compatible. The script is also easily editable to change the thrust of the double jump, and the max number of double-jumps that player can do per being airborne.
Now onto the implementation of how this works:
To the double jump, wait until you detect the player press the jump key. Then you need to check if the game made the player jump. If it didn't, thrust the player upwards, and remember that the player did a double jump, so that they can't double jump again until after they've done a normal jump.
Xaser wrote:What you achieve can probably be done well using [wiki]GetPlayerInput[/wiki] and [wiki]ThrustThingZ[/wiki] along with [wiki]GetActorZ[/wiki] and [wiki]GetActorFloorZ[/wiki] to check if the player's off the ground.
If you used GetActorZ and GetActorFloorZ, you wouldn't be able to check if the player jumped off of a thing.
To check if the game made the player jump is pretty tricky. You could check if the player's current Z is less than or equal to his last Z, but then he can't double-jump during the upward part of his jump. So my idea is to keep a running total every tic of his last tic's Z (lastZ), and the tic before that (olderZ).
When the jump key is pressed, it's checked if his Z now is greater than lastZ. If it is...
{
The player is moving upward. If lastZ is greater than olderZ, the player was moving upward before he pressed the jump button, so it's assumed this can be a double jump.
Otherwise, his double jump counter is just reset.
}
If his Z now wasn't greater than lastZ, it can be a double jump.
Also, if his Z stays the same for a few tics, reset the double jump counter.
#include "zcommon.acs"
#library "dbljump"
// Code by Agent ME
// Free to use/edit/distribute, just give some credit.
// The code should technically use MODINPUT_OLDBUTTONS instead of INPUT_OLDBUTTONS, but there seems to be
// a glitch with the former right now. http://forum.zdoom.org/viewtopic.php?t=21037
// INPUT_OLDBUTTONS works as well in this case anyway.
script 300 enter
{
int maxDblJumps = 1;
int dblJumpThrust = 30;
int lastZ = GetActorZ(0);
int olderZ;
int counter = 0;
while( true )
{
olderZ = lastZ;
lastZ = GetActorZ(0);
delay(1);
if( (GetPlayerInput(-1, MODINPUT_BUTTONS) & BT_JUMP) && !(GetPlayerInput(-1, INPUT_OLDBUTTONS) & BT_JUMP) )
{
if( (GetActorZ(0) > lastZ) && (lastZ <= olderZ) )
{
counter = 0;
} else {
if(counter < maxDblJumps)
{
ThrustThingZ(0, dblJumpThrust, 0, 0);
counter++;
}
}
} else if( (olderZ == lastZ) && (lastZ == GetActorZ(0)) )
{ counter = 0; }
}
}
If you use this in a game that has jumping disabled, then the player can only use double jumps. (This is different than normal gameplay because you can also jump while in mid-air this way.)
(Download is at the top of this post)
Re: its possible?
Posted: Mon Feb 23, 2009 12:46 am
by Zok
ohh very nice, this its great, thanks for the example and the code description agent me, of course i going to give the credits for the help, im working on another proyect, but since i was thinking "its doom i dont think its possible to do a double jump". i guess im going to be more open minded with Zdoom.
thanks for making the wad explaining how its work (I do not want to be a nuisance ), since i only want to know if a double jump were possible in doom, when we have a little more advanced in the project im going to post some screens well anyways thanks agent me and Zdoom community. (oh btw sorry for the double post, im going to be more careful watching if my antivirus its enable or not)
Re: its possible?
Posted: Mon Feb 23, 2009 4:42 am
by Isle
I added a small bit so you can change direction in midair when you jump.