mirror of
https://github.com/babalae/bettergi-scripts-list.git
synced 2026-03-25 04:59:52 +08:00
* 适配新的奖励领取界面及优化退出逻辑 - 在各功能函数中添加奖励界面退出校验机制 - 增强奖励尝试及路径执行的错误处理与日志记录 - 适配新的奖励领取界面,基于当前状态优化树脂消耗决策 * Update version to 4.3 and add new contributor information in manifest.json * ”将检查是否关闭奖励界面“的逻辑从"未找到对应的地脉花策略"中移除
71 lines
2.6 KiB
JavaScript
71 lines
2.6 KiB
JavaScript
/**
|
|
* 查找地脉花位置
|
|
* @param {string} country - 国家名称
|
|
* @param {string} type - 地脉花类型
|
|
* @returns {Promise<void>}
|
|
*/
|
|
this.findLeyLineOutcrop =
|
|
async function (country, type) {
|
|
currentFlower = null;
|
|
await sleep(1000);
|
|
log.info("开始寻找地脉花");
|
|
if (!config.mapPositions[country] || config.mapPositions[country].length === 0) {
|
|
await ensureExitRewardPage();
|
|
throw new Error(`未找到国家 ${country} 的位置信息`);
|
|
}
|
|
|
|
const positions = config.mapPositions[country];
|
|
await genshin.moveMapTo(positions[0].x, positions[0].y, country);
|
|
const found = await locateLeyLineOutcrop(type);
|
|
await sleep(1000); // 移动后等一下
|
|
if (found) return;
|
|
for (let retryCount = 1; retryCount < positions.length; retryCount++) {
|
|
const position = positions[retryCount];
|
|
log.info(`第 ${retryCount + 1} 次尝试定位地脉花`);
|
|
log.info(`移动到位置:(${position.x}, ${position.y}), ${position.name || '未命名位置'}`);
|
|
await genshin.moveMapTo(position.x, position.y);
|
|
|
|
const found = await locateLeyLineOutcrop(type);
|
|
if (found) return;
|
|
}
|
|
|
|
// 如果到这里还没找到
|
|
await ensureExitRewardPage();
|
|
throw new Error("寻找地脉花失败,已达最大重试次数");
|
|
}
|
|
|
|
/**
|
|
* 在地图上定位地脉花
|
|
* @param {string} type - 地脉花类型
|
|
* @returns {Promise<boolean>} 是否找到地脉花
|
|
*/
|
|
this.locateLeyLineOutcrop =
|
|
async function (type) {
|
|
await sleep(500); // 确保画面稳定
|
|
await genshin.setBigMapZoomLevel(3.0);
|
|
|
|
const iconPath = type === "蓝花(经验书)"
|
|
? "assets/icon/Blossom_of_Revelation.png"
|
|
: "assets/icon/Blossom_of_Wealth.png";
|
|
|
|
const captureRegion = captureGameRegion();
|
|
const flowerList = captureRegion.findMulti(RecognitionObject.TemplateMatch(file.ReadImageMatSync(iconPath)));
|
|
captureRegion.dispose();
|
|
|
|
if (flowerList && flowerList.count > 0) {
|
|
currentFlower = flowerList[0];
|
|
|
|
const center = genshin.getPositionFromBigMap();
|
|
const mapZoomLevel = genshin.getBigMapZoomLevel();
|
|
const mapScaleFactor = 2.361;
|
|
|
|
leyLineX = (960 - currentFlower.x - 25) * mapZoomLevel / mapScaleFactor + center.x;
|
|
leyLineY = (540 - currentFlower.y - 25) * mapZoomLevel / mapScaleFactor + center.y;
|
|
|
|
log.info(`找到地脉花的坐标:(${leyLineX}, ${leyLineY})`);
|
|
return true;
|
|
} else {
|
|
log.warn("未找到地脉花");
|
|
return false;
|
|
}
|
|
} |