Xonotic
sv_tdm.qc File Reference
#include "sv_tdm.qh"
+ Include dependency graph for sv_tdm.qc:

Go to the source code of this file.

Functions

 MUTATOR_HOOKFUNCTION (tdm, TeamBalance_CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
 
 MUTATOR_HOOKFUNCTION (tdm, Scores_CountFragsRemaining)
 
 spawnfunc (tdm_team)
 
void tdm_DelayedInit (entity this)
 
void tdm_Initialize ()
 
void tdm_SpawnTeam (string teamname, int teamcolor)
 

Variables

int autocvar_g_tdm_teams
 
int autocvar_g_tdm_teams_override
 

Function Documentation

◆ MUTATOR_HOOKFUNCTION() [1/2]

MUTATOR_HOOKFUNCTION ( tdm  ,
TeamBalance_CheckAllowedTeams  ,
CBC_ORDER_EXCLUSIVE   
)

Definition at line 63 of file sv_tdm.qc.

References M_ARGV.

64 {
65  M_ARGV(1, string) = "tdm_team";
66 }
#define M_ARGV(x, type)
Definition: events.qh:17

◆ MUTATOR_HOOKFUNCTION() [2/2]

MUTATOR_HOOKFUNCTION ( tdm  ,
Scores_CountFragsRemaining   
)

Definition at line 68 of file sv_tdm.qc.

69 {
70  // announce remaining frags
71  return true;
72 }

◆ spawnfunc()

spawnfunc ( tdm_team  )

Definition at line 13 of file sv_tdm.qc.

References cnt, g_tdm, and team.

14 {
15  if(!g_tdm || !this.cnt) { delete(this); return; }
16 
17  this.team = this.cnt + 1;
18 }
int team
Definition: main.qh:157
#define g_tdm
Definition: tdm.qh:52
float cnt
Definition: powerups.qc:24

◆ tdm_DelayedInit()

void tdm_DelayedInit ( entity  this)

Definition at line 31 of file sv_tdm.qc.

References autocvar_g_tdm_teams, autocvar_g_tdm_teams_override, BIT, BITS, bound(), classname, find(), LOG_TRACE, NULL, NUM_TEAM_1, NUM_TEAM_2, NUM_TEAM_3, NUM_TEAM_4, tdm_SpawnTeam(), and teams.

Referenced by tdm_Initialize().

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 }
const int NUM_TEAM_2
Definition: teams.qh:19
int autocvar_g_tdm_teams
Definition: sv_tdm.qc:4
string classname
Definition: csprogsdefs.qc:107
int autocvar_g_tdm_teams_override
Definition: sv_tdm.qc:5
entity teams
Definition: main.qh:44
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition: bits.qh:8
void tdm_SpawnTeam(string teamname, int teamcolor)
Definition: sv_tdm.qc:21
#define NULL
Definition: post.qh:17
const int NUM_TEAM_4
Definition: teams.qh:21
#define LOG_TRACE(...)
Definition: log.qh:81
const int NUM_TEAM_1
Definition: teams.qh:18
#define BITS(n)
Definition: bits.qh:9
const int NUM_TEAM_3
Definition: teams.qh:20
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tdm_Initialize()

void tdm_Initialize ( )

Definition at line 53 of file sv_tdm.qc.

References autocvar_g_tdm_point_leadlimit, autocvar_g_tdm_point_limit, autocvar_g_tdm_team_spawns, GameRules_limit_lead(), GameRules_limit_score(), GameRules_spawning_teams(), GameRules_teams(), InitializeEntity(), NULL, and tdm_DelayedInit().

Referenced by REGISTER_MUTATOR().

54 {
55  GameRules_teams(true);
59 
60  InitializeEntity(NULL, tdm_DelayedInit, INITPRIO_GAMETYPE);
61 }
void GameRules_spawning_teams(bool value)
Used to disable team spawns in team modes.
Definition: sv_rules.qc:22
int autocvar_g_tdm_point_leadlimit
Definition: sv_tdm.qh:5
void GameRules_limit_score(int limit)
Definition: sv_rules.qc:34
bool autocvar_g_tdm_team_spawns
Definition: sv_tdm.qh:6
void GameRules_teams(bool value)
Definition: sv_rules.qc:6
#define NULL
Definition: post.qh:17
void InitializeEntity(entity e, void(entity this) func, int order)
Definition: world.qc:2146
void GameRules_limit_lead(int limit)
Definition: sv_rules.qc:44
void tdm_DelayedInit(entity this)
Definition: sv_tdm.qc:31
int autocvar_g_tdm_point_limit
Definition: sv_tdm.qh:4
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tdm_SpawnTeam()

void tdm_SpawnTeam ( string  teamname,
int  teamcolor 
)

Definition at line 21 of file sv_tdm.qc.

References cnt, entity(), netname, new_pure, and team.

Referenced by tdm_DelayedInit().

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 }
int team
Definition: main.qh:157
entity() spawn
string netname
Definition: powerups.qc:20
float cnt
Definition: powerups.qc:24
#define new_pure(class)
purely logical entities (.origin doesn&#39;t work)
Definition: oo.qh:62
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ autocvar_g_tdm_teams

int autocvar_g_tdm_teams

Definition at line 4 of file sv_tdm.qc.

Referenced by tdm_DelayedInit().

◆ autocvar_g_tdm_teams_override

int autocvar_g_tdm_teams_override

Definition at line 5 of file sv_tdm.qc.

Referenced by tdm_DelayedInit().