]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/scores.qh
particles: volume weighting = negative count, absolute weighting = positive count
[divverent/nexuiz.git] / data / qcsrc / server / scores.qh
1 float scores_initialized; // 1 when scores labels/rules have been set
2
3 /**
4  * Attaches a PlayerScore entity to a player. Use that in ClientConnect.
5  * Remember to detach it in ClientDisconnect!
6  */
7 void PlayerScore_Attach(entity player);
8
9 /**
10  * Detaches a PlayerScore entity from the player. Use that in ClientDisconnect.
11  */
12 void PlayerScore_Detach(entity player);
13
14 /**
15  * Adds a score to the player's scores.
16  * NEVER call this if PlayerScore_Attach has not been called yet!
17  * Means: FIXME make players unable to join the game when not called ClientConnect yet.
18  * Returns the new score.
19  */
20 float PlayerScore_Add(entity player, float scorefield, float score);
21
22 /**
23  * Initialize the score of this player if needed.
24  * Does nothing in teamplay.
25  * Use that when a spectator becomes a player.
26  */
27 void PlayerScore_Clear(entity player);
28
29 /**
30  * Adds a score to the player's team's scores.
31  * NEVER call this if team has not been set yet!
32  * Returns the new score.
33  */
34 float TeamScore_Add(entity player, float scorefield, float score);
35
36 /**
37  * Adds a score to the given team.
38  * NEVER call this if team has not been set yet!
39  * Returns the new score.
40  */
41 float TeamScore_AddToTeam(float t, float scorefield, float score);
42
43 /**
44  * Returns a value indicating the team score (and higher is better).
45  */
46 float TeamScore_GetCompareValue(float t);
47
48 /**
49  * Adds a score to both the player and the team. Returns the team score if
50  * possible, otherwise the player score.
51  */
52 float PlayerTeamScore_Add(entity player, float pscorefield, float tscorefield, float score);
53
54 /**
55  * Adds to the generic score fields for both the player and the team.
56  */
57 #define PlayerTeamScore_AddScore(p,s) PlayerTeamScore_Add(p, SP_SCORE, ST_SCORE, s)
58
59 /**
60  * Set the label of a team score item, as well as the scoring flags.
61  */
62 void ScoreInfo_SetLabel_TeamScore(float i, string label, float scoreflags);
63
64 /**
65  * Set the label of a player score item, as well as the scoring flags.
66  */
67 void ScoreInfo_SetLabel_PlayerScore(float i, string label, float scoreflags);
68
69 /**
70  * Initialize the scores info for the given number of teams.
71  * Set all labels right before this call.
72  */
73 void ScoreInfo_Init(float teams);
74
75 /**
76  * Writes the scores info to the given stream. Use this in ClientConnect to
77  * notify newly connecting players.
78  */
79 void ScoreInfo_Write(float targ);
80
81 /**
82  * Clear ALL scores (for ready-restart).
83  */
84 void Score_ClearAll();
85
86 /**
87  * Prints the scores to the console of a player.
88  */
89 void Score_NicePrint(entity to);
90
91 /**
92  * Sets the following results for the current scores entities.
93  */
94 void WinningConditionHelper();
95 float WinningConditionHelper_topscore;   ///< highest score
96 float WinningConditionHelper_equality;   ///< 1 if and only if the top two have equal scores
97 float WinningConditionHelper_winnerteam; ///< the color of the winning team, or -1 if none
98 entity WinningConditionHelper_winner;    ///< the winning 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  */
122 entity PlayerScore_Sort(.float field);