Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
teamplay.qh
Go to the documentation of this file.
1#pragma once
2
4
6
12
14
16
17.int team_forced; // can be a team number to force a team, or 0 for default action, or -1 for forced spectator
18
19
20// ========================== Global teams API ================================
21
22void Team_InitTeams();
23
28
33entity Team_GetTeam(int team_num);
34
35// ========================= Team specific API ================================
36
40float Team_GetTeamScore(entity team_ent);
41
45void Team_SetTeamScore(entity team_ent, float score);
46
51
56
60
64
68int Team_GetWinnerTeam_WithOwnedItems(int min_owned_items);
69
74
78void Team_SetNumberOfOwnedItems(entity team_ent, int number);
79
83
84// ======================= Entity specific API ================================
85
86void setcolor(entity this, int clr);
87
92
97
103
104void SetPlayerColors(entity player, float _color);
105
110bool Player_SetTeamIndex(entity player, int index);
111
112enum
113{
117};
118
119bool QueuedPlayersReady(entity this, bool checkspecificteam);
120
126bool SetPlayerTeam(entity player, int team_index, int type);
127
133bool MoveToTeam(entity client, int team_index, int type);
134
135enum
136{
139};
140
146
151
155void Player_SetForcedTeamIndex(entity player, int team_index);
156
160
161// ========================= Team balance API =================================
162
167
175
179void TeamBalance_Destroy(entity balance);
180
185
188
189bool TeamBalance_AreEqual(entity ignore, bool would_leave);
198
204bool TeamBalance_IsTeamAllowed(entity balance, int index);
205
212void TeamBalance_GetTeamCounts(entity balance, entity ignore);
213
220int TeamBalance_GetNumberOfPlayers(entity balance, int index);
221
231int TeamBalance_FindBestTeam(entity balance, entity player, bool ignore_player);
232
242int TeamBalance_FindBestTeams(entity balance, entity player, bool use_score);
243
245enum
246{
251};
252
262int TeamBalance_CompareTeams(entity balance, int team_index_a, int team_index_b,
263 entity player, bool use_score);
264
267
274
282entity TeamBalance_GetPlayerForTeamSwitch(int source_team_index,
283 int destination_team_index, bool is_bot);
284
285// ============================ Internal API ==================================
286
287void LogTeamChange(float player_id, float team_number, int type);
288
292
299bool TeamBalance_IsTeamAllowedInternal(entity balance, int index);
300
304void TeamBalance_BanTeamsExcept(entity balance, int index);
305
312entity TeamBalance_GetTeamFromIndex(entity balance, int index);
313
321entity TeamBalance_GetTeam(entity balance, int team_num);
322
326bool TeamBalanceTeam_IsAllowed(entity team_ent);
327
334
341
350int TeamBalance_CompareTeamsInternal(entity team_a, entity team_index_b,
351 entity player, bool use_score);
352
357void SV_ChangeTeam(entity player, int new_color);
358
359
360bool QueueNeeded(entity ignore);
int team_forced
Definition buffs.qh:61
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity teams
Definition main.qh:58
#define SV_ChangeTeam
Definition _all.inc:276
#define setcolor
Definition pre.qh:11
int int number
Definition impulse.qc:89
bool QueuedPlayersReady(entity this, bool checkspecificteam)
Returns true when enough players are queued that the next will join directly to the only available te...
Definition teamplay.qc:238
bool TeamBalanceTeam_IsAllowed(entity team_ent)
Returns whether the team is allowed.
Definition teamplay.qc:1258
int autocvar_g_balance_teams_remove_wait
Definition teamplay.qh:11
int Entity_GetTeamIndex(entity this)
Returns the team index of the given entity.
Definition teamplay.qc:181
bool TeamBalance_QueuedPlayersTagIn(entity ignore)
Joins queued player(s) to team(s) with a shortage, this should be more robust than only replacing the...
Definition teamplay.qc:775
int Team_GetNumberOfAlivePlayers(entity team_ent)
Returns the number of alive players in a team.
Definition teamplay.qc:85
entity Team_GetTeam(int team_num)
Returns the global team entity that corresponds to the given TEAM_NUM value.
Definition teamplay.qc:66
void TeamBalance_AutoBalanceBots()
Switches a bot from one team to another if teams are not balanced.
Definition teamplay.qc:1059
string autocvar_g_forced_team_otherwise
Definition teamplay.qh:13
void TeamBalance_Destroy(entity balance)
Destroy the team balance entity.
Definition teamplay.qc:599
void TeamBalance_BanTeamsExcept(entity balance, int index)
Bans team change to all teams except the given one.
Definition teamplay.qc:1233
void TeamBalance_RemoveExcessPlayers(entity ignore)
Definition teamplay.qc:712
bool autocvar_g_balance_teams_queue
Definition teamplay.qh:9
entity Entity_GetTeam(entity this)
Returns the team entity of the given entity.
Definition teamplay.qc:186
void Player_DetermineForcedTeam(entity player)
Determines the forced team of the player using current global config.
Definition teamplay.qc:348
void TeamBalance_JoinBestTeam(entity player)
Assigns the given player to a team that will make the game most balanced.
Definition teamplay.qc:423
bool Player_HasRealForcedTeam(entity player)
Returns whether player has real forced team.
Definition teamplay.qc:313
void LogTeamChange(float player_id, float team_number, int type)
Definition teamplay.qc:1200
@ TEAM_FORCE_DEFAULT
Don't force any team.
Definition teamplay.qh:138
@ TEAM_FORCE_SPECTATOR
Force the player to spectator team.
Definition teamplay.qh:137
int TeamBalanceTeam_GetNumberOfPlayers(entity team_ent)
Returns the number of players (both humans and bots) in a team.
Definition teamplay.qc:1263
void Team_SetTeamScore(entity team_ent, float score)
Sets the score of the team.
Definition teamplay.qc:80
bool QueueNeeded(entity ignore)
Definition teamplay.qc:1325
int TeamBalance_GetNumberOfPlayers(entity balance, int index)
Returns the number of players (both humans and bots) in a team.
Definition teamplay.qc:927
bool SetPlayerTeam(entity player, int team_index, int type)
Sets the team of the player.
Definition teamplay.qc:255
void Team_InitTeams()
Definition teamplay.qc:47
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:1131
bool Player_SetTeamIndex(entity player, int index)
Sets the team of the player using its index.
Definition teamplay.qc:210
bool autocvar_g_balance_teams_remove
Definition teamplay.qh:10
int TeamBalanceTeam_GetNumberOfBots(entity team_ent)
Returns the number of bots in a team.
Definition teamplay.qc:1268
int Team_GetNumberOfTeamsWithOwnedItems()
Returns the number of teams that own items.
Definition teamplay.qc:148
int Team_GetWinnerAliveTeam()
Returns the winner team.
Definition teamplay.qc:95
void Team_SetNumberOfOwnedItems(entity team_ent, int number)
Sets the number of items owned by a team.
Definition teamplay.qc:143
void SetPlayerColors(entity player, float _color)
Definition teamplay.qc:196
void TeamBalance_GetTeamCounts(entity balance, entity ignore)
Counts the number of players and various other information about each team.
Definition teamplay.qc:846
int Team_GetNumberOfOwnedItems(entity team_ent)
Returns the number of items owned by a team.
Definition teamplay.qc:138
int Player_GetForcedTeamIndex(entity player)
Returns the index of the forced team of the given player.
Definition teamplay.qc:318
int Team_GetWinnerTeam_WithOwnedItems(int min_owned_items)
Returns the winner team.
Definition teamplay.qc:123
int autocvar_teamplay_mode
Definition teamplay.qh:3
@ TEAM_CHANGE_AUTO
The team was selected by autobalance.
Definition teamplay.qh:114
@ TEAM_CHANGE_MANUAL
Player has manually selected their team.
Definition teamplay.qh:115
@ TEAM_CHANGE_SPECTATOR
Player is joining spectators. //TODO: Remove?
Definition teamplay.qh:116
bool TeamBalance_IsTeamAllowedInternal(entity balance, int index)
Returns whether the team change to the specified team is allowed.
Definition teamplay.qc:1227
float Team_GetTeamScore(entity team_ent)
Returns the score of the team.
Definition teamplay.qc:75
bool Entity_HasValidTeam(entity this)
Returns whether the given entity belongs to a valid team.
Definition teamplay.qc:176
bool autocvar_g_balance_teams_prevent_imbalance
Definition teamplay.qh:8
int TeamBalance_GetAllowedTeams(entity balance)
Returns the bitmask of allowed teams.
Definition teamplay.qc:612
bool autocvar_teamplay_lockonrestart
Definition teamplay.qh:5
entity TeamBalance_CheckAllowedTeams(entity for_whom)
Checks whether the player can join teams according to global configuration and mutator settings.
Definition teamplay.qc:459
bool TeamBalance_IsTeamAllowed(entity balance, int index)
Returns whether the team change to the specified team is allowed.
Definition teamplay.qc:826
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:984
bool TeamBalance_AreEqual(entity ignore, bool would_leave)
Definition teamplay.qc:656
int Team_GetNumberOfAliveTeams()
Returns the number of alive teams.
Definition teamplay.qc:110
void KillPlayerForTeamChange(entity player)
Kills player as a result of team change.
Definition teamplay.qc:1213
void Team_SetNumberOfAlivePlayers(entity team_ent, int number)
Sets the number of alive players in a team.
Definition teamplay.qc:90
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:1273
int TeamBalance_SizeDifference(entity ignore)
Returns the size difference between the largest and smallest team (bots included).
Definition teamplay.qc:633
@ TEAMS_COMPARE_INVALID
One or both teams are invalid.
Definition teamplay.qh:247
@ TEAMS_COMPARE_GREATER
First team the greater than the second one.
Definition teamplay.qh:250
@ TEAMS_COMPARE_LESS
First team is less than the second one.
Definition teamplay.qh:248
@ TEAMS_COMPARE_EQUAL
Both teams are equal.
Definition teamplay.qh:249
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:1161
void Player_SetForcedTeamIndex(entity player, int team_index)
Sets the index of the forced team of the given player.
Definition teamplay.qc:323
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:944
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:1029
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:1253
entity TeamBalance_GetTeamFromIndex(entity balance, int index)
Returns the team entity of the team balance entity at the given index.
Definition teamplay.qc:1244
bool autocvar_g_balance_teams
Definition teamplay.qh:7
bool MoveToTeam(entity client, int team_index, int type)
Moves player to the specified team.
Definition teamplay.qc:299
bool lockteams
Definition teamplay.qh:15