648ef60e844b8f316662ea633e5c6ac3ca2a12dc
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / stats.qh
1 #pragma once
2
3 #ifdef SVQC
4 #include <server/autocvars.qh>
5 #include <server/client.qh>
6 #endif
7
8 // Full list of all stat constants, included in a single location for easy reference
9 // 255 is the current limit (MAX_CL_STATS - 1), engine will need to be modified if you wish to add more stats
10
11 const int MAX_CL_STATS = 256;
12
13 // const int STAT_HEALTH = 0;
14 // const int STAT_ARMOR = 4;
15 // const int STAT_SHELLS = 6;
16 // const int STAT_NAILS = 7;
17 // const int STAT_ROCKETS = 8;
18 // const int STAT_CELLS = 9;
19 // const int STAT_ACTIVEWEAPON = 10;
20 // const int STAT_ITEMS = 15; // .items | .items2 << 23 | serverflags << 28
21 // const int STAT_VIEWHEIGHT = 16;
22
23 #if defined(CSQC)
24     #define g_stat_HEALTH getstati(STAT_HEALTH)
25     #define g_stat_ARMOR getstat_int(STAT_ARMOR)
26     #define g_stat_SHELLS getstat_int(STAT_SHELLS)
27     #define g_stat_NAILS getstat_int(STAT_NAILS)
28     #define g_stat_ROCKETS getstat_int(STAT_ROCKETS)
29     #define g_stat_CELLS getstat_int(STAT_CELLS)
30     #define g_stat_ACTIVEWEAPON getstat_int(STAT_ACTIVEWEAPON)
31     #define g_stat_ITEMS getstat_int(STAT_ITEMS)
32     #define g_stat_VIEWHEIGHT getstati(STAT_VIEWHEIGHT)
33 #elif defined(SVQC)
34     #define stat_HEALTH health
35     #define stat_ARMOR armorvalue
36     #define stat_SHELLS ammo_shells
37     #define stat_NAILS ammo_nails
38     #define stat_ROCKETS ammo_rockets
39     #define stat_CELLS ammo_cells
40     #define stat_ACTIVEWEAPON weapon
41     #define stat_ITEMS items
42     #define stat_VIEWHEIGHT view_ofs_z
43 #endif
44
45 #ifdef SVQC
46 vector weaponsInMap;
47 #endif
48 REGISTER_STAT(WEAPONS, vectori)
49 REGISTER_STAT(WEAPONSINMAP, vectori, weaponsInMap)
50
51 REGISTER_STAT(PL_VIEW_OFS, vector)
52 REGISTER_STAT(PL_CROUCH_VIEW_OFS, vector)
53
54 REGISTER_STAT(PL_MIN, vector)
55 REGISTER_STAT(PL_CROUCH_MIN, vector)
56
57 REGISTER_STAT(PL_MAX, vector)
58 REGISTER_STAT(PL_CROUCH_MAX, vector)
59
60 REGISTER_STAT(KH_KEYS, int)
61
62 #ifdef SVQC
63 float W_WeaponRateFactor(entity this);
64 float game_stopped;
65 float game_starttime;
66 float round_starttime;
67 bool autocvar_g_allow_oldvortexbeam;
68 int autocvar_leadlimit;
69 #endif
70 REGISTER_STAT(WEAPONRATEFACTOR, float, W_WeaponRateFactor(this))
71 REGISTER_STAT(GAME_STOPPED, int, game_stopped)
72 REGISTER_STAT(GAMESTARTTIME, float, game_starttime)
73 REGISTER_STAT(STRENGTH_FINISHED, float)
74 REGISTER_STAT(INVINCIBLE_FINISHED, float)
75 /** arc heat in [0,1] */
76 REGISTER_STAT(PRESSED_KEYS, int)
77 /** this stat could later contain some other bits of info, like, more server-side particle config */
78 REGISTER_STAT(ALLOW_OLDVORTEXBEAM, bool, autocvar_g_allow_oldvortexbeam)
79 REGISTER_STAT(FUEL, int)
80 REGISTER_STAT(NB_METERSTART, float)
81 /** compressShotOrigin */
82 REGISTER_STAT(SHOTORG, int)
83 REGISTER_STAT(LEADLIMIT, float, autocvar_leadlimit)
84
85 REGISTER_STAT(LAST_PICKUP, float)
86 REGISTER_STAT(HUD, int)
87 REGISTER_STAT(HIT_TIME, float)
88 REGISTER_STAT(DAMAGE_DEALT_TOTAL, int)
89 REGISTER_STAT(TYPEHIT_TIME, float)
90 REGISTER_STAT(SUPERWEAPONS_FINISHED, float)
91 REGISTER_STAT(VEHICLESTAT_HEALTH, int)
92 REGISTER_STAT(VEHICLESTAT_SHIELD, int)
93 REGISTER_STAT(VEHICLESTAT_ENERGY, int)
94 REGISTER_STAT(VEHICLESTAT_AMMO1, int)
95 REGISTER_STAT(VEHICLESTAT_RELOAD1, int)
96 REGISTER_STAT(VEHICLESTAT_AMMO2, int)
97 REGISTER_STAT(VEHICLESTAT_RELOAD2, int)
98 REGISTER_STAT(VEHICLESTAT_W2MODE, int)
99 REGISTER_STAT(NADE_TIMER, float)
100 REGISTER_STAT(SECRETS_TOTAL, float)
101 REGISTER_STAT(SECRETS_FOUND, float)
102 REGISTER_STAT(RESPAWN_TIME, float)
103 REGISTER_STAT(ROUNDSTARTTIME, float, round_starttime)
104 REGISTER_STAT(MONSTERS_TOTAL, int)
105 REGISTER_STAT(MONSTERS_KILLED, int)
106 REGISTER_STAT(BUFFS, int)
107 REGISTER_STAT(NADE_BONUS, float)
108 REGISTER_STAT(NADE_BONUS_TYPE, int)
109 REGISTER_STAT(NADE_BONUS_SCORE, float)
110 REGISTER_STAT(HEALING_ORB, float)
111 REGISTER_STAT(HEALING_ORB_ALPHA, float)
112 REGISTER_STAT(PLASMA, int)
113 REGISTER_STAT(FROZEN, int)
114 REGISTER_STAT(REVIVE_PROGRESS, float)
115 REGISTER_STAT(ROUNDLOST, int)
116 REGISTER_STAT(BUFF_TIME, float)
117 REGISTER_STAT(CTF_FLAGSTATUS, int)
118 REGISTER_STAT(CAPTURE_PROGRESS, float)
119 REGISTER_STAT(ENTRAP_ORB, float)
120 REGISTER_STAT(ENTRAP_ORB_ALPHA, float)
121 REGISTER_STAT(ITEMSTIME, int, autocvar_sv_itemstime)
122 REGISTER_STAT(KILL_TIME, float)
123
124 #ifdef SVQC
125 float autocvar_sv_showfps = 5;
126 #endif
127 REGISTER_STAT(SHOWFPS, float, autocvar_sv_showfps)
128
129 #ifdef SVQC
130 bool autocvar_g_ctf_leaderboard;
131 #endif
132 REGISTER_STAT(CTF_SHOWLEADERBOARD, bool, autocvar_g_ctf_leaderboard)
133
134 #ifdef SVQC
135 int autocvar_g_multijump;
136 float autocvar_g_multijump_add;
137 float autocvar_g_multijump_speed;
138 float autocvar_g_multijump_maxspeed;
139 float autocvar_g_multijump_dodging = 1;
140 #endif
141 REGISTER_STAT(MULTIJUMP_DODGING, int, autocvar_g_multijump_dodging)
142 REGISTER_STAT(MULTIJUMP_MAXSPEED, float, autocvar_g_multijump_maxspeed)
143 REGISTER_STAT(MULTIJUMP_ADD, int, autocvar_g_multijump_add)
144 REGISTER_STAT(MULTIJUMP_SPEED, float, autocvar_g_multijump_speed)
145 .int multijump_count;
146 REGISTER_STAT(MULTIJUMP_COUNT, int, this.multijump_count)
147 REGISTER_STAT(MULTIJUMP, int, autocvar_g_multijump)
148 REGISTER_STAT(DOUBLEJUMP, int, autocvar_sv_doublejump)
149
150 #ifdef SVQC
151 bool g_bugrigs;
152 bool g_bugrigs_planar_movement;
153 bool g_bugrigs_planar_movement_car_jumping;
154 float g_bugrigs_reverse_spinning;
155 float g_bugrigs_reverse_speeding;
156 float g_bugrigs_reverse_stopping;
157 float g_bugrigs_air_steering;
158 float g_bugrigs_angle_smoothing;
159 float g_bugrigs_friction_floor;
160 float g_bugrigs_friction_brake;
161 float g_bugrigs_friction_air;
162 float g_bugrigs_accel;
163 float g_bugrigs_speed_ref;
164 float g_bugrigs_speed_pow;
165 float g_bugrigs_steer;
166 #endif
167 REGISTER_STAT(BUGRIGS, int, g_bugrigs)
168 REGISTER_STAT(BUGRIGS_ACCEL, float, g_bugrigs_accel)
169 REGISTER_STAT(BUGRIGS_AIR_STEERING, int, g_bugrigs_air_steering)
170 REGISTER_STAT(BUGRIGS_ANGLE_SMOOTHING, int, g_bugrigs_angle_smoothing)
171 REGISTER_STAT(BUGRIGS_CAR_JUMPING, int, g_bugrigs_planar_movement_car_jumping)
172 REGISTER_STAT(BUGRIGS_FRICTION_AIR, float, g_bugrigs_friction_air)
173 REGISTER_STAT(BUGRIGS_FRICTION_BRAKE, float, g_bugrigs_friction_brake)
174 REGISTER_STAT(BUGRIGS_FRICTION_FLOOR, float, g_bugrigs_friction_floor)
175 REGISTER_STAT(BUGRIGS_PLANAR_MOVEMENT, int, g_bugrigs_planar_movement)
176 REGISTER_STAT(BUGRIGS_REVERSE_SPEEDING, int, g_bugrigs_reverse_speeding)
177 REGISTER_STAT(BUGRIGS_REVERSE_SPINNING, int, g_bugrigs_reverse_spinning)
178 REGISTER_STAT(BUGRIGS_REVERSE_STOPPING, int, g_bugrigs_reverse_stopping)
179 REGISTER_STAT(BUGRIGS_SPEED_POW, float, g_bugrigs_speed_pow)
180 REGISTER_STAT(BUGRIGS_SPEED_REF, float, g_bugrigs_speed_ref)
181 REGISTER_STAT(BUGRIGS_STEER, float, g_bugrigs_steer)
182
183 #ifdef SVQC
184 int autocvar_sv_gameplayfix_downtracesupportsongroundflag;
185 int autocvar_sv_gameplayfix_easierwaterjump;
186 int autocvar_sv_gameplayfix_stepdown;
187 int autocvar_sv_gameplayfix_stepmultipletimes;
188 int autocvar_sv_gameplayfix_unstickplayers;
189 int autocvar_sv_gameplayfix_fixedcheckwatertransition;
190 #endif
191 REGISTER_STAT(GAMEPLAYFIX_DOWNTRACEONGROUND, int, autocvar_sv_gameplayfix_downtracesupportsongroundflag)
192 REGISTER_STAT(GAMEPLAYFIX_EASIERWATERJUMP, int, autocvar_sv_gameplayfix_easierwaterjump)
193 REGISTER_STAT(GAMEPLAYFIX_STEPDOWN, int, autocvar_sv_gameplayfix_stepdown)
194 REGISTER_STAT(GAMEPLAYFIX_STEPMULTIPLETIMES, int, autocvar_sv_gameplayfix_stepmultipletimes)
195 REGISTER_STAT(GAMEPLAYFIX_UNSTICKPLAYERS, int, autocvar_sv_gameplayfix_unstickplayers)
196 REGISTER_STAT(GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND, int, autocvar_sv_gameplayfix_upwardvelocityclearsongroundflag)
197 REGISTER_STAT(GAMEPLAYFIX_WATERTRANSITION, int, autocvar_sv_gameplayfix_fixedcheckwatertransition)
198
199 REGISTER_STAT(MOVEVARS_JUMPSTEP, int, cvar("sv_jumpstep"))
200 REGISTER_STAT(NOSTEP, int, cvar("sv_nostep"))
201
202 REGISTER_STAT(MOVEVARS_FRICTION, float)
203 REGISTER_STAT(MOVEVARS_FRICTION_SLICK, float, autocvar_sv_friction_slick)
204 REGISTER_STAT(MOVEVARS_FRICTION_ONLAND, float, autocvar_sv_friction_on_land)
205
206 REGISTER_STAT(MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS, int, autocvar_sv_jumpspeedcap_max_disable_on_ramps)
207 REGISTER_STAT(MOVEVARS_TRACK_CANJUMP, int)
208 /** cvar loopback */
209 REGISTER_STAT(MOVEVARS_CL_TRACK_CANJUMP, int)
210
211 #ifdef SVQC
212 int g_dodging;
213 float autocvar_sv_dodging_delay;
214 float autocvar_sv_dodging_wall_distance_threshold;
215 bool autocvar_sv_dodging_frozen;
216 bool autocvar_sv_dodging_frozen_doubletap;
217 float autocvar_sv_dodging_height_threshold;
218 float autocvar_sv_dodging_horiz_speed_min;
219 float autocvar_sv_dodging_horiz_speed_max;
220 float autocvar_sv_dodging_horiz_force_slowest;
221 float autocvar_sv_dodging_horiz_force_fastest;
222 float autocvar_sv_dodging_horiz_force_frozen;
223 float autocvar_sv_dodging_ramp_time;
224 float autocvar_sv_dodging_up_speed;
225 bool autocvar_sv_dodging_wall_dodging;
226 bool autocvar_sv_dodging_air_dodging;
227 float autocvar_sv_dodging_maxspeed;
228 float autocvar_sv_dodging_air_maxspeed;
229 #endif
230
231 #if 0
232 REGISTER_STAT(DODGING, int, g_dodging)
233 REGISTER_STAT(DODGING_DELAY, float, autocvar_sv_dodging_delay)
234 REGISTER_STAT(DODGING_DISTANCE_THRESHOLD, float, autocvar_sv_dodging_wall_distance_threshold)
235 REGISTER_STAT(DODGING_FROZEN_DOUBLETAP, int, autocvar_sv_dodging_frozen_doubletap)
236 REGISTER_STAT(DODGING_HEIGHT_THRESHOLD, float, autocvar_sv_dodging_height_threshold)
237 REGISTER_STAT(DODGING_HORIZ_SPEED_MIN, float, autocvar_sv_dodging_horiz_speed_min)
238 REGISTER_STAT(DODGING_HORIZ_SPEED_MAX, float, autocvar_sv_dodging_horiz_speed_max)
239 REGISTER_STAT(DODGING_HORIZ_FORCE_SLOWEST, float, autocvar_sv_dodging_horiz_force_slowest)
240 REGISTER_STAT(DODGING_HORIZ_FORCE_FASTEST, float, autocvar_sv_dodging_horiz_force_fastest)
241 REGISTER_STAT(DODGING_HORIZ_FORCE_FROZEN, float, autocvar_sv_dodging_horiz_force_frozen)
242 REGISTER_STAT(DODGING_RAMP_TIME, float, autocvar_sv_dodging_ramp_time)
243 REGISTER_STAT(DODGING_UP_SPEED, float, autocvar_sv_dodging_up_speed)
244 REGISTER_STAT(DODGING_WALL, bool, autocvar_sv_dodging_wall_dodging)
245 REGISTER_STAT(DODGING_AIR, bool, autocvar_sv_dodging_air_dodging)
246 REGISTER_STAT(DODGING_MAXSPEED, float, autocvar_sv_dodging_maxspeed)
247 REGISTER_STAT(DODGING_AIR_MAXSPEED, float, autocvar_sv_dodging_air_maxspeed)
248 #endif
249 /** cvar loopback */
250 REGISTER_STAT(DODGING_FROZEN, int, autocvar_sv_dodging_frozen)
251 REGISTER_STAT(DODGING_TIMEOUT, float)
252
253 REGISTER_STAT(JETPACK_ACCEL_SIDE, float, autocvar_g_jetpack_acceleration_side)
254 REGISTER_STAT(JETPACK_ACCEL_UP, float, autocvar_g_jetpack_acceleration_up)
255 REGISTER_STAT(JETPACK_ANTIGRAVITY, float, autocvar_g_jetpack_antigravity)
256 REGISTER_STAT(JETPACK_FUEL, float, autocvar_g_jetpack_fuel)
257 REGISTER_STAT(JETPACK_MAXSPEED_SIDE, float, autocvar_g_jetpack_maxspeed_side)
258 REGISTER_STAT(JETPACK_MAXSPEED_UP, float, autocvar_g_jetpack_maxspeed_up)
259 REGISTER_STAT(JETPACK_REVERSE_THRUST, float, autocvar_g_jetpack_reverse_thrust)
260
261 REGISTER_STAT(MOVEVARS_HIGHSPEED, float)
262
263 #ifdef SVQC
264 AUTOCVAR(g_walljump, bool, false, "Enable wall jumping mutator");
265 AUTOCVAR(g_walljump_delay, float, 1, "Minimum delay between wall jumps");
266 AUTOCVAR(g_walljump_force, float, 300, "How far to bounce/jump off the wall");
267 AUTOCVAR(g_walljump_velocity_xy_factor, float, 1.15, "How much to slow down along horizontal axis, higher value = higher deceleration, if factor is < 1, you accelerate by wall jumping");
268 AUTOCVAR(g_walljump_velocity_z_factor, float, 0.5, "Upwards velocity factor, multiplied by normal jump velocity");
269 #endif
270 REGISTER_STAT(WALLJUMP, int, autocvar_g_walljump)
271 REGISTER_STAT(WALLJUMP_VELOCITY_Z_FACTOR, float, autocvar_g_walljump_velocity_z_factor)
272 REGISTER_STAT(WALLJUMP_VELOCITY_XY_FACTOR, float, autocvar_g_walljump_velocity_xy_factor)
273 REGISTER_STAT(WALLJUMP_DELAY, float, autocvar_g_walljump_delay)
274 REGISTER_STAT(WALLJUMP_FORCE, float, autocvar_g_walljump_force)
275 REGISTER_STAT(LASTWJ, float)
276
277 // freeze tag, clan arena
278 REGISTER_STAT(REDALIVE, int)
279 REGISTER_STAT(BLUEALIVE, int)
280 REGISTER_STAT(YELLOWALIVE, int)
281 REGISTER_STAT(PINKALIVE, int)
282
283 // domination
284 REGISTER_STAT(DOM_TOTAL_PPS, float)
285 REGISTER_STAT(DOM_PPS_RED, float)
286 REGISTER_STAT(DOM_PPS_BLUE, float)
287 REGISTER_STAT(DOM_PPS_YELLOW, float)
288 REGISTER_STAT(DOM_PPS_PINK, float)
289
290 REGISTER_STAT(TELEPORT_MAXSPEED, float, autocvar_g_teleport_maxspeed)
291 REGISTER_STAT(TELEPORT_TELEFRAG_AVOID, int, autocvar_g_telefrags_avoid)
292
293 REGISTER_STAT(CAMERA_SPECTATOR, int)
294
295 REGISTER_STAT(SPECTATORSPEED, float)
296
297 #ifdef SVQC
298 bool autocvar_sv_slick_applygravity;
299 #endif
300 REGISTER_STAT(SLICK_APPLYGRAVITY, bool, autocvar_sv_slick_applygravity)
301
302 #ifdef SVQC
303 #include "physics/movetypes/movetypes.qh"
304 float warmup_limit;
305 #endif
306
307 #ifdef SVQC
308 bool autocvar_g_shootfromcenter;
309 bool autocvar_g_shootfromeye;
310 #endif
311 REGISTER_STAT(SHOOTFROMEYE, bool, autocvar_g_shootfromeye)
312 REGISTER_STAT(SHOOTFROMCENTER, bool, autocvar_g_shootfromcenter)
313
314 REGISTER_STAT(MOVEVARS_AIRACCEL_QW_STRETCHFACTOR, float)
315 REGISTER_STAT(MOVEVARS_AIRCONTROL_PENALTY, float)
316 REGISTER_STAT(MOVEVARS_AIRSPEEDLIMIT_NONQW, float)
317 REGISTER_STAT(MOVEVARS_AIRSTRAFEACCEL_QW, float)
318 REGISTER_STAT(MOVEVARS_AIRCONTROL_POWER, float)
319 REGISTER_STAT(MOVEVARS_AIRCONTROL_BACKWARDS, bool)
320 REGISTER_STAT(MOVEVARS_AIRCONTROL_SIDEWARDS, bool)
321 noref bool autocvar_sv_gameplayfix_nogravityonground;
322 REGISTER_STAT(MOVEFLAGS, int, MOVEFLAG_VALID
323                               | (autocvar_sv_gameplayfix_q2airaccelerate ? MOVEFLAG_Q2AIRACCELERATE : 0)
324                               | (autocvar_sv_gameplayfix_nogravityonground ? MOVEFLAG_NOGRAVITYONGROUND : 0)
325                               | (autocvar_sv_gameplayfix_gravityunaffectedbyticrate ? MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE : 0))
326
327 REGISTER_STAT(MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL, float)
328 REGISTER_STAT(MOVEVARS_WARSOWBUNNY_ACCEL, float)
329 REGISTER_STAT(MOVEVARS_WARSOWBUNNY_TOPSPEED, float)
330 REGISTER_STAT(MOVEVARS_WARSOWBUNNY_TURNACCEL, float)
331 REGISTER_STAT(MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO, float)
332
333 REGISTER_STAT(MOVEVARS_AIRSTOPACCELERATE, float)
334 REGISTER_STAT(MOVEVARS_AIRSTRAFEACCELERATE, float)
335 REGISTER_STAT(MOVEVARS_MAXAIRSTRAFESPEED, float)
336 REGISTER_STAT(MOVEVARS_AIRCONTROL, float)
337 REGISTER_STAT(FRAGLIMIT, float, autocvar_fraglimit)
338 REGISTER_STAT(TIMELIMIT, float, autocvar_timelimit)
339 REGISTER_STAT(WARMUP_TIMELIMIT, float, warmup_limit)
340 #ifdef SVQC
341 float autocvar_sv_wallfriction;
342 #endif
343 REGISTER_STAT(MOVEVARS_WALLFRICTION, int, autocvar_sv_wallfriction)
344 REGISTER_STAT(MOVEVARS_TICRATE, float, autocvar_sys_ticrate)
345 REGISTER_STAT(MOVEVARS_TIMESCALE, float, autocvar_slowmo)
346 REGISTER_STAT(MOVEVARS_GRAVITY, float, autocvar_sv_gravity)
347 REGISTER_STAT(MOVEVARS_STOPSPEED, float)
348 REGISTER_STAT(MOVEVARS_MAXSPEED, float)
349 REGISTER_STAT(MOVEVARS_ACCELERATE, float)
350 REGISTER_STAT(MOVEVARS_AIRACCELERATE, float)
351 .float gravity;
352 // FIXME: Was 0 on server, 1 on client. Still want that?
353 REGISTER_STAT(MOVEVARS_ENTGRAVITY, float, (this.gravity) ? this.gravity : 1)
354 REGISTER_STAT(MOVEVARS_JUMPVELOCITY, float)
355 REGISTER_STAT(MOVEVARS_JUMPVELOCITY_CROUCH, float)
356 REGISTER_STAT(MOVEVARS_MAXAIRSPEED, float)
357 REGISTER_STAT(MOVEVARS_STEPHEIGHT, float, autocvar_sv_stepheight)
358 REGISTER_STAT(MOVEVARS_AIRACCEL_QW, float)
359 REGISTER_STAT(MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION, float)
360 REGISTER_STAT(MOVEVARS_SPECIALCOMMAND, bool)
361
362
363 #ifdef CSQC
364 noref int autocvar_cl_gunalign;
365 #endif
366 #ifdef SVQC
367 .int cvar_cl_gunalign;
368 REPLICATE(cvar_cl_gunalign, int, "cl_gunalign");
369 #endif
370 REGISTER_STAT(GUNALIGN, int)
371 #ifdef SVQC
372 SPECTATE_COPYFIELD(_STAT(GUNALIGN))
373 #endif