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, int teamcolor)
63 entity this = new_pure(tdm_team);
64 this.netname = teamname;
65 this.cnt = teamcolor - 1;
66 this.team = teamcolor;
67 this.spawnfunc_checked = true;
68 //spawnfunc_tdm_team(this);
71 void tdm_DelayedInit(entity this)
73 // if no teams are found, spawn defaults
74 if(find(NULL, classname, "tdm_team") == NULL)
76 LOG_TRACE("No \"tdm_team\" entities found on this map, creating them anyway.\n");
78 int numteams = autocvar_g_tdm_teams_override;
80 if(numteams < 2) { numteams = autocvar_g_tdm_teams; }
81 numteams = bound(2, numteams, 4);
84 if(numteams >= 1) teams |= BIT(0);
85 if(numteams >= 2) teams |= BIT(1);
86 if(numteams >= 3) teams |= BIT(2);
87 if(numteams >= 4) teams |= BIT(3);
90 tdm_SpawnTeam("Red", NUM_TEAM_1);
92 tdm_SpawnTeam("Blue", NUM_TEAM_2);
94 tdm_SpawnTeam("Yellow", NUM_TEAM_3);
96 tdm_SpawnTeam("Pink", NUM_TEAM_4);
100 MUTATOR_HOOKFUNCTION(tdm, GetTeamCount, CBC_ORDER_EXCLUSIVE)
102 M_ARGV(1, string) = "tdm_team";
106 MUTATOR_HOOKFUNCTION(tdm, Scores_CountFragsRemaining)
108 // announce remaining frags