Compare commits
2 Commits
beb7084359
...
b370dc2514
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b370dc2514 | ||
|
|
1a4381a6cf |
10
repo.json
10
repo.json
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"time": "20250514195416",
|
||||
"time": "20250514213753",
|
||||
"url": "https://github.com/babalae/bettergi-scripts-list/archive/refs/heads/main.zip",
|
||||
"file": "repo.json",
|
||||
"indexes": [
|
||||
@@ -45947,12 +45947,12 @@
|
||||
{
|
||||
"name": "OCR购买食材",
|
||||
"type": "directory",
|
||||
"hash": "e27d217775bfc1e91832d5a455d126b549cbaf64",
|
||||
"version": "1.30420",
|
||||
"hash": "bd945d0923464a91c0cdc543bedb0046185b79b8",
|
||||
"version": "1.30513",
|
||||
"author": "吉吉喵",
|
||||
"description": "选择购买食材OCR~|~至少需要0.44版本bgi,对NPC和材料进行文字、图像识别。\n一般食材杂货在蒙德、璃月、稻妻、枫丹杂货商购买。\n10鱼肉、10螃蟹在卯师傅、珀姆、布特罗斯、阿扎莱和志村勘兵卫购买。\n咖啡豆在须弥、枫丹咖啡馆购买。\n增加对话F图像识别,增加个别字识别容错;增加香辛料,在阿扎莱处购买",
|
||||
"description": "选择购买食材OCR~|~至少需要0.44版本bgi,对NPC和材料进行文字、图像识别。\n一般食材杂货在蒙德、璃月、稻妻、枫丹杂货商购买。\n10鱼肉、10螃蟹在卯师傅、珀姆、布特罗斯、阿扎莱和志村勘兵卫购买。\n咖啡豆在须弥、枫丹咖啡馆购买。\n增加对话F图像识别,增加个别字识别容错;增加香辛料,在阿扎莱处购买。\nv1.30513修复循环套叠,优化F未识别后的尝试方案。",
|
||||
"tags": [],
|
||||
"lastUpdated": "2025-05-14 09:53:16"
|
||||
"lastUpdated": "2025-05-14 21:37:05"
|
||||
},
|
||||
{
|
||||
"name": "PathingBenchmark",
|
||||
|
||||
@@ -92,7 +92,7 @@ const replacementMap = {
|
||||
const npcNames = {
|
||||
[mondstadtGroceryFilePath]: ["布兰琪"],
|
||||
[liyueGroceryFilePath]: ["东升"],
|
||||
[liyueWanminFilePath]: ["卯师傅"],// ["卯师傅", "卵师傅"]
|
||||
[liyueWanminFilePath]: ["卯师傅", "师傅"],// ["卯师傅", "卵师傅"]
|
||||
[groceryFilePath]: ["葵"],
|
||||
[charcoalFilePath]: ["志村勘"],
|
||||
[fengdanGroceryFilePath]: ["布希柯"],
|
||||
@@ -210,6 +210,7 @@ function performOcr(targetText, xRange, yRange, tolerance, timeout = 2000) {
|
||||
// 遍历识别结果,检查是否找到目标文本
|
||||
for (let i = 0; i < resList.count; i++) {
|
||||
let res = resList[i];
|
||||
// log.info("0CR结果-"+ res.text);
|
||||
// 后处理:根据替换映射表检查和替换错误识别的字符
|
||||
let correctedText = res.text;
|
||||
for (let [wrongChar, correctChar] of Object.entries(replacementMap)) {
|
||||
@@ -297,56 +298,71 @@ async function clickSelectedIngredients(selectedIngredients, filePath, npcNames)
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 F 图标和右边水平对齐的文字
|
||||
async function checkNpcAndFAlignment(npcName, fDialogueRo) {
|
||||
let ra = captureGameRegion();
|
||||
let fRes = ra.find(fDialogueRo);
|
||||
if (!fRes.isExist()) {
|
||||
let f_attempts = 0; // 初始化尝试次数
|
||||
while (f_attempts < 3) { // 最多尝试 3 次
|
||||
f_attempts++;
|
||||
log.info(`当前尝试次数:${f_attempts}`);
|
||||
// 检查 F 图标和右边水平对齐的文字
|
||||
async function checkNpcAndFAlignment(npcName, fDialogueRo) {
|
||||
let ra = captureGameRegion();
|
||||
let fRes = ra.find(fDialogueRo);
|
||||
if (!fRes.isExist()) {
|
||||
let f_attempts = null; // 初始化尝试次数
|
||||
while (f_attempts < 5) { // 最多尝试 4 次
|
||||
f_attempts++;
|
||||
log.info(`当前尝试次数:${f_attempts}`);
|
||||
|
||||
if (f_attempts === 1) {
|
||||
// 第一次未找到 F 图标
|
||||
await simulateKeyOperations("S", 200); // 后退 200 毫秒
|
||||
await sleep(200);
|
||||
await simulateKeyOperations("W", 800); // 前进 800 毫秒
|
||||
} else if (f_attempts === 2) {
|
||||
// 第二次未找到 F 图标
|
||||
log.info("重新加载路径文件");
|
||||
await pathingScript.runFile(filePath);
|
||||
await sleep(500);
|
||||
} else {
|
||||
// 第三次未找到 F 图标
|
||||
log.warn("尝试次数已达上限");
|
||||
return false;
|
||||
}
|
||||
log.warn(`尝试 ${f_attempts + 1}:寻找 F 图标`);
|
||||
if (f_attempts <= 3) {
|
||||
// 第 1-3 次尝试
|
||||
await simulateKeyOperations("S", 200); // 后退 200 毫秒
|
||||
await sleep(200);
|
||||
await simulateKeyOperations("W", 400); // 前进 400 毫秒
|
||||
await sleep(500);
|
||||
} else if (f_attempts === 4) {
|
||||
// 第 4 次尝试
|
||||
log.info("重新加载路径文件");
|
||||
await pathingScript.runFile(filePath);
|
||||
await sleep(500);
|
||||
} else {
|
||||
// 第 5 次尝试,尝试次数已达上限
|
||||
log.warn("尝试次数已达上限");
|
||||
break; // 找到后退出循环
|
||||
}
|
||||
}
|
||||
// 获取 F 图标的中心点 Y 坐标
|
||||
let centerYF = fRes.y + fRes.height / 2;
|
||||
|
||||
// 在 F 图标右侧水平方向上识别 NPC 名称
|
||||
let ocrResult = await performOcr(npcName, npcxRange, { min: fRes.y, max: fRes.y + fRes.height }, tolerance);
|
||||
if (!ocrResult.success) {
|
||||
log.warn(`OCR 识别未找到 NPC: ${npcName},尝试滚动`);
|
||||
return false;
|
||||
// 检查是否找到 F 图标
|
||||
fRes = ra.find(fDialogueRo); // 重新查找 F 图标
|
||||
if (fRes.isExist()) {
|
||||
log.info("找到 F 图标");
|
||||
break; // 找到后退出循环
|
||||
}
|
||||
log.warn(`尝试 ${f_attempts}:寻找 F 图标`);
|
||||
}
|
||||
|
||||
// 获取 NPC 名称的中心点 Y 坐标
|
||||
let centerYnpcName = ocrResult.y + ocrResult.height / 2;
|
||||
|
||||
// 检查 NPC 名称和 F 图标的中心点 Y 坐标是否在容错范围内
|
||||
if (Math.abs(centerYnpcName - centerYF) <= npctolerance) {
|
||||
return true;
|
||||
} else {
|
||||
log.info(`NPC '${npcName}' 和 F 图标未水平对齐, NPC: ${centerYnpcName}, F 图标: ${centerYF}`);
|
||||
// 如果尝试次数用完仍未找到 F 图标,返回 false
|
||||
if (!fRes.isExist()) {
|
||||
log.warn("经过多次尝试后仍未找到 F 图标");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取 F 图标的中心点 Y 坐标
|
||||
let centerYF = fRes.y + fRes.height / 2;
|
||||
|
||||
// 在 F 图标右侧水平方向上识别 NPC 名称
|
||||
let ocrResult = await performOcr(npcName, npcxRange, { min: fRes.y, max: fRes.y + fRes.height }, tolerance);
|
||||
if (!ocrResult.success) {
|
||||
log.warn(`OCR 识别未找到 NPC: ${npcName},尝试滚动`);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取 NPC 名称的中心点 Y 坐标
|
||||
let centerYnpcName = ocrResult.y + ocrResult.height / 2;
|
||||
|
||||
// 检查 NPC 名称和 F 图标的中心点 Y 坐标是否在容错范围内
|
||||
if (Math.abs(centerYnpcName - centerYF) <= npctolerance) {
|
||||
return true;
|
||||
} else {
|
||||
log.info(`NPC '${npcName}' 和 F 图标未水平对齐,NPC: ${centerYnpcName}, F 图标: ${centerYF}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 新增变量用于记录滚轮操作次数
|
||||
let scrollAttempts = 0;
|
||||
const maxScrollAttempts = 5; // 最大滚轮操作次数限制
|
||||
@@ -354,7 +370,6 @@ async function clickSelectedIngredients(selectedIngredients, filePath, npcNames)
|
||||
for (const npcName of npcNames) {
|
||||
log.info(`尝试识别 NPC: ${npcName}`);
|
||||
let isAligned = await checkNpcAndFAlignment(npcName, fDialogueRo);
|
||||
|
||||
while (!isAligned && scrollAttempts < maxScrollAttempts) {
|
||||
// 如果未水平对齐,执行滚轮操作
|
||||
await keyMouseScript.runFile(`assets/滚轮下翻.json`);
|
||||
@@ -368,13 +383,39 @@ async function clickSelectedIngredients(selectedIngredients, filePath, npcNames)
|
||||
}
|
||||
|
||||
// 重新检查 F 图标和 NPC 名称是否对齐
|
||||
isAligned = await checkNpcAndFAlignment(npcName, fDialogueRo);
|
||||
let ra = captureGameRegion();
|
||||
let fRes = ra.find(fDialogueRo);
|
||||
if (!fRes.isExist()) {
|
||||
log.warn("未找到 F 图标");
|
||||
continue; // 如果未找到 F 图标,继续下一次循环
|
||||
}
|
||||
|
||||
// 获取 F 图标的中心点 Y 坐标
|
||||
let centerYF = fRes.y + fRes.height / 2;
|
||||
|
||||
// 在 F 图标右侧水平方向上识别 NPC 名称
|
||||
let ocrResult = await performOcr(npcName, npcxRange, { min: fRes.y, max: fRes.y + fRes.height }, tolerance);
|
||||
if (!ocrResult.success) {
|
||||
log.warn(`OCR 识别未找到 NPC: ${npcName}`);
|
||||
continue; // 如果未找到 NPC 名称,继续下一次循环
|
||||
}
|
||||
|
||||
// 获取 NPC 名称的中心点 Y 坐标
|
||||
let centerYnpcName = ocrResult.y + ocrResult.height / 2;
|
||||
|
||||
// 检查 NPC 名称和 F 图标的中心点 Y 坐标是否在容错范围内
|
||||
if (Math.abs(centerYnpcName - centerYF) <= npctolerance) {
|
||||
isAligned = true;
|
||||
log.info(`NPC '${npcName}' 和 F 图标水平对齐,NPC: ${centerYnpcName}, F 图标: ${centerYF}`);
|
||||
} else {
|
||||
log.info(`NPC '${npcName}' 和 F 图标未水平对齐,NPC: ${centerYnpcName}, F 图标: ${centerYF}`);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果水平对齐,执行交互操作
|
||||
if (isAligned) {
|
||||
keyPress("F");
|
||||
await sleep(2500);
|
||||
// 如果水平对齐,执行交互操作
|
||||
if (isAligned) {
|
||||
keyPress("F");
|
||||
await sleep(2500);
|
||||
|
||||
// 首次执行点击操作
|
||||
await performClickOperations(filePath);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "选择购买食材OCR",
|
||||
"version": "1.30420",
|
||||
"description": "至少需要0.44版本bgi,对NPC和材料进行文字、图像识别。\n一般食材杂货在蒙德、璃月、稻妻、枫丹杂货商购买。\n10鱼肉、10螃蟹在卯师傅、珀姆、布特罗斯、阿扎莱和志村勘兵卫购买。\n咖啡豆在须弥、枫丹咖啡馆购买。\n增加对话F图像识别,增加个别字识别容错;增加香辛料,在阿扎莱处购买",
|
||||
"version": "1.30513",
|
||||
"description": "至少需要0.44版本bgi,对NPC和材料进行文字、图像识别。\n一般食材杂货在蒙德、璃月、稻妻、枫丹杂货商购买。\n10鱼肉、10螃蟹在卯师傅、珀姆、布特罗斯、阿扎莱和志村勘兵卫购买。\n咖啡豆在须弥、枫丹咖啡馆购买。\n增加对话F图像识别,增加个别字识别容错;增加香辛料,在阿扎莱处购买。\nv1.30513修复循环套叠,优化F未识别后的尝试方案。",
|
||||
"authors": [
|
||||
{
|
||||
"name": "吉吉喵"
|
||||
|
||||
Reference in New Issue
Block a user