1 #include "gamemode_tdm.qh"
5 int autocvar_g_tdm_point_limit;
6 int autocvar_g_tdm_point_leadlimit;
7 bool autocvar_g_tdm_team_spawns;
8 void tdm_DelayedInit(entity this);
10 REGISTER_MUTATOR(tdm, false)
14 if (time > 1) // game loads at time 1
15 error("This is a game type and it cannot be added at runtime.");
16 InitializeEntity(NULL, tdm_DelayedInit, INITPRIO_GAMETYPE);
19 SetLimits(autocvar_g_tdm_point_limit, autocvar_g_tdm_point_leadlimit, autocvar_timelimit_override, -1);
20 if (autocvar_g_tdm_team_spawns)
21 have_team_spawns = -1; // request team spawns
24 MUTATOR_ONROLLBACK_OR_REMOVE
26 // we actually cannot roll back tdm_Initialize here
27 // BUT: we don't need to! If this gets called, adding always
33 LOG_INFO("This is a game type and it cannot be removed at runtime.");
43 int autocvar_g_tdm_teams;
44 int autocvar_g_tdm_teams_override;
46 /*QUAKED spawnfunc_tdm_team (0 .5 .8) (-16 -16 -24) (16 16 32)
47 Team declaration for TDM gameplay, this allows you to decide what team names and control point models are used in your map.
48 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.
50 "netname" Name of the team (for example Red, Blue, Green, Yellow, Life, Death, Offense, Defense, etc)...
51 "cnt" Scoreboard color of the team (for example 4 is red and 13 is blue)... */
54 if(!g_tdm || !this.cnt) { remove(this); return; }
56 this.classname = "tdm_team";
57 this.team = this.cnt + 1;
60 // code from here on is just to support maps that don't have team entities
61 void tdm_SpawnTeam (string teamname, float teamcolor)
63 entity this = new(tdm_team);
64 this.netname = teamname;
66 this.spawnfunc_checked = true;
67 spawnfunc_tdm_team(this);
70 void tdm_DelayedInit(entity this)
72 // if no teams are found, spawn defaults
73 if(find(NULL, classname, "tdm_team") == NULL)
75 LOG_TRACE("No \"tdm_team\" entities found on this map, creating them anyway.\n");
77 int numteams = min(4, autocvar_g_tdm_teams_override);
79 if(numteams < 2) { numteams = autocvar_g_tdm_teams; }
80 numteams = bound(2, numteams, 4);
83 for(i = 1; i <= numteams; ++i)
84 tdm_SpawnTeam(Team_ColorName(Team_NumberToTeam(i)), Team_NumberToTeam(i) - 1);
88 MUTATOR_HOOKFUNCTION(tdm, GetTeamCount, CBC_ORDER_EXCLUSIVE)
90 M_ARGV(1, string) = "tdm_team";
94 MUTATOR_HOOKFUNCTION(tdm, Scores_CountFragsRemaining)
96 // announce remaining frags