Double jump


(Chruker) #1

Hi

After have used my evening trying to track down where and how I could implement some shrub-like double jumping, I finally have somewhat succeded. But here goes:

In bg_pmove.c function PmoveSingle (around line 5400). Find the subsection that looks like this:


	} else if ( pml.walking && !(pm->ps->eFlags & EF_MOUNTEDTANK)) {
		// walking on ground
		PM_WalkMove();
	} else if (!(pm->ps->eFlags & EF_MOUNTEDTANK)) {
		// airborne
		PM_AirMove();
	}

and change it to


	} else if ( pml.walking && !(pm->ps->eFlags & EF_MOUNTEDTANK)) {
		// walking on ground
		PM_WalkMove();
	} else if (!(pm->ps->eFlags & EF_MOUNTEDTANK)) {
		// CHRUKER: Double-jumping
		if ((pm->cmd.serverTime - pm->pmext->jumpTime < 850) && pm->cmd.doubleTap == DT_UP)
			pm->ps->velocity[2] = JUMP_VELOCITY * 1.4f;

		// airborne
		PM_AirMove();
	}

There are still some differences between shrubet-style and this:

  • No double jumping from water here. However duplicating this new code into one of the other if’s above would probably solve it.
  • The window in which you have to double tap, seems a lot shorter than the 850 used here.
  • Also it feels a lot easier to strafe jump here than with shrub.

Anyhoo, I thought I would share this with you guys.
[/b]


(dark-tim) #2

how can i turn this code on/of with my cvar (iv’e created already an cvar named g_doublejump)

[edit]

i was trying and now i get this when compiling:

error C2224: left of ‘.integer’ must have struct/union type… :banghead: what to do?


(Jaquboss) #3

look at other cvars !
search for example g_dowarmup …


(dark-tim) #4

error C2224: left of ‘.integer’ must have struct/union type… what to do?

everytime when i use .integer i’m getting this error


(jaybird) #5

I’m at work and don’t have my source here in front of me, but implementing this is actually not too difficult. It involves adding a cg_ Cvar as well. When I get home I’ll post what changes/additions you’re going to need to get this working.


(jaybird) #6

ok here it is:

in g_main.c:


// add the cvar
vmCvar_t g_doublejump;

// and, where it belongs
{ &g_doublejump, "g_doublejump", "0", CVAR_SERVERINFO, 0, qfalse, qfalse },

also, in g_local.h


// where it belongs...
extern vmCvar_t g_doublejump;

What makes this work is adding the variable to the cgame as well, since the bg_ files are shared between both server and client code.

in cg_main.c


// where it belong...
vmCvar_t cg_doublejump;

// and where it belongs...
{ &cg_doublejump, "g_doublejump", "0", 0 },

The missing c in the second parameter is not a typo.

and in cg_local.h


extern vmCvar_t cg_doublejump;

Now, back in the game dir, in bg_pmove.c…


//somewhere around line 5119, inside of PmoveSingle
#ifdef CGAMEDLL
extern vmCvar_t cg_doublejump;
int doublejump = cg_doublejump.integer;
#elif GAMEDLL
extern vmCvar_t g_doublejump;
int doublejump = g_doublejump.integer;
#endif

// Now, where the doublejump would go, write it like this:
      if (doublejump == 1 && (pm->cmd.serverTime - pm->pmext->jumpTime < 850) && pm->cmd.doubleTap == DT_UP)
         pm->ps->velocity[2] = JUMP_VELOCITY * 1.4f;

And there you go. Compile and you got it. You can turn this variable on and off through rcon.


(dark-tim) #7

every time when i use .integer i get an error! :angry:
error C2224: left of ‘.integer’ must have struct/union type…

i know how to add cvars but i don’t know what to do with this error :’(


(SCDS_reyalP) #8

there is a semicolon missing in the code pasted above


#elif GAMEDLL
extern vmCvar_t g_doublejump
int doublejump = g_doublejump.integer;
#endif 


(jaybird) #9

Fixed ;]

Perhaps post the piece of code you’re getting the error on?


(Jaquboss) #10

oh Darktim , you should match case , and place your cvar to g_local.h as well…
edit: this is bg_pmove.c , look how is done g_gametype and cg_gametype , you need to have two sync cvars , one for client second for server…


(dark-tim) #11

oh Darktim , you should match case , and place your cvar to g_local.h as well…

I DID :blah:
but the problem is solved now :drink:


(jet Pilot) #12

Spent a bunch of time trying to figure out why it used to work but didn’t
I’ve since discovered that if you disable Double-Tap prone, pm->cmd.doubleTap never gets set to ANYTHING, and kills double jump


(d@Ve) #13

Ok ive tried this and im gettin some errors when compiling the cgame_mp_x86.dll

src\game\bg_pmove.c(5121) : error C2143: syntax error : missing ';' before 'type'
src\game\bg_pmove.c(5122) : error C2143: syntax error : missing ';' before 'type'
src\game\bg_pmove.c(5398) : error C2065: 'doublejump' : undeclared identifier
Error executing cl.exe.

lines 5121 & 5122 are

	extern vmCvar_t cg_doublejump;
	int doublejump = cg_doublejump.integer;

line 5398 are

      if (doublejump == 1 && (pm->cmd.serverTime - pm->pmext->jumpTime < 850) && pm->cmd.doubleTap == DT_UP) 

And im gettin these errors when compiling the qagame_mp_x86.dll

src\game\bg_pmove.c(5124) : error C2143: syntax error : missing ';' before 'type'
src\game\bg_pmove.c(5125) : error C2143: syntax error : missing ';' before 'type'
src\game\bg_pmove.c(5398) : error C2065: 'doublejump' : undeclared identifier
Error executing cl.exe.

