-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGHub_Mouse_Movement_Tester.lua
581 lines (460 loc) · 19.3 KB
/
GHub_Mouse_Movement_Tester.lua
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
-- ABSOLUTELY NO WARRANTY - YOU WILL RISK A GAME BAN FOR YOURSELF BY USING THIS - USE AT YOUR OWN RISK
-- Even then, PLEASE use it ONLY in the Training mode for learning and researching purposes.
-- Tuned ONLY for the following setup:
-- Beryl, Full Auto, standing and breathing
-- Red Dot, Compensator, Vertical Foregrip, Quickdraw Mag
-- Tested with Logitech G Hub app & Logitech G Pro Superlight mouse
-- Adjust mouseSensitivity to fit your mouse sensitivity settings
-- Scope modes can be used when universal sensitivity is used in-game ("monitor distance sensitivity")
-- All scopes work (except 1x with breath holding) automatically with 360deg/cm sensitivities
-- https://github.com/jehillert/logitech-ghub-lua-cheatsheet
-- Mouse Binds For This Script:
-- 1: LMB, 2: RMB, 3: MMB, 4: Thumb Near, 5: Thumb Far, 99: Non-Allocated
mouseBind_activation = 4 -- Activate recoil compensation
mouseBind_switchFireMode = 5 -- Switch fire modes
mouseBind_switchScope = 3 -- Switch scope settings (when using universal sensitivity in-game)
mouseBind_switchStance = 99 -- Switch stance settings
mouseBind_testPixelSkipping = 99 -- Run pixel skipping test
mouseBind_testZoomAnimation = 99 -- Run zoom animation test
mouseBind_autoClicker = 99 -- Activate non-compensating auto clicker
mouseSensitivity = 50 -- [1..n], adjust this factor for the script to work with your sensitivity settings
-- My in-game sensitivity settings (1000dpi):
-- SensitiveMap=((Mouse, (Array=((SensitiveName="Normal",Sensitivity=21.750566,LastConvertedSensitivity=0.005446),
-- (SensitiveName="Targeting",Sensitivity=21.750566,LastConvertedSensitivity=0.005446),
-- (SensitiveName="Scoping",Sensitivity=24.650163,LastConvertedSensitivity=0.006223),
-- (SensitiveName="ScopingMagnified",Sensitivity=50.000000,LastConvertedSensitivity=0.020000),
-- (SensitiveName="Scope2X",Sensitivity=36.802066,LastConvertedSensitivity=0.010891),
-- (SensitiveName="Scope3X",Sensitivity=45.606629,LastConvertedSensitivity=0.016337),
-- (SensitiveName="Scope4X",Sensitivity=52.967385,LastConvertedSensitivity=0.022929),
-- (SensitiveName="Scope6X",Sensitivity=60.658129,LastConvertedSensitivity=0.032673),
-- (SensitiveName="Scope8X",Sensitivity=66.905065,LastConvertedSensitivity=0.043564),
-- (SensitiveName="Scope15X",Sensitivity=75.709628,LastConvertedSensitivity=0.065347))))),
-- MouseVerticalSensitivityMultiplierAdjusted=1.000000
weapon = "M416" -- [Beryl|M416]
fireMode = "auto" -- [auto|single|burst]
magSize = 30 -- [1..n]
scope = 1 -- [1|1.31|2|3|4|4.21|6|8|15] 1.31: 1x hold breath, 4.21: ACOG
stance = "stand" -- [stand|crouch|prone]
autoReload = false -- [true|false]
autoScope = false -- [true|false]
autoHoldBreath = false -- [true|false]
toggleActivation = false -- [true|false] toggle or hold for activation bind
-- In-Game Controls:
mouseBind_fireInGame = 1 -- 1: LMB
mouseBind_scopeInGame = 2 -- 2: RMB
keyBind_reloadInGame = "r"
keyBind_holdBreathInGame = "lshift"
function SetDefaults()
ClearLog()
-- magSize = 1 -- [pcs] shots to fire
timePerShot_accurate = 100 -- [ms] rate of fire
moveY = 1 -- [%] vertical movement compensation per shot
moveY_increasePerShot = 0 -- [%] compensation increase per shot
moveY_increaseAfterShot = 999 -- [pcs] start increasing compensation after this shot
moveY_doubleIncreaseAfterShot = 999 -- [pcs] double compensation increasement after this shot
moveY_stopIncreaseAfterShot = 0 -- [pcs] stop compensation increasement after this shot
if weapon == "Beryl" then
timePerShot_accurate = 85.71
if fireMode == "auto" then
moveY = 1.61
moveY_increasePerShot = 0.056
moveY_increaseAfterShot = 5
moveY_stopIncreaseAfterShot = 16
elseif fireMode == "single" then
moveY = 1.35
elseif fireMode == "burst" then -- TODO: Tuning
moveY = 1.35
end
elseif weapon == "M416" then -- TODO: Tuning
timePerShot_accurate = 85.7
if fireMode == "auto" then
moveY = 1.61
moveY_increasePerShot = 0.056
moveY_increaseAfterShot = 5
moveY_stopIncreaseAfterShot = 16
elseif fireMode == "single" then
moveY = 1.35
moveY_increasePerShot = 0.0
end
elseif weapon == "SKS" then -- TODO: Tuning
timePerShot_accurate = 100
if fireMode == "single" then
moveY = 1.61
moveY_increasePerShot = 0.056
moveY_increaseAfterShot = 5
moveY_stopIncreaseAfterShot = 16
end
elseif weapon == "SLR" then -- TODO: Tuning
timePerShot_accurate = 100
if fireMode == "single" then
moveY = 1.61
moveY_increasePerShot = 0.056
moveY_increaseAfterShot = 5
moveY_stopIncreaseAfterShot = 16
end
elseif weapon == "Mini-14" then -- TODO: Tuning
timePerShot_accurate = 100
if fireMode == "single" then
moveY = 1.61
moveY_increasePerShot = 0.056
moveY_increaseAfterShot = 5
moveY_stopIncreaseAfterShot = 16
end
elseif weapon == "Mutant" then -- TODO: Tuning
timePerShot_accurate = 100
if fireMode == "single" then
moveY = 1.61
moveY_increasePerShot = 0.056
moveY_increaseAfterShot = 5
moveY_stopIncreaseAfterShot = 16
elseif fireMode == "burst" then
moveY = 1.35
end
elseif weapon == "M249" then -- TODO: Tuning
timePerShot_accurate = 75
if fireMode == "single" then
moveY = 1.61
moveY_increasePerShot = 0.056
moveY_increaseAfterShot = 5
moveY_stopIncreaseAfterShot = 16
elseif fireMode == "burst" then
moveY = 1.35
end
end
timePerShot = Rounding(timePerShot_accurate)
scopeFactor = CalculateScope()
stanceFactor = CalculateStance()
moveY = Rounding( moveY * mouseSensitivity * scopeFactor * stanceFactor )
moveY_increasePerShot = Rounding( moveY * moveY_increasePerShot )
mouseTimer_offset = Rounding( timePerShot / 2 )
end
function Rounding(value)
if value >= 0 then
return math.floor(value + 0.5)
else
return math.ceil(value - 0.5)
end
end
function CalculateScope()
-- default ADS FOV is 72
-- eg. 1x Red Dot is 72 FOV and holding breath decreases FOV to 55
-- 72/55 = 1,309.. => 72/1,31 = 54,96..
if scope == 1 then
return scope
elseif scope == 1.31 then -- hold breath (72FOV/55FOV)
return scope * 1.11
else
return scope / 1.11 -- scopes (80FOV/scopeFOV)
end
end
function CalculateStance() -- NOTE: May be a bit inaccurate estimation (due to moveY & increasePerShot, etc.)
if stance == "stand" then
return 1
elseif stance == "crouch" then
return 0.76
elseif stance == "prone" then
return 0.52
end
end
function OnEvent(event, arg)
if ( event == "MOUSE_BUTTON_PRESSED" and arg == mouseBind_activation ) then
TriggerAction()
elseif ( event == "MOUSE_BUTTON_PRESSED" and arg == mouseBind_switchFireMode ) then
SwitchFireMode()
elseif ( event == "MOUSE_BUTTON_PRESSED" and arg == mouseBind_switchScope ) then
SwitchScope()
elseif ( event == "MOUSE_BUTTON_PRESSED" and arg == mouseBind_switchStance ) then
SwitchStance()
elseif ( event == "MOUSE_BUTTON_PRESSED" and arg == mouseBind_testPixelSkipping ) then
TestPixelSkipping()
elseif ( event == "MOUSE_BUTTON_PRESSED" and arg == mouseBind_testZoomAnimation ) then
TestZoomAnimation()
elseif ( event == "MOUSE_BUTTON_PRESSED" and arg == mouseBind_autoClicker ) then
AutoClicker()
end
end
function SwitchFireMode()
if fireMode == "auto" then
fireMode = "single"
elseif fireMode == "single" then
fireMode = "burst"
elseif fireMode == "burst" then
fireMode = "auto"
end
OutputLogMessage("\nSwitching Fire Mode to: " .. fireMode .. "\n")
end
function SwitchScope()
if scope == 1 then
scope = 1.31
elseif scope == 1.31 then
scope = 2
elseif scope == 2 then
scope = 3
elseif scope == 3 then
scope = 4
elseif scope == 4 then
scope = 4.21
elseif scope == 4.21 then
scope = 6
elseif scope == 6 then
scope = 8
elseif scope == 8 then
scope = 15
elseif scope == 15 then
scope = 1
end
OutputLogMessage("\nSwitching Scope to: " .. scope .. "\n")
end
function SwitchStance()
if stance == "stand" then
stance = "crouch"
elseif stance == "crouch" then
stance = "prone"
elseif stance == "prone" then
stance = "stand"
end
OutputLogMessage("\nSwitching Stance to: " .. stance .. "\n")
end
function TriggerAction()
SetDefaults()
if autoScope then
PressAndReleaseMouseButton(mouseBind_scopeInGame)
Sleep(500)
end
if autoHoldBreath then
PressKey(keyBind_holdBreathInGame)
Sleep(100)
end
if fireMode == "auto" then
AutoFire()
elseif fireMode == "single" then
SingleFire()
elseif fireMode == "burst" then
BurstFire()
end
if autoHoldBreath then
ReleaseKey(keyBind_holdBreathInGame)
end
if autoScope then
PressAndReleaseMouseButton(mouseBind_scopeInGame)
Sleep(100)
end
if autoReload then
PressAndReleaseKey(keyBind_reloadInGame)
end
end
function AutoFire()
OutputLogMessage("AutoFire():\n")
OutputLogMessage("magSize: " .. magSize .. " pcs, timePerShot: " .. timePerShot)
OutputLogMessage(" ms, mouseTimer_offset: " .. mouseTimer_offset)
OutputLogMessage(" ms, moveY: " .. moveY .. " px, moveY_increasePerShot: " .. moveY_increasePerShot)
OutputLogMessage(" px, fireMode: " .. fireMode .. "\n\n")
PressMouseButton(mouseBind_fireInGame)
sprayTimer_start = GetRunningTime()
shotCounter = 1
moveY_steps = 4
moveY_sleepPerStep = 3
moveY_movePerStep = math.floor( moveY / moveY_steps )
repeat
sprayTimer = GetRunningTime() - sprayTimer_start
mouseTimer = (shotCounter * timePerShot) - mouseTimer_offset
if sprayTimer >= mouseTimer then
actualTimer_f = math.floor(shotCounter * timePerShot_accurate - timePerShot_accurate)
actualTimer_c = math.ceil(shotCounter * timePerShot_accurate - timePerShot_accurate)
OutputLogMessage(shotCounter .. "/" .. magSize)
OutputLogMessage("\t moveY: " .. moveY .. " px\t\t mouseTimer: " .. mouseTimer .. " ms")
OutputLogMessage("\t\t actual shot: " .. actualTimer_f .. " - " .. actualTimer_c .. " ms\n")
OutputLogMessage("\t sprayTimer: " .. sprayTimer .. " ms\t sprayTimer_start: " .. sprayTimer_start .. " ms\n")
for i = 1, moveY_steps, 1 do
MoveMouseRelative(0, moveY_movePerStep)
Sleep(moveY_sleepPerStep)
end
moveY_lastStep = moveY - (moveY_steps * moveY_movePerStep)
MoveMouseRelative(0, moveY_lastStep)
if moveY_stopIncreaseAfterShot <= shotCounter then
-- do nothing
elseif moveY_doubleIncreaseAfterShot <= shotCounter then
moveY = moveY + moveY_increasePerShot + moveY_increasePerShot
elseif moveY_increaseAfterShot <= shotCounter then
moveY = moveY + moveY_increasePerShot
end
shotCounter = shotCounter + 1
end
Sleep(1)
until not IsMouseButtonPressed(mouseBind_activation) or (shotCounter == magSize + 1) -- +1 includes last shot
ReleaseMouseButton(mouseBind_fireInGame)
OutputLogMessage("AutoFire() Running Time: ".. (GetRunningTime() - sprayTimer_start) .." ms\n\n")
end
function SingleFire()
OutputLogMessage("SingleFire():\n")
OutputLogMessage("magSize: " .. magSize .. " pcs, timePerShot: " .. timePerShot)
OutputLogMessage(" ms, mouseTimer_offset: " .. mouseTimer_offset)
OutputLogMessage(" ms, moveY: " .. moveY .. " px, moveY_increasePerShot: " .. moveY_increasePerShot)
OutputLogMessage(" px, fireMode: " .. fireMode .. "\n\n")
sprayTimer_start = GetRunningTime()
shotCounter = 1
moveY_steps = 4
moveY_sleepPerStep = 3
moveY_movePerStep = math.floor( moveY / moveY_steps )
repeat
sprayTimer = GetRunningTime() - sprayTimer_start
mouseTimer = (shotCounter * timePerShot)
if sprayTimer >= mouseTimer then
actualTimer_f = math.floor(shotCounter * timePerShot_accurate - timePerShot_accurate)
actualTimer_c = math.ceil(shotCounter * timePerShot_accurate - timePerShot_accurate)
OutputLogMessage(shotCounter .. "/" .. magSize)
OutputLogMessage("\t moveY: " .. moveY .. " px\t\t mouseTimer: " .. mouseTimer .. " ms")
OutputLogMessage("\t\t actual shot: " .. actualTimer_f .. " - " .. actualTimer_c .. " ms\n")
OutputLogMessage("\t sprayTimer: " .. sprayTimer .. " ms\t sprayTimer_start: " .. sprayTimer_start .. " ms\n")
PressMouseButton(mouseBind_fireInGame)
Sleep(math.random(10,20))
ReleaseMouseButton(mouseBind_fireInGame)
Sleep(mouseTimer_offset)
for i = 1, moveY_steps, 1 do
MoveMouseRelative(0, moveY_movePerStep)
Sleep(moveY_sleepPerStep)
end
moveY_lastStep = moveY - (moveY_steps * moveY_movePerStep)
MoveMouseRelative(0, moveY_lastStep)
if moveY_stopIncreaseAfterShot <= shotCounter then
-- do nothing
elseif moveY_doubleIncreaseAfterShot <= shotCounter then
moveY = moveY + moveY_increasePerShot + moveY_increasePerShot
elseif moveY_increaseAfterShot <= shotCounter then
moveY = moveY + moveY_increasePerShot
end
shotCounter = shotCounter + 1
end
Sleep(1)
until not IsMouseButtonPressed(mouseBind_activation) or (shotCounter == magSize + 1) -- +1 includes last shot
OutputLogMessage("AutoFire() Running Time: ".. (GetRunningTime() - sprayTimer_start) .." ms\n\n")
end
function BurstFire()
OutputLogMessage("SingleFire():\n")
OutputLogMessage("magSize: " .. magSize .. " pcs, timePerShot: " .. timePerShot)
OutputLogMessage(" ms, mouseTimer_offset: " .. mouseTimer_offset)
OutputLogMessage(" ms, moveY: " .. moveY .. " px, moveY_increasePerShot: " .. moveY_increasePerShot)
OutputLogMessage(" px, fireMode: " .. fireMode .. "\n\n")
sprayTimer_start = GetRunningTime()
shotCounter = 1
moveY_steps = 4
moveY_sleepPerStep = 3
moveY_movePerStep = math.floor( moveY / moveY_steps )
repeat
sprayTimer = GetRunningTime() - sprayTimer_start
mouseTimer = (shotCounter * timePerShot)
if sprayTimer >= mouseTimer then
actualTimer_f = math.floor(shotCounter * timePerShot_accurate - timePerShot_accurate)
actualTimer_c = math.ceil(shotCounter * timePerShot_accurate - timePerShot_accurate)
OutputLogMessage(shotCounter .. "/" .. magSize)
OutputLogMessage("\t moveY: " .. moveY .. " px\t\t mouseTimer: " .. mouseTimer .. " ms")
OutputLogMessage("\t\t actual shot: " .. actualTimer_f .. " - " .. actualTimer_c .. " ms\n")
OutputLogMessage("\t sprayTimer: " .. sprayTimer .. " ms\t sprayTimer_start: " .. sprayTimer_start .. " ms\n")
PressMouseButton(mouseBind_fireInGame)
Sleep(math.random(10,20))
ReleaseMouseButton(mouseBind_fireInGame)
Sleep(mouseTimer_offset)
for i = 1, moveY_steps, 1 do
MoveMouseRelative(0, moveY_movePerStep)
Sleep(moveY_sleepPerStep)
end
moveY_lastStep = moveY - (moveY_steps * moveY_movePerStep)
MoveMouseRelative(0, moveY_lastStep)
if moveY_stopIncreaseAfterShot <= shotCounter then
-- do nothing
elseif moveY_doubleIncreaseAfterShot <= shotCounter then
moveY = moveY + moveY_increasePerShot + moveY_increasePerShot
elseif moveY_increaseAfterShot <= shotCounter then
moveY = moveY + moveY_increasePerShot
end
shotCounter = shotCounter + 1
end
Sleep(1)
until not IsMouseButtonPressed(mouseBind_activation) or (shotCounter == magSize + 1) -- +1 includes last shot
OutputLogMessage("AutoFire() Running Time: ".. (GetRunningTime() - sprayTimer_start) .." ms\n\n")
end
function TestPixelSkipping()
OutputLogMessage("TestPixelSkipping()\n")
steps = 200
jumpSteps = 100
delay = 250 --ms
sleepDelay = 1 --ms
OutputLogMessage("Steps: " .. steps .. " \t Jump Steps: " .. jumpSteps .. " \t Delay: " .. delay .. " \n")
OutputLogMessage("Watch for uneven movement to detect possible pixel skipping\n")
OutputLogMessage("Primarily test with full zoomed 8x and 15x scopes\n\n")
OutputLogMessage("Down\n")
stepCount = 0
repeat
MoveMouseRelative(0,1)
Sleep(sleepDelay)
stepCount = stepCount + 1
until stepCount == steps
Sleep(delay)
OutputLogMessage("Up\n")
stepCount = 0
repeat
MoveMouseRelative(0,-1)
Sleep(sleepDelay)
stepCount = stepCount + 1
until stepCount == steps
Sleep(delay)
OutputLogMessage("Right\n")
stepCount = 0
repeat
MoveMouseRelative(1,0)
Sleep(sleepDelay)
stepCount = stepCount + 1
until stepCount == steps
Sleep(delay)
OutputLogMessage("Left\n")
stepCount = 0
repeat
MoveMouseRelative(-1,0)
Sleep(sleepDelay)
stepCount = stepCount + 1
until stepCount == steps
Sleep(delay)
OutputLogMessage("Down + Right\n")
stepCount = 0
repeat
MoveMouseRelative(1,1)
Sleep(sleepDelay)
stepCount = stepCount + 1
until stepCount == steps
Sleep(delay)
OutputLogMessage("Up + Left\n")
stepCount = 0
repeat
MoveMouseRelative(-1,-1)
Sleep(sleepDelay)
stepCount = stepCount + 1
until stepCount == steps
Sleep(delay)
OutputLogMessage("Jump Down + Right\n")
MoveMouseRelative(jumpSteps,jumpSteps)
Sleep(delay)
OutputLogMessage("Jump Up + Left\n")
MoveMouseRelative(jumpSteps * -1, jumpSteps * -1)
OutputLogMessage("TestPixelSkipping(): Finished")
end
function TestZoomAnimation()
OutputLogMessage("TestZoom()\n")
steps = 300
jumpSteps = 100
delay = 250 --ms
sleepDelay = 1 --ms
stepCount = 0
repeat
MoveMouseRelative(2,0)
Sleep(sleepDelay)
stepCount = stepCount + 1
until stepCount == steps
end
function AutoClicker()
repeat
PressMouseButton(mouseBind_fireInGame)
Sleep(math.random(10,20))
ReleaseMouseButton(mouseBind_fireInGame)
Sleep(math.random(110,130))
until not IsMouseButtonPressed(mouseBind_autoClicker)
end