From e958418821b36ef4596fd1443166d3944534bcc8 Mon Sep 17 00:00:00 2001 From: Colin Xu <127581131+ColinXHL@users.noreply.github.com> Date: Sat, 18 Oct 2025 11:05:27 +0800 Subject: [PATCH] =?UTF-8?q?[AutoLeyLineOutcrop]=E5=AE=8C=E5=96=84=E5=88=A9?= =?UTF-8?q?=E7=94=A8=E5=86=92=E9=99=A9=E4=B9=8B=E5=BE=81=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E5=9C=B0=E8=84=89=E8=8A=B1=E5=8F=8A=E9=A1=BB=E8=87=BE=E6=A0=91?= =?UTF-8?q?=E8=84=82=E4=BD=BF=E7=94=A8=E5=8F=98=E4=B8=BA=E5=8F=AF=E9=80=89?= =?UTF-8?q?=E9=A1=B9=20(#2162)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- repo/js/AutoLeyLineOutcrop/README.md | 2 + repo/js/AutoLeyLineOutcrop/manifest.json | 2 +- repo/js/AutoLeyLineOutcrop/settings.json | 20 +- .../AutoLeyLineOutcrop/utils/attemptReward.js | 8 +- .../utils/findLeyLineOutcropByBook.js | 174 ++++++++++++------ 5 files changed, 142 insertions(+), 64 deletions(-) diff --git a/repo/js/AutoLeyLineOutcrop/README.md b/repo/js/AutoLeyLineOutcrop/README.md index 3284d6cc7..a61e8a068 100644 --- a/repo/js/AutoLeyLineOutcrop/README.md +++ b/repo/js/AutoLeyLineOutcrop/README.md @@ -52,6 +52,8 @@ - 适配新的奖励领取界面 - 修复挪德卡莱识别错误及通过冒险之证寻找地脉花总会选择挪德卡莱的bug - 修复卡在奖励领取界面无法执行其他配置的bug +- 优化冒险之征寻找地脉花的逻辑 +- 新增是否使用须臾树脂配置选项 ### 4.2 - 新增挪德卡莱区域 ### 4.1 diff --git a/repo/js/AutoLeyLineOutcrop/manifest.json b/repo/js/AutoLeyLineOutcrop/manifest.json index eb2570b4d..6e9df593a 100644 --- a/repo/js/AutoLeyLineOutcrop/manifest.json +++ b/repo/js/AutoLeyLineOutcrop/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 1, "name": "全自动地脉花", - "version": "4.3.2", + "version": "4.3.3", "tags": ["地脉花"], "bgi_version": "0.44.7", "description": "基于OCR图像识别的全自动刷取地脉花。\n💡更多信息请查看在线手册:https://hcnsvf0s8d0s.feishu.cn/wiki/Tb1twpThLi7UlykqcYOcuccTnjJ \n\n----------注意事项----------\n●仅支持BetterGI 0.44.7 及以上版本!\n●部分地脉花因特殊原因不支持全自动,具体的点位请在手册中查看。\n●树脂使用的优先级:2倍原粹树脂 > 浓缩树脂 > 原粹树脂。\n●运行时会传送到七天神像设置中设置的七天神像,需要关闭七天神像设置中的“是否就近七天神像恢复血量”,并指定七天神像。\n●战斗策略注意调度器设置中地图追踪行走配置里的“允许在JsSpript中使用”和“覆盖JS中的自动战斗配置”,只有在都打开的情况下脚本才会使用下面的战斗配置,否则会使用独立任务中的战斗策略。战斗超时时间不能大于脚本自定义配置中的时间。\n\n如果遇到问题,请先参照手册中的方法进行解决。", diff --git a/repo/js/AutoLeyLineOutcrop/settings.json b/repo/js/AutoLeyLineOutcrop/settings.json index 306bd90fe..8aacaa40a 100644 --- a/repo/js/AutoLeyLineOutcrop/settings.json +++ b/repo/js/AutoLeyLineOutcrop/settings.json @@ -34,6 +34,12 @@ "label": "刷取次数,默认6次", "default": "6" }, + { + "name": "useTransientResin", + "type": "checkbox", + "label": "是否使用须臾树脂\n开启后会在原粹/浓缩树脂用完后使用", + "default": false + }, { "name": "useFragileResin", "type": "checkbox", @@ -59,7 +65,7 @@ { "name": "useAdventurerHandbook", "type": "checkbox", - "label": "是否使用冒险之证寻找地脉花\n【测试中】" + "label": "是否使用冒险之证寻找地脉花" }, { "name": "isNotification", @@ -70,12 +76,12 @@ "name": "isRecognizeResin", "type": "checkbox", "label": "树脂耗尽模式\n开启后脚本会在树脂耗尽时停止运行【开发中】" - }, - { - "name": "isGoToSynthesizer", - "type": "select", - "label": "是否前往合成台合成浓缩树脂\n 体力大于40时自动合成浓缩树脂【开发中】" - } + }, + { + "name": "isGoToSynthesizer", + "type": "select", + "label": "是否前往合成台合成浓缩树脂\n 体力大于40时自动合成浓缩树脂【开发中】" + } ] diff --git a/repo/js/AutoLeyLineOutcrop/utils/attemptReward.js b/repo/js/AutoLeyLineOutcrop/utils/attemptReward.js index 872b02687..f4e0d7ca0 100644 --- a/repo/js/AutoLeyLineOutcrop/utils/attemptReward.js +++ b/repo/js/AutoLeyLineOutcrop/utils/attemptReward.js @@ -279,7 +279,7 @@ async function analyzeResinOptions(sortedButtons, isOriginalResinEmpty) { button: sortedButtons[0], buttonIndex: 0 }; - } else if (hasTransientResin && sortedButtons.length >= 1) { + } else if (hasTransientResin && sortedButtons.length >= 1 && settings.useTransientResin) { choice = { type: "使用1个须臾树脂(原粹耗尽)", button: sortedButtons[0], @@ -293,7 +293,9 @@ async function analyzeResinOptions(sortedButtons, isOriginalResinEmpty) { }; } else { // 输出详细的调试信息 - if (hasFragileResin && !settings.useFragileResin) { + if (hasTransientResin && !settings.useTransientResin) { + log.warn(`原粹树脂耗尽,检测到须臾树脂但配置禁止使用(settings.useTransientResin=${settings.useTransientResin})`); + } else if (hasFragileResin && !settings.useFragileResin) { log.warn(`原粹树脂耗尽,检测到脆弱树脂但配置禁止使用(settings.useFragileResin=${settings.useFragileResin})`); } else { log.warn(`原粹树脂耗尽且无其他可用树脂(浓缩:${hasCondensedResin}, 须臾:${hasTransientResin}, 脆弱:${hasFragileResin}, 原石:${hasPrimogems})`); @@ -340,7 +342,7 @@ async function analyzeResinOptions(sortedButtons, isOriginalResinEmpty) { }; } // 优先级3: 使用须臾树脂 - else if (hasTransientResin && sortedButtons.length >= 2) { + else if (hasTransientResin && settings.useTransientResin && sortedButtons.length >= 2) { choice = { type: "使用1个须臾树脂", button: sortedButtons[1], diff --git a/repo/js/AutoLeyLineOutcrop/utils/findLeyLineOutcropByBook.js b/repo/js/AutoLeyLineOutcrop/utils/findLeyLineOutcropByBook.js index 88c949ceb..bff824ef6 100644 --- a/repo/js/AutoLeyLineOutcrop/utils/findLeyLineOutcropByBook.js +++ b/repo/js/AutoLeyLineOutcrop/utils/findLeyLineOutcropByBook.js @@ -5,81 +5,149 @@ * @returns {Promise} */ this.findLeyLineOutcropByBook = async function (country, type) { - // 挪德卡莱会被识别成挪德卡菜,需要特殊处理 - if (country === "挪德卡莱") { - country = "挪德卡"; - } - await genshin.returnMainUi(); await sleep(1000); log.info("使用冒险之证寻找地脉花"); - //确保运行时位于主界面 + + // 确保运行时位于主界面 keyPress("F1"); await sleep(1000); - click(300, 550); //点击讨伐 + click(300, 550); // 点击讨伐 await sleep(1000); - click(500, 200); //点击筛选 + click(500, 200); // 点击筛选 await sleep(1000); - click(500, 500); //点击其他 + click(500, 500); // 点击其他 await sleep(1000); + + // 选择地脉花类型 if (type === "蓝花(经验书)") { - click(700, 350); //点击经验花 + click(700, 350); // 点击经验花 } else { - click(500, 350); //点击摩拉花 + click(500, 350); // 点击摩拉花 } await sleep(1000); - click(1300, 800); //点击推荐 + click(1300, 800); // 点击推荐 await sleep(1000); - let captureRegion1 = captureGameRegion(); - let resList = captureRegion1.findMulti(ocrRoThis); - captureRegion1.dispose(); - for (let i = 0; i < resList.count; i++) { - let res = resList[i]; - if (res.text.includes(country)) { - res.click(); - } - } + + // 查找并点击指定国家 + await this.findAndClickCountry(country); + + // 查找并点击停止追踪按钮 + await this.findAndCancelTrackingInBook(); + await sleep(1000); - let captureRegion2 = captureGameRegion(); - let resList2 = captureRegion2.findMulti(ocrRoThis); - captureRegion2.dispose(); - for (let i = 0; i < resList2.count; i++) { - let res = resList2[i]; - if (res.text.includes("停止追踪")) { - res.click(); - await sleep(1000); - } - } click(1500, 850); - click(1500, 850); //点击追踪,连点两次防止点不到 await sleep(1000); - //获取地脉花位置 + + // 获取地脉花位置 const center = genshin.getPositionFromBigMap(); leyLineX = center.x; leyLineY = center.y; log.info(`找到地脉花的坐标:(${leyLineX}, ${leyLineY})`); // 取消追踪 - click(960, 540); - await sleep(1000); - let captureRegion3 = captureGameRegion(); - let zhuizong = captureRegion3.findMulti(ocrRoThis); - captureRegion3.dispose(); - if (zhuizong && zhuizong.count > 0) { - for (let i = 0; i < zhuizong.count; i++) { - if (zhuizong[i].text.includes("停止追踪")) { - zhuizong[i].click(); - log.debug("点击取消追踪"); - await sleep(1000); - return; - } else if (zhuizong[i].text.includes("地脉") || zhuizong[i].text.includes("衍出")) { - zhuizong[i].click(); - await sleep(1000); - click(1700, 1010); - log.debug("点击取消追踪"); - await sleep(1000); + await this.cancelTrackingInMap(); +}; + +/** + * 查找并点击指定国家 + * @param {string} country - 国家名称 + * @private + */ +this.findAndClickCountry = async function (country) { + // 挪德卡莱会被识别成挪德卡菜,需要特殊处理 + let match_country = country; + if (country === "挪德卡莱") { + match_country = "挪德卡"; + } + let captureRegion = captureGameRegion(); + try { + let resList = captureRegion.findMulti(ocrRoThis); + let found = false; + for (let i = 0; i < resList.count; i++) { + let res = resList[i]; + if (res.text.includes(match_country)) { + res.click(); + found = true; + break; } } + if (!found) { + // 没找到国家 + throw new Error("冒险之征中未找到国家:" + country + ",请检查该国家地图是否开启"); + } + } finally { + captureRegion.dispose(); } - return center; -} \ No newline at end of file +}; + +/** + * 在冒险之征中查找并点击停止追踪按钮 + * @private + */ +this.findAndCancelTrackingInBook = async function () { + let captureRegion = captureGameRegion(); + try { + let resList = captureRegion.findMulti(ocrRoThis); + let stop = null; + for (let i = 0; i < resList.count; i++) { + let res = resList[i]; + if (res.text.includes("停止")) { + stop = res; + break; + } + } + + if(stop) { + log.info("冒险之征中点击停止追踪并重新追踪获取坐标"); + stop.click(); + } else { + log.info("冒险之征中无需取消追踪"); + } + } finally { + captureRegion.dispose(); + } + await sleep(1000); +}; + +/** + * 在地图中取消地脉花追踪 + * @private + */ +this.cancelTrackingInMap = async function () { + // 点击地脉花(因为从书点击追踪后花会在屏幕正中间) + click(960, 540); + await sleep(1000); + + let captureRegion = captureGameRegion(); + let stop = null; + let leyLine = null; + + try { + let resList = captureRegion.findMulti(ocrRoThis); + if (resList && resList.count > 0) { + for (let i = 0; i < resList.count; i++) { + let res = resList[i]; + if (res.text.includes("停止")) { + stop = res; + } else if (res.text.includes("地脉") || res.text.includes("衍出")) { + leyLine = res; + } + } + } + } finally { + captureRegion.dispose(); + } + + + if (stop) { + log.info("地图中点击取消追踪"); + stop.click(); + } else if (leyLine) { + log.info("在地图中选择地脉花后点击取消追踪"); + leyLine.click(); + await sleep(1000); + click(1700, 1010); + await sleep(1000); + } +}; \ No newline at end of file