From 358b6d8d1ead947e18710103ebc75c5100c81682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E4=BA=91?= Date: Wed, 11 Jun 2025 07:18:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B8=85=E6=B3=89=E9=95=87=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=EF=BC=8C=E5=88=86=E6=94=AF=E8=B7=AF=E7=BA=BF=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assets/pathing/蒙德2-清泉镇-2.json | 2 +- .../assets/pathing/蒙德2-清泉镇-3.json | 4 +- .../assets/pathing/蒙德2-清泉镇-4-1.json | 57 ++++--------- .../utils/executePathsUsingNewNodeData.js | 0 .../utils/executePathsUsingNodeData.js | 80 +++++-------------- .../executePathsUsingSeparatedNodeData.js | 0 6 files changed, 41 insertions(+), 102 deletions(-) delete mode 100644 repo/js/AutoLeyLineOutcrop/utils/executePathsUsingNewNodeData.js delete mode 100644 repo/js/AutoLeyLineOutcrop/utils/executePathsUsingSeparatedNodeData.js diff --git a/repo/js/AutoLeyLineOutcrop/assets/pathing/蒙德2-清泉镇-2.json b/repo/js/AutoLeyLineOutcrop/assets/pathing/蒙德2-清泉镇-2.json index a828ee6a..6a6262f2 100644 --- a/repo/js/AutoLeyLineOutcrop/assets/pathing/蒙德2-清泉镇-2.json +++ b/repo/js/AutoLeyLineOutcrop/assets/pathing/蒙德2-清泉镇-2.json @@ -22,7 +22,7 @@ "x": -547.37, "y": 1829.88, "type": "path", - "move_mode": "fly", + "move_mode": "jump", "action": "", "action_params": "" }, diff --git a/repo/js/AutoLeyLineOutcrop/assets/pathing/蒙德2-清泉镇-3.json b/repo/js/AutoLeyLineOutcrop/assets/pathing/蒙德2-清泉镇-3.json index 3de89d56..fb2d42ef 100644 --- a/repo/js/AutoLeyLineOutcrop/assets/pathing/蒙德2-清泉镇-3.json +++ b/repo/js/AutoLeyLineOutcrop/assets/pathing/蒙德2-清泉镇-3.json @@ -32,8 +32,8 @@ "y": 1954.13, "type": "path", "move_mode": "walk", - "action": "", - "action_params": "" + "action": "combat_script", + "action_params": "wait(1.0)" }, { "id": 4, diff --git a/repo/js/AutoLeyLineOutcrop/assets/pathing/蒙德2-清泉镇-4-1.json b/repo/js/AutoLeyLineOutcrop/assets/pathing/蒙德2-清泉镇-4-1.json index e62d2b38..c86bac8b 100644 --- a/repo/js/AutoLeyLineOutcrop/assets/pathing/蒙德2-清泉镇-4-1.json +++ b/repo/js/AutoLeyLineOutcrop/assets/pathing/蒙德2-清泉镇-4-1.json @@ -2,64 +2,41 @@ "info": { "name": "蒙德2-清泉镇-4-1", "type": "collect", - "author": "ddaodan", + "author": "秋云", "version": "1.1", "description": "", - "bgi_version": "0.42.3" + "map_name": "Teyvat", + "bgi_version": "0.45.0", + "tags": [], + "last_modified_time": 1749595981247 }, "positions": [ { "id": 1, - "action": "", - "move_mode": "walk", + "x": -401.35, + "y": 1976.93, "type": "path", - "x": -524.25, - "y": 1816.41, + "move_mode": "walk", + "action": "", "action_params": "" }, { "id": 2, - "x": -489.69, - "y": 1839.69, + "x": -349.19, + "y": 1939.59, "type": "path", - "move_mode": "walk", - "action": "", + "move_mode": "fly", + "action": "stop_flying", "action_params": "" }, { "id": 3, - "x": -422.21, - "y": 1922.12, - "type": "path", - "move_mode": "dash", - "action": "", - "action_params": "" - }, - { - "id": 4, - "x": -385.48, - "y": 1910.01, - "type": "path", - "move_mode": "walk", - "action": "", - "action_params": "" - }, - { - "id": 5, - "x": -376.12, - "y": 1909.88, - "type": "path", - "move_mode": "walk", - "action": "", - "action_params": "" - }, - { - "id": 6, "x": -347.95, "y": 1902.51, - "type": "path", - "move_mode": "fly", - "action": "stop_flying" + "action": "", + "move_mode": "dash", + "action_params": "", + "type": "path" } ] } \ No newline at end of file diff --git a/repo/js/AutoLeyLineOutcrop/utils/executePathsUsingNewNodeData.js b/repo/js/AutoLeyLineOutcrop/utils/executePathsUsingNewNodeData.js deleted file mode 100644 index e69de29b..00000000 diff --git a/repo/js/AutoLeyLineOutcrop/utils/executePathsUsingNodeData.js b/repo/js/AutoLeyLineOutcrop/utils/executePathsUsingNodeData.js index 24da1497..a2234e05 100644 --- a/repo/js/AutoLeyLineOutcrop/utils/executePathsUsingNodeData.js +++ b/repo/js/AutoLeyLineOutcrop/utils/executePathsUsingNodeData.js @@ -61,7 +61,8 @@ async function (position) { log.info(`完成节点 ID ${nextNodeId}, 已执行 ${currentRunTimes}/${settings.timesValue} 次`); // 更新当前节点为下一个节点,继续检查 currentNode = nextNode; currentNodePosition = { x: nextNode.position.x, y: nextNode.position.y }; - } else if (currentNode.next.length > 1) { + } + else if (currentNode.next.length > 1) { // 如果存在分支路线,先打开大地图判断下一个地脉花的位置,然后结合顺序边缘数据选择最优路线 log.info("检测到多个分支路线,开始查找下一个地脉花位置"); @@ -81,71 +82,31 @@ async function (position) { if (!found) { log.warn("无法在分支点找到下一个地脉花,退出本次循环"); return; - } - + } log.info(`找到下一个地脉花,位置: (${leyLineX}, ${leyLineY})`); - // 优先使用顺序边缘数据来选择路径,如果没有则回退到距离计算 - const sequentialEdges = nodeData.indexes?.edgesBySource; + // 直接比较所有分支节点到地脉花的距离,选择最近的路径 let selectedRoute = null; let selectedNodeId = null; + let closestDistance = Infinity; - if (sequentialEdges) { - const currentNodeIdStr = currentNode.id.toString(); - const nextTargetIds = sequentialEdges[currentNodeIdStr]; + for (const nextRoute of currentNode.next) { + const nextNodeId = nextRoute.target; + const nextNode = nodeData.node.find(node => node.id === nextNodeId); - if (nextTargetIds && nextTargetIds.length > 0) { - const nextTargetId = nextTargetIds[0]; - log.info(`从顺序边缘数据中找到推荐的下一个目标节点ID: ${nextTargetId}`); + if (!nextNode) continue; - // 在当前节点的分支中查找通向推荐目标节点的路径 - for (const nextRoute of currentNode.next) { - const nextNodeId = nextRoute.target; - - // 检查这个路径是否通向推荐的目标节点(直接匹配或通过后续路径) - if (nextNodeId === nextTargetId) { - selectedRoute = nextRoute.route; - selectedNodeId = nextNodeId; - log.info(`使用顺序边缘数据:找到直接路径到推荐节点ID: ${nextTargetId}`); - break; - } else { - // 检查这个中间节点是否能通向推荐的目标节点 - const intermediateNodeIdStr = nextNodeId.toString(); - const intermediateNextTargets = sequentialEdges[intermediateNodeIdStr]; - - if (intermediateNextTargets && intermediateNextTargets.includes(nextTargetId)) { - selectedRoute = nextRoute.route; - selectedNodeId = nextNodeId; - log.info(`使用顺序边缘数据:找到通过中间节点ID ${nextNodeId} 到达推荐节点ID ${nextTargetId} 的路径`); - break; - } - } - } - } - } + const distance = calculate2DDistance( + leyLineX, leyLineY, + nextNode.position.x, nextNode.position.y + ); - // 如果顺序边缘数据没有找到合适的路径,回退到距离计算 - if (!selectedRoute) { - log.info("顺序边缘数据未找到合适路径,使用距离计算方法选择路径"); - - let closestDistance = Infinity; for (const nextRoute of currentNode.next) { - const nextNodeId = nextRoute.target; - const nextNode = nodeData.node.find(node => node.id === nextNodeId); + log.info(`分支节点ID ${nextNodeId} 到地脉花距离: ${distance.toFixed(2)}`); - if (!nextNode) continue; - - const distance = calculate2DDistance( - leyLineX, leyLineY, - nextNode.position.x, nextNode.position.y - ); - - log.info(`路线到地脉花距离: ID ${nextNodeId}, 距离: ${distance.toFixed(2)}`); - - if (distance < closestDistance) { - closestDistance = distance; - selectedRoute = nextRoute.route; - selectedNodeId = nextNodeId; - } + if (distance < closestDistance) { + closestDistance = distance; + selectedRoute = nextRoute.route; + selectedNodeId = nextNodeId; } } @@ -155,7 +116,8 @@ async function (position) { leyLineX = currentLeyLineX; leyLineY = currentLeyLineY; return; - } const nextNode = nodeData.node.find(node => node.id === selectedNodeId); + } + const nextNode = nodeData.node.find(node => node.id === selectedNodeId); if (!nextNode) { log.error(`未找到节点ID ${selectedNodeId},终止执行`); // 恢复原始坐标 @@ -175,7 +137,7 @@ async function (position) { await executePath(pathObject); currentRunTimes++; - + log.info(`完成节点 ID ${nextNodeId}, 已执行 ${currentRunTimes}/${settings.timesValue} 次`); // 更新当前节点为下一个节点,继续检查 currentNode = nextNode; currentNodePosition = { x: nextNode.position.x, y: nextNode.position.y }; diff --git a/repo/js/AutoLeyLineOutcrop/utils/executePathsUsingSeparatedNodeData.js b/repo/js/AutoLeyLineOutcrop/utils/executePathsUsingSeparatedNodeData.js deleted file mode 100644 index e69de29b..00000000