适配原神5.7版本更新,修复打开自定义标记的bug (#1124)
This commit is contained in:
@@ -773,13 +773,13 @@ async function adjustViewForReward(boxIconRo, token) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭自定义标记,使用前确保在地图界面
|
* 关闭自定义标记
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
async function closeCustomMarks() {
|
async function closeCustomMarks() {
|
||||||
// await genshin.returnMainUi();
|
await genshin.returnMainUi();
|
||||||
// keyPress("M");
|
keyPress("M");
|
||||||
await sleep(600);
|
await sleep(1000);
|
||||||
click(60, 1020);
|
click(60, 1020);
|
||||||
await sleep(600);
|
await sleep(600);
|
||||||
|
|
||||||
@@ -797,11 +797,13 @@ async function closeCustomMarks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打开自定义标记,使用前确保在地图界面
|
* 打开自定义标记
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
async function openCustomMarks() {
|
async function openCustomMarks() {
|
||||||
await sleep(600);
|
await genshin.returnMainUi();
|
||||||
|
keyPress("M");
|
||||||
|
await sleep(1000);
|
||||||
click(60, 1020);
|
click(60, 1020);
|
||||||
await sleep(600);
|
await sleep(600);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 1,
|
"manifest_version": 1,
|
||||||
"name": "全自动地脉花",
|
"name": "全自动地脉花",
|
||||||
"version": "3.5.1",
|
"version": "4.0",
|
||||||
"tags": ["地脉花"],
|
"tags": ["地脉花"],
|
||||||
"bgi_version": "0.44.7",
|
"bgi_version": "0.44.7",
|
||||||
"description": "基于OCR图像识别的全自动刷取地脉花。\n💡更多信息请查看在线手册:https://hcnsvf0s8d0s.feishu.cn/wiki/Tb1twpThLi7UlykqcYOcuccTnjJ \n\n----------注意事项----------\n●仅支持BetterGI 0.44.7 及以上版本!\n●部分地脉花因特殊原因不支持全自动,具体的点位请在手册中查看。\n●树脂使用的优先级:2倍原粹树脂 > 浓缩树脂 > 原粹树脂。\n●运行时会传送到七天神像设置中设置的七天神像,需要关闭七天神像设置中的“是否就近七天神像恢复血量”,并指定七天神像。\n●战斗策略注意调度器设置中地图追踪行走配置里的“允许在JsSpript中使用”和“覆盖JS中的自动战斗配置”,只有在都打开的情况下脚本才会使用下面的战斗配置,否则会使用独立任务中的战斗策略。战斗超时时间不能大于脚本自定义配置中的时间。\n\n如果遇到问题,请先参照手册中的方法进行解决。",
|
"description": "基于OCR图像识别的全自动刷取地脉花。\n💡更多信息请查看在线手册:https://hcnsvf0s8d0s.feishu.cn/wiki/Tb1twpThLi7UlykqcYOcuccTnjJ \n\n----------注意事项----------\n●仅支持BetterGI 0.44.7 及以上版本!\n●部分地脉花因特殊原因不支持全自动,具体的点位请在手册中查看。\n●树脂使用的优先级:2倍原粹树脂 > 浓缩树脂 > 原粹树脂。\n●运行时会传送到七天神像设置中设置的七天神像,需要关闭七天神像设置中的“是否就近七天神像恢复血量”,并指定七天神像。\n●战斗策略注意调度器设置中地图追踪行走配置里的“允许在JsSpript中使用”和“覆盖JS中的自动战斗配置”,只有在都打开的情况下脚本才会使用下面的战斗配置,否则会使用独立任务中的战斗策略。战斗超时时间不能大于脚本自定义配置中的时间。\n\n如果遇到问题,请先参照手册中的方法进行解决。",
|
||||||
|
|||||||
@@ -33,6 +33,12 @@
|
|||||||
"label": "刷取次数,默认6次",
|
"label": "刷取次数,默认6次",
|
||||||
"default": "6"
|
"default": "6"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "useFragileResin",
|
||||||
|
"type": "checkbox",
|
||||||
|
"label": "是否使用脆弱树脂\n开启后会在其他树脂用完后使用",
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "team",
|
"name": "team",
|
||||||
"type": "input-text",
|
"type": "input-text",
|
||||||
@@ -49,6 +55,11 @@
|
|||||||
"label": "战斗超时时间,单位秒,默认120秒",
|
"label": "战斗超时时间,单位秒,默认120秒",
|
||||||
"default": 120
|
"default": 120
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "useAdventurerHandbook",
|
||||||
|
"type": "checkbox",
|
||||||
|
"label": "是否使用冒险之证寻找地脉花【开发中】"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "isNotification",
|
"name": "isNotification",
|
||||||
"type": "checkbox",
|
"type": "checkbox",
|
||||||
|
|||||||
@@ -65,43 +65,53 @@ async function () {
|
|||||||
// 分析识别到的文本
|
// 分析识别到的文本
|
||||||
for (let i = 0; i < resList.count; i++) {
|
for (let i = 0; i < resList.count; i++) {
|
||||||
let res = resList[i];
|
let res = resList[i];
|
||||||
if (res.text.includes("使用浓缩树脂")) {
|
if (res.text.includes("浓缩树脂")) {
|
||||||
isValid = true;
|
isValid = true;
|
||||||
condensedResin = res;
|
condensedResin = res;
|
||||||
} else if (res.text.includes("使用原粹树脂")) {
|
} else if (res.text.includes("原粹树脂")) {
|
||||||
isValid = true;
|
isValid = true;
|
||||||
originalResin = res;
|
originalResin = res;
|
||||||
} else if (res.text.includes("补充原粹树脂")) {
|
} else if (res.text.includes("脆弱树脂") && settings.fragileResin) {
|
||||||
isValid = true;
|
isValid = true;
|
||||||
isResinEmpty = true;
|
fragileResin = res;
|
||||||
} else if (res.text.includes("产出")) {
|
} else if (res.text.includes("双倍掉落")) {
|
||||||
isValid = true;
|
isValid = true;
|
||||||
dobuleReward = true;
|
dobuleReward = true;
|
||||||
|
} else {
|
||||||
|
isValid = true;
|
||||||
|
isResinEmpty = true;
|
||||||
}
|
}
|
||||||
} // 处理不同的树脂情况
|
} // 处理不同的树脂情况
|
||||||
if (originalResin && dobuleReward == true) {
|
if (originalResin && dobuleReward) {
|
||||||
log.info("选择使用原粹树脂,获得双倍产出");
|
log.info("选择使用原粹树脂,获得双倍产出");
|
||||||
await clickWithVerification(
|
await clickWithVerification(
|
||||||
Math.round(originalResin.x + originalResin.width / 2),
|
Math.round(originalResin.x + originalResin.width / 2) + 400,
|
||||||
Math.round(originalResin.y + originalResin.height / 2),
|
Math.round(originalResin.y + originalResin.height / 2),
|
||||||
"树脂"
|
"使用"
|
||||||
);
|
);
|
||||||
} else if (condensedResin) {
|
} else if (condensedResin) {
|
||||||
log.info("选择使用浓缩树脂");
|
log.info("选择使用浓缩树脂");
|
||||||
await clickWithVerification(
|
await clickWithVerification(
|
||||||
Math.round(condensedResin.x + condensedResin.width / 2),
|
Math.round(condensedResin.x + condensedResin.width / 2) + 400,
|
||||||
Math.round(condensedResin.y + condensedResin.height / 2),
|
Math.round(condensedResin.y + condensedResin.height / 2),
|
||||||
"树脂"
|
"使用"
|
||||||
);
|
);
|
||||||
} else if (originalResin) {
|
} else if (originalResin) {
|
||||||
log.info("选择使用原粹树脂");
|
log.info("选择使用原粹树脂");
|
||||||
await clickWithVerification(
|
await clickWithVerification(
|
||||||
Math.round(originalResin.x + originalResin.width / 2),
|
Math.round(originalResin.x + originalResin.width / 2) + 400,
|
||||||
Math.round(originalResin.y + originalResin.height / 2),
|
Math.round(originalResin.y + originalResin.height / 2),
|
||||||
"树脂"
|
"使用"
|
||||||
|
);
|
||||||
|
} else if (fragileResin) {
|
||||||
|
log.info("选择使用脆弱树脂");
|
||||||
|
await clickWithVerification(
|
||||||
|
Math.round(fragileResin.x + fragileResin.width / 2) + 400,
|
||||||
|
Math.round(fragileResin.y + fragileResin.height / 2),
|
||||||
|
"使用"
|
||||||
);
|
);
|
||||||
} else if (isResinEmpty) {
|
} else if (isResinEmpty) {
|
||||||
log.error("识别到补充原粹树脂,看来树脂用完了呢");
|
log.error("树脂用完了呢");
|
||||||
keyPress("VK_ESCAPE");
|
keyPress("VK_ESCAPE");
|
||||||
throw new Error("树脂已用完");
|
throw new Error("树脂已用完");
|
||||||
}
|
}
|
||||||
|
|||||||
124
repo/js/AutoLeyLineOutcrop/utils/attemptRewardOld.js
Normal file
124
repo/js/AutoLeyLineOutcrop/utils/attemptRewardOld.js
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
/**
|
||||||
|
* 带验证的单击函数
|
||||||
|
* @param {number} x - X坐标
|
||||||
|
* @param {number} y - Y坐标
|
||||||
|
* @param {string} targetText - 需要验证消失的目标文字
|
||||||
|
* @param {number} maxRetries - 最大重试次数,默认为10
|
||||||
|
* @returns {Promise<boolean>} 是否成功
|
||||||
|
*/
|
||||||
|
this.clickWithVerification = async function(x, y, targetText, maxRetries = 20) {
|
||||||
|
for (let i = 0; i < maxRetries; i++) {
|
||||||
|
click(x, y);
|
||||||
|
await sleep(400);
|
||||||
|
|
||||||
|
// 验证目标文字是否消失
|
||||||
|
let resList = captureGameRegion().findMulti(ocrRoThis);
|
||||||
|
let textFound = false;
|
||||||
|
|
||||||
|
if (resList && resList.count > 0) {
|
||||||
|
for (let j = 0; j < resList.count; j++) {
|
||||||
|
if (resList[j].text.includes(targetText)) {
|
||||||
|
textFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果文字消失了,说明点击成功
|
||||||
|
if (!textFound) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
log.warn(`经过${maxRetries}次点击,文字"${targetText}"仍未消失`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 尝试领取地脉花奖励
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
this.attemptReward =
|
||||||
|
async function () {
|
||||||
|
const MAX_RETRY = 5;
|
||||||
|
|
||||||
|
// 超时处理
|
||||||
|
if (retryCount >= MAX_RETRY) {
|
||||||
|
retryCount = 0;
|
||||||
|
throw new Error("超过最大重试次数,领取奖励失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("开始领取地脉奖励");
|
||||||
|
keyPress("F");
|
||||||
|
await sleep(500);
|
||||||
|
|
||||||
|
// 识别是否为地脉之花界面
|
||||||
|
let resList = captureGameRegion().findMulti(ocrRoThis); // 使用预定义的ocrRoThis对象
|
||||||
|
let isValid = false;
|
||||||
|
let condensedResin = null;
|
||||||
|
let originalResin = null;
|
||||||
|
let isResinEmpty = false;
|
||||||
|
let dobuleReward = false;
|
||||||
|
|
||||||
|
if (resList && resList.count > 0) {
|
||||||
|
// 分析识别到的文本
|
||||||
|
for (let i = 0; i < resList.count; i++) {
|
||||||
|
let res = resList[i];
|
||||||
|
if (res.text.includes("使用浓缩树脂")) {
|
||||||
|
isValid = true;
|
||||||
|
condensedResin = res;
|
||||||
|
} else if (res.text.includes("使用原粹树脂")) {
|
||||||
|
isValid = true;
|
||||||
|
originalResin = res;
|
||||||
|
} else if (res.text.includes("补充原粹树脂")) {
|
||||||
|
isValid = true;
|
||||||
|
isResinEmpty = true;
|
||||||
|
} else if (res.text.includes("产出")) {
|
||||||
|
isValid = true;
|
||||||
|
dobuleReward = true;
|
||||||
|
}
|
||||||
|
} // 处理不同的树脂情况
|
||||||
|
if (originalResin && dobuleReward == true) {
|
||||||
|
log.info("选择使用原粹树脂,获得双倍产出");
|
||||||
|
await clickWithVerification(
|
||||||
|
Math.round(originalResin.x + originalResin.width / 2),
|
||||||
|
Math.round(originalResin.y + originalResin.height / 2),
|
||||||
|
"树脂"
|
||||||
|
);
|
||||||
|
} else if (condensedResin) {
|
||||||
|
log.info("选择使用浓缩树脂");
|
||||||
|
await clickWithVerification(
|
||||||
|
Math.round(condensedResin.x + condensedResin.width / 2),
|
||||||
|
Math.round(condensedResin.y + condensedResin.height / 2),
|
||||||
|
"树脂"
|
||||||
|
);
|
||||||
|
} else if (originalResin) {
|
||||||
|
log.info("选择使用原粹树脂");
|
||||||
|
await clickWithVerification(
|
||||||
|
Math.round(originalResin.x + originalResin.width / 2),
|
||||||
|
Math.round(originalResin.y + originalResin.height / 2),
|
||||||
|
"树脂"
|
||||||
|
);
|
||||||
|
} else if (isResinEmpty) {
|
||||||
|
log.error("识别到补充原粹树脂,看来树脂用完了呢");
|
||||||
|
keyPress("VK_ESCAPE");
|
||||||
|
throw new Error("树脂已用完");
|
||||||
|
}
|
||||||
|
if (settings.friendshipTeam) {
|
||||||
|
log.info("切换回战斗队伍");
|
||||||
|
await sleep(500);
|
||||||
|
const switchSuccess = await switchTeam(settings.team);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 界面不正确,尝试重试
|
||||||
|
if (!isValid) {
|
||||||
|
log.info("当前界面不是地脉之花界面,重试");
|
||||||
|
await genshin.returnMainUi();
|
||||||
|
await sleep(1000);
|
||||||
|
retryCount++;
|
||||||
|
await autoNavigateToReward();
|
||||||
|
await attemptReward();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,8 +7,6 @@
|
|||||||
this.findLeyLineOutcrop =
|
this.findLeyLineOutcrop =
|
||||||
async function (country, type) {
|
async function (country, type) {
|
||||||
currentFlower = null;
|
currentFlower = null;
|
||||||
keyPress("M");
|
|
||||||
await sleep(1000);
|
|
||||||
await closeCustomMarks();
|
await closeCustomMarks();
|
||||||
await sleep(1000);
|
await sleep(1000);
|
||||||
log.info("开始寻找地脉花");
|
log.info("开始寻找地脉花");
|
||||||
|
|||||||
Reference in New Issue
Block a user