自动地脉花掉落物主动捡取 (#3473)
* 新增两个简单的脚本 * 1 * 移除重复功能的脚本,把新功能添加到现有脚本上 * 署名顺带更新文档 * bug fix * 清理了忘记处理的调试代码,修复了识别不到浓缩的bug,修复树脂耗尽模式+刷取次数取小值的情况下,当OCR计算次数>手动设置刷取次数时无法正确终止脚本的bug * 修复AI留下的作用域bug * 调整设置缩进 * 设置文案修改 * 调整缩进 * fix typo. * 清理新增脚本提交 * 修复双倍模式下可能会用到浓缩的bug,统一了错误处理逻辑 --------- Co-authored-by: 起个名字好难的喵 <[email protected]>
This commit is contained in:
1 parent
05ad9cfce7
commit
7dad5733f8
9 files changed
+1166
-519
No files matched your search
Vendored
+2
-2
@@ -1033,7 +1033,7 @@ declare class AutoLeyLineOutcropParam {
|
||||
isResinExhaustionMode: boolean;
|
||||
/** 耗尽模式取小值 */
|
||||
openModeCountMin: boolean;
|
||||
/** 是否使用冒险之证寻找地脉花 */
|
||||
/** 不使用冒险之证寻路(启用后改用内置路线,不通过冒险之证定位地脉花) */
|
||||
useAdventurerHandbook: boolean;
|
||||
/** 好感队名称 */
|
||||
friendshipTeam: string;
|
||||
@@ -4620,4 +4620,4 @@ declare class Task<T = void> {
|
||||
declare Then: typeof Task.prototype.then;
|
||||
|
||||
// ==== END AUTO-GENERATED ALIASES ====
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,9 @@
|
||||
- **全自动运行**:配置好之后,只需要点击运行,就可以全部打完,无需任何其他操作。
|
||||
- **自动寻找地脉花**:通过大地图定位地脉花位置的方式来寻找地脉花,并执行后续的路线。
|
||||
- **自动开启地脉花奖励,优先使用浓缩树脂**:领取奖励时优先选择浓缩树脂,当存在双倍奖励活动(地脉移涌或星之归还)时会优先选择双倍奖励。
|
||||
- **双倍检测模式**:开启后仅在检测到双倍产出时才刷地脉,刷完后自动退出,适合只想用双倍活动的玩家。
|
||||
- **材料拾取**:领奖后自动追踪拾取怪物掉落物,搭配20树脂模式可高效获取怪物素材(会触发短暂战斗)。
|
||||
- **20树脂模式(怪物素材慢刷)**:每次仅消耗20体力,以效率换取更多怪物掉落素材机会,配合材料拾取效果更佳。
|
||||
- **树脂耗尽模式**:根据设置统计当前的树脂情况,计算出需要运行的次数,运行结束后再次判断,若结束后统计到未消耗的树脂则继续执行(最多3次)
|
||||
- **树脂不足时自动停止**:如果领取奖励时树脂不够了,脚本会直接停止,可以配置是否使用须臾/脆弱。
|
||||
- **好感队领取奖励**:领取奖励前切换到好感队,还可以领取到好感度。
|
||||
@@ -77,6 +80,12 @@
|
||||
打开大地图,点击左下角设置,开启自定义标记。
|
||||
脚本非正常结束运行时会出现该问题。
|
||||
## 更新日志
|
||||
### 5.1
|
||||
- 新增双倍检测模式(只刷双倍产出)
|
||||
- 新增材料拾取功能(领奖后自动拾取掉落物)
|
||||
- 新增20树脂模式(怪物素材慢刷,配合材料拾取使用)
|
||||
- 修复浓缩树脂识别失败的问题
|
||||
- 修复树脂耗尽模式+刷取次数取小值的情况下,当OCR计算次数>手动设置刷取次数时无法正确终止脚本的bug(到达手动刷取次数会继续刷,直到体力用光)
|
||||
### 5.0
|
||||
- 新增至冬路线
|
||||
- BGI最低版本要求改为0.63.2
|
||||
|
||||
@@ -14,12 +14,14 @@ let currentRunTimes = 0; // 当前运行次数
|
||||
let isNotification = false; // 是否发送通知
|
||||
let config = {}; // 全局配置对象
|
||||
let recheckCount = 0; // 树脂重新检查次数(防止无限递归)
|
||||
let originalResinCount = 0; // 原始识别到的树脂可刷取次数(用于判断是否需要重检)
|
||||
const MAX_RECHECK_COUNT = 3; // 最大重新检查次数
|
||||
let consecutiveFailureCount = 0; // 连续战斗失败次数
|
||||
const MAX_CONSECUTIVE_FAILURES = 5; // 最大连续失败次数,超过后终止脚本
|
||||
const ocrRegion1 = {x: 800, y: 200, width: 300, height: 100}; // 中心区域
|
||||
const ocrRegion2 = {x: 0, y: 200, width: 300, height: 300}; // 追踪任务区域
|
||||
const ocrRegion3 = {x: 1200, y: 520, width: 300, height: 300}; // 拾取区域
|
||||
let doubleSurgeCounter = 0; // 双倍剩余次数计数器(0=未知/未初始化,>0=剩余次数)
|
||||
const ocrRegion1 = { x: 800, y: 200, width: 300, height: 100 }; // 中心区域
|
||||
const ocrRegion2 = { x: 0, y: 200, width: 300, height: 300 }; // 追踪任务区域
|
||||
const ocrRegion3 = { x: 1200, y: 520, width: 300, height: 300 }; // 拾取区域
|
||||
|
||||
// 预定义识别对象
|
||||
const openRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/icon/open.png"));
|
||||
@@ -55,6 +57,14 @@ const ocrRoThis = RecognitionObject.ocrThis;
|
||||
// 任何时候都确保自定义标记处于打开状态
|
||||
await openCustomMarks();
|
||||
}
|
||||
|
||||
// 确保返回主界面(防止拾取等操作后停留在意外界面)
|
||||
try {
|
||||
await genshin.returnMainUi();
|
||||
} catch (mainUiError) {
|
||||
log.warn(`返回主界面时出错: ${mainUiError.message}`);
|
||||
}
|
||||
|
||||
log.info("全自动地脉花运行结束");
|
||||
}
|
||||
})();
|
||||
@@ -65,7 +75,14 @@ const ocrRoThis = RecognitionObject.ocrThis;
|
||||
*/
|
||||
async function runLeyLineOutcropScript() {
|
||||
// 初始化加载配置和设置并校验
|
||||
initialize();
|
||||
await initialize();
|
||||
|
||||
// 如果开启"只刷双倍"模式,双倍检测在两个位置进行:
|
||||
// 1. 开书时快速检测(如果开启冒险之证)
|
||||
// 2. 打完地脉花后在奖励界面兜底检测(带区域重试)
|
||||
if (settings.onlySurgeMode) {
|
||||
log.info("开启只刷双倍模式,双倍检测将在开书时进行");
|
||||
}
|
||||
|
||||
// 处理树脂耗尽模式(如果开启)
|
||||
let runTimesValue = await handleResinExhaustionMode();
|
||||
@@ -80,7 +97,20 @@ async function runLeyLineOutcropScript() {
|
||||
|
||||
// 如果是树脂耗尽模式,执行完毕后再次检查是否还有树脂
|
||||
if (settings.isResinExhaustionMode) {
|
||||
await recheckResinAndContinue();
|
||||
// 判断是否需要重新检查:
|
||||
// 1. 非取小值模式 → 需要重检(确保真刷完)
|
||||
// 2. 取小值模式但设定次数≥识别次数 → 用户想刷光 → 需要重检
|
||||
// 3. 取小值模式且设定次数<识别次数 → 用户只想刷设定次数 → 不需要重检
|
||||
const needRecheck = !physical.OpenModeCountMin || settings.timesValue >= originalResinCount;
|
||||
|
||||
if (needRecheck) {
|
||||
await recheckResinAndContinue();
|
||||
} else {
|
||||
log.info(`[取小值模式] 已完成设定的 ${settings.timesValue} 次(可刷 ${originalResinCount} 次),结束运行`);
|
||||
if (isNotification) {
|
||||
notification.send(`树脂耗尽模式(取小值):已完成 ${settings.timesValue} 次运行,脚本结束`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,10 +148,14 @@ async function initialize() {
|
||||
// 2. 加载配置文件
|
||||
try {
|
||||
config = JSON.parse(file.readTextSync("config.json"));
|
||||
loadSettings();
|
||||
} catch (error) {
|
||||
throw new Error("配置文件加载失败,请检查config.json文件是否存在");
|
||||
}
|
||||
try {
|
||||
loadSettings();
|
||||
} catch (error) {
|
||||
throw new Error(error.message);
|
||||
}
|
||||
try {
|
||||
// 3. 检查脚本更新
|
||||
await checkUpdate();
|
||||
@@ -138,7 +172,7 @@ async function checkUpdate() {
|
||||
try {
|
||||
// 发送GET请求
|
||||
const response = await http.request("GET", "https://cnb.cool/bettergi/bettergi-scripts-list/-/git/raw/release/repo/js/AutoLeyLineOutcrop/manifest.json",
|
||||
JSON.stringify({"Content-Type": "text/plain; charset=utf-8"})
|
||||
JSON.stringify({ "Content-Type": "text/plain; charset=utf-8" })
|
||||
);
|
||||
const latestManifest = JSON.parse(response.body);
|
||||
const manifest = JSON.parse(file.readTextSync("manifest.json"));
|
||||
@@ -160,6 +194,9 @@ async function checkUpdate() {
|
||||
} catch (error) {
|
||||
throw new Error(`检查脚本更新时出错: ${error.message}`);
|
||||
}
|
||||
|
||||
// 重置双倍次数计数器
|
||||
doubleSurgeCounter = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -200,6 +237,9 @@ async function handleResinExhaustionMode() {
|
||||
settings.timesValue = resinResult.count;
|
||||
}
|
||||
|
||||
// 保存原始识别到的树脂次数,用于后续判断是否需要重检
|
||||
originalResinCount = resinResult.count;
|
||||
|
||||
physical.NeedRunsCount = settings.timesValue;
|
||||
log.info(`树脂统计成功:`);
|
||||
log.info(` 原粹树脂可刷取: ${resinResult.originalResinTimes} 次`);
|
||||
@@ -376,7 +416,17 @@ async function runLeyLineChallenges() {
|
||||
// 寻找地脉花位置
|
||||
// 数据保存在全局变量中 leyLineX,leyLineY
|
||||
if (settings.useAdventurerHandbook) {
|
||||
await findLeyLineOutcropByBook(settings.country, settings.leyLineOutcropType);
|
||||
// 仅在第一次循环且开启双倍模式时检测双倍
|
||||
const checkSurge = settings.onlySurgeMode && currentRunTimes === 0;
|
||||
const findResult = await findLeyLineOutcropByBook(settings.country, settings.leyLineOutcropType, checkSurge);
|
||||
|
||||
// 开书双倍检测未通过,提前退出
|
||||
if (findResult && findResult.noSurge) {
|
||||
log.info("[双倍检测] 开书未检测到双倍产出,脚本结束");
|
||||
// 确保返回主界面(此时可能在冒险之证菜单)
|
||||
try { await genshin.returnMainUi(); } catch (e) { }
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
await findLeyLineOutcrop(settings.country, settings.leyLineOutcropType);
|
||||
}
|
||||
@@ -647,11 +697,21 @@ async function executePath(path) {
|
||||
await processLeyLineOutcrop(settings.timeout, targetPath);
|
||||
|
||||
// 尝试领取奖励,如果失败则抛出异常停止执行
|
||||
const rewardSuccess = await attemptReward();
|
||||
if (!rewardSuccess) {
|
||||
const rewardResult = await attemptReward();
|
||||
if (!rewardResult || !rewardResult.success) {
|
||||
throw new Error("无法领取奖励,树脂不足或其他原因");
|
||||
}
|
||||
|
||||
// 根据双倍剩余次数决定是否继续
|
||||
if (settings.onlySurgeMode && rewardResult.willFinishDoubleTimes) {
|
||||
log.info("[双倍次数] 双倍次数已刷完,脚本结束");
|
||||
// 设置运行次数为目标值,终止while循环
|
||||
currentRunTimes = settings.timesValue;
|
||||
return;
|
||||
} else if (settings.onlySurgeMode && rewardResult.doubleRemainingTimes !== undefined) {
|
||||
log.info(`[双倍次数] 还有 ${rewardResult.doubleRemainingTimes} 次双倍,继续下一个地脉花`);
|
||||
}
|
||||
|
||||
// 成功完成地脉花挑战,重置连续失败计数器
|
||||
consecutiveFailureCount = 0;
|
||||
}
|
||||
|
||||
@@ -6,44 +6,47 @@
|
||||
"bgi_version": "0.63.2",
|
||||
"description": "基于OCR图像识别的全自动刷取地脉花。\n💡更多信息请查看README! \n\n----------注意事项----------\n●仅支持BetterGI 0.63.2 及以上版本!\n●部分地脉花因特殊原因不支持全自动,具体的点位请在手册中查看。\n●树脂使用的优先级:2倍原粹树脂 > 浓缩树脂 > 原粹树脂。\n●运行时会传送到七天神像设置中设置的七天神像,需要关闭七天神像设置中的“是否就近七天神像恢复血量”,并指定七天神像。\n●战斗策略注意调度器设置中地图追踪行走配置里的“允许在JsSpript中使用”和“覆盖JS中的自动战斗配置”,只有在都打开的情况下脚本才会使用下面的战斗配置,否则会使用独立任务中的战斗策略。战斗超时时间不能大于脚本自定义配置中的时间。\n\n如果遇到问题,请先参照README中的方法进行解决。",
|
||||
"authors": [
|
||||
{
|
||||
"name": "ddaodan",
|
||||
"links": "https://github.com/ddaodan"
|
||||
},
|
||||
{
|
||||
"name": "平面镜",
|
||||
"links": "https://github.com/Flatmirrr"
|
||||
},
|
||||
{
|
||||
"name": "秋云",
|
||||
"links": "https://github.com/physligl"
|
||||
},
|
||||
{
|
||||
"name": "起个名字好难的喵",
|
||||
"links": "https://github.com/MisakaAldrich"
|
||||
},
|
||||
{
|
||||
"name": "火山",
|
||||
"links": "https://github.com/RRRR623"
|
||||
},
|
||||
{
|
||||
"name": "寒烟",
|
||||
"links": "https://github.com/214-hanyan"
|
||||
},
|
||||
{
|
||||
"name": "羊汪汪",
|
||||
"links": "https://github.com/ColinXHL"
|
||||
},
|
||||
{
|
||||
"name": "云端客",
|
||||
"links": "https://github.com/Kirito520Asuna"
|
||||
}
|
||||
{
|
||||
"name": "ddaodan",
|
||||
"links": "https://github.com/ddaodan"
|
||||
},
|
||||
{
|
||||
"name": "平面镜",
|
||||
"links": "https://github.com/Flatmirrr"
|
||||
},
|
||||
{
|
||||
"name": "秋云",
|
||||
"links": "https://github.com/physligl"
|
||||
},
|
||||
{
|
||||
"name": "起个名字好难的喵",
|
||||
"links": "https://github.com/MisakaAldrich"
|
||||
},
|
||||
{
|
||||
"name": "火山",
|
||||
"links": "https://github.com/RRRR623"
|
||||
},
|
||||
{
|
||||
"name": "寒烟",
|
||||
"links": "https://github.com/214-hanyan"
|
||||
},
|
||||
{
|
||||
"name": "羊汪汪",
|
||||
"links": "https://github.com/ColinXHL"
|
||||
},
|
||||
{
|
||||
"name": "云端客",
|
||||
"links": "https://github.com/Kirito520Asuna"
|
||||
},
|
||||
{
|
||||
"name": "lingyu",
|
||||
"links": "https://github.com/aaahai00"
|
||||
}
|
||||
],
|
||||
"settings_ui": "settings.json",
|
||||
"main": "main.js",
|
||||
"http_allowed_urls": [
|
||||
"https://cnb.cool/*",
|
||||
"https://*.github.com/*"
|
||||
"https://cnb.cool/*",
|
||||
"https://*.github.com/*"
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,21 +29,33 @@
|
||||
],
|
||||
"default": "稻妻"
|
||||
},
|
||||
{
|
||||
"name": "count",
|
||||
"type": "input-text",
|
||||
"label": "刷取次数",
|
||||
"default": "6"
|
||||
},
|
||||
{
|
||||
"name": "isResinExhaustionMode",
|
||||
"type": "checkbox",
|
||||
"label": "树脂耗尽模式\n开启后会自动统计所有可用树脂并计算可刷取次数,替换上方设置的刷取次数\n注意:请同时设置树脂刷取次数,将在统计失败时使用"
|
||||
"label": "树脂耗尽模式\n开启后,将根据当前可用树脂自动计算刷取次数\n注意:若统计失败,则使用设置的「刷取次数」"
|
||||
},
|
||||
{
|
||||
"name": "openModeCountMin",
|
||||
"type": "checkbox",
|
||||
"label": "刷取次数取小值\n开启后树脂耗尽模式中计算可刷取次数,和上方设置的刷取次数取小值"
|
||||
"label": "限制刷取次数\n开启后,以设置的「刷取次数」为上限;树脂不足时则按实际可刷次数执行"
|
||||
},
|
||||
{
|
||||
"name": "count",
|
||||
"type": "input-text",
|
||||
"label": "刷取次数,默认6次",
|
||||
"default": "6"
|
||||
"name": "onlySurgeMode",
|
||||
"type": "checkbox",
|
||||
"label": "只刷双倍\n自动检查双倍地脉,没有就不刷,双倍次数用尽会退出(测试功能,可能不准,建议开启冒险之证找花)",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "monsterMaterialMode",
|
||||
"type": "checkbox",
|
||||
"label": "20树脂模式\n优先使用20树脂,建议配合战斗后拾取材料(低效率)",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "useTransientResin",
|
||||
@@ -63,9 +75,9 @@
|
||||
"label": "战斗的队伍名称,不填表示不切换队伍"
|
||||
},
|
||||
{
|
||||
"name": "friendshipTeam",
|
||||
"type": "input-text",
|
||||
"label": "好感队名称,不填表示不切换好感队"
|
||||
"name": "friendshipTeam",
|
||||
"type": "input-text",
|
||||
"label": "好感队名称,不填表示不切换好感队"
|
||||
},
|
||||
{
|
||||
"name": "timeout",
|
||||
@@ -73,10 +85,23 @@
|
||||
"label": "战斗超时时间,单位秒,默认120秒",
|
||||
"default": 120
|
||||
},
|
||||
{
|
||||
"name": "pickDropsAfterReward",
|
||||
"type": "checkbox",
|
||||
"label": "战斗后拾取材料",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "pickDropsSeconds",
|
||||
"type": "input-text",
|
||||
"label": "拾取材料时间(秒)",
|
||||
"default": "25"
|
||||
},
|
||||
{
|
||||
"name": "useAdventurerHandbook",
|
||||
"type": "checkbox",
|
||||
"label": "是否使用冒险之证寻找地脉花"
|
||||
"label": "是否使用冒险之证寻找地脉花",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "isNotification",
|
||||
@@ -89,10 +114,8 @@
|
||||
"label": "一条龙模式\n开启后,会跳过开始的前往七天神像以及强制更新"
|
||||
},
|
||||
{
|
||||
"name": "isGoToSynthesizer",
|
||||
"type": "select",
|
||||
"label": "是否前往合成台合成浓缩树脂\n 体力大于40时自动合成浓缩树脂【开发中】"
|
||||
"name": "isGoToSynthesizer",
|
||||
"type": "select",
|
||||
"label": "是否前往合成台合成浓缩树脂\n 体力大于40时自动合成浓缩树脂【开发中】"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
]
|
||||
File diff suppressed because it is too large.
Load diff
@@ -17,20 +17,20 @@ const RESIN_ICONS = {
|
||||
|
||||
// 普通数字识别对象(1-4)
|
||||
const NUMBER_ICONS = [
|
||||
{ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num1.png")), value: 1},
|
||||
{ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num2.png")), value: 2},
|
||||
{ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num3.png")), value: 3},
|
||||
{ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num4.png")), value: 4}
|
||||
{ ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num1.png")), value: 1 },
|
||||
{ ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num2.png")), value: 2 },
|
||||
{ ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num3.png")), value: 3 },
|
||||
{ ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num4.png")), value: 4 }
|
||||
];
|
||||
|
||||
// 白色数字识别对象(0-5,用于浓缩树脂)
|
||||
const WHITE_NUMBER_ICONS = [
|
||||
{ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num0_white.png")), value: 0},
|
||||
{ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num1_white.png")), value: 1},
|
||||
{ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num2_white.png")), value: 2},
|
||||
{ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num3_white.png")), value: 3},
|
||||
{ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num4_white.png")), value: 4},
|
||||
{ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num5_white.png")), value: 5}
|
||||
{ ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num0_white.png")), value: 0 },
|
||||
{ ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num1_white.png")), value: 1 },
|
||||
{ ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num2_white.png")), value: 2 },
|
||||
{ ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num3_white.png")), value: 3 },
|
||||
{ ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num4_white.png")), value: 4 },
|
||||
{ ro: RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/num5_white.png")), value: 5 }
|
||||
];
|
||||
|
||||
// 配置常量
|
||||
@@ -42,16 +42,16 @@ const CONFIG = {
|
||||
|
||||
// 点击坐标
|
||||
COORDINATES: {
|
||||
MAP_SWITCH: {x: 1840, y: 1020}, // 地图右下角切换按钮
|
||||
MONDSTADT: {x: 1420, y: 180}, // 蒙德选择按钮
|
||||
AVOID_SELECTION: {x: 1090, y: 450} // 避免选中效果的点击位置
|
||||
MAP_SWITCH: { x: 1840, y: 1020 }, // 地图右下角切换按钮
|
||||
MONDSTADT: { x: 1420, y: 180 }, // 蒙德选择按钮
|
||||
AVOID_SELECTION: { x: 1090, y: 450 } // 避免选中效果的点击位置
|
||||
},
|
||||
|
||||
// OCR识别区域配置
|
||||
OCR_REGIONS: {
|
||||
ORIGINAL_RESIN: {width: 200, height: 40},
|
||||
CONDENSED_RESIN: {width: 90, height: 40},
|
||||
OTHER_RESIN: {width: 0, height: 60} // width会根据图标宽度动态设置
|
||||
ORIGINAL_RESIN: { width: 200, height: 40 },
|
||||
CONDENSED_RESIN: { width: 90, height: 40 }, // 调用位置(L269)已改为硬编码,如果确认无用可删除
|
||||
OTHER_RESIN: { width: 0, height: 60 } // width会根据图标宽度动态设置
|
||||
}
|
||||
};
|
||||
|
||||
@@ -163,7 +163,7 @@ async function recognizeNumberByOCR(ocrRegion, pattern) {
|
||||
captureRegion = captureGameRegion();
|
||||
resList = captureRegion.findMulti(ocrRo);
|
||||
|
||||
if (!resList || resList.length === 0) {
|
||||
if (!resList || resList.count === 0) {
|
||||
log.warn("OCR未识别到任何文本");
|
||||
return null;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ async function countOriginalResin(tryOriginalMode, opToMainUi, openMap) {
|
||||
} else {
|
||||
log.info('尝试使用优化模式');
|
||||
let ocrPhysical = await physical.ocrPhysical(opToMainUi, openMap);
|
||||
log.debug(`ocrPhysical: {0}`,JSON.stringify(ocrPhysical))
|
||||
log.debug(`ocrPhysical: {0}`, JSON.stringify(ocrPhysical))
|
||||
await sleep(600)
|
||||
// ocrPhysical = false//模拟异常
|
||||
if (ocrPhysical/* && ocrPhysical.ok*/) {
|
||||
@@ -256,6 +256,9 @@ async function countOriginalResinBackup() {
|
||||
* @returns {number} 浓缩树脂数量
|
||||
*/
|
||||
async function countCondensedResin() {
|
||||
keyPress("ESCAPE"); // 关闭上一步的补充原萃树脂界面
|
||||
await sleep(CONFIG.UI_DELAY);
|
||||
|
||||
const condensedResin = await recognizeImage(RESIN_ICONS.CONDENSED);
|
||||
if (!condensedResin) {
|
||||
log.warn(`未找到浓缩树脂图标`);
|
||||
@@ -263,10 +266,15 @@ async function countCondensedResin() {
|
||||
}
|
||||
|
||||
const ocrRegion = {
|
||||
x: condensedResin.x,
|
||||
y: condensedResin.y,
|
||||
width: CONFIG.OCR_REGIONS.CONDENSED_RESIN.width,
|
||||
height: CONFIG.OCR_REGIONS.CONDENSED_RESIN.height
|
||||
// 调用处的坐标范围不对,正常来说应该改偏移或者去源头看看问题,但是这样改简单粗暴,能用就行
|
||||
// x: condensedResin.x,
|
||||
// y: condensedResin.y,
|
||||
// width: CONFIG.OCR_REGIONS.CONDENSED_RESIN.width,
|
||||
// height: CONFIG.OCR_REGIONS.CONDENSED_RESIN.height
|
||||
x: 1140,
|
||||
y: 26,
|
||||
width: 45,
|
||||
height: 41
|
||||
};
|
||||
|
||||
// 首先尝试OCR识别
|
||||
@@ -288,30 +296,33 @@ async function countCondensedResin() {
|
||||
// 点击浓缩树脂打开说明界面统计
|
||||
condensedResin.click();
|
||||
await sleep(CONFIG.UI_DELAY);
|
||||
let captureRegion = captureGameRegion();
|
||||
let textList = null;
|
||||
let captureRegion = null;
|
||||
try {
|
||||
// OCR识别整个界面的文本
|
||||
captureRegion = captureGameRegion();
|
||||
let ocrRo = RecognitionObject.Ocr(0, 0, captureRegion.width, captureRegion.height);
|
||||
textList = captureRegion.findMulti(ocrRo);
|
||||
let textList = captureRegion.findMulti(ocrRo);
|
||||
|
||||
for (const res of textList) {
|
||||
if (res.text.includes("当前拥有")) {
|
||||
const match = res.text.match(/当前拥有\s*([0-5ss])/);
|
||||
if (match && match[1]) {
|
||||
const count = parseInt(match[1]);
|
||||
log.info(`浓缩树脂数量(说明界面): ${count}`);
|
||||
keyPress("ESCAPE");
|
||||
await sleep(CONFIG.UI_DELAY);
|
||||
return count;
|
||||
if (textList && textList.count > 0) {
|
||||
for (let i = 0; i < textList.count; i++) {
|
||||
if (textList[i].text.includes("当前拥有")) {
|
||||
const match = textList[i].text.match(/当前拥有\s*([0-5ss])/);
|
||||
if (match && match[1]) {
|
||||
const count = parseInt(match[1]);
|
||||
log.info(`浓缩树脂数量(说明界面): ${count}`);
|
||||
keyPress("ESCAPE");
|
||||
await sleep(CONFIG.UI_DELAY);
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
log.error(`说明界面OCR出错: ${error.message}`);
|
||||
} finally {
|
||||
if (textList && typeof textList.dispose === 'function') {
|
||||
textList.dispose();
|
||||
if (captureRegion) {
|
||||
captureRegion.dispose();
|
||||
}
|
||||
captureRegion.dispose();
|
||||
}
|
||||
|
||||
log.warn(`未能识别浓缩树脂数量`);
|
||||
@@ -541,24 +552,33 @@ this.calCountByResin = async function () {
|
||||
let count = 0;
|
||||
// 计算可刷取次数
|
||||
// 1. 原粹树脂:优先消耗40/次,不满40消耗20/次,不满20不消耗
|
||||
// 20树脂模式:每次消耗20/次
|
||||
let originalResinTimes = 0;
|
||||
let remainingOriginalResin = countResult.originalResinCount;
|
||||
|
||||
// 先计算40树脂的次数
|
||||
if (remainingOriginalResin >= 40) {
|
||||
const times40 = Math.floor(remainingOriginalResin / 40);
|
||||
originalResinTimes += times40;
|
||||
remainingOriginalResin = remainingOriginalResin - (times40 * 40);
|
||||
}
|
||||
if (settings.monsterMaterialMode) {
|
||||
// 20树脂模式:每次20体力
|
||||
originalResinTimes = Math.floor(remainingOriginalResin / 20);
|
||||
remainingOriginalResin = remainingOriginalResin % 20;
|
||||
log.info(`原粹树脂可刷取次数(20树脂模式,20/次): ${originalResinTimes}`);
|
||||
} else {
|
||||
// 正常模式:优先40/次
|
||||
// 先计算40树脂的次数
|
||||
if (remainingOriginalResin >= 40) {
|
||||
const times40 = Math.floor(remainingOriginalResin / 40);
|
||||
originalResinTimes += times40;
|
||||
remainingOriginalResin = remainingOriginalResin - (times40 * 40);
|
||||
}
|
||||
|
||||
// 再计算20树脂的次数
|
||||
if (remainingOriginalResin >= 20) {
|
||||
const times20 = Math.floor(remainingOriginalResin / 20);
|
||||
originalResinTimes += times20;
|
||||
remainingOriginalResin = remainingOriginalResin - (times20 * 20);
|
||||
}
|
||||
// 再计算20树脂的次数
|
||||
if (remainingOriginalResin >= 20) {
|
||||
const times20 = Math.floor(remainingOriginalResin / 20);
|
||||
originalResinTimes += times20;
|
||||
remainingOriginalResin = remainingOriginalResin - (times20 * 20);
|
||||
}
|
||||
|
||||
log.info(`原粹树脂可刷取次数: ${originalResinTimes}`);
|
||||
log.info(`原粹树脂可刷取次数: ${originalResinTimes}`);
|
||||
}
|
||||
|
||||
// 2. 浓缩树脂:每个计算为1次
|
||||
let condensedResinTimes = countResult.condensedResinCount;
|
||||
|
||||
@@ -1,74 +1,142 @@
|
||||
// 齿轮图标识别对象
|
||||
const mapSettingButtonRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/icon/map_setting_button.bmp"));
|
||||
|
||||
// OCR 检测辅助函数(用于地脉移涌检测)
|
||||
function wipOcrCheckText(roi1080, keywords, label) {
|
||||
let ra = null;
|
||||
try {
|
||||
const s = genshin.scaleTo1080PRatio;
|
||||
const x = Math.round(roi1080[0] * s);
|
||||
const y = Math.round(roi1080[1] * s);
|
||||
const w = Math.round(roi1080[2] * s);
|
||||
const h = Math.round(roi1080[3] * s);
|
||||
|
||||
ra = captureGameRegion();
|
||||
const resList = ra.findMulti(RecognitionObject.ocr(x, y, w, h));
|
||||
const count = resList.length !== undefined ? resList.length : resList.count;
|
||||
|
||||
if (typeof enableDebug !== "undefined" && enableDebug) {
|
||||
log.info(`[DEBUG][${label}] ROI(1080P)=(${roi1080.join(',')}) 当前=(${x},${y},${w},${h}) 段数=${count}`);
|
||||
for (let i = 0; i < count; i++) {
|
||||
const r = resList[i];
|
||||
if (r) log.info(`[DEBUG][${label}] #${i + 1} text="${r.text}" pos=(${r.x},${r.y},${r.width},${r.height})`);
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
const r = resList[i];
|
||||
if (!r || !r.text) continue;
|
||||
for (let k = 0; k < keywords.length; k++) {
|
||||
if (r.text.includes(keywords[k])) return r;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
log.warn(`[DEBUG][${label}] OCR异常: ${e.message}`);
|
||||
return null;
|
||||
} finally {
|
||||
if (ra) ra.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过冒险之证查找地脉花位置
|
||||
* @param {string} country - 国家名称
|
||||
* @param {string} type - 地脉花类型
|
||||
* @returns {Promise<void>}
|
||||
* @param {boolean} checkSurge - 是否检测双倍产出
|
||||
* @returns {Promise<{found: boolean, hasSurge?: boolean}>} 返回查找结果和双倍状态
|
||||
*/
|
||||
this.findLeyLineOutcropByBook = async function (country, type) {
|
||||
await genshin.returnMainUi();
|
||||
await sleep(1000);
|
||||
log.info("使用冒险之证寻找地脉花");
|
||||
|
||||
// 确保运行时位于主界面
|
||||
keyPress("F1");
|
||||
// 开书等待时间延长至2.5s
|
||||
await sleep(2500);
|
||||
click(300, 550); // 点击讨伐
|
||||
await sleep(1000);
|
||||
click(500, 200); // 点击筛选
|
||||
await sleep(1000);
|
||||
click(500, 500); // 点击其他
|
||||
await sleep(1000);
|
||||
|
||||
// 选择地脉花类型
|
||||
if (type === "蓝花(经验书)") {
|
||||
click(700, 350); // 点击经验花
|
||||
} else {
|
||||
click(500, 350); // 点击摩拉花
|
||||
}
|
||||
await sleep(1000);
|
||||
click(1300, 800); // 点击推荐
|
||||
await sleep(1000);
|
||||
|
||||
// 查找并点击指定国家
|
||||
await this.findAndClickCountry(country);
|
||||
|
||||
// 查找并点击停止追踪按钮
|
||||
await this.findAndCancelTrackingInBook();
|
||||
|
||||
// 最多重试3次确保大地图正确打开
|
||||
for (let retry = 0; retry < 3; retry++) {
|
||||
this.findLeyLineOutcropByBook = async function (country, type, checkSurge = false) {
|
||||
await genshin.returnMainUi();
|
||||
await sleep(1000);
|
||||
click(1500, 850);
|
||||
// 等待大地图打开延长至 2.5s
|
||||
log.info("使用冒险之证寻找地脉花");
|
||||
|
||||
// 确保运行时位于主界面
|
||||
keyPress("F1");
|
||||
// 开书等待时间延长至2.5s
|
||||
await sleep(2500);
|
||||
|
||||
if (await this.checkBigMapOpened()) {
|
||||
log.info("识别到大地图");
|
||||
break; // 成功打开大地图
|
||||
}
|
||||
|
||||
if (retry < 2) { // 不是最后一次重试
|
||||
log.info(`大地图未正确打开,第${retry + 1}次重试...`);
|
||||
await genshin.returnMainUi();
|
||||
await this.findAndClickCountry(country);
|
||||
await this.findAndCancelTrackingInBook();
|
||||
click(300, 550); // 点击讨伐
|
||||
await sleep(1000);
|
||||
click(500, 200); // 点击筛选
|
||||
await sleep(1000);
|
||||
click(500, 500); // 点击其他
|
||||
await sleep(1000);
|
||||
|
||||
// 选择地脉花类型
|
||||
if (type === "蓝花(经验书)") {
|
||||
click(700, 350); // 点击经验花
|
||||
} else {
|
||||
throw new Error("大地图打开失败,已重试3次");
|
||||
click(500, 350); // 点击摩拉花
|
||||
}
|
||||
}
|
||||
await sleep(1000);
|
||||
|
||||
// 获取地脉花位置
|
||||
const center = genshin.getPositionFromBigMap();
|
||||
leyLineX = center.x;
|
||||
leyLineY = center.y;
|
||||
log.info(`找到地脉花的坐标:(${leyLineX}, ${leyLineY})`);
|
||||
// 开书双倍检测:在选择花类型之后、点击推荐之前进行
|
||||
let doubleHit = null;
|
||||
if (checkSurge) {
|
||||
log.info("[双倍检测] 开始识别两倍产出...");
|
||||
const doubleLarge = [1041, 496, 170, 37];
|
||||
doubleHit = wipOcrCheckText(doubleLarge, ["2倍", "两倍", "双倍"], "双倍产出检测");
|
||||
if (!doubleHit) {
|
||||
log.info('[双倍检测] 识别失败,重试1...');
|
||||
await sleep(1500);
|
||||
doubleHit = wipOcrCheckText(doubleLarge, ["2倍", "两倍", "双倍"], "双倍产出检测-r1");
|
||||
}
|
||||
|
||||
// 取消追踪
|
||||
await this.cancelTrackingInMap();
|
||||
if (!doubleHit) {
|
||||
log.warn("[双倍检测] 开书未识别到两倍产出,脚本将提前退出");
|
||||
if (isNotification) {
|
||||
notification.send("⚠️ 未识别到两倍产出,脚本已终止");
|
||||
}
|
||||
return { found: false, noSurge: true };
|
||||
} else {
|
||||
log.info("[双倍检测] 开书识别到两倍产出,继续执行");
|
||||
if (isNotification) {
|
||||
notification.send("✅ 识别到两倍产出");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
click(1300, 800); // 点击推荐
|
||||
await sleep(1000);
|
||||
|
||||
// 查找并点击指定国家
|
||||
await this.findAndClickCountry(country);
|
||||
|
||||
// 查找并点击停止追踪按钮
|
||||
await this.findAndCancelTrackingInBook();
|
||||
|
||||
// 最多重试3次确保大地图正确打开
|
||||
for (let retry = 0; retry < 3; retry++) {
|
||||
await sleep(1000);
|
||||
click(1500, 850);
|
||||
// 等待大地图打开延长至 2.5s
|
||||
await sleep(2500);
|
||||
|
||||
if (await this.checkBigMapOpened()) {
|
||||
log.info("识别到大地图");
|
||||
break; // 成功打开大地图
|
||||
}
|
||||
|
||||
if (retry < 2) { // 不是最后一次重试
|
||||
log.info(`大地图未正确打开,第${retry + 1}次重试...`);
|
||||
await genshin.returnMainUi();
|
||||
await this.findAndClickCountry(country);
|
||||
await this.findAndCancelTrackingInBook();
|
||||
} else {
|
||||
throw new Error("大地图打开失败,已重试3次");
|
||||
}
|
||||
}
|
||||
|
||||
// 获取地脉花位置
|
||||
const center = genshin.getPositionFromBigMap();
|
||||
leyLineX = center.x;
|
||||
leyLineY = center.y;
|
||||
log.info(`找到地脉花的坐标:(${leyLineX}, ${leyLineY})`);
|
||||
|
||||
// 取消追踪
|
||||
await this.cancelTrackingInMap();
|
||||
|
||||
return { found: true, hasSurge: checkSurge ? !!doubleHit : undefined };
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -76,14 +144,14 @@ this.findLeyLineOutcropByBook = async function (country, type) {
|
||||
* @returns {Promise<boolean>} 返回是否检测到齿轮图标
|
||||
* @private
|
||||
*/
|
||||
this.checkBigMapOpened = async function() {
|
||||
let captureRegion = captureGameRegion();
|
||||
try {
|
||||
const imageResult = captureGameRegion().find(mapSettingButtonRo);
|
||||
return imageResult.isExist();
|
||||
} finally {
|
||||
captureRegion.dispose();
|
||||
}
|
||||
this.checkBigMapOpened = async function () {
|
||||
let captureRegion = captureGameRegion();
|
||||
try {
|
||||
const imageResult = captureGameRegion().find(mapSettingButtonRo);
|
||||
return imageResult.isExist();
|
||||
} finally {
|
||||
captureRegion.dispose();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -92,30 +160,30 @@ this.checkBigMapOpened = async function() {
|
||||
* @private
|
||||
*/
|
||||
this.findAndClickCountry = async function (country) {
|
||||
// 挪德卡莱会被识别成挪德卡菜,需要特殊处理
|
||||
let match_country = country;
|
||||
if (country === "挪德卡莱") {
|
||||
match_country = "挪德卡";
|
||||
}
|
||||
let captureRegion = captureGameRegion();
|
||||
try {
|
||||
let resList = captureRegion.findMulti(ocrRoThis);
|
||||
let found = false;
|
||||
for (let i = 0; i < resList.count; i++) {
|
||||
let res = resList[i];
|
||||
if (res.text.includes(match_country)) {
|
||||
res.click();
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
// 挪德卡莱会被识别成挪德卡菜,需要特殊处理
|
||||
let match_country = country;
|
||||
if (country === "挪德卡莱") {
|
||||
match_country = "挪德卡";
|
||||
}
|
||||
if (!found) {
|
||||
// 没找到国家
|
||||
throw new Error("冒险之征中未找到国家:" + country + ",请检查该国家地图是否开启");
|
||||
let captureRegion = captureGameRegion();
|
||||
try {
|
||||
let resList = captureRegion.findMulti(ocrRoThis);
|
||||
let found = false;
|
||||
for (let i = 0; i < resList.count; i++) {
|
||||
let res = resList[i];
|
||||
if (res.text.includes(match_country)) {
|
||||
res.click();
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
// 没找到国家
|
||||
throw new Error("冒险之征中未找到国家:" + country + ",请检查该国家地图是否开启");
|
||||
}
|
||||
} finally {
|
||||
captureRegion.dispose();
|
||||
}
|
||||
} finally {
|
||||
captureRegion.dispose();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -123,28 +191,28 @@ this.findAndClickCountry = async function (country) {
|
||||
* @private
|
||||
*/
|
||||
this.findAndCancelTrackingInBook = async function () {
|
||||
let captureRegion = captureGameRegion();
|
||||
try {
|
||||
let resList = captureRegion.findMulti(ocrRoThis);
|
||||
let stop = null;
|
||||
for (let i = 0; i < resList.count; i++) {
|
||||
let res = resList[i];
|
||||
if (res.text.includes("停止")) {
|
||||
stop = res;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let captureRegion = captureGameRegion();
|
||||
try {
|
||||
let resList = captureRegion.findMulti(ocrRoThis);
|
||||
let stop = null;
|
||||
for (let i = 0; i < resList.count; i++) {
|
||||
let res = resList[i];
|
||||
if (res.text.includes("停止")) {
|
||||
stop = res;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(stop) {
|
||||
log.info("冒险之征中点击停止追踪并重新追踪获取坐标");
|
||||
stop.click();
|
||||
} else {
|
||||
log.info("冒险之征中无需取消追踪");
|
||||
if (stop) {
|
||||
log.info("冒险之征中点击停止追踪并重新追踪获取坐标");
|
||||
stop.click();
|
||||
} else {
|
||||
log.info("冒险之征中无需取消追踪");
|
||||
}
|
||||
} finally {
|
||||
captureRegion.dispose();
|
||||
}
|
||||
} finally {
|
||||
captureRegion.dispose();
|
||||
}
|
||||
await sleep(1000);
|
||||
await sleep(1000);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -152,39 +220,39 @@ this.findAndCancelTrackingInBook = async function () {
|
||||
* @private
|
||||
*/
|
||||
this.cancelTrackingInMap = async function () {
|
||||
// 点击地脉花(因为从书点击追踪后花会在屏幕正中间)
|
||||
click(960, 540);
|
||||
await sleep(1000);
|
||||
|
||||
let captureRegion = captureGameRegion();
|
||||
let stop = null;
|
||||
let leyLine = null;
|
||||
|
||||
try {
|
||||
let resList = captureRegion.findMulti(ocrRoThis);
|
||||
if (resList && resList.count > 0) {
|
||||
for (let i = 0; i < resList.count; i++) {
|
||||
let res = resList[i];
|
||||
if (res.text.includes("停止")) {
|
||||
stop = res;
|
||||
} else if (res.text.includes("地脉") || res.text.includes("衍出")) {
|
||||
leyLine = res;
|
||||
// 点击地脉花(因为从书点击追踪后花会在屏幕正中间)
|
||||
click(960, 540);
|
||||
await sleep(1000);
|
||||
|
||||
let captureRegion = captureGameRegion();
|
||||
let stop = null;
|
||||
let leyLine = null;
|
||||
|
||||
try {
|
||||
let resList = captureRegion.findMulti(ocrRoThis);
|
||||
if (resList && resList.count > 0) {
|
||||
for (let i = 0; i < resList.count; i++) {
|
||||
let res = resList[i];
|
||||
if (res.text.includes("停止")) {
|
||||
stop = res;
|
||||
} else if (res.text.includes("地脉") || res.text.includes("衍出")) {
|
||||
leyLine = res;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
captureRegion.dispose();
|
||||
}
|
||||
|
||||
|
||||
if (stop) {
|
||||
log.info("地图中点击取消追踪");
|
||||
stop.click();
|
||||
} else if (leyLine) {
|
||||
log.info("在地图中选择地脉花后点击取消追踪");
|
||||
leyLine.click();
|
||||
await sleep(1000);
|
||||
click(1700, 1010);
|
||||
await sleep(1000);
|
||||
}
|
||||
} finally {
|
||||
captureRegion.dispose();
|
||||
}
|
||||
|
||||
|
||||
if (stop) {
|
||||
log.info("地图中点击取消追踪");
|
||||
stop.click();
|
||||
} else if (leyLine) {
|
||||
log.info("在地图中选择地脉花后点击取消追踪");
|
||||
leyLine.click();
|
||||
await sleep(1000);
|
||||
click(1700, 1010);
|
||||
await sleep(1000);
|
||||
}
|
||||
};
|
||||
@@ -2,79 +2,108 @@
|
||||
* 加载、验证、输出用户设置
|
||||
* @returns {Object} 处理过的设置对象
|
||||
*/
|
||||
this.loadSettings =
|
||||
function () {
|
||||
try {
|
||||
// 直接使用全局settings对象而不是重新创建
|
||||
// 这样能保留原始设置内容
|
||||
this.loadSettings =
|
||||
function () {
|
||||
try {
|
||||
// 直接使用全局settings对象而不是重新创建
|
||||
// 这样能保留原始设置内容
|
||||
|
||||
// 验证必要的设置
|
||||
if (!settings.start) {
|
||||
throw new Error("请仔细阅读脚本介绍和手册,并在调度器内进行配置,如果你是直接运行的脚本,请将脚本加入调度器内运行!");
|
||||
}
|
||||
// 验证必要的设置
|
||||
if (!settings.start) {
|
||||
throw new Error("请仔细阅读脚本介绍和手册,并在调度器内进行配置,如果你是直接运行的脚本,请将脚本加入调度器内运行!");
|
||||
}
|
||||
|
||||
if (!settings.leyLineOutcropType) {
|
||||
throw new Error("请选择你要刷取的地脉花类型(经验书/摩拉)");
|
||||
}
|
||||
if (!settings.leyLineOutcropType) {
|
||||
throw new Error("请选择你要刷取的地脉花类型(经验书/摩拉)");
|
||||
}
|
||||
|
||||
if (!settings.country) {
|
||||
throw new Error("请在游戏中确认地脉花的第一个点的位置,然后在js设置中选择地脉花所在的国家。");
|
||||
}
|
||||
if (!settings.country) {
|
||||
throw new Error("请在游戏中确认地脉花的第一个点的位置,然后在js设置中选择地脉花所在的国家。");
|
||||
}
|
||||
|
||||
if (settings.friendshipTeam && !settings.team) {
|
||||
throw new Error("未配置战斗队伍!当配置了好感队时必须配置战斗队伍!");
|
||||
}
|
||||
if (settings.friendshipTeam && !settings.team) {
|
||||
throw new Error("未配置战斗队伍!当配置了好感队时必须配置战斗队伍!");
|
||||
}
|
||||
|
||||
// 为了向后兼容,确保某些设置有默认值
|
||||
//settings.timeout = settings.timeout * 1000 || 120000;
|
||||
if (settings.isResinExhaustionMode && settings.onlySurgeMode) {
|
||||
throw new Error("树脂耗尽模式和只刷双倍模式是互斥选项,不能同时开启!\n请根据需求选择其中一种模式");
|
||||
}
|
||||
|
||||
// 处理刷取次数
|
||||
if (!settings.count || !/^-?\d+\.?\d*$/.test(settings.count)) {
|
||||
log.warn(`刷取次数 ${settings.count} 不是数字,使用默认次数6次`);
|
||||
settings.timesValue = 6;
|
||||
} else {
|
||||
// 转换为数字
|
||||
const num = parseFloat(settings.count);
|
||||
// 为了向后兼容,确保某些设置有默认值
|
||||
//settings.timeout = settings.timeout * 1000 || 120000;
|
||||
|
||||
// 范围检查
|
||||
if (num < 1) {
|
||||
settings.timesValue = 1;
|
||||
log.info(`⚠️ 次数 ${num} 小于1,已调整为1`);
|
||||
// 处理刷取次数
|
||||
if (!settings.count || !/^-?\d+\.?\d*$/.test(settings.count)) {
|
||||
log.warn(`刷取次数 ${settings.count} 不是数字,使用默认次数6次`);
|
||||
settings.timesValue = 6;
|
||||
} else {
|
||||
// 处理小数
|
||||
if (!Number.isInteger(num)) {
|
||||
settings.timesValue = Math.floor(num);
|
||||
log.info(`⚠️ 次数 ${num} 不是整数,已向下取整为 ${settings.timesValue}`);
|
||||
// 转换为数字
|
||||
const num = parseFloat(settings.count);
|
||||
|
||||
// 范围检查
|
||||
if (num < 1) {
|
||||
settings.timesValue = 1;
|
||||
log.info(`⚠️ 次数 ${num} 小于1,已调整为1`);
|
||||
} else {
|
||||
settings.timesValue = num;
|
||||
// 处理小数
|
||||
if (!Number.isInteger(num)) {
|
||||
settings.timesValue = Math.floor(num);
|
||||
log.info(`⚠️ 次数 ${num} 不是整数,已向下取整为 ${settings.timesValue}`);
|
||||
} else {
|
||||
settings.timesValue = num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 记录使用的设置
|
||||
log.info(`地脉花类型:${settings.leyLineOutcropType}`);
|
||||
log.info(`国家:${settings.country}`);
|
||||
|
||||
if (settings.friendshipTeam) {
|
||||
log.info(`好感队:${settings.friendshipTeam}`);
|
||||
}
|
||||
if (settings.isResinExhaustionMode) {
|
||||
log.warn("树脂耗尽模式已开启,若统计成功将覆盖设置的刷取次数");
|
||||
} else if (settings.onlySurgeMode) {
|
||||
log.info(`只刷双倍模式已开启(双倍次数用尽后将提前退出)`);
|
||||
} else {
|
||||
log.info(`刷取次数:${settings.timesValue}`);
|
||||
}
|
||||
|
||||
// 设置通知状态
|
||||
isNotification = settings.isNotification;
|
||||
|
||||
// 设置一条龙模式
|
||||
oneDragonMode = settings.oneDragonMode;
|
||||
|
||||
// 设置拾取材料时间
|
||||
if (!settings.pickDropsSeconds || !/^\d+$/.test(settings.pickDropsSeconds) || parseInt(settings.pickDropsSeconds) < 1) {
|
||||
settings.pickDropsSecondsValue = 25;
|
||||
if (settings.pickDropsSeconds && !/^\d+$/.test(settings.pickDropsSeconds)) {
|
||||
log.warn(`拾取时间 "${settings.pickDropsSeconds}" 不是有效数字,已使用默认值 25 秒`);
|
||||
} else if (settings.pickDropsSeconds && parseInt(settings.pickDropsSeconds) < 1) {
|
||||
log.warn(`拾取时间 ${settings.pickDropsSeconds} 小于 1,已使用默认值 25 秒`);
|
||||
}
|
||||
} else {
|
||||
settings.pickDropsSecondsValue = parseInt(settings.pickDropsSeconds);
|
||||
}
|
||||
|
||||
if (settings.pickDropsAfterReward) {
|
||||
log.info(`战斗后拾取材料:开启,拾取时间 ${settings.pickDropsSecondsValue} 秒`);
|
||||
}
|
||||
|
||||
if (settings.monsterMaterialMode) {
|
||||
log.info(`20树脂模式:开启`);
|
||||
}
|
||||
|
||||
if (settings.onlySurgeMode && !settings.isResinExhaustionMode) {
|
||||
log.info(`只刷双倍模式:开启(建议配合"使用冒险之证寻找地脉花"选项)`);
|
||||
}
|
||||
|
||||
if (isNotification) {
|
||||
notification.send(`全自动地脉花开始运行,以下是本次运行的配置:\n\n地脉花类型:${settings.leyLineOutcropType}\n国家:${settings.country}\n刷取次数:${settings.timesValue}`);
|
||||
}
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
// 记录使用的设置
|
||||
log.info(`地脉花类型:${settings.leyLineOutcropType}`);
|
||||
log.info(`国家:${settings.country}`);
|
||||
|
||||
if (settings.friendshipTeam) {
|
||||
log.info(`好感队:${settings.friendshipTeam}`);
|
||||
}
|
||||
if (settings.isResinExhaustionMode) {
|
||||
log.warn("树脂耗尽模式已开启,若统计成功将覆盖设置的刷取次数");
|
||||
} else {
|
||||
log.info(`刷取次数:${settings.timesValue}`);
|
||||
}
|
||||
|
||||
// 设置通知状态
|
||||
isNotification = settings.isNotification;
|
||||
|
||||
// 设置一条龙模式
|
||||
oneDragonMode = settings.oneDragonMode;
|
||||
|
||||
if (isNotification) {
|
||||
notification.send(`全自动地脉花开始运行,以下是本次运行的配置:\n\n地脉花类型:${settings.leyLineOutcropType}\n国家:${settings.country}\n刷取次数:${settings.timesValue}`);
|
||||
}
|
||||
} catch (error) {
|
||||
log.error(`加载设置失败: ${error.message}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user