-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmovementapi.inc
663 lines (566 loc) · 19.7 KB
/
movementapi.inc
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
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
/*
MovementAPI Plugin Include
Website: https://github.com/danzayau/MovementAPI
*/
#if defined _movementapi_included_
#endinput
#endif
#define _movementapi_included_
#include <movement>
/*
Terminology
Takeoff
Becoming airborne, including jumping, falling, getting off a ladder and leaving noclip.
Landing
Leaving the air, including landing on the ground, grabbing a ladder and entering noclip.
Perfect Bunnyhop (Perf)
When the player has jumped in the tick after landing and keeps their speed.
Duckbug/Crouchbug
When the player sucessfully lands due to uncrouching from mid air and not by falling
down. This causes no stamina loss or fall damage upon landing.
Jumpbug
This is achieved by duckbugging and jumping at the same time. The player is never seen
as 'on ground' when bunnyhopping from a tick by tick perspective. A jumpbug inherits
the same behavior as a duckbug/crouchbug, along with its effects such as maintaining
speed due to no stamina loss.
Distbug
Landing behavior varies depending on whether the player lands close to the edge of a
block or not:
1. If the player lands close to the edge of a block, this causes the jump duration to
be one tick longer and the player can "slide" on the ground during the landing tick,
using the position post-tick as landing position becomes inaccurate.
2. On the other hand, if the player does not land close to the edge, the player will
be considered on the ground one tick earlier, using this position as landing position
is not accurate as the player has yet to be fully on the ground.
In scenario 1, GetNobugLandingOrigin calculates the correct landing position of the
player before the sliding effect takes effect.
In scenario 2, GetNobugLandingOrigin attempts to extrapolate the player's fully on
ground position to make landing positions consistent across scenarios.
*/
// =====[ FORWARDS ]=====
/**
* Called when a player's movetype changes.
*
* @param client Client index.
* @param oldMovetype Player's old movetype.
* @param newMovetype Player's new movetype.
*/
forward void Movement_OnChangeMovetype(int client, MoveType oldMovetype, MoveType newMovetype);
/**
* Called when a player touches the ground.
*
* @param client Client index.
*/
forward void Movement_OnStartTouchGround(int client);
/**
* Called when a player leaves the ground.
*
* @param client Client index.
* @param jumped Whether player jumped to leave ground.
* @param ladderJump Whether player jumped from a ladder.
* @param jumpbug Whether player performed a jumpbug.
*/
forward void Movement_OnStopTouchGround(int client, bool jumped, bool ladderJump, bool jumpbug);
/**
* Called when a player starts ducking.
*
* @param client Client index.
*/
forward void Movement_OnStartDucking(int client);
/**
* Called when a player stops ducking.
*
* @param client Client index.
*/
forward void Movement_OnStopDucking(int client);
/**
* Called when a player jumps (player_jump event), including 'jumpbugs'.
* Setting velocity when this is called may not be effective.
*
* @param client Client index.
* @param jumpbug Whether player 'jumpbugged'.
*/
forward void Movement_OnPlayerJump(int client, bool jumpbug);
/**
* Called before PlayerMove movement function is called.
* Modifying origin or velocity parameters will change player's origin and velocity accordingly.
*
* @param client Client index.
* @param origin Player origin.
* @param velocity Player velocity.
* @return Plugin_Changed if origin or velocity is changed, Plugin_Continue otherwise.
*/
forward Action Movement_OnPlayerMovePre(int client, float origin[3], float velocity[3]);
/**
* Called after PlayerMove movement function is called.
* Modifying origin or velocity parameters will change player's origin and velocity accordingly.
*
* @param client Client index.
* @param origin Player origin.
* @param velocity Player velocity.
* @return Plugin_Changed if origin or velocity is changed, Plugin_Continue otherwise.
*/
forward Action Movement_OnPlayerMovePost(int client, float origin[3], float velocity[3]);
/**
* Called before Duck movement function is called.
* Modifying origin or velocity parameters will change player's origin and velocity accordingly.
*
* @param client Client index.
* @param origin Player origin.
* @param velocity Player velocity.
* @return Plugin_Changed if origin or velocity is changed, Plugin_Continue otherwise.
*/
forward Action Movement_OnDuckPre(int client, float origin[3], float velocity[3]);
/**
* Called after Duck movement function is called.
* Modifying origin or velocity parameters will change player's origin and velocity accordingly.
*
* @param client Client index.
* @param origin Player origin.
* @param velocity Player velocity.
* @return Plugin_Changed if origin or velocity is changed, Plugin_Continue otherwise.
*/
forward Action Movement_OnDuckPost(int client, float origin[3], float velocity[3]);
/**
* Called before LadderMove movement function is called.
* Modifying origin or velocity parameters will change player's origin and velocity accordingly.
*
* @param client Client index.
* @param origin Player origin.
* @param velocity Player velocity.
* @return Plugin_Changed if origin or velocity is changed, Plugin_Continue otherwise.
*/
forward Action Movement_OnLadderMovePre(int client, float origin[3], float velocity[3]);
/**
* Called after LadderMove movement function is called.
* Modifying origin or velocity parameters will change player's origin and velocity accordingly.
*
* @param client Client index.
* @param origin Player origin.
* @param velocity Player velocity.
* @return Plugin_Changed if origin or velocity is changed, Plugin_Continue otherwise.
*/
forward Action Movement_OnLadderMovePost(int client, float origin[3], float velocity[3]);
/**
* Called before FullLadderMove movement function is called.
* Modifying origin or velocity parameters will change player's origin and velocity accordingly.
*
* @param client Client index.
* @param origin Player origin.
* @param velocity Player velocity.
* @return Plugin_Changed if origin or velocity is changed, Plugin_Continue otherwise.
*/
forward Action Movement_OnFullLadderMovePre(int client, float origin[3], float velocity[3]);
/**
* Called after FullLadderMove movement function is called.
* Modifying origin or velocity parameters will change player's origin and velocity accordingly.
*
* @param client Client index.
* @param origin Player origin.
* @param velocity Player velocity.
* @return Plugin_Changed if origin or velocity is changed, Plugin_Continue otherwise.
*/
forward Action Movement_OnFullLadderMovePost(int client, float origin[3], float velocity[3]);
/**
* Called after the player jumps, but before jumping stamina is applied and takeoff variables are not set yet.
* Modifying origin or velocity parameters will change player's origin and velocity accordingly.
*
* @param client Client index.
* @param origin Player origin.
* @param velocity Player velocity.
* @return Plugin_Changed if origin or velocity is changed, Plugin_Continue otherwise.
*/
forward Action Movement_OnJumpPre(int client, float origin[3], float velocity[3]);
/**
* Called after the player jumps and after jumping stamina is applied and takeoff variables are already set here.
* Modifying origin or velocity parameters will change player's origin and velocity accordingly.
*
* @param client Client index.
* @param origin Player origin.
* @param velocity Player velocity.
* @return Plugin_Changed if origin or velocity is changed, Plugin_Continue otherwise.
*/
forward Action Movement_OnJumpPost(int client, float origin[3], float velocity[3]);
/**
* Called before AirAccelerate movement function is called.
* Modifying origin or velocity parameters will change player's origin and velocity accordingly.
*
* @param client Client index.
* @param origin Player origin.
* @param velocity Player velocity.
* @return Plugin_Changed if origin or velocity is changed, Plugin_Continue otherwise.
*/
forward Action Movement_OnAirAcceleratePre(int client, float origin[3], float velocity[3]);
/**
* Called after AirAccelerate movement function is called.
* Modifying origin or velocity parameters will change player's origin and velocity accordingly.
*
* @param client Client index.
* @param origin Player origin.
* @param velocity Player velocity.
* @return Plugin_Changed if origin or velocity is changed, Plugin_Continue otherwise.
*/
forward Action Movement_OnAirAcceleratePost(int client, float origin[3], float velocity[3]);
/**
* Called before WalkMove movement function is called.
* Modifying origin or velocity parameters will change player's origin and velocity accordingly.
*
* @param client Client index.
* @param origin Player origin.
* @param velocity Player velocity.
* @return Plugin_Changed if origin or velocity is changed, Plugin_Continue otherwise.
*/
forward Action Movement_OnWalkMovePre(int client, float origin[3], float velocity[3]);
/**
* Called after WalkMove movement function is called.
* Modifying origin or velocity parameters will change player's origin and velocity accordingly.
*
* @param client Client index.
* @param origin Player origin.
* @param velocity Player velocity.
* @return Plugin_Changed if origin or velocity is changed, Plugin_Continue otherwise.
*/
forward Action Movement_OnWalkMovePost(int client, float origin[3], float velocity[3]);
/**
* Called before CategorizePosition movement function is called.
* Modifying origin or velocity parameters will change player's origin and velocity accordingly.
*
* @param client Client index.
* @param origin Player origin.
* @param velocity Player velocity.
* @return Plugin_Changed if origin or velocity is changed, Plugin_Continue otherwise.
*/
forward Action Movement_OnCategorizePositionPre(int client, float origin[3], float velocity[3]);
/**
* Called after CategorizePosition movement function is called.
* Modifying origin or velocity parameters will change player's origin and velocity accordingly.
*
* @param client Client index.
* @param origin Player origin.
* @param velocity Player velocity.
* @return Plugin_Changed if origin or velocity is changed, Plugin_Continue otherwise.
*/
forward Action Movement_OnCategorizePositionPost(int client, float origin[3], float velocity[3]);
// =====[ NATIVES ]=====
/**
* Gets whether a player's last takeoff was a jump.
*
* @param client Client index.
* @return Whether player's last takeoff was a jump.
*/
native bool Movement_GetJumped(int client);
/**
* Gets whether a player's last takeoff was a perfect bunnyhop.
*
* @param client Client index.
* @return Whether player's last takeoff was a perfect bunnyhop.
*/
native bool Movement_GetHitPerf(int client);
/**
* Gets a player's origin at the time of their last takeoff.
*
* @param client Client index.
* @param result Resultant vector.
*/
native void Movement_GetTakeoffOrigin(int client, float result[3]);
/**
* Gets a player's velocity at the time of their last takeoff.
*
* If sv_enablebunnyhopping is 0, CS:GO may adjust the player's
* velocity after the takeoff velocity has already been measured.
*
* @param client Client index.
* @param result Resultant vector.
*/
native void Movement_GetTakeoffVelocity(int client, float result[3]);
/**
* Gets a player's horizontal speed at the time of their last takeoff.
*
* If sv_enablebunnyhopping is 0, CS:GO may adjust the player's
* velocity after the takeoff velocity has already been measured.
*
* @param client Client index.
* @return Player's last takeoff speed.
*/
native float Movement_GetTakeoffSpeed(int client);
/**
* Gets a player's 'tickcount' at the time of their last takeoff.
*
* @param client Client index.
* @return Player's last takeoff 'tickcount'.
*/
native int Movement_GetTakeoffTick(int client);
/**
* Gets a player's 'cmdnum' at the time of their last takeoff.
*
* @param client Client index.
* @return Player's last takeoff 'cmdnum'.
*/
native int Movement_GetTakeoffCmdNum(int client);
/**
* Gets a player's origin at the time of their last landing with the distbug fixed.
*
* @param client Client index.
* @param result Resultant vector.
*/
native void Movement_GetNobugLandingOrigin(int client, float result[3]);
/**
* Gets a player's origin at the time of their last landing.
*
* @param client Client index.
* @param result Resultant vector.
*/
native void Movement_GetLandingOrigin(int client, float result[3]);
/**
* Gets a player's velocity at the time of their last landing.
*
* @param client Client index.
* @param result Resultant vector.
*/
native void Movement_GetLandingVelocity(int client, float result[3]);
/**
* Gets a player's horizontal speed at the time of their last landing.
*
* @param client Client index.
* @return Last landing speed of the player (horizontal).
*/
native float Movement_GetLandingSpeed(int client);
/**
* Gets a player's 'tickcount' at the time of their last landing.
*
* @param client Client index.
* @return Player's last landing 'tickcount'.
*/
native int Movement_GetLandingTick(int client);
/**
* Gets a player's 'cmdnum' at the time of their last landing.
*
* @param client Client index.
* @return Player's last landing 'cmdnum'.
*/
native int Movement_GetLandingCmdNum(int client);
/**
* Gets whether a player is turning their aim horizontally.
*
* @param client Client index.
* @return Whether player is turning their aim horizontally.
*/
native bool Movement_GetTurning(int client);
/**
* Gets whether a player is turning their aim left.
*
* @param client Client index.
* @return Whether player is turning their aim left.
*/
native bool Movement_GetTurningLeft(int client);
/**
* Gets whether a player is turning their aim right.
*
* @param client Client index.
* @return Whether player is turning their aim right.
*/
native bool Movement_GetTurningRight(int client);
/**
* Gets result of CCSPlayer::GetPlayerMaxSpeed(client), which
* is the player's max speed as limited by their weapon.
*
* @param client Client index.
* @return Player's max speed as limited by their weapon.
*/
native float Movement_GetMaxSpeed(int client);
/**
* Gets whether a player duckbugged on this tick.
*
* @param client Client index.
* @return Whether a player duckbugged on this tick.
*/
native bool Movement_GetDuckbugged(int client);
/**
* Gets whether a player jumpbugged on this tick.
*
* @param client Client index.
* @return Whether a player jumpbugged on this tick.
*/
native bool Movement_GetJumpbugged(int client);
/**
* Get the player's origin during movement processing.
*
* @param client Client index.
* @param result Resultant vector.
*/
native void Movement_GetProcessingOrigin(int client, float result[3]);
/**
* Get the player's velocity during movement processing.
*
* @param client Param description
* @param result Resultant vector.
*/
native void Movement_GetProcessingVelocity(int client, float result[3]);
/**
* Set the player's takeoff origin.
*
* @param client Client index.
* @param origin Desired origin.
*/
native void Movement_SetTakeoffOrigin(int client, float origin[3]);
/**
* Set the player's takeoff velocity.
*
* @param client Client index.
* @param origin Desired velocity.
*/
native void Movement_SetTakeoffVelocity(int client, float velocity[3]);
/**
* Set the player's landing origin.
*
* @param client Client index.
* @param origin Desired origin.
*/
native void Movement_SetLandingOrigin(int client, float origin[3]);
/**
* Set the player's landing velocity.
*
* @param client Client index.
* @param origin Desired velocity.
*/
native void Movement_SetLandingVelocity(int client, float velocity[3]);
// =====[ METHODMAP ]=====
methodmap MovementAPIPlayer < MovementPlayer {
public MovementAPIPlayer(int client) {
return view_as<MovementAPIPlayer>(MovementPlayer(client));
}
property bool Jumped {
public get() {
return Movement_GetJumped(this.ID);
}
}
property bool HitPerf {
public get() {
return Movement_GetHitPerf(this.ID);
}
}
public void GetTakeoffOrigin(float buffer[3]) {
Movement_GetTakeoffOrigin(this.ID, buffer);
}
public void GetTakeoffVelocity(float buffer[3]) {
Movement_GetTakeoffVelocity(this.ID, buffer);
}
public void SetTakeoffOrigin(float buffer[3])
{
Movement_SetTakeoffOrigin(this.ID, buffer);
}
public void SetTakeoffVelocity(float buffer[3])
{
Movement_SetTakeoffVelocity(this.ID, buffer);
}
property float TakeoffSpeed {
public get() {
return Movement_GetTakeoffSpeed(this.ID);
}
}
property int TakeoffTick {
public get() {
return Movement_GetTakeoffTick(this.ID);
}
}
property int TakeoffCmdNum {
public get() {
return Movement_GetTakeoffCmdNum(this.ID);
}
}
public void GetLandingOrigin(float buffer[3]) {
Movement_GetLandingOrigin(this.ID, buffer);
}
public void GetLandingVelocity(float buffer[3]) {
Movement_GetLandingVelocity(this.ID, buffer);
}
public void SetLandingOrigin(float buffer[3])
{
Movement_SetLandingOrigin(this.ID, buffer);
}
public void SetLandingVelocity(float buffer[3])
{
Movement_SetLandingVelocity(this.ID, buffer);
}
property float LandingSpeed {
public get() {
return Movement_GetLandingSpeed(this.ID);
}
}
property int LandingTick {
public get() {
return Movement_GetLandingTick(this.ID);
}
}
property int LandingCmdNum {
public get() {
return Movement_GetLandingCmdNum(this.ID);
}
}
property bool Turning {
public get() {
return Movement_GetTurning(this.ID);
}
}
property bool TurningLeft {
public get() {
return Movement_GetTurningLeft(this.ID);
}
}
property bool TurningRight {
public get() {
return Movement_GetTurningRight(this.ID);
}
}
property float MaxSpeed {
public get() {
return Movement_GetMaxSpeed(this.ID);
}
}
public void GetProcessingVelocity(float buffer[3])
{
Movement_GetProcessingVelocity(this.ID, buffer);
}
public void GetProcessingOrigin(float buffer[3])
{
Movement_GetProcessingOrigin(this.ID, buffer);
}
}
// =====[ DEPENDENCY ]=====
public SharedPlugin __pl_movementapi =
{
name = "movementapi",
file = "movementapi.smx",
#if defined REQUIRE_PLUGIN
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_PLUGIN
public void __pl_movementapi_SetNTVOptional()
{
MarkNativeAsOptional("Movement_GetJumped");
MarkNativeAsOptional("Movement_GetHitPerf");
MarkNativeAsOptional("Movement_GetTakeoffOrigin");
MarkNativeAsOptional("Movement_GetTakeoffVelocity");
MarkNativeAsOptional("Movement_GetTakeoffSpeed");
MarkNativeAsOptional("Movement_GetTakeoffTick");
MarkNativeAsOptional("Movement_GetTakeoffCmdNum");
MarkNativeAsOptional("Movement_GetLandingOrigin");
MarkNativeAsOptional("Movement_GetLandingVelocity");
MarkNativeAsOptional("Movement_GetLandingSpeed");
MarkNativeAsOptional("Movement_GetLandingTick");
MarkNativeAsOptional("Movement_GetLandingCmdNum");
MarkNativeAsOptional("Movement_GetTurning");
MarkNativeAsOptional("Movement_GetTurningLeft");
MarkNativeAsOptional("Movement_GetTurningRight");
MarkNativeAsOptional("Movement_GetMaxSpeed");
MarkNativeAsOptional("Movement_GetProcessingOrigin");
MarkNativeAsOptional("Movement_GetProcessingVelocity");
MarkNativeAsOptional("Movement_SetTakeoffOrigin");
MarkNativeAsOptional("Movement_SetTakeoffVelocity");
MarkNativeAsOptional("Movement_SetLandingOrigin");
MarkNativeAsOptional("Movement_SetLandingVelocity");
}
#endif