diff --git a/reaction/game/g_client.c b/reaction/game/g_client.c index b93c8728..e7736dd3 100644 --- a/reaction/game/g_client.c +++ b/reaction/game/g_client.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.29 2002/02/02 20:39:09 slicer +// Matchmode: Adding Captains +// // Revision 1.28 2002/02/01 01:00:36 slicer // Adding Matchmode: just a few basics and files... // @@ -1129,8 +1132,10 @@ void ClientBegin( int clientNum ) { //Slicer : Reseting matchmode vars //Note: Each time a player changes team, this will also be called.. - client->pers.captain = TEAM_FREE; - client->pers.sub = TEAM_FREE; + if(g_matchmode.integer ) { + client->pers.captain = TEAM_FREE; + client->pers.sub = TEAM_FREE; + } client->pers.connected = CON_CONNECTED; client->pers.enterTime = level.time; diff --git a/reaction/game/g_cmds.c b/reaction/game/g_cmds.c index 5ea459f1..f0f858c2 100644 --- a/reaction/game/g_cmds.c +++ b/reaction/game/g_cmds.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.44 2002/02/02 20:39:09 slicer +// Matchmode: Adding Captains +// // Revision 1.43 2002/02/02 16:34:02 slicer // Matchmode.. // @@ -685,7 +688,9 @@ void SetTeam( gentity_t *ent, char *s ) { client->pers.teamState.state = TEAM_BEGIN; // JBravo: if player is changing from FREE or SPECT. there is no need for violence. - if ( oldTeam != TEAM_SPECTATOR && oldTeam != TEAM_FREE ) { + //Slicer: If he's dead no need for violence too + if ( (oldTeam != TEAM_SPECTATOR && oldTeam != TEAM_FREE) && + ent->client->ps.pm_type == PM_NORMAL){ // Kill him (makes sure he loses flags, etc) ent->flags &= ~FL_GODMODE; ent->client->ps.stats[STAT_HEALTH] = ent->health = 0; @@ -702,6 +707,22 @@ void SetTeam( gentity_t *ent, char *s ) { client->sess.sessionTeam = team; } + + //Slicer : Matchmode + if(g_matchmode.integer) { + client->sess.savedTeam = team; + + switch(team) { + case TEAM_RED: + level.team1ready = qfalse; + break; + case TEAM_BLUE: + level.team2ready = qfalse; + break; + } + + } + // they go to the end of the line for tournements if ( team == TEAM_SPECTATOR ) { client->sess.spectatorTime = level.time; @@ -2659,7 +2680,7 @@ void ClientCommand( int clientNum ) { else if (Q_stricmp (cmd, "stats") == 0) Cmd_Stats_f( ent ); //Slicer: matchmode - else if (Q_stricmp (cmd, "captain") == 0 && g_matchmode.integer) + else if (Q_stricmp (cmd, "captain") == 0) MM_Captain_f( ent ); // Begin Duffman diff --git a/reaction/game/g_local.h b/reaction/game/g_local.h index 99a934be..e9267cdf 100644 --- a/reaction/game/g_local.h +++ b/reaction/game/g_local.h @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.41 2002/02/02 20:39:09 slicer +// Matchmode: Adding Captains +// // Revision 1.40 2002/02/01 01:00:36 slicer // Adding Matchmode: just a few basics and files... // @@ -40,8 +43,7 @@ #include "bg_public.h" #include "g_public.h" -//Slicer: MatchMode -#include "g_matchmode.h" + //================================================================== // the "gameversion" client command will print this plus compile date @@ -295,7 +297,6 @@ typedef struct { // time and reading them back at connection time. Anything added here // MUST be dealt with in G_InitSessionData() / G_ReadSessionData() / G_WriteSessionData() typedef struct { - //Slicer team_t sessionTeam; team_t savedTeam; // JBravo: Used to hold the real team status of a player. int spectatorTime; // for determining next-in-line to play @@ -1274,3 +1275,6 @@ int trap_GeneticParentsAndChildSelection(int numranks, float *ranks, int *paren void trap_SnapVector( float *v ); gentity_t *findradius (gentity_t *from, vec3_t org, float rad); // Blaze: Find someone in a radius around you + +//Slicer: MatchMode +#include "g_matchmode.h" diff --git a/reaction/game/g_matchmode.c b/reaction/game/g_matchmode.c index 4cddd927..47f7cf7d 100644 --- a/reaction/game/g_matchmode.c +++ b/reaction/game/g_matchmode.c @@ -9,7 +9,7 @@ qboolean checkCaptain(team_t team) { ent = &g_entities[i]; if (!ent->inuse) continue; - if(ent->client->sess.sessionTeam == team && ent->client->pers.captain == team) + if(ent->client->sess.savedTeam == team && ent->client->pers.captain == team) return qtrue; } return qfalse; @@ -29,31 +29,32 @@ void MM_RunFrame(void) { } } void MM_Captain_f( gentity_t *ent ) { - - if(ent->client->sess.sessionTeam == TEAM_FREE) { + if(!g_matchmode.integer) + return; + if(ent->client->sess.savedTeam == TEAM_SPECTATOR || ent->client->sess.savedTeam == TEAM_FREE ) { trap_SendServerCommand(ent-g_entities, "print \"You need to be on a team for that\n\""); return; } - - if(ent->client->pers.captain != TEAM_FREE) { - - if(ent->client->sess.sessionTeam == TEAM_RED) { + if(ent->client->pers.captain == TEAM_RED) { level.team1ready = qfalse; trap_SendServerCommand( -1, va("print \"%s is no longer %s's Captain!\n\"", - ent->client->pers.netname,"Red Team"));// Teams will have names in the future.. - } - else { + ent->client->pers.netname,"Red Team"));// Teams will have names in the future.. + ent->client->pers.captain = TEAM_FREE; + } + else if(ent->client->pers.captain == TEAM_BLUE) { level.team2ready = qfalse; trap_SendServerCommand( -1, va("print \"%s is no longer %s's Captain!\n\"", ent->client->pers.netname,"Blue Team"));// Teams will have names in the future.. + ent->client->pers.captain = TEAM_FREE; + } + else { + if(!checkCaptain(ent->client->sess.savedTeam)) { + ent->client->pers.captain = ent->client->sess.savedTeam; + trap_SendServerCommand( -1, va("print \"%s is now %s's Captain!\n\"", + ent->client->pers.netname, + ent->client->sess.savedTeam==TEAM_BLUE ? "Blue Team": "Red Team")); } - ent->client->pers.captain = TEAM_FREE; + else + trap_SendServerCommand(ent-g_entities, va("print \"Your team already has a Captain\n\"")); } - - if(checkCaptain(ent->client->sess.sessionTeam)) { - trap_SendServerCommand(ent-g_entities, va("print \"Your team already has a Captain\n\"")); - return; - } - - } \ No newline at end of file diff --git a/reaction/game/g_session.c b/reaction/game/g_session.c index b35228cd..393ffe4a 100644 --- a/reaction/game/g_session.c +++ b/reaction/game/g_session.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.6 2002/02/02 20:39:09 slicer +// Matchmode: Adding Captains +// // Revision 1.5 2002/01/11 19:48:30 jbravo // Formatted the source in non DOS format. // @@ -103,6 +106,9 @@ void G_InitSessionData( gclient_t *client, char *userinfo ) { sess = &client->sess; + //Slicer : setting savedteam + sess->savedTeam = TEAM_SPECTATOR; + // initial team determination if ( g_gametype.integer >= GT_TEAM ) { if ( g_teamAutoJoin.integer ) {