优化路线 (#2215)

1、修改路线
2、修改设置时间方式
3、增加无限制运行选项
This commit is contained in:
skyflag2022
2025-10-23 17:57:21 +08:00
committed by GitHub
parent 4e6d6b2802
commit 64e2631874
6 changed files with 94 additions and 32 deletions

View File

@@ -8,4 +8,5 @@
账户名只允许使用数字中英文同时长度在20个字符以内。
如果你想要在一周中重复运行,可以删除文件夹里的"账户名.txt"文件
如果你想要无限制运行,可以勾选取消运行限制

View File

@@ -19,15 +19,6 @@
},
{
"id": 2,
"action": "set_time",
"action_params": "19:00",
"move_mode": "walk",
"type": "path",
"x": 366.748046875,
"y": -502.51904296875,
},
{
"id": 3,
"x": 378.5673828125,
"y": -532.35009765625,
"type": "path",
@@ -36,7 +27,7 @@
"action_params": ""
},
{
"id": 4,
"id": 3,
"x": 330.466796875,
"y": -585.69921875,
"type": "path",
@@ -45,7 +36,7 @@
"action_params": ""
},
{
"id": 5,
"id": 4,
"x": 340.091796875,
"y": -593.6611328125,
"type": "path",

View File

@@ -16,6 +16,15 @@
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 2,
"x": 9061.1553,
"y": -1850.5386,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
}
]
}

View File

@@ -19,6 +19,74 @@ let userName = settings.userName || "默认账户";
return userName;
}
// 设置游戏时间
async function setTime(hour, minute) {
// 关于setTime
// 原作者: Tim
// 脚本名称: SetTimeMinute - 精确调整游戏时间到分钟
// 脚本版本: 1.0
// Hash: f5c2547dfc286fc643c733d630f775e8fbf12971
// 设置游戏分辨率和DPI缩放
setGameMetrics(1920, 1080, 1);
// 圆心坐标
const centerX = 1441;
const centerY = 501.6;
// 半径
const r1 = 30;
const r2 = 150;
const r3 = 300;
const stepDuration = 50;
function getPosition(r, index) {
let angle = index * Math.PI / 720;
return [Math.round(centerX + r * Math.cos(angle)), Math.round(centerY + r * Math.sin(angle))];
}
async function mouseClick(x, y) {
moveMouseTo(x, y);
await sleep(50);
leftButtonDown();
await sleep(50);
leftButtonUp();
await sleep(stepDuration);
}
async function mouseClickAndMove(x1, y1, x2, y2) {
moveMouseTo(x1, y1);
await sleep(50);
leftButtonDown();
await sleep(50);
moveMouseTo(x2, y2);
await sleep(50);
leftButtonUp();
await sleep(stepDuration);
}
async function setTime(hour, minute) {
const end = (hour + 6) * 60 + minute - 20;
const n = 3;
for (let i = - n + 1; i < 1; i++) {
let [x, y] = getPosition(r1, end + i * 1440 / n);
await mouseClick(x, y);
}
let [x1, y1] = getPosition(r2, end + 5);
let [x2, y2] = getPosition(r3, end + 20 + 0.5);
await mouseClickAndMove(x1, y1, x2, y2);
}
let h = Math.floor(hour + minute / 60);
const m = Math.floor(hour * 60 + minute) - h * 60;
h = ((h % 24) + 24) % 24;
log.info(`设置时间到 ${h}${m}`);
await keyPress("Escape");
await sleep(1000);
await click(50, 700);
await sleep(2000);
await setTime(h, m);
await sleep(1000);
await click(1500, 1000);//确认
await sleep(2000);
await genshin.returnMainUi();
}
/**
* 判断任务是否已刷新
* @param {string} filePath - 存储最后完成时间的文件路径
@@ -153,19 +221,6 @@ let userName = settings.userName || "默认账户";
let filePath = `assets/Pathing/${locationName}.json`;
await pathingScript.runFile(filePath);
await sleep(1000);
if (locationName=='璃月购买狗粮2'){
await sleep(1000);
keyDown("w");
await sleep(600);
keyUp("w");
await sleep(1000);
}
if (locationName=='纳塔购买狗粮'){
await sleep(1000);
keyDown("a");
await sleep(500);
keyUp("a");
}
// 定义模板
let fDialogueRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/F_Dialogue.png"), 1050, 400, 100, 400);
@@ -179,7 +234,7 @@ let userName = settings.userName || "默认账户";
let fRes = ra.find(fDialogueRo);
if (!fRes.isExist()) {
let f_attempts = null; // 初始化尝试次数
while (f_attempts < 5) { // 最多尝试 4
while (f_attempts < 6) { // 最多尝试 5
f_attempts++;
log.info(`当前尝试次数:${f_attempts}`);
if (f_attempts <= 3) {
@@ -188,13 +243,13 @@ let userName = settings.userName || "默认账户";
await sleep(200);
await simulateKeyOperations("W", 400); // 前进 400 毫秒
await sleep(500);
} else if (f_attempts === 4) {
// 第 4 次尝试
} else if (f_attempts <= 5) {
// 第 4-5 次尝试
log.info("重新加载路径文件");
await pathingScript.runFile(filePath);
await sleep(500);
} else {
// 第 5 次尝试,尝试次数已达上限
// 第 6 次尝试,尝试次数已达上限
log.warn("尝试次数已达上限");
break; // 找到后退出循环
}
@@ -285,6 +340,7 @@ let userName = settings.userName || "默认账户";
}
if(settings.select3){
await setTime(19,00)
await purChase('璃月购买狗粮2');
}
@@ -317,7 +373,7 @@ let userName = settings.userName || "默认账户";
refreshType: 'weekly',
weeklyDay: 4, // 周四
weeklyHour: 4 // 凌晨4点
})){
})|| settings.select9){
await main();
}
})();

View File

@@ -1,7 +1,7 @@
{
"manifest_version": 1,
"name": "自动购买狗粮(8点位)",
"version": "2.2",
"version": "2.3",
"bgi_version": "0.51",
"description": "自动购买狗粮",
"authors": [

View File

@@ -5,6 +5,12 @@
"label": "账户名称\n用于多账户运行时区分不同账户",
"default": "默认账户"
},
{
"name": "select9",
"type": "checkbox",
"label": "取消运行限制",
"default": false
},
{
"name": "select1",
"type": "checkbox",
@@ -53,5 +59,4 @@
"label": "挪德卡莱商人",
"default": true
},
]