]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/gamemodes/gamemode/tdm/tdm.qh
Merge branch 'master' into terencehill/lms_updates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / tdm / tdm.qh
1 #pragma once
2
3 #include <common/gamemodes/gamemode/deathmatch/deathmatch.qh>
4 #include <common/mapinfo.qh>
5
6 CLASS(TeamDeathmatch, Gametype)
7     INIT(TeamDeathmatch)
8     {
9         this.gametype_init(this, _("Team Deathmatch"),"tdm","g_tdm",GAMETYPE_FLAG_TEAMPLAY | GAMETYPE_FLAG_USEPOINTS | GAMETYPE_FLAG_PRIORITY,"","timelimit=15 pointlimit=50 teams=2 leadlimit=0",_("Help your team score the most frags against the enemy team"));
10     }
11     METHOD(TeamDeathmatch, m_parse_mapinfo, bool(string k, string v))
12     {
13         if (!k) {
14             cvar_set("g_tdm_teams", cvar_defstring("g_tdm_teams"));
15             return true;
16         }
17         switch (k) {
18             case "teams":
19                 cvar_set("g_tdm_teams", v);
20                 return true;
21         }
22         return false;
23     }
24     METHOD(TeamDeathmatch, m_isAlwaysSupported, bool(Gametype this, int spawnpoints, float diameter))
25     {
26         if(spawnpoints >= 8 && diameter > 4096)
27             return true;
28         return false;
29     }
30     METHOD(TeamDeathmatch, m_isForcedSupported, bool(Gametype this))
31     {
32         if(cvar("g_tdm_on_dm_maps"))
33         {
34             // if this is set, all DM maps support TDM too
35             if(!(MapInfo_Map_supportedGametypes & this.m_flags) && (MapInfo_Map_supportedGametypes & MAPINFO_TYPE_DEATHMATCH.m_flags))
36                 return true; // TODO: references another gametype (alternatively, we could check which gamemodes are always enabled and append this if any are supported)
37         }
38         return false;
39     }
40     METHOD(TeamDeathmatch, m_setTeams, void(string sa))
41     {
42         cvar_set("g_tdm_teams", sa);
43     }
44     METHOD(TeamDeathmatch, m_configuremenu, void(Gametype this, entity menu, void(entity me, string pLabel, float pMin, float pMax, float pStep, string pCvar, string tCvar, string pTooltip) returns))
45     {
46         TC(Gametype, this);
47         returns(menu, _("Point limit:"),     5,  100,  5, "g_tdm_point_limit",         "g_tdm_teams_override",         _("The amount of points needed before the match will end"));
48     }
49     ATTRIB(TeamDeathmatch, m_legacydefaults, string, "50 20 2 0");
50 ENDCLASS(TeamDeathmatch)
51 REGISTER_GAMETYPE(TEAM_DEATHMATCH, NEW(TeamDeathmatch));
52 #define g_tdm IS_GAMETYPE(TEAM_DEATHMATCH)