Skip to content

Commit

Permalink
Simplify the Spitfire's flight.
Browse files Browse the repository at this point in the history
  • Loading branch information
dGr8LookinSparky committed Dec 25, 2019
1 parent 5ed78c8 commit a8b1e58
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 57 deletions.
70 changes: 19 additions & 51 deletions src/game/bg_pmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ float pm_flyaccelerate = 4.0f;
float pm_friction = 6.0f;
float pm_waterfriction = 1.0f;
float pm_flightfriction = 4.0f;
float pm_spitfire_flyfriction = 3.5f;
float pm_spitfire_flyfriction = 3.0f;
float pm_spitfire_flywalkfriction = 5.0f;
float pm_spectatorfriction = 5.0f;

Expand Down Expand Up @@ -880,15 +880,6 @@ static float PM_CmdScale( usercmd_t *cmd, qboolean zFlight )
modifier *= LEVEL0_POUNCE_SPEED_MOD;
}

// the spitfire strafes and moves backwards slower when flying
if( pm->ps->weapon == WP_ASPITFIRE &&
pm->ps->groundEntityNum == ENTITYNUM_NONE )
{
cmd->rightmove *= SPITFIRE_SIDE_MODIFIER;
if( cmd->forwardmove < 0 )
cmd->forwardmove *= SPITFIRE_BACK_MODIFIER;
}

//slow the player if slow locked
if( pm->ps->stats[ STAT_STATE ] & SS_SLOWLOCKED )
modifier *= ABUILDER_BLOB_SPEED_MOD;
Expand Down Expand Up @@ -2086,7 +2077,7 @@ static void PM_SpitfireFlyMove( void )
vec3_t wishdir;
float scale;
float accel = BG_Class( pm->ps->stats[ STAT_CLASS ] )->airAcceleration;
qboolean isgliding = qfalse;
qboolean isflying = qfalse;
qboolean basicflight = qfalse;
qboolean ascend = qfalse;
qboolean upmovePressed = qfalse;
Expand Down Expand Up @@ -2136,8 +2127,8 @@ static void PM_SpitfireFlyMove( void )
pm->ps->persistant[PERS_JUMPTIME] > SPITFIRE_ASCEND_REPEAT &&
!freefall )
{
accel = SPITFIRE_GLIDE_ACCEL;
isgliding = qtrue;
accel = SPITFIRE_FLY_ACCEL;
isflying = qtrue;
}
}

Expand Down Expand Up @@ -2170,43 +2161,18 @@ static void PM_SpitfireFlyMove( void )
for( i = 0; i < 3; i++ )
wishvel[ i ] = scale * pml.forward[ i ] * pm->cmd.forwardmove;

if( isgliding )
{
float pathspeed = VectorLength( pm->ps->velocity);

//apply gravity
pm->ps->velocity[ 2 ] -= PM_Gravity(pm->ps) * pml.frametime;
//normal slowdown
PM_Friction( );

if( pathspeed )
{
vec3_t pathdir, pathup, pathang;
float liftmod = PM_Gravity(pm->ps) / pow( ( SPITFIRE_GLIDE_MOD ), 2 );
float dragmod = liftmod / tan( DEG2RAD( SPITFIRE_GLIDE_ANGLE ) );
float dragmag = dragmod * pow( pathspeed, 2 );
float liftmag = liftmod * pow( pathspeed, 2 );

vectoangles( pm->ps->velocity, pathang );
AngleVectors( pathang, pathdir, NULL, pathup );
//apply drag
VectorMA( pm->ps->velocity, -( dragmag * pml.frametime ), pathdir,
pm->ps->velocity );

//apply lift
VectorMA( pm->ps->velocity, liftmag * pml.frametime, pathup,
pm->ps->velocity );
}
} else
if(!isflying)
{
//normal slowdown
PM_Friction( );

// hovering
// precise hovering
if( basicflight &&
( pm->cmd.buttons & BUTTON_WALKING ) )
{
int bobmove, old;

// restrict ascent for hovering
// restrict ascent for precise hovering
if( wishvel[ 2 ] > 0 )
wishvel[ 2 ] = 0;

Expand All @@ -2220,7 +2186,7 @@ static void PM_SpitfireFlyMove( void )
VectorCopy( wishvel, wishdir );
wishspeed = VectorNormalize( wishdir );

if( !isgliding || scale )
if( !isflying || scale )
{
PM_Accelerate( wishdir, wishspeed, accel );
}
Expand Down Expand Up @@ -2267,7 +2233,7 @@ static void PM_SpitfireFlyMove( void )
}

if( ( upmovePressed || freefall ) &&
!isgliding )
!isflying )
gravity = qtrue;

PM_StepSlideMove( gravity, qfalse );
Expand Down Expand Up @@ -6654,12 +6620,14 @@ void PmoveSingle( pmove_t *pmove )
// entering / leaving water splashes
PM_WaterEvents( );

// snap some parts of playerstate to save network bandwidth
#ifdef Q3_VM
trap_SnapVector( pm->ps->velocity );
#else
Q_SnapVector( pm->ps->velocity );
#endif
if(pm->ps->pm_type != PM_SPITFIRE_FLY) {
// snap some parts of playerstate to save network bandwidth
#ifdef Q3_VM
trap_SnapVector( pm->ps->velocity );
#else
Q_SnapVector( pm->ps->velocity );
#endif
}
}


Expand Down
10 changes: 4 additions & 6 deletions src/game/tremulous.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,10 @@ along with Tremulous; if not, see <https://www.gnu.org/licenses/>
#define SPITFIRE_PAYLOAD_DISCHARGE_TIME ( SPITFIRE_POUNCE_TIME + SPITFIRE_POUNCE_REPEAT )
#define SPITFIRE_POUNCE_MAX_STAMINA ( SPITFIRE_POUNCE_TIME * 20 )
#define SPITFIRE_POUNCE_STAMINA_RESTORE 15
#define SPITFIRE_BACK_MODIFIER 0.8f
#define SPITFIRE_SIDE_MODIFIER 0.9f
#define SPITFIRE_AIRSPEED_MOD 0.36f
#define SPITFIRE_GLIDE_ANGLE 15.0f //optimal angle of attack
#define SPITFIRE_GLIDE_MOD 1000
#define SPITFIRE_GLIDE_ACCEL 3.8f
#define SPITFIRE_BACK_MODIFIER 1.5f
#define SPITFIRE_SIDE_MODIFIER 2.0f
#define SPITFIRE_AIRSPEED_MOD 0.45f
#define SPITFIRE_FLY_ACCEL 3.0f
#define SPITFIRE_HOVER_BOB 0.001f //for view bobbing from hovering
#define SPITFIRE_GAS_TRAIL_REPEAT 300
#define SPITFIRE_GAS_TRAIL_RELOAD_TIME 0
Expand Down

0 comments on commit a8b1e58

Please sign in to comment.