JS脚本:周本2.2更新 (#899)

* 周本2.2更新

* Update repo/js/周本3-公子/main.js

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update repo/js/周本11-火龙/assets/tp.json

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
5117600049
2025-05-22 02:57:37 +08:00
committed by GitHub
parent d4d2fb5686
commit d4097a8ee4
38 changed files with 1713 additions and 365 deletions

View File

@@ -23,10 +23,43 @@ async function tpEndDetection() {
}
throw new Error('传送时间超时');
}
//吃料理
async function eatFood() {
let foodName = settings.foodName ?? 0;
if(foodName){
const foodSum = foodName.split('-');
log.info("开始吃菜");
await sleep(1000);
keyPress("B");//打开背包
await sleep(2000);
click(863, 51);//选择食物
await sleep(1000);
for(let i = 0; i < foodSum.length; i++){
click(170, 1020);//筛选
await sleep(1000);
click(195, 1020);//重置
await sleep(1000);
click(110, 110);//输入名字
await sleep(1000);
inputText(foodSum[i]);
await sleep(500);
click(490, 1020);//确认筛选
await sleep(1000);
click(180, 180);//选择第一个食物
await sleep(1000);
click(1690, 1015);//使用
await sleep(1000);
}
keyPress("ESCAPE");
await sleep(1500);
}}
//检测角色是否阵亡,并前往吃药复活
async function resurgenceDetectionAndEatFood() {
const region1 = RecognitionObject.ocr(1170, 780, 75, 35);// 复活料理区域
const region2 = RecognitionObject.ocr(545, 360, 800, 45);// 料理冷却区域
let recoveryFoodName = settings.recoveryFoodName ?? 0;
let resurgenceFoodName = settings.resurgenceFoodName ?? 0;
if(resurgenceFoodName && recoveryFoodName){
keyPress("1");
await sleep(100);
keyPress("2");
@@ -44,6 +77,9 @@ let res2 = capture.find(region2);
else if (!res1.isEmpty() && !res2.isEmpty()) {
log.info("复活料理处于冷却中");
keyPress("ESCAPE");
await sleep(1000);
await genshin.tp(2297.6201171875,-824.5869140625);//传送到神像回血
throw new Error('战斗失败');
return;
}
else if (!res1.isEmpty() && res2.isEmpty()) {
@@ -52,7 +88,7 @@ let res2 = capture.find(region2);
await eatResurgenceFood();//满血复活
return;
}
}
}}
//吃料理复活
async function eatResurgenceFood() {
@@ -132,36 +168,6 @@ for (let i = 0; i < clickPositions.length; i++) {
}
}
//吃料理
async function eatFood() {
let foodName = settings.foodName ?? 0;
if(foodName){
log.info("开始吃菜");
await sleep(1000);
keyPress("B");//打开背包
await sleep(2000);
click(863, 51);//选择食物
await sleep(1000);
click(170, 1020);//筛选
await sleep(1000);
click(195, 1020);//重置
await sleep(1000);
click(110, 110);//输入名字
await sleep(1000);
inputText(`${foodName}`);
await sleep(500);
click(490, 1020);//确认筛选
await sleep(1000);
click(180, 180);//选择第一个食物
await sleep(1000);
click(1690, 1015);//使用
await sleep(1000);
keyPress("ESCAPE");
await sleep(1500);
}}
//征讨之花领奖(无图标前进检测)
const autoNavigateToReward = async () => {
const rewardTextRo = RecognitionObject.Ocr(1210, 515, 200, 50);//领奖区域检测
@@ -176,14 +182,30 @@ const autoNavigateToReward = async () => {
log.info("已到达领奖点,检测到文字: " + rewardResult.text);
return;
}
else if(advanceNum > 20){
throw new Error('前进时间超时');
else if(advanceNum > 700){
await genshin.tp(2297.6201171875,-824.5869140625);//传送到神像回血
throw new Error('前进时间超时');
}
// 前进一小步
keyDown("w");
await sleep(500);
keyUp("w");
await sleep(100); // 等待角色移动稳定
if((advanceNum%70)<34){
keyDown("w");
await sleep(500);
keyUp("w");
await sleep(200); // 等待角色移动稳定
}
else if((advanceNum%70)>34){
keyDown("s");
await sleep(500);
keyUp("s");
await sleep(200); // 等待角色移动稳定
}
else {
keyDown("d");
await sleep(500);
keyUp("d");
}
advanceNum++;
}
}
@@ -213,19 +235,15 @@ async function autoFightAndEndDetection() {
keyDown("s");
await sleep(1800);
keyUp("s");
capture = captureGameRegion();
res1 = capture.find(region1);
res2 = capture.find(region2);
res3 = capture.find(region3);
hasText1 = !res1.isEmpty() && res1.text.trim().length > 0;
hasText2 = !res2.isEmpty() && res2.text.trim().length > 0;
hasText3 = !res3.isEmpty() && res3.text.trim().length > 0;
//二次检测避免无法启动战斗
if (hasText1 && !hasText2 && hasText3){
log.info(`执行第${challengeNum}次战斗`);
challengeTime = challengeTime + 205;
await dispatcher.runTask(new SoloTask("AutoFight"));
}
try {
await dispatcher.runTask(new SoloTask("AutoFight"));
} catch (error) {
log.info("启动战斗失败,尝试重新启动");
await sleep(500);
}
}
// 情况2: 区域2有文字 且 区域1无文字 且 区域3有文字 → 结束循环
else if (hasText2 && !hasText1 && hasText3) {
@@ -234,19 +252,23 @@ async function autoFightAndEndDetection() {
}
// 情况3: 区域2无文字区域1无文字区域3有文字 →BOSS二阶段需要移动触发
else if (!hasText2 && !hasText1 && hasText3) {
/*
log.info("检测到BOSS进入二阶段");
keyDown("s");
await sleep(2500);
keyUp("s");
await dispatcher.runTask(new SoloTask("AutoFight"));
*/
}
// 情况4: 三个区域均无文字,可能处于转场动画,尝试点击快进
else if (!hasText1 && !hasText2 && !hasText3){
/*
log.info("进入过场动画尝试快进");
await sleep(400);
click(1765, 55);
await sleep(400);
click(1765, 55);
*/
}
challengeTime = challengeTime + 1;
@@ -279,7 +301,6 @@ await tpEndDetection();
await eatFood();//嗑药
keyPress("1");
await sleep(1000);//切回固定行走位
keyDown("s");
await sleep(300);
keyDown("SHIFT");
@@ -287,22 +308,25 @@ await sleep(300);
keyUp("SHIFT");
await sleep(500);
keyUp("s");
//战斗和领奖
await autoFightAndEndDetection();//一直战斗直到检测到结束
//走到角落对准身位
//领奖并退出
keyDown("s");
await sleep(4000);
keyUp("s");
await autoNavigateToReward();//前往地脉之花
await sleep(1000);
keyPress("F");//领奖
await sleep(1000);
click(950, 750);//使用树脂
await sleep(6000);
click(975, 1000);//退出秘境
await sleep(10000);
await tpEndDetection();
await genshin.tp(2297.6201171875,-824.5869140625);//传送到神像回血
await sleep(1000);
keyPress("M");//展示剩余体力
await sleep(1000);
notification.send('挑战完成');
})();