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