X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fteamplay.qh;h=7c4ebe77b6c2a82a51ae2949999734d5da4022e8;hb=53469243f6f632376c40f10be252aa216a98499f;hp=c9713984e809a2a1fc49a1c4f7ca61910b0dcdb5;hpb=10c0e93c75ef6f408e3357bd5fb46c721e7e0576;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/teamplay.qh b/qcsrc/server/teamplay.qh index c9713984e..7c4ebe77b 100644 --- a/qcsrc/server/teamplay.qh +++ b/qcsrc/server/teamplay.qh @@ -3,10 +3,29 @@ 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 num_bots_team1; ///< Number of bots in the first team. +float num_bots_team2; ///< Number of bots in the second team. +float num_bots_team3; ///< Number of bots in the third team. +float num_bots_team4; ///< Number of bots in the fourth team. +entity lowest_human_team1; ///< Human with the lowest score in the first team. +entity lowest_human_team2; ///< Human with the lowest score in the second team. +entity lowest_human_team3; ///< Human with the lowest score in the third team. +entity lowest_human_team4; ///< Human with the lowest score in the fourth team. +entity lowest_bot_team1; ///< Bot with the lowest score in the first team. +entity lowest_bot_team2; ///< Bot with the lowest score in the second team. +entity lowest_bot_team3; ///< Bot with the lowest score in the third team. +entity lowest_bot_team4; ///< Bot with the lowest score in the fourth team. int redowned, blueowned, yellowowned, pinkowned; @@ -18,20 +37,36 @@ void LogTeamchange(float player_id, float team_number, float type); void default_delayedinit(entity this); -void ActivateTeamplay(); - void InitGameplayMode(); string GetClientVersionMessage(entity this); string getwelcomemessage(entity this); -void SetPlayerColors(entity pl, float _color); +void SetPlayerColors(entity player, float _color); + +/// \brief Kills player as a result of team change. +/// \param[in,out] player Player to kill. +/// \return No return. +void KillPlayerForTeamChange(entity player); + +/// \brief Sets the team of the player. +/// \param[in,out] player Player to adjust. +/// \param[in] team_num Team number to set. See TEAM_NUM constants. +/// \return True if team switch was successful, false otherwise. +bool SetPlayerTeamSimple(entity player, int team_num); -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] destination_team Team to set. +/// \param[in] source_team Previous team of the player. +/// \param[in] no_print Whether to print this event to players' console. +/// \return True if team switch was successful, false otherwise. +bool SetPlayerTeam(entity player, int destination_team, int source_team, + bool no_print); // set c1...c4 to show what teams are allowed -void CheckAllowedTeams (entity for_whom); +void CheckAllowedTeams(entity for_whom); float PlayerValue(entity p); @@ -39,15 +74,47 @@ 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] team_a First team. +/// \param[in] team_b Second team. +/// \param[in] player Player to check. +/// \param[in] use_score 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 team_a, int team_b, entity player, + bool use_score); + +/// \brief Returns whether one team is equal to the other. +/// \param[in] team_a First team. +/// \param[in] team_b Second team. +/// \param[in] player Player to check. +/// \param[in] use_score 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 team_a, int team_b, entity player, bool use_score); + +/// \brief Returns the bitmask of the best teams for the player to join. +/// \param[in] player Player to check. +/// \param[in] use_score 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 use_score); // returns # of smallest team (1, 2, 3, 4) // NOTE: Assumes CheckAllowedTeams has already been called! -float FindSmallestTeam(entity pl, float ignore_pl); +int FindSmallestTeam(entity player, float ignore_player); -int JoinBestTeam(entity this, bool only_return_best, bool forcebestteam); +void JoinBestTeam(entity this, bool force_best_team); -//void() ctf_playerchanged; -void SV_ChangeTeam(float _color); +/// \brief Auto balances bots in teams after the player has changed team. +/// \param[in] source_team Previous team of the player (1, 2, 3, 4). +/// \param[in] destination_team 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 source_team, int destination_team); -void ShufflePlayerOutOfTeam (float source_team); +void setcolor(entity this, int clr);