]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/scores.qh
implement battle royale gamemode in xonotic
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / scores.qh
1 #pragma once
2
3 #define MAX_SCORE 64
4
5 #define REGISTER_SP(id) REGISTER(Scores, SP, id, m_id, new_pure(PlayerScoreField))
6 REGISTRY(Scores, MAX_SCORE);
7 REGISTER_REGISTRY(Scores)
8 REGISTRY_SORT(Scores);
9 REGISTRY_CHECK(Scores);
10
11 REGISTRY_DEFINE_GET(Scores, NULL)
12 STATIC_INIT(Scores_renumber) { FOREACH(Scores, true, it.m_id = i); }
13
14 /*
15  * Score indices
16  */
17
18 // game mode specific indices are not in common/, but in server/scores_rules.qc!
19 #ifdef GAMEQC
20 // fields not networked via the score system
21 REGISTER_SP(END);
22
23 REGISTER_SP(PING);
24 REGISTER_SP(PL);
25 REGISTER_SP(NAME);
26 REGISTER_SP(SEPARATOR);
27
28 REGISTER_SP(KDRATIO); // kills / deaths
29 REGISTER_SP(SUM); // kills - deaths
30 REGISTER_SP(FRAGS); // kills - suicides
31
32 // networked fields
33
34 REGISTER_SP(SCORE);
35
36 REGISTER_SP(DMG);
37 REGISTER_SP(DMGTAKEN);
38
39 REGISTER_SP(KILLS);
40 REGISTER_SP(DEATHS);
41 REGISTER_SP(SUICIDES);
42 REGISTER_SP(TEAMKILLS);
43
44 REGISTER_SP(ELO);
45
46 REGISTER_SP(FPS);
47
48 // TODO: move to common mutators
49
50 REGISTER_SP(RACE_TIME);
51 REGISTER_SP(RACE_LAPS);
52 REGISTER_SP(RACE_FASTEST);
53
54 //REGISTER_SP(CTS_TIME);
55 //REGISTER_SP(CTS_LAPS);
56 //REGISTER_SP(CTS_FASTEST);
57
58 REGISTER_SP(ASSAULT_OBJECTIVES);
59
60 REGISTER_SP(CTF_PICKUPS);
61 REGISTER_SP(CTF_FCKILLS);
62 REGISTER_SP(CTF_RETURNS);
63 REGISTER_SP(CTF_CAPS);
64 REGISTER_SP(CTF_CAPTIME);
65 REGISTER_SP(CTF_DROPS);
66
67 REGISTER_SP(DOM_TAKES);
68 REGISTER_SP(DOM_TICKS);
69
70 REGISTER_SP(FREEZETAG_REVIVALS);
71
72 REGISTER_SP(KEEPAWAY_PICKUPS);
73 REGISTER_SP(KEEPAWAY_BCTIME);
74 REGISTER_SP(KEEPAWAY_CARRIERKILLS);
75
76 REGISTER_SP(KH_PICKUPS);
77 REGISTER_SP(KH_CAPS);
78 REGISTER_SP(KH_KCKILLS);
79 REGISTER_SP(KH_PUSHES);
80 REGISTER_SP(KH_DESTROYS);
81 REGISTER_SP(KH_LOSSES);
82
83 REGISTER_SP(LMS_RANK);
84 REGISTER_SP(LMS_LIVES);
85
86 REGISTER_SP(NEXBALL_GOALS);
87 REGISTER_SP(NEXBALL_FAULTS);
88
89 REGISTER_SP(ONS_TAKES);
90 REGISTER_SP(ONS_CAPS);
91
92 REGISTER_SP(BR_RANK);
93 REGISTER_SP(BR_SQUAD);
94 REGISTER_SP(BR_REVIVALS);
95 #endif
96
97
98 // the stuff you don't need to see
99
100 /**
101  * Lower scores are better (e.g. suicides)
102  */
103 const int SFL_LOWER_IS_BETTER = BIT(0);
104
105 /**
106  * Don't show zero values as scores
107  */
108 const int SFL_HIDE_ZERO = BIT(1);
109
110 /**
111  * Allow a column to be hidden (do not automatically add it even if it is a sorting key)
112  */
113 const int SFL_ALLOW_HIDE = BIT(4);
114
115 /**
116  * Display as a rank (with st, nd, rd, th suffix)
117  */
118 const int SFL_RANK = BIT(5);
119
120 /**
121  * Display as mm:ss.s, value is stored as 10ths of a second (AND 0 is the worst possible value!)
122  */
123 const int SFL_TIME = BIT(6);
124
125 // not an extra constant yet
126 #define SFL_ZERO_IS_WORST SFL_TIME
127
128 /**
129  * Scoring priority (NOTE: PRIMARY is used for fraglimit)
130  */
131 const int SFL_SORT_PRIO_SECONDARY = 4;
132 const int SFL_SORT_PRIO_PRIMARY = 8;
133 const int SFL_SORT_PRIO_MASK = 12;
134
135 #define IS_INCREASING(x) ( (x) & SFL_LOWER_IS_BETTER )
136 #define IS_DECREASING(x) ( !((x) & SFL_LOWER_IS_BETTER) )
137
138 USING(PlayerScoreField, entity);
139 .int _scores[MAX_SCORE];
140 .string m_name;
141 .int m_flags;
142
143 #define scores(this) _scores[(this).m_id]
144 #define scores_label(this) ((this).m_name)
145 #define scores_flags(this) ((this).m_flags)
146
147 #define MAX_TEAMSCORE 2
148 USING(ScoreTeam, string);
149 .int _teamscores[MAX_TEAMSCORE];
150 #define teamscores(i) _teamscores[i]
151 string _teamscores_label[MAX_TEAMSCORE];
152 #define teamscores_label(i) _teamscores_label[i]
153 int _teamscores_flags[MAX_TEAMSCORE];
154 #define teamscores_flags(i) _teamscores_flags[i]
155
156 const int ST_SCORE = 0;