Xonotic
tdm.qh
Go to the documentation of this file.
1 #pragma once
2 
4 #include <common/mapinfo.qh>
5 
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");
51 REGISTER_GAMETYPE(TEAM_DEATHMATCH, NEW(TeamDeathmatch));
52 #define g_tdm IS_GAMETYPE(TEAM_DEATHMATCH)
#define NEW(cname,...)
Definition: oo.qh:105
CLASS(Object) Object
Definition: oo.qh:318
entity() spawn
#define METHOD(cname, name, prototype)
Definition: oo.qh:257
int m_flags
Definition: mapinfo.qh:27
const int GAMETYPE_FLAG_TEAMPLAY
Definition: mapinfo.qh:19
#define ATTRIB(...)
Definition: oo.qh:136
#define INIT(cname)
Definition: oo.qh:198
int MapInfo_Map_supportedGametypes
Definition: mapinfo.qh:13
#define TC(T, sym)
Definition: _all.inc:82
vector v
Definition: ent_cs.qc:116
const int GAMETYPE_FLAG_USEPOINTS
Definition: mapinfo.qh:20
#define ENDCLASS(cname)
Definition: oo.qh:269
const int GAMETYPE_FLAG_PRIORITY
Definition: mapinfo.qh:22
REGISTER_GAMETYPE(TEAM_DEATHMATCH, NEW(TeamDeathmatch))