Add a new nade type
[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 REGISTER_STAT(VEIL_ORB, float)
124 REGISTER_STAT(VEIL_ORB_ALPHA, float)
125
126 #ifdef SVQC
127 float autocvar_sv_showfps = 5;
128 #endif
129 REGISTER_STAT(SHOWFPS, float, autocvar_sv_showfps)
130
131 #ifdef SVQC
132 bool autocvar_g_ctf_leaderboard;
133 #endif
134 REGISTER_STAT(CTF_SHOWLEADERBOARD, bool, autocvar_g_ctf_leaderboard)
135
136 #ifdef SVQC
137 int autocvar_g_multijump;
138 float autocvar_g_multijump_add;
139 float autocvar_g_multijump_speed;
140 float autocvar_g_multijump_maxspeed;
141 float autocvar_g_multijump_dodging = 1;
142 #endif
143 REGISTER_STAT(MULTIJUMP_DODGING, int, autocvar_g_multijump_dodging)
144 REGISTER_STAT(MULTIJUMP_MAXSPEED, float, autocvar_g_multijump_maxspeed)
145 REGISTER_STAT(MULTIJUMP_ADD, int, autocvar_g_multijump_add)
146 REGISTER_STAT(MULTIJUMP_SPEED, float, autocvar_g_multijump_speed)
147 .int multijump_count;
148 REGISTER_STAT(MULTIJUMP_COUNT, int, this.multijump_count)
149 REGISTER_STAT(MULTIJUMP, int, autocvar_g_multijump)
150 REGISTER_STAT(DOUBLEJUMP, int, autocvar_sv_doublejump)
151
152 #ifdef SVQC
153 bool g_bugrigs;
154 bool g_bugrigs_planar_movement;
155 bool g_bugrigs_planar_movement_car_jumping;
156 float g_bugrigs_reverse_spinning;
157 float g_bugrigs_reverse_speeding;
158 float g_bugrigs_reverse_stopping;
159 float g_bugrigs_air_steering;
160 float g_bugrigs_angle_smoothing;
161 float g_bugrigs_friction_floor;
162 float g_bugrigs_friction_brake;
163 float g_bugrigs_friction_air;
164 float g_bugrigs_accel;
165 float g_bugrigs_speed_ref;
166 float g_bugrigs_speed_pow;
167 float g_bugrigs_steer;
168 #endif
169 REGISTER_STAT(BUGRIGS, int, g_bugrigs)
170 REGISTER_STAT(BUGRIGS_ACCEL, float, g_bugrigs_accel)
171 REGISTER_STAT(BUGRIGS_AIR_STEERING, int, g_bugrigs_air_steering)
172 REGISTER_STAT(BUGRIGS_ANGLE_SMOOTHING, int, g_bugrigs_angle_smoothing)
173 REGISTER_STAT(BUGRIGS_CAR_JUMPING, int, g_bugrigs_planar_movement_car_jumping)
174 REGISTER_STAT(BUGRIGS_FRICTION_AIR, float, g_bugrigs_friction_air)
175 REGISTER_STAT(BUGRIGS_FRICTION_BRAKE, float, g_bugrigs_friction_brake)
176 REGISTER_STAT(BUGRIGS_FRICTION_FLOOR, float, g_bugrigs_friction_floor)
177 REGISTER_STAT(BUGRIGS_PLANAR_MOVEMENT, int, g_bugrigs_planar_movement)
178 REGISTER_STAT(BUGRIGS_REVERSE_SPEEDING, int, g_bugrigs_reverse_speeding)
179 REGISTER_STAT(BUGRIGS_REVERSE_SPINNING, int, g_bugrigs_reverse_spinning)
180 REGISTER_STAT(BUGRIGS_REVERSE_STOPPING, int, g_bugrigs_reverse_stopping)
181 REGISTER_STAT(BUGRIGS_SPEED_POW, float, g_bugrigs_speed_pow)
182 REGISTER_STAT(BUGRIGS_SPEED_REF, float, g_bugrigs_speed_ref)
183 REGISTER_STAT(BUGRIGS_STEER, float, g_bugrigs_steer)
184
185 #ifdef SVQC
186 int autocvar_sv_gameplayfix_downtracesupportsongroundflag;
187 int autocvar_sv_gameplayfix_easierwaterjump;
188 int autocvar_sv_gameplayfix_stepdown;
189 int autocvar_sv_gameplayfix_stepmultipletimes;
190 int autocvar_sv_gameplayfix_unstickplayers;
191 int autocvar_sv_gameplayfix_fixedcheckwatertransition;
192 #endif
193 REGISTER_STAT(GAMEPLAYFIX_DOWNTRACEONGROUND, int, autocvar_sv_gameplayfix_downtracesupportsongroundflag)
194 REGISTER_STAT(GAMEPLAYFIX_EASIERWATERJUMP, int, autocvar_sv_gameplayfix_easierwaterjump)
195 REGISTER_STAT(GAMEPLAYFIX_STEPDOWN, int, autocvar_sv_gameplayfix_stepdown)
196 REGISTER_STAT(GAMEPLAYFIX_STEPMULTIPLETIMES, int, autocvar_sv_gameplayfix_stepmultipletimes)
197 REGISTER_STAT(GAMEPLAYFIX_UNSTICKPLAYERS, int, autocvar_sv_gameplayfix_unstickplayers)
198 REGISTER_STAT(GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND, int, autocvar_sv_gameplayfix_upwardvelocityclearsongroundflag)
199 REGISTER_STAT(GAMEPLAYFIX_WATERTRANSITION, int, autocvar_sv_gameplayfix_fixedcheckwatertransition)
200
201 REGISTER_STAT(MOVEVARS_JUMPSTEP, int, cvar("sv_jumpstep"))
202 REGISTER_STAT(NOSTEP, int, cvar("sv_nostep"))
203
204 REGISTER_STAT(MOVEVARS_FRICTION, float)
205 REGISTER_STAT(MOVEVARS_FRICTION_SLICK, float, autocvar_sv_friction_slick)
206 REGISTER_STAT(MOVEVARS_FRICTION_ONLAND, float, autocvar_sv_friction_on_land)
207
208 REGISTER_STAT(MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS, int, autocvar_sv_jumpspeedcap_max_disable_on_ramps)
209 REGISTER_STAT(MOVEVARS_TRACK_CANJUMP, int)
210 /** cvar loopback */
211 REGISTER_STAT(MOVEVARS_CL_TRACK_CANJUMP, int)
212
213 #ifdef SVQC
214 int g_dodging;
215 float autocvar_sv_dodging_delay;
216 float autocvar_sv_dodging_wall_distance_threshold;
217 bool autocvar_sv_dodging_frozen;
218 bool autocvar_sv_dodging_frozen_doubletap;
219 float autocvar_sv_dodging_height_threshold;
220 float autocvar_sv_dodging_horiz_speed_min;
221 float autocvar_sv_dodging_horiz_speed_max;
222 float autocvar_sv_dodging_horiz_force_slowest;
223 float autocvar_sv_dodging_horiz_force_fastest;
224 float autocvar_sv_dodging_horiz_force_frozen;
225 float autocvar_sv_dodging_ramp_time;
226 float autocvar_sv_dodging_up_speed;
227 bool autocvar_sv_dodging_wall_dodging;
228 bool autocvar_sv_dodging_air_dodging;
229 float autocvar_sv_dodging_maxspeed;
230 float autocvar_sv_dodging_air_maxspeed;
231 #endif
232
233 #if 0
234 REGISTER_STAT(DODGING, int, g_dodging)
235 REGISTER_STAT(DODGING_DELAY, float, autocvar_sv_dodging_delay)
236 REGISTER_STAT(DODGING_DISTANCE_THRESHOLD, float, autocvar_sv_dodging_wall_distance_threshold)
237 REGISTER_STAT(DODGING_FROZEN_DOUBLETAP, int, autocvar_sv_dodging_frozen_doubletap)
238 REGISTER_STAT(DODGING_HEIGHT_THRESHOLD, float, autocvar_sv_dodging_height_threshold)
239 REGISTER_STAT(DODGING_HORIZ_SPEED_MIN, float, autocvar_sv_dodging_horiz_speed_min)
240 REGISTER_STAT(DODGING_HORIZ_SPEED_MAX, float, autocvar_sv_dodging_horiz_speed_max)
241 REGISTER_STAT(DODGING_HORIZ_FORCE_SLOWEST, float, autocvar_sv_dodging_horiz_force_slowest)
242 REGISTER_STAT(DODGING_HORIZ_FORCE_FASTEST, float, autocvar_sv_dodging_horiz_force_fastest)
243 REGISTER_STAT(DODGING_HORIZ_FORCE_FROZEN, float, autocvar_sv_dodging_horiz_force_frozen)
244 REGISTER_STAT(DODGING_RAMP_TIME, float, autocvar_sv_dodging_ramp_time)
245 REGISTER_STAT(DODGING_UP_SPEED, float, autocvar_sv_dodging_up_speed)
246 REGISTER_STAT(DODGING_WALL, bool, autocvar_sv_dodging_wall_dodging)
247 REGISTER_STAT(DODGING_AIR, bool, autocvar_sv_dodging_air_dodging)
248 REGISTER_STAT(DODGING_MAXSPEED, float, autocvar_sv_dodging_maxspeed)
249 REGISTER_STAT(DODGING_AIR_MAXSPEED, float, autocvar_sv_dodging_air_maxspeed)
250 #endif
251 /** cvar loopback */
252 REGISTER_STAT(DODGING_FROZEN, int, autocvar_sv_dodging_frozen)
253 REGISTER_STAT(DODGING_TIMEOUT, float)
254
255 REGISTER_STAT(JETPACK_ACCEL_SIDE, float, autocvar_g_jetpack_acceleration_side)
256 REGISTER_STAT(JETPACK_ACCEL_UP, float, autocvar_g_jetpack_acceleration_up)
257 REGISTER_STAT(JETPACK_ANTIGRAVITY, float, autocvar_g_jetpack_antigravity)
258 REGISTER_STAT(JETPACK_FUEL, float, autocvar_g_jetpack_fuel)
259 REGISTER_STAT(JETPACK_MAXSPEED_SIDE, float, autocvar_g_jetpack_maxspeed_side)
260 REGISTER_STAT(JETPACK_MAXSPEED_UP, float, autocvar_g_jetpack_maxspeed_up)
261 REGISTER_STAT(JETPACK_REVERSE_THRUST, float, autocvar_g_jetpack_reverse_thrust)
262
263 REGISTER_STAT(MOVEVARS_HIGHSPEED, float)
264
265 #ifdef SVQC
266 AUTOCVAR(g_walljump, bool, false, "Enable wall jumping mutator");
267 AUTOCVAR(g_walljump_delay, float, 1, "Minimum delay between wall jumps");
268 AUTOCVAR(g_walljump_force, float, 300, "How far to bounce/jump off the wall");
269 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");
270 AUTOCVAR(g_walljump_velocity_z_factor, float, 0.5, "Upwards velocity factor, multiplied by normal jump velocity");
271 #endif
272 REGISTER_STAT(WALLJUMP, int, autocvar_g_walljump)
273 REGISTER_STAT(WALLJUMP_VELOCITY_Z_FACTOR, float, autocvar_g_walljump_velocity_z_factor)
274 REGISTER_STAT(WALLJUMP_VELOCITY_XY_FACTOR, float, autocvar_g_walljump_velocity_xy_factor)
275 REGISTER_STAT(WALLJUMP_DELAY, float, autocvar_g_walljump_delay)
276 REGISTER_STAT(WALLJUMP_FORCE, float, autocvar_g_walljump_force)
277 REGISTER_STAT(LASTWJ, float)
278
279 // freeze tag, clan arena
280 REGISTER_STAT(REDALIVE, int)
281 REGISTER_STAT(BLUEALIVE, int)
282 REGISTER_STAT(YELLOWALIVE, int)
283 REGISTER_STAT(PINKALIVE, int)
284
285 // domination
286 REGISTER_STAT(DOM_TOTAL_PPS, float)
287 REGISTER_STAT(DOM_PPS_RED, float)
288 REGISTER_STAT(DOM_PPS_BLUE, float)
289 REGISTER_STAT(DOM_PPS_YELLOW, float)
290 REGISTER_STAT(DOM_PPS_PINK, float)
291
292 REGISTER_STAT(TELEPORT_MAXSPEED, float, autocvar_g_teleport_maxspeed)
293 REGISTER_STAT(TELEPORT_TELEFRAG_AVOID, int, autocvar_g_telefrags_avoid)
294
295 REGISTER_STAT(CAMERA_SPECTATOR, int)
296
297 REGISTER_STAT(SPECTATORSPEED, float)
298
299 #ifdef SVQC
300 bool autocvar_sv_slick_applygravity;
301 #endif
302 REGISTER_STAT(SLICK_APPLYGRAVITY, bool, autocvar_sv_slick_applygravity)
303
304 #ifdef SVQC
305 #include "physics/movetypes/movetypes.qh"
306 float warmup_limit;
307 #endif
308
309 #ifdef SVQC
310 bool autocvar_g_shootfromcenter;
311 bool autocvar_g_shootfromeye;
312 #endif
313 REGISTER_STAT(SHOOTFROMEYE, bool, autocvar_g_shootfromeye)
314 REGISTER_STAT(SHOOTFROMCENTER, bool, autocvar_g_shootfromcenter)
315
316 REGISTER_STAT(MOVEVARS_AIRACCEL_QW_STRETCHFACTOR, float)
317 REGISTER_STAT(MOVEVARS_AIRCONTROL_PENALTY, float)
318 REGISTER_STAT(MOVEVARS_AIRSPEEDLIMIT_NONQW, float)
319 REGISTER_STAT(MOVEVARS_AIRSTRAFEACCEL_QW, float)
320 REGISTER_STAT(MOVEVARS_AIRCONTROL_POWER, float)
321 REGISTER_STAT(MOVEVARS_AIRCONTROL_BACKWARDS, bool)
322 REGISTER_STAT(MOVEVARS_AIRCONTROL_SIDEWARDS, bool)
323 noref bool autocvar_sv_gameplayfix_nogravityonground;
324 REGISTER_STAT(MOVEFLAGS, int, MOVEFLAG_VALID
325                               | (autocvar_sv_gameplayfix_q2airaccelerate ? MOVEFLAG_Q2AIRACCELERATE : 0)
326                               | (autocvar_sv_gameplayfix_nogravityonground ? MOVEFLAG_NOGRAVITYONGROUND : 0)
327                               | (autocvar_sv_gameplayfix_gravityunaffectedbyticrate ? MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE : 0))
328
329 REGISTER_STAT(MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL, float)
330 REGISTER_STAT(MOVEVARS_WARSOWBUNNY_ACCEL, float)
331 REGISTER_STAT(MOVEVARS_WARSOWBUNNY_TOPSPEED, float)
332 REGISTER_STAT(MOVEVARS_WARSOWBUNNY_TURNACCEL, float)
333 REGISTER_STAT(MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO, float)
334
335 REGISTER_STAT(MOVEVARS_AIRSTOPACCELERATE, float)
336 REGISTER_STAT(MOVEVARS_AIRSTRAFEACCELERATE, float)
337 REGISTER_STAT(MOVEVARS_MAXAIRSTRAFESPEED, float)
338 REGISTER_STAT(MOVEVARS_AIRCONTROL, float)
339 REGISTER_STAT(FRAGLIMIT, float, autocvar_fraglimit)
340 REGISTER_STAT(TIMELIMIT, float, autocvar_timelimit)
341 REGISTER_STAT(WARMUP_TIMELIMIT, float, warmup_limit)
342 #ifdef SVQC
343 float autocvar_sv_wallfriction;
344 #endif
345 REGISTER_STAT(MOVEVARS_WALLFRICTION, int, autocvar_sv_wallfriction)
346 REGISTER_STAT(MOVEVARS_TICRATE, float, autocvar_sys_ticrate)
347 REGISTER_STAT(MOVEVARS_TIMESCALE, float, autocvar_slowmo)
348 REGISTER_STAT(MOVEVARS_GRAVITY, float, autocvar_sv_gravity)
349 REGISTER_STAT(MOVEVARS_STOPSPEED, float)
350 REGISTER_STAT(MOVEVARS_MAXSPEED, float)
351 REGISTER_STAT(MOVEVARS_ACCELERATE, float)
352 REGISTER_STAT(MOVEVARS_AIRACCELERATE, float)
353 .float gravity;
354 // FIXME: Was 0 on server, 1 on client. Still want that?
355 REGISTER_STAT(MOVEVARS_ENTGRAVITY, float, (this.gravity) ? this.gravity : 1)
356 REGISTER_STAT(MOVEVARS_JUMPVELOCITY, float)
357 REGISTER_STAT(MOVEVARS_JUMPVELOCITY_CROUCH, float)
358 REGISTER_STAT(MOVEVARS_MAXAIRSPEED, float)
359 REGISTER_STAT(MOVEVARS_STEPHEIGHT, float, autocvar_sv_stepheight)
360 REGISTER_STAT(MOVEVARS_AIRACCEL_QW, float)
361 REGISTER_STAT(MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION, float)
362 REGISTER_STAT(MOVEVARS_SPECIALCOMMAND, bool)
363
364
365 #ifdef CSQC
366 noref int autocvar_cl_gunalign;
367 #endif
368 #ifdef SVQC
369 .int cvar_cl_gunalign;
370 REPLICATE(cvar_cl_gunalign, int, "cl_gunalign");
371 #endif
372 REGISTER_STAT(GUNALIGN, int)
373 #ifdef SVQC
374 SPECTATE_COPYFIELD(_STAT(GUNALIGN))
375 #endif