diff options
Diffstat (limited to 'src/game/g_active.c')
-rw-r--r-- | src/game/g_active.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c index e4ae4d6a..eba06a2a 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -415,6 +415,8 @@ void ClientTimerActions( gentity_t *ent, int msec ) gclient_t *client; usercmd_t *ucmd; int aForward, aRight; + float maxspeed = + BG_FindLaunchSpeedForClass( ent->client->ps.stats[ STAT_PCLASS ] ); ucmd = &ent->client->pers.cmd; @@ -491,12 +493,38 @@ void ClientTimerActions( gentity_t *ent, int msec ) client->ps.stats[ STAT_MISC ] = MAX_POUNCE_SPEED; } +#define LAUNCH_TIME 2000 + switch( client->ps.weapon ) { case WP_DBUILD: case WP_DBUILD2: case WP_HBUILD: case WP_HBUILD2: + //charge up launch velocity + if( client->ps.stats[ STAT_MISC ] < maxspeed && ucmd->buttons & BUTTON_ATTACK ) + client->ps.stats[ STAT_MISC ] += ( 100.0f / LAUNCH_TIME ) * maxspeed; + + //not holding attack anymore and allowed to launch so build + if( !( ucmd->buttons & BUTTON_ATTACK ) && client->allowedToLaunch ) + { + if( !BG_FindInvertNormalForBuildable( client->ps.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT ) ) + client->ps.stats[ STAT_MISC ] = 0; + + G_ValidateBuild( ent, + client->ps.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT, + client->ps.stats[ STAT_MISC ] ); + + client->ps.stats[ STAT_BUILDABLE ] = BA_NONE; + client->allowedToLaunch = qfalse; + client->ps.stats[ STAT_MISC ] = 0; + } + + //cap speed + if( client->ps.stats[ STAT_MISC ] > maxspeed ) + client->ps.stats[ STAT_MISC ] = maxspeed; + + //set validity bit on buildable if( ( client->ps.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT ) > BA_NONE ) { int dist = BG_FindBuildDistForClass( ent->client->ps.stats[ STAT_PCLASS ] ); |