地图追踪:香辛果新增30个 (#631)

* 完善归档路径

* 地图追踪:香辛果新增30个
This commit is contained in:
起个名字好难的喵
2025-04-22 23:24:07 +08:00
committed by GitHub
parent a2277ae6ad
commit d69f6e5bc6
125 changed files with 714 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
{
"macroEvents": [
{"type": 2, "mouseX": 525, "mouseY": 881, "time": 0},
{"type": 2, "mouseX": 525, "mouseY": 781, "time": 50},
{"type": 2, "mouseX": 525, "mouseY": 681, "time": 100},
{"type": 2, "mouseX": 525, "mouseY": 581, "time": 150},
{"type": 2, "mouseX": 525, "mouseY": 481, "time": 200},
{"type": 2, "mouseX": 525, "mouseY": 381, "time": 250},
{"type": 2, "mouseX": 525, "mouseY": 281, "time": 300},
{"type": 2, "mouseX": 525, "mouseY": 211, "time": 350},
{"type": 2, "mouseX": 525, "mouseY": 209, "mouseButton": "Left", "time": 400}
],
"info": {
"name": "",
"description": "",
"x": 0,
"y": 0,
"width": 1920,
"height": 1080,
"recordDpi": 1
}
}

View File

@@ -0,0 +1,22 @@
{
"macroEvents": [
{"type": 2, "mouseX": 1200, "mouseY": 881, "time": 0},
{"type": 2, "mouseX": 1200, "mouseY": 781, "time": 50},
{"type": 2, "mouseX": 1200, "mouseY": 681, "time": 100},
{"type": 2, "mouseX": 1200, "mouseY": 581, "time": 150},
{"type": 2, "mouseX": 1200, "mouseY": 481, "time": 200},
{"type": 2, "mouseX": 1200, "mouseY": 381, "time": 250},
{"type": 2, "mouseX": 1200, "mouseY": 281, "time": 300},
{"type": 2, "mouseX": 1200, "mouseY": 211, "time": 350},
{"type": 2, "mouseX": 1200, "mouseY": 208, "mouseButton": "Left", "time": 400}
],
"info": {
"name": "",
"description": "",
"x": 0,
"y": 0,
"width": 1920,
"height": 1080,
"recordDpi": 1
}
}

View File

@@ -0,0 +1,122 @@
(async function () {
setGameMetrics(1920, 1080, 1);
// 提取字符串中的第一个数字字符
const Character = (parseInt(settings.Character?.match(/\d/)?.[0], 10)) || 4; // 默认值为 4
log.info(`Character${Character}`);
const elements = ["火", "水", "草", "雷", "风", "冰", "岩", "物"];
const Element = settings.Element || "物";
const elementIndex = elements.indexOf(Element);
const Switching = Math.min(99, Math.max(0, Math.floor(Number(settings.Switching) || 0)));
// 确保 pageScrollCount 是 0 到 99 的整数,默认值为 0
const pageScrollCount = Math.min(99, Math.max(0, Math.floor(Number(settings.pageScrollCount) || 0)));
const rightOffset = Math.max(0, Number(settings.rightOffset) || 2) -1; // 第几列,默认值为 2
const downOffset = Math.max(0, Number(settings.downOffset) || 2) -1; // 第几行,默认值为 2
log.info(`rightOffset: ${rightOffset},downOffset: ${downOffset}`);
// 提前计算所有动态坐标
// 武器区左顶处物品左上角坐标(37,138)
// 武器图片大小(125,151)
// 武器间隔(16,16)
// 第一点击区位置:125/2+37=99.5; 151/2+138=213.5
const rightClickX = Math.round(99.5 + rightOffset * 141);
const downClickY = Math.round(213.5 + downOffset * 167);
async function CharacterPath() {
// 日志记录任务开始
log.info("开始寻找");
// 初始化
await genshin.returnMainUi();
// 切换角色
keyPress(String(Character));
await sleep(1000);
// 按下 C 键
keyPress("C");
await sleep(1000);
if (elementIndex !== -1) {
const ElementClickX = Math.round(787 + elementIndex * 57.5); // 计算 X 坐标
log.info(`ElementClickX: ${ElementClickX}`);
// 如果 Element 不是 "物",则触发 moveMouseBy(960, 45)
if (Element !== "物") {
moveMouseTo(960, 45); // 移动到指定坐标
await sleep(100);
leftButtonDown();
log.info("移动鼠标");
const steps = 10; // 分成若干步移动
const stepDistance = 15; // 每步移动的距离
for (let j = 0; j < steps; j++) {
moveMouseBy(stepDistance, 0); // 每次移动 stepDistance 像素
await sleep(10); // 每次移动后延迟10毫秒
}
// 释放鼠标左键
await sleep(700);
leftButtonUp();await sleep(100);
await click(ElementClickX, 130); await sleep(1000); // 点击元素选项
const Switchingsteps = Switching+(4-Number(Character))
for (let i = 0; i < Switchingsteps; i++) {
await click(1840, 540); await sleep(200); // 循环点击切换选项
}
}
} else {
log.error(`无效元素: ${Element}`);
}
await sleep(1000);
// 执行按键和鼠标操作
try {
// 执行一系列鼠标点击操作
await click(125, 225); await sleep(1000); // 点击武器选项
await click(1600, 1005); await sleep(1000); // 点击替换当前武器
await click(500, 1005); await sleep(200);
await click(500, 905); await sleep(200); // 使用等级顺序排列
await moveMouseTo(605, 145); await sleep(200); // 初始化滑条
await leftButtonDown(); await sleep(600);
await leftButtonUp(); await sleep(200);
for (let i = 0; i < pageScrollCount; ++i) {
// 点击固定坐标
moveMouseTo(525, 920);
await sleep(500);
leftButtonDown();
await sleep(100);
// 根据条件选择运行的 JSON 文件
let filePath;
if (pageScrollCount >= 10 && (i + 1) % 10 === 0) {
filePath = `assets/pageScroll2.json`; // 每 10 次运行一次pageScroll2.json多移动一个像素点
} else {
filePath = `assets/pageScroll.json`; // 一般情况下运行 pageScroll.json
}
await keyMouseScript.runFile(filePath); // 平滑移动鼠标
await sleep(600);
leftButtonUp();
await sleep(100);
}
// 点击动态坐标
click(rightClickX, downClickY); // 点击选中物品的坐标
await sleep(1000);
click(1600, 1005); await sleep(1000); // 点击替换
click(1320, 755); await sleep(1000); // 确定替换
click(1845, 45); await sleep(1000); // 退出武器界面
click(1845, 45); await sleep(1000); // 退出角色界面
} catch (error) {
log.error(`执行按键或鼠标操作时发生错误:${error.message}`);
}
}
// 调用函数
await CharacterPath();
})();

View File

@@ -0,0 +1,13 @@
{
"manifest_version": 1,
"name": "选择切换武器的角色 ",
"version": "1.01",
"description": "可自定义 当前配队角色武器默认4号位角色默认四行为一页",
"authors": [
{
"name": "吉吉喵"
}
],
"settings_ui": "settings.json",
"main": "main.js"
}

View File

@@ -0,0 +1,61 @@
[
{
"name": "Character",
"type": "select",
"label": "出战位号默认4",
"options": [
"1号位",
"2号位",
"3号位",
"4号位"
]
},
{
"name": "pageScrollCount",
"type": "input-text",
"label": "默认:四行为一页\n滑页次数默认0"
},
{
"name": "rightOffset",
"type": "select",
"label": "----------------------\n武器按【等级排序】:\n位于第几列默认1",
"options": [
"1",
"2",
"3",
"4",
]
},
{
"name": "downOffset",
"type": "select",
"label": "位于第几行默认1",
"options": [
"1",
"2",
"3",
"4",
"5"
]
},
{
"name": "Element",
"type": "select",
"label": "=============\n\n需选则出战外的角色时\n----------------------\n元素默认'物'=无)\n选元素缩范围 非必填",
"options": [
"火",
"水",
"草",
"雷",
"风",
"冰",
"岩",
"物",
]
},
{
"name": "Switching",
"type": "input-text",
"label": "----------------------\n切换次数默认0\n填入从出战位号\n向右切换多少次"
}
]