From 7be80c8945e43009f20287a11588152a7b14a580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E4=BA=91?= Date: Wed, 28 May 2025 16:30:57 +0800 Subject: [PATCH] =?UTF-8?q?bugfix(js):=20=E6=91=94=E8=90=BD=E4=BF=9D?= =?UTF-8?q?=E6=8A=A4=20(#945)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 通过键鼠自动到锚点,自动放置锚点 * fix: 异常时释放所有按键,未进入游泳状态直接放弃任务 --- .../assets/pathing/原始胎海.json | 4 +- repo/js/FeatherFalling/main.js | 38 +++++++++++++++---- repo/js/FeatherFalling/manifest.json | 2 +- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/repo/js/FeatherFalling/assets/pathing/原始胎海.json b/repo/js/FeatherFalling/assets/pathing/原始胎海.json index 6536cbff..e7eb2126 100644 --- a/repo/js/FeatherFalling/assets/pathing/原始胎海.json +++ b/repo/js/FeatherFalling/assets/pathing/原始胎海.json @@ -16,8 +16,8 @@ "action": "", "move_mode": "dash", "type": "path", - "x": 3387.220703125, - "y": 2575.370849609375, + "x": 3364.22, + "y": 2558.37, "action_params": "" } ] diff --git a/repo/js/FeatherFalling/main.js b/repo/js/FeatherFalling/main.js index 6b0a1483..79be17dc 100644 --- a/repo/js/FeatherFalling/main.js +++ b/repo/js/FeatherFalling/main.js @@ -11,7 +11,14 @@ tpBagRo.Use3Channels = true; swimStateRo.threshold = 0.60; (async function () { - await FeatherFailing(); + try { + await FeatherFailing(); + } catch (error) { + log.error("程序执行出现异常: " + error.message); + keyUp("W"); + keyUp("VK_LCONTROL"); + throw error; // 重新抛出异常 + } })(); async function switchPartyIfNeeded(partyName) { @@ -39,14 +46,14 @@ async function PlacePortableWaypoint() { log.info("正在放置锚点"); await genshin.returnMainUi(); await sleep(500); - keyPress("B"); + keyPress("B"); await sleep(500); click(1050, 50); await sleep(50); click(1050, 50); await sleep(1000); let result = captureGameRegion().find(tpBagRo); - if(result.isExist()) { + if (result.isExist()) { result.click(); await sleep(1000); click(1680, 990); @@ -70,7 +77,7 @@ async function FeatherFailing() { if (result.isExist()) { log.info("传送点图标已识别,点击传送"); result.click(); - await sleep(1000); + await sleep(1000); if (settings.autoPortableWaypoint) { let result = captureGameRegion().find(ocrRo); log.info("识别到锚点文字: " + result.text); @@ -133,7 +140,7 @@ async function FeatherFailing() { } - for (let i = 0; i < 20; i++) { + for (let i = 0; i < 30; i++) { keyDown("W"); await sleep(50); keyUp("W"); @@ -143,6 +150,13 @@ async function FeatherFailing() { log.info("已进入游泳状态"); break; } + if (i === 29) { + log.error("未进入游泳状态"); + log.error("可能是键鼠模拟出现偏差,或锚点位置偏差"); + log.error("可以手动放置锚点在水面正后方,确保小碎步可以到达"); + await sleep(5000); + throw new Error("未进入游泳状态,请检查设置或手动操作"); + } } keyDown("VK_LCONTROL"); for (let i = 0; i < 100; i++) { @@ -155,10 +169,20 @@ async function FeatherFailing() { } } await pathingScript.runFile("assets/pathing/原始胎海.json"); - await sleep(25000); + await sleep(200); + middleButtonClick(); + for (let i = 0; i < 100; i++) { + result = captureGameRegion().find(swimStateRo); + if (!result.isExist()) { + log.info("已退出游泳状态"); + break; + } + await sleep(200); + } keyUp("VK_LCONTROL"); + await sleep(10000); log.info("我已无敌!"); - if (settings.Test) { + if (settings.test) { await pathingScript.runFile("assets/pathing/信仰之跃.json"); } } \ No newline at end of file diff --git a/repo/js/FeatherFalling/manifest.json b/repo/js/FeatherFalling/manifest.json index 785e43a0..dbe9738c 100644 --- a/repo/js/FeatherFalling/manifest.json +++ b/repo/js/FeatherFalling/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 1, "name": "摔落保护:提瓦特反牛顿机制", - "version": "1.1", + "version": "1.1.1", "description": "利用游戏机制获取免疫摔落伤害的buff", "authors": [ {