forked from kiccer/Soldier76
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Soldier76.lua
1308 lines (1104 loc) · 35.1 KB
/
Soldier76.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
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
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--[[ Script Start ]]
------------------------------------------ [[ 玩家自定义 ]] ------------------------------------------
-- 推荐边查阅帮助文档,边对下列内容进行修改。
-- 参考地址: https://github.com/kiccer/Soldier76#%E5%88%9D%E6%AC%A1%E4%BD%BF%E7%94%A8
-- It is recommended to review the help documents and modify the following contents.
userInfo = {
-- 是否输出调试信息,关闭后可以减小 CPU 计算压力。建议调试时开启,调试完毕后关闭。(1 - 开启 | 0 - 关闭)
-- Whether to output debugging information, the CPU calculation pressure can be reduced after close.
-- It is recommended to turn it on during debugging and turn it off after debugging.
-- (0 - Disable | 1 - Enable)
debug = 1,
-- CPU 负载等级,建议输入 1 ~ 30 之间的数字,不能小于 1 。值越小,压枪效果越好,值越大,帧数越高。(过分掉帧会直接影响压枪效果,请在保证帧数的情况下减小该值)
-- CPU load level, It is recommended to enter a number between 1 and 30, cannot be less than 1.
-- The lower the value is, the better the effect is, the higher the value, the higher the number of frames.
-- (excessive frame dropping will directly affect the gun pressing effect, please reduce the value while ensuring the frame number)
cpuLoad = 2,
-- 灵敏度调整 | Sensitivity adjustment
sensitivity = {
-- 开镜 | sighting mirror
ADS = 100,
-- 腰射 | take aim
Aim = 0.55,
-- 二倍 | twice scope
scopeX2 = 1.3,
-- 三倍 | trebling scope
scopeX3 = 1.3,
-- 四倍 | quadruple scope
scopeX4 = 3.9,
-- 六倍 | sixfold scope
scopeX6 = 2.3,
},
-- 自动腰射,不使用自动腰射留空,使用则设置为键盘上按键
-- Auto aim, leave blank without auto aim, set as the key on the keyboard when using.
autoPressAimKey = "",
-- 启动控制 (capslock - 使用大写锁定键控制 | numlock - 小键盘锁定键控制 | G_bind - 使用指令控制) | Start up control
startControl = "capslock",
-- 瞄准设置 (default - 使用游戏默认设置 | recommend - 使用脚本推荐设置 | custom - 自定义设置 | ctrlmode - 下蹲模式) | Aiming setting
aimingSettings = "recommend",
-- 当 aimingSettings = "custom" ,需要在此处设置自定义判断条件,通常配合 IsMouseButtonPressed 或 IsModifierPressed 使用,使用方法请查阅 G-series Lua API 参考文档.docx
customAimingSettings = {
-- 开镜判断
ADS = function ()
return false -- 判断条件,返回值为布尔型
end,
-- 腰射判断
Aim = function ()
return false -- 判断条件,返回值为布尔型
end,
},
-- 支持的枪械,排列顺序即是配置顺序,可以自行调整。
-- 模式:0 - 不启用 | 1 - 启用 | 2 - 开启连点
-- 系数:枪械自身系数,基于 ADS 进行调整 (ADS为全局系数,此处为自身系数)
-- 下蹲系数:下蹲时的系数,基于 ADS 和 自身系数
canUse = {
[".45"] = {
-- 枪械 模式 系数 下蹲系数
{ "UMP45", 1, 1, 0.8 }, -- 基础镜 + 扩容,Bizon (基础镜即可),Vector (补偿 + 基础镜 + 扩容) | Reddot + Mag,Bizon (Reddot),Vector (Komp + Reddot + Mag)
{ "Tommy Gun", 1, 1, 0.8 }, -- 扩容 | Mag
},
-- 枪械 模式 系数 下蹲系数
["9mm"] = {
{ "Vector", 1, 1, 0.8 }, -- 基础镜 + 扩容 | Reddot + Mag
{ "Micro UZI", 1, 1, 0.8 }, -- 扩容 | Mag
},
["5.56"] = {
-- 枪械 模式 系数 下蹲系数
{ "M416", 1, 1, 0.8 }, -- 补偿 + 基础镜 + 直角 + 枪托 + 扩容 | Komp + Reddot + Triangular grip + Gunstock + Mag
{ "SCAR-L", 1, 1, 0.8 }, -- 补偿 + 基础镜 + 直角 + 扩容 | Komp + Reddot + Triangular grip + Mag
{ "QBZ", 1, 1, 0.8 }, -- 补偿 + 基础镜 + 直角 + 扩容 | Komp + Reddot + Triangular grip + Mag
{ "G36C", 1, 1, 0.8 }, -- 补偿 + 基础镜 + 直角 + 扩容 | Komp + Reddot + Triangular grip + Mag
{ "M16A4", 2, 1, 0.8 }, -- 补偿 + 基础镜 + 枪托 + 扩容 | Komp + Reddot + Gunstock + Mag
},
["7.62"] = {
-- 枪械 模式 系数 下蹲系数
{ "AKM", 1, 1, 0.8 }, -- 补偿 + 基础镜 + 扩容 | Komp + Reddot + Mag
{ "Beryl M762", 1, 1, 0.8 }, -- 补偿 + 基础镜 + 直角 + 扩容 | Komp + Reddot + Triangular grip + Mag
{ "DP-28", 0, 1, 0.8 }, -- 基础镜 | Reddot
},
},
-- G键自定义绑定,多余的组合键可以删除
-- 可绑定指令请参考: https://github.com/kiccer/Soldier76#%E6%8C%87%E4%BB%A4%E5%88%97%E8%A1%A8
-- 指令绑定演示参考: https://github.com/kiccer/Soldier76#g_bind-%E6%8C%87%E4%BB%A4%E7%BB%91%E5%AE%9A%E6%BC%94%E7%A4%BA
G_bind = {
-- G
["G3"] = "",
["G4"] = "",
["G5"] = "",
["G6"] = "5.56",
["G7"] = "9mm",
["G8"] = "7.62",
["G9"] = ".45",
["G10"] = "last",
["G11"] = "next",
-- lalt + G
["lalt + G3"] = "",
["lalt + G4"] = "",
["lalt + G5"] = "",
["lalt + G6"] = "",
["lalt + G7"] = "",
["lalt + G8"] = "",
["lalt + G9"] = "",
["lalt + G10"] = "",
["lalt + G11"] = "",
-- lctrl + G
["lctrl + G3"] = "",
["lctrl + G4"] = "",
["lctrl + G5"] = "",
["lctrl + G6"] = "",
["lctrl + G7"] = "",
["lctrl + G8"] = "",
["lctrl + G9"] = "",
["lctrl + G10"] = "",
["lctrl + G11"] = "",
-- lshift + G
["lshift + G3"] = "",
["lshift + G4"] = "",
["lshift + G5"] = "",
["lshift + G6"] = "fast_pickup",
["lshift + G7"] = "",
["lshift + G8"] = "",
["lshift + G9"] = "",
["lshift + G10"] = "",
["lshift + G11"] = "fast_lick_box",
-- ralt + G
["ralt + G3"] = "",
["ralt + G4"] = "",
["ralt + G5"] = "",
["ralt + G6"] = "",
["ralt + G7"] = "",
["ralt + G8"] = "",
["ralt + G9"] = "",
["ralt + G10"] = "",
["ralt + G11"] = "",
-- rctrl + G
["rctrl + G3"] = "",
["rctrl + G4"] = "",
["rctrl + G5"] = "",
["rctrl + G6"] = "",
["rctrl + G7"] = "",
["rctrl + G8"] = "",
["rctrl + G9"] = "",
["rctrl + G10"] = "",
["rctrl + G11"] = "",
-- rshift + G
["rshift + G3"] = "",
["rshift + G4"] = "",
["rshift + G5"] = "",
["rshift + G6"] = "fast_discard",
["rshift + G7"] = "",
["rshift + G8"] = "",
["rshift + G9"] = "",
["rshift + G10"] = "",
["rshift + G11"] = "",
-- 非鼠标G键,可以使键盘或者耳机上的G键,默认使用键盘G键,请确保你使用的是可编程的罗技键盘 | F1~12 (Non-mouse G-key)
["F1"] = "",
["F2"] = "",
["F3"] = "",
["F4"] = "",
["F5"] = "",
["F6"] = "",
["F7"] = "",
["F8"] = "",
["F9"] = "",
["F10"] = "",
["F11"] = "",
["F12"] = "",
},
}
----------------------------- [[ 以下是脚本核心代码,非专业人士请勿改动 ]] -----------------------------
----------------------------- [[ 以下是脚本核心代码,非专业人士请勿改动 ]] -----------------------------
----------------------------- [[ 以下是脚本核心代码,非专业人士请勿改动 ]] -----------------------------
-- internal configuration
pubg = {
gun = {
[".45"] = {},
["9mm"] = {},
["5.56"] = {},
["7.62"] = {},
}, -- 枪械库
gunOptions = {
[".45"] = {},
["9mm"] = {},
["5.56"] = {},
["7.62"] = {},
}, -- 配置库
allCanUse = {}, -- 所有可用枪械
allCanUse_index = 1, -- 所有可用枪械列表索引
allCanUse_count = 0, -- 所有可用总数量
bulletType = "", -- 默认子弹型号
gunIndex = 1, -- 选中枪械下标
counter = 0, -- 计数器
xCounter = 0, -- x计数器
sleep = userInfo.cpuLoad, -- 频率设置 (这里不能设置成0,调试会出BUG)
sleepRandom = { userInfo.cpuLoad, userInfo.cpuLoad + 5 }, -- 防检测随机延迟
startTime = 0, -- 鼠标按下时记录脚本运行时间戳
prevTime = 0, -- 记录上一轮脚本运行时间戳
scopeX1 = 1, -- 基瞄压枪倍率 (裸镜、红点、全息、侧瞄)
scopeX2 = userInfo.sensitivity.scopeX2, -- 二倍压枪倍率
scopeX3 = userInfo.sensitivity.scopeX3, -- 三倍压枪倍率
scopeX4 = userInfo.sensitivity.scopeX4, -- 四倍压枪倍率
scopeX6 = userInfo.sensitivity.scopeX6, -- 六倍压枪倍率
scope_current = "scopeX1", -- 当前使用倍镜
generalSensitivityRatio = userInfo.sensitivity.ADS / 100, -- 按比例调整灵敏度
isStart = false, -- 是否是启动状态
G1 = false, -- G1键状态
currentTime = 0, -- 此刻
bulletIndex = 0, -- 第几颗子弹
}
pubg.xLengthForDebug = pubg.generalSensitivityRatio * 30 -- 调试模式下的水平移动单元长度
-- 渲染节点
pubg.renderDom = {
switchTable = "",
separator = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n", -- 分割线
combo_key = "G-key", -- 组合键
cmd = "cmd", -- 指令
autoLog = "No operational data yet.\n", -- 压枪过程产生的数据输出
}
-- 是否开镜或瞄准
function pubg.isAimingState (mode)
local switch = {
-- 开镜
["ADS"] = function ()
if userInfo.aimingSettings == "recommend" then
return IsMouseButtonPressed(3) and not IsModifierPressed("lshift")
elseif userInfo.aimingSettings == "default" then
return not IsModifierPressed("lshift") and not IsModifierPressed("lalt")
elseif userInfo.aimingSettings == "ctrlmode" then
return IsMouseButtonPressed(3) and not IsModifierPressed("lshift")
elseif userInfo.aimingSettings == "custom" then
return userInfo.customAimingSettings.ADS()
end
end,
-- 腰射
["Aim"] = function ()
if userInfo.aimingSettings == "recommend" then
if userInfo.autoPressAimKey == "" then
return IsModifierPressed("lctrl")
else
return not IsModifierPressed("lshift") and not IsModifierPressed("lalt")
end
elseif userInfo.aimingSettings == "default" then
return IsMouseButtonPressed(3)
elseif userInfo.aimingSettings == "ctrlmode" then
return false
elseif userInfo.aimingSettings == "custom" then
return userInfo.customAimingSettings.Aim()
end
end,
}
return switch[mode]()
end
pubg["M16A4"] = function (gunName)
return pubg.execOptions(gunName, {
interval = 108,
ballistic = {
{1, 0},
{5, 20},
{40, 24},
}
})
end
pubg["SCAR-L"] = function (gunName)
return pubg.execOptions(gunName, {
interval = 96,
ballistic = {
{1, 0},
{2, 30},
{5, 20},
{10, 24},
{15, 28},
{40, 32},
}
})
end
pubg["Beryl M762"] = function (gunName)
return pubg.execOptions(gunName, {
interval = 86,
ballistic = {
{1, 0},
{2, 44},
{3, 24},
{5, 28},
{10, 33},
{15, 45},
{30, 47},
{40, 51},
}
})
end
pubg["Tommy Gun"] = function (gunName)
return pubg.execOptions(gunName, {
interval = 84,
ballistic = {
{1, 0},
{3, 20},
{6, 21},
{8, 24},
{10, 30},
{15, 40},
{50, 45},
}
})
end
pubg["G36C"] = function (gunName)
return pubg.execOptions(gunName, {
interval = 86,
ballistic = {
{1, 0},
{2, 40},
{5, 16},
{10, 26},
{15, 30},
{20, 34},
{40, 36},
}
})
end
pubg["Vector"] = function (gunName)
return pubg.execOptions(gunName, {
interval = 55,
ballistic = {
{1, 0},
{6, 16},
{10, 20},
{13, 24},
{15, 28},
{20, 32},
{33, 34},
}
})
end
pubg["Micro UZI"] = function (gunName)
return pubg.execOptions(gunName, {
interval = 46,
ballistic = {
{1, 0},
{2, 13},
{10, 12},
{15, 20},
{35, 30},
}
})
end
pubg["UMP45"] = function (gunName)
return pubg.execOptions(gunName, {
interval = 94,
ballistic = {
{1, 0},
{5, 18},
{15, 30},
{35, 32},
}
})
end
pubg["AKM"] = function (gunName)
return pubg.execOptions(gunName, {
interval = 99,
ballistic = {
{1, 0},
{2, 42},
{5, 25},
{10, 32},
{40, 40},
}
})
end
pubg["M416"] = function (gunName)
return pubg.execOptions(gunName, {
interval = 85,
ballistic = {
{1, 0},
{2, 35},
{4, 18},
{10, 24},
{15, 32},
{30, 30},
{40, 37},
}
})
end
pubg["QBZ"] = function (gunName)
return pubg.execOptions(gunName, {
interval = 92,
ballistic = {
{1, 0},
{2, 34},
{5, 18},
{10, 22},
{15, 32},
{20, 34},
{40, 36},
}
})
end
pubg["DP-28"] = function (gunName)
return pubg.execOptions(gunName, {
interval = 100,
ballistic = {
{1, 0},
{2, 30},
{5, 20},
{47, 30},
}
})
end
-- [[通过枪械名查找在 canuse 中的项]]
function pubg.canUseFindByGunName (gunName)
local forList = { ".45", "9mm", "5.56", "7.62" }
for i = 1, #forList do
local bulletType = forList[i]
for j = 1, #userInfo.canUse[bulletType] do
local item = userInfo.canUse[bulletType][j]
if item[1] == gunName then
return item
end
end
end
end
--[[ FormatFactory ]]
function pubg.execOptions (gunName, options)
--[[
from
{
{ 5, 10 },
{ 10, 24 },
}
to
{ 10, 10, 10, 10, 10, 24, 24, 24, 24, 24 }
to
{ 10, 20, 30, 40, 50, 74, 98, 122, 146, 170 }
]]
local gunInfo = pubg.canUseFindByGunName(gunName)
-- Temporary container
local ballisticConfig1 = {}
-- Temporary container (v3.0)
local ballisticConfig2 = {}
local ballisticIndex = 1
for i = 1, #options.ballistic do
local nextCount = options.ballistic[i][1]
if i ~= 1 then
nextCount = options.ballistic[i][1] - options.ballistic[i - 1][1]
end
for j = 1, nextCount do
ballisticConfig1[ballisticIndex] =
-- options.ballistic[i][2] * pubg.generalSensitivityRatio * options.ratio
options.ballistic[i][2] * pubg.generalSensitivityRatio * gunInfo[3]
ballisticIndex = ballisticIndex + 1
end
end
for i = 1, #ballisticConfig1 do
if i == 1 then
ballisticConfig2[i] = ballisticConfig1[i]
else
ballisticConfig2[i] = ballisticConfig2[i - 1] + ballisticConfig1[i]
end
end
-- 取整
-- for i = 1, #ballisticConfig2 do
-- ballisticConfig2[i] = math.ceil(ballisticConfig2[i])
-- end
return {
duration = options.interval * #ballisticConfig2, -- Time of duration
amount = #ballisticConfig2, -- Number of bullets
interval = options.interval, -- Time of each bullet
ballistic = ballisticConfig2, -- ballistic data
ctrlmodeRatio = gunInfo[4], -- Individual recoil coefficient for each gun when squatting
}
end
--[[ Initialization of firearms database ]]
function pubg.init ()
-- Clean up the firearms Depot
local forList = { ".45", "9mm", "5.56", "7.62" }
for i = 1, #forList do
local type = forList[i]
local gunCount = 0
for j = 1, #userInfo.canUse[type] do
local gunName = userInfo.canUse[type][j][1]
local gunState = userInfo.canUse[type][j][2]
if gunState >= 1 then
-- one series
gunCount = gunCount + 1 -- Accumulative number of firearms configuration files
pubg.gun[type][gunCount] = gunName -- Adding available firearms to the Arsenal
pubg.gunOptions[type][gunCount] = pubg[gunName](gunName) -- Get firearms data and add it to the configuration library
-- 单独设置连发
pubg.gunOptions[type][gunCount].autoContinuousFiring = ({ 0, 0, 1 })[
math.max(1, math.min(gunState + 1, 3))
]
-- all canUse
pubg.allCanUse_count = pubg.allCanUse_count + 1 -- Total plus one
pubg.allCanUse[pubg.allCanUse_count] = gunName -- All available firearms
if pubg.bulletType == "" then pubg.bulletType = type end -- Default Bullet type
end
end
end
-- Initial setting of random number seeds
pubg.SetRandomseed()
pubg.outputLogRender()
-- console.log(pubg)
end
-- SetRandomseed
function pubg.SetRandomseed ()
math.randomseed((pubg.isEffective and {GetRunningTime()} or {0})[1])
end
--[[ Before automatic press gun ]]
function pubg.auto (options)
-- Accurate aiming press gun
pubg.currentTime = GetRunningTime()
pubg.bulletIndex = math.ceil(((pubg.currentTime - pubg.startTime == 0 and {1} or {pubg.currentTime - pubg.startTime})[1]) / options.interval) + 1
if pubg.bulletIndex > options.amount then return false end
-- Developer Debugging Mode
local d = (IsKeyLockOn("scrolllock") and { (pubg.bulletIndex - 1) * pubg.xLengthForDebug } or { 0 })[1]
local x = math.ceil((pubg.currentTime - pubg.startTime) / (options.interval * (pubg.bulletIndex - 1)) * d) - pubg.xCounter
local y = math.ceil((pubg.currentTime - pubg.startTime) / (options.interval * (pubg.bulletIndex - 1)) * options.ballistic[pubg.bulletIndex]) - pubg.counter
-- 4-fold pressure gun mode
local realY = pubg.getRealY(options, y)
MoveMouseRelative(x, realY)
-- Whether to issue automatically or not
if options.autoContinuousFiring == 1 then
PressAndReleaseMouseButton(1)
end
-- Real-time operation parameters
pubg.autoLog(options, y)
pubg.outputLogRender()
pubg.xCounter = pubg.xCounter + x
pubg.counter = pubg.counter + y
pubg.autoSleep(IsKeyLockOn("scrolllock"))
end
--[[ Sleep of pubg.auto ]]
function pubg.autoSleep (isTest)
local random = 0
if isTest then
-- When debugging mode is turned on, Turn off random delays in preventive testing
random = math.random(pubg.sleep, pubg.sleep)
else
random = math.random(pubg.sleepRandom[1], pubg.sleepRandom[2])
end
-- Sleep(10)
Sleep(random)
end
--[[ get real y position ]]
function pubg.getRealY (options, y)
local realY = y
if pubg.isAimingState("ADS") then
realY = y * pubg[pubg.scope_current]
elseif pubg.isAimingState("Aim") then
realY = y * userInfo.sensitivity.Aim * pubg.generalSensitivityRatio
end
if userInfo.aimingSettings == "ctrlmode" and IsModifierPressed("lctrl") then
realY = realY * options.ctrlmodeRatio
end
return realY
end
--[[ change pubg isStart status ]]
function pubg.changeIsStart (isTrue)
pubg.isStart = isTrue
if isTrue then
SetBacklightColor(0, 255, 150, "kb")
SetBacklightColor(0, 255, 150, "mouse")
else
SetBacklightColor(255, 0, 90, "kb")
SetBacklightColor(255, 0, 90, "mouse")
end
end
--[[ set bullet type ]]
function pubg.setBulletType (bulletType)
pubg.bulletType = bulletType
pubg.gunIndex = 1
pubg.allCanUse_index = 0
local forList = { ".45", "9mm", "5.56", "7.62" }
for i = 1, #forList do
local type = forList[i]
if type == bulletType then
pubg.allCanUse_index = pubg.allCanUse_index + 1
break
else
pubg.allCanUse_index = pubg.allCanUse_index + #pubg.gun[type]
end
end
pubg.changeIsStart(true)
end
--[[ set current scope ]]
function pubg.setScope (scope)
pubg.scope_current = scope
end
--[[ set current gun ]]
function pubg.setGun (gunName)
local forList = { ".45", "9mm", "5.56", "7.62" }
local allCanUse_index = 0
for i = 1, #forList do
local type = forList[i]
local gunIndex = 0
local selected = false
for j = 1, #userInfo.canUse[type] do
if userInfo.canUse[type][j][2] >= 1 then
gunIndex = gunIndex + 1
allCanUse_index = allCanUse_index + 1
if userInfo.canUse[type][j][1] == gunName then
pubg.bulletType = type
pubg.gunIndex = gunIndex
pubg.allCanUse_index = allCanUse_index
selected = true
break
end
end
end
if selected then break end
end
pubg.changeIsStart(true)
end
--[[ Consider all available firearms as an entire list ]]
function pubg.findInCanUse (cmd)
if "first_in_canUse" == cmd then
pubg.allCanUse_index = 1
elseif "next_in_canUse" == cmd then
if pubg.allCanUse_index < #pubg.allCanUse then
pubg.allCanUse_index = pubg.allCanUse_index + 1
end
elseif "last_in_canUse" == cmd then
pubg.allCanUse_index = #pubg.allCanUse
end
pubg.setGun(pubg.allCanUse[pubg.allCanUse_index])
end
--[[ Switching guns in the same series ]]
function pubg.findInSeries (cmd)
if "first" == cmd then
pubg.gunIndex = 1
elseif "next" == cmd then
if pubg.gunIndex < #pubg.gun[pubg.bulletType] then
pubg.gunIndex = pubg.gunIndex + 1
end
elseif "last" == cmd then
pubg.gunIndex = #pubg.gun[pubg.bulletType]
end
pubg.setGun(pubg.gun[pubg.bulletType][pubg.gunIndex])
end
--[[ Script running status ]]
function pubg.runStatus ()
if userInfo.startControl == "capslock" then
return IsKeyLockOn("capslock")
elseif userInfo.startControl == "numlock" then
return IsKeyLockOn("numlock")
elseif userInfo.startControl == "G_bind" then
return pubg.isStart
end
end
--[[ 一键舔包,仅拾取进背包的物品,无法拾取需穿戴的物品 ]]
function pubg.fastLickBox ()
PressAndReleaseKey("lshift")
PressAndReleaseKey("lctrl")
PressAndReleaseKey("lalt")
PressAndReleaseKey("rshift")
PressAndReleaseKey("rctrl")
PressAndReleaseKey("ralt")
PressAndReleaseKey("tab")
Sleep(10 + pubg.sleep)
PressAndReleaseMouseButton(1)
local lastItemCp = {
300 / 2560 * 65535,
1210 / 1440 * 65535
}
local itemHeight = 83 / 1440 * 65535
-- 重复 3 次动作,强化拾取成功率
for i = 1, 3 do
for j = 1, 13 do
MoveMouseTo(lastItemCp[1], lastItemCp[2] - itemHeight * (j - 1))
PressMouseButton(1)
MoveMouseTo(670 / 2560 * 65535, 710 / 1440 * 65535) -- 修改为背包的坐标
ReleaseMouseButton(1)
end
end
Sleep(10 + pubg.sleep)
MoveMouseTo(lastItemCp[1], lastItemCp[2])
PressAndReleaseKey("tab")
end
--[[ 一键拾取功能,支持所有分辨率 ]]
function pubg.fastPickup ()
PressAndReleaseKey("lshift")
PressAndReleaseKey("lctrl")
PressAndReleaseKey("lalt")
PressAndReleaseKey("rshift")
PressAndReleaseKey("rctrl")
PressAndReleaseKey("ralt")
PressAndReleaseKey("tab")
Sleep(10 + pubg.sleep)
PressAndReleaseMouseButton(1)
local lastItemCp = {
300 / 2560 * 65535,
1210 / 1440 * 65535
}
local itemHeight = 83 / 1440 * 65535
-- 重复 3 次动作,强化拾取成功率
for i = 1, 3 do
for j = 1, 13 do
MoveMouseTo(lastItemCp[1], lastItemCp[2] - itemHeight * (j - 1))
PressMouseButton(1)
MoveMouseTo(32767, 32767)
ReleaseMouseButton(1)
end
end
Sleep(10 + pubg.sleep)
MoveMouseTo(lastItemCp[1], lastItemCp[2])
PressAndReleaseKey("tab")
end
--[[ 背包清空之术,就算战死,也要让敌人舔个空盒! ]]
function pubg.fastDiscard ()
PressAndReleaseKey("lshift")
PressAndReleaseKey("lctrl")
PressAndReleaseKey("lalt")
PressAndReleaseKey("rshift")
PressAndReleaseKey("rctrl")
PressAndReleaseKey("ralt")
PressAndReleaseKey("tab")
Sleep(10 + pubg.sleep)
PressAndReleaseMouseButton(1)
local lastItemCp = {
630 / 2560 * 65535,
1210 / 1440 * 65535
}
local itemHeight = 83 / 1440 * 65535
-- 清空背包 第一轮
Sleep(10 + pubg.sleep)
for i = 1, 5 do
for j = 1, 13 do
MoveMouseTo(lastItemCp[1], lastItemCp[2] - itemHeight * (j - 1))
PressMouseButton(1)
MoveMouseTo(0, 0)
ReleaseMouseButton(1)
end
end
-- 清空武器
Sleep(10 + pubg.sleep)
local itemPos = {
{ 1770, 180 },
{ 1770, 480 },
{ 1770, 780 },
{ 1770, 1050 },
{ 2120, 1050 }
}
for i = 1, #itemPos do
MoveMouseTo(itemPos[i][1] / 2560 * 65535, itemPos[i][2] / 1440 * 65535)
PressAndReleaseMouseButton(3)
end
-- 清空背包 第二轮
Sleep(10 + pubg.sleep)
for i = 1, 5 do
for j = 1, 13 do
MoveMouseTo(lastItemCp[1], lastItemCp[2] - itemHeight * (j - 1))
PressMouseButton(1)
MoveMouseTo(0, 0)
ReleaseMouseButton(1)
end
end
-- 清空装备
Sleep(10 + pubg.sleep)
local itemPos2 = {
{ 900, 392 },
{ 900, 630 },
{ 900, 720 },
{ 900, 808 },
{ 1605, 397 },
{ 1605, 481 },
{ 1605, 632 },
{ 1605, 719 },
{ 1605, 807 },
{ 1605, 1049 },
{ 1605, 1229 }
}
for i = 1, #itemPos2 do
MoveMouseTo(itemPos2[i][1] / 2560 * 65535, itemPos2[i][2] / 1440 * 65535)
-- Sleep(300 + pubg.sleep)
PressAndReleaseMouseButton(3)
end
Sleep(10 + pubg.sleep)
MoveMouseTo(lastItemCp[1], lastItemCp[2])
PressAndReleaseKey("tab")
end
--[[ G key command binding ]]
function pubg.runCmd (cmd)
if cmd == "" then cmd = "none" end
local switch = {
["none"] = function () end,
[".45"] = pubg.setBulletType,
["9mm"] = pubg.setBulletType,
["5.56"] = pubg.setBulletType,
["7.62"] = pubg.setBulletType,
["scopeX1"] = pubg.setScope,
["scopeX2"] = pubg.setScope,
["scopeX3"] = pubg.setScope,
["scopeX4"] = pubg.setScope,
["scopeX6"] = pubg.setScope,
["UMP45"] = pubg.setGun,
["Tommy Gun"] = pubg.setGun,
["Vector"] = pubg.setGun,
["Micro UZI"] = pubg.setGun,
["M416"] = pubg.setGun,
["SCAR-L"] = pubg.setGun,
["QBZ"] = pubg.setGun,
["G36C"] = pubg.setGun,
["M16A4"] = pubg.setGun,
["AKM"] = pubg.setGun,
["Beryl M762"] = pubg.setGun,
["DP-28"] = pubg.setGun,
["first"] = pubg.findInSeries,
["next"] = pubg.findInSeries,
["last"] = pubg.findInSeries,
["first_in_canUse"] = pubg.findInCanUse,
["next_in_canUse"] = pubg.findInCanUse,
["last_in_canUse"] = pubg.findInCanUse,
["fast_pickup"] = pubg.fastPickup,
["fast_discard"] = pubg.fastDiscard,
["fast_lick_box"] = pubg.fastLickBox,
["off"] = function ()
pubg.changeIsStart(false)
end,
}
local cmdGroup = string.split(cmd, '|')
for i = 1, #cmdGroup do
local _cmd = cmdGroup[i]
if switch[_cmd] then
switch[_cmd](_cmd)
end
end
end
--[[ autputLog render ]]
function pubg.outputLogRender ()
if userInfo.debug == 0 then return false end
if not pubg.G1 then
pubg.renderDom.switchTable = pubg.outputLogGunSwitchTable()
end
local resStr = table.concat({
"\n>> [\"", pubg.renderDom.combo_key, "\"] = \"", pubg.renderDom.cmd, "\" <<\n",
pubg.renderDom.separator,
pubg.renderDom.switchTable,
pubg.renderDom.separator,
pubg.outputLogGunInfo(),
pubg.renderDom.separator,
pubg.renderDom.autoLog,
pubg.renderDom.separator,
})
ClearLog()
OutputLogMessage(resStr)
end
--[[ Output switching table ]]
function pubg.outputLogGunSwitchTable ()
local forList = { ".45", "9mm", "5.56", "7.62" }