auto artifacts: add methods to handle map error (#436)

This commit is contained in:
Yang-z
2025-03-13 13:48:25 +08:00
committed by GitHub
parent a7d14ab1b2
commit 709933c3e7
6 changed files with 46 additions and 52 deletions

View File

@@ -8,8 +8,7 @@
{ {
"x": 3917.1767578125, "x": 3917.1767578125,
"y": 2576.28662109375, "y": 2576.28662109375,
"type": "teleport", "type": "teleport"
"move_mode": "walk"
}, },
{ {
"x": 3904.10498046875, "x": 3904.10498046875,
@@ -22,7 +21,6 @@
"y": 2543.31640625, "y": 2543.31640625,
"type": "target", "type": "target",
"move_mode": "walk", "move_mode": "walk",
"action":"",
"#" : "1" "#" : "1"
}, },
{ {
@@ -33,14 +31,6 @@
"action": "combat_script", "action": "combat_script",
"action_params": "wait(0.8)", "action_params": "wait(0.8)",
"#" : "2" "#" : "2"
},
{
"x": 3890.994140625,
"y": 2429.1708984375,
"type": "path",
"move_mode": "dash",
"//": "跑远,防止'揭示之书'和地图缩放按钮重叠导致地图识别失败"
} }
] ]
} }

View File

@@ -8,12 +8,11 @@
{ {
"x": -2612.30078125, "x": -2612.30078125,
"y": -6508.21875, "y": -6508.21875,
"type": "teleport", "type": "teleport"
"move_mode": "walk"
}, },
{ {
"x": -2581.470703125, "x": -2583.203125,
"y": -6529.7802734375, "y": -6523.86328125,
"type": "path", "type": "path",
"move_mode": "fly", "move_mode": "fly",
"action": "stop_flying" "action": "stop_flying"
@@ -22,20 +21,18 @@
"x": -2581.470703125, "x": -2581.470703125,
"y": -6529.7802734375, "y": -6529.7802734375,
"type": "target", "type": "target",
"move_mode": "walk", "move_mode": "walk"
"action": ""
}, },
{ {
"x": -2579.80859375, "x": -2579.80859375,
"y": -6533.02734375, "y": -6533.02734375,
"type": "target", "type": "target",
"move_mode": "walk", "move_mode": "walk"
"action": ""
}, },
{ {
"x": -2582.0341796875, "x": -2580.0732421875,
"y": -6525.9619140625, "y": -6535.291015625,
"type": "path", "type": "path",
"move_mode": "walk" "move_mode": "walk"
} }

View File

