diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cgame/cg_weapons.c | 6 | ||||
-rw-r--r-- | src/game/g_active.c | 4 | ||||
-rw-r--r-- | src/game/g_cmds.c | 75 | ||||
-rw-r--r-- | src/game/g_local.h | 2 |
4 files changed, 64 insertions, 23 deletions
diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c index 1f06c35a..4a24f12c 100644 --- a/src/cgame/cg_weapons.c +++ b/src/cgame/cg_weapons.c @@ -1514,7 +1514,10 @@ void CG_NextWeapon_f( void ) return; if( cg.snap->ps.pm_flags & PMF_FOLLOW ) + { + trap_SendClientCommand( "followprev" ); return; + } cg.weaponSelectTime = cg.time; original = cg.weaponSelect; @@ -1555,7 +1558,10 @@ void CG_PrevWeapon_f( void ) return; if( cg.snap->ps.pm_flags & PMF_FOLLOW ) + { + trap_SendClientCommand( "follownext" ); return; + } cg.weaponSelectTime = cg.time; original = cg.weaponSelect; diff --git a/src/game/g_active.c b/src/game/g_active.c index 7ef3c810..516bac5a 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -360,8 +360,8 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) } } - if( ( client->buttons & BUTTON_ATTACK2 ) && !( client->oldbuttons & BUTTON_ATTACK2 ) ) - Cmd_FollowCycle_f( ent, 1 ); + if( ( client->buttons & BUTTON_USE_HOLDABLE ) && !( client->oldbuttons & BUTTON_USE_HOLDABLE ) ) + Cmd_Follow_f( ent ); } diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 1145bad1..5762d3f0 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1839,30 +1839,65 @@ void Cmd_Follow_f( gentity_t *ent ) { if( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) G_StopFollowing( ent ); - - return; - } + else + { + //follow somebody, anybody + int clientnum = ent->client->sess.spectatorClient; + int original = clientnum; + + do + { + clientnum++; + + if( clientnum >= level.maxclients ) + clientnum = 0; + + if( clientnum < 0 ) + clientnum = level.maxclients - 1; - trap_Argv( 1, arg, sizeof( arg ) ); - i = G_ClientNumberFromString( ent, arg ); - - if( i == -1 ) - return; + // can't follow self + if( &level.clients[ clientnum ] == ent->client ) + continue; - // can't follow self - if( &level.clients[ i ] == ent->client ) - return; + // can only follow connected clients + if( level.clients[ clientnum ].pers.connected != CON_CONNECTED ) + continue; - // can't follow another spectator - if( level.clients[ i ].sess.sessionTeam == TEAM_SPECTATOR ) - return; + // can't follow another spectator + if( level.clients[ clientnum ].sess.sessionTeam == TEAM_SPECTATOR ) + continue; - // first set them to spectator - if( ent->client->sess.sessionTeam != TEAM_SPECTATOR ) - G_ChangeTeam( ent, PTE_NONE ); + // this is good, we can use it + ent->client->sess.spectatorClient = clientnum; + ent->client->sess.spectatorState = SPECTATOR_FOLLOW; + break; + + } while( clientnum != original ); + } + } + else + { + trap_Argv( 1, arg, sizeof( arg ) ); + i = G_ClientNumberFromString( ent, arg ); + + if( i == -1 ) + return; + + // can't follow self + if( &level.clients[ i ] == ent->client ) + return; + + // can't follow another spectator + if( level.clients[ i ].sess.sessionTeam == TEAM_SPECTATOR ) + return; - ent->client->sess.spectatorState = SPECTATOR_FOLLOW; - ent->client->sess.spectatorClient = i; + // first set them to spectator + if( ent->client->sess.sessionTeam != TEAM_SPECTATOR ) + G_ChangeTeam( ent, PTE_NONE ); + + ent->client->sess.spectatorState = SPECTATOR_FOLLOW; + ent->client->sess.spectatorClient = i; + } } /* @@ -1877,7 +1912,7 @@ void Cmd_FollowCycle_f( gentity_t *ent, int dir ) // first set them to spectator if( ent->client->sess.spectatorState == SPECTATOR_NOT ) - G_ChangeTeam( ent, PTE_NONE ); + return; if( dir != 1 && dir != -1 ) G_Error( "Cmd_FollowCycle_f: bad dir %i", dir ); diff --git a/src/game/g_local.h b/src/game/g_local.h index 99f6ebf4..5f73424d 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -565,7 +565,7 @@ char *G_NewString( const char *string ); // void Cmd_Score_f( gentity_t *ent ); void G_StopFollowing( gentity_t *ent ); -void Cmd_FollowCycle_f( gentity_t *ent, int dir ); +void Cmd_Follow_f( gentity_t *ent ); // // g_physics.c |