Click for more information!

Here is the tutorial that I followed to come up with the Jetpack in Ultra.  This tutorial in essence, got the ball rolling for the rest of the mod.  This tutorial should be appearing on Code3arena shortly.
by Crawdad_Cletis

This tutorial was created in response to a request on the quake3world forums requesting a Tribes style jetpack. It is intended to give you a start, not make the sweetest jetpack man has ever known.


First we need to define a button to use for activating the jetpack. Go to qshared.h and search for "BUTTON_ANY". Then add the line below right after it. 
#define BUTTON_ANY              2048            // any key whatsoever
#define BUTTON_JETPACK          4096            // use the jetpack


Bust open bg_pmove.c. Add the following function anywhere north of the function PmoveSingle (I put it between PM_FlyMove and PM_AirMove). 

Use the jetpack.
static void PM_JetpackMove( void ) {
        int             i;
        vec3_t  wishvel;
        float   wishspeed;
        vec3_t  wishdir;
        float   scale;

        // normal slowdown
        PM_Friction ();

        scale = PM_CmdScale( &pm->cmd );
        // user intentions
        if ( !scale ) {
                wishvel[0] = 0;
                wishvel[1] = 0;
                wishvel[2] = 255;       //< this is upward thrust (bigger number, more thrust)
        } else {
                for (i=0 ; i<3 ; i++) {
                        wishvel[i] = scale * pml.forward[i]*pm->cmd.forwardmove + scale * pml.right[i]*pm->cmd.rightmove;

        VectorCopy (wishvel, wishdir);
        wishspeed = VectorNormalize(wishdir);

        PM_Accelerate (wishdir, wishspeed, pm_jetpackaccelerate);       //< use the jetpack acceleration factor

        PM_StepSlideMove( qtrue );      //< make this true to make gravity affect you

Ok, this is the function that will control how you move while you are using the jetpack. It is mostly a copy of the PM_FlyMove function with a couple of changes. These changes are noted in the comments in the code above. Now we also need to define the acceleration rate for the jetpack. This number affects how quickly we accelerate in the direction we are jetting. This variable is also in bg_pmove.c, but it's right up at the top. Search for "pm_flyaccelerate" and add the following line right after it. 
float   pm_flyaccelerate = 8.0f;
float   pm_jetpackaccelerate = 5.0f;


Now we need to make sure that our function is called when it is time to fly. Once again we will be adding a couple of lines to bg_pmove.c. Search for "else if ( pm->ps->powerups[PW_FLIGHT] )". It is in the function PmoveSingle. This group of if/else's determines what function calculates the movement for the player. We want to add our own jetpack movement here, so add the lines below... 
if ( pm->ps->powerups[PW_FLIGHT] ) {
        // flight powerup doesn't allow jump and has different friction

} else if ( pm->cmd.buttons & BUTTON_JETPACK ) {

} else if (pm->ps->pm_flags & PMF_GRAPPLE_PULL) {
        // We can wiggle a bit
} else if (pm->ps->pm_flags & PMF_TIME_WATERJUMP) {
} else if ( pm->waterlevel > 1 ) {
Basically, this just says to call our own jetpack movement function whenever the jetpack button is held down. 

4. Using it...

To use the jetpack you'll need to bind a key. The button I used for it is button 12 and I bound it to the second mouse button. To do that you'll need to type "bind mouse2 +button12". Now, whenever you hold down the right mouse button, your jetpack will propel you upwards. (Note: this jetpack works like the ones in Tribes. It will only propel you upwards while you are not also trying to jet forwards, backwards or sideways. This would be exceedingly easy to change, however, and will be left as an excercise for the reader.) 

4. Further enhancements...

>From here, you could add sound and visual effects. You could implement a fuel/energy system to limit the amount of jettin' one can do. You could also play with the upward thrust and the acceleration values. Anyways, enjoy. Write me with any questions.


Back to Club Lard
Back to Club Lard Game Modifications