From 338312feec072735a99d4a30a9d9b5e54a8395a0 Mon Sep 17 00:00:00 2001 From: Colin Xu <127581131+ColinXHL@users.noreply.github.com> Date: Sat, 18 Oct 2025 18:16:29 +0800 Subject: [PATCH] =?UTF-8?q?[AutoLeyLineOutcrop]=E4=BF=AE=E5=A4=8D=E5=BC=80?= =?UTF-8?q?=E4=B9=A6=E6=88=96=E8=80=85=E5=85=B3=E4=B9=A6=E6=97=B6=E7=AD=89?= =?UTF-8?q?=E5=BE=85=E6=97=B6=E9=97=B4=E8=BF=87=E7=9F=AD=E5=81=B6=E7=8E=B0?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=AD=A3=E7=A1=AE=E9=80=89=E6=8B=A9=E5=9C=B0?= =?UTF-8?q?=E8=84=89=E8=8A=B1=E6=88=96=E6=89=93=E5=BC=80=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20(#2168)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [AutoLeyLineOutcrop]修复开书或者关书时等待时间过短偶现无法正确选择地脉花或打开地图的问题 * update manifest.json --- .../assets/icon/map_setting_button.bmp | Bin 0 -> 3382 bytes repo/js/AutoLeyLineOutcrop/manifest.json | 2 +- .../utils/findLeyLineOutcropByBook.js | 56 ++++++++++++++++-- 3 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 repo/js/AutoLeyLineOutcrop/assets/icon/map_setting_button.bmp diff --git a/repo/js/AutoLeyLineOutcrop/assets/icon/map_setting_button.bmp b/repo/js/AutoLeyLineOutcrop/assets/icon/map_setting_button.bmp new file mode 100644 index 0000000000000000000000000000000000000000..6460289afbb0da7622ba03ee2c92605408050cd1 GIT binary patch literal 3382 zcmchaPiqrF7{=ER;N7Em@)Pu;pw!w!)k6;!g`$*_gMz3~=s^Sz9t~KrSiA`(Hvei+ zD2N9sO05;`pGdMv+9s{p-AI$}!7t#inRb}&Y?ciq3A4+)?>z7G%)B$R`=*Icw>kQXvt`o*7?)(n>#e=wS*7i-iZdzSvcBA09r9ZXVw{gQLSdFfT91OgXcib(< z&2Lu?BUohVS2h-#Tgeu5*!K;SE&zI$@GyfCB92?GxqdqN>K<)*J@<0z`St#Dw9zY< z-!FX3?fw;A7(C(>y}$sAE+5Tmy=XOB=%nT|k&$6Rb0{@5FnRCp>zNrE#^}(1+6$Nv zq3mxJdUNoiN)yH=gur%mo<4pQhFHfC=&OU%Z$8O%M&}6QAuzNKIsUw~ z5{6aB5ZG#owD|y>iaygh!gyXpqoH-yN;_l2S3RsFm(D*Jznx6K%a*OxLM5I|Ka7mw z^uP!t+&6W{=kskn_hfRyLqPOgBKf;ws{}m86DiM#2qYX56)Ef^oz-IH)%3JHdUBwI zBI273oOF2xMIai@TXhZ8jqq6FDJ30Y*OQhy? zZq)-oorbji@)ocUI5xri0D$CH4Q(HY!F7LMt4Rnrr@RSNB##`P_Rp#0Acvl4vcX}z zKYoj)VAW|DJnAQuK*A-JY8<@}q>r7*>rl;fc$*in+{ltp7=AiE`7R*elkXflz4~r< zybfXP+WO#QEjwFRwbntZV|AicFWSC!BJ#3{x|b4HdZa-y99;JbB-QVxvrirGG)$XP pzAM!{6)z&@4t4zY-aoThZOegnz~GOLeUPrQ;}& 浓缩树脂 > 原粹树脂。\n●运行时会传送到七天神像设置中设置的七天神像,需要关闭七天神像设置中的“是否就近七天神像恢复血量”,并指定七天神像。\n●战斗策略注意调度器设置中地图追踪行走配置里的“允许在JsSpript中使用”和“覆盖JS中的自动战斗配置”,只有在都打开的情况下脚本才会使用下面的战斗配置,否则会使用独立任务中的战斗策略。战斗超时时间不能大于脚本自定义配置中的时间。\n\n如果遇到问题,请先参照手册中的方法进行解决。", diff --git a/repo/js/AutoLeyLineOutcrop/utils/findLeyLineOutcropByBook.js b/repo/js/AutoLeyLineOutcrop/utils/findLeyLineOutcropByBook.js index bff824ef6..f6e0e1cf3 100644 --- a/repo/js/AutoLeyLineOutcrop/utils/findLeyLineOutcropByBook.js +++ b/repo/js/AutoLeyLineOutcrop/utils/findLeyLineOutcropByBook.js @@ -1,5 +1,8 @@ +// 齿轮图标识别对象 +const mapSettingButtonRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/icon/map_setting_button.bmp")); + /** - * 通过冒险之证查找地脉花位置 - 【测试中】 + * 通过冒险之证查找地脉花位置 * @param {string} country - 国家名称 * @param {string} type - 地脉花类型 * @returns {Promise} @@ -11,7 +14,8 @@ this.findLeyLineOutcropByBook = async function (country, type) { // 确保运行时位于主界面 keyPress("F1"); - await sleep(1000); + // 开书等待时间延长至2.5s + await sleep(2500); click(300, 550); // 点击讨伐 await sleep(1000); click(500, 200); // 点击筛选 @@ -35,10 +39,28 @@ this.findLeyLineOutcropByBook = async function (country, type) { // 查找并点击停止追踪按钮 await this.findAndCancelTrackingInBook(); - await sleep(1000); - click(1500, 850); - await sleep(1000); - + // 最多重试3次确保大地图正确打开 + for (let retry = 0; retry < 3; retry++) { + await sleep(1000); + click(1500, 850); + // 等待大地图打开延长至 2.5s + await sleep(2500); + + if (await this.checkBigMapOpened()) { + log.info("识别到大地图"); + break; // 成功打开大地图 + } + + if (retry < 2) { // 不是最后一次重试 + log.info(`大地图未正确打开,第${retry + 1}次重试...`); + await genshin.returnMainUi(); + await this.findAndClickCountry(country); + await this.findAndCancelTrackingInBook(); + } else { + throw new Error("大地图打开失败,已重试3次"); + } + } + // 获取地脉花位置 const center = genshin.getPositionFromBigMap(); leyLineX = center.x; @@ -49,6 +71,28 @@ this.findLeyLineOutcropByBook = async function (country, type) { await this.cancelTrackingInMap(); }; +/** + * 检测大地图是否正确打开(通过检测齿轮图标) + * @returns {Promise} 返回是否检测到齿轮图标 + * @private + */ +this.checkBigMapOpened = async function() { + let captureRegion = captureGameRegion(); + try { + // 只在左下角十六分之一区域查找齿轮图标(提高识别效率和准确性) + const searchWidth = genshin.width / 4; + const searchHeight = genshin.height / 4; + const searchX = 0; + const searchY = genshin.height - searchHeight; + + let croppedRegion = captureRegion.DeriveCrop(searchX, searchY, searchWidth, searchHeight); + let result = croppedRegion.Find(mapSettingButtonRo); + return !result.isEmpty(); + } finally { + captureRegion.dispose(); + } +}; + /** * 查找并点击指定国家 * @param {string} country - 国家名称