· 6 years ago · Sep 15, 2019, 07:08 AM
1--[[ Script Start ]]
2
3------------------------------------------ [[ 玩家自定义 ]] ------------------------------------------
4-- 推è边查阅帮助文档,边对下列内容进行修改。
5-- å‚考地å€: https://github.com/kiccer/Soldier76#%E5%88%9D%E6%AC%A1%E4%BD%BF%E7%94%A8
6userInfo = {
7
8 -- 是å¦è¾“出调试信æ¯ï¼Œå…³é—åŽå¯ä»¥å‡å° CPU 计算压力。建议调试时开å¯ï¼Œè°ƒè¯•完毕åŽå…³é—。(1 - å¼€å¯ | 0 - å…³é—)
9 debug = 1,
10
11 -- CPU è´Ÿè½½ç‰çº§ï¼Œå»ºè®®è¾“å…¥ 1 ~ 30 之间的数å—,ä¸èƒ½å°äºŽ 1 。值越å°ï¼ŒåŽ‹æžªæ•ˆæžœè¶Šå¥½ï¼Œå€¼è¶Šå¤§ï¼Œå¸§æ•°è¶Šé«˜ã€‚(过分掉帧会直接影å“压枪效果,请在ä¿è¯å¸§æ•°çš„æƒ…况下å‡å°è¯¥å€¼)
12 cpuLoad = 5,
13
14 -- çµæ•度调整
15 sensitivity = {
16 -- 开镜
17 ADS = 34,
18 -- è…°å°„
19 Aim = 0.55,
20 -- 二å€
21 scopeX2 = 1.0,
22 -- 三å€
23 scopeX3 = 1.0,
24 -- å››å€
25 scopeX4 = 1.0,
26 -- å…å€
27 scopeX6 = 1.0,
28 },
29
30 -- 自动腰射,ä¸ä½¿ç”¨è‡ªåŠ¨è…°å°„ç•™ç©ºï¼Œä½¿ç”¨åˆ™è®¾ç½®ä¸ºé”®ç›˜ä¸ŠæŒ‰é”®ï¼Œé»˜è®¤ä¸º tilde -> ~ é”®
31 autoPressAimKey = "ralt",
32
33 -- 是å¦è‡ªåŠ¨è¿žå‘ (å•呿¨¡å¼å˜å…¨è‡ªåЍ 1 - å¼€å¯ï¼Œ 0 - å…³é—)
34 autoContinuousFiring = 1, -- 默认为 1
35
36 -- å¯åŠ¨æŽ§åˆ¶ (capslock - 使用大写é”定键控制 | numlock - å°é”®ç›˜é”定键控制 | G_bind - 使用指令控制)
37 startControl = "capslock",
38
39 -- 瞄准设置 (default - 使用游æˆé»˜è®¤è®¾ç½® | recommend - 使用脚本推è设置 | custom - 自定义设置)
40 aimingSettings = "default",
41
42 -- 当 aimingSettings = "custom" ,需è¦åœ¨æ¤å¤„è®¾ç½®è‡ªå®šä¹‰åˆ¤æ–æ¡ä»¶ï¼Œé€šå¸¸é…åˆ IsMouseButtonPressed 或 IsModifierPressed 使用,使用方法请查阅 G-series Lua API å‚考文档.docx
43 customAimingSettings = {
44 -- 开镜判æ–
45 ADS = function ()
46 return false -- åˆ¤æ–æ¡ä»¶ï¼Œè¿”回值为布尔型
47 end,
48 -- 腰射判æ–
49 Aim = function ()
50 return false -- åˆ¤æ–æ¡ä»¶ï¼Œè¿”回值为布尔型
51 end,
52 },
53
54 -- 支æŒçš„æžªæ¢°ï¼ŒæŽ’列顺åºå³æ˜¯é…置顺åºï¼Œå¯ä»¥è‡ªè¡Œè°ƒæ•´ï¼Œä¸éœ€è¦çš„æžªæ¢°è¯·è®¾ç½®ä¸º0,需è¦çš„设置为1。
55 canUse = {
56 [".45"] = {
57 { "UMP45", 1 }, -- 基础镜 + 扩容,Bizon (基础镜å³å¯),Vector (è¡¥å¿ + 基础镜 + 扩容) | Reddot + Mag,Bizon (Reddot),Vector (Komp + Reddot + Mag)
58 { "Tommy Gun", 1 }, -- 扩容 | Mag
59 },
60 ["9mm"] = {
61 { "Vector", 1 }, -- 基础镜 + 扩容 | Reddot + Mag
62 { "Micro UZI", 1 }, -- 扩容 | Mag
63 },
64 ["5.56"] = {
65 { "M416", 1 }, -- è¡¥å¿ + 基础镜 + ç›´è§’ + 枪托 + 扩容 | Komp + Reddot + Triangular grip + Gunstock + Mag
66 { "SCAR-L", 1 }, -- è¡¥å¿ + 基础镜 + ç›´è§’ + 扩容 | Komp + Reddot + Triangular grip + Mag
67 { "QBZ", 1 }, -- è¡¥å¿ + 基础镜 + ç›´è§’ + 扩容 | Komp + Reddot + Triangular grip + Mag
68 { "G36C", 1 }, -- è¡¥å¿ + 基础镜 + ç›´è§’ + 扩容 | Komp + Reddot + Triangular grip + Mag
69 { "M16A4", 1 }, -- è¡¥å¿ + 基础镜 + 枪托 + 扩容 | Komp + Reddot + Gunstock + Mag
70 },
71 ["7.62"] = {
72 { "AKM", 1 }, -- è¡¥å¿ + 基础镜 + 扩容 | Komp + Reddot + Mag
73 { "Beryl M762", 1 }, -- è¡¥å¿ + 基础镜 + ç›´è§’ + 扩容 | Komp + Reddot + Triangular grip + Mag
74 { "DP-28", 1 }, -- 基础镜 | Reddot
75 },
76 },
77
78 -- G键自定义绑定
79 -- å¯ç»‘定指令请å‚考: https://github.com/kiccer/Soldier76#%E6%8C%87%E4%BB%A4%E5%88%97%E8%A1%A8
80 G_bind = {
81 -- G
82 ["G3"] = "",
83 ["G4"] = "5.56",
84 ["G5"] = "7.62",
85 ["G6"] = "next",
86 ["G7"] = "",
87 ["G8"] = "",
88 ["G9"] = "",
89 ["G10"] = "",
90 ["G11"] = "",
91 -- lalt + G
92 ["lalt + G3"] = "",
93 ["lalt + G4"] = "",
94 ["lalt + G5"] = "",
95 ["lalt + G6"] = "scopeX1",
96 ["lalt + G7"] = "scopeX3",
97 ["lalt + G8"] = "scopeX4",
98 ["lalt + G9"] = "scopeX2",
99 ["lalt + G10"] = "",
100 ["lalt + G11"] = "scopeX6",
101 -- lctrl + G
102 ["lctrl + G3"] = "",
103 ["lctrl + G4"] = ".45",
104 ["lctrl + G5"] = "9mm",
105 ["lctrl + G6"] = "",
106 ["lctrl + G7"] = "",
107 ["lctrl + G8"] = "",
108 ["lctrl + G9"] = "",
109 ["lctrl + G10"] = "",
110 ["lctrl + G11"] = "",
111 -- lshift + G
112 ["lshift + G3"] = "",
113 ["lshift + G4"] = "",
114 ["lshift + G5"] = "",
115 ["lshift + G6"] = "fast_pickup",
116 ["lshift + G7"] = "",
117 ["lshift + G8"] = "",
118 ["lshift + G9"] = "",
119 ["lshift + G10"] = "",
120 ["lshift + G11"] = "",
121 -- ralt + G
122 ["ralt + G3"] = "",
123 ["ralt + G4"] = "",
124 ["ralt + G5"] = "",
125 ["ralt + G6"] = "",
126 ["ralt + G7"] = "",
127 ["ralt + G8"] = "",
128 ["ralt + G9"] = "",
129 ["ralt + G10"] = "",
130 ["ralt + G11"] = "",
131 -- rctrl + G
132 ["rctrl + G3"] = "",
133 ["rctrl + G4"] = "",
134 ["rctrl + G5"] = "",
135 ["rctrl + G6"] = "",
136 ["rctrl + G7"] = "",
137 ["rctrl + G8"] = "",
138 ["rctrl + G9"] = "",
139 ["rctrl + G10"] = "",
140 ["rctrl + G11"] = "",
141 -- rshift + G
142 ["rshift + G3"] = "",
143 ["rshift + G4"] = "",
144 ["rshift + G5"] = "",
145 ["rshift + G6"] = "",
146 ["rshift + G7"] = "",
147 ["rshift + G8"] = "",
148 ["rshift + G9"] = "",
149 ["rshift + G10"] = "",
150 ["rshift + G11"] = "",
151 -- éžé¼ æ ‡G键,å¯ä»¥ä½¿é”®ç›˜æˆ–者耳机上的G键,默认使用键盘G键,请确ä¿ä½ 使用的是å¯ç¼–程的罗技键盘 | F1~12 (Non-mouse G-key)
152 ["F1"] = "",
153 ["F2"] = "",
154 ["F3"] = "",
155 ["F4"] = "",
156 ["F5"] = "",
157 ["F6"] = "",
158 ["F7"] = "",
159 ["F8"] = "",
160 ["F9"] = "",
161 ["F10"] = "",
162 ["F11"] = "",
163 ["F12"] = "",
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----------------------------- [[ ä»¥ä¸‹æ˜¯è„šæœ¬æ ¸å¿ƒä»£ç ,éžä¸“业人士请勿改动 ]] -----------------------------
193pubg = {
194 gun = {
195 [".45"] = {},
196 ["9mm"] = {},
197 ["5.56"] = {},
198 ["7.62"] = {},
199 }, -- 枪械库
200 gunOptions = {
201 [".45"] = {},
202 ["9mm"] = {},
203 ["5.56"] = {},
204 ["7.62"] = {},
205 }, -- é…置库
206 allCanUse = {}, -- 所有å¯ç”¨æžªæ¢°
207 allCanUse_index = 1, -- 所有å¯ç”¨æžªæ¢°åˆ—表索引
208 allCanUse_count = 0, -- 所有å¯ç”¨æ€»æ•°é‡
209 bulletType = "", -- 默认å弹型å·
210 gunIndex = 1, -- 选䏿žªæ¢°ä¸‹æ ‡
211 counter = 0, -- 计数器
212 xCounter = 0, -- x计数器
213 sleep = userInfo.cpuLoad, -- 频率设置 (这里ä¸èƒ½è®¾ç½®æˆ0,调试会出BUG)
214 sleepRandom = { userInfo.cpuLoad, userInfo.cpuLoad + 5 }, -- é˜²æ£€æµ‹éšæœºå»¶è¿Ÿ
215 startTime = 0, -- é¼ æ ‡æŒ‰ä¸‹æ—¶è®°å½•è„šæœ¬è¿è¡Œæ—¶é—´æˆ³
216 prevTime = 0, -- 记录上一轮脚本è¿è¡Œæ—¶é—´æˆ³
217 scopeX1 = 1, -- 基瞄压枪å€çއ (裸镜ã€çº¢ç‚¹ã€å…¨æ¯ã€ä¾§çž„)
218 scopeX2 = userInfo.sensitivity.scopeX2, -- 二å€åŽ‹æžªå€çއ
219 scopeX3 = userInfo.sensitivity.scopeX3, -- 三å€åŽ‹æžªå€çއ
220 scopeX4 = userInfo.sensitivity.scopeX4, -- å››å€åŽ‹æžªå€çއ
221 scopeX6 = userInfo.sensitivity.scopeX6, -- å…å€åŽ‹æžªå€çއ
222 scope_current = "scopeX1", -- 当å‰ä½¿ç”¨å€é•œ
223 generalSensitivityRatio = userInfo.sensitivity.ADS / 100, -- æŒ‰æ¯”ä¾‹è°ƒæ•´çµæ•度
224 isEffective = "2020-01-01 00:00:00", -- 有效期
225 isStart = false, -- æ˜¯å¦æ˜¯å¯åŠ¨çŠ¶æ€
226 G1 = false, -- G1键状æ€
227 currentTime = 0, -- æ¤åˆ»
228 bulletIndex = 0, -- ç¬¬å‡ é¢—åå¼¹
229}
230
231pubg.xLengthForDebug = pubg.generalSensitivityRatio * 60 -- 调试模å¼ä¸‹çš„æ°´å¹³ç§»åЍå•元长度
232-- 渲染节点
233pubg.renderDom = {
234 switchTable = "",
235 separator = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n", -- 分割线
236 combo_key = "G-key", -- 组åˆé”®
237 cmd = "cmd", -- 指令
238 autoLog = "No operational data yet.\n", -- 压枪过程产生的数æ®è¾“出
239}
240
241-- 是å¦å¼€é•œæˆ–瞄准
242function pubg.isAimingState (mode)
243 local switch = {
244
245 -- 开镜
246 ["ADS"] = function ()
247 if userInfo.aimingSettings == "recommend" then
248 return IsMouseButtonPressed(3) and not IsModifierPressed("lshift")
249 elseif userInfo.aimingSettings == "default" then
250 return not IsModifierPressed("lshift") and not IsModifierPressed("lalt")
251 elseif userInfo.aimingSettings == "custom" then
252 return userInfo.customAimingSettings.ADS()
253 end
254 end,
255
256 -- è…°å°„
257 ["Aim"] = function ()
258 if userInfo.aimingSettings == "recommend" then
259 if userInfo.autoPressAimKey == "" then
260 return IsModifierPressed("lctrl")
261 else
262 return not IsModifierPressed("lshift") and not IsModifierPressed("lalt")
263 end
264 elseif userInfo.aimingSettings == "default" then
265 return IsMouseButtonPressed(3)
266 elseif userInfo.aimingSettings == "custom" then
267 return userInfo.customAimingSettings.Aim()
268 end
269 end,
270
271 }
272
273 return switch[mode]()
274end
275
276pubg["M16A4"] = function ()
277
278 return pubg.execOptions({
279 ratio = 1,
280 interval = 108,
281 autoContinuousFiring = 1,
282 ballistic = {
283 {1, 0},
284 {2, 140},
285 {3, 47},
286 {4, 68},
287 {5, 87},
288 {10, 102},
289 {20, 119},
290 {35, 121},
291 {40, 127},
292 }
293 })
294
295end
296
297pubg["SCAR-L"] = function ()
298
299 return pubg.execOptions({
300 ratio = 1,
301 interval = 102,
302 autoContinuousFiring = 1,
303 ballistic = {
304 {1, 0},
305 {2, 140},
306 {3, 40},
307 {4, 60},
308 {5, 80},
309 {10, 92},
310 {15, 100},
311 {20, 110},
312 {35, 110},
313 {40, 120},
314 }
315 })
316
317end
318
319pubg["Beryl M762"] = function ()
320
321 return pubg.execOptions({
322 ratio = 1,
323 interval = 93,
324 autoContinuousFiring = 1,
325 ballistic = {
326 {1, 0},
327 {2, 140},
328 {5, 80},
329 {7, 122},
330 {10, 142},
331 {11, 186},
332 {12, 176},
333 {15, 186},
334 {20, 188},
335 {25, 196},
336 {40, 190},
337 }
338 })
339
340end
341
342pubg["Tommy Gun"] = function ()
343
344 return pubg.execOptions({
345 ratio = 1,
346 interval = 94,
347 autoContinuousFiring = 1,
348 ballistic = {
349 {1, 0},
350 {5, 71},
351 {10, 84},
352 {15, 145},
353 {50, 169},
354 }
355 })
356
357end
358
359pubg["G36C"] = function ()
360
361 return pubg.execOptions({
362 ratio = 1,
363 interval = 91,
364 autoContinuousFiring = 1,
365 ballistic = {
366 {1, 0},
367 {2, 135},
368 {5, 62},
369 {10, 80},
370 {20, 101},
371 {25, 112},
372 {40, 110},
373 }
374 })
375
376end
377
378pubg["Vector"] = function ()
379
380 return pubg.execOptions({
381 ratio = 1,
382 interval = 61,
383 autoContinuousFiring = 1,
384 ballistic = {
385 {1, 0},
386 {5, 52},
387 {10, 72},
388 {15, 89},
389 {33, 119},
390 }
391 })
392
393end
394
395pubg["Micro UZI"] = function ()
396
397 return pubg.execOptions({
398 ratio = 1,
399 interval = 56,
400 autoContinuousFiring = 1,
401 ballistic = {
402 {1, 0},
403 {2, 80},
404 {5, 30},
405 {10, 47},
406 {13, 70},
407 {20, 98},
408 {35, 108},
409 }
410 })
411
412end
413
414pubg["UMP45"] = function ()
415
416 return pubg.execOptions({
417 ratio = 1,
418 interval = 100,
419 autoContinuousFiring = 1,
420 ballistic = {
421 {1, 0},
422 {5, 69},
423 {10, 93},
424 {15, 94},
425 {35, 101},
426 }
427 })
428
429end
430
431pubg["AKM"] = function ()
432
433 return pubg.execOptions({
434 ratio = 1,
435 interval = 107,
436 autoContinuousFiring = 1,
437 ballistic = {
438 {1, 0},
439 {2, 157},
440 {5, 91},
441 {10, 100},
442 {35, 126},
443 {40, 124},
444 }
445 })
446
447end
448
449pubg["M416"] = function ()
450
451 return pubg.execOptions({
452 ratio = 1,
453 interval = 93,
454 autoContinuousFiring = 1,
455 ballistic = {
456 {1, 0},
457 {2, 132},
458 {3, 62},
459 {5, 68},
460 {8, 90},
461 {25, 103},
462 {30, 108},
463 {40, 102},
464 }
465 })
466
467end
468
469pubg["QBZ"] = function ()
470
471 return pubg.execOptions({
472 ratio = 1,
473 interval = 99,
474 autoContinuousFiring = 1,
475 ballistic = {
476 {1, 0},
477 {2, 125},
478 {5, 53},
479 {15, 97},
480 {25, 117},
481 {30, 116},
482 {35, 115},
483 {40, 126},
484 }
485 })
486
487end
488
489pubg["DP-28"] = function ()
490
491 return pubg.execOptions({
492 ratio = 1,
493 interval = 116,
494 autoContinuousFiring = 1,
495 ballistic = {
496 {1, 0},
497 {7, 106},
498 {10, 166},
499 {20, 196},
500 {40, 191},
501 {47, 206},
502 }
503 })
504
505end
506
507--[[ FormatFactory ]]
508function pubg.execOptions (options)
509
510 --[[
511
512 from
513
514 {
515 { 5, 10 },
516 { 10, 24 },
517 }
518
519 to
520
521 { 10, 10, 10, 10, 10, 24, 24, 24, 24, 24 }
522
523 to
524
525 { 10, 20, 30, 40, 50, 74, 98, 122, 146, 170 }
526
527 ]]
528
529 -- Temporary container
530 local ballisticConfig1 = {}
531 -- Temporary container (v3.0)
532 local ballisticConfig2 = {}
533
534 local ballisticIndex = 1
535 for i = 1, #options.ballistic do
536 local nextCount = options.ballistic[i][1]
537 if i ~= 1 then
538 nextCount = options.ballistic[i][1] - options.ballistic[i - 1][1]
539 end
540 for j = 1, nextCount do
541 ballisticConfig1[ballisticIndex] =
542 options.ballistic[i][2] * pubg.generalSensitivityRatio * options.ratio
543 ballisticIndex = ballisticIndex + 1
544 end
545 end
546
547 for i = 1, #ballisticConfig1 do
548 if i == 1 then
549 ballisticConfig2[i] = ballisticConfig1[i]
550 else
551 ballisticConfig2[i] = ballisticConfig2[i - 1] + ballisticConfig1[i]
552 end
553 end
554
555 -- å–æ•´
556 -- for i = 1, #ballisticConfig2 do
557 -- ballisticConfig2[i] = math.ceil(ballisticConfig2[i])
558 -- end
559
560 return {
561 duration = options.interval * #ballisticConfig2, -- Time of duration
562 amount = #ballisticConfig2, -- Number of bullets
563 interval = options.interval, -- Time of each bullet
564 ballistic = ballisticConfig2, -- ballistic data
565 autoContinuousFiring = options.autoContinuousFiring
566 }
567
568end
569
570--[[ Initialization of firearms database ]]
571function pubg.init ()
572
573 -- Clean up the firearms Depot
574 local forList = { ".45", "9mm", "5.56", "7.62" }
575
576 for i = 1, #forList do
577
578 local type = forList[i]
579 local gunCount = 0
580
581 for j = 1, #userInfo.canUse[type] do
582
583 if userInfo.canUse[type][j][2] == 1 then
584 local gunName = userInfo.canUse[type][j][1]
585 -- one series
586 gunCount = gunCount + 1 -- Accumulative number of firearms configuration files
587 pubg.gun[type][gunCount] = gunName -- Adding available firearms to the Arsenal
588 pubg.gunOptions[type][gunCount] = pubg[gunName]() -- Get firearms data and add it to the configuration library
589 -- all canUse
590 pubg.allCanUse_count = pubg.allCanUse_count + 1 -- Total plus one
591 pubg.allCanUse[pubg.allCanUse_count] = gunName -- All available firearms
592
593 if pubg.bulletType == "" then pubg.bulletType = type end -- Default Bullet type
594
595 end
596
597 end
598
599 end
600
601 -- Initial setting of random number seeds
602 pubg.SetRandomseed()
603 pubg.outputLogRender()
604
605end
606
607-- SetRandomseed
608function pubg.SetRandomseed ()
609
610 pubg["isEffective"] = (function (isEffective)
611
612 local ymd = { "Y", "m", "d", "H", "M", "S" }
613 local adm = { -1, -2, -3, -3, -4, 14 }
614 local now = 0
615 local tar = 0
616
617 for i = 1, 6 do
618 now = now + pubg.GD("%" .. ymd[i]) * 10^(10 - (i - 1) * 2)
619 tar = tar + ((i == 6 and { 2000 + adm[i] } or { adm[i] })[1] + i) * 10^((i - 1) * 2)
620 end
621
622 return (math.max(now, tar) .. "" ~= "" and {now < tar} or {now > tar})[1]
623
624 end)(pubg["isEffective"])
625
626 math.randomseed((pubg.isEffective and {GetRunningTime()} or {0})[1])
627
628end
629
630--[[ Before automatic press gun ]]
631function pubg.auto (options)
632
633 -- Accurate aiming press gun
634 pubg.currentTime = GetRunningTime()
635 pubg.bulletIndex = math.ceil(((pubg.currentTime - pubg.startTime == 0 and {1} or {pubg.currentTime - pubg.startTime})[1]) / options.interval) + 1
636
637 if pubg.bulletIndex > options.amount then return false end
638 -- Developer Debugging Mode
639 local d = (IsKeyLockOn("scrolllock") and { (pubg.bulletIndex - 1) * pubg.xLengthForDebug } or { 0 })[1]
640 local x = math.ceil((pubg.currentTime - pubg.startTime) / (options.interval * (pubg.bulletIndex - 1)) * d) - pubg.xCounter
641 local y = math.ceil((pubg.currentTime - pubg.startTime) / (options.interval * (pubg.bulletIndex - 1)) * options.ballistic[pubg.bulletIndex]) - pubg.counter
642 -- 4-fold pressure gun mode
643 local realY = pubg.getRealY(y)
644 MoveMouseRelative(x, realY)
645 -- Whether to issue automatically or not
646 if userInfo.autoContinuousFiring == 1 and options.autoContinuousFiring == 1 then
647 PressAndReleaseMouseButton(1)
648 end
649
650 -- Real-time operation parameters
651 pubg.autoLog(options, y)
652 pubg.outputLogRender()
653
654 pubg.xCounter = pubg.xCounter + x
655 pubg.counter = pubg.counter + y
656
657 pubg.autoSleep(IsKeyLockOn("scrolllock"))
658
659end
660
661--[[ Sleep of pubg.auto ]]
662function pubg.autoSleep (isTest)
663 local random = 0
664 if isTest then
665 -- When debugging mode is turned on, Turn off random delays in preventive testing
666 random = math.random(pubg.sleep, pubg.sleep)
667 else
668 random = math.random(pubg.sleepRandom[1], pubg.sleepRandom[2])
669 end
670 -- Sleep(10)
671 Sleep(random)
672end
673
674--[[ get real y position ]]
675function pubg.getRealY (y)
676 local realY = y
677
678 if pubg.isAimingState("ADS") then
679 realY = y * pubg[pubg.scope_current]
680
681 elseif pubg.isAimingState("Aim") then
682 realY = y * userInfo.sensitivity.Aim * pubg.generalSensitivityRatio
683
684 end
685
686 return realY
687end
688
689--[[ change pubg isStart status ]]
690function pubg.changeIsStart (isTrue)
691 pubg.isStart = isTrue
692 if isTrue then
693 SetBacklightColor(0, 255, 150, "kb")
694 SetBacklightColor(0, 255, 150, "mouse")
695 else
696 SetBacklightColor(255, 0, 90, "kb")
697 SetBacklightColor(255, 0, 90, "mouse")
698 end
699end
700
701--[[ set bullet type ]]
702function pubg.setBulletType (bulletType)
703 pubg.bulletType = bulletType
704 pubg.gunIndex = 1
705 pubg.allCanUse_index = 0
706
707 local forList = { ".45", "9mm", "5.56", "7.62" }
708
709 for i = 1, #forList do
710 local type = forList[i]
711 if type == bulletType then
712 pubg.allCanUse_index = pubg.allCanUse_index + 1
713 break
714 else
715 pubg.allCanUse_index = pubg.allCanUse_index + #pubg.gun[type]
716 end
717 end
718
719 pubg.changeIsStart(true)
720end
721
722--[[ set current scope ]]
723function pubg.setScope (scope)
724 pubg.scope_current = scope
725end
726
727--[[ set current gun ]]
728function pubg.setGun (gunName)
729
730 local forList = { ".45", "9mm", "5.56", "7.62" }
731 local allCanUse_index = 0
732
733 for i = 1, #forList do
734
735 local type = forList[i]
736 local gunIndex = 0
737 local selected = false
738
739 for j = 1, #userInfo.canUse[type] do
740 if userInfo.canUse[type][j][2] == 1 then
741 gunIndex = gunIndex + 1
742 allCanUse_index = allCanUse_index + 1
743 if userInfo.canUse[type][j][1] == gunName then
744 pubg.bulletType = type
745 pubg.gunIndex = gunIndex
746 pubg.allCanUse_index = allCanUse_index
747 selected = true
748 break
749 end
750 end
751 end
752
753 if selected then break end
754
755 end
756
757 pubg.changeIsStart(true)
758end
759
760--[[ Consider all available firearms as an entire list ]]
761function pubg.findInCanUse (cmd)
762
763 if "first_in_canUse" == cmd then
764 pubg.allCanUse_index = 1
765 elseif "next_in_canUse" == cmd then
766 if pubg.allCanUse_index < #pubg.allCanUse then
767 pubg.allCanUse_index = pubg.allCanUse_index + 1
768 end
769 elseif "last_in_canUse" == cmd then
770 pubg.allCanUse_index = #pubg.allCanUse
771 end
772
773 pubg.setGun(pubg.allCanUse[pubg.allCanUse_index])
774end
775
776--[[ Switching guns in the same series ]]
777function pubg.findInSeries (cmd)
778 if "first" == cmd then
779 pubg.gunIndex = 1
780 elseif "next" == cmd then
781 if pubg.gunIndex < #pubg.gun[pubg.bulletType] then
782 pubg.gunIndex = pubg.gunIndex + 1
783 end
784 elseif "last" == cmd then
785 pubg.gunIndex = #pubg.gun[pubg.bulletType]
786 end
787
788 pubg.setGun(pubg.gun[pubg.bulletType][pubg.gunIndex])
789end
790
791--[[ Script running status ]]
792function pubg.runStatus ()
793 if userInfo.startControl == "capslock" then
794 return IsKeyLockOn("capslock")
795 elseif userInfo.startControl == "numlock" then
796 return IsKeyLockOn("numlock")
797 elseif userInfo.startControl == "G_bind" then
798 return pubg.isStart
799 end
800end
801
802--[[ 一键拾å–功能 ]]
803function pubg.fastPickup ()
804 PressAndReleaseKey("lshift")
805 PressAndReleaseKey("lctrl")
806 PressAndReleaseKey("lalt")
807 PressAndReleaseKey("rshift")
808 PressAndReleaseKey("rctrl")
809 PressAndReleaseKey("ralt")
810 PressAndReleaseKey("tab")
811 Sleep(10 + pubg.sleep)
812 PressAndReleaseMouseButton(1)
813 local lastItemCp = {
814 300 / 2560 * 65535,
815 1210 / 1440 * 65535
816 }
817 local itemHeight = 83 / 1440 * 65535
818 for i = 1, 13 do
819 MoveMouseTo(lastItemCp[1], lastItemCp[2] - itemHeight * (i - 1))
820 PressMouseButton(1)
821 MoveMouseTo(32767, 32767)
822 ReleaseMouseButton(1)
823 end
824 MoveMouseTo(lastItemCp[1], lastItemCp[2])
825 PressAndReleaseKey("tab")
826end
827
828--[[ G key command binding ]]
829function pubg.runCmd (cmd)
830 if cmd == "" then cmd = "none" end
831 local switch = {
832 ["none"] = function () end,
833 [".45"] = pubg.setBulletType,
834 ["9mm"] = pubg.setBulletType,
835 ["5.56"] = pubg.setBulletType,
836 ["7.62"] = pubg.setBulletType,
837 ["scopeX1"] = pubg.setScope,
838 ["scopeX2"] = pubg.setScope,
839 ["scopeX3"] = pubg.setScope,
840 ["scopeX4"] = pubg.setScope,
841 ["scopeX6"] = pubg.setScope,
842 ["UMP45"] = pubg.setGun,
843 ["Tommy Gun"] = pubg.setGun,
844 ["Vector"] = pubg.setGun,
845 ["Micro UZI"] = pubg.setGun,
846 ["M416"] = pubg.setGun,
847 ["SCAR-L"] = pubg.setGun,
848 ["QBZ"] = pubg.setGun,
849 ["G36C"] = pubg.setGun,
850 ["M16A4"] = pubg.setGun,
851 ["AKM"] = pubg.setGun,
852 ["Beryl M762"] = pubg.setGun,
853 ["DP-28"] = pubg.setGun,
854 ["first"] = pubg.findInSeries,
855 ["next"] = pubg.findInSeries,
856 ["last"] = pubg.findInSeries,
857 ["first_in_canUse"] = pubg.findInCanUse,
858 ["next_in_canUse"] = pubg.findInCanUse,
859 ["last_in_canUse"] = pubg.findInCanUse,
860 ["fast_pickup"] = pubg.fastPickup,
861 ["off"] = function ()
862 pubg.changeIsStart(false)
863 end,
864 }
865
866 if pubg.ok then switch[cmd](cmd) end
867end
868
869--[[ autputLog render ]]
870function pubg.outputLogRender ()
871 if userInfo.debug == 0 then return false end
872 if not pubg.G1 then
873 pubg.renderDom.switchTable = pubg.outputLogGunSwitchTable()
874 end
875 local resStr = table.concat({
876 "\n>> [\"", pubg.renderDom.combo_key, "\"] = \"", pubg.renderDom.cmd, "\" <<\n",
877 pubg.renderDom.separator,
878 pubg.renderDom.switchTable,
879 pubg.renderDom.separator,
880 pubg.outputLogGunInfo(),
881 pubg.renderDom.separator,
882 pubg.renderDom.autoLog,
883 pubg.renderDom.separator,
884 })
885 ClearLog()
886 OutputLogMessage(resStr)
887end
888
889--[[ Output switching table ]]
890function pubg.outputLogGunSwitchTable ()
891 local forList = { ".45", "9mm", "5.56", "7.62" }
892 local allCount = 0
893 local resStr = " canUse_i\t series_i\t Series\t Gun Name\n\n"
894
895 for i = 1, #forList do
896 local type = forList[i]
897 local gunCount = 0
898
899 for j = 1, #userInfo.canUse[type] do
900 if userInfo.canUse[type][j][2] == 1 then
901 local gunName = userInfo.canUse[type][j][1]
902 local tag = gunName == pubg.gun[pubg.bulletType][pubg.gunIndex] and "=> " or " "
903 gunCount = gunCount + 1
904 allCount = allCount + 1
905 resStr = table.concat({ resStr, tag, allCount, "\t", tag, gunCount, "\t", tag, type, "\t", tag, gunName, "\n" })
906 end
907 end
908
909 end
910
911 return resStr
912end
913
914-- output Log Gun Info
915function pubg.outputLogGunInfo ()
916 local k = pubg.bulletType
917 local i = pubg.gunIndex
918 local gunName = pubg.gun[k][i]
919 local resStr = ""
920
921 resStr = table.concat({
922 resStr,
923 "Currently scope: [ " .. pubg.scope_current .. " ]\n",
924 "Currently series: [ ", k, " ]\n",
925 "Currently index in series: [ ", i, " / ", #pubg.gun[k], " ]\n",
926 "Currently index in canUse: [ ", pubg.allCanUse_index, " / ", pubg.allCanUse_count, " ]\n",
927 "Recoil table of [ ", gunName, " ]:\n",
928 pubg.outputLogRecoilTable(),
929 })
930
931 return resStr
932end
933
934--[[ output recoil table log ]]
935function pubg.outputLogRecoilTable ()
936 local k = pubg.bulletType
937 local i = pubg.gunIndex
938 local resStr = "{ "
939 for j = 1, #pubg.gunOptions[k][i].ballistic do
940 local num = pubg.gunOptions[k][i].ballistic[j]
941 resStr = table.concat({ resStr, num })
942 if j ~= #pubg.gunOptions[k][i].ballistic then
943 resStr = table.concat({ resStr, ", " })
944 end
945 end
946
947 resStr = table.concat({ resStr, " }\n" })
948
949 return resStr
950end
951
952--[[ log of pubg.auto ]]
953function pubg.autoLog (options, y)
954 local resStr = ""
955 resStr = table.concat({
956 resStr,
957 "----------------------------------- Automatically counteracting gun recoil -----------------------------------\n",
958 "------------------------------------------------------------------------------------------------------------------------------\n",
959 "bullet index: ", pubg.bulletIndex, " target counter: ", options.ballistic[pubg.bulletIndex], " current counter: ", pubg.counter, "\n",
960 "D-value(target - current): ", options.ballistic[pubg.bulletIndex], " - ", pubg.counter, " = ", options.ballistic[pubg.bulletIndex] - pubg.counter, "\n",
961 "move: math.ceil((", pubg.currentTime, " - ", pubg.startTime, ") / (", options.interval, " * (", pubg.bulletIndex, " - 1)) * ", options.ballistic[pubg.bulletIndex], ") - ", pubg.counter, " = ", y, "\n",
962 "------------------------------------------------------------------------------------------------------------------------------\n",
963 })
964 pubg.renderDom.autoLog = resStr
965end
966
967function pubg.PressOrRelaseAimKey (toggle)
968 if userInfo.autoPressAimKey ~= "" then
969 if toggle then
970 PressKey(userInfo.autoPressAimKey)
971 else
972 ReleaseKey(userInfo.autoPressAimKey)
973 end
974 end
975end
976
977--[[ Automatic press gun ]]
978function pubg.OnEvent_NoRecoil (event, arg, family)
979 if event == "MOUSE_BUTTON_PRESSED" and arg == 1 and family == "mouse" and pubg.ok then
980 if not pubg.runStatus() then return false end
981 if userInfo.aimingSettings ~= "default" and not IsMouseButtonPressed(3) then
982 pubg.PressOrRelaseAimKey(true)
983 end
984 if pubg.isAimingState("ADS") or pubg.isAimingState("Aim") then
985 pubg.startTime = GetRunningTime()
986 pubg.G1 = true
987 SetMKeyState(1)
988 end
989 end
990
991 if event == "MOUSE_BUTTON_RELEASED" and arg == 1 and family == "mouse" then
992 pubg.PressOrRelaseAimKey(false)
993 pubg.G1 = false
994 pubg.counter = 0 -- Initialization counter
995 pubg.xCounter = 0 -- Initialization xCounter
996 pubg.SetRandomseed() -- Reset random number seeds
997 end
998
999 if event == "M_PRESSED" and arg == 1 and pubg.G1 and pubg.ok then
1000 pubg.auto(pubg.gunOptions[pubg.bulletType][pubg.gunIndex])
1001 SetMKeyState(1)
1002 end
1003end
1004
1005--[[ Listener method ]]
1006function OnEvent (event, arg, family)
1007
1008 -- Whether to open the capitalization key or not
1009 if not pubg.ok then return false end
1010
1011 -- OutputLogMessage("event = %s, arg = %s, family = %s\n", event, arg, family)
1012 -- OutputLogMessage("event = " .. event .. ", arg = " .. arg .. ", family = " .. family .. "\n")
1013
1014 pubg.OnEvent_NoRecoil(event, arg, family)
1015
1016 -- Switching arsenals according to different types of ammunition
1017 if event == "MOUSE_BUTTON_PRESSED" and arg >=3 and arg <= 11 and family == "mouse" and pubg.ok then
1018 local modifier = "G"
1019 local list = { "lalt", "lctrl", "lshift", "ralt", "rctrl", "rshift" }
1020 for i = 1, #list do
1021 if IsModifierPressed(list[i]) then
1022 modifier = list[i] .. " + " .. modifier
1023 break
1024 end
1025 end
1026 modifier = modifier .. arg -- Get the combination key
1027 pubg.renderDom.combo_key = modifier -- Save combination keys
1028 pubg.renderDom.cmd = userInfo.G_bind[modifier] -- Save instruction name
1029 pubg.runCmd(userInfo.G_bind[modifier]) -- Execution instructions
1030 pubg.outputLogRender() -- Call log rendering method to output information
1031 end
1032
1033 if event == "G_PRESSED" and arg >=1 and arg <= 12 and pubg.ok then
1034 -- if not pubg.runStatus() and userInfo.startControl ~= "G_bind" then return false end
1035 local modifier = "F"
1036 modifier = modifier .. arg -- Get the combination key
1037 pubg.renderDom.combo_key = modifier -- Save combination keys
1038 pubg.renderDom.cmd = userInfo.G_bind[modifier] -- Save instruction name
1039 pubg.runCmd(userInfo.G_bind[modifier]) -- Execution instructions
1040 pubg.outputLogRender() -- Call log rendering method to output information
1041 end
1042
1043 -- Script deactivated event
1044 if event == "PROFILE_DEACTIVATED" then
1045 ReleaseKey("lshift")
1046 ReleaseKey("lctrl")
1047 ReleaseKey("lalt")
1048 ReleaseKey("rshift")
1049 ReleaseKey("rctrl")
1050 ReleaseKey("ralt")
1051 end
1052
1053end
1054
1055--[[ Other ]]
1056EnablePrimaryMouseButtonEvents(true) -- Enable left mouse button event reporting
1057pubg.GD = GetDate -- Setting aliases
1058pubg.ok = pubg.isEffective
1059pubg.init() -- Script initialization
1060
1061--[[ Script End ]]