Merge pull request #130 from Yang-z/main

implement user settings and fine-tune
This commit is contained in:
辉鸭蛋
2024-12-02 00:02:29 +08:00
committed by GitHub
7 changed files with 135 additions and 110 deletions

View File

@@ -30,27 +30,25 @@
"move_mode": "run" "move_mode": "run"
}, },
{ {
"x": -3712.8046875, "x": -3711.8173828125,
"y": -4748.9580078125, "y": -4749.169921875,
"type": "target", "type": "target",
"move_mode": "run", "move_mode": "run",
"action": "" "action": ""
}, },
{ {
"x": -3712.994140625, "x": -3710.8828125,
"y": -4748.5810546875, "y": -4747.0546875,
"type": "target", "type": "target",
"move_mode": "walk", "move_mode": "walk",
"action": "" "action": ""
}, },
{ {
"x": -3711.8955078125, "x": -3712.4990234375,
"y": -4747.560546875, "y": -4746.32421875,
"type": "target", "type": "path",
"move_mode": "walk", "move_mode": "walk"
"action": ""
} }
] ]
} }

View File

@@ -11,6 +11,12 @@
"type": "teleport", "type": "teleport",
"move_mode": "walk" "move_mode": "walk"
}, },
{
"x": -3220.759765625,
"y": -6183.2890625,
"type": "path",
"move_mode": "run"
},
{ {
"x": -3219.5185546875, "x": -3219.5185546875,
"y": -6216.2353515625, "y": -6216.2353515625,
@@ -37,37 +43,32 @@
}, },
{ {
"x": -3260.615234375, "x": -3260.61328125,
"y": -6212.7294921875, "y": -6212.1015625,
"type": "path", "type": "path",
"move_mode": "run" "move_mode": "run"
}, },
{ {
"x": -3267.4814453125, "x": -3271.361328125,
"y": -6217.068359375, "y": -6215.748046875,
"type": "path", "type": "target",
"move_mode": "walk" "move_mode": "run",
"action": "",
"#": "3"
},
{
"x": -3270.759765625,
"y": -6215.4892578125,
"type": "target",
"move_mode": "run",
"action": "",
"#": "3"
}, },
{ {
"x": -3270.759765625, "x": -3270.3818359375,
"y": -6215.4892578125, "y": -6217.875,
"type": "target",
"move_mode": "run",
"action": "",
"#": "3"
},
{
"x": -3270.759765625,
"y": -6215.4892578125,
"type": "target",
"move_mode": "run",
"action": "",
"#": "3"
},
{
"x": -3269.556640625,
"y": -6212.7734375,
"type": "path", "type": "path",
"move_mode": "walk" "move_mode": "walk"
} }

View File

