3 // TODO? rename to teamdeathmatch
4 int autocvar_g_tdm_teams;
5 int autocvar_g_tdm_teams_override;
7 /*QUAKED spawnfunc_tdm_team (0 .5 .8) (-16 -16 -24) (16 16 32)
8 Team declaration for TDM gameplay, this allows you to decide what team names and control point models are used in your map.
9 Note: If you use spawnfunc_tdm_team entities you must define at least 2! However, unlike domination, you don't need to make a blank one too.
11 "netname" Name of the team (for example Red, Blue, Green, Yellow, Life, Death, Offense, Defense, etc)...
12 "cnt" Scoreboard color of the team (for example 4 is red and 13 is blue)... */
15 if(!g_tdm || !this.cnt) { delete(this); return; }
17 this.team = this.cnt + 1;
20 // code from here on is just to support maps that don't have team entities
21 void tdm_SpawnTeam (string teamname, int teamcolor)
23 entity this = new_pure(tdm_team);
24 this.netname = teamname;
25 this.cnt = teamcolor - 1;
26 this.team = teamcolor;
27 this.spawnfunc_checked = true;
28 //spawnfunc_tdm_team(this);
31 void tdm_DelayedInit(entity this)
33 // if no teams are found, spawn defaults
34 if(find(NULL, classname, "tdm_team") == NULL)
36 LOG_TRACE("No \"tdm_team\" entities found on this map, creating them anyway.");
38 int numteams = autocvar_g_tdm_teams_override;
39 if(numteams < 2) { numteams = autocvar_g_tdm_teams; }
41 int teams = BITS(bound(2, numteams, 4));
43 tdm_SpawnTeam("Red", NUM_TEAM_1);
45 tdm_SpawnTeam("Blue", NUM_TEAM_2);
47 tdm_SpawnTeam("Yellow", NUM_TEAM_3);
49 tdm_SpawnTeam("Pink", NUM_TEAM_4);
55 GameRules_teams(true);
56 GameRules_spawning_teams(autocvar_g_tdm_team_spawns);
57 GameRules_limit_score(autocvar_g_tdm_point_limit);
58 GameRules_limit_lead(autocvar_g_tdm_point_leadlimit);
60 InitializeEntity(NULL, tdm_DelayedInit, INITPRIO_GAMETYPE);
63 MUTATOR_HOOKFUNCTION(tdm, TeamBalance_CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
65 M_ARGV(1, string) = "tdm_team";
68 MUTATOR_HOOKFUNCTION(tdm, Scores_CountFragsRemaining)
70 // announce remaining frags