3 #include <common/scores.qh>
5 bool autocvar_g_full_getstatus_responses;
7 entity scores_initialized; // non-NULL when scores labels/rules have been set
11 * Attaches a PlayerScore entity to a player. Use that in ClientConnect.
12 * Remember to detach it in ClientDisconnect!
14 void PlayerScore_Attach(entity player);
17 * Detaches a PlayerScore entity from the player. Use that in ClientDisconnect.
19 void PlayerScore_Detach(entity player);
22 * Adds a score to the player's scores.
23 * NEVER call this if PlayerScore_Attach has not been called yet!
24 * Means: FIXME make players unable to join the game when not called ClientConnect yet.
25 * Returns the new score.
27 float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score);
30 * Sets the player's score to the score parameter.
31 * NEVER call this if PlayerScore_Attach has not been called yet!
32 * Means: FIXME make players unable to join the game when not called ClientConnect yet.
33 * Returns the new (or old if unchanged) score.
35 float PlayerScore_Set(entity player, PlayerScoreField scorefield, float score);
38 * \brief Returns the player's score.
39 * \param[in] player Player to inspect.
40 * \param[in] scorefield Field of the score.
41 * \return Player's score.
43 #define PlayerScore_Get(player, scorefield) PlayerScore_Add(player, scorefield, 0)
46 * Initialize the score of this player if needed.
47 * Does nothing in teamplay.
48 * Use that when a spectator becomes a player.
49 * Returns whether clearing has been performed
51 float PlayerScore_Clear(entity player);
54 * Adds a score to the player's team's scores.
55 * NEVER call this if team has not been set yet!
56 * Returns the new score.
58 float TeamScore_Add(entity player, float scorefield, float score);
61 * Adds a score to the given team.
62 * NEVER call this if team has not been set yet!
63 * Returns the new score.
65 float TeamScore_AddToTeam(int t, float scorefield, float score);
68 * Returns a value indicating the team score (and higher is better).
70 float TeamScore_GetCompareValue(float t);
73 * Adds a score to both the player and the team. Returns the team score if
74 * possible, otherwise the player score.
76 float PlayerTeamScore_Add(entity player, PlayerScoreField pscorefield, float tscorefield, float score);
79 * Set the label of a team score item, as well as the scoring flags.
81 void ScoreInfo_SetLabel_TeamScore(float i, string label, float scoreflags);
84 * Set the label of a player score item, as well as the scoring flags.
86 void ScoreInfo_SetLabel_PlayerScore(PlayerScoreField i, string label, float scoreflags);
89 * Initialize the scores info for the given number of teams.
90 * Set all labels right before this call.
92 void ScoreInfo_Init(float teams);
95 * Clear ALL scores (for ready-restart).
97 void Score_ClearAll();
100 * Prints the scores to the console of a player.
102 void Score_NicePrint(entity to);
105 * Sets the following results for the current scores entities.
107 void WinningConditionHelper(entity this);
108 float WinningConditionHelper_topscore; ///< highest score
109 float WinningConditionHelper_secondscore; ///< second highest score
110 float WinningConditionHelper_winnerteam; ///< the color of the winning team, or -1 if none
111 float WinningConditionHelper_secondteam; ///< the color of the second team, or -1 if none
112 float WinningConditionHelper_equality; ///< we have no winner
113 entity WinningConditionHelper_winner; ///< the winning player, or NULL if none
114 entity WinningConditionHelper_second; ///< the second player, or NULL if none
115 float WinningConditionHelper_lowerisbetter; ///< lower is better, duh
116 float WinningConditionHelper_zeroisworst; ///< zero is worst, duh
117 #define WINNINGCONDITIONHELPER_LOWERISBETTER_WORST 999999999
120 * Returns score strings for eventlog etc.
121 * When called with NULL, or 0, as argument, they return the labels in the
123 * The strings are comma separated; labels that end with !! designate primary,
124 * labels that end with ! designate high priority.
125 * Labels get an appended < if the scores are better if smaller (e.g. deaths).
126 * High priorities always come first.
127 * Example label string: score!!,kills,deaths<,suicides<
128 * If shortString is set, only the sort keys are returned.
130 string GetPlayerScoreString(entity pl, float shortString);
131 string GetTeamScoreString(float tm, float shortString);
134 * Sorts the players and stores their place in the given field, starting with
135 * 1. Non-players get 0 written into that field.
136 * Returns the beginning of a sorted chain of the non-spectators.
137 * teams: >0: sort by teams first (always strict ordering); <0: sort by teams only (respects strict flag)
138 * strict: return a strict ordering
139 * nospectators: exclude spectators
141 entity PlayerScore_Sort(.float field, int teams, bool strict, bool nospectators);