bugfix(js): 摔落保护 (#945)

* feat: 通过键鼠自动到锚点,自动放置锚点

* fix: 异常时释放所有按键,未进入游泳状态直接放弃任务
This commit is contained in:
秋云
2025-05-28 16:30:57 +08:00
committed by GitHub
parent 3387d6aa3c
commit 7be80c8945
3 changed files with 34 additions and 10 deletions

View File

@@ -16,8 +16,8 @@
"action": "", "action": "",
"move_mode": "dash", "move_mode": "dash",
"type": "path", "type": "path",
"x": 3387.220703125, "x": 3364.22,
"y": 2575.370849609375, "y": 2558.37,
"action_params": "" "action_params": ""
} }
] ]

View File

@@ -11,7 +11,14 @@ tpBagRo.Use3Channels = true;
swimStateRo.threshold = 0.60; swimStateRo.threshold = 0.60;
(async function () { (async function () {
try {
await FeatherFailing(); await FeatherFailing();
} catch (error) {
log.error("程序执行出现异常: " + error.message);
keyUp("W");
keyUp("VK_LCONTROL");
throw error; // 重新抛出异常
}
})(); })();
async function switchPartyIfNeeded(partyName) { async function switchPartyIfNeeded(partyName) {
@@ -133,7 +140,7 @@ async function FeatherFailing() {
} }
for (let i = 0; i < 20; i++) { for (let i = 0; i < 30; i++) {
keyDown("W"); keyDown("W");
await sleep(50); await sleep(50);
keyUp("W"); keyUp("W");
@@ -143,6 +150,13 @@ async function FeatherFailing() {
log.info("已进入游泳状态"); log.info("已进入游泳状态");
break; break;
} }
if (i === 29) {
log.error("未进入游泳状态");
log.error("可能是键鼠模拟出现偏差,或锚点位置偏差");
log.error("可以手动放置锚点在水面正后方,确保小碎步可以到达");
await sleep(5000);
throw new Error("未进入游泳状态,请检查设置或手动操作");
}
} }
keyDown("VK_LCONTROL"); keyDown("VK_LCONTROL");
for (let i = 0; i < 100; i++) { for (let i = 0; i < 100; i++) {
@@ -155,10 +169,20 @@ async function FeatherFailing() {
} }
} }
await pathingScript.runFile("assets/pathing/原始胎海.json"); 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"); keyUp("VK_LCONTROL");
await sleep(10000);
log.info("我已无敌!"); log.info("我已无敌!");
if (settings.Test) { if (settings.test) {
await pathingScript.runFile("assets/pathing/信仰之跃.json"); await pathingScript.runFile("assets/pathing/信仰之跃.json");
} }
} }

View File

@@ -1,7 +1,7 @@
{ {
"manifest_version": 1, "manifest_version": 1,
"name": "摔落保护:提瓦特反牛顿机制", "name": "摔落保护:提瓦特反牛顿机制",
"version": "1.1", "version": "1.1.1",
"description": "利用游戏机制获取免疫摔落伤害的buff", "description": "利用游戏机制获取免疫摔落伤害的buff",
"authors": [ "authors": [
{ {