fix: 清泉镇修复,分支路线逻辑修复
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
"x": -547.37,
|
"x": -547.37,
|
||||||
"y": 1829.88,
|
"y": 1829.88,
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"move_mode": "fly",
|
"move_mode": "jump",
|
||||||
"action": "",
|
"action": "",
|
||||||
"action_params": ""
|
"action_params": ""
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -32,8 +32,8 @@
|
|||||||
"y": 1954.13,
|
"y": 1954.13,
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"move_mode": "walk",
|
"move_mode": "walk",
|
||||||
"action": "",
|
"action": "combat_script",
|
||||||
"action_params": ""
|
"action_params": "wait(1.0)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 4,
|
"id": 4,
|
||||||
|
|||||||
@@ -2,64 +2,41 @@
|
|||||||
"info": {
|
"info": {
|
||||||
"name": "蒙德2-清泉镇-4-1",
|
"name": "蒙德2-清泉镇-4-1",
|
||||||
"type": "collect",
|
"type": "collect",
|
||||||
"author": "ddaodan",
|
"author": "秋云",
|
||||||
"version": "1.1",
|
"version": "1.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"bgi_version": "0.42.3"
|
"map_name": "Teyvat",
|
||||||
|
"bgi_version": "0.45.0",
|
||||||
|
"tags": [],
|
||||||
|
"last_modified_time": 1749595981247
|
||||||
},
|
},
|
||||||
"positions": [
|
"positions": [
|
||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"action": "",
|
"x": -401.35,
|
||||||
"move_mode": "walk",
|
"y": 1976.93,
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"x": -524.25,
|
"move_mode": "walk",
|
||||||
"y": 1816.41,
|
"action": "",
|
||||||
"action_params": ""
|
"action_params": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"x": -489.69,
|
"x": -349.19,
|
||||||
"y": 1839.69,
|
"y": 1939.59,
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"move_mode": "walk",
|
"move_mode": "fly",
|
||||||
"action": "",
|
"action": "stop_flying",
|
||||||
"action_params": ""
|
"action_params": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 3,
|
"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,
|
"x": -347.95,
|
||||||
"y": 1902.51,
|
"y": 1902.51,
|
||||||
"type": "path",
|
"action": "",
|
||||||
"move_mode": "fly",
|
"move_mode": "dash",
|
||||||
"action": "stop_flying"
|
"action_params": "",
|
||||||
|
"type": "path"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,8 @@ async function (position) {
|
|||||||
log.info(`完成节点 ID ${nextNodeId}, 已执行 ${currentRunTimes}/${settings.timesValue} 次`); // 更新当前节点为下一个节点,继续检查
|
log.info(`完成节点 ID ${nextNodeId}, 已执行 ${currentRunTimes}/${settings.timesValue} 次`); // 更新当前节点为下一个节点,继续检查
|
||||||
currentNode = nextNode;
|
currentNode = nextNode;
|
||||||
currentNodePosition = { x: nextNode.position.x, y: nextNode.position.y };
|
currentNodePosition = { x: nextNode.position.x, y: nextNode.position.y };
|
||||||
} else if (currentNode.next.length > 1) {
|
}
|
||||||
|
else if (currentNode.next.length > 1) {
|
||||||
// 如果存在分支路线,先打开大地图判断下一个地脉花的位置,然后结合顺序边缘数据选择最优路线
|
// 如果存在分支路线,先打开大地图判断下一个地脉花的位置,然后结合顺序边缘数据选择最优路线
|
||||||
log.info("检测到多个分支路线,开始查找下一个地脉花位置");
|
log.info("检测到多个分支路线,开始查找下一个地脉花位置");
|
||||||
|
|
||||||
@@ -82,70 +83,30 @@ async function (position) {
|
|||||||
log.warn("无法在分支点找到下一个地脉花,退出本次循环");
|
log.warn("无法在分支点找到下一个地脉花,退出本次循环");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(`找到下一个地脉花,位置: (${leyLineX}, ${leyLineY})`);
|
log.info(`找到下一个地脉花,位置: (${leyLineX}, ${leyLineY})`);
|
||||||
|
|
||||||
// 优先使用顺序边缘数据来选择路径,如果没有则回退到距离计算
|
// 直接比较所有分支节点到地脉花的距离,选择最近的路径
|
||||||
const sequentialEdges = nodeData.indexes?.edgesBySource;
|
|
||||||
let selectedRoute = null;
|
let selectedRoute = null;
|
||||||
let selectedNodeId = null;
|
let selectedNodeId = null;
|
||||||
|
let closestDistance = Infinity;
|
||||||
|
|
||||||
if (sequentialEdges) {
|
for (const nextRoute of currentNode.next) {
|
||||||
const currentNodeIdStr = currentNode.id.toString();
|
const nextNodeId = nextRoute.target;
|
||||||
const nextTargetIds = sequentialEdges[currentNodeIdStr];
|
const nextNode = nodeData.node.find(node => node.id === nextNodeId);
|
||||||
|
|
||||||
if (nextTargetIds && nextTargetIds.length > 0) {
|
if (!nextNode) continue;
|
||||||
const nextTargetId = nextTargetIds[0];
|
|
||||||
log.info(`从顺序边缘数据中找到推荐的下一个目标节点ID: ${nextTargetId}`);
|
|
||||||
|
|
||||||
// 在当前节点的分支中查找通向推荐目标节点的路径
|
const distance = calculate2DDistance(
|
||||||
for (const nextRoute of currentNode.next) {
|
leyLineX, leyLineY,
|
||||||
const nextNodeId = nextRoute.target;
|
nextNode.position.x, nextNode.position.y
|
||||||
|
);
|
||||||
|
|
||||||
// 检查这个路径是否通向推荐的目标节点(直接匹配或通过后续路径)
|
log.info(`分支节点ID ${nextNodeId} 到地脉花距离: ${distance.toFixed(2)}`);
|
||||||
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)) {
|
if (distance < closestDistance) {
|
||||||
selectedRoute = nextRoute.route;
|
closestDistance = distance;
|
||||||
selectedNodeId = nextNodeId;
|
selectedRoute = nextRoute.route;
|
||||||
log.info(`使用顺序边缘数据:找到通过中间节点ID ${nextNodeId} 到达推荐节点ID ${nextTargetId} 的路径`);
|
selectedNodeId = nextNodeId;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果顺序边缘数据没有找到合适的路径,回退到距离计算
|
|
||||||
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);
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +116,8 @@ async function (position) {
|
|||||||
leyLineX = currentLeyLineX;
|
leyLineX = currentLeyLineX;
|
||||||
leyLineY = currentLeyLineY;
|
leyLineY = currentLeyLineY;
|
||||||
return;
|
return;
|
||||||
} const nextNode = nodeData.node.find(node => node.id === selectedNodeId);
|
}
|
||||||
|
const nextNode = nodeData.node.find(node => node.id === selectedNodeId);
|
||||||
if (!nextNode) {
|
if (!nextNode) {
|
||||||
log.error(`未找到节点ID ${selectedNodeId},终止执行`);
|
log.error(`未找到节点ID ${selectedNodeId},终止执行`);
|
||||||
// 恢复原始坐标
|
// 恢复原始坐标
|
||||||
@@ -175,7 +137,7 @@ async function (position) {
|
|||||||
|
|
||||||
await executePath(pathObject);
|
await executePath(pathObject);
|
||||||
currentRunTimes++;
|
currentRunTimes++;
|
||||||
|
log.info(`完成节点 ID ${nextNodeId}, 已执行 ${currentRunTimes}/${settings.timesValue} 次`);
|
||||||
// 更新当前节点为下一个节点,继续检查
|
// 更新当前节点为下一个节点,继续检查
|
||||||
currentNode = nextNode;
|
currentNode = nextNode;
|
||||||
currentNodePosition = { x: nextNode.position.x, y: nextNode.position.y };
|
currentNodePosition = { x: nextNode.position.x, y: nextNode.position.y };
|
||||||
|
|||||||
Reference in New Issue
Block a user