]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/teamplay.qh
Removed 'owned' global variables.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / teamplay.qh
1 #pragma once
2
3 string cache_mutatormsg;
4 string cache_lastmutatormsg;
5
6 /// \brief Returns the global team entity at the given index.
7 /// \param[in] index Index of the team.
8 /// \return Global team entity at the given index.
9 entity Team_GetTeamFromIndex(int index);
10
11 /// \brief Returns the global team entity that corresponds to the given TEAM_NUM
12 /// value.
13 /// \param[in] team_num Team value. See TEAM_NUM constants.
14 /// \return Global team entity that corresponds to the given TEAM_NUM value.
15 entity Team_GetTeam(int team_num);
16
17 /// \brief Returns the score of the team.
18 /// \param[in] team_ Team entity.
19 /// \return Score of the team.
20 float Team_GetTeamScore(entity team_);
21
22 /// \brief Sets the score of the team.
23 /// \param[in,out] team_ Team entity.
24 /// \param[in] score Score to set.
25 void Team_SetTeamScore(entity team_, float score);
26
27 /// \brief Returns the number of alive players in a team.
28 /// \param[in] team_ Team entity.
29 /// \return Number of alive players in a team.
30 int Team_GetNumberOfAlivePlayers(entity team_);
31
32 /// \brief Sets the number of alive players in a team.
33 /// \param[in,out] team_ Team entity.
34 /// \param[in] number Number of players to set.
35 void Team_SetNumberOfAlivePlayers(entity team_, int number);
36
37 /// \brief Returns the number of alive teams.
38 /// \return Number of alive teams.
39 int Team_GetNumberOfAliveTeams();
40
41 /// \brief Returns the number of control points owned by a team.
42 /// \param[in] team_ Team entity.
43 /// \return Number of control points owned by a team.
44 int Team_GetNumberOfControlPoints(entity team_);
45
46 /// \brief Sets the number of control points owned by a team.
47 /// \param[in,out] team_ Team entity.
48 /// \param[in] number Number of control points to set.
49 void Team_SetNumberOfControlPoints(entity team_, int number);
50
51 /// \brief Returns the number of teams that own control points.
52 /// \return Number of teams that own control points.
53 int Team_GetNumberOfTeamsWithControlPoints();
54
55 void TeamchangeFrags(entity e);
56
57 void LogTeamchange(float player_id, float team_number, float type);
58
59 void default_delayedinit(entity this);
60
61 void InitGameplayMode();
62
63 string GetClientVersionMessage(entity this);
64
65 string getwelcomemessage(entity this);
66
67 void setcolor(entity this, int clr);
68
69 /// \brief Returns whether the given entity belongs to a valid team.
70 /// \param[in] this Entity to check.
71 /// \return True if entity belongs to a valid team, false otherwise.
72 bool Entity_HasValidTeam(entity this);
73
74 /// \brief Returns the team index of the given entity.
75 /// \param[in] this Entity to check.
76 /// \return Team index of the entity.
77 int Entity_GetTeamIndex(entity this);
78
79 /// \brief Returns the team entity of the given entity.
80 /// \param[in] this Entity to check.
81 /// \return Team entity of the given entity.
82 entity Entity_GetTeam(entity this);
83
84 void SetPlayerColors(entity player, float _color);
85
86 /// \brief Sets the team of the player using its index.
87 /// \param[in,out] player Player to adjust.
88 /// \param[in] index Index of the team to set.
89 /// \return True if team switch was successful, false otherwise.
90 bool Player_SetTeamIndex(entity player, int index);
91
92 /// \brief Sets the team of the player.
93 /// \param[in,out] player Player to adjust.
94 /// \param[in] destination_team_index Index of the team to set.
95 /// \param[in] source_team_index Previous index of the team of the player.
96 /// \param[in] no_print Whether to print this event to players' console.
97 /// \return True if team switch was successful, false otherwise.
98 bool SetPlayerTeam(entity player, int destination_team_index,
99         int source_team_index, bool no_print);
100
101 /// \brief Kills player as a result of team change.
102 /// \param[in,out] player Player to kill.
103 void KillPlayerForTeamChange(entity player);
104
105 // ========================= Team balance API =================================
106
107 /// \brief Checks whether the player can join teams according to global
108 /// configuration and mutator settings.
109 /// \param[in] for_whom Player to check for. Pass NULL for global rules.
110 /// \return Team balance entity that holds information about teams. This entity
111 /// must be manually destroyed by calling TeamBalance_Destroy.
112 entity TeamBalance_CheckAllowedTeams(entity for_whom);
113
114 /// \brief Destroy the team balance entity.
115 /// \param[in,out] balance Team balance entity to destroy.
116 /// \note Team balance entity is allowed to be NULL.
117 void TeamBalance_Destroy(entity balance);
118
119 /// \brief Returns the bitmask of allowed teams.
120 /// \param[in] balance Team balance entity.
121 /// \return Bitmask of allowed teams.
122 int TeamBalance_GetAllowedTeams(entity balance);
123
124 /// \brief Returns whether the team change to the specified team is allowed.
125 /// \param[in] balance Team balance entity.
126 /// \param[in] index Index of the team.
127 /// \return True if team change to the specified team is allowed, false
128 /// otherwise.
129 bool TeamBalance_IsTeamAllowed(entity balance, int index);
130
131 /// \brief Counts the number of players and various other information about
132 /// each team.
133 /// \param[in,out] balance Team balance entity.
134 /// \param[in] ignore Player to ignore. This is useful if you plan to switch the
135 /// player's team. Pass NULL for global information.
136 /// \note This function updates the internal state of the team balance entity.
137 void TeamBalance_GetTeamCounts(entity balance, entity ignore);
138
139 /// \brief Returns the number of players (both humans and bots) in a team.
140 /// \param[in] balance Team balance entity.
141 /// \param[in] index Index of the team.
142 /// \return Number of player (both humans and bots) in a team.
143 /// \note You need to call TeamBalance_GetTeamCounts before calling this
144 /// function.
145 int TeamBalance_GetNumberOfPlayers(entity balance, int index);
146
147 /// \brief Finds the team that will make the game most balanced if the player
148 /// joins it.
149 /// \param[in] balance Team balance entity.
150 /// \param[in] player Player to check.
151 /// \param[in] ignore_player ???
152 /// \return Index of the team that will make the game most balanced if the
153 /// player joins it. If there are several equally good teams available, the
154 /// function will pick a random one.
155 int TeamBalance_FindBestTeam(entity balance, entity player, bool ignore_player);
156
157 /// \brief Returns the bitmask of the teams that will make the game most
158 /// balanced if the player joins any of them.
159 /// \param[in] balance Team balance entity.
160 /// \param[in] player Player to check.
161 /// \param[in] use_score Whether to take into account team scores.
162 /// \return Bitmask of the teams that will make the game most balanced if the
163 /// player joins any of them.
164 /// \note You need to call TeamBalance_GetTeamCounts before calling this
165 /// function.
166 int TeamBalance_FindBestTeams(entity balance, entity player, bool use_score);
167
168 void TeamBalance_JoinBestTeam(entity this, bool force_best_team);
169
170 /// \brief Describes the result of comparing teams.
171 enum
172 {
173         TEAMS_COMPARE_INVALID, ///< One or both teams are invalid.
174         TEAMS_COMPARE_LESS, ///< First team is less than the second one.
175         TEAMS_COMPARE_EQUAL, ///< Both teams are equal.
176         TEAMS_COMPARE_GREATER ///< First team the greater than the second one.
177 };
178
179 /// \brief Compares two teams for the purposes of game balance.
180 /// \param[in] balance Team balance entity.
181 /// \param[in] team_index_a Index of the first team.
182 /// \param[in] team_index_b Index of the second team.
183 /// \param[in] player Player to check.
184 /// \param[in] use_score Whether to take into account team scores.
185 /// \return TEAMS_COMPARE value. See above.
186 /// \note You need to call TeamBalance_GetTeamCounts before calling this
187 /// function.
188 int TeamBalance_CompareTeams(entity balance, int team_index_a, int team_index_b,
189         entity player, bool use_score);
190
191 /// \brief Auto balances bots in teams after the player has changed team.
192 /// \param[in] balance Team balance entity.
193 /// \param[in] source_team_index Previous index of the team of the player.
194 /// \param[in] destination_team_index Current index of the team of the player.
195 /// \note You need to call CheckAllowedTeams and GetTeamCounts before calling
196 /// this function.
197 void TeamBalance_AutoBalanceBots(entity balance, int source_team_index,
198         int destination_team_index);
199
200 // ============================ Internal API ==================================
201
202 /// \brief Returns whether the team change to the specified team is allowed.
203 /// \param[in] balance Team balance entity.
204 /// \param[in] index Index of the team.
205 /// \return True if team change to the specified team is allowed, false
206 /// otherwise.
207 /// \note This function bypasses all the sanity checks.
208 bool TeamBalance_IsTeamAllowedInternal(entity balance, int index);
209
210 /// \brief Bans team change to all teams except the given one.
211 /// \param[in,out] balance Team balance entity.
212 /// \param[in] index Index of the team.
213 void TeamBalance_BanTeamsExcept(entity balance, int index);
214
215 /// \brief Returns the team entity of the team balance entity at the given
216 /// index.
217 /// \param[in] balance Team balance entity.
218 /// \param[in] index Index of the team.
219 /// \return Team entity of the team balance entity at the given index.
220 entity TeamBalance_GetTeamFromIndex(entity balance, int index);
221
222 /// \brief Returns the team entity of the team balance entity that corresponds
223 /// to the given TEAM_NUM value.
224 /// \param[in] balance Team balance entity.
225 /// \param[in] team_num Team value. See TEAM_NUM constants.
226 /// \return Team entity of the team balance entity that corresponds to the given
227 /// TEAM_NUM value.
228 entity TeamBalance_GetTeam(entity balance, int team_num);
229
230 /// \brief Returns whether the team is allowed.
231 /// \param[in] team_ Team entity.
232 /// \return True if team is allowed, false otherwise.
233 bool TeamBalanceTeam_IsAllowed(entity team_);
234
235 /// \brief Returns the number of players (both humans and bots) in a team.
236 /// \param[in] team_ Team entity.
237 /// \return Number of player (both humans and bots) in a team.
238 /// \note You need to call TeamBalance_GetTeamCounts before calling this
239 /// function.
240 int TeamBalanceTeam_GetNumberOfPlayers(entity team_);
241
242 /// \brief Returns the number of bots in a team.
243 /// \param[in] team_ Team entity.
244 /// \return Number of bots in a team.
245 /// \note You need to call TeamBalance_GetTeamCounts before calling this
246 /// function.
247 int TeamBalanceTeam_GetNumberOfBots(entity team_);
248
249 /// \brief Returns the human with the lowest score in a team or NULL if there is
250 /// none.
251 /// \param[in] team_ Team entity.
252 /// \return Human with the lowest score in a team or NULL if there is none.
253 /// \note You need to call TeamBalance_GetTeamCounts before calling this
254 /// function.
255 entity TeamBalanceTeam_GetLowestHuman(entity team_);
256
257 /// \brief Returns the bot with the lowest score in a team or NULL if there is
258 /// none.
259 /// \param[in] team_ Team entity.
260 /// \return Bot with the lowest score in a team or NULL if there is none.
261 /// \note You need to call TeamBalance_GetTeamCounts before calling this
262 /// function.
263 entity TeamBalanceTeam_GetLowestBot(entity team_);
264
265 /// \brief Compares two teams for the purposes of game balance.
266 /// \param[in] team_a First team.
267 /// \param[in] team_b Second team.
268 /// \param[in] player Player to check.
269 /// \param[in] use_score Whether to take into account team scores.
270 /// \return TEAMS_COMPARE value. See above.
271 /// \note You need to call TeamBalance_GetTeamCounts before calling this
272 /// function.
273 int TeamBalance_CompareTeamsInternal(entity team_a, entity team_index_b,
274         entity player, bool use_score);