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
175
176// ========================= Team balance API =================================
177
182
190
194void TeamBalance_Destroy(entity balance);
195
200
203
204bool TeamBalance_AreEqual(entity ignore, bool would_leave);
213
219bool TeamBalance_IsTeamAllowed(entity balance, int index);
220
227void TeamBalance_GetTeamCounts(entity balance, entity ignore);
228
235int TeamBalance_GetNumberOfPlayers(entity balance, int index);
236
246int TeamBalance_FindBestTeam(entity balance, entity player, bool ignore_player);
247
257int TeamBalance_FindBestTeams(entity balance, entity player, bool use_score);
258
260enum
261{
266};
267
270
277
285entity TeamBalance_GetPlayerForTeamSwitch(int source_team_index,
286 int destination_team_index, bool is_bot);
287
288// ============================ Internal API ==================================
289
290void LogTeamChange(float player_id, float team_number, int type);
291
295
302bool TeamBalance_IsTeamAllowedInternal(entity balance, int index);
303
307void TeamBalance_BanTeamsExcept(entity balance, int index);
308
315entity TeamBalance_GetTeamFromIndex(entity balance, int index);
316
324entity TeamBalance_GetTeam(entity balance, int team_num);
325
329bool TeamBalanceTeam_IsAllowed(entity team_ent);
330
337
344
352int TeamBalance_CompareTeamsInternal(entity team_a, entity team_index_b, bool use_score);
353
358void SV_ChangeTeam(entity player, int new_color);
359
360
361bool 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:267
bool TeamBalanceTeam_IsAllowed(entity team_ent)
Returns whether the team is allowed.
Definition teamplay.qc:1277
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:763
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:1078
string autocvar_g_forced_team_otherwise
Definition teamplay.qh:16
void TeamBalance_Destroy(entity balance)
Destroy the team balance entity.
Definition teamplay.qc:597
void TeamBalance_BanTeamsExcept(entity balance, int index)
Bans team change to all teams except the given one.
Definition teamplay.qc:1252
void TeamBalance_RemoveExcessPlayers(entity ignore)
Definition teamplay.qc:700
bool autocvar_g_balance_teams_queue
Definition teamplay.qh:9
bool QueueNeeded(entity client, int team_index)
Definition teamplay.qc:1333
entity Entity_GetTeam(entity this)
Returns the team entity of the given entity.
Definition teamplay.qc:215
void Player_DetermineForcedTeam(entity player)
Determines the forced team of the player using current global config.
Definition teamplay.qc:377
void TeamBalance_JoinBestTeam(entity player)
Assigns the given player to a team that will make the game most balanced.
Definition teamplay.qc:452
bool Player_HasRealForcedTeam(entity player)
Returns whether player has real forced team.
Definition teamplay.qc:342
void LogTeamChange(float player_id, float team_number, int type)
Definition teamplay.qc:1219
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:1282
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:945
bool SetPlayerTeam(entity player, int team_index, int type)
Sets the team of the player.
Definition teamplay.qc:284
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:1150
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:1287
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
int TeamBalance_CompareTeamsInternal(entity team_a, entity team_index_b, bool use_score)
Compares two teams for the purposes of game balance.
Definition teamplay.qc:1292
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:827
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:347
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:1246
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:610
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:488
bool TeamBalance_IsTeamAllowed(entity balance, int index)
Returns whether the team change to the specified team is allowed.
Definition teamplay.qc:807
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:1002
bool TeamBalance_AreEqual(entity ignore, bool would_leave)
Definition teamplay.qc:654
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 KillPlayerForTeamChange(entity player)
Kills player as a result of team change.
Definition teamplay.qc:1232
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:631
@ TEAMS_COMPARE_INVALID
One or both teams are invalid.
Definition teamplay.qh:262
@ TEAMS_COMPARE_GREATER
First team the greater than the second one.
Definition teamplay.qh:265
@ TEAMS_COMPARE_LESS
First team is less than the second one.
Definition teamplay.qh:263
@ TEAMS_COMPARE_EQUAL
Both teams are equal.
Definition teamplay.qh:264
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:1180
void Player_SetForcedTeamIndex(entity player, int team_index)
Sets the index of the forced team of the given player.
Definition teamplay.qc:352
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:962
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:1272
entity TeamBalance_GetTeamFromIndex(entity balance, int index)
Returns the team entity of the team balance entity at the given index.
Definition teamplay.qc:1263
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:328
bool lockteams
Definition teamplay.qh:20