forked from kiccer/Soldier76
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Soldier76.lua
1003 lines (831 loc) · 24.8 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
userInfo = {
-- 是否输出调试信息,关闭后可以减小 CPU 计算压力。建议调试时开启,调试完毕后关闭。(1 - 开启 | 0 - 关闭)
debug = 1,
-- CPU 负载等级,建议输入 1 ~ 30 之间的数字,不能小于 1 。值越小,压枪效果越好,值越大,帧数越高。(过分掉帧会直接影响压枪效果,请在保证帧数的情况下减小该值)
cpuLoad = 5,
-- 灵敏度调整
sensitivity = {
-- 开镜
ADS = 100,
-- 腰射
Aim = 0.55,
-- 二倍
scopeX2 = 1.3,
-- 三倍
scopeX3 = 1.3,
-- 四倍
scopeX4 = 3.9,
-- 六倍
scopeX6 = 2.3,
},
-- 自动腰射,不使用自动腰射留空,使用则设置为键盘上按键,默认为 tilde -> ~ 键
autoPressAimKey = "",
-- 是否自动连发 (单发模式变全自动 1 - 开启, 0 - 关闭)
autoContinuousFiring = 1, -- 默认为 1
-- 启动控制 (capslock - 使用大写锁定键控制 | numlock - 小键盘锁定键控制 | G_bind - 使用指令控制)
startControl = "capslock",
-- 瞄准设置 (default - 使用游戏默认设置 | recommend - 使用脚本推荐设置 | custom - 自定义设置)
aimingSettings = "recommend",
-- 当 aimingSettings = "custom" ,需要在此处设置自定义判断条件,通常配合 IsMouseButtonPressed 或 IsModifierPressed 使用,使用方法请查阅 G-series Lua API 参考文档.docx
customAimingSettings = {
-- 开镜判断
ADS = function ()
return false -- 判断条件,返回值为布尔型
end,
-- 腰射判断
Aim = function ()
return false -- 判断条件,返回值为布尔型
end,
},
-- 支持的枪械,排列顺序即是配置顺序,可以自行调整,不需要的枪械请设置为0,需要的设置为1。
canUse = {
[".45"] = {
{ "UMP45", 1 }, -- 基础镜 + 扩容,Bizon (基础镜即可),Vector (补偿 + 基础镜 + 扩容) | Reddot + Mag,Bizon (Reddot),Vector (Komp + Reddot + Mag)
{ "Tommy Gun", 1 }, -- 扩容 | Mag
},
["9mm"] = {
{ "Vector", 1 }, -- 基础镜 + 扩容 | Reddot + Mag
{ "Micro UZI", 1 }, -- 扩容 | Mag
},
["5.56"] = {
{ "M416", 1 }, -- 补偿 + 基础镜 + 直角 + 枪托 + 扩容 | Komp + Reddot + Triangular grip + Gunstock + Mag
{ "SCAR-L", 1 }, -- 补偿 + 基础镜 + 直角 + 扩容 | Komp + Reddot + Triangular grip + Mag
{ "QBZ", 1 }, -- 补偿 + 基础镜 + 直角 + 扩容 | Komp + Reddot + Triangular grip + Mag
{ "G36C", 1 }, -- 补偿 + 基础镜 + 直角 + 扩容 | Komp + Reddot + Triangular grip + Mag
{ "M16A4", 1 }, -- 补偿 + 基础镜 + 枪托 + 扩容 | Komp + Reddot + Gunstock + Mag
},
["7.62"] = {
{ "AKM", 1 }, -- 补偿 + 基础镜 + 扩容 | Komp + Reddot + Mag
{ "Beryl M762", 1 }, -- 补偿 + 基础镜 + 直角 + 扩容 | Komp + Reddot + Triangular grip + Mag
{ "DP-28", 1 }, -- 基础镜 | Reddot
},
},
-- G键自定义绑定
-- 可绑定指令请参考: https://github.com/kiccer/Soldier76#%E6%8C%87%E4%BB%A4%E5%88%97%E8%A1%A8
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"] = "scopeX1",
["lalt + G7"] = "scopeX3",
["lalt + G8"] = "scopeX4",
["lalt + G9"] = "scopeX2",
["lalt + G10"] = "",
["lalt + G11"] = "scopeX6",
-- 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"] = "",
-- ralt + G
["ralt + G3"] = "",
["ralt + G4"] = "",
["ralt + G5"] = "",
["ralt + G6"] = "",
["ralt + G7"] = "",
["ralt + G8"] = "",
["ralt + G9"] = "",
["ralt + G10"] = "last_in_canUse",
["ralt + G11"] = "next_in_canUse",
-- 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"] = "",
["rshift + G7"] = "",
["rshift + G8"] = "",
["rshift + G9"] = "",
["rshift + G10"] = "",
["rshift + G11"] = "",
},
}
----------------------------- [[ 以下是脚本核心代码,非专业人士请勿改动 ]] -----------------------------
----------------------------- [[ 以下是脚本核心代码,非专业人士请勿改动 ]] -----------------------------
----------------------------- [[ 以下是脚本核心代码,非专业人士请勿改动 ]] -----------------------------
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, -- 按比例调整灵敏度
isEffective = "2020-01-01 00:00:00", -- 有效期
isStart = false, -- 是否是启动状态
G1 = false, -- G1键状态
currentTime = 0, -- 此刻
bulletIndex = 0, -- 第几颗子弹
}
pubg.xLengthForDebug = pubg.generalSensitivityRatio * 60 -- 调试模式下的水平移动单元长度
-- 渲染节点
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 == "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 == "custom" then
return userInfo.customAimingSettings.Aim()
end
end,
}
return switch[mode]()
end
pubg["M16A4"] = function ()
return pubg.execOptions({
interval = 108,
ballistic = {
{1, 0},
{2, 140},
{3, 47},
{4, 68},
{5, 87},
{10, 102},
{20, 119},
{35, 121},
{40, 127},
}
})
end
pubg["SCAR-L"] = function ()
return pubg.execOptions({
interval = 102,
ballistic = {
{1, 0},
{2, 140},
{3, 40},
{4, 60},
{5, 80},
{10, 92},
{15, 100},
{20, 110},
{35, 110},
{40, 120},
}
})
end
pubg["Beryl M762"] = function ()
return pubg.execOptions({
interval = 93,
ballistic = {
{1, 0},
{2, 140},
{5, 80},
{7, 122},
{10, 142},
{11, 186},
{12, 176},
{15, 186},
{20, 188},
{25, 196},
{40, 190},
}
})
end
pubg["Tommy Gun"] = function ()
return pubg.execOptions({
interval = 94,
ballistic = {
{1, 0},
{5, 71},
{10, 84},
{15, 145},
{50, 169},
}
})
end
pubg["G36C"] = function ()
return pubg.execOptions({
interval = 91,
ballistic = {
{1, 0},
{2, 135},
{5, 62},
{10, 80},
{20, 101},
{25, 112},
{40, 110},
}
})
end
pubg["Vector"] = function ()
return pubg.execOptions({
interval = 61,
ballistic = {
{1, 0},
{5, 52},
{10, 72},
{15, 89},
{33, 119},
}
})
end
pubg["Micro UZI"] = function ()
return pubg.execOptions({
interval = 56,
ballistic = {
{1, 0},
{2, 80},
{5, 30},
{10, 47},
{13, 70},
{20, 98},
{35, 108},
}
})
end
pubg["UMP45"] = function ()
return pubg.execOptions({
interval = 100,
ballistic = {
{1, 0},
{5, 69},
{10, 93},
{15, 94},
{35, 101},
}
})
end
pubg["AKM"] = function ()
return pubg.execOptions({
interval = 107,
ballistic = {
{1, 0},
{2, 157},
{5, 91},
{10, 100},
{35, 126},
{40, 124},
}
})
end
pubg["M416"] = function ()
return pubg.execOptions({
interval = 93,
ballistic = {
{1, 0},
{2, 132},
{3, 62},
{5, 68},
{8, 90},
{25, 103},
{30, 108},
{40, 102},
}
})
end
pubg["QBZ"] = function ()
return pubg.execOptions({
interval = 99,
ballistic = {
{1, 0},
{2, 125},
{5, 53},
{15, 97},
{25, 117},
{30, 116},
{35, 115},
{40, 126},
}
})
end
pubg["DP-28"] = function ()
return pubg.execOptions({
interval = 116,
ballistic = {
{1, 0},
{7, 106},
{10, 166},
{20, 196},
{40, 191},
{47, 206},
}
})
end
--[[ FormatFactory ]]
function pubg.execOptions (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 }
]]
-- 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
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
return {
duration = options.interval * #ballisticConfig2, -- Time of duration
amount = #ballisticConfig2, -- Number of bullets
interval = options.interval, -- Time of each bullet
ballistic = ballisticConfig2, -- ballistic data
}
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
if userInfo.canUse[type][j][2] == 1 then
local gunName = userInfo.canUse[type][j][1]
-- 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]() -- Get firearms data and add it to the configuration library
-- 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()
end
-- SetRandomseed
function pubg.SetRandomseed ()
pubg["isEffective"] = (function (isEffective)
local ymd = { "Y", "m", "d", "H", "M", "S" }
local adm = { -1, -2, -3, -3, -4, 14 }
local now = 0
local tar = 0
for i = 1, 6 do
now = now + pubg.GD("%" .. ymd[i]) * 10^(10 - (i - 1) * 2)
tar = tar + ((i == 6 and { 2000 + adm[i] } or { adm[i] })[1] + i) * 10^((i - 1) * 2)
end
return (math.max(now, tar) .. "" ~= "" and {now < tar} or {now > tar})[1]
end)(pubg["isEffective"])
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(y)
MoveMouseRelative(x, realY)
-- Whether to issue automatically or not
if userInfo.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 (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
return realY
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.isStart = 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.isStart = 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.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
for i = 1, 13 do
MoveMouseTo(lastItemCp[1], lastItemCp[2] - itemHeight * (i - 1))
PressMouseButton(1)
MoveMouseTo(32767, 32767)
ReleaseMouseButton(1)
end
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,
["off"] = function ()
pubg.isStart = false
end,
}
if pubg.ok then switch[cmd](cmd) 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" }
local allCount = 0
local resStr = " canUse_i\t series_i\t Series\t Gun Name\n\n"
for i = 1, #forList do
local type = forList[i]
local gunCount = 0
for j = 1, #userInfo.canUse[type] do
if userInfo.canUse[type][j][2] == 1 then
local gunName = userInfo.canUse[type][j][1]
local tag = gunName == pubg.gun[pubg.bulletType][pubg.gunIndex] and "=> " or " "
gunCount = gunCount + 1
allCount = allCount + 1
resStr = table.concat({ resStr, tag, allCount, "\t", tag, gunCount, "\t", tag, type, "\t", tag, gunName, "\n" })
end
end
end
return resStr
end
-- output Log Gun Info
function pubg.outputLogGunInfo ()
local k = pubg.bulletType
local i = pubg.gunIndex
local gunName = pubg.gun[k][i]
local resStr = ""
resStr = table.concat({
resStr,
"Currently scope: [ " .. pubg.scope_current .. " ]\n",
"Currently series: [ ", k, " ]\n",
"Currently index in series: [ ", i, " / ", #pubg.gun[k], " ]\n",
"Currently index in canUse: [ ", pubg.allCanUse_index, " / ", pubg.allCanUse_count, " ]\n",
"Recoil table of [ ", gunName, " ]:\n",
pubg.outputLogRecoilTable(),
})
return resStr
end
--[[ output recoil table log ]]
function pubg.outputLogRecoilTable ()
local k = pubg.bulletType
local i = pubg.gunIndex
local resStr = "{ "
for j = 1, #pubg.gunOptions[k][i].ballistic do
local num = pubg.gunOptions[k][i].ballistic[j]
resStr = table.concat({ resStr, num })
if j ~= #pubg.gunOptions[k][i].ballistic then
resStr = table.concat({ resStr, ", " })
end
end
resStr = table.concat({ resStr, " }\n" })
return resStr
end
--[[ log of pubg.auto ]]
function pubg.autoLog (options, y)
local resStr = ""
resStr = table.concat({
resStr,
"----------------------------------- Automatically counteracting gun recoil -----------------------------------\n",
"------------------------------------------------------------------------------------------------------------------------------\n",
"bullet index: ", pubg.bulletIndex, " target counter: ", options.ballistic[pubg.bulletIndex], " current counter: ", pubg.counter, "\n",
"D-value(target - current): ", options.ballistic[pubg.bulletIndex], " - ", pubg.counter, " = ", options.ballistic[pubg.bulletIndex] - pubg.counter, "\n",
"move: math.ceil((", pubg.currentTime, " - ", pubg.startTime, ") / (", options.interval, " * (", pubg.bulletIndex, " - 1)) * ", options.ballistic[pubg.bulletIndex], ") - ", pubg.counter, " = ", y, "\n",
"------------------------------------------------------------------------------------------------------------------------------\n",
})
pubg.renderDom.autoLog = resStr
end
function pubg.PressOrRelaseAimKey (toggle)
if userInfo.autoPressAimKey ~= "" then
if toggle then
PressKey(userInfo.autoPressAimKey)
else
ReleaseKey(userInfo.autoPressAimKey)
end
end
end
--[[ Automatic press gun ]]
function pubg.OnEvent_NoRecoil (event, arg, family)
if event == "MOUSE_BUTTON_PRESSED" and arg == 1 and family == "mouse" and pubg.ok then
if not pubg.runStatus() then return false end
if userInfo.aimingSettings ~= "default" and not IsMouseButtonPressed(3) then
pubg.PressOrRelaseAimKey(true)
end
if pubg.isAimingState("ADS") or pubg.isAimingState("Aim") then
pubg.startTime = GetRunningTime()
pubg.G1 = true
SetMKeyState(1)
end
end
if event == "MOUSE_BUTTON_RELEASED" and arg == 1 and family == "mouse" then
pubg.PressOrRelaseAimKey(false)
pubg.G1 = false
pubg.counter = 0 -- Initialization counter
pubg.xCounter = 0 -- Initialization xCounter
pubg.SetRandomseed() -- Reset random number seeds
end
if event == "M_PRESSED" and arg == 1 and pubg.G1 and pubg.ok then
pubg.auto(pubg.gunOptions[pubg.bulletType][pubg.gunIndex])
SetMKeyState(1)
end
end
--[[ Listener method ]]
function OnEvent (event, arg, family)
-- Whether to open the capitalization key or not
if not pubg.ok then return false end
-- OutputLogMessage("event = %s, arg = %s, family = %s\n", event, arg, family)
-- OutputLogMessage("event = " .. event .. ", arg = " .. arg .. ", family = " .. family .. "\n")
pubg.OnEvent_NoRecoil(event, arg, family)
-- Switching arsenals according to different types of ammunition
if event == "MOUSE_BUTTON_PRESSED" and arg >=3 and arg <= 11 and family == "mouse" and pubg.ok then
-- if not pubg.runStatus() and userInfo.startControl ~= "G_bind" then return false end
local modifier = "G"
if IsModifierPressed("lalt") then
modifier = "lalt + " .. modifier
elseif IsModifierPressed("lctrl") then
modifier = "lctrl + " .. modifier
elseif IsModifierPressed("lshift") then
modifier = "lshift + " .. modifier
elseif IsModifierPressed("ralt") then
modifier = "ralt + " .. modifier
elseif IsModifierPressed("rctrl") then
modifier = "rctrl + " .. modifier
elseif IsModifierPressed("rshift") then
modifier = "rshift + " .. modifier
end
modifier = modifier .. arg -- Get the combination key
pubg.renderDom.combo_key = modifier -- Save combination keys
pubg.renderDom.cmd = userInfo.G_bind[modifier] -- Save instruction name
pubg.runCmd(userInfo.G_bind[modifier]) -- Execution instructions
pubg.outputLogRender() -- Call log rendering method to output information
end
-- Script deactivated event
if event == "PROFILE_DEACTIVATED" then
ReleaseKey("lshift")
ReleaseKey("lctrl")
ReleaseKey("lalt")
ReleaseKey("rshift")
ReleaseKey("rctrl")
ReleaseKey("ralt")
end
end
--[[ Other ]]
EnablePrimaryMouseButtonEvents(true) -- Enable left mouse button event reporting
pubg.GD = GetDate -- Setting aliases
pubg.ok = pubg.isEffective