铁匠铺1.4更新 (#883)
* Delete repo/js/铁匠铺/readme(25.05.15).md * 铁匠铺1.4更新 --增加通知功能 * Add files via upload * Update repo/js/铁匠铺/main.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update repo/js/铁匠铺/main.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update repo/js/铁匠铺/main.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: 秋云 <physligl@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,15 @@
|
|||||||
(async function () {
|
(async function () {
|
||||||
// 设置游戏基础参数
|
// 设置通知状态
|
||||||
|
let notice = settings.notice ?? false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 设置游戏基础参数/初始化
|
||||||
setGameMetrics(1920, 1080, 1.25); // 设置编写脚本环境的游戏分辨率和DPI缩放
|
setGameMetrics(1920, 1080, 1.25); // 设置编写脚本环境的游戏分辨率和DPI缩放
|
||||||
await genshin.returnMainUi(); // 返回主界面
|
await genshin.returnMainUi(); // 返回主界面
|
||||||
|
if (notice) {
|
||||||
|
notification.send("自动锻造矿石脚本开始");
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// 读取用户配置
|
// 读取用户配置
|
||||||
@@ -56,71 +64,85 @@
|
|||||||
let recognitionObject = RecognitionObject.TemplateMatch(template, x, y, searchWidth, searchHeight);
|
let recognitionObject = RecognitionObject.TemplateMatch(template, x, y, searchWidth, searchHeight);
|
||||||
|
|
||||||
// 设置识别阈值和通道
|
// 设置识别阈值和通道
|
||||||
/* prettier-ignore */
|
recognitionObject.threshold = 0.85; // 设置识别阈值
|
||||||
recognitionObject.threshold = 0.85; // 设置识别阈值
|
recognitionObject.Use3Channels = true; // 使用三通道匹配
|
||||||
recognitionObject.Use3Channels = true; // 使用三通道匹配
|
|
||||||
|
|
||||||
let result = captureGameRegion().find(recognitionObject);
|
let result = captureGameRegion().find(recognitionObject);
|
||||||
return result.isExist() ? result : null;
|
return result.isExist() ? result : null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(`图像识别失败,路径: ${imagePath}, 错误: ${error.message}`);
|
if (notice) {
|
||||||
|
notification.error(`图像识别失败,路径: ${imagePath}, 错误: ${error.message}`);
|
||||||
|
} else {
|
||||||
|
log.error(`图像识别失败,路径: ${imagePath}, 错误: ${error.message}`);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自动前往铁匠铺
|
// 自动前往铁匠铺
|
||||||
async function autoSmithy(smithyName) {
|
async function autoSmithy(smithyName) {
|
||||||
|
|
||||||
log.info(`自动前往 ${smithyName}`);
|
log.info(`自动前往 ${smithyName}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let filePath = `assets/Pathing/${smithyName}.json`;
|
let filePath = `assets/Pathing/${smithyName}.json`;
|
||||||
await pathingScript.runFile(filePath);
|
await pathingScript.runFile(filePath);
|
||||||
|
if (notice) {
|
||||||
|
notification.send(`已抵达 ${smithyName}`);
|
||||||
|
} else {
|
||||||
|
log.info(`已抵达 ${smithyName}`);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(`执行 ${smithyName} 路径时发生错误`);
|
if (notice) {
|
||||||
log.error(error.toString());
|
notification.error(`执行 ${smithyName} 路径时发生错误: ${error.toString()}`);
|
||||||
|
} else {
|
||||||
|
log.error(`执行 ${smithyName} 路径时发生错误: ${error.toString()}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 确认使用矿石
|
// 确认使用矿石
|
||||||
function determineOre() {
|
function determineOre() {
|
||||||
if (ore == "水晶块") {
|
let message;
|
||||||
log.info("将使用 水晶块 锻造矿石");
|
if (ore === "水晶块") {
|
||||||
} else if (ore == "紫晶块") {
|
message = "将使用 水晶块 锻造矿石";
|
||||||
log.info("将使用 紫晶块 锻造矿石");
|
} else if (ore === "紫晶块") {
|
||||||
} else if (ore == "萃凝晶") {
|
message = "将使用 紫晶块 锻造矿石";
|
||||||
log.info("将使用 萃凝晶 锻造矿石");
|
} else if (ore === "萃凝晶") {
|
||||||
|
message = "将使用 萃凝晶 锻造矿石";
|
||||||
} else {
|
} else {
|
||||||
log.info("无指定矿石,将使用 水晶块 锻造矿石");
|
message = "无指定矿石,将使用 水晶块 锻造矿石";
|
||||||
}
|
}
|
||||||
|
log.info(message);
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 锻造矿石操作
|
// 锻造矿石操作
|
||||||
const forgeOre = async function (smithyName) {
|
const forgeOre = async function (smithyName) {
|
||||||
// 对话
|
// 对话
|
||||||
/* prettier-ignore */
|
await sleep(1000); keyPress("F"); // 开始交互
|
||||||
{
|
await sleep(1000); await click(960, 600); //
|
||||||
await sleep(1000);keyPress("F"); // 开始交互
|
await sleep(1000); await click(960, 600); // 跳过第一个对话
|
||||||
await sleep(1000);await click(960, 600); //
|
await sleep(1000); await click(1375, 500); // 跳过第一个对话
|
||||||
await sleep(1000);await click(960, 600); // 跳过第一个对话
|
await sleep(1000); await click(960, 600); await sleep(1000); // 跳过第二个对话
|
||||||
await sleep(1000);await click(1375, 500); // 跳过第一个对话
|
await click(960, 600); await sleep(1000); // 跳过第二个对话
|
||||||
await sleep(1000);await click(960, 600);await sleep(1000); // 跳过第二个对话
|
|
||||||
await click(960, 600);await sleep(1000); // 跳过第二个对话
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("已进入锻造界面,准备锻造");
|
log.info("已进入锻造界面,准备锻造");
|
||||||
// 锻造领取
|
// 锻造领取
|
||||||
/* prettier-ignore */
|
await click(520, 140); await sleep(1000); // 选择锻造队列
|
||||||
{
|
await click(170, 1010); await sleep(1000); // 领取全部
|
||||||
await click(520, 140);await sleep(1000); // 选择锻造队列
|
await click(960, 900); await sleep(1000); // 确认
|
||||||
await click(170, 1010);await sleep(1000); // 领取全部
|
click(220, 150); await sleep(1000); // 点击"配方"
|
||||||
await click(960, 900);await sleep(1000); // 确认
|
|
||||||
click(220, 150);await sleep(1000); // 点击"配方"
|
|
||||||
}
|
|
||||||
|
|
||||||
determineOre();
|
determineOre();
|
||||||
|
|
||||||
// 根据用户选择的矿石进行锻造
|
// 根据用户选择的矿石进行锻造
|
||||||
if (!imagePath) {
|
if (!imagePath) {
|
||||||
log.error(`未找到矿石图像路径: ${chineseDescription}`);
|
if (notice) {
|
||||||
|
notification.error(`未找到矿石图像路径: ${chineseDescription}`);
|
||||||
|
} else {
|
||||||
|
log.error(`未找到矿石图像路径: ${chineseDescription}`);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.info(`开始识别矿石: ${chineseDescription}`);
|
log.info(`开始识别矿石: ${chineseDescription}`);
|
||||||
|
|
||||||
@@ -133,32 +155,46 @@
|
|||||||
const imageResult = recognizeImage(imagePath, scanX, scanY, 70, 70);
|
const imageResult = recognizeImage(imagePath, scanX, scanY, 70, 70);
|
||||||
|
|
||||||
if (imageResult) {
|
if (imageResult) {
|
||||||
log.info(`通过图像识别找到矿石: ${chineseDescription}`);
|
|
||||||
imageResult.click();
|
imageResult.click();
|
||||||
await sleep(2000); // 等待点击生效
|
await sleep(2000); // 等待点击生效
|
||||||
|
if (notice) {
|
||||||
|
notification.send(`通过图像识别找到矿石: ${chineseDescription}`);
|
||||||
|
} else {
|
||||||
|
log.info(`通过图像识别找到矿石: ${chineseDescription}`);
|
||||||
|
}
|
||||||
foundIngredient = true;
|
foundIngredient = true;
|
||||||
|
|
||||||
/* prettier-ignore */
|
|
||||||
// 点击“开始锻造”3次
|
// 点击“开始锻造”3次
|
||||||
{ await sleep(1000); click(1645, 1015); await sleep(1000); click(1645, 1015); await sleep(1000); }
|
{ await sleep(1000); click(1645, 1015); await sleep(1000); click(1645, 1015); await sleep(1000); }
|
||||||
|
|
||||||
break; // 找到矿石后退出循环
|
break; // 找到矿石后退出循环
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!foundIngredient) {
|
if (!foundIngredient) {
|
||||||
log.error(`未能识别到矿石: ${chineseDescription}`);
|
if (notice) {
|
||||||
|
notification.error(`未能识别到矿石: ${chineseDescription}`);
|
||||||
|
} else {
|
||||||
|
log.error(`未能识别到矿石: ${chineseDescription}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 退出锻造界面
|
// 退出锻造界面
|
||||||
log.info("锻造结束,退出界面");
|
await click(520, 140); await sleep(1000); // 选择锻造队列
|
||||||
|
if (notice) {
|
||||||
|
notification.send("锻造结束,退出界面");
|
||||||
|
} else {
|
||||||
|
log.info("锻造结束,退出界面");
|
||||||
|
}
|
||||||
keyPress("ESCAPE");
|
keyPress("ESCAPE");
|
||||||
};
|
};
|
||||||
|
|
||||||
await autoSmithy(smithyName); // 寻路函数
|
await autoSmithy(smithyName); // 寻路函数
|
||||||
await forgeOre(smithyName); // 锻造函数
|
await forgeOre(smithyName); // 锻造函数
|
||||||
await genshin.returnMainUi(); // 返回主界面
|
await genshin.returnMainUi(); // 返回主界面
|
||||||
|
|
||||||
/* prettier-ignore */
|
{ keyDown("S"); await sleep(1000); keyUp("S"); await sleep(1000); } // 后退两步
|
||||||
{keyDown("S");await sleep(1000);keyUp("S");await sleep(1000); } // 后退两步
|
|
||||||
|
if (notice) {
|
||||||
|
notification.send("自动锻造矿石脚本结束");
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 1,
|
"manifest_version": 1,
|
||||||
"name": "自动锻造魔矿(识图)",
|
"name": "自动锻造魔矿",
|
||||||
"version": "1.3(2025.05.15版)",
|
"version": "1.4(2025.05.20版)",
|
||||||
"bgi_version": "0.44.0",
|
"bgi_version": "0.44.0",
|
||||||
"description": "自动选择铁匠铺和使用矿物去锻造精锻矿。\n使用前请阅读“readme”文件。\n鸣谢:寒露,蜜柑魚",
|
"description": "自动选择铁匠铺和使用矿物去锻造精锻矿。\n \n使用前请阅读“readme”文件。 \n---更新说明--- \n- 新增通知功能",
|
||||||
"tags": ["铁匠铺", "锻造", "精锻用矿"],
|
"tags": ["铁匠铺", "锻造", "精锻用矿"],
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "呱呱z"
|
"name": "呱呱z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "寒露"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "蜜柑魚"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"settings_ui": "settings.json",
|
"settings_ui": "settings.json",
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name 自动锻造魔矿脚本
|
// @name 自动锻造魔矿脚本
|
||||||
// @version 1.2
|
// @version 1.4
|
||||||
// @description 自动前往铁匠铺并锻造魔矿,通过识图模式自动选择矿石
|
// @description 自动前往铁匠铺并锻造魔矿,通过识图模式自动选择矿石
|
||||||
// @author 呱呱 z
|
// @author 呱呱z
|
||||||
// @match 原神版本:5.6;BGI 版本:0.45.1
|
// @match 原神版本:5.6;BGI 版本:0.45.1
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
# 自动锻造魔矿脚本
|
# 自动锻造魔矿脚本
|
||||||
|
|
||||||
## 简介
|
## 简介
|
||||||
本脚本可自动前往铁匠铺并锻造魔矿,利用识图模式智能选择需要的矿石,让自定义操作更加便捷。
|
本脚本可自动前往铁匠铺并利用识图模式选择需要的矿石锻造魔矿。
|
||||||
|
|
||||||
## 文件结构
|
## 文件结构
|
||||||
- **main.js**:负责核心业务逻辑,包括前往铁匠铺和执行锻造任务。
|
- **main.js**:负责核心业务逻辑,包括前往铁匠铺和执行锻造任务。
|
||||||
@@ -50,7 +50,10 @@
|
|||||||
|
|
||||||
## 更新日志
|
## 更新日志
|
||||||
|
|
||||||
### 1.2(2025.05.15)
|
### 1.4(2025.05.20)
|
||||||
|
- 新增通知功能
|
||||||
|
|
||||||
|
### 1.3(2025.05.15)
|
||||||
- 修复选择“萃凝晶”时无法识别的问题
|
- 修复选择“萃凝晶”时无法识别的问题
|
||||||
- 仓库内新增标签。
|
- 仓库内新增标签。
|
||||||
|
|
||||||
@@ -1,17 +1,22 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "smithyName", // 变量名,在js内使用 settings.变量名 获取对应的配置值
|
"name": "notice",
|
||||||
"type": "select", // 类型
|
"type": "checkbox",
|
||||||
"label": "选择铁匠铺(默认:枫丹铁匠铺)",
|
"label": "通过BGI通知系统发送详细通知"
|
||||||
"options": [
|
},
|
||||||
"蒙德铁匠铺",
|
{
|
||||||
"璃月铁匠铺",
|
"name": "smithyName",
|
||||||
"稻妻铁匠铺",
|
"type": "select",
|
||||||
"须弥铁匠铺",
|
"label": "选择铁匠铺(默认:枫丹铁匠铺)",
|
||||||
"枫丹铁匠铺"
|
"options": [
|
||||||
]
|
"蒙德铁匠铺",
|
||||||
},
|
"璃月铁匠铺",
|
||||||
{
|
"稻妻铁匠铺",
|
||||||
|
"须弥铁匠铺",
|
||||||
|
"枫丹铁匠铺"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
"name": "ore",
|
"name": "ore",
|
||||||
"type": "select",
|
"type": "select",
|
||||||
"label": "锻造用矿(默认:水晶块)",
|
"label": "锻造用矿(默认:水晶块)",
|
||||||
@@ -24,4 +29,4 @@
|
|||||||
"萃凝晶"
|
"萃凝晶"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Reference in New Issue
Block a user