示例#1
0
/*
===================
SV_ClientThink

the move fields specify an intended velocity in pix/sec
the angle fields specify an exact angular motion in degrees
===================
*/
void SV_ClientThink (void)
{
	vec3_t		v_angle;

	if (sv_player->v.movetype == MOVETYPE_NONE)
		return;

	onground = (int)sv_player->v.flags & FL_ONGROUND;

	origin = sv_player->v.origin;
	velocity = sv_player->v.velocity;

	DropPunchAngle ();

//
// if dead, behave differently
//
	if (sv_player->v.health <= 0)
		return;

//
// angles
// show 1/3 the pitch angle and all the roll angle
	cmd = host_client->cmd;
	angles = sv_player->v.angles;

	VectorAdd (sv_player->v.v_angle, sv_player->v.punchangle, v_angle);
	angles[ROLL] = V_CalcRoll (sv_player->v.angles, sv_player->v.velocity)*4;
	if (!sv_player->v.fixangle)
	{
		angles[PITCH] = -v_angle[PITCH]/3;
		angles[YAW] = v_angle[YAW];
	}

	if ( (int)sv_player->v.flags & FL_WATERJUMP )
	{
		SV_WaterJump ();
		return;
	}
//
// walk
//
	if ( (sv_player->v.waterlevel >= 2)
	&& (sv_player->v.movetype != MOVETYPE_NOCLIP) )
	{
		SV_WaterMove ();
		return;
	}

	SV_AirMove ();
}
示例#2
0
/*
===================
SV_ClientThink

the move fields specify an intended velocity in pix/sec
the angle fields specify an exact angular motion in degrees
===================
*/
static void
SV_ClientThink(client_t *client)
{
    edict_t *player = client->edict;
    vec3_t v_angle;

    if (player->v.movetype == MOVETYPE_NONE)
	return;

    DropPunchAngle(player->v.punchangle);

    /* if dead, behave differently */
    if (player->v.health <= 0)
	return;

    /* angles - show 1/3 the pitch angle and all the roll angle */
    VectorAdd(player->v.v_angle, player->v.punchangle, v_angle);
    player->v.angles[ROLL] = V_CalcRoll(player->v.angles, player->v.velocity) * 4;
    if (!player->v.fixangle) {
	player->v.angles[PITCH] = -v_angle[PITCH] / 3;
	player->v.angles[YAW] = v_angle[YAW];
    }

    if ((int)player->v.flags & FL_WATERJUMP) {
	SV_WaterJump(player);
	return;
    }

    /* walk */
    if (player->v.waterlevel >= 2 && player->v.movetype != MOVETYPE_NOCLIP) {
	SV_WaterMove(&client->cmd, player);
	return;
    }

    SV_AirMove(&client->cmd, player);
}
示例#3
0
/*
=============
SV_Physics_Step

Monsters freefall when they don't have a ground entity, otherwise
all movement is done with discrete steps.

This is also used for objects that have become still on the ground, but
will fall if the floor is pulled out from under them.
=============
*/
void SV_Physics_Step( edict_t *ent )
{
	qboolean	inwater;
	qboolean	wasonground;
	qboolean	wasonmover;
	vec3_t	mins, maxs;
	vec3_t	point;
	trace_t	trace;
	int	x, y;

	SV_WaterMove( ent );
	SV_CheckVelocity( ent );

	wasonground = (ent->v.flags & FL_ONGROUND);
	wasonmover = SV_CheckMover( ent );
	inwater = SV_CheckWater( ent );

	if( ent->v.flags & FL_FLOAT && ent->v.waterlevel > 0 )
	{
		float buoyancy = SV_Submerged( ent ) * ent->v.skin * host.frametime;

		SV_AddGravity( ent );
		ent->v.velocity[2] += buoyancy;
	}

	if( !wasonground && !( ent->v.flags & FL_FLY ) && (!( ent->v.flags & FL_SWIM ) || ent->v.waterlevel <= 0 ))
	{
		if( !inwater )
			SV_AddGravity( ent );
	}

	if( !VectorIsNull( ent->v.velocity ) || !VectorIsNull( ent->v.basevelocity ))
	{
		ent->v.flags &= ~FL_ONGROUND;

		if(( wasonground || wasonmover ) && ( ent->v.health > 0 || SV_CheckBottom( ent, MOVE_NORMAL )))
		{
			float	*vel = ent->v.velocity;
			float	control, speed, newspeed;
			float	friction;

			speed = sqrt(( vel[0] * vel[0] ) + ( vel[1] * vel[1] ));	// DotProduct2D

			if( speed )
			{
				friction = sv_friction->value * ent->v.friction;	// factor
				ent->v.friction = 1.0f; // g-cont. ???
				if( wasonmover ) friction *= 0.5f; // add a little friction

				control = (speed < sv_stopspeed->value) ? sv_stopspeed->value : speed;
				newspeed = speed - (host.frametime * control * friction);
				if( newspeed < 0 ) newspeed = 0;
				newspeed /= speed;

				vel[0] = vel[0] * newspeed;
				vel[1] = vel[1] * newspeed;
			}
		}

		VectorAdd( ent->v.velocity, ent->v.basevelocity, ent->v.velocity );
		SV_CheckVelocity( ent );

		SV_FlyMove( ent, host.frametime, NULL );
		if( ent->free ) return;

		SV_CheckVelocity( ent );
		VectorSubtract( ent->v.velocity, ent->v.basevelocity, ent->v.velocity );

		SV_CheckVelocity( ent );

		VectorAdd( ent->v.origin, ent->v.mins, mins );
		VectorAdd( ent->v.origin, ent->v.maxs, maxs );

		point[2] = mins[2] - 1.0f;

		for( x = 0; x <= 1; x++ )
		{
			if( ent->v.flags & FL_ONGROUND )
				break;

			for( y = 0; y <= 1; y++ )
			{
				point[0] = x ? maxs[0] : mins[0];
				point[1] = y ? maxs[1] : mins[1];

				trace = SV_Move( point, vec3_origin, vec3_origin, point, MOVE_NORMAL, ent );

				if( trace.startsolid )
				{
					ent->v.flags |= FL_ONGROUND;
					ent->v.groundentity = trace.ent;
					ent->v.friction = 1.0f;
					break;
				}
			}
		}

		SV_LinkEdict( ent, true );
	}
	else
	{
		if( svgame.globals->force_retouch != 0 )
		{
			trace = SV_Move( ent->v.origin, ent->v.mins, ent->v.maxs, ent->v.origin, MOVE_NORMAL, ent );

			// hentacle impact code
			if(( trace.fraction < 1.0f || trace.startsolid ) && SV_IsValidEdict( trace.ent ))
			{
				SV_Impact( ent, trace.ent, &trace );
				if( ent->free ) return;
			}
		}
	}

	if( !SV_RunThink( ent )) return;
	SV_CheckWaterTransition( ent );

}
示例#4
0
文件: sv_user.c 项目: Blzut3/Engoo
void SV_ClientThink (void)
{
	vec3_t		v_angle;
	int yeahdead;

	if (sv_player->v.movetype == MOVETYPE_NONE)
		return;

	if (cl.stats[STAT_HEALTH] <= 0) {	
		
			yeahdead = 1;
		
			if (!deathcam_yesiamdead){

				deathcam_angles[PITCH] = 50;
			//	deathcam_angles[YAW] = 20;
				deathcam_angles[ROLL] = 0;
				deathcam_whenidied = sv.time;
				//Con_Printf("I died at %f. sob.\n", deathcam_whenidied);
			}

			if (cl_diecam->value)
			deathcam_yesiamdead = cl_diecam->value;

	}
	else	
	{
			yeahdead = 0;
			deathcam_yesiamdead = 0;
	}

	onground = (int)sv_player->v.flags & FL_ONGROUND;

	origin = sv_player->v.origin;
	velocity = sv_player->v.velocity;


		

	DropPunchAngle ();


//
// if dead, behave differently
//

	// leilei - standstill hack
	if (sv_standstill->value)
	{
		float sample1, sample2, sample3, sample4, sample5;
		float divided;

		if (sv_maxspeed->value)
		divided = 1 / sv_maxspeed->value * sv_standstill->value;
		else
		divided = 1;	// avoiding a div0......

		sample1 = cmd.forwardmove * divided;
		sample2 = cmd.sidemove * divided;
		sample3 = cmd.upmove  * divided;
		sample4 = amouse_x * divided;
		sample5 = amouse_y * divided;
		
		if (sample1 < 0) sample1 *= -1;
		if (sample2 < 0) sample2 *= -1;
		if (sample3 < 0) sample3 *= -1;
		if (sample4 < 0) sample4 *= -1;
		if (sample5 < 0) sample5 *= -1;
		
		thestandstill = sample1 + sample2 + sample3 + sample4 + sample5 * 0.5;
		if (thestandstill > 1)
			thestandstill = 1;
		
		Cvar_SetValue (host_timescale,thestandstill); // slow it down!
	}


	if (sv_player->v.health <= 0)
		return;

//
// angles
// show 1/3 the pitch angle and all the roll angle
	cmd = host_client->cmd;


	angles = sv_player->v.angles;
	// leilei - aim lock
	if (aimlock){
		if ((lockedangle[YAW] + aimlockangle) > 360){
//			Con_Printf("goddamnit.\n");
			if (cl.viewangles[YAW] > (lockedangle[YAW] + aimlockangle > 360)) sv_player->v.angles[YAW] -= 360;
			if (cl.viewangles[YAW] > lockedangle[YAW] + aimlockangle) cl.viewangles[YAW] = lockedangle[YAW] + aimlockangle;
		}
		else
			if (cl.viewangles[YAW] > lockedangle[YAW] + aimlockangle) cl.viewangles[YAW] = lockedangle[YAW] + aimlockangle;
			if ((lockedangle[YAW] - aimlockangle) < 0){
			if (cl.viewangles[YAW] < lockedangle[YAW] - aimlockangle) cl.viewangles[YAW] = lockedangle[YAW] - aimlockangle + 360;
			if (cl.viewangles[YAW] < lockedangle[YAW] - aimlockangle) cl.viewangles[YAW] = lockedangle[YAW] - aimlockangle;
	//		Con_Printf("mother\n");
			}
			else
			if (cl.viewangles[YAW] < lockedangle[YAW] - aimlockangle) cl.viewangles[YAW] = lockedangle[YAW] - aimlockangle;

			// TODO: wrap angle, wrapangle
		if (cl.viewangles[PITCH] < lockedangle[PITCH] - aimlockangle) cl.viewangles[PITCH] = lockedangle[PITCH] - aimlockangle;
		if (cl.viewangles[PITCH] > lockedangle[PITCH] + aimlockangle) cl.viewangles[PITCH] = lockedangle[PITCH] + aimlockangle;
//		if (cl.viewangles[YAW] < lockedangle[YAW] - aimlockangle) cl.viewangles[YAW] = lockedangle[YAW] - aimlockangle;
//		if (cl.viewangles[YAW] > lockedangle[YAW] + aimlockangle) cl.viewangles[YAW] = lockedangle[YAW] + aimlockangle;
	

	}

	
	VectorAdd (sv_player->v.v_angle, sv_player->v.punchangle, v_angle);
	angles[ROLL] = V_CalcRoll (sv_player->v.angles, sv_player->v.velocity)*4;


	 if (!sv_player->v.fixangle)
	{
		angles[PITCH] = -v_angle[PITCH]/3;
		angles[YAW] = v_angle[YAW];

	}

	if ( (int)sv_player->v.flags & FL_WATERJUMP )
	{
		SV_WaterJump ();
		return;
	}
//
// walk
//
	if ( (sv_player->v.waterlevel >= 2)
	&& (sv_player->v.movetype != MOVETYPE_NOCLIP) )
	{
		SV_WaterMove ();
		return;
	}


	SV_AirMove ();
}