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