Skip to content

Commit

Permalink
No-Team CTF
Browse files Browse the repository at this point in the history
Added the game logic. Improvements could include bot code, flag event sounds and a flag pickup delay on capture.
  • Loading branch information
themuffinator committed Jan 5, 2021
1 parent d97c559 commit 3023780
Show file tree
Hide file tree
Showing 35 changed files with 272 additions and 113 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
15 changes: 10 additions & 5 deletions build/win32-msvc/baseq3e.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cgame", "cgame.vcproj", "{FF0DC79F-C1D1-4DE3-BBD0-91B6146FD69C}"
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cgame", "cgame.vcxproj", "{FF0DC79F-C1D1-4DE3-BBD0-91B6146FD69C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "game", "game.vcproj", "{25F3B624-E060-4DAD-93D6-479AB6CD782F}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "game", "game.vcxproj", "{25F3B624-E060-4DAD-93D6-479AB6CD782F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "q3_ui", "q3_ui.vcproj", "{96D17D51-0760-4732-89C1-26DFD5B581BF}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "q3_ui", "q3_ui.vcxproj", "{96D17D51-0760-4732-89C1-26DFD5B581BF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -43,4 +45,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F82ECECF-8C58-48BB-9BEC-F3063735CD3B}
EndGlobalSection
EndGlobal
27 changes: 16 additions & 11 deletions code/cgame/cg_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ static void CG_DrawUpperRight(stereoFrame_t stereoFrame)

y = cgs.screenYmin;

if ( cgs.gametype >= GT_TEAM && cg_drawTeamOverlay.integer == 1 ) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF && cg_drawTeamOverlay.integer == 1 ) {
y = CG_DrawTeamOverlay( y, qtrue, qtrue );
}
if ( cg_drawSnapshot.integer ) {
Expand Down Expand Up @@ -1149,7 +1149,7 @@ static float CG_DrawScores( float y ) {
y1 = y;

// draw from the right side to left
if ( cgs.gametype >= GT_TEAM ) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF ) {
x0 = cgs.screenXmax + 1;
color[0] = 0.0f;
color[1] = 0.1f;
Expand Down Expand Up @@ -1192,7 +1192,7 @@ static float CG_DrawScores( float y ) {

CG_DrawString( x0-4, y, s, colorWhite, BIGCHAR_WIDTH, BIGCHAR_HEIGHT, 0, DS_SHADOW | DS_RIGHT );

if ( cgs.gametype == GT_CTF ) {
if ( cgs.gametype == GT_CTF || cgs.gametype == GT_NTCTF ) {
// Display flag status
item = BG_FindItemForPowerup( PW_REDFLAG );

Expand Down Expand Up @@ -1229,6 +1229,9 @@ static float CG_DrawScores( float y ) {

} else {
qboolean spectator;
int limit;

limit = cgs.gametype == GT_NTCTF ? cgs.capturelimit : cgs.fraglimit;

x = cgs.screenXmax + 1;

Expand Down Expand Up @@ -1284,8 +1287,8 @@ static float CG_DrawScores( float y ) {
CG_DrawString( x0-4, y, s, colorWhite, BIGCHAR_WIDTH, BIGCHAR_HEIGHT, 0, DS_SHADOW | DS_RIGHT );
}

if ( cgs.fraglimit ) {
s = va( "%2i", cgs.fraglimit );
if ( limit ) {
s = va( "%2i", limit );
CG_DrawString( x-4, y, s, colorWhite, BIGCHAR_WIDTH, BIGCHAR_HEIGHT, 0, DS_SHADOW | DS_RIGHT );
}
}
Expand Down Expand Up @@ -1409,7 +1412,7 @@ static void CG_DrawLowerRight( void ) {

y = cgs.screenYmax + 1 - STATUSBAR_HEIGHT;

if ( cgs.gametype >= GT_TEAM && cg_drawTeamOverlay.integer == 2 ) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF && cg_drawTeamOverlay.integer == 2 ) {
y = CG_DrawTeamOverlay( y, qtrue, qfalse );
}

Expand Down Expand Up @@ -1474,7 +1477,7 @@ static void CG_DrawLowerLeft( void ) {

y = cgs.screenYmax + 1 - STATUSBAR_HEIGHT;

if ( cgs.gametype >= GT_TEAM && cg_drawTeamOverlay.integer == 3 ) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF && cg_drawTeamOverlay.integer == 3 ) {
y = CG_DrawTeamOverlay( y, qfalse, qfalse );
}

Expand Down Expand Up @@ -2148,7 +2151,7 @@ static void CG_DrawSpectator( void ) {
CG_DrawString( 320, cgs.screenYmax - 40 + 1, "SPECTATOR", colorWhite, BIGCHAR_WIDTH, BIGCHAR_HEIGHT, 0, DS_SHADOW | DS_CENTER | DS_PROPORTIONAL );
if ( cgs.gametype == GT_TOURNAMENT ) {
CG_DrawString( 320, cgs.screenYmax - 20 + 1, "waiting to play", colorWhite, BIGCHAR_WIDTH, BIGCHAR_HEIGHT, 0, DS_SHADOW | DS_CENTER | DS_PROPORTIONAL );
} else if ( cgs.gametype >= GT_TEAM ) {
} else if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF ) {
CG_DrawString( 320, cgs.screenYmax - 20 + 1, "press ESC and use the JOIN menu to play", colorWhite, BIGCHAR_WIDTH, BIGCHAR_HEIGHT, 0, DS_SHADOW | DS_CENTER | DS_PROPORTIONAL );
}
}
Expand Down Expand Up @@ -2269,7 +2272,7 @@ static qboolean CG_DrawScoreboard( void ) {


if (menuScoreboard == NULL) {
if ( cgs.gametype >= GT_TEAM ) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF ) {
menuScoreboard = Menus_FindByName("teamscore_menu");
} else {
menuScoreboard = Menus_FindByName("score_menu");
Expand Down Expand Up @@ -2468,6 +2471,8 @@ static void CG_DrawWarmup( void ) {
s = "Team Deathmatch";
} else if ( cgs.gametype == GT_CTF ) {
s = "Capture the Flag";
} else if ( cgs.gametype == GT_NTCTF ) {
s = "No-Team CTF";
#ifdef MISSIONPACK
} else if ( cgs.gametype == GT_1FCTF ) {
s = "One Flag CTF";
Expand Down Expand Up @@ -2619,7 +2624,7 @@ static void CG_Draw2D( stereoFrame_t stereoFrame )
CG_DrawReward();
}

if ( cgs.gametype >= GT_TEAM ) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF ) {
#ifndef MISSIONPACK
CG_DrawTeamInfo();
#endif
Expand Down Expand Up @@ -2839,7 +2844,7 @@ void CG_TrackClientTeamChange( void )
return;
}

if ( cgs.gametype >= GT_TEAM )
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF )
{
spec_client = cg.snap->ps.clientNum;
return;
Expand Down
4 changes: 2 additions & 2 deletions code/cgame/cg_ents.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,9 +794,9 @@ static void CG_TeamBase( const centity_t *cent ) {
int t, h;
float c;

if ( cgs.gametype == GT_CTF || cgs.gametype == GT_1FCTF ) {
if ( cgs.gametype == GT_CTF || cgs.gametype == GT_1FCTF || cgs.gametype == GT_NTCTF ) {
#else
if ( cgs.gametype == GT_CTF) {
if ( cgs.gametype == GT_CTF || cgs.gametype == GT_NTCTF ) {
#endif
// show the flag base
memset(&model, 0, sizeof(model));
Expand Down
3 changes: 3 additions & 0 deletions code/cgame/cg_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ void CG_DrawInformation( void ) {
case GT_CTF:
s = "Capture The Flag";
break;
case GT_NTCTF:
s = "No-Team CTF";
break;
#ifdef MISSIONPACK
case GT_1FCTF:
s = "One Flag CTF";
Expand Down
26 changes: 19 additions & 7 deletions code/cgame/cg_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,19 @@ static void CG_RegisterSounds( void ) {
cgs.media.countPrepareTeamSound = trap_S_RegisterSound( "sound/feedback/prepare_team.wav", qtrue );
#endif

if ( cgs.gametype >= GT_TEAM || cg_buildScript.integer ) {

if ( cgs.gametype == GT_NTCTF || cg_buildScript.integer ) {
cgs.media.redFlagReturnedSound = cgs.media.blueFlagReturnedSound =
trap_S_RegisterSound( "sound/teamplay/flagreturn_opponent.wav", qtrue );

cgs.media.takenYourTeamSound = cgs.media.takenOpponentSound =
trap_S_RegisterSound( "sound/teamplay/flagtaken_opponent.wav", qtrue );

cgs.media.captureYourTeamSound = cgs.media.captureOpponentSound =
trap_S_RegisterSound( "sound/teamplay/flagcapture_opponent.wav", qtrue );
}

if ( (cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF) || cg_buildScript.integer ) {

cgs.media.captureAwardSound = trap_S_RegisterSound( "sound/teamplay/flagcapture_yourteam.wav", qtrue );
cgs.media.redLeadsSound = trap_S_RegisterSound( "sound/feedback/redleads.wav", qtrue );
Expand Down Expand Up @@ -937,9 +949,9 @@ static void CG_RegisterGraphics( void ) {
}

#ifdef MISSIONPACK
if ( cgs.gametype == GT_CTF || cgs.gametype == GT_1FCTF || cgs.gametype == GT_HARVESTER || cg_buildScript.integer ) {
if ( cgs.gametype == GT_CTF || cgs.gametype == GT_NTCTF || cgs.gametype == GT_1FCTF || cgs.gametype == GT_HARVESTER || cg_buildScript.integer ) {
#else
if ( cgs.gametype == GT_CTF || cg_buildScript.integer ) {
if ( cgs.gametype == GT_CTF || cgs.gametype == GT_NTCTF || cg_buildScript.integer ) {
#endif
cgs.media.redFlagModel = trap_R_RegisterModel( "models/flags/r_flag.md3" );
cgs.media.blueFlagModel = trap_R_RegisterModel( "models/flags/b_flag.md3" );
Expand Down Expand Up @@ -990,7 +1002,7 @@ static void CG_RegisterGraphics( void ) {
cgs.media.dustPuffShader = trap_R_RegisterShader("hasteSmokePuff" );
#endif

if ( cgs.gametype >= GT_TEAM || cg_buildScript.integer ) {
if ( (cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF) || cg_buildScript.integer ) {
cgs.media.friendShader = trap_R_RegisterShader( "sprites/foe" );
cgs.media.redQuadShader = trap_R_RegisterShader("powerups/blueflag" );
cgs.media.teamStatusBar = trap_R_RegisterShader( "gfx/2d/colorbar.tga" );
Expand Down Expand Up @@ -1599,7 +1611,7 @@ void CG_SetScoreSelection(void *p) {
return;
}

if ( cgs.gametype >= GT_TEAM ) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF ) {
int feeder = FEEDER_REDTEAM_LIST;
i = red;
if (cg.scores[cg.selectedScore].team == TEAM_BLUE) {
Expand All @@ -1615,7 +1627,7 @@ void CG_SetScoreSelection(void *p) {
// FIXME: might need to cache this info
static clientInfo_t * CG_InfoFromScoreIndex(int index, int team, int *scoreIndex) {
int i, count;
if ( cgs.gametype >= GT_TEAM ) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF ) {
count = 0;
for (i = 0; i < cg.numScores; i++) {
if (cg.scores[i].team == team) {
Expand Down Expand Up @@ -1720,7 +1732,7 @@ static qhandle_t CG_FeederItemImage(float feederID, int index) {
}

static void CG_FeederSelection(float feederID, int index) {
if ( cgs.gametype >= GT_TEAM ) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF ) {
int i, count;
int team = (feederID == FEEDER_REDTEAM_LIST) ? TEAM_RED : TEAM_BLUE;
count = 0;
Expand Down
24 changes: 12 additions & 12 deletions code/cgame/cg_players.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ static qboolean CG_FindClientModelFile( char *filename, int length, clientInfo_t
char *team, *charactersFolder;
int i;

if ( cgs.gametype >= GT_TEAM ) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF ) {
switch ( ci->team ) {
case TEAM_BLUE: {
team = "blue";
Expand Down Expand Up @@ -343,7 +343,7 @@ static qboolean CG_FindClientModelFile( char *filename, int length, clientInfo_t
if ( CG_FileExists( filename ) ) {
return qtrue;
}
if ( cgs.gametype >= GT_TEAM ) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF ) {
if ( i == 0 && teamName && *teamName ) {
// "models/players/characters/james/stroggs/lower_red.skin"
Com_sprintf( filename, length, "models/players/%s%s/%s%s_%s.%s", charactersFolder, modelName, teamName, base, team, ext );
Expand Down Expand Up @@ -390,7 +390,7 @@ static qboolean CG_FindClientHeadFile( char *filename, int length, clientInfo_t
char *team, *headsFolder;
int i;

if ( cgs.gametype >= GT_TEAM ) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF ) {
switch ( ci->team ) {
case TEAM_RED: {
team = "red";
Expand Down Expand Up @@ -433,7 +433,7 @@ static qboolean CG_FindClientHeadFile( char *filename, int length, clientInfo_t
if ( CG_FileExists( filename ) ) {
return qtrue;
}
if ( cgs.gametype >= GT_TEAM ) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF ) {
if ( i == 0 && teamName && *teamName ) {
Com_sprintf( filename, length, "models/players/%s%s/%s%s_%s.%s", headsFolder, headModelName, teamName, base, team, ext );
}
Expand Down Expand Up @@ -755,7 +755,7 @@ static void CG_LoadClientInfo( clientInfo_t *ci ) {
}

#ifdef MISSIONPACK
if( cgs.gametype >= GT_TEAM) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF ) {
if( ci->team == TEAM_BLUE ) {
Q_strncpyz(teamname, cg_blueTeamName.string, sizeof(teamname) );
} else {
Expand All @@ -773,7 +773,7 @@ static void CG_LoadClientInfo( clientInfo_t *ci ) {
}

// fall back to default team name
if( cgs.gametype >= GT_TEAM) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF ) {
// keep skin name
if( ci->team == TEAM_BLUE ) {
Q_strncpyz(teamname, DEFAULT_BLUETEAM_NAME, sizeof(teamname) );
Expand Down Expand Up @@ -886,7 +886,7 @@ static qboolean CG_ScanForExistingClientInfo( clientInfo_t *ci ) {
&& !Q_stricmp( ci->headSkinName, match->headSkinName )
//&& !Q_stricmp( ci->blueTeam, match->blueTeam )
//&& !Q_stricmp( ci->redTeam, match->redTeam )
&& (cgs.gametype < GT_TEAM || ci->team == match->team) ) {
&& ( (cgs.gametype < GT_TEAM || cgs.gametype == GT_NTCTF) || ci->team == match->team) ) {
// this clientinfo is identical, so use it's handles

ci->deferred = qfalse;
Expand Down Expand Up @@ -925,7 +925,7 @@ static void CG_SetDeferredClientInfo( clientInfo_t *ci ) {
Q_stricmp( ci->modelName, match->modelName ) ||
// Q_stricmp( ci->headModelName, match->headModelName ) ||
// Q_stricmp( ci->headSkinName, match->headSkinName ) ||
(cgs.gametype >= GT_TEAM && ci->team != match->team) ) {
(cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF && ci->team != match->team) ) {
continue;
}
// just load the real info cause it uses the same models and skins
Expand All @@ -934,7 +934,7 @@ static void CG_SetDeferredClientInfo( clientInfo_t *ci ) {
}

// if we are in teamplay, only grab a model if the skin is correct
if ( cgs.gametype >= GT_TEAM ) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF ) {
for ( i = 0 ; i < cgs.maxclients ; i++ ) {
match = &cgs.clientinfo[ i ];
if ( !match->infoValid || match->deferred ) {
Expand Down Expand Up @@ -996,7 +996,7 @@ static void CG_SetSkinAndModel( clientInfo_t *newInfo,

if ( cg_forceModel.integer || cg_enemyModel.string[0] || cg_teamModel.string[0] )
{
if ( cgs.gametype >= GT_TEAM )
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF )
{
// enemy model
if ( cg_enemyModel.string[0] && team != myTeam && team != TEAM_SPECTATOR ) {
Expand Down Expand Up @@ -1207,7 +1207,7 @@ void CG_NewClientInfo( int clientNum ) {
}

allowNativeModel = qfalse;
if ( cgs.gametype < GT_TEAM ) {
if ( cgs.gametype < GT_TEAM || cgs.gametype == GT_NTCTF ) {
if ( !cg.snap || ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_FREE && cg.snap->ps.clientNum == clientNum ) ) {
if ( cg.demoPlayback || ( cg.snap && cg.snap->ps.pm_flags & PMF_FOLLOW ) ) {
allowNativeModel = qtrue;
Expand Down Expand Up @@ -2242,7 +2242,7 @@ static void CG_PlayerSprites( centity_t *cent ) {
team = cgs.clientinfo[ cent->currentState.clientNum ].team;
if ( !(cent->currentState.eFlags & EF_DEAD) &&
cg.snap->ps.persistant[PERS_TEAM] == team &&
cgs.gametype >= GT_TEAM) {
(cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF) ) {
if (cg_drawFriend.integer) {
CG_PlayerFloatSprite( cent, cgs.media.friendShader );
}
Expand Down
2 changes: 1 addition & 1 deletion code/cgame/cg_playerstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ void CG_CheckLocalSounds( playerState_t *ps, playerState_t *ops ) {
if ( !cg.warmup ) {
// never play lead changes during warmup
if ( ps->persistant[PERS_RANK] != ops->persistant[PERS_RANK] ) {
if ( cgs.gametype < GT_TEAM) {
if ( cgs.gametype < GT_TEAM || cgs.gametype == GT_NTCTF ) {
if ( ps->persistant[PERS_RANK] == 0 ) {
CG_AddBufferedSound(cgs.media.takenLeadSound);
} else if ( ps->persistant[PERS_RANK] == RANK_TIED_FLAG ) {
Expand Down
6 changes: 6 additions & 0 deletions code/cgame/cg_predict.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,12 @@ static void CG_TouchItem( centity_t *cent ) {
if (cg.predictedPlayerState.persistant[PERS_TEAM] == TEAM_BLUE &&
item->giType == IT_TEAM && item->giTag == PW_BLUEFLAG)
return;
} else if ( cgs.gametype == GT_NTCTF ) {
// don't predict on flag captures
if ( (item->giTag == PW_BLUEFLAG && cg.predictedPlayerState.powerups[PW_REDFLAG]) ||
(item->giTag == PW_REDFLAG && cg.predictedPlayerState.powerups[PW_BLUEFLAG]) ) {
return;
}
}

// grab it
Expand Down
8 changes: 4 additions & 4 deletions code/cgame/cg_scoreboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static void CG_DrawClientScore( int y, score_t *score, float *color, float fade,
localClient = qtrue;

if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR
|| cgs.gametype >= GT_TEAM ) {
|| (cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF)) {
rank = -1;
} else {
rank = cg.snap->ps.persistant[PERS_RANK] & ~RANK_TIED_FLAG;
Expand Down Expand Up @@ -345,7 +345,7 @@ qboolean CG_DrawOldScoreboard( void ) {
}

// current rank
if ( cgs.gametype < GT_TEAM) {
if ( cgs.gametype < GT_TEAM || cgs.gametype == GT_NTCTF ) {
if (cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR ) {
s = va( "%s place with %i",
CG_PlaceString( cg.snap->ps.persistant[PERS_RANK] + 1 ),
Expand Down Expand Up @@ -390,7 +390,7 @@ qboolean CG_DrawOldScoreboard( void ) {

localClient = qfalse;

if ( cgs.gametype >= GT_TEAM ) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF ) {
//
// teamplay scoreboard
//
Expand Down Expand Up @@ -496,7 +496,7 @@ void CG_DrawOldTourneyScoreboard( void ) {
// print the two scores

y = 160;
if ( cgs.gametype >= GT_TEAM ) {
if ( cgs.gametype >= GT_TEAM && cgs.gametype != GT_NTCTF ) {
//
// teamplay scoreboard
//
Expand Down
Loading

0 comments on commit 3023780

Please sign in to comment.