1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
|
/*
gokz-jumpstats Plugin Include
Website: https://bitbucket.org/kztimerglobalteam/gokz
*/
#if defined _gokz_jumpstats_included_
#endinput
#endif
#define _gokz_jumpstats_included_
// =====[ ENUMS ]=====
enum
{
JumpType_FullInvalid = -1,
JumpType_LongJump,
JumpType_Bhop,
JumpType_MultiBhop,
JumpType_WeirdJump,
JumpType_LadderJump,
JumpType_Ladderhop,
JumpType_Jumpbug,
JumpType_LowpreBhop,
JumpType_LowpreWeirdJump,
JumpType_Fall,
JumpType_Other,
JumpType_Invalid,
JUMPTYPE_COUNT
};
enum
{
StrafeDirection_None,
StrafeDirection_Left,
StrafeDirection_Right
};
enum
{
DistanceTier_None = 0,
DistanceTier_Meh,
DistanceTier_Impressive,
DistanceTier_Perfect,
DistanceTier_Godlike,
DistanceTier_Ownage,
DistanceTier_Wrecker,
DISTANCETIER_COUNT
};
enum JSOption:
{
JSOPTION_INVALID = -1,
JSOption_JumpstatsMaster,
JSOption_MinChatTier,
JSOption_MinConsoleTier,
JSOption_MinSoundTier,
JSOption_FailstatsConsole,
JSOption_FailstatsChat,
JSOption_JumpstatsAlways,
JSOption_ExtendedChatReport,
JSOption_MinChatBroadcastTier,
JSOption_MinSoundBroadcastTier,
JSOPTION_COUNT
};
enum
{
JSToggleOption_Disabled = 0,
JSToggleOption_Enabled,
JSTOGGLEOPTION_COUNT
};
// =====[ CONSTANTS ]=====
#define JS_CFG_TIERS "cfg/sourcemod/gokz/gokz-jumpstats-tiers.cfg"
#define JS_CFG_SOUNDS "cfg/sourcemod/gokz/gokz-jumpstats-sounds.cfg"
#define JS_CFG_BROADCAST "cfg/sourcemod/gokz/gokz-jumpstats-broadcast.cfg"
#define JS_OPTION_CATEGORY "Jumpstats"
#define JS_MAX_LADDERJUMP_OFFSET 2.0
#define JS_MAX_BHOP_GROUND_TICKS 5
#define JS_MAX_DUCKBUG_RESET_TICKS 6
#define JS_MAX_WEIRDJUMP_FALL_OFFSET 64.0
#define JS_TOUCH_GRACE_TICKS 3
#define JS_MAX_TRACKED_STRAFES 48
#define JS_MIN_BLOCK_DISTANCE 186
#define JS_MIN_LAJ_BLOCK_DISTANCE 50
#define JS_MAX_LAJ_FAILSTAT_DISTANCE 250
#define JS_TOP_RECORD_COUNT 20
#define JS_MAX_JUMP_DISTANCE 500
#define JS_FAILSTATS_MAX_TRACKED_TICKS 128
#define JS_MIN_TELEPORT_DELAY 5
#define JS_SPEED_MODIFICATION_TOLERANCE 0.1
#define JS_OFFSET_EPSILON 0.03125
stock char gC_JumpTypes[JUMPTYPE_COUNT][] =
{
"Long Jump",
"Bunnyhop",
"Multi Bunnyhop",
"Weird Jump",
"Ladder Jump",
"Ladderhop",
"Jumpbug",
"Lowpre Bunnyhop",
"Lowpre Weird Jump",
"Fall",
"Unknown Jump",
"Invalid Jump"
};
stock char gC_JumpTypesShort[JUMPTYPE_COUNT][] =
{
"LJ",
"BH",
"MBH",
"WJ",
"LAJ",
"LAH",
"JB",
"LBH",
"LWJ",
"FL",
"UNK",
"INV"
};
stock char gC_JumpTypeKeys[JUMPTYPE_COUNT][] =
{
"longjump",
"bhop",
"multibhop",
"weirdjump",
"ladderjump",
"ladderhop",
"jumpbug",
"lowprebhop",
"lowpreweirdjump",
"fall",
"unknown",
"invalid"
};
stock char gC_DistanceTiers[DISTANCETIER_COUNT][] =
{
"None",
"Meh",
"Impressive",
"Perfect",
"Godlike",
"Ownage",
"Wrecker"
};
stock char gC_DistanceTierKeys[DISTANCETIER_COUNT][] =
{
"none",
"meh",
"impressive",
"perfect",
"godlike",
"ownage",
"wrecker"
};
stock char gC_DistanceTierChatColours[DISTANCETIER_COUNT][] =
{
"{grey}",
"{grey}",
"{blue}",
"{green}",
"{darkred}",
"{gold}",
"{orchid}"
};
stock char gC_JSOptionNames[JSOPTION_COUNT][] =
{
"GOKZ JS - Master Switch",
"GOKZ JS - Chat Report",
"GOKZ JS - Console Report",
"GOKZ JS - Sounds",
"GOKZ JS - Failstats Console",
"GOKZ JS - Failstats Chat",
"GOKZ JS - Jumpstats Always",
"GOKZ JS - Ext Chat Report",
"GOKZ JS - Min Chat Broadcast",
"GOKZ JS - Min Sound Broadcast"
};
stock char gC_JSOptionDescriptions[JSOPTION_COUNT][] =
{
"Master Switch for All Jumpstats Functionality - 0 = Disabled, 1 = Enabled",
"Minimum Tier for Jumpstats Chat Report - 0 = Disabled, 1 = Meh+, 2 = Impressive+, 3 = Perfect+, 4 = Godlike+, 5 = Ownage+, 6 = Wrecker",
"Minimum Tier for Jumpstats Console report - 0 = Disabled, 1 = Meh+, 2 = Impressive+, 3 = Perfect+, 4 = Godlike+, 5 = Ownage+, 6 = Wrecker",
"Minimum Tier for Jumpstats Sounds - 0 = Disabled, 2 = Impressive+, 3 = Perfect+, 4 = Godlike+, 5 = Ownage+, 6 = Wrecker",
"Print Failstats To Console - 0 = Disabled, 1 = Enabled",
"Print Failstats To Chat - 0 = Disabled, 1 = Enabled",
"Always show jumpstats, even for invalid jumps - 0 = Disabled, 1 = Enabled",
"Extended Chat Report - 0 = Disabled, 1 = Enabled",
"Minimum Jump Tier for Jumpstat Chat Broadcast - 0 = Disabled, 1 = Meh+, 2 = Impressive+, 3 = Perfect+, 4 = Godlike+, 5 = Ownage+, 6 = Wrecker",
"Minimum Jump Tier for Jumpstat Sound Broadcast - 0 = Disabled, 1 = Meh+, 2 = Impressive+, 3 = Perfect+, 4 = Godlike+, 5 = Ownage+, 6 = Wrecker"
};
stock char gI_JSOptionPhrases[JSOPTION_COUNT][] =
{
"Options Menu - Jumpstats Master Switch",
"Options Menu - Jumpstats Chat Report",
"Options Menu - Jumpstats Console Report",
"Options Menu - Jumpstats Sounds",
"Options Menu - Failstats Console Report",
"Options Menu - Failstats Chat Report",
"Options Menu - Jumpstats Always",
"Options Menu - Extended Jump Chat Report",
"Options Menu - Minimal Jump Chat Broadcast Tier",
"Options Menu - Minimal Jump Sound Broadcast Tier"
};
stock int gI_JSOptionDefaults[JSOPTION_COUNT] =
{
JSToggleOption_Enabled,
DistanceTier_Meh,
DistanceTier_Meh,
DistanceTier_Impressive,
JSToggleOption_Enabled,
JSToggleOption_Disabled,
JSToggleOption_Disabled,
JSToggleOption_Disabled,
DistanceTier_Ownage,
DistanceTier_None
};
stock int gI_JSOptionCounts[JSOPTION_COUNT] =
{
JSTOGGLEOPTION_COUNT,
DISTANCETIER_COUNT,
DISTANCETIER_COUNT,
DISTANCETIER_COUNT,
JSTOGGLEOPTION_COUNT,
JSTOGGLEOPTION_COUNT,
JSTOGGLEOPTION_COUNT,
JSTOGGLEOPTION_COUNT,
DISTANCETIER_COUNT,
DISTANCETIER_COUNT
};
// =====[ STRUCTS ]=====
enum struct Jump
{
int jumper;
int block;
int crouchRelease;
int crouchTicks;
int deadair;
int duration;
int originalType;
int overlap;
int releaseW;
int strafes;
int type;
float deviation;
float distance;
float edge;
float height;
float maxSpeed;
float offset;
float preSpeed;
float sync;
float width;
// For the 'always' stats
float miss;
// We can't make a separate enum struct for that cause it won't let us
// index an array of enum structs.
int strafes_gainTicks[JS_MAX_TRACKED_STRAFES];
int strafes_deadair[JS_MAX_TRACKED_STRAFES];
int strafes_overlap[JS_MAX_TRACKED_STRAFES];
int strafes_ticks[JS_MAX_TRACKED_STRAFES];
float strafes_gain[JS_MAX_TRACKED_STRAFES];
float strafes_loss[JS_MAX_TRACKED_STRAFES];
float strafes_sync[JS_MAX_TRACKED_STRAFES];
float strafes_width[JS_MAX_TRACKED_STRAFES];
}
// =====[ FORWARDS ]=====
/**
* Called when a player begins their jump.
*
* @param client Client index.
* @param jumpType Type of jump.
*/
forward void GOKZ_JS_OnTakeoff(int client, int jumpType);
/**
* Called when a player lands their jump.
*
* @param jump The jumpstats.
*/
forward void GOKZ_JS_OnLanding(Jump jump);
/**
* Called when player's current jump has been declared an invalid jumpstat.
*
* @param client Client index.
*/
forward void GOKZ_JS_OnJumpInvalidated(int client);
/**
* Called when a player fails a blockjump.
*
* @param jump The jumpstats.
*/
forward void GOKZ_JS_OnFailstat(Jump jump);
/**
* Called when a player lands a jump and has always-on jumpstats enabled.
*
* @param jump The jumpstats.
*/
forward void GOKZ_JS_OnJumpstatAlways(Jump jump);
/**
* Called when a player fails a jump and has always-on failstats enabled.
*
* @param jump The failstats.
*/
forward void GOKZ_JS_OnFailstatAlways(Jump jump);
// =====[ NATIVES ]=====
/**
* Gets the default jumpstats option value as set by a config file.
*
* @param option GOKZ Jumpstats option.
* @return Default option value.
*/
native int GOKZ_JS_GetDefaultOption(JSOption option);
/**
* Declare a player's current jump an invalid jumpstat.
*
* @param client Client index.
*/
native void GOKZ_JS_InvalidateJump(int client);
// =====[ STOCKS ]=====
/**
* Returns whether an option is a gokz-jumpstats option.
*
* @param option Option name.
* @param optionEnum Variable to store enumerated gokz-jumpstats option (if it is one).
* @return Whether option is a gokz-jumpstats option.
*/
stock bool GOKZ_JS_IsJSOption(const char[] option, JSOption &optionEnum = JSOPTION_INVALID)
{
for (JSOption i; i < JSOPTION_COUNT; i++)
{
if (StrEqual(option, gC_JSOptionNames[i]))
{
optionEnum = i;
return true;
}
}
return false;
}
/**
* Gets the current value of a player's gokz-jumpstats option.
*
* @param client Client index.
* @param option gokz-jumpstats option.
* @return Current value of option.
*/
stock any GOKZ_JS_GetOption(int client, JSOption option)
{
return GOKZ_GetOption(client, gC_JSOptionNames[option]);
}
/**
* Sets a player's gokz-jumpstats option's value.
*
* @param client Client index.
* @param option gokz-jumpstats option.
* @param value New option value.
* @return Whether option was successfully set.
*/
stock bool GOKZ_JS_SetOption(int client, JSOption option, any value)
{
return GOKZ_SetOption(client, gC_JSOptionNames[option], value);
}
/**
* Increment an integer-type gokz-jumpstats option's value.
* Loops back to '0' if max value is exceeded.
*
* @param client Client index.
* @param option gokz-jumpstats option.
* @return Whether option was successfully set.
*/
stock bool GOKZ_JS_CycleOption(int client, JSOption option)
{
return GOKZ_CycleOption(client, gC_JSOptionNames[option]);
}
// =====[ DEPENDENCY ]=====
public SharedPlugin __pl_gokz_jumpstats =
{
name = "gokz-jumpstats",
file = "gokz-jumpstats.smx",
#if defined REQUIRE_PLUGIN
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_PLUGIN
public void __pl_gokz_jumpstats_SetNTVOptional()
{
MarkNativeAsOptional("GOKZ_JS_GetDefaultOption");
MarkNativeAsOptional("GOKZ_JS_InvalidateJump");
}
#endif
|