Skip to content

Commit 1322e3a

Browse files
authored
Merge pull request #67 from kiccer/test
Test
2 parents 56b4e54 + 08e9a64 commit 1322e3a

File tree

2 files changed

+97
-63
lines changed

2 files changed

+97
-63
lines changed

README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103

104104
### 其他设置(非必要)
105105
* 所有枪械单独设置系数 `ratio`
106-
* 所有枪械单独设置连发 `autoContinuousFiring`
107106
* [扩展开发教程:增加一把新的枪械/修改一把枪械的数据](https://github.com/kiccer/Soldier76/issues/24)
108107
* [扩展开发教程:设置自定义瞄准判断条件](https://github.com/kiccer/Soldier76/issues/52)
109108

@@ -127,11 +126,13 @@ G键 | 功能
127126
`G9` | 切换至 **.45** 枪械配置文件表,并使用**第一个**配置
128127
`G10` | 切换至**最后一个**配置 (滚轮右偏)
129128
`G11` | 切换至**下一个**配置 (滚轮左偏)
130-
`lalt` + `G6` | 切换至基瞄压枪模式
131-
`lalt` + `G7` | 切换至三倍镜压枪模式
132-
`lalt` + `G8` | 切换至四倍镜压枪模式
133-
`lalt` + `G9` | 切换至二倍镜压枪模式
134-
`lalt` + `G11` | 切换至六倍镜压枪模式
129+
130+
[//]: # (以下内容已注释)
131+
[//]: # (`lalt` + `G6` | 切换至基瞄压枪模式)
132+
[//]: # (`lalt` + `G7` | 切换至三倍镜压枪模式)
133+
[//]: # (`lalt` + `G8` | 切换至四倍镜压枪模式)
134+
[//]: # (`lalt` + `G9` | 切换至二倍镜压枪模式)
135+
[//]: # (`lalt` + `G11` | 切换至六倍镜压枪模式)
135136

136137
> 以上设置均可在 `G_bind` 中自定义修改键位
137138

Soldier76.lua

+90-57
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ userInfo = {
3131
autoPressAimKey = "",
3232

3333
-- 是否自动连发 (单发模式变全自动 1 - 开启, 0 - 关闭)
34-
autoContinuousFiring = 1, -- 默认为 1
34+
-- autoContinuousFiring = 1, -- 默认为 1
3535

3636
-- 启动控制 (capslock - 使用大写锁定键控制 | numlock - 小键盘锁定键控制 | G_bind - 使用指令控制)
3737
startControl = "capslock",
@@ -51,31 +51,31 @@ userInfo = {
5151
end,
5252
},
5353

54-
-- 支持的枪械,排列顺序即是配置顺序,可以自行调整,不需要的枪械请设置为0,需要的设置为1。
54+
-- 支持的枪械,排列顺序即是配置顺序,可以自行调整,不需要的枪械请设置为 0 ,需要的设置为 1 ,需要单独启用自动连发的设置为 2
5555
canUse = {
5656
[".45"] = {
57-
{ "UMP45", 1 }, -- 基础镜 + 扩容,Bizon (基础镜即可),Vector (补偿 + 基础镜 + 扩容) | Reddot + Mag,Bizon (Reddot),Vector (Komp + Reddot + Mag)
58-
{ "Tommy Gun", 1 }, -- 扩容 | Mag
57+
{ "UMP45", 2 }, -- 基础镜 + 扩容,Bizon (基础镜即可),Vector (补偿 + 基础镜 + 扩容) | Reddot + Mag,Bizon (Reddot),Vector (Komp + Reddot + Mag)
58+
{ "Tommy Gun", 2 }, -- 扩容 | Mag
5959
},
6060
["9mm"] = {
61-
{ "Vector", 1 }, -- 基础镜 + 扩容 | Reddot + Mag
62-
{ "Micro UZI", 1 }, -- 扩容 | Mag
61+
{ "Vector", 2 }, -- 基础镜 + 扩容 | Reddot + Mag
62+
{ "Micro UZI", 2 }, -- 扩容 | Mag
6363
},
6464
["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
65+
{ "M416", 2 }, -- 补偿 + 基础镜 + 直角 + 枪托 + 扩容 | Komp + Reddot + Triangular grip + Gunstock + Mag
66+
{ "SCAR-L", 2 }, -- 补偿 + 基础镜 + 直角 + 扩容 | Komp + Reddot + Triangular grip + Mag
67+
{ "QBZ", 2 }, -- 补偿 + 基础镜 + 直角 + 扩容 | Komp + Reddot + Triangular grip + Mag
68+
{ "G36C", 2 }, -- 补偿 + 基础镜 + 直角 + 扩容 | Komp + Reddot + Triangular grip + Mag
69+
{ "M16A4", 2 }, -- 补偿 + 基础镜 + 枪托 + 扩容 | Komp + Reddot + Gunstock + Mag
7070
},
7171
["7.62"] = {
72-
{ "AKM", 1 }, -- 补偿 + 基础镜 + 扩容 | Komp + Reddot + Mag
73-
{ "Beryl M762", 1 }, -- 补偿 + 基础镜 + 直角 + 扩容 | Komp + Reddot + Triangular grip + Mag
74-
{ "DP-28", 1 }, -- 基础镜 | Reddot
72+
{ "AKM", 2 }, -- 补偿 + 基础镜 + 扩容 | Komp + Reddot + Mag
73+
{ "Beryl M762", 2 }, -- 补偿 + 基础镜 + 直角 + 扩容 | Komp + Reddot + Triangular grip + Mag
74+
{ "DP-28", 2 }, -- 基础镜 | Reddot
7575
},
7676
},
7777

78-
-- G键自定义绑定
78+
-- G键自定义绑定,多余的组合键可以删除
7979
-- 可绑定指令请参考: https://github.com/kiccer/Soldier76#%E6%8C%87%E4%BB%A4%E5%88%97%E8%A1%A8
8080
G_bind = {
8181
-- G
@@ -92,12 +92,12 @@ userInfo = {
9292
["lalt + G3"] = "",
9393
["lalt + G4"] = "",
9494
["lalt + G5"] = "",
95-
["lalt + G6"] = "scopeX1",
96-
["lalt + G7"] = "scopeX3",
97-
["lalt + G8"] = "scopeX4",
98-
["lalt + G9"] = "scopeX2",
95+
["lalt + G6"] = "",
96+
["lalt + G7"] = "",
97+
["lalt + G8"] = "",
98+
["lalt + G9"] = "",
9999
["lalt + G10"] = "",
100-
["lalt + G11"] = "scopeX6",
100+
["lalt + G11"] = "",
101101
-- lctrl + G
102102
["lctrl + G3"] = "",
103103
["lctrl + G4"] = "",
@@ -142,7 +142,7 @@ userInfo = {
142142
["rshift + G3"] = "",
143143
["rshift + G4"] = "",
144144
["rshift + G5"] = "",
145-
["rshift + G6"] = "",
145+
["rshift + G6"] = "fast_discard",
146146
["rshift + G7"] = "",
147147
["rshift + G8"] = "",
148148
["rshift + G9"] = "",
@@ -278,7 +278,7 @@ pubg["M16A4"] = function ()
278278
return pubg.execOptions({
279279
ratio = 1,
280280
interval = 108,
281-
autoContinuousFiring = 1,
281+
-- autoContinuousFiring = 1,
282282
ballistic = {
283283
{1, 0},
284284
{2, 140},
@@ -299,7 +299,7 @@ pubg["SCAR-L"] = function ()
299299
return pubg.execOptions({
300300
ratio = 1,
301301
interval = 102,
302-
autoContinuousFiring = 1,
302+
-- autoContinuousFiring = 1,
303303
ballistic = {
304304
{1, 0},
305305
{2, 140},
@@ -321,7 +321,7 @@ pubg["Beryl M762"] = function ()
321321
return pubg.execOptions({
322322
ratio = 1,
323323
interval = 93,
324-
autoContinuousFiring = 1,
324+
-- autoContinuousFiring = 1,
325325
ballistic = {
326326
{1, 0},
327327
{2, 140},
@@ -344,7 +344,7 @@ pubg["Tommy Gun"] = function ()
344344
return pubg.execOptions({
345345
ratio = 1,
346346
interval = 94,
347-
autoContinuousFiring = 1,
347+
-- autoContinuousFiring = 1,
348348
ballistic = {
349349
{1, 0},
350350
{5, 71},
@@ -361,7 +361,7 @@ pubg["G36C"] = function ()
361361
return pubg.execOptions({
362362
ratio = 1,
363363
interval = 91,
364-
autoContinuousFiring = 1,
364+
-- autoContinuousFiring = 1,
365365
ballistic = {
366366
{1, 0},
367367
{2, 135},
@@ -380,7 +380,7 @@ pubg["Vector"] = function ()
380380
return pubg.execOptions({
381381
ratio = 1,
382382
interval = 61,
383-
autoContinuousFiring = 1,
383+
-- autoContinuousFiring = 1,
384384
ballistic = {
385385
{1, 0},
386386
{5, 52},
@@ -398,7 +398,7 @@ pubg["Micro UZI"] = function ()
398398
return pubg.execOptions({
399399
ratio = 1,
400400
interval = 56,
401-
autoContinuousFiring = 1,
401+
-- autoContinuousFiring = 1,
402402
ballistic = {
403403
{1, 0},
404404
{2, 80},
@@ -417,7 +417,7 @@ pubg["UMP45"] = function ()
417417
return pubg.execOptions({
418418
ratio = 1,
419419
interval = 100,
420-
autoContinuousFiring = 1,
420+
-- autoContinuousFiring = 1,
421421
ballistic = {
422422
{1, 0},
423423
{5, 69},
@@ -434,7 +434,7 @@ pubg["AKM"] = function ()
434434
return pubg.execOptions({
435435
ratio = 1,
436436
interval = 107,
437-
autoContinuousFiring = 1,
437+
-- autoContinuousFiring = 1,
438438
ballistic = {
439439
{1, 0},
440440
{2, 157},
@@ -452,7 +452,7 @@ pubg["M416"] = function ()
452452
return pubg.execOptions({
453453
ratio = 1,
454454
interval = 93,
455-
autoContinuousFiring = 1,
455+
-- autoContinuousFiring = 1,
456456
ballistic = {
457457
{1, 0},
458458
{2, 132},
@@ -472,7 +472,7 @@ pubg["QBZ"] = function ()
472472
return pubg.execOptions({
473473
ratio = 1,
474474
interval = 99,
475-
autoContinuousFiring = 1,
475+
-- autoContinuousFiring = 1,
476476
ballistic = {
477477
{1, 0},
478478
{2, 125},
@@ -492,7 +492,7 @@ pubg["DP-28"] = function ()
492492
return pubg.execOptions({
493493
ratio = 1,
494494
interval = 116,
495-
autoContinuousFiring = 1,
495+
-- autoContinuousFiring = 1,
496496
ballistic = {
497497
{1, 0},
498498
{7, 106},
@@ -563,7 +563,7 @@ function pubg.execOptions (options)
563563
amount = #ballisticConfig2, -- Number of bullets
564564
interval = options.interval, -- Time of each bullet
565565
ballistic = ballisticConfig2, -- ballistic data
566-
autoContinuousFiring = options.autoContinuousFiring
566+
-- autoContinuousFiring = options.autoContinuousFiring
567567
}
568568

569569
end
@@ -580,13 +580,18 @@ function pubg.init ()
580580
local gunCount = 0
581581

582582
for j = 1, #userInfo.canUse[type] do
583+
local gunName = userInfo.canUse[type][j][1]
584+
local gunState = userInfo.canUse[type][j][2]
583585

584-
if userInfo.canUse[type][j][2] == 1 then
585-
local gunName = userInfo.canUse[type][j][1]
586+
if gunState >= 1 then
586587
-- one series
587588
gunCount = gunCount + 1 -- Accumulative number of firearms configuration files
588589
pubg.gun[type][gunCount] = gunName -- Adding available firearms to the Arsenal
589590
pubg.gunOptions[type][gunCount] = pubg[gunName]() -- Get firearms data and add it to the configuration library
591+
-- 单独设置连发
592+
pubg.gunOptions[type][gunCount].autoContinuousFiring = ({ 0, 0, 1 })[
593+
math.max(1, math.min(gunState, 100)) + 1
594+
]
590595
-- all canUse
591596
pubg.allCanUse_count = pubg.allCanUse_count + 1 -- Total plus one
592597
pubg.allCanUse[pubg.allCanUse_count] = gunName -- All available firearms
@@ -644,7 +649,7 @@ function pubg.auto (options)
644649
local realY = pubg.getRealY(y)
645650
MoveMouseRelative(x, realY)
646651
-- Whether to issue automatically or not
647-
if userInfo.autoContinuousFiring == 1 and options.autoContinuousFiring == 1 then
652+
if options.autoContinuousFiring == 1 then
648653
PressAndReleaseMouseButton(1)
649654
end
650655

@@ -738,7 +743,7 @@ function pubg.setGun (gunName)
738743
local selected = false
739744

740745
for j = 1, #userInfo.canUse[type] do
741-
if userInfo.canUse[type][j][2] == 1 then
746+
if userInfo.canUse[type][j][2] >= 1 then
742747
gunIndex = gunIndex + 1
743748
allCanUse_index = allCanUse_index + 1
744749
if userInfo.canUse[type][j][1] == gunName then
@@ -811,17 +816,24 @@ function pubg.fastPickup ()
811816
PressAndReleaseKey("tab")
812817
Sleep(10 + pubg.sleep)
813818
PressAndReleaseMouseButton(1)
819+
814820
local lastItemCp = {
815821
300 / 2560 * 65535,
816822
1210 / 1440 * 65535
817823
}
818824
local itemHeight = 83 / 1440 * 65535
819-
for i = 1, 13 do
820-
MoveMouseTo(lastItemCp[1], lastItemCp[2] - itemHeight * (i - 1))
821-
PressMouseButton(1)
822-
MoveMouseTo(32767, 32767)
823-
ReleaseMouseButton(1)
825+
826+
-- 重复 3 次动作,强化拾取成功率
827+
for i = 1, 3 do
828+
for j = 1, 13 do
829+
MoveMouseTo(lastItemCp[1], lastItemCp[2] - itemHeight * (j - 1))
830+
PressMouseButton(1)
831+
MoveMouseTo(32767, 32767)
832+
ReleaseMouseButton(1)
833+
end
824834
end
835+
836+
Sleep(10 + pubg.sleep)
825837
MoveMouseTo(lastItemCp[1], lastItemCp[2])
826838
PressAndReleaseKey("tab")
827839
end
@@ -941,10 +953,14 @@ function pubg.runCmd (cmd)
941953

942954
if pubg.ok then
943955
local cmdGroup = string.split(cmd, '|')
956+
944957
for i = 1, #cmdGroup do
945958
local _cmd = cmdGroup[i]
946-
switch[_cmd](_cmd)
959+
if switch[_cmd] then
960+
switch[_cmd](_cmd)
961+
end
947962
end
963+
948964
end
949965
end
950966

@@ -979,7 +995,7 @@ function pubg.outputLogGunSwitchTable ()
979995
local gunCount = 0
980996

981997
for j = 1, #userInfo.canUse[type] do
982-
if userInfo.canUse[type][j][2] == 1 then
998+
if userInfo.canUse[type][j][2] >= 1 then
983999
local gunName = userInfo.canUse[type][j][1]
9841000
local tag = gunName == pubg.gun[pubg.bulletType][pubg.gunIndex] and "=> " or " "
9851001
gunCount = gunCount + 1
@@ -1077,6 +1093,21 @@ function pubg.OnEvent_NoRecoil (event, arg, family)
10771093
end
10781094
end
10791095

1096+
-- [[ processing instruction ]]
1097+
function pubg.modifierHandle (modifier)
1098+
local cmd = userInfo.G_bind[modifier]
1099+
pubg.renderDom.combo_key = modifier -- Save combination keys
1100+
1101+
if (cmd) then
1102+
pubg.renderDom.cmd = cmd -- Save instruction name
1103+
pubg.runCmd(cmd) -- Execution instructions
1104+
else
1105+
pubg.renderDom.cmd = ""
1106+
end
1107+
1108+
pubg.outputLogRender() -- Call log rendering method to output information
1109+
end
1110+
10801111
--[[ Listener method ]]
10811112
function OnEvent (event, arg, family)
10821113

@@ -1090,29 +1121,31 @@ function OnEvent (event, arg, family)
10901121

10911122
-- Switching arsenals according to different types of ammunition
10921123
if event == "MOUSE_BUTTON_PRESSED" and arg >=3 and arg <= 11 and family == "mouse" and pubg.ok then
1093-
local modifier = "G"
1124+
local modifier = "G" .. arg
10941125
local list = { "lalt", "lctrl", "lshift", "ralt", "rctrl", "rshift" }
10951126
for i = 1, #list do
10961127
if IsModifierPressed(list[i]) then
10971128
modifier = list[i] .. " + " .. modifier
10981129
break
10991130
end
11001131
end
1101-
modifier = modifier .. arg -- Get the combination key
1102-
pubg.renderDom.combo_key = modifier -- Save combination keys
1103-
pubg.renderDom.cmd = userInfo.G_bind[modifier] -- Save instruction name
1104-
pubg.runCmd(userInfo.G_bind[modifier]) -- Execution instructions
1105-
pubg.outputLogRender() -- Call log rendering method to output information
1132+
-- modifier = modifier .. arg -- Get the combination key
1133+
-- pubg.renderDom.combo_key = modifier -- Save combination keys
1134+
-- pubg.renderDom.cmd = userInfo.G_bind[modifier] -- Save instruction name
1135+
-- pubg.runCmd(userInfo.G_bind[modifier]) -- Execution instructions
1136+
-- pubg.outputLogRender() -- Call log rendering method to output information
1137+
pubg.modifierHandle(modifier)
11061138
end
11071139

11081140
if event == "G_PRESSED" and arg >=1 and arg <= 12 and pubg.ok then
11091141
-- if not pubg.runStatus() and userInfo.startControl ~= "G_bind" then return false end
1110-
local modifier = "F"
1111-
modifier = modifier .. arg -- Get the combination key
1112-
pubg.renderDom.combo_key = modifier -- Save combination keys
1113-
pubg.renderDom.cmd = userInfo.G_bind[modifier] -- Save instruction name
1114-
pubg.runCmd(userInfo.G_bind[modifier]) -- Execution instructions
1115-
pubg.outputLogRender() -- Call log rendering method to output information
1142+
local modifier = "F" .. arg
1143+
-- modifier = modifier .. arg -- Get the combination key
1144+
-- pubg.renderDom.combo_key = modifier -- Save combination keys
1145+
-- pubg.renderDom.cmd = userInfo.G_bind[modifier] -- Save instruction name
1146+
-- pubg.runCmd(userInfo.G_bind[modifier]) -- Execution instructions
1147+
-- pubg.outputLogRender() -- Call log rendering method to output information
1148+
pubg.modifierHandle(modifier)
11161149
end
11171150

11181151
-- Script deactivated event

0 commit comments

Comments
 (0)