engine/EngineServerUser.c
/*	The move fields specify an intended velocity in pix/sec.
	The angle fields specify an exact angular motion in degrees.
*/
The move fields specify an intended velocity in pix/sec.
The angle fields specify an exact angular motion in degrees.
The move fields specify an intended velocity in pix / sec . The angle fields specify an exact angular motion in degrees .
void SV_ClientThink (void)
{
	int	i;
	float fLength,fmove,smove,addspeed,accelspeed,currentspeed;
	MathVector3f_t vAngle, vWishVelocity;
	if(sv_player->v.movetype == MOVETYPE_NONE)
		return;
	bIsOnGround	= sv_player->v.flags & FL_ONGROUND;
	origin		= sv_player->v.origin;
	velocity	= sv_player->v.velocity;
	fLength = Math_VectorNormalize (sv_player->v.punchangle);
	fLength -= 10*host_frametime;
	if(fLength < 0)
		fLength = 0;
	Math_VectorScale(sv_player->v.punchangle,fLength,sv_player->v.punchangle);
	if(sv_player->v.iHealth <= 0)
		return;
	cmd = host_client->cmd;
	angles = sv_player->v.angles;
	Math_VectorAdd (sv_player->v.v_angle, sv_player->v.punchangle, vAngle);
	angles[ROLL] = V_CalcRoll (sv_player->v.angles, sv_player->v.velocity)*4;
	if (!sv_player->v.bFixAngle)
	{
		angles[PITCH]	= -vAngle[PITCH]/3.0f;
		angles[YAW]		= vAngle[YAW];
	}
	if(sv_player->v.flags & FL_WATERJUMP)
	{
		if (sv.time > sv_player->v.dTeleportTime || !sv_player->v.waterlevel)
		{
			sv_player->v.flags = sv_player->v.flags & ~FL_WATERJUMP;
			sv_player->v.dTeleportTime = 0;
		}
		sv_player->v.velocity[0] = sv_player->v.movedir[0];
		sv_player->v.velocity[1] = sv_player->v.movedir[1];
		return;
	}
	if(sv_player->v.movetype == MOVETYPE_NOCLIP && sv_altnoclip.value)
	{
		Math_AngleVectors(sv_player->v.v_angle,forward,right,up);
		velocity[0] = forward[0]*cmd.forwardmove+right[0]*cmd.sidemove;
		velocity[1] = forward[1]*cmd.forwardmove+right[1]*cmd.sidemove;
		velocity[2] = forward[2]*cmd.forwardmove+right[2]*cmd.sidemove;
		velocity[2] += cmd.upmove*2; 
		if(Math_Length(velocity) > sv_maxspeed.value)
		{
			Math_VectorNormalize(velocity);
			Math_VectorScale(velocity,sv_maxspeed.value,velocity);
		}
	}
	else if(sv_player->v.waterlevel >= 2 && sv_player->v.movetype != MOVETYPE_NOCLIP)
		SV_WaterMove ();
	else
	{
		Math_AngleVectors(sv_player->v.angles, forward, right, up);
		fmove = cmd.forwardmove;
		smove = cmd.sidemove;
		if (sv.time < sv_player->v.dTeleportTime && fmove < 0)
			fmove = 0;
		for(i = 0; i < 3; i++)
			vWishVelocity[i] = forward[i]*fmove+right[i]*smove;
		if(sv_player->v.movetype != MOVETYPE_WALK)
			vWishVelocity[2] = cmd.upmove;
		else
			vWishVelocity[2] = 0;
		Math_VectorCopy(vWishVelocity,wishdir);
		wishspeed = Math_VectorNormalize(wishdir);
		if(wishspeed > sv_maxspeed.value)
		{
			Math_VectorScale(vWishVelocity,sv_maxspeed.value/wishspeed,vWishVelocity);
			wishspeed = sv_maxspeed.value;
		}
		if(sv_player->v.movetype == MOVETYPE_NOCLIP)
			Math_VectorCopy(vWishVelocity, velocity);
		else if(bIsOnGround)
		{
			Physics_AddFriction(sv_player,velocity,origin);
			currentspeed = Math_DotProduct (velocity, wishdir);
			addspeed = wishspeed - currentspeed;
			if(addspeed <= 0)
				return;
			accelspeed = sv_accelerate.value*host_frametime*wishspeed;
			if (accelspeed > addspeed)
				accelspeed = addspeed;
			for(i = 0; i < 3; i++)
				velocity[i] += accelspeed*wishdir[i];
		}
		else
			SV_AirAccelerate(vWishVelocity);
	}
}
void SV_ClientThink ( void ) { int i ; float fLength , fmove , smove , addspeed , accelspeed , currentspeed ; MathVector3f_t vAngle , vWishVelocity ; if ( sv_player -> v . movetype == MOVETYPE_NONE ) return ; bIsOnGround = sv_player -> v . flags & FL_ONGROUND ; origin = sv_player -> v . origin ; velocity = sv_player -> v . velocity ; fLength = Math_VectorNormalize ( sv_player -> v . punchangle ) ; fLength -= 10 * host_frametime ; if ( fLength < 0 ) fLength = 0 ; Math_VectorScale ( sv_player -> v . punchangle , fLength , sv_player -> v . punchangle ) ; if ( sv_player -> v . iHealth <= 0 ) return ; cmd = host_client -> cmd ; angles = sv_player -> v . angles ; Math_VectorAdd ( sv_player -> v . v_angle , sv_player -> v . punchangle , vAngle ) ; angles [ ROLL ] = V_CalcRoll ( sv_player -> v . angles , sv_player -> v . velocity ) * 4 ; if ( ! sv_player -> v . bFixAngle ) { angles [ PITCH ] = - vAngle [ PITCH ] / 3.0f ; angles [ YAW ] = vAngle [ YAW ] ; } if ( sv_player -> v . flags & FL_WATERJUMP ) { if ( sv . time > sv_player -> v . dTeleportTime || ! sv_player -> v . waterlevel ) { sv_player -> v . flags = sv_player -> v . flags & ~ FL_WATERJUMP ; sv_player -> v . dTeleportTime = 0 ; } sv_player -> v . velocity [ 0 ] = sv_player -> v . movedir [ 0 ] ; sv_player -> v . velocity [ 1 ] = sv_player -> v . movedir [ 1 ] ; return ; } if ( sv_player -> v . movetype == MOVETYPE_NOCLIP && sv_altnoclip . value ) { Math_AngleVectors ( sv_player -> v . v_angle , forward , right , up ) ; velocity [ 0 ] = forward [ 0 ] * cmd . forwardmove + right [ 0 ] * cmd . sidemove ; velocity [ 1 ] = forward [ 1 ] * cmd . forwardmove + right [ 1 ] * cmd . sidemove ; velocity [ 2 ] = forward [ 2 ] * cmd . forwardmove + right [ 2 ] * cmd . sidemove ; velocity [ 2 ] += cmd . upmove * 2 ; if ( Math_Length ( velocity ) > sv_maxspeed . value ) { Math_VectorNormalize ( velocity ) ; Math_VectorScale ( velocity , sv_maxspeed . value , velocity ) ; } } else if ( sv_player -> v . waterlevel >= 2 && sv_player -> v . movetype != MOVETYPE_NOCLIP ) SV_WaterMove ( ) ; else { Math_AngleVectors ( sv_player -> v . angles , forward , right , up ) ; fmove = cmd . forwardmove ; smove = cmd . sidemove ; if ( sv . time < sv_player -> v . dTeleportTime && fmove < 0 ) fmove = 0 ; for ( i = 0 ; i < 3 ; i ++ ) vWishVelocity [ i ] = forward [ i ] * fmove + right [ i ] * smove ; if ( sv_player -> v . movetype != MOVETYPE_WALK ) vWishVelocity [ 2 ] = cmd . upmove ; else vWishVelocity [ 2 ] = 0 ; Math_VectorCopy ( vWishVelocity , wishdir ) ; wishspeed = Math_VectorNormalize ( wishdir ) ; if ( wishspeed > sv_maxspeed . value ) { Math_VectorScale ( vWishVelocity , sv_maxspeed . value / wishspeed , vWishVelocity ) ; wishspeed = sv_maxspeed . value ; } if ( sv_player -> v . movetype == MOVETYPE_NOCLIP ) Math_VectorCopy ( vWishVelocity , velocity ) ; else if ( bIsOnGround ) { Physics_AddFriction ( sv_player , velocity , origin ) ; currentspeed = Math_DotProduct ( velocity , wishdir ) ; addspeed = wishspeed - currentspeed ; if ( addspeed <= 0 ) return ; accelspeed = sv_accelerate . value * host_frametime * wishspeed ; if ( accelspeed > addspeed ) accelspeed = addspeed ; for ( i = 0 ; i < 3 ; i ++ ) velocity [ i ] += accelspeed * wishdir [ i ] ; } else SV_AirAccelerate ( vWishVelocity ) ; } }
The move fields specify an intended velocity in pix/sec.
The move fields specify an intended velocity in pix / sec .
// If dead, behave differently // Show 1/3 the pitch angle and all the roll angle //johnfitz -- alternate noclip //doubled to match running speed // Hack to not let you back into teleporter // Not on ground, so little effect on velocity //johnfitz