From 3d8c73598162c2026d9701e5cc53dbb106fe285e Mon Sep 17 00:00:00 2001 From: FFA <78807750+RJFAC@users.noreply.github.com> Date: Sun, 30 Nov 2025 11:11:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E7=BE=A9=E8=87=AA=E5=8B=95?= =?UTF-8?q?=E7=A7=98=E5=A2=83=E8=85=B3=E6=9C=AC=20(#2415)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 可自定義參數的自動秘境腳本 --- repo/js/AutoDomainCustomizable/README.md | 70 ++++++++++ repo/js/AutoDomainCustomizable/main.js | 106 +++++++++++++++ repo/js/AutoDomainCustomizable/manifest.json | 25 ++++ repo/js/AutoDomainCustomizable/settings.json | 129 +++++++++++++++++++ 4 files changed, 330 insertions(+) create mode 100644 repo/js/AutoDomainCustomizable/README.md create mode 100644 repo/js/AutoDomainCustomizable/main.js create mode 100644 repo/js/AutoDomainCustomizable/manifest.json create mode 100644 repo/js/AutoDomainCustomizable/settings.json diff --git a/repo/js/AutoDomainCustomizable/README.md b/repo/js/AutoDomainCustomizable/README.md new file mode 100644 index 000000000..87ee680b3 --- /dev/null +++ b/repo/js/AutoDomainCustomizable/README.md @@ -0,0 +1,70 @@ +# 传送并自动秘境 (增强版) + +本脚本为 **BetterGI** 自带脚本的增强版本。允许用户直接在脚本设置中自定义“刷取次数”、“树脂类型”及其他高级参数,无需修改 BetterGI 全局设置。 + +--- + +## ✨ 主要功能 + +* **自定义树脂策略**:支持指定各类型树脂的使用次数,或选择自动刷取至树脂耗尽。 +* **智能队伍切换**:进本前自动切换至指定队伍。 +* **全自动托管**:直接调用 BetterGI 内置的自动秘境逻辑,支持自动传送、自动进门、战斗及领奖。 +* **自动处理**:支持结束后自动分解圣遗物。 + +--- + +## 🚀 使用方法 + +> ⚠️ **重要**:本脚本的参数需要在**调度器**中配置! + +1. 在调度器中添加脚本。 +2. **右键点击**脚本并选择 **“修改JS脚本自定义配置”**。 + +### 📌 必填项 + +* **指定要前往的秘境** + * 请在下拉菜单中选择目标副本。 + +* **树脂策略 (二选一)** + * **☑️ 刷取至树脂耗尽 (勾选)** + * 优先使用原粹树脂,耗尽后使用浓缩树脂。 + * 此模式下**忽略**下方的具体次数设定。 + * **⬜ 指定每种树脂刷取次数 (不勾选)** + * 严格按照下方填写的各树脂次数进行刷取。 + * 若四种树脂次数都为 0,脚本将不会进行任何战斗。 + +### ⚙️ 可选项 + +* **自动切换到指定队伍** + * 输入预设队伍名称(需完全一致),留空则不切换。 +* **秘境刷取轮数** + * `0`:刷到体力耗尽或达到指定次数。 + * `数字`:刷满该场数后强制停止。 +* **结束后自动分解圣遗物** + * 开启后自动执行分解逻辑。 +* **周日副本序号** + * 仅周日全开时有效,填 `1` / `2` / `3` 对应界面选项。 + +### 🔧 进阶/除错项 + +* **战斗完成后等待时间** + * 建议设置 5 秒以上,防止战斗结束过快导致识别错误。 +* **启用调试模式** + * 勾选后,日志窗口会显示详细参数,供排查问题使用。 + +> *注:复活重试次数、寻路优化等参数请直接在 BetterGI 主界面的设置中修改。* + +--- + +## ❓ 常见问题 + +* **Q: 脚本显示“未找到秘境”?** + * **A:** 请确认选择的秘境名称是否在当前版本 BetterGI 支持列表中。 + +--- + +## 👨‍💻 关于作者 + +* **原作者**: huiyadanli, iris, 霁 +* **修改者**: [RJFAC](https://github.com/RJFAC) +* **辅助生成**: AI \ No newline at end of file diff --git a/repo/js/AutoDomainCustomizable/main.js b/repo/js/AutoDomainCustomizable/main.js new file mode 100644 index 000000000..9b6f4d6dc --- /dev/null +++ b/repo/js/AutoDomainCustomizable/main.js @@ -0,0 +1,106 @@ +(async function () { + // ========================================================================= + // 1. 读取用户设置 + // ========================================================================= + let userConfig = settings; + let enableDebug = userConfig.EnableDebug; + + // --- 参数解析 --- + let pDomainName = userConfig.DomainName; + let pPartyName = userConfig.PartyName || ""; + let pRunUntilDepleted = userConfig.RunUntilResinDepleted; + let pAutoArtifactSalvage = userConfig.AutoArtifactSalvage; + let pMaxArtifactStar = userConfig.MaxArtifactStar || "4"; + let pSundaySelectedValue = userConfig.SundaySelectedValue || ""; + + // 数值转换 + let pOriginal = parseInt(userConfig.OriginalResinUseCount) || 0; + let pCondensed = parseInt(userConfig.CondensedResinUseCount) || 0; + let pTransient = parseInt(userConfig.TransientResinUseCount) || 0; + let pFragile = parseInt(userConfig.FragileResinUseCount) || 0; + let pDomainRoundNum = parseInt(userConfig.DomainRoundNum) || 0; + + // 注意:FightEndDelay 在 JS 层执行,作为 C# 任务结束后的额外等待 + let pFightEndDelay = parseInt(userConfig.FightEndDelay) || 5; + + // --- 检查 --- + if (!pDomainName) { + log.error("请先在配置中选择要前往的秘境!"); + return; + } + + // ========================================================================= + // 2. 主流程 + // ========================================================================= + while (true) { + try { + // --- A. 创建并配置 C# 参数对象 --- + // 直接使用 EngineExtend 暴露的 AutoDomainParam 类 + let taskParam = new AutoDomainParam(pDomainRoundNum); + + // 填入参数 (仅填入 AutoDomainParam 实际支持的属性) + taskParam.DomainName = pDomainName; + taskParam.PartyName = pPartyName; + taskParam.AutoArtifactSalvage = pAutoArtifactSalvage; + taskParam.MaxArtifactStar = pMaxArtifactStar; + taskParam.SundaySelectedValue = pSundaySelectedValue; + + // 重要:树脂设置逻辑 + taskParam.SpecifyResinUse = !pRunUntilDepleted; + if (!pRunUntilDepleted) { + // 指定次数模式 + taskParam.OriginalResinUseCount = pOriginal; + taskParam.CondensedResinUseCount = pCondensed; + taskParam.TransientResinUseCount = pTransient; + taskParam.FragileResinUseCount = pFragile; + // 设置优先级:从左到右 + taskParam.SetResinPriorityList("浓缩树脂", "原粹树脂", "须臾树脂", "脆弱树脂"); + } else { + // 刷到耗尽模式 + taskParam.SetResinPriorityList("浓缩树脂", "原粹树脂"); + } + + if (enableDebug) { + log.info(`[DEBUG] 参数注入完成。模式: ${!pRunUntilDepleted ? "指定次数" : "刷到耗尽"}`); + log.info(`[DEBUG] 浓缩: ${pCondensed}, 原粹: ${pOriginal}, 周日: ${pSundaySelectedValue}`); + } + + // --- B. 执行任务 --- + // 使用 RunAutoDomainTask 直接执行 C# 托管的完整流程 + // 包含自动传送、自动进门、战斗及重试 logic + await dispatcher.RunAutoDomainTask(taskParam); + + // --- C. 战后等待 (脚本层面额外等待) --- + if (pFightEndDelay > 0) { + log.info(`[脚本] 任务执行完毕,额外等待 ${pFightEndDelay} 秒...`); + await sleep(pFightEndDelay * 1000); + } + + break; + + } catch (ex) { + let msg = ex.message || ""; + if (msg.includes("背包物品已满") || msg.includes("未检测到秘境结束")) { + log.warn(`[脚本] 任务可能已完成,但检测到: ${msg}`); + break; + } + else if (msg.includes("检测到复苏界面") || msg.includes("复苏")) { + log.warn(`[脚本] 角色死亡,准备复活重试...`); + await sleep(5000); + continue; + } + else if (msg.includes("TaskCanceledException") || msg.includes("A task was canceled")) { + log.info("[脚本] 任务已取消或停止。"); + break; + } + else if (msg.includes("取消自动任务")) { + log.info("[脚本] 用户手动停止任务。"); + break; + } + else { + log.error(`[脚本] 发生错误: ${msg}`); + throw ex; + } + } + } +})(); \ No newline at end of file diff --git a/repo/js/AutoDomainCustomizable/manifest.json b/repo/js/AutoDomainCustomizable/manifest.json new file mode 100644 index 000000000..bd8e5bad4 --- /dev/null +++ b/repo/js/AutoDomainCustomizable/manifest.json @@ -0,0 +1,25 @@ +{ + "manifest_version": 1, + "name": "传送并自动秘境(增强版)", + "version": "0.4", + "bgi_version": "0.53.0", + "description": "BetterGI自带脚本的增强版。支持自定义传送后执行自动秘境的各项参数(如多种树脂设置、自动废弃圣遗物、轮数设置等)。(本脚本逻辑由AI辅助生成)", + "authors": [ + { + "name": "huiyadanli", + "link": "https://github.com/huiyadanli" + }, + { + "name": "iris" + }, + { + "name": "霁" + }, + { + "name": "RJFAC", + "link": "https://github.com/RJFAC" + } + ], + "settings_ui": "settings.json", + "main": "main.js" +} \ No newline at end of file diff --git a/repo/js/AutoDomainCustomizable/settings.json b/repo/js/AutoDomainCustomizable/settings.json new file mode 100644 index 000000000..4f0773ae0 --- /dev/null +++ b/repo/js/AutoDomainCustomizable/settings.json @@ -0,0 +1,129 @@ +[ + { + "name": "DomainName", + "type": "select", + "label": "指定要前往的秘境 (自动传送到刷取的秘境)", + "options": [ + "", + "仲夏庭园", + "塞西莉亚苗圃", + "震雷连山密宫", + "铭记之谷", + "孤云凌霄之处", + "无妄引咎密宫", + "华池岩岫", + "忘却之峡", + "太山府", + "芬德尼尔之顶", + "山脊守望", + "砂流之庭", + "菫色之庭", + "椛染之庭", + "沉眠之庭", + "岩中幽谷", + "缘觉塔", + "有顶塔", + "赤金的城墟", + "熔铁的孤塞", + "苍白的遗荣", + "深潮的余响", + "罪祸的终末", + "临瀑之城", + "褪色的剧场", + "蕴火的幽墟", + "深古瞭望所", + "虹灵的净土", + "昏识塔", + "荒废砌造坞", + "霜凝的机枢", + "失落的月庭", + "无光的深都" + ], + "default": "" + }, + { + "name": "PartyName", + "type": "input-text", + "label": "自动切换到指定队伍 (注意队伍名称是游戏内你手动设置的名称)", + "default": "" + }, + { + "name": "RunUntilResinDepleted", + "type": "checkbox", + "label": "刷取至树脂耗尽 (优先用原粹后用浓缩,其余不用)", + "default": false + }, + { + "name": "OriginalResinUseCount", + "type": "input-text", + "label": "原粹树脂刷取次数 (请输入数字)", + "default": "0" + }, + { + "name": "CondensedResinUseCount", + "type": "input-text", + "label": "浓缩树脂刷取次数 (请输入数字)", + "default": "0" + }, + { + "name": "TransientResinUseCount", + "type": "input-text", + "label": "须臾树脂刷取次数 (请输入数字)", + "default": "0" + }, + { + "name": "FragileResinUseCount", + "type": "input-text", + "label": "脆弱树脂刷取次数 (请输入数字)", + "default": "0" + }, + { + "name": "AutoArtifactSalvage", + "type": "checkbox", + "label": "结束后自动分解圣遗物", + "default": true + }, + { + "name": "MaxArtifactStar", + "type": "select", + "label": "需要快速分解圣遗物的最高星级", + "options": [ + "1", + "2", + "3", + "4", + "5" + ], + "default": "4" + }, + { + "name": "FightEndDelay", + "type": "input-text", + "label": "战斗完成后等待时间 (秒) (任务结束后的额外延迟)", + "default": "5" + }, + { + "name": "DomainRoundNum", + "type": "input-text", + "label": "秘境刷取轮数 (0表示9999轮,刷取至体力耗尽或达到指定次数)", + "default": "0" + }, + { + "name": "SundaySelectedValue", + "type": "select", + "label": "周日副本序号 (限时副本全开时用)", + "options": [ + "", + "1", + "2", + "3" + ], + "default": "" + }, + { + "name": "EnableDebug", + "type": "checkbox", + "label": "启用调试模式 (将在日志中显示详细参数信息)", + "default": false + } +] \ No newline at end of file