Change Jump Height and Player height?

Locked
bludshot
Posts: 65
Joined: Thu Nov 26, 2009 6:14 am

Change Jump Height and Player height?

Post by bludshot »

I'm looking to make the player taller and jump higher. Once they are taller, they won't be able to fit through some shorter doors or openings that they are currently short enough to fit through.

I already figured out how to change their viewheight which goes along with this.

I've searched through all the q3 modding tuts I know about and searched through the code for how to do this (at least with the jumping) and haven't found it yet. As far as the player height, I haven't looked too thoroughly yet but I figured I might as well ask while I'm asking about the jump height.

I also looked at the tremulous code and they have something called jumpMagnitude but, tbh I just couldn't figure out what they were doing (plus it's clear they use it for various classes to jump different heights and I don't need that ability).
bludshot
Posts: 65
Joined: Thu Nov 26, 2009 6:14 am

Re: Change Jump Height and Player height?

Post by bludshot »

Well, I haven't figured out how to change the jump height yet, but I figured out how to change the player height:

in bg_pmove.c in PM_CheckDuck() they have hard coded the standing and crouching heights in more than one place to 16 and 32.

So first (because hard coding values in multiple places is dumb) at the top of bg_public.h I added:

#define PLAYER_STANDHEIGHT 45
#define PLAYER_CROUCHHEIGHT 24

(I arrived at those numbers through testing a bunch of numbers in a test map with doorways and low ceilings till I found the exact height numbers I wanted)

Then in bg_pmove in PM_CheckDuck() I changed it like this (changed code is highlighted)

// stand up if possible
if (pm->ps->pm_flags & PMF_DUCKED)
{
// try to stand up
pm->maxs[2] = PLAYER_STANDHEIGHT; //was 32
pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, pm->ps->origin, pm->ps->clientNum, pm->tracemask );
if (!trace.allsolid)
pm->ps->pm_flags &= ~PMF_DUCKED;
}
}

if (pm->ps->pm_flags & PMF_DUCKED)
{
//blud fix player height
pm->maxs[2] = PLAYER_CROUCHHEIGHT; //was 16
pm->ps->viewheight = CROUCH_VIEWHEIGHT;
}
else
{


//blud fix player height
pm->maxs[2] = PLAYER_STANDHEIGHT; //was 32
pm->ps->viewheight = DEFAULT_VIEWHEIGHT;
}


If anyone has any ideas on how I can increase the jump height I am all ears :)
bludshot
Posts: 65
Joined: Thu Nov 26, 2009 6:14 am

Re: Change Jump Height and Player height?

Post by bludshot »

I figured out the jump height too now:

Our bg_pmove.c PM_CheckJump had already been altered a bit with some Tremulous code. So the fix I needed was:

VectorMA( pm->ps->velocity, JUMP_VELOCITY, normal, pm->ps->velocity );

And then I set JUMP_VELOCITY to 364.0f in bg_local.h (364 is a value I got from trial and error trying to jump onto a box in a test map I made.)

Lest this seem like a noobish issue to even have (which, sure, it is :P ), the problem I had was that another coder on the team had hardcoded the jump velocity there when he copied some of the tremulous code, thus... obscuring how and where one is supposed to change the jump height.

I'm only just learning about coding q3 mods, so a lot of the code is a huge mystery to me.


In the original q3 code (or ioq3 code) it would have been more obvious, and the solution would just be to go to bg_local.h and change #define JUMP_VELOCITY 270 to some other value...
Locked