@@ -1,5 +1,5 @@
(async function () { (async function () {
setGameMetrics(1920, 1080, 1);
const folderA = 'assets/狗粮A线@Yang-z/'; const folderA = 'assets/狗粮A线@Yang-z/';
const folderB = 'assets/狗粮B线@Yang-z/'; const folderB = 'assets/狗粮B线@Yang-z/';
const folderE = 'assets/狗粮额外@Yang-z/'; const folderE = 'assets/狗粮额外@Yang-z/';
@@ -71,20 +71,27 @@
]; // 17个其中纳塔第2个似乎是一次性的 ]; // 17个其中纳塔第2个似乎是一次性的
let path = ''; // 路线 // 读取用户设置JS脚本直接运行已不会抛出异常但默认值还不支持[bgi0.37.1]
function determinePath() { let path = settings.path != undefined ? settings.path : '';
try { let swapPath = settings.swapPath != undefined && settings.swapPath != '否' ? true : false;
path = settings.path; let extra = settings.extra != undefined && settings.extra != '是' ? false : true;
} catch (error) { let autoSalvage = settings.autoSalvage != undefined && settings.autoSalvage != '是' ? false : true;
log.error(error.toString()); let autoSalvage4 = settings.autoSalvage4 != undefined && autoSalvage4 != '否' ? true : false;
} let autoSalvageSpan = settings.autoSalvageSpan != undefined && ~~settings.autoSalvageSpan > 0 ? ~~settings.autoSalvageSpan : 10;
log.debug(`path: ${path}; swapPath: ${swapPath}; extra: ${extra}; autoSalvage: ${autoSalvage}; autoSalvage4: ${autoSalvage4}; autoSalvageSpan: ${autoSalvageSpan};`);
// await sleep(30000);
// 路线
function determinePath() {
if (path != 'A' && path != 'B') { if (path != 'A' && path != 'B') {
const benchmark = new Date("2024-11-20T04:00:00"); const benchmark = new Date("2024-11-20T04:00:00");
const now = new Date(); const now = new Date();
const delta = now - benchmark; const delta = now - benchmark;
const days = delta / (1000 * 60 * 60 * 24); const days = delta / (1000 * 60 * 60 * 24);
path = days % 2 < 1 ? 'A' : 'B'; path = days % 2 < 1 ? 'A' : 'B';
if (swapPath) path = path == 'A' ? 'B' : 'A';
} }
} }
@@ -107,15 +114,17 @@
// 分解圣遗物 // 分解圣遗物
async function salvage() { async function salvage() {
if (!autoSalvage) return;
keyPress("B"); await sleep(2000); keyPress("B"); await sleep(2000);
click(670, 40); await sleep(1000); // 圣遗物 click(670, 40); await sleep(1000); // 圣遗物
click(660, 1010); await sleep(1000); // 分解 click(660, 1010); await sleep(1000); // 分解
click(300, 1020); await sleep(1000); // 快速选择 click(300, 1020); await sleep(1000); // 快速选择
click(200, 150); await sleep(500); // 1 click(200, 140); await sleep(500); // 1
click(200, 220); await sleep(500); // 2 click(200, 220); await sleep(500); // 2
click(200, 300); await sleep(500); // 3 click(200, 300); await sleep(500); // 3
// click(200, 380); await sleep(3000); // 4 if (autoSalvage4) click(200, 380); await sleep(500); // 4
click(340, 1000); await sleep(1000); // 确认选择 click(340, 1000); await sleep(1000); // 确认选择
click(1720, 1015); await sleep(1500); // 分解 click(1720, 1015); await sleep(1500); // 分解
@@ -146,13 +155,14 @@
dispatcher.addTimer(new RealtimeTimer("AutoPick", { "forceInteraction": forceInteraction })); dispatcher.addTimer(new RealtimeTimer("AutoPick", { "forceInteraction": forceInteraction }));
for (let i = 0; i < files.length; i++) { for (let i = 0; i < files.length; i++) {
if (i % 10 == 0) await salvage(); if (i % autoSalvageSpan == 0) await salvage();
const filePath = folder + files[i]; const filePath = folder + files[i];
await runFile(filePath); await runFile(filePath);
} }
} }
// main // main
setGameMetrics(1920, 1080, 1);
determinePath(); determinePath();
// A or B // A or B
@@ -162,9 +172,11 @@
else await batch(folderB, pathingB); else await batch(folderB, pathingB);
// Extra // Extra
await init(false); if (extra) {
log.info(`开始执行额外线路。`); await init(false);
await batch(folderE, pathingE, true); // 强制交互 log.info(`开始执行额外线路。`);
await batch(folderE, pathingE, true); // 强制交互
}
log.info(`今日狗粮拾取任务完成。拾取路线:${path}+E`); log.info(`今日狗粮拾取任务完成。拾取路线:${path}+E`);
await sleep(3000); await sleep(3000);

View File

@@ -1,7 +1,7 @@
{ {
"manifest_version": 1, "manifest_version": 1,
"name": "狗粮ABE路线自动拾取分解", "name": "狗粮ABE路线自动拾取分解",
"version": "1.5.2", "version": "1.6",
"bgi_version": "0.37.1", "bgi_version": "0.37.1",
"description": "圣遗物狗粮AB路线自动轮换及额外点位拾取途中自动分解。更新纳塔5.2优质点位。", "description": "圣遗物狗粮AB路线自动轮换及额外点位拾取途中自动分解。更新纳塔5.2优质点位。",
"authors": [ "authors": [

View File

@@ -1,40 +1,55 @@
[ [
{ {
"name": "path", "name": "path",
"type": "select", "type": "select",
"label": "路线", "label": "路线(默认:自动)",
"options": [ "options": [
"A", "A",
"B", "B",
"自动" "自动"
] ]
}, },
// { {
// "name": "swapPath", "name": "swapPath",
// "type": "checkbox", "type": "select",
// "label": "自动选择路线时交换AB路线" "label": "自动选择路线时交换AB路线(默认:否)",
// }, "options": [
"是",
"否"
]
},
// { {
// "name": "Extra", "name": "extra",
// "type": "checkbox", "type": "select",
// "label": "拾取额外点位" "label": "拾取额外点位(默认:是)",
// }, "options": [
"是",
"否"
]
},
// { {
// "name": "autoSalvage", "name": "autoSalvage",
// "type": "checkbox", "type": "select",
// "label": "自动分解" "label": "自动分解(默认:是)",
// }, "options": [
// { "是",
// "name": "autoSalvage4", "否"
// "type": "checkbox", ]
// "label": "自动分解包括4星圣遗物" },
// }, {
// { "name": "autoSalvage4",
// "name": "autoSalvageSpan", "type": "select",
// "type": "input-text", "label": "自动分解包括4星圣遗物默认",
// "label": "自动分解在多少路径后执行一次" "options": [
// } "是",
"否"
]
},
{
"name": "autoSalvageSpan",
"type": "input-text",
"label": "自动分解在多少路径后执行一次默认10"
}
] ]

View File

@@ -30,27 +30,25 @@
"move_mode": "run" "move_mode": "run"
}, },
{ {
"x": -3712.8046875, "x": -3711.8173828125,
"y": -4748.9580078125, "y": -4749.169921875,
"type": "target", "type": "target",
"move_mode": "run", "move_mode": "run",
"action": "" "action": ""
}, },
{ {
"x": -3712.994140625, "x": -3710.8828125,
"y": -4748.5810546875, "y": -4747.0546875,
"type": "target", "type": "target",
"move_mode": "walk", "move_mode": "walk",
"action": "" "action": ""
}, },
{ {
"x": -3711.8955078125, "x": -3712.4990234375,
"y": -4747.560546875, "y": -4746.32421875,
"type": "target", "type": "path",
"move_mode": "walk", "move_mode": "walk"
"action": ""
} }
] ]
} }

