YNF-AutoEat-V1.4.1版本更新 (#2002)

* YNF-AutoEat-1.4.1版本

1. 副本进入流程增加OCR识别,提升流程稳定性
2. 优化了多处的等待时长,实现脚本运行全流程的平滑过渡与效率跃升
3. 优化了多处识别流程,提高识别准确率并减少无用日志

* YNF-AutoEat-V1.4.1版本更新

1. 副本进入流程增加OCR识别,提升流程稳定性
2. 优化了多处的等待时长,实现脚本运行全流程的平滑过渡与效率跃升
3. 优化了多处识别流程,提高识别准确率并减少无用日志
This commit is contained in:
江紫烟owo
2025-09-27 00:25:42 +08:00
committed by GitHub
parent 6954d7eead
commit 71fe6f6785
3 changed files with 42 additions and 43 deletions

View File

@@ -17,10 +17,10 @@
## 作者留言
欢迎使用该脚本毕竟使用的过程也是帮作者发现bug的过程
那么当你在使用时发现有bug存在请反馈到频道并艾特作者
当然,作者会保证尽力去修但是不一定能修好。(书到用时方恨少了属于是)
希望发现问题积极反馈,来频道尽情蹂虐作者吧!
这个脚本是作者第一次pr的脚本。大家可以发现更新频率很高但是对于这种小功能的脚本来说更新频率高也意味着欠缺的地方还有很多
作者也在慢慢学习,慢慢在摸索,偶尔可能会出现新版本不如上一版本的情况……
那么……欢迎使用此脚本毕竟使用的过程也是帮作者发现bug的过程。
有问题请及时到频道反馈,作者会高频刷帖的,看到之后会很快处理,来频道尽情蹂虐作者吧!
~~(PS:许愿也行,需求尽管提,没回就是做不到,欸嘿)~~
@@ -29,6 +29,10 @@
2. 感谢氨气老师和秋秋云老师,在审核时提供了宝贵的意见和建议。
---------------------------------------------------------------------------------------------------------------------------------
## 更新日志
### 1.4.12025.09.26
1. 副本进入流程增加OCR识别提升流程稳定性
2. 优化了多处的等待时长,实现脚本运行全流程的平滑过渡与效率跃升
3. 优化了多处识别流程,提高识别准确率并减少无用日志
### 1.42025.09.24
1. 修复了运行次数为某些值时运行结束前往神像之后还会回到秘境的bug
2. 添加了更为完善的过期物品拦截机制,不用再傻乎乎的每次点击同一位置了!(感谢糖雕老师以身殉道提供海量素材~

View File

@@ -129,17 +129,17 @@
}
/**
* 文字OCR识别封装函数测试中未封装完成后续会优化逻辑
* @param text 要识别的文字,默认为"空参数"
* @param timeout 超时时间单位为秒默认为10秒
* @param afterBehavior 点击模式0表示不点击1表示点击识别到文字的位置2表示输出模式默认为0
* @param debugmodel 调试代码0表示输入判断模式1表示输出位置信息2表示输出判断模式默认为0
* @param x OCR识别区域的起始X坐标默认为0
* @param y OCR识别区域的起始Y坐标默认为0
* @param w OCR识别区域的宽度默认为1920
* @param h OCR识别区域的高度默认为1080
* @returns 包含识别结果的对象,包括识别的文字、坐标和是否找到的结果
*/
* 文字OCR识别封装函数测试中未封装完成后续会优化逻辑
* @param text 要识别的文字,默认为"空参数"
* @param timeout 超时时间单位为秒默认为10秒
* @param afterBehavior 点击模式0表示不点击1表示点击识别到文字的位置2表示输出模式默认为0
* @param debugmodel 调试代码0表示输入判断模式1表示输出位置信息2表示输出判断模式默认为0
* @param x OCR识别区域的起始X坐标默认为0
* @param y OCR识别区域的起始Y坐标默认为0
* @param w OCR识别区域的宽度默认为1920
* @param h OCR识别区域的高度默认为1080
* @returns 包含识别结果的对象,包括识别的文字、坐标和是否找到的结果
*/
async function textOCR(text = "空参数", timeout = 10, afterBehavior = 0, debugmodel = 0, x = 0, y = 0, w = 1920, h = 1080) {
const startTime = new Date();
var Outcheak = 0
@@ -161,9 +161,8 @@
if (res.text.includes(text) && debugmodel == 3) { return result = { text: res.text, x: res.x, y: res.y, found: true }; }
if (res.text.includes(text) && debugmodel !== 2) {
conuntcottimecot++;
log.info(`${res1}”找到`);
if (debugmodel === 1 & x === 0 & y === 0) { log.info("全图代码位置:({x},{y},{h},{w})", res.x - 10, res.y - 10, res.width + 10, res.Height + 10); } else { log.info("文本OCR完成'{text}'", res.text); }
if (afterBehavior === 1) { log.info("点击模式:开"); await sleep(1000); click(res.x, res.y); } else { if (debugmodel === 1 & x === 0 & y === 0) { log.info("点击模式:关") } }
if (debugmodel === 1 & x === 0 & y === 0) { log.info("全图代码位置:({x},{y},{h},{w})", res.x - 10, res.y - 10, res.width + 10, res.Height + 10); }
if (afterBehavior === 1) { await sleep(1000); click(res.x, res.y); } else { if (debugmodel === 1 & x === 0 & y === 0) { log.info("点击模式:关") } }
if (afterBehavior === 2) { log.info("F模式:开"); await sleep(100); keyPress("F"); } else { if (debugmodel === 1 & x === 0 & y === 0) { log.info("F模式:关"); } }
if (conuntcottimecot >= conuntcottimecomp / 2) { return result = { text: res.text, x: res.x, y: res.y, found: true }; } else { return result = { found: false }; }
}
@@ -187,7 +186,7 @@
for (let i = 0; i < avatars.length; i++) {
if (avatars[i] === characterName) {
await keyPress(String(i + 1));
await sleep(1000);
await sleep(1500);
return true;
}
}
@@ -219,22 +218,21 @@
await genshin.tp(-887.193359375, 1679.44287109375);//识别成功直接传送
keyDown("w");
await sleep(2500);
await sleep(2000);
keyUp("w");
keyPress("F");
await sleep(4000);
await click(1600, 1015);
await sleep(1500);
await click(1600, 1015);
await sleep(9000);
leftButtonClick();
await sleep(1500);
await textOCR("单人挑战", 8, 1, 1, 1615, 990, 220, 50);//等待“单人挑战”出现
await textOCR("开始挑战", 8, 1, 1, 1615, 990, 220, 50);//等待“开始挑战”出现
await textOCR("地脉异常", 10, 1, 1, 840, 405, 180, 55);//等待“地脉异常”出现
await sleep(1000);
return true;
}
// 伊涅芙跳楼机
async function doit() {
// 江紫烟老师绞尽脑汁想也不出来几句骚话
const randomNumber = Math.floor(Math.random() * 3) + 1;
if (randomNumber == 1) { log.info("即使分离,我们的心始终相连"); }
if (randomNumber == 2) { log.info("再见了伊涅芙,希望你喜欢这几分钟的戏份"); }
@@ -247,18 +245,17 @@
await keyPress("B");
await handleExpiredItems();//处理过期物品弹窗
await sleep(1000);
await sleep(800);
await click(860, 50);
await sleep(1000);
await sleep(800);
const ifshiwu = await imageRecognitionEnhanced(foodbag, 3, 0, 0, 126, 17, 99, 53);
if (!ifshiwu.found) {
await genshin.returnMainUi();
throw new Error("未打开'食物'页面,请确保背包已正确打开并切换到食物标签页");
}//确认在食物界面
await sleep(500);
const ifpingguo = await imageRecognitionEnhanced(pingguo, 1, 1, 0, 115, 120, 1150, 155, true);//识别"苹果"图片
const ifpingguo = await imageRecognitionEnhanced(pingguo, 3, 1, 0, 115, 120, 1150, 155, true);//识别"苹果"图片
if (!ifpingguo.found) {
await genshin.returnMainUi();
throw new Error("没有找到指定的食物:" + food + ",请检查背包中该食材数量是否足够!");
@@ -266,12 +263,9 @@
await sleep(500);
await click(1700, 1020);//点击使用
await sleep(1000);
const ifzjz = await imageRecognitionEnhanced(zjz, 5, 1, 0, 625, 290, 700, 360, true);//点击伊涅芙证件照
await sleep(300);
leftButtonClick();//连续点击确保吃食物的是伊涅芙
await sleep(300);
await imageRecognitionEnhanced(zjz, 3, 1, 0, 625, 290, 700, 360, true);//点击伊涅芙证件照,确保吃食物的是伊涅芙
await sleep(500);
for (let i = 0; i < foodCount; i++) {
click(1251, 630);
@@ -294,14 +288,13 @@
// 背包过期物品识别需要在背包界面并且是1920x1080分辨率下使用
async function handleExpiredItems() {
const ifGuoqi = await textOCR("物品过期", 1, 0, 0, 870, 280, 170, 40);
const ifGuoqi = await textOCR("物品过期", 1.5, 0, 0, 870, 280, 170, 40);
if (ifGuoqi.found) {
log.info("检测到过期物品,正在处理...");
await sleep(500);
await click(980, 750); // 点击确认按钮,关闭提示
} else {
log.info("未检测到过期物品");
}
// else { log.info("未检测到过期物品"); }//频繁开关背包,不需要每次都提示
}
@@ -319,6 +312,8 @@
const zjz = `assets/zhengjianzhao.png`;//伊涅芙证件照
const foodbag = `assets/foodbag.png`;//背包的“食物”界面
const eater = "伊涅芙";//客官一位~
// 添加验证
if (!party) { log.error("队伍名为空请仔细阅读readme并进行设置后再使用此脚本"); return; }// 利用队伍是否为空判断用户有没有进行设置
if (foodCount > 98 || foodCount < 0) { log.error("食材数量请填写1-99之间的数字"); return; }//确保食材数量1~99
@@ -337,12 +332,12 @@
// 先判断一次,队伍里有伊涅芙就直接开始运行,没有的话就切换指定队伍
if (!await includes("伊涅芙")) {
if (!await includes(eater)) {
if (!await switchPartyIfNeeded(party)) { log.error("未识别到指定队伍,请检查队伍名是否正确!"); return false; }//找不到指定队伍就直接报错停止
if (!await includes("伊涅芙")) { log.error("未识别到伊涅芙,请检查队伍名是否正确!"); return false; }// 切换成功后判断队伍中是否有伊涅芙
if (!await includes(eater)) { log.error(`未识别到`+eater+`,请检查队伍名是否正确!`); return false; }// 切换成功后判断队伍中是否有伊涅芙
}
log.info("已识别到伊涅芙,即将开始后续动作……");
log.info(`已识别到`+eater+`,即将开始后续动作……`);
try {
await fuben();//进入副本

View File

@@ -1,7 +1,7 @@
{
"manifest_version": 1,
"name": "伊涅芙の自助餐",
"version": "1.4",
"version": "1.4.1",
"tags": [
"伊涅芙",
"调味品"