Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/action.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
39 changes: 21 additions & 18 deletions src/action/a_ctf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -876,25 +876,28 @@ 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 &&
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) {
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);
Expand Down Expand Up @@ -930,7 +933,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));
Expand Down Expand Up @@ -958,7 +961,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;
Expand Down Expand Up @@ -1084,7 +1087,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);
Expand Down Expand Up @@ -1422,7 +1425,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);
Expand Down
2 changes: 1 addition & 1 deletion src/action/g_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions src/action/g_spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/action/p_weapon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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])]))
{
Expand Down
Loading