From 2e31dc2db6caa2319c11588a709ae4b531f070c5 Mon Sep 17 00:00:00 2001 From: Dino <8dino2@gmail.com> Date: Mon, 22 Dec 2025 22:39:01 -0500 Subject: [PATCH 1/2] Restored ctf_mode design --- doc/action.md | 2 ++ src/action/a_ctf.c | 29 +++++++++++++++-------------- src/action/g_misc.c | 2 +- src/action/g_spawn.c | 6 +++--- src/action/p_weapon.c | 2 +- 5 files changed, 22 insertions(+), 19 deletions(-) diff --git a/doc/action.md b/doc/action.md index a4896c7ae..fa9f0871a 100644 --- a/doc/action.md +++ b/doc/action.md @@ -213,6 +213,8 @@ Flag locations and CTF player spawns should be specified in tng/mapname.ctf file - `ctf_dropflag [0/1]` - Allow clients to drop the flag or not. - `uvtime [#]` - The number of seconds *10 of the duration of the 'shield' effect. (for example 40 is 4 secs) - `ctf_dyn_respawn [0/1]` - Default 0, if enabled, this will reduce the respawn timer for a losing team periodically. Will self-correct as that team mounts a comeback. The score discrepancy gets evaluated when a flag is captured on either team. + - `ctf_mode [0/1]`, default 0 -- `0` means standard CTF Mode (with flags), `1` means CTB Mode (with briefcases and one-hand-free requirement to pick one up) + - `ctf_rewards [0/1]`, default 1 -- this enables rewards for CTF flag caps, such as restoring health and ammo - Client settings: - `drop flag` - Drop the flag if you're holding it diff --git a/src/action/a_ctf.c b/src/action/a_ctf.c index 23d4e6f1b..459e80237 100644 --- a/src/action/a_ctf.c +++ b/src/action/a_ctf.c @@ -752,16 +752,16 @@ qboolean CTFPickup_Flag(edict_t * ent, edict_t * other) strcpy(flag_name, "briefcase"); // figure out what team this flag is - if (ctf_mode->value == 2 && strcmp(ent->classname, "item_bcase_team1") == 0) + if (ctf_mode->value && strcmp(ent->classname, "item_bcase_team1") == 0) team = TEAM1; - else if (ctf_mode->value == 2 && strcmp(ent->classname, "item_bcase_team2") == 0) + else if (ctf_mode->value && strcmp(ent->classname, "item_bcase_team2") == 0) team = TEAM2; else if (strcmp(ent->classname, "item_flag_team1") == 0) team = TEAM1; else if (strcmp(ent->classname, "item_flag_team2") == 0) team = TEAM2; else { - gi.cprintf(ent, PRINT_HIGH, "Don't know what team the %s is on.\n", flag_name); + gi.dprintf("ERROR: Don't know what team the %s is on.\n", flag_name); return false; } @@ -876,7 +876,7 @@ qboolean CTFPickup_Flag(edict_t * ent, edict_t * other) // TODO: Make this work // in CTB mode, you must have a hand free to pick up the briefcase... - if (ctf_mode->value == 2 && + if (ctf_mode->value && other->client->curr_weap != MK23_NUM || other->client->curr_weap != KNIFE_NUM || other->client->curr_weap != GRENADE_NUM ){ @@ -886,15 +886,16 @@ qboolean CTFPickup_Flag(edict_t * ent, edict_t * other) if (other->client->uvTime) { other->client->uvTime = 0; - if (ctf_mode->value == 1) - gi.centerprintf(other, "Flag taken! Shields are DOWN! Run for it!"); - else + if (ctf_mode->value) gi.centerprintf(other, "Briefcase taken! Shields are DOWN! Run for it!"); - } else { - if (ctf_mode->value == 1) - gi.centerprintf(other, "You've got the ENEMY FLAG! Run for it!"); else + gi.centerprintf(other, "Flag taken! Shields are DOWN! Run for it!"); + + } else { + if (ctf_mode->value ) gi.centerprintf(other, "You've got the ENEMY BRIEFCASE! Run for it!"); + else + gi.centerprintf(other, "You've got the ENEMY FLAG! Run for it!"); } // hey, its not our flag, pick it up gi.bprintf(PRINT_HIGH, "%s got the %s %s!\n", other->client->pers.netname, CTFTeamName(team), flag_name); @@ -930,7 +931,7 @@ static void CTFDropFlagThink(edict_t * ent) { // auto return the flag // reset flag will remove ourselves - if (ctf_mode->value == 2) { + if (ctf_mode->value) { if (strcmp(ent->classname, "item_bcase_team1") == 0) { CTFResetFlag(TEAM1); gi.bprintf(PRINT_HIGH, "The %s briefcase has returned!\n", CTFTeamName(TEAM1)); @@ -958,7 +959,7 @@ void CTFDeadDropFlag(edict_t * self) { edict_t *dropped = NULL; - if (ctf_mode->value == 2) { + if (ctf_mode->value) { if (self->client->inventory[ITEM_INDEX(team_flag[TEAM1])]) { dropped = Drop_Item(self, team_flag[TEAM1]); self->client->inventory[ITEM_INDEX(team_flag[TEAM1])] = 0; @@ -1084,7 +1085,7 @@ void CTFEffects(edict_t * player) char t2modelpath[MAX_QPATH] = ""; // This sets the briefcase vwep in place of your weapon in CTB mode - if (ctf_mode->value == 2) { + if (ctf_mode->value) { if (player->client->inventory[ITEM_INDEX(team_flag[TEAM1])]) { Q_snprintf(t1modelpath, sizeof(t1modelpath), "players/%s/w_bc1.md2", model); player->s.modelindex2 = gi.modelindex(t1modelpath); @@ -1422,7 +1423,7 @@ void CTFDestroyFlag(edict_t * self) { //flags are important if (ctf->value) { - if (ctf_mode->value == 2) { + if (ctf_mode->value) { if (strcmp(self->classname, "item_bcase_team1") == 0) { CTFResetFlag(TEAM1); // this will free self! gi.bprintf(PRINT_HIGH, "The %s %s has returned!\n", CTFTeamName(TEAM1), team_flag[TEAM1]->pickup_name); diff --git a/src/action/g_misc.c b/src/action/g_misc.c index 66bcf73eb..e807f14c1 100644 --- a/src/action/g_misc.c +++ b/src/action/g_misc.c @@ -330,7 +330,7 @@ BecomeExplosion1 (edict_t * self) { //flags are important if (ctf->value) { - if (ctf_mode->value == 2) { + if (ctf_mode->value) { if (strcmp (self->classname, "item_bcase_team1") == 0){ CTFResetFlag (TEAM1); // this will free self! gi.bprintf (PRINT_HIGH, "The %s briefcase has returned!\n", CTFTeamName (TEAM1)); diff --git a/src/action/g_spawn.c b/src/action/g_spawn.c index e753944a9..0abc597c6 100644 --- a/src/action/g_spawn.c +++ b/src/action/g_spawn.c @@ -2315,12 +2315,12 @@ int LoadFlagsFromFile (const char *mapname) VectorCopy(position, ent->s.origin); if (!flagCount) { // Red Flag / Black Briefcase - if (ctf_mode->value == 2) + if (ctf_mode->value) ent->classname = ED_NewString ("item_bcase_team1"); else ent->classname = ED_NewString ("item_flag_team1"); } else { // Blue Flag / Silver Briefcase - if (ctf_mode->value == 2) + if (ctf_mode->value) ent->classname = ED_NewString ("item_bcase_team2"); else ent->classname = ED_NewString ("item_flag_team2"); @@ -2352,7 +2352,7 @@ void ChangePlayerSpawns (void) range1 = range2 = range3 = range4 = 99999; spot = spot1 = spot2 = spot3 = spot4 = NULL; - if (ctf_mode->value == 2){ + if (ctf_mode->value){ flag1 = G_Find (flag1, FOFS(classname), "item_bcase_team1"); flag2 = G_Find (flag2, FOFS(classname), "item_bcase_team2"); } else { diff --git a/src/action/p_weapon.c b/src/action/p_weapon.c index d3fd49159..378f97aaf 100644 --- a/src/action/p_weapon.c +++ b/src/action/p_weapon.c @@ -500,7 +500,7 @@ void ChangeWeapon(edict_t* ent) // TODO: Make this work // CTB prevents changing to a non-mk23/knife/grenade if carrying a briefcase - if (ctf_mode->value == 2 && + if (ctf_mode->value && (ent->client->inventory[ITEM_INDEX(team_flag[TEAM1])] || ent->client->inventory[ITEM_INDEX(team_flag[TEAM2])])) { From d43990b957ed86f92b51628c365749d0fb7b2b66 Mon Sep 17 00:00:00 2001 From: Dino <8dino2@gmail.com> Date: Mon, 22 Dec 2025 23:09:30 -0500 Subject: [PATCH 2/2] If statement fix for CTB --- src/action/a_ctf.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/action/a_ctf.c b/src/action/a_ctf.c index 459e80237..bf0059728 100644 --- a/src/action/a_ctf.c +++ b/src/action/a_ctf.c @@ -876,12 +876,14 @@ qboolean CTFPickup_Flag(edict_t * ent, edict_t * other) // TODO: Make this work // in CTB mode, you must have a hand free to pick up the briefcase... - if (ctf_mode->value && - other->client->curr_weap != MK23_NUM || - other->client->curr_weap != KNIFE_NUM || - other->client->curr_weap != GRENADE_NUM ){ + if (ctf_mode->value) { + if ( + other->client->curr_weap != MK23_NUM && + other->client->curr_weap != KNIFE_NUM && + other->client->curr_weap != GRENADE_NUM ){ gi.centerprintf(other, "You must have a free hand to pick up the %s!\n", flag_name); - return false; + return false; + } } if (other->client->uvTime) {