]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/gamemodes/gamemode/tdm/tdm.qc
Merge branch 'master' into terencehill/bot_ai
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / tdm / tdm.qc
1 #include "tdm.qh"
2
3 // TODO: sv_tdm
4 // TODO? rename to teamdeathmatch
5 #ifdef SVQC
6 int autocvar_g_tdm_teams;
7 int autocvar_g_tdm_teams_override;
8
9 /*QUAKED spawnfunc_tdm_team (0 .5 .8) (-16 -16 -24) (16 16 32)
10 Team declaration for TDM gameplay, this allows you to decide what team names and control point models are used in your map.
11 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.
12 Keys:
13 "netname" Name of the team (for example Red, Blue, Green, Yellow, Life, Death, Offense, Defense, etc)...
14 "cnt" Scoreboard color of the team (for example 4 is red and 13 is blue)... */
15 spawnfunc(tdm_team)
16 {
17         if(!g_tdm || !this.cnt) { delete(this); return; }
18
19         this.classname = "tdm_team";
20         this.team = this.cnt + 1;
21 }
22
23 // code from here on is just to support maps that don't have team entities
24 void tdm_SpawnTeam (string teamname, int teamcolor)
25 {
26         entity this = new_pure(tdm_team);
27         this.netname = teamname;
28         this.cnt = teamcolor - 1;
29         this.team = teamcolor;
30         this.spawnfunc_checked = true;
31         //spawnfunc_tdm_team(this);
32 }
33
34 void tdm_DelayedInit(entity this)
35 {
36         // if no teams are found, spawn defaults
37         if(find(NULL, classname, "tdm_team") == NULL)
38         {
39                 LOG_TRACE("No \"tdm_team\" entities found on this map, creating them anyway.");
40
41                 int numteams = autocvar_g_tdm_teams_override;
42                 if(numteams < 2) { numteams = autocvar_g_tdm_teams; }
43
44                 int teams = BITS(bound(2, numteams, 4));
45                 if(teams & BIT(0))
46                         tdm_SpawnTeam("Red", NUM_TEAM_1);
47                 if(teams & BIT(1))
48                         tdm_SpawnTeam("Blue", NUM_TEAM_2);
49                 if(teams & BIT(2))
50                         tdm_SpawnTeam("Yellow", NUM_TEAM_3);
51                 if(teams & BIT(3))
52                         tdm_SpawnTeam("Pink", NUM_TEAM_4);
53         }
54 }
55
56 MUTATOR_HOOKFUNCTION(tdm, TeamBalance_CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
57 {
58         M_ARGV(1, string) = "tdm_team";
59 }
60
61 MUTATOR_HOOKFUNCTION(tdm, Scores_CountFragsRemaining)
62 {
63         // announce remaining frags
64         return true;
65 }
66 #endif