1 entity scores_initialized; // non-world when scores labels/rules have been set
\r
2 .float scores[MAX_SCORE];
\r
3 .float teamscores[MAX_TEAMSCORE];
\r
6 * Attaches a PlayerScore entity to a player. Use that in ClientConnect.
\r
7 * Remember to detach it in ClientDisconnect!
\r
9 void PlayerScore_Attach(entity player);
\r
12 * Detaches a PlayerScore entity from the player. Use that in ClientDisconnect.
\r
14 void PlayerScore_Detach(entity player);
\r
17 * Adds a score to the player's scores.
\r
18 * NEVER call this if PlayerScore_Attach has not been called yet!
\r
19 * Means: FIXME make players unable to join the game when not called ClientConnect yet.
\r
20 * Returns the new score.
\r
22 float PlayerScore_Add(entity player, float scorefield, float score);
\r
25 * Initialize the score of this player if needed.
\r
26 * Does nothing in teamplay.
\r
27 * Use that when a spectator becomes a player.
\r
29 void PlayerScore_Clear(entity player);
\r
32 * Adds a score to the player's team's scores.
\r
33 * NEVER call this if team has not been set yet!
\r
34 * Returns the new score.
\r
36 float TeamScore_Add(entity player, float scorefield, float score);
\r
39 * Adds a score to the given team.
\r
40 * NEVER call this if team has not been set yet!
\r
41 * Returns the new score.
\r
43 float TeamScore_AddToTeam(float t, float scorefield, float score);
\r
46 * Returns a value indicating the team score (and higher is better).
\r
48 float TeamScore_GetCompareValue(float t);
\r
51 * Adds a score to both the player and the team. Returns the team score if
\r
52 * possible, otherwise the player score.
\r
54 float PlayerTeamScore_Add(entity player, float pscorefield, float tscorefield, float score);
\r
57 * Adds to the generic score fields for both the player and the team.
\r
59 #define PlayerTeamScore_AddScore(p,s) PlayerTeamScore_Add(p, SP_SCORE, ST_SCORE, s)
\r
62 * Set the label of a team score item, as well as the scoring flags.
\r
64 void ScoreInfo_SetLabel_TeamScore(float i, string label, float scoreflags);
\r
67 * Set the label of a player score item, as well as the scoring flags.
\r
69 void ScoreInfo_SetLabel_PlayerScore(float i, string label, float scoreflags);
\r
72 * Initialize the scores info for the given number of teams.
\r
73 * Set all labels right before this call.
\r
75 void ScoreInfo_Init(float teams);
\r
78 * Clear ALL scores (for ready-restart).
\r
80 void Score_ClearAll();
\r
83 * Prints the scores to the console of a player.
\r
85 void Score_NicePrint(entity to);
\r
88 * Sets the following results for the current scores entities.
\r
90 void WinningConditionHelper();
\r
91 float WinningConditionHelper_topscore; ///< highest score
\r
92 float WinningConditionHelper_secondscore; ///< second highest score
\r
93 float WinningConditionHelper_winnerteam; ///< the color of the winning team, or -1 if none
\r
94 float WinningConditionHelper_secondteam; ///< the color of the second team, or -1 if none
\r
95 float WinningConditionHelper_equality; ///< we have no winner
\r
96 entity WinningConditionHelper_winner; ///< the winning player, or world if none
\r
97 entity WinningConditionHelper_second; ///< the second player, or world if none
\r
98 float WinningConditionHelper_lowerisbetter; ///< lower is better, duh
\r
99 float WinningConditionHelper_zeroisworst; ///< zero is worst, duh
\r
100 #define WINNINGCONDITIONHELPER_LOWERISBETTER_WORST 999999999
\r
103 * Returns score strings for eventlog etc.
\r
104 * When called with world, or 0, as argument, they return the labels in the
\r
106 * The strings are comma separated; labels that end with !! designate primary,
\r
107 * labels that end with ! designate high priority.
\r
108 * Labels get an appended < if the scores are better if smaller (e.g. deaths).
\r
109 * High priorities always come first.
\r
110 * Example label string: score!!,kills,deaths<,suicides<
\r
111 * If shortString is set, only the sort keys are returned.
\r
113 string GetPlayerScoreString(entity pl, float shortString);
\r
114 string GetTeamScoreString(float tm, float shortString);
\r
117 * Sorts the players and stores their place in the given field, starting with
\r
118 * 1. Non-players get 0 written into that field.
\r
119 * Returns the beginning of a sorted chain of the non-spectators.
\r
121 entity PlayerScore_Sort(.float field);
\r