7 #include "../common/util-pre.qh"
9 #include "../dpdefs/progsdefs.qc"
10 #include "../dpdefs/dpextensions.qc"
11 #include "sys-post.qh"
12 #include "../warpzonelib/anglestransform.qh"
13 #include "../warpzonelib/mathlib.qh"
14 #include "../warpzonelib/common.qh"
15 #include "../warpzonelib/util_server.qh"
16 #include "../warpzonelib/server.qh"
17 #include "../common/constants.qh"
18 #include "../common/stats.qh"
19 #include "../common/teams.qh"
20 #include "../common/util.qh"
21 #include "../common/nades.qh"
22 #include "../common/buffs.qh"
23 #include "../common/test.qh"
24 #include "../common/counting.qh"
25 #include "../common/urllib.qh"
26 #include "../common/command/markup.qh"
27 #include "../common/command/rpn.qh"
28 #include "../common/command/generic.qh"
29 #include "../common/command/shared_defs.qh"
30 #include "../common/net_notice.qh"
31 #include "../common/animdecide.qh"
32 #include "../common/monsters/monsters.qh"
33 #include "../common/monsters/sv_monsters.qh"
34 #include "../common/monsters/spawn.qh"
35 #include "../common/weapons/config.qh"
36 #include "../common/weapons/weapons.qh"
37 #include "weapons/accuracy.qh"
38 #include "weapons/common.qh"
39 #include "weapons/csqcprojectile.qh"
40 #include "weapons/hitplot.qh"
41 #include "weapons/selection.qh"
42 #include "weapons/spawning.qh"
43 #include "weapons/throwing.qh"
44 #include "weapons/tracing.qh"
45 #include "weapons/weaponstats.qh"
46 #include "weapons/weaponsystem.qh"
48 #include "autocvars.qh"
49 #include "constants.qh"
51 #include "../common/notifications.qh"
52 #include "../common/deathtypes.qh"
53 #include "mutators/mutators_include.qh"
54 #include "tturrets/include/turrets_early.qh"
55 #include "vehicles/vehicles_def.qh"
56 #include "campaign.qh"
57 #include "../common/campaign_common.qh"
58 #include "../common/mapinfo.qh"
59 #include "command/common.qh"
60 #include "command/banning.qh"
61 #include "command/radarmap.qh"
62 #include "command/vote.qh"
63 #include "command/getreplies.qh"
64 #include "command/cmd.qh"
65 #include "command/sv_cmd.qh"
66 #include "../common/csqcmodel_settings.qh"
67 #include "../csqcmodellib/common.qh"
68 #include "../csqcmodellib/sv_model.qh"
69 #include "anticheat.qh"
71 #include "../common/playerstats.qh"
76 entity scores_initialized; // non-world when scores labels/rules have been set
77 .float scores[MAX_SCORE];
78 .float teamscores[MAX_TEAMSCORE];
79 .float scoreboard_pos;
82 * Attaches a PlayerScore entity to a player. Use that in ClientConnect.
83 * Remember to detach it in ClientDisconnect!
85 void PlayerScore_Attach(entity player);
88 * Detaches a PlayerScore entity from the player. Use that in ClientDisconnect.
90 void PlayerScore_Detach(entity player);
93 * Adds a score to the player's scores.
94 * NEVER call this if PlayerScore_Attach has not been called yet!
95 * Means: FIXME make players unable to join the game when not called ClientConnect yet.
96 * Returns the new score.
98 float PlayerScore_Add(entity player, float scorefield, float score);
101 * Initialize the score of this player if needed.
102 * Does nothing in teamplay.
103 * Use that when a spectator becomes a player.
104 * Returns whether clearing has been performed
106 float PlayerScore_Clear(entity player);
109 * Adds a score to the player's team's scores.
110 * NEVER call this if team has not been set yet!
111 * Returns the new score.
113 float TeamScore_Add(entity player, float scorefield, float score);
116 * Adds a score to the given team.
117 * NEVER call this if team has not been set yet!
118 * Returns the new score.
120 float TeamScore_AddToTeam(float t, float scorefield, float score);
123 * Returns a value indicating the team score (and higher is better).
125 float TeamScore_GetCompareValue(float t);
128 * Adds a score to both the player and the team. Returns the team score if
129 * possible, otherwise the player score.
131 float PlayerTeamScore_Add(entity player, float pscorefield, float tscorefield, float score);
134 * Adds to the generic score fields for both the player and the team.
136 #define PlayerTeamScore_AddScore(p,s) PlayerTeamScore_Add(p, SP_SCORE, ST_SCORE, s)
139 * Set the label of a team score item, as well as the scoring flags.
141 void ScoreInfo_SetLabel_TeamScore(float i, string label, float scoreflags);
144 * Set the label of a player score item, as well as the scoring flags.
146 void ScoreInfo_SetLabel_PlayerScore(float i, string label, float scoreflags);
149 * Initialize the scores info for the given number of teams.
150 * Set all labels right before this call.
152 void ScoreInfo_Init(float teams);
155 * Clear ALL scores (for ready-restart).
157 void Score_ClearAll();
160 * Prints the scores to the console of a player.
162 void Score_NicePrint(entity to);
165 * Sets the following results for the current scores entities.
167 void WinningConditionHelper();
168 float WinningConditionHelper_topscore; ///< highest score
169 float WinningConditionHelper_secondscore; ///< second highest score
170 float WinningConditionHelper_winnerteam; ///< the color of the winning team, or -1 if none
171 float WinningConditionHelper_secondteam; ///< the color of the second team, or -1 if none
172 float WinningConditionHelper_equality; ///< we have no winner
173 entity WinningConditionHelper_winner; ///< the winning player, or world if none
174 entity WinningConditionHelper_second; ///< the second player, or world if none
175 float WinningConditionHelper_lowerisbetter; ///< lower is better, duh
176 float WinningConditionHelper_zeroisworst; ///< zero is worst, duh
177 #define WINNINGCONDITIONHELPER_LOWERISBETTER_WORST 999999999
180 * Returns score strings for eventlog etc.
181 * When called with world, or 0, as argument, they return the labels in the
183 * The strings are comma separated; labels that end with !! designate primary,
184 * labels that end with ! designate high priority.
185 * Labels get an appended < if the scores are better if smaller (e.g. deaths).
186 * High priorities always come first.
187 * Example label string: score!!,kills,deaths<,suicides<
188 * If shortString is set, only the sort keys are returned.
190 string GetPlayerScoreString(entity pl, float shortString);
191 string GetTeamScoreString(float tm, float shortString);
194 * Sorts the players and stores their place in the given field, starting with
195 * 1. Non-players get 0 written into that field.
196 * Returns the beginning of a sorted chain of the non-spectators.
197 * teams: >0: sort by teams first (always strict ordering); <0: sort by teams only (respects strict flag)
198 * strict: return a strict ordering
199 * nospectators: exclude spectators
201 entity PlayerScore_Sort(.float field, float teams, float strict, float nospectators);