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
15
17
19
22
23.float m_skill_mu;
25
27
28
29// ========================== Global teams API ================================
30
35int Team_MapEnts_FindOrSpawn(string ent_classname, int defaultmask);
36
37void Team_InitTeams();
38
43
48entity Team_GetTeam(int team_num);
49
50// ========================= Team specific API ================================
51
55float Team_GetTeamScore(entity team_ent);
56
60void Team_SetTeamScore(entity team_ent, float score);
61
66
71
75
79
83int Team_GetWinnerTeam_WithOwnedItems(int min_owned_items);
84
89
93void Team_SetNumberOfOwnedItems(entity team_ent, int number);
94
98
99// ======================= Entity specific API ================================
100
101void setcolor(entity this, int clr);
102
106bool Entity_HasValidTeam(entity this);
107
112
118
119void SetPlayerColors(entity player, float _color);
120
125bool Player_SetTeamIndex(entity player, int index);
126
127enum
128{
132};
133
134bool QueuedPlayersReady(entity this, bool checkspecificteam);
135
141bool SetPlayerTeam(entity player, int team_index, int type);
142
148bool MoveToTeam(entity client, int team_index, int type);
149
150enum
151{
154};
155
161
166
170void Player_SetForcedTeamIndex(entity player, int team_index);
171
172// ========================= Team balance API =================================
173
178
186
190void TeamBalance_Destroy(entity balance);
191
196
199
200bool TeamBalance_AreEqual(entity ignore, bool would_leave);
209
215bool TeamBalance_IsTeamAllowed(entity balance, int index);
216
223void TeamBalance_GetTeamCounts(entity balance, entity ignore);
224
231int TeamBalance_GetNumberOfPlayers(entity balance, int index);
232
242int TeamBalance_FindBestTeam(entity balance, entity player, bool ignore_player);
243
253int TeamBalance_FindBestTeams(entity balance, entity player, bool use_score);
254
256enum
257{
262};
263
266
273
281entity TeamBalance_GetPlayerForTeamSwitch(int source_team_index,
282 int destination_team_index, bool is_bot);
283
284// ============================ Internal API ==================================
285
286void LogTeamChange(float player_id, float team_number, int type);
287
294bool TeamBalance_IsTeamAllowedInternal(entity balance, int index);
295
299void TeamBalance_BanTeamsExcept(entity balance, int index);
300
307entity TeamBalance_GetTeamFromIndex(entity balance, int index);
308
316entity TeamBalance_GetTeam(entity balance, int team_num);
317
321bool TeamBalanceTeam_IsAllowed(entity team_ent);
322
329
336
345int TeamBalance_CompareTeamsInternal(entity team_a, entity team_b, entity client, bool use_score);
346
351void SV_ChangeTeam(entity player, int new_color);
352
353
354bool QueueNeeded(entity client, int team_index);
int team_forced
Definition buffs.qh:59
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity teams
Definition main.qh:58
#define SV_ChangeTeam
Definition _all.inc:280
#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:269
bool TeamBalanceTeam_IsAllowed(entity team_ent)
Returns whether the team is allowed.
Definition teamplay.qc:1192
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:210
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:694
int autocvar_g_balance_teams_skill
Definition teamplay.qh:12
int Team_GetNumberOfAlivePlayers(entity team_ent)
Returns the number of alive players in a team.
Definition teamplay.qc:114
entity Team_GetTeam(int team_num)
Returns the global team entity that corresponds to the given TEAM_NUM value.
Definition teamplay.qc:95
void TeamBalance_AutoBalanceBots()
Switches a bot from one team to another if teams are not balanced.
Definition teamplay.qc:1007
string autocvar_g_forced_team_otherwise
Definition teamplay.qh:16
void TeamBalance_Destroy(entity balance)
Destroy the team balance entity.
Definition teamplay.qc:528
void TeamBalance_BanTeamsExcept(entity balance, int index)
Bans team change to all teams except the given one.
Definition teamplay.qc:1167
void TeamBalance_RemoveExcessPlayers(entity ignore)
Definition teamplay.qc:631
bool autocvar_g_balance_teams_queue
Definition teamplay.qh:9
bool QueueNeeded(entity client, int team_index)
Definition teamplay.qc:1254
entity Entity_GetTeam(entity this)
Returns the team entity of the given entity.
Definition teamplay.qc:215
void TeamBalance_JoinBestTeam(entity player)
Assigns the given player to a team that will make the game most balanced.
Definition teamplay.qc:415
bool Player_HasRealForcedTeam(entity player)
Returns whether player has real forced team.
Definition teamplay.qc:340
int TeamBalance_CompareTeamsInternal(entity team_a, entity team_b, entity client, bool use_score)
Compares two teams for the purposes of game balance.
Definition teamplay.qc:1207
void LogTeamChange(float player_id, float team_number, int type)
Definition teamplay.qc:1148
float m_skill_var
Team: members' inverse-variance weighted skill variance (sigma**2).
Definition teamplay.qh:24
@ TEAM_FORCE_DEFAULT
Don't force any team.
Definition teamplay.qh:153
@ TEAM_FORCE_SPECTATOR
Force the player to spectator team.
Definition teamplay.qh:152
int TeamBalanceTeam_GetNumberOfPlayers(entity team_ent)
Returns the number of players (both humans and bots) in a team.
Definition teamplay.qc:1197
void Team_SetTeamScore(entity team_ent, float score)
Sets the score of the team.
Definition teamplay.qc:109
int Team_MapEnts_FindOrSpawn(string ent_classname, int defaultmask)
Finds any team map entities and returns their bitmask, else spawns them.
Definition teamplay.qc:56
float autocvar_g_balance_teams_skill_unranked_factor
Definition teamplay.qh:13
int TeamBalance_GetNumberOfPlayers(entity balance, int index)
Returns the number of players (both humans and bots) in a team.
Definition teamplay.qc:875
bool SetPlayerTeam(entity player, int team_index, int type)
Sets the team of the player.
Definition teamplay.qc:286
void Team_InitTeams()
Definition teamplay.qc:76
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:1079
int teamplay_bitmask
The set of currently available teams (AVAILABLE_TEAMS is the number of them).
Definition teamplay.qh:18
bool Player_SetTeamIndex(entity player, int index)
Sets the team of the player using its index.
Definition teamplay.qc:239
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:1202
float server_skill_average
Scaled inverse-variance weighted mean of all clients' m_skill_mu, for unranked clients.
Definition teamplay.qh:21
int Team_GetNumberOfTeamsWithOwnedItems()
Returns the number of teams that own items.
Definition teamplay.qc:177
int Team_GetWinnerAliveTeam()
Returns the winner team.
Definition teamplay.qc:124
void Team_SetNumberOfOwnedItems(entity team_ent, int number)
Sets the number of items owned by a team.
Definition teamplay.qc:172
void SetPlayerColors(entity player, float _color)
Definition teamplay.qc:225
void TeamBalance_GetTeamCounts(entity balance, entity ignore)
Counts the number of players and various other information about each team.
Definition teamplay.qc:758
int Team_GetNumberOfOwnedItems(entity team_ent)
Returns the number of items owned by a team.
Definition teamplay.qc:167
int Player_GetForcedTeamIndex(entity player)
Returns the index of the forced team of the given player.
Definition teamplay.qc:370
int Team_GetWinnerTeam_WithOwnedItems(int min_owned_items)
Returns the winner team.
Definition teamplay.qc:152
int autocvar_teamplay_mode
Definition teamplay.qh:3
@ TEAM_CHANGE_AUTO
The team was selected by autobalance.
Definition teamplay.qh:129
@ TEAM_CHANGE_MANUAL
Player has manually selected their team.
Definition teamplay.qh:130
@ TEAM_CHANGE_SPECTATOR
Player is joining spectators. //TODO: Remove?
Definition teamplay.qh:131
bool TeamBalance_IsTeamAllowedInternal(entity balance, int index)
Returns whether the team change to the specified team is allowed.
Definition teamplay.qc:1161
float Team_GetTeamScore(entity team_ent)
Returns the score of the team.
Definition teamplay.qc:104
bool Entity_HasValidTeam(entity this)
Returns whether the given entity belongs to a valid team.
Definition teamplay.qc:205
float autocvar_g_balance_teams_skill_significance_threshold
Definition teamplay.qh:14
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:541
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:424
bool TeamBalance_IsTeamAllowed(entity balance, int index)
Returns whether the team change to the specified team is allowed.
Definition teamplay.qc:738
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:928
bool TeamBalance_AreEqual(entity ignore, bool would_leave)
Definition teamplay.qc:585
int Team_GetNumberOfAliveTeams()
Returns the number of alive teams.
Definition teamplay.qc:139
float m_skill_mu
Team: members' inverse-variance weighted skill mean.
Definition teamplay.qh:23
void Team_SetNumberOfAlivePlayers(entity team_ent, int number)
Sets the number of alive players in a team.
Definition teamplay.qc:119
entity Team_GetTeamFromIndex(int index)
Returns the global team entity at the given index.
Definition teamplay.qc:86
int TeamBalance_SizeDifference(entity ignore)
Returns the size difference between the largest and smallest team (bots included).
Definition teamplay.qc:562
@ TEAMS_COMPARE_INVALID
One or both teams are invalid.
Definition teamplay.qh:258
@ TEAMS_COMPARE_GREATER
First team the greater than the second one.
Definition teamplay.qh:261
@ TEAMS_COMPARE_LESS
First team is less than the second one.
Definition teamplay.qh:259
@ TEAMS_COMPARE_EQUAL
Both teams are equal.
Definition teamplay.qh:260
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:1109
void Player_SetForcedTeamIndex(entity player, int team_index)
Sets the index of the forced team of the given player.
Definition teamplay.qc:345
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:892
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:1187
entity TeamBalance_GetTeamFromIndex(entity balance, int index)
Returns the team entity of the team balance entity at the given index.
Definition teamplay.qc:1178
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:331
bool lockteams
Definition teamplay.qh:20