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