X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fteamplay.qh;h=b19b8c0daad4e0cd1991d7a469d81fe94de625de;hb=5fd0fa537582090adc9a9be29ecbbb5f2fa82835;hp=3ce05ac2a66c2d24ab50dc74b91a94c61d6d156a;hpb=a39af09cb4b15ec94461af2c1f314098ffe7ce0c;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/teamplay.qh b/qcsrc/server/teamplay.qh index 3ce05ac2a..b19b8c0da 100644 --- a/qcsrc/server/teamplay.qh +++ b/qcsrc/server/teamplay.qh @@ -1,13 +1,33 @@ -#ifndef TEAMPLAY_H -#define TEAMPLAY_H +#pragma once string cache_mutatormsg; string cache_lastmutatormsg; -// client counts for each team -//float c1, c2, c3, c4; -// # of bots on those teams -float cb1, cb2, cb3, cb4; +// The following variables are used for balancing. They are not updated +// automatically. You need to call CheckAllowedTeams and GetTeamCounts to get +// proper values. + +// These four have 2 different states. If they are equal to -1, it means that +// the player can't join the team. Zero or positive value means that player can +// join the team and means the number of players on that team. +float c1; +float c2; +float c3; +float c4; +float numbotsteam1; ///< Number of bots in the first team. +float numbotsteam2; ///< Number of bots in the second team. +float numbotsteam3; ///< Number of bots in the third team. +float numbotsteam4; ///< Number of bots in the fourth team. +entity lowesthumanteam1; ///< Human with the lowest score in the first team. +entity lowesthumanteam2; ///< Human with the lowest score in the second team. +entity lowesthumanteam3; ///< Human with the lowest score in the third team. +entity lowesthumanteam4; ///< Human with the lowest score in the fourth team. +entity lowestbotteam1; ///< Bot with the lowest score in the first team. +entity lowestbotteam2; ///< Bot with the lowest score in the second team. +entity lowestbotteam3; ///< Bot with the lowest score in the third team. +entity lowestbotteam4; ///< Bot with the lowest score in the fourth team. + +int redowned, blueowned, yellowowned, pinkowned; //float audit_teams_time; @@ -15,19 +35,31 @@ void TeamchangeFrags(entity e); void LogTeamchange(float player_id, float team_number, float type); -void default_delayedinit(); +void default_delayedinit(entity this); void ActivateTeamplay(); void InitGameplayMode(); -string GetClientVersionMessage(); +string GetClientVersionMessage(entity this); -string getwelcomemessage(void); +string getwelcomemessage(entity this); -void SetPlayerColors(entity pl, float _color); +void SetPlayerColors(entity player, float _color); -void SetPlayerTeam(entity pl, float t, float s, float noprint); +/// \brief Sets the team of the player. +/// \param[in,out] player Player to adjust. +/// \param[in] teamnum Team number to set. See TEAM_NUM constants. +/// \return True if team switch was successful, false otherwise. +bool SetPlayerTeamSimple(entity player, int teamnum); + +/// \brief Sets the team of the player. +/// \param[in,out] player Player to adjust. +/// \param[in] destinationteam Team to set. +/// \param[in] sourceteam Previous team of the player. +/// \param[in] noprint Whether to print this event to players' console. +/// \return True if team switch was successful, false otherwise. +bool SetPlayerTeam(entity player, int destinationteam, int sourceteam, bool noprint); // set c1...c4 to show what teams are allowed void CheckAllowedTeams (entity for_whom); @@ -38,16 +70,46 @@ float PlayerValue(entity p); // teams that are allowed will now have their player counts stored in c1...c4 void GetTeamCounts(entity ignore); -float TeamSmallerEqThanTeam(float ta, float tb, entity e); +/// \brief Returns whether one team is smaller than the other. +/// \param[in] teama First team. +/// \param[in] teamb Second team. +/// \param[in] e Player to check. +/// \param[in] usescore Whether to take into account team scores. +/// \return True if first team is smaller than the second one, false otherwise. +/// \note This function assumes that CheckAllowedTeams and GetTeamCounts have +/// been called. +bool IsTeamSmallerThanTeam(int teama, int teamb, entity e, bool usescore); + +/// \brief Returns whether one team is equal to the other. +/// \param[in] teama First team. +/// \param[in] teamb Second team. +/// \param[in] e Player to check. +/// \param[in] usescore Whether to take into account team scores. +/// \return True if first team is equal to the second one, false otherwise. +/// \note This function assumes that CheckAllowedTeams and GetTeamCounts have +/// been called. +bool IsTeamEqualToTeam(int teama, int teamb, entity e, bool usescore); + +/// \brief Returns the bitmask of the best teams for the player to join. +/// \param[in] player Player to check. +/// \param[in] usescore Whether to take into account team scores. +/// \return Bitmask of the best teams for the player to join. +/// \note This function assumes that CheckAllowedTeams and GetTeamCounts have +/// been called. +int FindBestTeams(entity player, bool usescore); // returns # of smallest team (1, 2, 3, 4) // NOTE: Assumes CheckAllowedTeams has already been called! -float FindSmallestTeam(entity pl, float ignore_pl); +float FindSmallestTeam(entity player, float ignore_player); -float JoinBestTeam(entity pl, float only_return_best, float forcebestteam); +int JoinBestTeam(entity this, bool only_return_best, bool forcebestteam); -//void() ctf_playerchanged; -void SV_ChangeTeam(float _color); +/// \brief Auto balances bots in teams after the player has changed team. +/// \param[in] sourceteam Previous team of the player (1, 2, 3, 4). +/// \param[in] destinationteam Current team of the player (1, 2, 3, 4). +/// \return No return. +/// \note This function assumes that CheckAllowedTeams and GetTeamCounts have +/// been called. +void AutoBalanceBots(int sourceteam, int destinationteam); -void ShufflePlayerOutOfTeam (float source_team); -#endif +void setcolor(entity this, int clr);