From 7305f0d97dbdc2e1f7ea2da79357bd4c94d0d441 Mon Sep 17 00:00:00 2001 From: kaedelcb <57870068+kaedelcb@users.noreply.github.com> Date: Thu, 28 Aug 2025 13:03:12 +0800 Subject: [PATCH] =?UTF-8?q?=20v.1.9=E7=89=88=E6=9C=AC=20=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=B9=BD=E5=A2=83=E5=8D=B1=E6=88=98=2020250828=20(#1743)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * v.1.9版本 自动幽境危战 20250828 ### v.1.9版本:20250828 - **优化**: 1. 优化内存释放。 2. 优化JS设置显示。 * 修复README文字 修复README文字 --- repo/js/AutoStygianOnslaught/README.md | 13 ++- repo/js/AutoStygianOnslaught/main.js | 25 ++++- repo/js/AutoStygianOnslaught/manifest.json | 34 +++--- repo/js/AutoStygianOnslaught/settings.json | 121 +++++++++++---------- 4 files changed, 109 insertions(+), 84 deletions(-) diff --git a/repo/js/AutoStygianOnslaught/README.md b/repo/js/AutoStygianOnslaught/README.md index 63541b199..9b0bb1a42 100644 --- a/repo/js/AutoStygianOnslaught/README.md +++ b/repo/js/AutoStygianOnslaught/README.md @@ -9,12 +9,8 @@ 1. **使用前准备**: - 请在`<<幽境危战>>`中配置好战斗队伍。 -2. **黑名单建议**: - - 根目录下有文件内含建议加入`自动拾取黑名单`的名称,请检查并添加。 3. **战斗实力**: - 请确保队伍具备足够的战斗实力,当前版本在战斗失败或执行错误,只会重试`一次`。 -4. **自动拾取功能**: - - 为避免不必要的干扰,建议关闭自动拾取功能。 ## 二、配置简介 @@ -44,6 +40,15 @@ ## 三、更新说明 + +### v.1.9版本:20250828 + +- **新功能**: + +- **优化**: +1. 优化内存释放。 +2. 优化JS设置显示。 + ### v.1.8版本:20250809 - **新功能**: diff --git a/repo/js/AutoStygianOnslaught/main.js b/repo/js/AutoStygianOnslaught/main.js index 2870bce3f..313cd6f55 100644 --- a/repo/js/AutoStygianOnslaught/main.js +++ b/repo/js/AutoStygianOnslaught/main.js @@ -84,18 +84,24 @@ res1=res.text if (res.text===wenzi) { log.info(`识别到 ·${res1}·`); - if (debugcode===1){if (x===0 & y===0){log.info("全图代码位置:({x},{y},{h},{w})", res.x-10, res.y-10, res.width+10, res.Height+10);return result = { text: res.text, x: res.x, y: res.y, found: true }}}else{if (x===0 & y===0){log.info("文本OCR完成'{text}'", res.text);}} + if (debugcode===1){if (x===0 & y===0){log.info("全图代码位置:({x},{y},{h},{w})", res.x-10, res.y-10, res.width+10, res.Height+10); + captureRegion.dispose(); + return result = { text: res.text, x: res.x, y: res.y, found: true }}}else{if (x===0 & y===0){log.info("文本OCR完成'{text}'", res.text);}} if (clickocr===1){await sleep(1000);await click(res.x, res.y);}else{} if (clickocr===2){await sleep(100);await keyPress("F");}else{} + captureRegion.dispose(); return result = { text: res.text, x: res.x, y: res.y, found: true } } if (debugcode===2 && !res.isEmpty()){ // log.info("({x},{y},{h},{w})", res.x-10, res.y-10, res.width+10, res.Height+10); + captureRegion.dispose(); return result = { text: res.text, x: res.x, y: res.y, found: true } } } const NowTime = new Date(); - if (Math.abs(NowTime - startTime)>chaotime*1000){if (x===0 & y===0){log.info(`${chaotime}秒超时退出,"${wenzi}"未找到`);}return result = {found: false };}else{ii=8;if (x !== 861){if(debugcode!==3){await keyPress("VK_W");}};} + if (Math.abs(NowTime - startTime)>chaotime*1000){if (x===0 & y===0){log.info(`${chaotime}秒超时退出,"${wenzi}"未找到`);} + captureRegion.dispose(); + return result = {found: false };}else{ii=8;if (x !== 861){if(debugcode!==3){await keyPress("VK_W");}};} await sleep(100); } } @@ -113,11 +119,13 @@ if (afterBehavior===1){if (xa===0 & ya===0){log.info("点击模式:开");}await sleep(1000);click(res.x+xa, res.y+ya);}else{if (debugmodel===1 & xa===0 & ya===0){log.info("点击模式:关")}} if (afterBehavior===2){if (xa===0 & ya===0){log.info("F模式:开");}await sleep(1000);keyPress("F");}else{if (debugmodel===1 & xa===0 & ya===0){log.info("F模式:关")}} if (debugmodel===1 & xa===0 & ya===0){log.info("全图代码位置:({x},{y},{h},{w})", res.x+xa, res.y+ya, res.width, res.Height);}else{ log.info("识别到页面元素");} - + captureRegion.dispose(); return result = { x: res.x+xa, y: res.y+ya, w:res.width,h:res.Height,found: true } } const NowTime = new Date(); - if ((NowTime - startTime)>timeout*1000){if (debugmodel===1 & xa===0 & ya===0){log.info(`${timeout}秒超时退出,未找到图片`);}return result = {found: false };}else{ii=8} + if ((NowTime - startTime)>timeout*1000){if (debugmodel===1 & xa===0 & ya===0){log.info(`${timeout}秒超时退出,未找到图片`);} + captureRegion.dispose(); + return result = {found: false };}else{ii=8} await sleep(200); } await sleep(1200); @@ -254,6 +262,8 @@ // 检测到特点文字则结束!!! if (rewardResult.text.includes("之花") || rewardResult.text.includes("激活")) { log.info("已到达领奖点,检测到文字: " + rewardResult.text); + captureRegion.dispose(); + rewardTextArea.dispose(); return true; } else if(advanceNum > 40){ @@ -286,10 +296,12 @@ verticalNum = 0; await getOut(); await await genshin.returnMainUi(); + captureRegion.dispose(); throw new Error('领取超时'); } log.info("领取超时,重新尝试1次"); await sleep(1000); + captureRegion.dispose(); return false; } } @@ -362,6 +374,7 @@ if (text.includes(keyword)) { log.info("检测到战斗成功关键词: {0}", keyword); resolve(true); + captureRegion.dispose(); return; } } @@ -371,11 +384,13 @@ if (text2.includes(keyword)) { log.warn("检测到战斗失败关键词: {0}", keyword); resolve(false); + captureRegion.dispose(); return; } } } catch (error) { + captureRegion.dispose(); log.error("OCR过程中出错: {0}", error); } @@ -576,7 +591,7 @@ } - log.warn("自动幽境危战版本:v1.8"); + log.warn("自动幽境危战版本:v1.9"); log.warn("请保证队伍战斗实力,战斗失败或执行错误,会重试两次..."); log.warn("使用前请在 <<幽境危战>> 中配置好战斗队伍..."); log.info("使用树脂类型数量:{0} ", rewards.length) diff --git a/repo/js/AutoStygianOnslaught/manifest.json b/repo/js/AutoStygianOnslaught/manifest.json index fa433b9a5..179e20b3b 100644 --- a/repo/js/AutoStygianOnslaught/manifest.json +++ b/repo/js/AutoStygianOnslaught/manifest.json @@ -1,18 +1,18 @@ -{ - "manifest_version": 1, - "name": "自动幽境危战", - "version": "1.7", - "tags": [ - "幽境危战" - ], - "bgi_version": "0.44.8", - "description": "请先配置好秘境内的队伍,幽境危战战斗失败或执行错误会重试一次,请保证队伍实力", - "authors": [ - { - "name": "LCB-茶包", - "links": "https://github.com/kaedelcb" - } - ], - "settings_ui": "settings.json", - "main": "main.js" +{ + "manifest_version": 1, + "name": "自动幽境危战", + "version": "1.9", + "tags": [ + "幽境危战" + ], + "bgi_version": "0.44.8", + "description": "请先配置好秘境内的队伍,幽境危战战斗失败或执行错误会重试一次,请保证队伍实力", + "authors": [ + { + "name": "LCB-茶包", + "links": "https://github.com/kaedelcb" + } + ], + "settings_ui": "settings.json", + "main": "main.js" } \ No newline at end of file diff --git a/repo/js/AutoStygianOnslaught/settings.json b/repo/js/AutoStygianOnslaught/settings.json index ece7dafd8..6f466e3b9 100644 --- a/repo/js/AutoStygianOnslaught/settings.json +++ b/repo/js/AutoStygianOnslaught/settings.json @@ -1,58 +1,63 @@ -[ -{ - "name": "Artifacts", - "type": "select", - "label": "圣遗物奖励,默认不修改圣遗物奖励", - "options": [ - "保持圣遗物奖励不变", - "长夜之誓 / 深廊终曲", - "黑曜秘典 / 烬城勇者绘卷", - "谐律异想断章 / 未竟的遐思" , - "回声之林夜话 / 昔时之歌" , - "逐影猎人 / 黄金剧团" , - "水仙之梦 / 花海甘露之光" , - "乐园遗落之花 / 沙上楼阁史话" , - "深林的记忆 / 饰金之梦" , - "来歆余响 / 辰砂往生录" , - "华馆梦醒形骸记 / 海染砗磲" , - "绝缘之旗印 / 追忆之注连" , - "昔日宗室之仪 / 染血的骑士道" , - "渡过烈火的贤人 / 炽烈的炎之魔女" , - "悠古的磐岩 / 逆飞的流星", - "千岩牢固 / 苍白之火" , - "冰风迷途的勇士 / 沉沦之心" , - "翠绿之影 / 被怜爱的少女" , - "如雷的盛怒 / 平息鸣雷的尊者" - ] -}, - { - "name": "challengeName", - "type": "select", - "label": "必填:从上往下(1~3),选择第几个Boss挑战关卡", - "options": [ - "1", - "2", - "3" - ] - }, - { - "name": "challengeNum", - "type": "input-text", - "label": "挑战次数,默认15次,期间树脂耗尽会自动结束" - }, -{ - "name": "Rewardsuse", - "type": "input-text", - "label": "树脂顺序,1=浓缩树脂/2=原粹树脂/3=脆弱树脂/4=须臾树脂\n用`/`隔开,填写对应的树脂数字即可,默认:1/2\n表示先使用浓缩树脂,再使用原粹树脂,不填的不使用" -}, - { - "name": "Fighttimeout", - "type": "input-text", - "label": "最长战斗超时时间,单位秒,默认240秒" - }, - { - "name": "Startforward", - "type": "input-text", - "label": "开始战斗后,向前移动的时间,默认1秒(注意单位:秒)" - } -] +[ +{ + "name": "Artifacts", + "type": "select", + "label": "圣遗物奖励,默认不修改圣遗物奖励", + "options": [ + "保持圣遗物奖励不变", + "长夜之誓 / 深廊终曲", + "黑曜秘典 / 烬城勇者绘卷", + "谐律异想断章 / 未竟的遐思" , + "回声之林夜话 / 昔时之歌" , + "逐影猎人 / 黄金剧团" , + "水仙之梦 / 花海甘露之光" , + "乐园遗落之花 / 沙上楼阁史话" , + "深林的记忆 / 饰金之梦" , + "来歆余响 / 辰砂往生录" , + "华馆梦醒形骸记 / 海染砗磲" , + "绝缘之旗印 / 追忆之注连" , + "昔日宗室之仪 / 染血的骑士道" , + "渡过烈火的贤人 / 炽烈的炎之魔女" , + "悠古的磐岩 / 逆飞的流星", + "千岩牢固 / 苍白之火" , + "冰风迷途的勇士 / 沉沦之心" , + "翠绿之影 / 被怜爱的少女" , + "如雷的盛怒 / 平息鸣雷的尊者" + ], + "default": "保持圣遗物奖励不变" +}, + { + "name": "challengeName", + "type": "select", + "label": "必填:从上往下(1~3),选择第几个Boss挑战关卡", + "options": [ + "1", + "2", + "3" + ] + }, + { + "name": "challengeNum", + "type": "input-text", + "label": "挑战次数,默认15次,期间树脂耗尽会自动结束", + "default": "15" + }, +{ + "name": "Rewardsuse", + "type": "input-text", + "label": "树脂顺序,1=浓缩树脂/2=原粹树脂/3=脆弱树脂/4=须臾树脂\n用`/`隔开,填写对应的树脂数字即可,默认:1/2\n表示先使用浓缩树脂,再使用原粹树脂,不填的不使用", + "default": "1/2" +}, + { + "name": "Fighttimeout", + "type": "input-text", + "label": "最长战斗超时时间,单位秒,默认240秒", + "default": "240" + }, + { + "name": "Startforward", + "type": "input-text", + "label": "开始战斗后,向前移动的时间,默认1秒(注意单位:秒)", + "default": "1" + } +]