]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/scores.qh
Merge branch 'master' into terencehill/vehicles_fixes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / scores.qh
1 entity scores_initialized; // non-world when scores labels/rules have been set
2 .float scores[MAX_SCORE];
3 .float teamscores[MAX_TEAMSCORE];
4
5 /**
6  * Attaches a PlayerScore entity to a player. Use that in ClientConnect.
7  * Remember to detach it in ClientDisconnect!
8  */
9 void PlayerScore_Attach(entity player);
10
11 /**
12  * Detaches a PlayerScore entity from the player. Use that in ClientDisconnect.
13  */
14 void PlayerScore_Detach(entity player);
15
16 /**
17  * Adds a score to the player's scores.
18  * NEVER call this if PlayerScore_Attach has not been called yet!
19  * Means: FIXME make players unable to join the game when not called ClientConnect yet.
20  * Returns the new score.
21  */
22 float PlayerScore_Add(entity player, float scorefield, float score);
23
24 /**
25  * Initialize the score of this player if needed.
26  * Does nothing in teamplay.
27  * Use that when a spectator becomes a player.
28  * Returns whether clearing has been performed
29  */
30 float PlayerScore_Clear(entity player);
31
32 /**
33  * Adds a score to the player's team's scores.
34  * NEVER call this if team has not been set yet!
35  * Returns the new score.
36  */
37 float TeamScore_Add(entity player, float scorefield, float score);
38
39 /**
40  * Adds a score to the given team.
41  * NEVER call this if team has not been set yet!
42  * Returns the new score.
43  */
44 float TeamScore_AddToTeam(float t, float scorefield, float score);
45
46 /**
47  * Returns a value indicating the team score (and higher is better).
48  */
49 float TeamScore_GetCompareValue(float t);
50
51 /**
52  * Adds a score to both the player and the team. Returns the team score if
53  * possible, otherwise the player score.
54  */
55 float PlayerTeamScore_Add(entity player, float pscorefield, float tscorefield, float score);
56
57 /**
58  * Adds to the generic score fields for both the player and the team.
59  */
60 #define PlayerTeamScore_AddScore(p,s) PlayerTeamScore_Add(p, SP_SCORE, ST_SCORE, s)
61
62 /**
63  * Set the label of a team score item, as well as the scoring flags.
64  */
65 void ScoreInfo_SetLabel_TeamScore(float i, string label, float scoreflags);
66
67 /**
68  * Set the label of a player score item, as well as the scoring flags.
69  */
70 void ScoreInfo_SetLabel_PlayerScore(float i, string label, float scoreflags);
71
72 /**
73  * Initialize the scores info for the given number of teams.
74  * Set all labels right before this call.
75  */
76 void ScoreInfo_Init(float teams);
77
78 /**
79  * Clear ALL scores (for ready-restart).
80  */
81 void Score_ClearAll();
82
83 /**
84  * Prints the scores to the console of a player.
85  */
86 void Score_NicePrint(entity to);
87
88 /**
89  * Sets the following results for the current scores entities.
90  */
91 void WinningConditionHelper();
92 float WinningConditionHelper_topscore;      ///< highest score
93 float WinningConditionHelper_secondscore;   ///< second highest score
94 float WinningConditionHelper_winnerteam;    ///< the color of the winning team, or -1 if none
95 float WinningConditionHelper_secondteam;    ///< the color of the second team, or -1 if none
96 float WinningConditionHelper_equality;      ///< we have no winner
97 entity WinningConditionHelper_winner;       ///< the winning player, or world if none
98 entity WinningConditionHelper_second;       ///< the second player, or world if none
99 float WinningConditionHelper_lowerisbetter; ///< lower is better, duh
100 float WinningConditionHelper_zeroisworst;   ///< zero is worst, duh
101 #define WINNINGCONDITIONHELPER_LOWERISBETTER_WORST 999999999
102
103 /**
104  * Returns score strings for eventlog etc.
105  * When called with world, or 0, as argument, they return the labels in the
106  * same order.
107  * The strings are comma separated; labels that end with !! designate primary,
108  * labels that end with ! designate high priority.
109  * Labels get an appended < if the scores are better if smaller (e.g. deaths).
110  * High priorities always come first.
111  * Example label string: score!!,kills,deaths<,suicides<
112  * If shortString is set, only the sort keys are returned.
113  */
114 string GetPlayerScoreString(entity pl, float shortString);
115 string GetTeamScoreString(float tm, float shortString);
116
117 /**
118  * Sorts the players and stores their place in the given field, starting with
119  * 1. Non-players get 0 written into that field.
120  * Returns the beginning of a sorted chain of the non-spectators.
121  * teams: >0: sort by teams first (always strict ordering); <0: sort by teams only (respects strict flag)
122  * strict: return a strict ordering
123  * nospectators: exclude spectators
124  */
125 entity PlayerScore_Sort(.float field, float teams, float strict, float nospectators);