fix: 清泉镇修复,分支路线逻辑修复
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
"x": -547.37,
|
||||
"y": 1829.88,
|
||||
"type": "path",
|
||||
"move_mode": "fly",
|
||||
"move_mode": "jump",
|
||||
"action": "",
|
||||
"action_params": ""
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user