forked from liantian-cn/logitech-pubg
-
Notifications
You must be signed in to change notification settings - Fork 2
/
adv_mode.lua
423 lines (333 loc) · 14 KB
/
adv_mode.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
--------------------------------------------------------------------------
---------------- Basic Variable -----------------------------
---------------- Do not edit ---------------------
--------------------------------------------------------------------------
local current_weapon = "none"
--------------------------------------------------------------------------
---------------- Basic Setting ------------------------------
--------------------------------------------------------------------------
---- key bind ----
local ump9_key = 4
local akm_key = 5
local m16a4_key = 7
local m416_key = 8
local scarl_key = nil
local uzi_key = nil
local set_off_key = 6
---- keyboard ---- Only Support logitech G Keyboard
local ump9_gkey = nil ---1 is use F1.
local akm_gkey = nil
local m16a4_gkey = nil
local m416_gkey = nil
local scarl_gkey = nil
local uzi_gkey = nil
local set_off_gkey = nil
---- fire key ----
local fire_key = "F8"
---- can use "lalt", "ralt", "alt" "lshift", "rshift", "shift" "lctrl", "rctrl", "ctrl"
local ignore_key = "lalt" --- ignore key
local hold_breath_key = "lshift"
---- only can use "numlock", "capslock", "scrolllock"
local full_mode_key = "numlock" ---numlock lamp on,recoil is full_mode.
local mode_switch_key = "capslock"
local lighton_key = "scrolllock" ---start script,scrolllock lamp will be on.close script ,scrolllock lamp will be off.
--- fastloot setting---
--- Press fast_loot_key and click Left mouse button ---
local fastloot = true ---if you don't need it, you can close it by true to false.
local fast_loot_key = "lctrl"
local move = 40 ----1920*1080
--- Your Sensitivity in Game
local vertical_sensitivity = 0.7 --- default is 0.7
local target_sensitivity = 50 --- default is 50.0
local scope_sensitivity = 50 --- default is 50.0
local scope4x_sensitivity = 50 --- default is 50.0
---- function ----
-- if auto_mode = true ,the guns need to switch automatic shooting mode,except m16 single.
local auto_mode = true
-- you can close these by true to false
local hold_breath_mode = true
local full_mode = true
---- Obfs setting
---- Two firing time intervals = weapon_speed * interval_ratio * ( 1 + random_seed * ( 0 ~ 1))
local weapon_speed_mode = false
-- local obfs_mode = false
local obfs_mode = false
local interval_ratio = 0.75
local random_seed = 1
--------------------------------------------------------------------------
---------------- Recoil Table ------------------------------
---------------- You can fix the value here ------------------------------
--------------------------------------------------------------------------
--- recoil times
--- if the Recoil compensation is Large or small,You can modify the value of all_recoil_Times or recoil_table{times}
local all_recoil_times = 1
local recoil_table = {}
recoil_table["ump9"] = {
basic={28,30,30,30,37,30,31,36,37,37,37,40,40,39,39,41,41,42,44,42,43,40,41,44,40,40,41,42,43},
basictimes = 0.963,
full={28,30,30,30,37,30,31,36,37,37,37,40,40,39,39,41,41,42,44,42,43,40,41,44,40,40,41,42,43},
fulltimes = 0.963*0.75,
holdbreathtimes = 1.25,
quadruple={28,30,30,30,37,30,31,36,37,37,37,40,40,39,39,41,41,42,44,42,43,40,41,44,40,40,41,42,43},
quadrupletimes = 4*0.963,
fullof4x={28,30,30,30,37,30,31,36,37,37,37,40,40,39,39,41,41,42,44,42,43,40,41,44,40,40,41,42,43},
fullof4xtimes = 4*0.963*0.75,
speed = 90,
}
recoil_table["akm"] = {
basic={56,40,38,44,48,55,56,61,65,65,67,68,67,71,74,70,65,66,72,74,72,71,70,70,70,72,74,76,72},
basictimes = 0.96,
full={56,40,38,44,48,55,56,61,65,65,67,68,67,71,74,70,65,66,72,74,72,71,70,70,70,72,74,76,72},
fulltimes = 0.96*0.75,
holdbreathtimes = 1.25,
quadruple={56,40,38,44,48,55,56,61,65,65,67,68,67,71,74,70,65,66,72,74,72,71,70,70,70,72,74,76,72},
quadrupletimes = 4*0.96*0.99,
fullof4x={56,40,38,44,48,55,56,61,65,65,67,68,67,71,74,70,65,66,72,74,72,71,70,70,70,72,74,76,72},
fullof4xtimes = 4*0.96*0.99*0.75,
speed = 100,
}
recoil_table["m16a4"] = {
basic={47,35,38,44,58,61,70,67,73,74,72,69,72,71,72,70,72,70,69,71},
basictimes = 1.15,
full={47,35,38,44,58,61,70,67,73,74,72,69,72,71,72,70,72,70,69,71},
fulltimes = 1.15*0.75,
holdbreathtimes = 1.25,
quadruple={47,35,38,44,58,61,70,67,73,74,72,69,72,71,72,70,72,70,69,71},
quadrupletimes = 1.15*4,
fullof4x={47,35,38,44,58,61,70,67,73,74,72,69,72,71,72,70,72,70,69,71},
fullof4xtimes = 4*1.15*0.75,
speed = 80,
}
recoil_table["m416"] = {
basic={49,37,38,39,43,46,47,47,48,49,50,49,55,56,58,60},
basictimes = 1.05,
full={49,37,38,39,43,46,47,47,48,49,50,49,55,56,58,60},
fulltimes = 1.05*0.75,
holdbreathtimes = 1.25,
quadruple={49,37,38,39,43,46,47,47,48,49,50,49,55,56,58,60},
quadrupletimes = 4*1.05,
fullof4x={49,37,38,39,43,46,47,47,48,49,50,49,55,56,58,60},
fullof4xtimes = 4*1.05*0.75,
speed = 90,
}
recoil_table["scarl"] = {
basic={44,28,32,40,44, 45,48,48,46,53, 54,56,58,57,56, 62},
basictimes = 0.89,
full={44,28,32,40,44, 45,48,48,46,53, 54,56,58,57,56, 62},
fulltimes = 0.89*0.75,
holdbreathtimes = 1.25,
quadruple={44,28,32,40,44, 45,48,48,46,53, 54,56,58,57,56, 62},
quadrupletimes = 4*0.89,
fullof4x={44,28,32,40,44, 45,48,48,46,53, 54,56,58,57,56, 62},
fullof4xtimes = 4*0.89*0.75,
speed = 100,
}
recoil_table["uzi"] = {
basic={18,18,18,19,19,21,24,24,30,26,30,30,34,34,38},
basictimes = 1.7,
full={18,18,18,19,19,21,24,24,30,26,30,30,34,34,38},
fulltimes = 1.7*0.75,
holdbreathtimes = 1.25,
quadruple={18,18,18,19,19,21,24,24,30,26,30,30,34,34,38},
quadrupletimes = 1.7,
fullof4x={18,18,18,19,19,21,24,24,30,26,30,30,34,34,38},
fullof4xtimes = 1.7*0.75,
speed = 48,
}
recoil_table["none"] = {
basic={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
basictimes = 1,
full={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
fulltimes = 1,
holdbreathtimes = 1,
quadruple={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
quadrupletimes = 1,
fullof4x={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
fullof4xtimes = 1,
speed = 60,
}
--------------------------------------------------------------------------
---------------- Function ------------------------------
--------------------------------------------------------------------------
function convert_sens(unconvertedSens)
return 0.002 * math.pow(10, unconvertedSens / 50)
end
function calc_sens_scale(sensitivity)
return convert_sens(sensitivity)/convert_sens(50)
end
local target_scale = calc_sens_scale(target_sensitivity)
local scope_scale = calc_sens_scale(scope_sensitivity)
local scope4x_scale = calc_sens_scale(scope4x_sensitivity)
function recoil_mode()
if not IsKeyLockOn(mode_switch_key) then
if IsKeyLockOn(full_mode_key) and full_mode then
return "full";
else
return "basic";
end
end
if IsKeyLockOn(mode_switch_key) then
if IsKeyLockOn(full_mode_key) and full_mode then
return "fullof4x"
else
return "quadruple"
end
end
end
function recoil_value(_weapon,_duration)
local _mode = recoil_mode()
local step = (math.floor(_duration/100)) + 1
if step > #recoil_table[_weapon][_mode] then
step = #recoil_table[_weapon][_mode]
end
local weapon_recoil = recoil_table[_weapon][_mode][step]
-- OutputLogMessage("weapon_recoil = %s\n", weapon_recoil)
local weapon_speed = 30
if weapon_speed_mode then
weapon_speed = recoil_table[_weapon]["speed"]
end
-- OutputLogMessage("weapon_speed = %s\n", weapon_speed)
local weapon_basictimes = recoil_table[_weapon]["basictimes"]
local weapon_fulltimes = recoil_table[_weapon]["fulltimes"]
local weapon_quadrupletimes = recoil_table[_weapon]["quadrupletimes"]
local weapon_fullof4xtimes = recoil_table[_weapon]["fullof4xtimes"]
local weapon_holdbreathtimes = recoil_table[_weapon]["holdbreathtimes"]
local weapon_intervals = weapon_speed
if obfs_mode then
local coefficient = interval_ratio * ( 1 + random_seed * math.random())
weapon_intervals = math.floor(coefficient * weapon_speed)
end
-- OutputLogMessage("weapon_intervals = %s\n", weapon_intervals)
recoil_recovery = weapon_recoil * weapon_intervals / 100
recoil_times = all_recoil_times * 0.7 / vertical_sensitivity
if recoil_mode() == "basic" and not IsModifierPressed(hold_breath_key) then
recoil_recovery = recoil_recovery * recoil_times * weapon_basictimes
end
if recoil_mode() == "basic" and hold_breath_mode and IsModifierPressed(hold_breath_key) then
recoil_recovery = recoil_recovery * weapon_holdbreathtimes * recoil_times * weapon_basictimes
end
if recoil_mode() == "full" and not IsModifierPressed(hold_breath_key) then
recoil_recovery = recoil_recovery * recoil_times * weapon_fulltimes
end
if recoil_mode() == "full" and hold_breath_mode and IsModifierPressed(hold_breath_key) then
recoil_recovery = recoil_recovery * weapon_holdbreathtimes * recoil_times * weapon_fulltimes
end
if recoil_mode() == "quadruple" then
recoil_recovery = recoil_recovery * recoil_times * weapon_quadrupletimes
end
if recoil_mode() == "fullof4x" then
recoil_recovery = recoil_recovery * recoil_times * weapon_fullof4xtimes
end
-- issues/3
if IsMouseButtonPressed(2) then
recoil_recovery = recoil_recovery / target_scale
elseif recoil_mode() == "basic" then
recoil_recovery = recoil_recovery / scope_scale
elseif recoil_mode() == "full" then
recoil_recovery = recoil_recovery / scope_scale
elseif recoil_mode() == "quadruple" then
recoil_recovery = recoil_recovery / scope4x_scale
elseif recoil_mode() == "fullof4x" then
recoil_recovery = recoil_recovery / scope4x_scale
end
return weapon_intervals,recoil_recovery
end
--------------------------------------------------------------------------
---------------- OnEvent ------------------------------
--------------------------------------------------------------------------
function OnEvent(event, arg)
OutputLogMessage("event = %s, arg = %d\n", event, arg)
if (event == "PROFILE_ACTIVATED") then
EnablePrimaryMouseButtonEvents(true)
elseif event == "PROFILE_DEACTIVATED" then
current_weapon = "none"
shoot_duration = 0.0
ReleaseKey(fire_key)
ReleaseMouseButton(1)
end
if (event == "MOUSE_BUTTON_PRESSED" and arg == set_off_key)
or (event == "G_PRESSED" and arg == set_off_gkey) then
current_weapon = "none"
elseif (event == "MOUSE_BUTTON_PRESSED" and arg == akm_key)
or (event == "G_PRESSED" and arg == akm_gkey) then
current_weapon = "akm"
elseif (event == "MOUSE_BUTTON_PRESSED" and arg == m16a4_key)
or (event == "G_PRESSED" and arg == m16a4_gkey) then
current_weapon = "m16a4"
elseif (event == "MOUSE_BUTTON_PRESSED" and arg == m416_key)
or (event == "G_PRESSED" and arg == m416_gkey) then
current_weapon = "m416"
elseif (event == "MOUSE_BUTTON_PRESSED" and arg == ump9_key)
or (event == "G_PRESSED" and arg == ump9_gkey) then
current_weapon = "ump9"
elseif (event == "MOUSE_BUTTON_PRESSED" and arg == uzi_key)
or (event == "G_PRESSED" and arg == uzi_gkey) then
current_weapon = "uzi"
elseif (event == "MOUSE_BUTTON_PRESSED" and arg == scarl_key)
or (event == "G_PRESSED" and arg == scarl_gkey) then
current_weapon = "scarl"
elseif (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and not IsModifierPressed(fast_loot_key)) then
-- button 1 : Shoot
if ((current_weapon == "none") or IsModifierPressed(ignore_key)) then
PressKey(fire_key)
repeat
Sleep(30)
until not IsMouseButtonPressed(1)
ReleaseKey(fire_key)
elseif((current_weapon == "m16a4") and not IsModifierPressed(ignore_key)) then
local shoot_duration = 0.0
repeat
local intervals,recovery = recoil_value(current_weapon,shoot_duration)
PressAndReleaseKey(fire_key)
MoveMouseRelative(0, recovery )
Sleep(intervals)
shoot_duration = shoot_duration + intervals
until not IsMouseButtonPressed(1)
else
if auto_mode then
PressKey(fire_key)
local shoot_duration = 0.0
repeat
local intervals,recovery = recoil_value(current_weapon,shoot_duration)
MoveMouseRelative(0, recovery )
Sleep(intervals)
shoot_duration = shoot_duration + intervals
until not IsMouseButtonPressed(1)
else
local shoot_duration = 0.0
repeat
local intervals,recovery = recoil_value(current_weapon,shoot_duration)
PressAndReleaseKey(fire_key)
MoveMouseRelative(0, recovery )
Sleep(intervals)
shoot_duration = shoot_duration + intervals
until not IsMouseButtonPressed(1)
end
end
elseif (event == "MOUSE_BUTTON_RELEASED" and arg == 1) then
ReleaseKey(fire_key)
end
while (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and IsModifierPressed(fast_loot_key) and fastloot) do
ReleaseMouseButton(1)
PressMouseButton(1)
for i = 0, 14 do
MoveMouseRelative(move, 0)
Sleep(2)
end
ReleaseMouseButton(1)
for i = 0, 14 do
MoveMouseRelative(-move, 0)
Sleep(2)
end
Sleep(10)
end
if (current_weapon == "none") then
if IsKeyLockOn(lighton_key) then
PressAndReleaseKey(lighton_key)
end
else
if not IsKeyLockOn(lighton_key) then
PressAndReleaseKey(lighton_key)
end
end
end