lines 5124 & 5125 are

	extern vmCvar_t g_doublejump;
	int doublejump = g_doublejump.integer;

line 5398 are

      if (doublejump == 1 && (pm->cmd.serverTime - pm->pmext->jumpTime < 850) && pm->cmd.doubleTap == DT_UP) 

I didnt get any errors before i added the cvars, maybe it was somethin i messed up? Anybody see any errors in the codes i posted?

btw thankz for the snippet Chruker…any updates on the php server info stuff?

Thankz,
d@Ve


(Chruker) #14

Can you show lines 5118-ish to 5130-ish?

About the server info stuff. It was the coloration, right?


(d@Ve) #15

ok ive gotten rid of the syntax errors…now the only error it gives is
src\game\bg_pmove.c(5398) : error C2065: ‘doublejump’ : undeclared identifier
when i compile either dll

	PM_DropTimers();

	if (pml.ladder) {
		PM_LadderMove();
	} else if (pm->ps->pm_flags & PMF_TIME_WATERJUMP) {
		PM_WaterJumpMove();
	} else if ( pm->waterlevel > 1 ) {
		// swimming
		PM_WaterMove();
	} else if ( pml.walking && !(pm->ps->eFlags & EF_MOUNTEDTANK)) {
		// walking on ground
		PM_WalkMove();
	} else if (!(pm->ps->eFlags & EF_MOUNTEDTANK)) {

//CHRUKER & jaybird MOD
      if (doublejump == 1 && (pm->cmd.serverTime - pm->pmext->jumpTime < 850) && pm->cmd.doubleTap == DT_UP) 
         pm->ps->velocity[2] = JUMP_VELOCITY * 1.4f;
//CHRUKER & jaybird MOD

		// airborne
		PM_AirMove();
	}

i completely redid everything u and jaybird posted twice and i still get ‘doublejump’ : undeclared identifier error…wtf is this things problem lol…i guess ill start over a 3rd time, maybe a 4th and 5th lol i’ve got about another 24 hrs of computer time left in me

Hey i was readin another post about shovin a player with the function button
Jaquboss posted it here back in Nov. 04 ( http://splashdamage.com/index.php?name=pnPHPbb2&file=viewtopic&t=10299 ) he refferenced a cpl files i dont seam to have in my et source codes…these 2 here ( g_func_desc.h, g_funcs.h ) am i supposed to make these or what? if u know.

…yeah the colorization and the levelshit bein displayed for each map


(Chruker) #16

Can you show us where doublejump gets declared


(jaybird) #17

Wow I’m looking at that code and thinking “What the hell was I thinking?”. Why the hell did I define cg_doublejump?

This implementation of double jump is pretty basic, and not very good (you can actually get a triple jump out of it). If you want to just get this working, take out the doublejump == 1 && portion and it should work. Note that you cannot turn it off then. If you want this thing able to be toggleable, you might want to read up on the cvar stuff on code3arena.


(d@Ve) #18
/*
================
PmoveSingle

================
*/
void trap_SnapVector( float *v );

void PmoveSingle (pmove_t *pmove) {
	// RF, update conditional values for anim system
	BG_AnimUpdatePlayerStateConditions( pmove );

//CHRUKER & jaybird MOD
#ifdef CGAMEDLL 
extern vmCvar_t cg_doublejump; 
int doublejump = cg_doublejump.integer; 
#elif GAMEDLL 
extern vmCvar_t g_doublejump; 
int doublejump = g_doublejump.integer; 
#endif
//CHRUKER & jaybird MOD

	pm = pmove;

	// this counter lets us debug movement problems with a journal
	// by setting a conditional breakpoint fot the previous frame
	c_pmove++;

it was workin but i wanted to add a cvar…im wonderin why other ppl got this workin and i cant…i guess ill go on over there n read some more
thankz for te help fellas :smiley:

ive only been coding in vc++ for almost 26 hours now lol…looks pretty similar to php n vb…stuff like that…im catchn on perty quick


(d@Ve) #19

ok ive read it let me get this strait…to add a new game cvar all u have to do is

open g_main.c
and add where other vmCvar_t 's are


vmCvar_t	g_doublejump;

add in cvarTable_t gameCvarTable[] = {


{ &g_doublejump, "g_doublejump", "0", CVAR_ROM | CVAR_SERVERINFO, 0, qfalse },

open g_local.c
and add where other vmCvar_t 's are


extern	vmCvar_t	g_doublejump;

open bg_pmove.c (or whatever file ur usin the cvar in)
and add


#ifdef GAMEDLL 
extern vmCvar_t g_doublejump; 
int doublejump = g_doublejump.integer; 
#endif

add where u want the cvar to control a function


if(g_doublejump.integer == 1) {
do it
} else if {
dont do it
}

am i right? or am i way off


(Chruker) #20

I think this part of your code:

//CHRUKER & jaybird MOD 
#ifdef CGAMEDLL 
extern vmCvar_t cg_doublejump; 
int doublejump = cg_doublejump.integer; 
#elif GAMEDLL 
extern vmCvar_t g_doublejump; 
int doublejump = g_doublejump.integer; 
#endif 
//CHRUKER & jaybird MOD 

should be:

//CHRUKER & jaybird MOD 
#ifdef CGAMEDLL 
extern vmCvar_t cg_doublejump; 
#define doublejump cg_doublejump.integer; 
#elif GAMEDLL 
extern vmCvar_t g_doublejump; 
#define doublejump g_doublejump.integer; 
#endif 
//CHRUKER & jaybird MOD