Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
86 lines (67 sloc) 1.75 KB
void PM_AirMove (void)
{
int i;
vec3_t wishvel;
float fmove, smove;
vec3_t wishdir;
float wishspeed;
// Copy movement amounts
fmove = pmove->cmd.forwardmove;
smove = pmove->cmd.sidemove;
// Zero out z components of movement vectors
pmove->forward[2] = 0;
pmove->right[2] = 0;
// Renormalize
VectorNormalize (pmove->forward);
VectorNormalize (pmove->right);
// Determine x and y parts of velocity
for (i=0 ; i<2 ; i++)
{
wishvel[i] = pmove->forward[i]*fmove + pmove->right[i]*smove;
}
// Zero out z part of velocity
wishvel[2] = 0;
// Determine maginitude of speed of move
VectorCopy (wishvel, wishdir);
wishspeed = VectorNormalize(wishdir);
// Clamp to server defined max speed
if (wishspeed > pmove->maxspeed)
{
VectorScale (wishvel, pmove->maxspeed/wishspeed, wishvel);
wishspeed = pmove->maxspeed;
}
PM_AirAccelerate (wishdir, wishspeed, pmove->movevars->airaccelerate);
// Add in any base velocity to the current velocity.
VectorAdd (pmove->velocity, pmove->basevelocity, pmove->velocity );
PM_FlyMove ();
}
void PM_AirAccelerate (vec3_t wishdir, float wishspeed, float accel)
{
int i;
float addspeed, accelspeed, currentspeed, wishspd = wishspeed;
if (pmove->dead)
return;
if (pmove->waterjumptime)
return;
// Cap speed
//wishspd = VectorNormalize (pmove->wishveloc);
if (wishspd > 30)
wishspd = 30;
// Determine veer amount
currentspeed = DotProduct (pmove->velocity, wishdir);
// See how much to add
addspeed = wishspd - currentspeed;
// If not adding any, done.
if (addspeed <= 0)
return;
// Determine acceleration speed after acceleration
accelspeed = accel * wishspeed * pmove->frametime * pmove->friction;
// Cap it
if (accelspeed > addspeed)
accelspeed = addspeed;
// Adjust pmove vel.
for (i=0 ; i<3 ; i++)
{
pmove->velocity[i] += accelspeed*wishdir[i];
}
}
Something went wrong with that request. Please try again.