View File

@@ -11,6 +11,12 @@
"type": "teleport", "type": "teleport",
"move_mode": "walk" "move_mode": "walk"
}, },
{
"x": -3220.759765625,
"y": -6183.2890625,
"type": "path",
"move_mode": "run"
},
{ {
"x": -3219.5185546875, "x": -3219.5185546875,
"y": -6216.2353515625, "y": -6216.2353515625,
@@ -37,37 +43,32 @@
}, },
{ {
"x": -3260.615234375, "x": -3260.61328125,
"y": -6212.7294921875, "y": -6212.1015625,
"type": "path", "type": "path",
"move_mode": "run" "move_mode": "run"
}, },
{ {
"x": -3267.4814453125, "x": -3271.361328125,
"y": -6217.068359375, "y": -6215.748046875,
"type": "path", "type": "target",
"move_mode": "walk" "move_mode": "run",
"action": "",
"#": "3"
},
{
"x": -3270.759765625,
"y": -6215.4892578125,
"type": "target",
"move_mode": "run",
"action": "",
"#": "3"
}, },
{ {
"x": -3270.759765625, "x": -3270.3818359375,
"y": -6215.4892578125, "y": -6217.875,
"type": "target",
"move_mode": "run",
"action": "",
"#": "3"
},
{
"x": -3270.759765625,
"y": -6215.4892578125,
"type": "target",
"move_mode": "run",
"action": "",
"#": "3"
},
{
"x": -3269.556640625,
"y": -6212.7734375,
"type": "path", "type": "path",
"move_mode": "walk" "move_mode": "walk"
} }