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_winnerteam_last;
112 float WinningConditionHelper_secondteam; ///< the color of the second team, or -1 if none
113 float WinningConditionHelper_equality; ///< we have no winner
114 entity WinningConditionHelper_winner; ///< the winning player, or NULL if none
115 entity WinningConditionHelper_second; ///< the second player, or NULL if none
116 entity WinningConditionHelper_winner_last;
117 entity WinningConditionHelper_equality_one;
118 entity WinningConditionHelper_equality_two;
119 float WinningConditionHelper_lowerisbetter; ///< lower is better, duh
120 float WinningConditionHelper_zeroisworst; ///< zero is worst, duh
121 #define WINNINGCONDITIONHELPER_LOWERISBETTER_WORST 999999999
124 * Returns score strings for eventlog etc.
125 * When called with NULL, or 0, as argument, they return the labels in the
127 * The strings are comma separated; labels that end with !! designate primary,
128 * labels that end with ! designate high priority.
129 * Labels get an appended < if the scores are better if smaller (e.g. deaths).
130 * High priorities always come first.
131 * Example label string: score!!,kills,deaths<,suicides<
132 * If shortString is set, only the sort keys are returned.
134 string GetPlayerScoreString(entity pl, float shortString);
135 string GetTeamScoreString(float tm, float shortString);
138 * Sorts the players and stores their place in the given field, starting with
139 * 1. Non-players get 0 written into that field.
140 * Returns the beginning of a sorted chain of the non-spectators.
141 * teams: >0: sort by teams first (always strict ordering); <0: sort by teams only (respects strict flag)
142 * strict: return a strict ordering
143 * nospectators: exclude spectators
145 entity PlayerScore_Sort(.float field, int teams, bool strict, bool nospectators);
148 bool Score_NewLeader();