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
10 * Attaches a PlayerScore entity to a player. Use that in ClientConnect.
11 * Remember to detach it in ClientDisconnect!
13 void PlayerScore_Attach(entity player);
16 * Detaches a PlayerScore entity from the player. Use that in ClientDisconnect.
18 void PlayerScore_Detach(entity player);
21 * Adds a score to the player's scores.
22 * NEVER call this if PlayerScore_Attach has not been called yet!
23 * Means: FIXME make players unable to join the game when not called ClientConnect yet.
24 * Returns the new score.
26 float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score);
29 * Sets the player's score to the score parameter.
30 * NEVER call this if PlayerScore_Attach has not been called yet!
31 * Means: FIXME make players unable to join the game when not called ClientConnect yet.
32 * Returns the new (or old if unchanged) score.
34 float PlayerScore_Set(entity player, PlayerScoreField scorefield, float score);
37 * \brief Returns the player's score.
38 * \param[in] player Player to inspect.
39 * \param[in] scorefield Field of the score.
40 * \return Player's score.
42 #define PlayerScore_Get(player, scorefield) PlayerScore_Add(player, scorefield, 0)
45 * Initialize the score of this player if needed.
46 * Does nothing in teamplay.
47 * Use that when a spectator becomes a player.
48 * Returns whether clearing has been performed
50 float PlayerScore_Clear(entity player);
53 * Adds a score to the player's team's scores.
54 * NEVER call this if team has not been set yet!
55 * Returns the new score.
57 float TeamScore_Add(entity player, float scorefield, float score);
60 * Adds a score to the given team.
61 * NEVER call this if team has not been set yet!
62 * Returns the new score.
64 float TeamScore_AddToTeam(int t, float scorefield, float score);
67 * Returns a value indicating the team score (and higher is better).
69 float TeamScore_GetCompareValue(float t);
72 * Adds a score to both the player and the team. Returns the team score if
73 * possible, otherwise the player score.
75 float PlayerTeamScore_Add(entity player, PlayerScoreField pscorefield, float tscorefield, float score);
78 * Set the label of a team score item, as well as the scoring flags.
80 void ScoreInfo_SetLabel_TeamScore(float i, string label, float scoreflags);
83 * Set the label of a player score item, as well as the scoring flags.
85 void ScoreInfo_SetLabel_PlayerScore(PlayerScoreField i, string label, float scoreflags);
88 * Initialize the scores info for the given number of teams.
89 * Set all labels right before this call.
91 void ScoreInfo_Init(int teams);
94 * Clear ALL scores (for ready-restart).
96 void Score_ClearAll();
99 * Prints the scores to the console of a player.
101 void Score_NicePrint(entity to);
104 * Sets the following results for the current scores entities.
106 void WinningConditionHelper(entity this);
107 float WinningConditionHelper_topscore; ///< highest score
108 float WinningConditionHelper_secondscore; ///< second highest score
109 float WinningConditionHelper_winnerteam; ///< the color of the winning team, or -1 if none
110 float WinningConditionHelper_secondteam; ///< the color of the second team, or -1 if none
111 float WinningConditionHelper_equality; ///< we have no winner
112 entity WinningConditionHelper_winner; ///< the winning player, or NULL if none
113 entity WinningConditionHelper_second; ///< the second player, or NULL if none
114 float WinningConditionHelper_lowerisbetter; ///< lower is better, duh
115 float WinningConditionHelper_zeroisworst; ///< zero is worst, duh
116 #define WINNINGCONDITIONHELPER_LOWERISBETTER_WORST 999999999
119 * Returns score strings for eventlog etc.
120 * When called with NULL, or 0, as argument, they return the labels in the
122 * The strings are comma separated; labels that end with !! designate primary,
123 * labels that end with ! designate high priority.
124 * Labels get an appended < if the scores are better if smaller (e.g. deaths).
125 * High priorities always come first.
126 * Example label string: score!!,kills,deaths<,suicides<
127 * If shortString is set, only the sort keys are returned.
129 string GetPlayerScoreString(entity pl, float shortString);
130 string GetTeamScoreString(float tm, float shortString);
133 * Sorts the players and stores their place in the given field, starting with
134 * 1. Non-players get 0 written into that field.
135 * Returns the beginning of a sorted chain of the non-spectators.
136 * teams: >0: sort by teams first (always strict ordering); <0: sort by teams only (respects strict flag)
137 * strict: return a strict ordering
138 * nospectators: exclude spectators
140 entity PlayerScore_Sort(.float field, int teams, bool strict, bool nospectators);