Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Doom_Dude1278

double jump

Recommended Posts

ok so i was thinking how would i go about making a double jump as I cant seem to find very much about this im thinking that I could make a script where if the player isnt touching the floor and if he/she presses the jump button a second jump he will jump a second time but Im not sure how to do this as if its a script it wouldnt having nothing to trigger it (at least that i know of) and as well as this I dont know any commands which make the player walk,jump,shoot etc.

thanks again guys

Share this post


Link to post

Make a script using ThrustThingZ (), and remake the jump key to toggle a boolean.

oh nice find scifista42. Ya and Get Actor's Floor Height to cancel it out.

Share this post


Link to post
ViperGTS96 said:

nice find

It was the first Google result for "zdoom double jump". :)

Share this post


Link to post

scfista you obviously have a lot of experiance with this if its not to much trouble to ask do you mind explaining this code to me as i dont get it and everytime i do it then stops making sense thanks

Share this post


Link to post
Doom_Dude1278 said:

this code

Just making sure: Do you mean the one quoted below, or some other code?

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;   }
   }
}

Share this post


Link to post

script 300 enter
{
Script 300 is launched upon map start, one instance for each player in the map.
   int maxDblJumps = 1;
   int dblJumpThrust = 30;

   int lastZ = GetActorZ(0);
   int olderZ;
   int counter = 0;
Declarations of variables used in the script later.
   while( true )
   {
Run an infinite loop.
      olderZ = lastZ;
      lastZ = GetActorZ(0);
"lastZ" holds the value of the player's Z coordinate. "olderZ" holds the value that "lastZ" had in the previous tic.
      delay(1);
The loop runs every tic.
      if( (GetPlayerInput(-1, MODINPUT_BUTTONS) & BT_JUMP) && !(GetPlayerInput(-1, INPUT_OLDBUTTONS) & BT_JUMP) )
      {
If (#1) the player has JUST NOW pressed the jump button...
         if( (GetActorZ(0) > lastZ) && (lastZ <= olderZ) )
         {
And if (#2) the player's Z position increased since the previous tic, indicating that he has JUST NOW jumped, while in the previous tic, he was either descending or staying at a constant Z position...
            counter = 0;
The script will assume that he has only "single-jumped" yet, and reset the counter of "double-jumps" to zero.
         } else {
            if(counter < maxDblJumps)
            {
But if the previous condition (#2) wasn't met (the player hasn't jumped OR he was already ascending), and if the player hasn't yet reached the maximum limit of "double-jumps" in a single jump through the air...
               ThrustThingZ(0, dblJumpThrust, 0, 0);
               counter++;
Do a "double-jump" (with a specific thrust force) and increase the counter.
           }
         }
      } else if( (olderZ == lastZ) && (lastZ == GetActorZ(0)) )
Otherwise, if even the pre-previous condition (#1) wasn't met (the player hasn't pressed the jump button), and if he seems to be staying at a constant Z position...
      {   counter = 0;   }
The script will assume that the player is standing on the ground, and reset the counter of "double-jumps" to zero.
   }
}
The loop will restart. End of script definition.

Share this post


Link to post

thanks lol think my brains about to explode. so at the if statement why is there 3 parts to it the last part i get is so it can be repeated the first if statement doesnt make much sense as to me im getting that its going to reset the counter to zero but if the counter is already set to zero at the beggining of the script why does it need to be changed and on the else statement or the second part of this it seems to me that this can only run if the player didnt jump already. if you get what im saying

and as well as this I see you press jump once to start the script but what makes jump run the player thrust part

Share this post


Link to post

Here is a workflow diagram of this script that should make the logic easier to follow and to understand:

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×