Rage through 32 single player levels and 6 deathmatch levels of sheer terror and fully immersive sound and lighting. Arm yourself against the cannibalistic Ogre, fiendish Vore and indestructible Schambler using lethal nails, fierce Thunderbolts and abominable Rocket and Grenade Launchers.

Post tutorial Report RSS Semi-Automatic Jumping

This tutorial teaches you how to change Quake's jumping to something more Half-Life style, where you cannot press the jump key again until you hit the ground (eliminates pogo-stick jumping)

Posted by on - Basic Server Side Coding

Looking through the Quake code, you may notice that id Software put in anti-'pogo jumping' protection, so you can't simply hold down the jump key in game and hop around. But if you've played Quake, you probably noticed that you can still 'pogo jump' if you quickly release and re-press the jump key while in midair! Perhaps you'd like to change this, so players will have to wait until they hit the ground before they can hit the jump key again.

Warning! Do this at your own risk! If your mod is multiplayer-oriented or you want people to make cool speedruns with it, you may not want to add this! Bunny-hopping is an extremely common exploit of Quake physics that many people would be sad to see go. If you do this tutorial, you may get many people mad at you!

Another Warning! Apparently this code does not work in QuakeWorld! I assume that the client-side prediction built in to the client engine will cause the client to believe he is jumping (i.e. your view will still rise and fall as if you were jumping) when you're actually not! This means that the engine assumes that the server progs use the standard Quake jump behaviour. So only do this in a non-QuakeWorld engine (a 'NetQuake' engine).

Now that the audience of this tutorial is slimmed down, let's proceed. This is a very simple tutorial that only requires one line change!

Open up client.qc. Scroll about halfway down until you find the function PlayerPreThink. Find the following chunk of code in that function:

if (self.button2)
{
 PlayerJump ();
}
else
 self.flags = self.flags | FL_JUMPRELEASED;

Simply add 'if (self.flags & FL_ONGROUND)' to the 'else' line, like so:

if (self.button2)
{
 PlayerJump ();
}
else if (self.flags & FL_ONGROUND)
 self.flags = self.flags | FL_JUMPRELEASED;

You now have 'debounced' the jump!

[page=Explanation & Conclusion]
Let's see exactly why this works.

Explanation
id's original code would check if button2 (the +jump key) is currently pressed. If so, it would call PlayerJump, which would jump unless the player is airborne or the 'jumpreleased' flag isn't set. If button2 is not pressed, then the 'jumpreleased' flag is set, letting the game know that the player has released the jump key at least once since his last jump, so jumping again is possible.

We changed it so that it will only set the 'jumpreleased' flag if you are on the ground (the 'onground' flag is set). This means that the game only recognizes that you actually released the jump key once you have hit the ground.

Conclusion
This was a quick and easy tutorial that shows that cool new features can be added with very little changes (although most cool new features still require a lot of code ;). Good luck and keep coding!

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: