Jump to content

Remove Strafe Jumping (MP)


Recommended Posts

Hey all,

I'm wondering if anyone could give me some insight into removing strafe jumping and bunny hopping from the multiplayer FFA/Duel gamemodes. I've noticed Siege disables strafe jump and would like to replicate this in the other game types, but I can only assume this is more difficult than copy-pasting some code and rebuilding from the OpenJK source. I plan to do some investigating later tonight, but if someone has already encountered this I'd mad appreciate some help.

Link to comment

Okay so after some light investigating it was exactly as easy as I thought it would be thanks to some amazing comments.

For anyone that's curious, I found the following code within bg_pmove.c:

/*
==============
PM_Accelerate
Handles user intended acceleration
==============
*/
static void PM_Accelerate( vec3_t wishdir, float wishspeed, float accel )
{
	if (pm->gametype != GT_SIEGE
		|| pm->ps->m_iVehicleNum
		|| pm->ps->clientNum >= MAX_CLIENTS
		|| pm->ps->pm_type != PM_NORMAL)
	{ //standard method, allows "bunnyhopping" and whatnot
		int			i;
		float		addspeed, accelspeed, currentspeed;

		currentspeed = DotProduct (pm->ps->velocity, wishdir);
		addspeed = wishspeed - currentspeed;
		if (addspeed <= 0 && pm->ps->clientNum < MAX_CLIENTS) {
			return;
		}

		if (addspeed < 0)
		{
			accelspeed = (-accel)*pml.frametime*wishspeed;
			if (accelspeed < addspeed) {
				accelspeed = addspeed;
			}
		}
		else
		{
			accelspeed = accel*pml.frametime*wishspeed;
			if (accelspeed > addspeed) {
				accelspeed = addspeed;
			}
		}

		for (i=0 ; i<3 ; i++) {
			pm->ps->velocity[i] += accelspeed*wishdir[i];
		}
	}
	else
	{ //use the proper way for siege
		vec3_t		wishVelocity;
		vec3_t		pushDir;
		float		pushLen;
		float		canPush;

		VectorScale( wishdir, wishspeed, wishVelocity );
		VectorSubtract( wishVelocity, pm->ps->velocity, pushDir );
		pushLen = VectorNormalize( pushDir );

		canPush = accel*pml.frametime*wishspeed;
		if (canPush > pushLen) {
			canPush = pushLen;
		}

		VectorMA( pm->ps->velocity, canPush, pushDir, pm->ps->velocity );
	}
}

I removed the conditional, chipped away the bunny-hopping and voila:

/*
==============
PM_Accelerate
Handles user intended acceleration
==============
*/
static void PM_Accelerate( vec3_t wishdir, float wishspeed, float accel )
{
	vec3_t		wishVelocity;
	vec3_t		pushDir;
	float		pushLen;
	float		canPush;

	VectorScale( wishdir, wishspeed, wishVelocity );
	VectorSubtract( wishVelocity, pm->ps->velocity, pushDir );
	pushLen = VectorNormalize( pushDir );

	canPush = accel*pml.frametime*wishspeed;
	if (canPush > pushLen) {
		canPush = pushLen;
	}

	VectorMA( pm->ps->velocity, canPush, pushDir, pm->ps->velocity );
}



 

Link to comment

Dude that's so kool! It's awesome to see the actual code that makes bunnyhopping a possibility and the comments that the programmer wrote, "allows bunnyhopping" :D.

Thanks for sharing, and I'm glad you got it working like you were wanting! :)

 

ooeJack

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...