diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cgame/cg_event.c | 61 | ||||
-rw-r--r-- | src/game/bg_misc.c | 2 | ||||
-rw-r--r-- | src/game/bg_public.h | 2 | ||||
-rw-r--r-- | src/game/g_cmds.c | 40 |
4 files changed, 98 insertions, 7 deletions
diff --git a/src/cgame/cg_event.c b/src/cgame/cg_event.c index aa0f37cd..a8632cb4 100644 --- a/src/cgame/cg_event.c +++ b/src/cgame/cg_event.c @@ -367,6 +367,62 @@ static void CG_Obituary( entityState_t *ent ) CG_Printf( "%s died\n", targetName ); } + +/* +============= +CG_TeamJoinMessage + +Prints messages when players change teams +============= +*/ +static void CG_TeamJoinMessage( entityState_t *ent ) +{ + int player; + int team; + int oldteam; + char *playerName; + + + // Collect info + player = ent->eventParm; + team = ent->otherEntityNum; + oldteam = ent->otherEntityNum2; + + if( player < 0 || player >= MAX_CLIENTS ) + CG_Error( "CG_TeamJoinMessage: target out of range" ); + + playerName = cgs.clientinfo[player].name; + + // If no change occurred, print nothing + if( team == oldteam ) + return; + + // Print the appropriate message + if( team == TEAM_NONE ) + { + if( oldteam == TEAM_HUMANS ) + CG_Printf( "%s" S_COLOR_WHITE " left the humans\n", playerName ); + else if( oldteam == TEAM_ALIENS ) + CG_Printf( "%s" S_COLOR_WHITE " left the aliens\n", playerName ); + } + else if( oldteam == TEAM_NONE ) + { + if( team == TEAM_ALIENS ) + CG_Printf( "%s" S_COLOR_WHITE " joined the aliens\n", playerName ); + else if( team == TEAM_HUMANS ) + CG_Printf( "%s" S_COLOR_WHITE " joined the humans\n", playerName ); + } + else + { + if( oldteam == TEAM_HUMANS && team == TEAM_ALIENS ) + CG_Printf( "%s" S_COLOR_WHITE " abandoned the humans and joined the aliens\n", playerName ); + else if( oldteam == TEAM_ALIENS && team == TEAM_HUMANS ) + CG_Printf( "%s" S_COLOR_WHITE " abandoned the aliens and joined the humans\n", playerName ); + } +} + + + //========================================================================== /* @@ -917,6 +973,11 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) CG_Obituary( es ); break; + case EV_TEAMJOIN: + DEBUGNAME( "EV_TEAMJOIN" ); + CG_TeamJoinMessage( es ); + break; + case EV_GIB_PLAYER: DEBUGNAME( "EV_GIB_PLAYER" ); // no gibbing diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index db01881c..450844d5 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -2784,6 +2784,8 @@ char *eventnames[ ] = "EV_DEATH3", "EV_OBITUARY", + "EV_TEAMJOIN", // teamjoin message + "EV_GIB_PLAYER", // gib a previously living player "EV_BUILD_CONSTRUCT", diff --git a/src/game/bg_public.h b/src/game/bg_public.h index df1bc0ba..b8938c63 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -509,6 +509,8 @@ typedef enum EV_DEATH3, EV_OBITUARY, + EV_TEAMJOIN, // teamjoin message + EV_GIB_PLAYER, // gib a previously living player EV_BUILD_CONSTRUCT, diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 738239a7..c3a0af65 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -641,15 +641,25 @@ void Cmd_Team_f( gentity_t *ent ) qboolean force = G_admin_permission(ent, ADMF_FORCETEAMCHANGE); int aliens = level.numAlienClients; int humans = level.numHumanClients; + char *teamname, *oldteamname; + gentity_t *tempent; // stop team join spam if( level.time - ent->client->pers.teamChangeTime < 1000 ) return; if( oldteam == TEAM_ALIENS ) + { aliens--; + oldteamname = "aliens"; + } else if( oldteam == TEAM_HUMANS ) + { humans--; + oldteamname = "humans"; + } + else + oldteamname = "spectators"; trap_Argv( 1, s, sizeof( s ) ); @@ -660,7 +670,7 @@ void Cmd_Team_f( gentity_t *ent ) return; } - if( !Q_stricmp( s, "spectate" ) ) + if( !Q_stricmpn( s, "spec", 4 ) ) team = TEAM_NONE; else if( !force && oldteam == TEAM_NONE && g_maxGameClients.integer && level.numPlayingClients >= g_maxGameClients.integer ) @@ -670,7 +680,7 @@ void Cmd_Team_f( gentity_t *ent ) g_maxGameClients.integer ) ); return; } - else if( !Q_stricmp( s, "aliens" ) ) + else if( !Q_stricmpn( s, "alien", 5 ) ) { if( level.alienTeamLocked ) { @@ -693,7 +703,7 @@ void Cmd_Team_f( gentity_t *ent ) team = TEAM_ALIENS; } - else if( !Q_stricmp( s, "humans" ) ) + else if( !Q_stricmpn( s, "human", 5 ) ) { if( level.humanTeamLocked ) { @@ -742,7 +752,7 @@ void Cmd_Team_f( gentity_t *ent ) if( oldteam == team ) return; - //guard against build timer exploit + // guard against build timer exploit if( oldteam != TEAM_NONE && ent->client->sess.spectatorState == SPECTATOR_NOT && ( ent->client->ps.stats[ STAT_CLASS ] == PCL_ALIEN_BUILDER0 || ent->client->ps.stats[ STAT_CLASS ] == PCL_ALIEN_BUILDER0_UPG || @@ -756,13 +766,29 @@ void Cmd_Team_f( gentity_t *ent ) return; } - + // Apply the change G_ChangeTeam( ent, team ); + // Send the team join message event to everyone + tempent = G_TempEntity( ent->r.currentOrigin, EV_TEAMJOIN ); + tempent->s.eventParm = ent->s.number; + tempent->s.otherEntityNum = team; + tempent->s.otherEntityNum2 = oldteam; + tempent->r.svFlags = SVF_BROADCAST; + if( team == TEAM_ALIENS ) - trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE " joined the aliens\n\"", ent->client->pers.netname ) ); + teamname = "aliens"; else if( team == TEAM_HUMANS ) - trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE " joined the humans\n\"", ent->client->pers.netname ) ); + teamname = "humans"; + else + teamname = "spectators"; + + if( oldteam != TEAM_NONE && team != TEAM_NONE ) + G_LogPrintf( "team: %i %i %i: %s" S_COLOR_WHITE " left the %s and joined the %s\n", ent->s.number, team, oldteam, ent->client->pers.netname, oldteamname, teamname ); + else if( team == TEAM_NONE ) + G_LogPrintf( "team: %i %i %i: %s" S_COLOR_WHITE " left the %s\n", ent->s.number, team, oldteam, ent->client->pers.netname, oldteamname ); + else + G_LogPrintf( "team: %i %i %i: %s" S_COLOR_WHITE " joined the %s\n", ent->s.number, team, oldteam, ent->client->pers.netname, teamname ); } |