Xonotic
teamplay.qh
Go to the documentation of this file.
1 #pragma once
2 
4 
7 
10 
12 
13 bool lockteams;
14 
15 .int team_forced; // can be a team number to force a team, or 0 for default action, or -1 for forced spectator
16 
17 // ========================== Global teams API ================================
18 
19 void Team_InitTeams();
20 
24 entity Team_GetTeamFromIndex(int index);
25 
30 entity Team_GetTeam(int team_num);
31 
32 // ========================= Team specific API ================================
33 
37 float Team_GetTeamScore(entity team_ent);
38 
42 void Team_SetTeamScore(entity team_ent, float score);
43 
48 
52 void Team_SetNumberOfAlivePlayers(entity team_ent, int number);
53 
57 
61 
65 int Team_GetWinnerTeam_WithOwnedItems(int min_owned_items);
66 
71 
75 void Team_SetNumberOfOwnedItems(entity team_ent, int number);
76 
80 
81 // ======================= Entity specific API ================================
82 
83 void setcolor(entity this, int clr);
84 
88 bool Entity_HasValidTeam(entity this);
89 
93 int Entity_GetTeamIndex(entity this);
94 
100 
101 void SetPlayerColors(entity player, float _color);
102 
107 bool Player_SetTeamIndex(entity player, int index);
108 
109 enum
110 {
114 };
115 
121 bool SetPlayerTeam(entity player, int team_index, int type);
122 
126 void Player_SetTeamIndexChecked(entity player, int team_index);
127 
133 bool MoveToTeam(entity client, int team_index, int type);
134 
135 enum
136 {
139 };
140 
145 bool Player_HasRealForcedTeam(entity player);
146 
151 
155 void Player_SetForcedTeamIndex(entity player, int team_index);
156 
160 
161 // ========================= Team balance API =================================
162 
166 void TeamBalance_JoinBestTeam(entity player);
167 
175 
179 void TeamBalance_Destroy(entity balance);
180 
185 
191 bool TeamBalance_IsTeamAllowed(entity balance, int index);
192 
199 void TeamBalance_GetTeamCounts(entity balance, entity ignore);
200 
207 int TeamBalance_GetNumberOfPlayers(entity balance, int index);
208 
217 int TeamBalance_FindBestTeam(entity balance, entity player, bool ignore_player);
218 
228 int TeamBalance_FindBestTeams(entity balance, entity player, bool use_score);
229 
231 enum
232 {
237 };
238 
248 int TeamBalance_CompareTeams(entity balance, int team_index_a, int team_index_b,
249  entity player, bool use_score);
250 
253 
260 
268 entity TeamBalance_GetPlayerForTeamSwitch(int source_team_index,
269  int destination_team_index, bool is_bot);
270 
271 // ============================ Internal API ==================================
272 
273 void LogTeamChange(float player_id, float team_number, int type);
274 
277 void KillPlayerForTeamChange(entity player);
278 
285 bool TeamBalance_IsTeamAllowedInternal(entity balance, int index);
286 
290 void TeamBalance_BanTeamsExcept(entity balance, int index);
291 
297 entity TeamBalance_GetTeamFromIndex(entity balance, int index);
298 
305 entity TeamBalance_GetTeam(entity balance, int team_num);
306 
310 bool TeamBalanceTeam_IsAllowed(entity team_ent);
311 
318 
325 
334 int TeamBalance_CompareTeamsInternal(entity team_a, entity team_index_b,
335  entity player, bool use_score);
336 
341 void SV_ChangeTeam(entity player, int new_color);
void Team_InitTeams()
Definition: teamplay.qc:47
One or both teams are invalid.
Definition: teamplay.qh:233
int Team_GetWinnerAliveTeam()
Returns the winner team.
Definition: teamplay.qc:95
entity TeamBalance_GetTeamFromIndex(entity balance, int index)
Returns the team entity of the team balance entity at the given index.
Definition: teamplay.qc:1080
string autocvar_g_forced_team_otherwise
Definition: teamplay.qh:11
int int number
Definition: impulse.qc:89
entity Entity_GetTeam(entity this)
Returns the team entity of the given entity.
Definition: teamplay.qc:181
void TeamBalance_JoinBestTeam(entity player)
Assigns the given player to a team that will make the game most balanced.
Definition: teamplay.qc:451
int Entity_GetTeamIndex(entity this)
Returns the team index of the given entity.
Definition: teamplay.qc:176
bool Entity_HasValidTeam(entity this)
Returns whether the given entity belongs to a valid team.
Definition: teamplay.qc:171
entity() spawn
bool TeamBalanceTeam_IsAllowed(entity team_ent)
Returns whether the team is allowed.
Definition: teamplay.qc:1094
void TeamBalance_Destroy(entity balance)
Destroy the team balance entity.
Definition: teamplay.qc:627
entity Team_GetTeamFromIndex(int index)
Returns the global team entity at the given index.
Definition: teamplay.qc:57
int TeamBalance_CompareTeamsInternal(entity team_a, entity team_index_b, entity player, bool use_score)
Compares two teams for the purposes of game balance.
Definition: teamplay.qc:1109
int Team_GetNumberOfTeamsWithOwnedItems()
Returns the number of teams that own items.
Definition: teamplay.qc:148
int TeamBalance_GetAllowedTeams(entity balance)
Returns the bitmask of allowed teams.
Definition: teamplay.qc:640
void setcolor(entity this, int clr)
Definition: teamplay.qc:161
The team was selected by autobalance.
Definition: teamplay.qh:111
bool SetPlayerTeam(entity player, int team_index, int type)
Sets the team of the player.
Definition: teamplay.qc:237
bool autocvar_g_changeteam_banned
Definition: teamplay.qh:5
Player has manually selected their team.
Definition: teamplay.qh:112
entity TeamBalance_GetPlayerForTeamSwitch(int source_team_index, int destination_team_index, bool is_bot)
Returns the player who is the most suitable for switching between the given teams.
Definition: teamplay.qc:997
void Player_SetTeamIndexChecked(entity player, int team_index)
Sets the team of the player with all sanity checks.
Definition: teamplay.qc:276
void SetPlayerColors(entity player, float _color)
Definition: teamplay.qc:191
entity teams
Definition: main.qh:44
Force the player to spectator team.
Definition: teamplay.qh:137
int Player_GetForcedTeamIndex(entity player)
Returns the index of the forced team of the given player.
Definition: teamplay.qc:346
void TeamBalance_BanTeamsExcept(entity balance, int index)
Bans team change to all teams except the given one.
Definition: teamplay.qc:1069
Player is joining spectators. //TODO: Remove?
Definition: teamplay.qh:113
bool autocvar_g_balance_teams_prevent_imbalance
Definition: teamplay.qh:9
int TeamBalance_GetLargestTeamIndex(entity balance, int teams)
Returns the index of the team with most players that is contained in the given bitmask of teams...
Definition: teamplay.qc:967
bool autocvar_teamplay_lockonrestart
Definition: teamplay.qh:6
int autocvar_teamplay_mode
Definition: teamplay.qh:3
void KillPlayerForTeamChange(entity player)
Kills player as a result of team change.
Definition: teamplay.qc:1049
float Team_GetTeamScore(entity team_ent)
Returns the score of the team.
Definition: teamplay.qc:75
void SV_ChangeTeam(entity player, int new_color)
Called when the player changes color with the "color" command.
Definition: teamplay.qc:1151
int team_forced
Definition: teamplay.qh:15
entity TeamBalance_GetTeam(entity balance, int team_num)
Returns the team entity of the team balance entity that corresponds to the given TEAM_NUM value...
Definition: teamplay.qc:1089
int TeamBalanceTeam_GetNumberOfBots(entity team_ent)
Returns the number of bots in a team.
Definition: teamplay.qc:1104
bool Player_SetTeamIndex(entity player, int index)
Sets the team of the player using its index.
Definition: teamplay.qc:205
int Team_GetNumberOfOwnedItems(entity team_ent)
Returns the number of items owned by a team.
Definition: teamplay.qc:138
void TeamBalance_GetTeamCounts(entity balance, entity ignore)
Counts the number of players and various other information about each team.
Definition: teamplay.qc:681
bool Player_HasRealForcedTeam(entity player)
Returns whether player has real forced team.
Definition: teamplay.qc:341
bool TeamBalance_IsTeamAllowed(entity balance, int index)
Returns whether the team change to the specified team is allowed.
Definition: teamplay.qc:662
int Team_GetNumberOfAliveTeams()
Returns the number of alive teams.
Definition: teamplay.qc:110
int Team_GetNumberOfAlivePlayers(entity team_ent)
Returns the number of alive players in a team.
Definition: teamplay.qc:85
entity TeamBalance_CheckAllowedTeams(entity for_whom)
Checks whether the player can join teams according to global configuration and mutator settings...
Definition: teamplay.qc:487
bool lockteams
Definition: teamplay.qh:13
First team is less than the second one.
Definition: teamplay.qh:234
void Player_DetermineForcedTeam(entity player)
Determines the forced team of the player using current global config.
Definition: teamplay.qc:376
void Player_SetForcedTeamIndex(entity player, int team_index)
Sets the index of the forced team of the given player.
Definition: teamplay.qc:351
bool TeamBalance_IsTeamAllowedInternal(entity balance, int index)
Returns whether the team change to the specified team is allowed.
Definition: teamplay.qc:1063
int TeamBalance_CompareTeams(entity balance, int team_index_a, int team_index_b, entity player, bool use_score)
Compares two teams for the purposes of game balance.
Definition: teamplay.qc:866
void Team_SetNumberOfAlivePlayers(entity team_ent, int number)
Sets the number of alive players in a team.
Definition: teamplay.qc:90
Don't force any team.
Definition: teamplay.qh:138
int TeamBalanceTeam_GetNumberOfPlayers(entity team_ent)
Returns the number of players (both humans and bots) in a team.
Definition: teamplay.qc:1099
int TeamBalance_FindBestTeams(entity balance, entity player, bool use_score)
Returns the bitmask of the teams that will make the game most balanced if the player joins any of the...
Definition: teamplay.qc:820
int TeamBalance_FindBestTeam(entity balance, entity player, bool ignore_player)
Finds the team that will make the game most balanced if the player joins it.
Definition: teamplay.qc:783
void TeamBalance_AutoBalanceBots()
Switches a bot from one team to another if teams are not balanced.
Definition: teamplay.qc:897
bool autocvar_g_balance_teams
Definition: teamplay.qh:8
void LogTeamChange(float player_id, float team_number, int type)
Definition: teamplay.qc:1036
int TeamBalance_GetNumberOfPlayers(entity balance, int index)
Returns the number of players (both humans and bots) in a team.
Definition: teamplay.qc:763
entity Team_GetTeam(int team_num)
Returns the global team entity that corresponds to the given TEAM_NUM value.
Definition: teamplay.qc:66
int Team_GetWinnerTeam_WithOwnedItems(int min_owned_items)
Returns the winner team.
Definition: teamplay.qc:123
bool MoveToTeam(entity client, int team_index, int type)
Moves player to the specified team.
Definition: teamplay.qc:327
void Team_SetTeamScore(entity team_ent, float score)
Sets the score of the team.
Definition: teamplay.qc:80
void Team_SetNumberOfOwnedItems(entity team_ent, int number)
Sets the number of items owned by a team.
Definition: teamplay.qc:143
First team the greater than the second one.
Definition: teamplay.qh:236
Both teams are equal.
Definition: teamplay.qh:235