From 24154fd13ee5e54f5ca719d19b1d118f87372e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E4=BA=91?= Date: Wed, 11 Jun 2025 07:18:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=95=88=E5=85=BD=E5=A5=BD=E6=84=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assets/AutoPath/蕈兽-准备.json | 40 +++++++++ .../assets/AutoPath/蕈兽-对话.json | 22 +++++ .../assets/AutoPath/蕈兽-战斗点.json | 40 +++++++++ .../assets/AutoPath/蕈兽-触发点.json | 22 +++++ .../assets/AutoPath/鳄鱼-拾取.json | 11 +-- repo/js/AutoFriendshipFight/main.js | 87 ++++++++++++------- repo/js/AutoFriendshipFight/manifest.json | 2 +- repo/js/AutoFriendshipFight/settings.json | 3 +- 8 files changed, 191 insertions(+), 36 deletions(-) create mode 100644 repo/js/AutoFriendshipFight/assets/AutoPath/蕈兽-准备.json create mode 100644 repo/js/AutoFriendshipFight/assets/AutoPath/蕈兽-对话.json create mode 100644 repo/js/AutoFriendshipFight/assets/AutoPath/蕈兽-战斗点.json create mode 100644 repo/js/AutoFriendshipFight/assets/AutoPath/蕈兽-触发点.json diff --git a/repo/js/AutoFriendshipFight/assets/AutoPath/蕈兽-准备.json b/repo/js/AutoFriendshipFight/assets/AutoPath/蕈兽-准备.json new file mode 100644 index 00000000..909f43d3 --- /dev/null +++ b/repo/js/AutoFriendshipFight/assets/AutoPath/蕈兽-准备.json @@ -0,0 +1,40 @@ +{ + "info": { + "name": "蕈兽-准备", + "type": "collect", + "author": "寒烟", + "version": "1.0", + "description": "", + "map_name": "Teyvat", + "bgi_version": "0.45.0" + }, + "positions": [ + { + "id": 1, + "x": 3705.44, + "y": -497.53, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "teleport" + }, + { + "id": 2, + "x": 3739.62, + "y": -466.75, + "action": "", + "move_mode": "dash", + "action_params": "", + "type": "path" + }, + { + "id": 3, + "x": 3788.61, + "y": -390.8, + "action": "stop_flying", + "move_mode": "fly", + "action_params": "100", + "type": "path" + } + ] +} \ No newline at end of file diff --git a/repo/js/AutoFriendshipFight/assets/AutoPath/蕈兽-对话.json b/repo/js/AutoFriendshipFight/assets/AutoPath/蕈兽-对话.json new file mode 100644 index 00000000..17547f15 --- /dev/null +++ b/repo/js/AutoFriendshipFight/assets/AutoPath/蕈兽-对话.json @@ -0,0 +1,22 @@ +{ + "info": { + "name": "蕈兽-对话", + "type": "collect", + "author": "寒烟", + "version": "1.0", + "description": "", + "map_name": "Teyvat", + "bgi_version": "0.45.0" + }, + "positions": [ + { + "id": 1, + "x": 3797.06, + "y": -343.96, + "type": "target", + "move_mode": "walk", + "action": "", + "action_params": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/AutoFriendshipFight/assets/AutoPath/蕈兽-战斗点.json b/repo/js/AutoFriendshipFight/assets/AutoPath/蕈兽-战斗点.json new file mode 100644 index 00000000..c7eb5845 --- /dev/null +++ b/repo/js/AutoFriendshipFight/assets/AutoPath/蕈兽-战斗点.json @@ -0,0 +1,40 @@ +{ + "info": { + "name": "蕈兽-战斗点", + "type": "collect", + "author": "寒烟", + "version": "1.0", + "description": "", + "map_name": "Teyvat", + "bgi_version": "0.45.0" + }, + "positions": [ + { + "id": 1, + "action": "", + "move_mode": "dash", + "type": "path", + "x": 3759.96, + "y": -395.62, + "action_params": "" + }, + { + "id": 2, + "x": 3774.26, + "y": -379.18, + "type": "path", + "move_mode": "dash", + "action": "", + "action_params": "" + }, + { + "id": 3, + "x": 3794.55, + "y": -350.6, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/AutoFriendshipFight/assets/AutoPath/蕈兽-触发点.json b/repo/js/AutoFriendshipFight/assets/AutoPath/蕈兽-触发点.json new file mode 100644 index 00000000..20d1fa6d --- /dev/null +++ b/repo/js/AutoFriendshipFight/assets/AutoPath/蕈兽-触发点.json @@ -0,0 +1,22 @@ +{ + "info": { + "name": "蕈兽-触发点", + "type": "collect", + "author": "寒烟", + "version": "1.0", + "description": "", + "map_name": "Teyvat", + "bgi_version": "0.45.0" + }, + "positions": [ + { + "id": 1, + "x": 3749.38, + "y": -391.91, + "type": "target", + "move_mode": "dash", + "action": "", + "action_params": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/AutoFriendshipFight/assets/AutoPath/鳄鱼-拾取.json b/repo/js/AutoFriendshipFight/assets/AutoPath/鳄鱼-拾取.json index 9cc6480d..41725212 100644 --- a/repo/js/AutoFriendshipFight/assets/AutoPath/鳄鱼-拾取.json +++ b/repo/js/AutoFriendshipFight/assets/AutoPath/鳄鱼-拾取.json @@ -5,13 +5,14 @@ "author": "秋云", "version": "1.0", "description": "", - "bgiVersion": "0.42.3" + "bgiVersion": "0.42.3", + "bgi_version": "0.42.0" }, "positions": [ { "id": 1, - "x": 3576.7568359375, - "y": -495.845703125, + "x": 3576.76, + "y": -495.85, "type": "path", "move_mode": "walk", "action": "", @@ -19,8 +20,8 @@ }, { "id": 2, - "x": 3572.375, - "y": -502.4375, + "x": 3572.38, + "y": -502.44, "action": "", "move_mode": "walk", "action_params": "", diff --git a/repo/js/AutoFriendshipFight/main.js b/repo/js/AutoFriendshipFight/main.js index db808460..ee6dfa0a 100644 --- a/repo/js/AutoFriendshipFight/main.js +++ b/repo/js/AutoFriendshipFight/main.js @@ -30,6 +30,10 @@ const DEFAULT_FIGHT_TIMEOUT_SECONDS = 120; log.info(`导航到鳄鱼触发点...`); await AutoPath('鳄鱼-准备'); } + if (enemyType === "蕈兽") { + log.info(`导航到蕈兽触发点...`); + await AutoPath('蕈兽-准备'); + } // 验证超时设置 const ocrTimeout = validateTimeoutSetting(settings.ocrTimeout, DEFAULT_OCR_TIMEOUT_SECONDS, "OCR"); const fightTimeout = validateTimeoutSetting(settings.fightTimeout, DEFAULT_FIGHT_TIMEOUT_SECONDS, "战斗"); @@ -255,6 +259,16 @@ async function executeSingleFriendshipRound(roundIndex, ocrTimeout, fightTimeout if (enemyType === "鳄鱼") { await AutoPath('鳄鱼-拾取'); } + if(enemyType === "蕈兽") { + await AutoPath('蕈兽-对话'); + await sleep(50); + keyPress("F"); + await sleep(50); + keyPress("F"); + await sleep(500); + await genshin.chooseTalkOption("下次"); + await sleep(500); + } // 返回 true 表示成功完成这一轮 return true; @@ -353,7 +367,11 @@ function getOcrKeywords(enemyType) { else if (enemyType === "鳄鱼") { return ["张牙", "舞爪", "恶党", "鳄鱼", "打倒", "所有", "鳄鱼"]; } - else { + else if (enemyType === "蕈兽") { + return ["实验家", "变成", "实验品", "击败", "所有", "魔物"]; + } + else + { return ["突发", "任务", "打倒", "消灭", "敌人", "所有"]; // 兜底关键词 } } @@ -368,6 +386,8 @@ function getTargetCoordinates(enemyType) { } else if (enemyType === "鳄鱼") { // 鳄鱼战斗点坐标 return { x: 3578.08, y: -500.75 }; + } else if (enemyType === "蕈兽") { + return { x: 3794.55, y: -350.60 }; } } @@ -380,6 +400,8 @@ function getTriggerPoint(enemyType) { } else if (enemyType === "鳄鱼") { return { x: 3614.63, y: -521.60 }; // 鳄鱼触发点坐标 + } else if (enemyType === "蕈兽") { + return { x: 3749.38, y: -391.91 }; // 蕈兽触发点坐标 } } @@ -436,8 +458,9 @@ async function waitForBattleResult(timeout = 2 * 60 * 1000, enemyType = "盗宝 while (Date.now() - fightStartTime < timeout) { try { // 简化OCR检测,只使用一个try-catch块 - let result = captureGameRegion().find(RecognitionObject.ocr(850, 150, 200, 80)); - let result2 = captureGameRegion().find(RecognitionObject.ocr(0, 200, 300, 300)); + let capture = captureGameRegion(); + let result = capture.find(RecognitionObject.ocr(850, 150, 200, 80)); + let result2 = capture.find(RecognitionObject.ocr(0, 200, 300, 300)); let text = result.text; let text2 = result2.text; @@ -449,6 +472,11 @@ async function waitForBattleResult(timeout = 2 * 60 * 1000, enemyType = "盗宝 cts.cancel(); // 取消任务 return true; } + if(enemyType=="蕈兽" && text2.includes("维沙瓦")){ + log.info("战斗结果:成功"); + cts.cancel(); + return true; + } } // 检查失败关键词 @@ -464,36 +492,37 @@ async function waitForBattleResult(timeout = 2 * 60 * 1000, enemyType = "盗宝 return false; } } - - // 检查事件关键词 - let find = 0; - for (let keyword of eventKeywords) { - if (text2.includes(keyword)) { - find++; + if(enemyType !== "蕈兽") { + // 检查事件关键词 + let find = 0; + for (let keyword of eventKeywords) { + if (text2.includes(keyword)) { + find++; + } } - } - if (find === 0) { - notFind++; - log.info("未检测到任务触发关键词:{0} 次", notFind); - } else { - notFind = 0; - } - - if (notFind > 10) { - log.warn("不在任务触发区域,战斗失败"); - cts.cancel(); // 取消任务 - if (enemyType === "愚人众") { - log.warn("回到愚人众准备点"); - await AutoPath('愚人众-准备'); + if (find === 0) { + notFind++; + log.info("未检测到任务触发关键词:{0} 次", notFind); + } else { + notFind = 0; } - if (enemyType === "鳄鱼") { - log.warn("回到鳄鱼准备点"); - await AutoPath('鳄鱼-准备'); - await sleep(5000); - } - return false; + if (notFind > 10) { + log.warn("不在任务触发区域,战斗失败"); + cts.cancel(); // 取消任务 + if (enemyType === "愚人众") { + log.warn("回到愚人众准备点"); + await AutoPath('愚人众-准备'); + } + if (enemyType === "鳄鱼") { + log.warn("回到鳄鱼准备点"); + await AutoPath('鳄鱼-准备'); + await sleep(5000); + } + return false; + + } } } catch (error) { diff --git a/repo/js/AutoFriendshipFight/manifest.json b/repo/js/AutoFriendshipFight/manifest.json index 81c8d45e..eae7f2b3 100644 --- a/repo/js/AutoFriendshipFight/manifest.json +++ b/repo/js/AutoFriendshipFight/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 1, "name": "战斗好感:自动好感度&卡时间", - "version": "1.4", + "version": "1.4.1", "bgi_version": "0.45.1", "tags": [ "好感", diff --git a/repo/js/AutoFriendshipFight/settings.json b/repo/js/AutoFriendshipFight/settings.json index 1b471e43..8375e03e 100644 --- a/repo/js/AutoFriendshipFight/settings.json +++ b/repo/js/AutoFriendshipFight/settings.json @@ -6,7 +6,8 @@ "options": [ "盗宝团", "愚人众", - "鳄鱼" + "鳄鱼", + "蕈兽" ], "default": "盗宝团" },