@@ -123,6 +123,8 @@
// 调整地图 // 调整地图
async function resizeMap(level = 1) { async function resizeMap(level = 1) {
await genshin.returnMainUi();
keyPress("M"); await sleep(1000); keyPress("M"); await sleep(1000);
for (let i = 5; i > 0; --i) { for (let i = 5; i > 0; --i) {
click(46, 436); await sleep(500); // zoom in click(46, 436); await sleep(500); // zoom in
@@ -130,20 +132,22 @@
for (let i = 0; i < level; ++i) { for (let i = 0; i < level; ++i) {
click(46, 630); await sleep(500); // zoom out click(46, 630); await sleep(500); // zoom out
} }
keyPress("M"); await sleep(1000); // keyPress("M"); await sleep(1000);
} }
// 拖拽地图 // 拖拽地图
async function dragMap(byX, byY) { async function dragMap(byX, byY) {
await genshin.returnMainUi();
let byL = Math.sqrt(byX * byX + byY * byY); let byL = Math.sqrt(byX * byX + byY * byY);
let d = 5; let d = 5;
let dx = Math.round(d * byX / byL); let dx = Math.round(d * byX / byL);
let dy = Math.round(d * byY / byL); let dy = Math.round(d * byY / byL);
let times = Math.round(byX / dx) * 2; // let times = Math.round(byX / dx * genshin.screenDpiScale);
log.debug(`byL: ${byL}; dx: ${dx}; dy: ${dy}; times: ${times};`); log.debug(`byL: ${byL}; dx: ${dx}; dy: ${dy}; times: ${times}; genshin.screenDpiScale: ${genshin.screenDpiScale};`);
keyPress("M"); await sleep(1000); keyPress("M"); await sleep(1000);
moveMouseBy(-byX, -byY); await sleep(300); moveMouseBy(-byX, -byY); await sleep(300);
@@ -155,10 +159,19 @@
leftButtonUp(); await sleep(300); leftButtonUp(); await sleep(300);
} }
// 就近传送(传送脚本文件中的第一个点)
async function tpNearby(filePath) {
const raw = file.ReadTextSync(filePath);
const data = JSON.parse(raw);
await genshin.tp(data['positions'][0]['x'], data['positions'][0]['y']);
}
// 分解圣遗物 // 分解圣遗物
async function salvage() { async function salvage() {
if (!autoSalvage) return; if (!autoSalvage) return;
await genshin.returnMainUi();
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); // 分解
@@ -208,12 +221,19 @@
await pathingScript.runFile(filePath); await pathingScript.runFile(filePath);
// 地图缩放按键同某些地图标识重叠,导致识别失败(bgi[v0.43.0]后引入) // 地图缩放按键同某些地图标识重叠,导致识别失败(bgi[v0.43.0]后引入)
// 完成路径后,拖拽地图,就近传送。仍有问题,到下个路径时会关闭地图再打开。 // // 完成路径后,放大地图,脚本中调用就近传送。仍可能被缩小回去。不可行
// let shouldDragMap_after = filePath.search("~m") != -1; // let shouldResizeMap_after = filePath.search("~m") != -1;
// if (shouldDragMap_after) await dragMap(-50, 50); // if (shouldResizeMap_after) {
// 完成路径后,放大地图。仍可能被缩小回去。 // await resizeMap(0);
// let shouldDragMap_after = filePath.search("~m") != -1; // await tpNearby(filePath);
// if (shouldDragMap_after) await resizeMap(0); // }
// 完成路径后,拖拽地图,脚本中调用就近传送。可行
let shouldDragMap_after = filePath.search("~m") != -1;
if (shouldDragMap_after) {
await dragMap(-50, 50);
await tpNearby(filePath);
}
} }
catch (error) { // bgi已捕获可预期异常此处仅做兜底 catch (error) { // bgi已捕获可预期异常此处仅做兜底
log.error(error.toString()); log.error(error.toString());

View File

@@ -1,7 +1,7 @@
{ {
"manifest_version": 1, "manifest_version": 1,
"name": "狗粮ABE路线自动拾取分解", "name": "狗粮ABE路线自动拾取分解",
"version": "2.3.5", "version": "2.4.0",
"bgi_version": "0.42.0", "bgi_version": "0.42.0",
"description": "圣遗物狗粮AB及额外路线自动轮换自动分解就近恢复。", "description": "圣遗物狗粮AB及额外路线自动轮换自动分解就近恢复。",
"authors": [ "authors": [

View File

@@ -8,8 +8,7 @@
{ {
"x": 3917.1767578125, "x": 3917.1767578125,
"y": 2576.28662109375, "y": 2576.28662109375,
"type": "teleport", "type": "teleport"
"move_mode": "walk"
}, },
{ {
"x": 3904.10498046875, "x": 3904.10498046875,
@@ -22,7 +21,6 @@
"y": 2543.31640625, "y": 2543.31640625,
"type": "target", "type": "target",
"move_mode": "walk", "move_mode": "walk",
"action":"",
"#" : "1" "#" : "1"
}, },
{ {
@@ -33,14 +31,6 @@
"action": "combat_script", "action": "combat_script",
"action_params": "wait(0.8)", "action_params": "wait(0.8)",
"#" : "2" "#" : "2"
},
{
"x": 3890.994140625,
"y": 2429.1708984375,
"type": "path",
"move_mode": "dash",
"//": "跑远,防止'揭示之书'和地图缩放按钮重叠导致地图识别失败"
} }
] ]
} }

View File

@@ -8,12 +8,11 @@
{ {
"x": -2612.30078125, "x": -2612.30078125,
"y": -6508.21875, "y": -6508.21875,
"type": "teleport", "type": "teleport"
"move_mode": "walk"
}, },
{ {
"x": -2581.470703125, "x": -2583.203125,
"y": -6529.7802734375, "y": -6523.86328125,
"type": "path", "type": "path",
"move_mode": "fly", "move_mode": "fly",
"action": "stop_flying" "action": "stop_flying"
@@ -22,20 +21,18 @@
"x": -2581.470703125, "x": -2581.470703125,
"y": -6529.7802734375, "y": -6529.7802734375,
"type": "target", "type": "target",
"move_mode": "walk", "move_mode": "walk"
"action": ""
}, },
{ {
"x": -2579.80859375, "x": -2579.80859375,
"y": -6533.02734375, "y": -6533.02734375,
"type": "target", "type": "target",
"move_mode": "walk", "move_mode": "walk"
"action": ""
}, },
{ {
"x": -2582.0341796875, "x": -2580.0732421875,
"y": -6525.9619140625, "y": -6535.291015625,
"type": "path", "type": "path",
"move_mode": "walk" "move_mode": "walk"
} }