Skip to content

Commit

Permalink
game: add pmove_doublejump,jumpvelocity(max,scaleadd,timetreshold),st…
Browse files Browse the repository at this point in the history
…epheight,overbounce
  • Loading branch information
yumirak committed Mar 12, 2024
1 parent 51108bd commit 352ccb9
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 8 deletions.
12 changes: 12 additions & 0 deletions code/cgame/cg_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ vmCvar_t pmove_fixed;
//vmCvar_t cg_pmove_fixed;
vmCvar_t pmove_msec;
vmCvar_t pmove_JumpVelocity;
vmCvar_t pmove_JumpVelocityMax;
vmCvar_t pmove_JumpVelocityScaleAdd;
vmCvar_t pmove_JumpVelocityTimeThreshold;
vmCvar_t pmove_DoubleJump;
vmCvar_t pmove_StepHeight;
vmCvar_t pmove_Overbounce;
vmCvar_t pmove_WishSpeed;
vmCvar_t pmove_WalkAccel;
vmCvar_t pmove_AirAccel;
Expand Down Expand Up @@ -406,6 +412,12 @@ static cvarTable_t cvarTable[] = {
{ &pmove_fixed, "pmove_fixed", "0", CVAR_SYSTEMINFO},
{ &pmove_msec, "pmove_msec", "8", CVAR_SYSTEMINFO},
{ &pmove_JumpVelocity, "pmove_JumpVelocity", "275", CVAR_SYSTEMINFO},
{ &pmove_JumpVelocityMax, "pmove_JumpVelocityMax", "700", CVAR_SYSTEMINFO},
{ &pmove_JumpVelocityScaleAdd, "pmove_JumpVelocityScaleAdd", "275", CVAR_SYSTEMINFO},
{ &pmove_JumpVelocityTimeThreshold, "pmove_JumpVelocityTimeThreshold", "500.0", CVAR_SYSTEMINFO},
{ &pmove_DoubleJump, "pmove_DoubleJump", "0", CVAR_SYSTEMINFO},
{ &pmove_StepHeight, "pmove_StepHeight", "22", CVAR_SYSTEMINFO},
{ &pmove_Overbounce, "pmove_Overbounce", "0", CVAR_SYSTEMINFO},
{ &pmove_WishSpeed, "pmove_WishSpeed", "400", CVAR_SYSTEMINFO},
{ &pmove_WalkAccel, "pmove_WalkAccel", "10", CVAR_SYSTEMINFO},
{ &pmove_AirAccel, "pmove_AirAccel", "1", CVAR_SYSTEMINFO},
Expand Down
6 changes: 6 additions & 0 deletions code/game/bg_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ qboolean PM_SlideMove( qboolean gravity );
void PM_StepSlideMove( qboolean gravity );

extern vmCvar_t pmove_JumpVelocity;
extern vmCvar_t pmove_JumpVelocityMax;
extern vmCvar_t pmove_JumpVelocityScaleAdd;
extern vmCvar_t pmove_JumpVelocityTimeThreshold;
extern vmCvar_t pmove_DoubleJump;
extern vmCvar_t pmove_StepHeight;
extern vmCvar_t pmove_Overbounce;
extern vmCvar_t pmove_WishSpeed;
extern vmCvar_t pmove_WalkAccel;
extern vmCvar_t pmove_AirAccel;
Expand Down
32 changes: 27 additions & 5 deletions code/game/bg_pmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,17 @@ static qboolean PM_CheckJump( void ) {

pm->ps->groundEntityNum = ENTITYNUM_NONE;
pm->ps->velocity[2] = pmove_JumpVelocity.value; // JUMP_VELOCITY
// Double jump
if (pmove_DoubleJump.integer) {
float jump_zvel;
jump_zvel = Com_Clamp( 0,
pmove_JumpVelocityMax.value,
pm->ps->velocity[2] * pmove_JumpVelocityScaleAdd.value);

if (pm->ps->stats[STAT_JUMPTIME] > 0)
pm->ps->velocity[2] += jump_zvel;
}
pm->ps->stats[STAT_JUMPTIME] = pmove_JumpVelocityTimeThreshold.value;
PM_AddEvent( EV_JUMP );

if ( pm->cmd.forwardmove >= 0 ) {
Expand Down Expand Up @@ -519,8 +530,10 @@ static void PM_WaterMove( void ) {
PM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal,
pm->ps->velocity, OVERCLIP );

VectorNormalize(pm->ps->velocity);
VectorScale(pm->ps->velocity, vel, pm->ps->velocity);
if ( pmove_Overbounce.integer || VectorLength(pm->ps->velocity) > 1 ) {
VectorNormalize(pm->ps->velocity);
VectorScale(pm->ps->velocity, vel, pm->ps->velocity);
}
}

PM_SlideMove( qfalse );
Expand Down Expand Up @@ -785,9 +798,10 @@ static void PM_WalkMove( void ) {
PM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal,
pm->ps->velocity, OVERCLIP );

// don't decrease velocity when going up or down a slope
VectorNormalize(pm->ps->velocity);
VectorScale(pm->ps->velocity, vel, pm->ps->velocity);
if ( pmove_Overbounce.integer || VectorLength(pm->ps->velocity) > 1 ) {
VectorNormalize(pm->ps->velocity);
VectorScale(pm->ps->velocity, vel, pm->ps->velocity);
}

// don't do anything if standing still
if (!pm->ps->velocity[0] && !pm->ps->velocity[1]) {
Expand Down Expand Up @@ -1779,6 +1793,14 @@ static void PM_DropTimers( void ) {
pm->ps->torsoTimer = 0;
}
}

// drop post-jump counter
if ( pm->ps->stats[STAT_JUMPTIME] > 0 ) {
pm->ps->stats[STAT_JUMPTIME] -= pml.msec;
if ( pm->ps->stats[STAT_JUMPTIME] < 0 ) {
pm->ps->stats[STAT_JUMPTIME] = 0;
}
}
}

/*
Expand Down
3 changes: 2 additions & 1 deletion code/game/bg_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ typedef enum {
STAT_ARMOR,
STAT_DEAD_YAW, // look this direction when dead (FIXME: get rid of?)
STAT_CLIENTS_READY, // bit mask of clients wishing to exit the intermission (FIXME: configstring?)
STAT_MAX_HEALTH // health / armor limit, changeable by handicap
STAT_MAX_HEALTH, // health / armor limit, changeable by handicap
STAT_JUMPTIME
} statIndex_t;


Expand Down
4 changes: 2 additions & 2 deletions code/game/bg_slidemove.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void PM_StepSlideMove( qboolean gravity ) {
}

VectorCopy(start_o, down);
down[2] -= STEPSIZE;
down[2] -= pmove_StepHeight.value;
pm->trace (&trace, start_o, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask);
VectorSet(up, 0, 0, 1);
// never step up when you still have up velocity
Expand All @@ -271,7 +271,7 @@ void PM_StepSlideMove( qboolean gravity ) {
//VectorCopy (pm->ps->velocity, down_v);

VectorCopy (start_o, up);
up[2] += STEPSIZE;
up[2] += pmove_StepHeight.value;;

// test the player position if they were a stepheight higher
pm->trace (&trace, start_o, pm->mins, pm->maxs, up, pm->ps->clientNum, pm->tracemask);
Expand Down
6 changes: 6 additions & 0 deletions code/game/g_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,12 @@ extern vmCvar_t g_smoothClients;
extern vmCvar_t pmove_fixed;
extern vmCvar_t pmove_msec;
extern vmCvar_t pmove_JumpVelocity;
extern vmCvar_t pmove_JumpVelocityMax;
extern vmCvar_t pmove_JumpVelocityScaleAdd;
extern vmCvar_t pmove_JumpVelocityTimeThreshold;
extern vmCvar_t pmove_DoubleJump;
extern vmCvar_t pmove_StepHeight;
extern vmCvar_t pmove_Overbounce;
extern vmCvar_t pmove_WishSpeed;
extern vmCvar_t pmove_WalkAccel;
extern vmCvar_t pmove_AirAccel;
Expand Down
13 changes: 13 additions & 0 deletions code/game/g_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ vmCvar_t g_smoothClients;
vmCvar_t pmove_fixed;
vmCvar_t pmove_msec;
vmCvar_t pmove_JumpVelocity;
vmCvar_t pmove_JumpVelocityMax;
vmCvar_t pmove_JumpVelocityScaleAdd;
vmCvar_t pmove_JumpVelocityTimeThreshold;
vmCvar_t pmove_DoubleJump;
vmCvar_t pmove_StepHeight;
vmCvar_t pmove_Overbounce;
vmCvar_t pmove_WishSpeed;
vmCvar_t pmove_WalkAccel;
vmCvar_t pmove_AirAccel;
Expand Down Expand Up @@ -279,6 +285,13 @@ static cvarTable_t gameCvarTable[] = {
{ &pmove_msec, "pmove_msec", "8", CVAR_SYSTEMINFO, 0, qfalse},
{ &pmove_WishSpeed, "pmove_WishSpeed", "400", CVAR_SYSTEMINFO,0, qfalse},
{ &pmove_JumpVelocity, "pmove_JumpVelocity", "275", CVAR_SYSTEMINFO, 0, qfalse},
{ &pmove_JumpVelocityMax, "pmove_JumpVelocityMax", "700", CVAR_SYSTEMINFO, 0, qfalse},
{ &pmove_JumpVelocityScaleAdd, "pmove_JumpVelocityScaleAdd", "0.4", CVAR_SYSTEMINFO, 0, qfalse},
{ &pmove_JumpVelocityTimeThreshold, "pmove_JumpVelocityTimeThreshold", "500.0", CVAR_SYSTEMINFO, 0, qfalse},
{ &pmove_DoubleJump, "pmove_DoubleJump", "0", CVAR_SYSTEMINFO, 0, qfalse},
{ &pmove_StepHeight, "pmove_StepHeight", "22", CVAR_SYSTEMINFO, 0, qfalse},
{ &pmove_Overbounce, "pmove_Overbounce", "0", CVAR_SYSTEMINFO, 0, qfalse},

{ &pmove_WalkAccel, "pmove_WalkAccel", "10", CVAR_SYSTEMINFO,0, qfalse},
{ &pmove_AirAccel, "pmove_AirAccel", "1", CVAR_SYSTEMINFO, 0, qfalse},
{ &pmove_WaterAccel, "pmove_WaterAccel", "4", CVAR_SYSTEMINFO, 0, qfalse},
Expand Down

0 comments on commit 352ccb9

Please sign in to comment.