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