feat: 替换NPC原食的SetTime逻辑为快速版本 (#2275)

This commit is contained in:
NyaMisty
2025-10-30 15:05:05 +08:00
committed by GitHub
parent f108442c11
commit 40e38e981e
2 changed files with 81 additions and 63 deletions

View File

@@ -234,72 +234,90 @@ const othrtRo = {
// 设置游戏时间
async function setTime(hour, minute) {
// 关于setTime
// 原作者: Tim
// 脚本名称: SetTimeMinute - 精确调整游戏时间到分钟
// 原作者: Tim,子寻
// 脚本名称: 设置时间并跳过调整动画 - 精确调整游戏时间到分钟,跳过调整动画
// 脚本版本: 1.0
// Hash: f5c2547dfc286fc643c733d630f775e8fbf12971
// Hash: ef806e665bccb42675ed5052157b325610181700
// 设置游戏分辨率和DPI缩放
setGameMetrics(1920, 1080, 1);
// 圆心坐标
const centerX = 1441;
const centerY = 501.6;
// 半径
const r1 = 30;
const r2 = 150;
const r3 = 300;
const stepDuration = 50;
// 设置游戏分辨率和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);
}
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);
}
async function cancelAni() {
moveMouseTo(200, 200);
leftButtonDown();
await(10);
leftButtonUp();
}
const hour = Number(settings.hour);
const minute = Number(settings.minute);
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(1000);
await setTime(h, m);
await sleep(500);
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(18000);
await keyPress("Escape");
await sleep(2000);
await keyPress("Escape");
await sleep(2000);
// 点击确认
await click(1500,1000);
// 跳过调整动画
await sleep(1);
await cancelAni();
await sleep(1000);
await click(45,715);
// 重新进入调时间界面以消除调时间的声音
await sleep(600);
await keyPress("Escape");
// 退出派蒙界面
await sleep(600);
await keyPress("Escape");
}
// 地图追踪

View File

@@ -1,7 +1,7 @@
{
"manifest_version": 1,
"name": "购买NPC食材-图像识别",
"version": "2.0.3",
"version": "2.0.4",
"description": "原食脚本: 基于图像识别的购买NPC商品, 可选择性购买商品, 按地区顺序购买, 节省大量时间.",
"authors": [
{