From 2f633b95a9103cda0e25f617b27835706b3017ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B7=E4=B8=AA=E5=90=8D=E5=AD=97=E5=A5=BD=E9=9A=BE?= <25520958+MisakaAldrich@users.noreply.github.com> Date: Thu, 27 Mar 2025 16:41:18 +0800 Subject: [PATCH] =?UTF-8?q?JS=E8=84=9A=E6=9C=AC=EF=BC=9A=E5=88=B7=E8=82=89?= =?UTF-8?q?=E9=80=82=E9=85=8Dexit=5Fand=5Frelogin=EF=BC=8C=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E5=8D=A1=E6=97=B6=E9=97=B4=E5=8A=9F=E8=83=BD=20(#475)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutoPath/好感-张牙舞爪的恶党-循环(二净甸).json | 4 +- .../好感-张牙舞爪的恶党-循环(二净甸刷肉版).json | 4 +- .../好感-张牙舞爪的恶党-触发位置(二净甸).json | 19 +- .../main.js | 125 +++++++++++++ .../manifest.json | 13 ++ .../settings.json | 47 +++++ repo/js/Auto好感&刷兽肉/main.js | 166 ------------------ repo/js/Auto好感&刷兽肉/manifest.json | 13 -- repo/js/Auto好感&刷兽肉/settings.json | 37 ---- 9 files changed, 206 insertions(+), 222 deletions(-) rename repo/js/{Auto好感&刷兽肉 => AutoFriendshipEvilBaresItsFangsGetRawMeat}/assets/AutoPath/好感-张牙舞爪的恶党-循环(二净甸).json (93%) rename repo/js/{Auto好感&刷兽肉 => AutoFriendshipEvilBaresItsFangsGetRawMeat}/assets/AutoPath/好感-张牙舞爪的恶党-循环(二净甸刷肉版).json (96%) rename repo/js/{Auto好感&刷兽肉 => AutoFriendshipEvilBaresItsFangsGetRawMeat}/assets/AutoPath/好感-张牙舞爪的恶党-触发位置(二净甸).json (59%) create mode 100644 repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/main.js create mode 100644 repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/manifest.json create mode 100644 repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/settings.json delete mode 100644 repo/js/Auto好感&刷兽肉/main.js delete mode 100644 repo/js/Auto好感&刷兽肉/manifest.json delete mode 100644 repo/js/Auto好感&刷兽肉/settings.json diff --git a/repo/js/Auto好感&刷兽肉/assets/AutoPath/好感-张牙舞爪的恶党-循环(二净甸).json b/repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/assets/AutoPath/好感-张牙舞爪的恶党-循环(二净甸).json similarity index 93% rename from repo/js/Auto好感&刷兽肉/assets/AutoPath/好感-张牙舞爪的恶党-循环(二净甸).json rename to repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/assets/AutoPath/好感-张牙舞爪的恶党-循环(二净甸).json index bbb26ef4..63328ac1 100644 --- a/repo/js/Auto好感&刷兽肉/assets/AutoPath/好感-张牙舞爪的恶党-循环(二净甸).json +++ b/repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/assets/AutoPath/好感-张牙舞爪的恶党-循环(二净甸).json @@ -5,7 +5,7 @@ "author": "起个名字好难的喵", "version": "1.0", "description": "", - "bgiVersion": "0.42.3" + "bgiVersion": "0.43.5" }, "positions": [ { @@ -41,7 +41,7 @@ "y": -521.4970703125, "type": "path", "move_mode": "dash", - "action": "", + "action": "exit_and_relogin", "action_params": "" } ] diff --git a/repo/js/Auto好感&刷兽肉/assets/AutoPath/好感-张牙舞爪的恶党-循环(二净甸刷肉版).json b/repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/assets/AutoPath/好感-张牙舞爪的恶党-循环(二净甸刷肉版).json similarity index 96% rename from repo/js/Auto好感&刷兽肉/assets/AutoPath/好感-张牙舞爪的恶党-循环(二净甸刷肉版).json rename to repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/assets/AutoPath/好感-张牙舞爪的恶党-循环(二净甸刷肉版).json index aa6cbb63..96702c1c 100644 --- a/repo/js/Auto好感&刷兽肉/assets/AutoPath/好感-张牙舞爪的恶党-循环(二净甸刷肉版).json +++ b/repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/assets/AutoPath/好感-张牙舞爪的恶党-循环(二净甸刷肉版).json @@ -5,7 +5,7 @@ "author": "起个名字好难的喵", "version": "1.0", "description": "", - "bgiVersion": "0.42.3" + "bgiVersion": "0.43.5" }, "positions": [ { @@ -84,7 +84,7 @@ "id": 9, "x": 3614.63, "y": -521.6, - "action": "", + "action": "exit_and_relogin", "move_mode": "dash", "action_params": "", "type": "path" diff --git a/repo/js/Auto好感&刷兽肉/assets/AutoPath/好感-张牙舞爪的恶党-触发位置(二净甸).json b/repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/assets/AutoPath/好感-张牙舞爪的恶党-触发位置(二净甸).json similarity index 59% rename from repo/js/Auto好感&刷兽肉/assets/AutoPath/好感-张牙舞爪的恶党-触发位置(二净甸).json rename to repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/assets/AutoPath/好感-张牙舞爪的恶党-触发位置(二净甸).json index 8e866956..434b301b 100644 --- a/repo/js/Auto好感&刷兽肉/assets/AutoPath/好感-张牙舞爪的恶党-触发位置(二净甸).json +++ b/repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/assets/AutoPath/好感-张牙舞爪的恶党-触发位置(二净甸).json @@ -5,7 +5,7 @@ "author": "起个名字好难的喵", "version": "1.0", "description": "", - "bgiVersion": "0.42.3" + "bgiVersion": "0.43.5" }, "positions": [ { @@ -23,8 +23,23 @@ "y": -521.2724609375, "type": "path", "move_mode": "fly", + "action": "stop_flying", + "action_params": "2500" + }, + { + "x": 3615.4814453125, + "y": -521.2724609375, + "type": "path", + "move_mode": "walk", "action": "combat_script", - "action_params": "wait(0.5),keypress(VK_SPACE),wait(2.5),click" + "action_params": "wait(10)" + }, + { + "x": 3615.4814453125, + "y": -521.2724609375, + "type": "path", + "move_mode": "walk", + "action": "exit_and_relogin" } ] } \ No newline at end of file diff --git a/repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/main.js b/repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/main.js new file mode 100644 index 00000000..ecebf9f4 --- /dev/null +++ b/repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/main.js @@ -0,0 +1,125 @@ +(async function () { + + function logTimeTaken(startTime) { + const currentTime = Date.now(); + const totalTimeInSeconds = (currentTime - startTime) / 1000; + const minutes = Math.floor(totalTimeInSeconds / 60); + const seconds = totalTimeInSeconds % 60; + const formattedTime = `${minutes}分${seconds.toFixed(0).padStart(2, '0')}秒`; + log.info(`当前运行总时长:${formattedTime}`); + } + + // powered by 秋云 + function calculateEstimatedCompletion(startTime, current, total) { + if (current === 0) return "计算中..."; + const elapsedTime = Date.now() - startTime; + const timePerTask = elapsedTime / current; + const remainingTasks = total - current; + const remainingTime = timePerTask * remainingTasks; + const completionDate = new Date(Date.now() + remainingTime); + return `${completionDate.toLocaleTimeString()} (约 ${Math.round(remainingTime / 60000)} 分钟)`; + } + + async function AutoPath(locationName) { + try { + let filePath = `assets/AutoPath/${locationName}.json`; + await pathingScript.runFile(filePath); + } catch (error) { + log.error(`执行 ${locationName} 路径时发生错误`); + log.error(error.message); + } + await sleep(1000); + } + + // 好感核心函数 + async function AutoFriendship(runTimes, statueTimes, GetMeatMode,startTime) { + log.info(`导航至好感-张牙舞爪的恶党-触发位置(二净甸)`); + await AutoPath(`好感-张牙舞爪的恶党-触发位置(二净甸)`); + + log.info(`已抵达预期位置,兽肉好感循环开始...`); + + for (let i = 0; i < runTimes; i++) { + if ((i + 1) % statueTimes === 0) { + await genshin.tp(2297.60, -824.45); // 神像坐标 + await AutoPath(`好感-张牙舞爪的恶党-触发位置(二净甸)`); + log.info(`当前次数:${i + 1}/${runTimes}`); + await AutoPath(`好感-张牙舞爪的恶党-循环${GetMeatMode ? '(二净甸刷肉版)' : '(二净甸)'}`); + } else { + log.info(`当前次数:${i + 1}/${runTimes}`); + await AutoPath(`好感-张牙舞爪的恶党-循环${GetMeatMode ? '(二净甸刷肉版)' : '(二净甸)'}`); + } + const estimatedCompletion = calculateEstimatedCompletion(startTime, i + 1, runTimes); + log.info(`已完成次数:${i + 1}/${runTimes}`); + logTimeTaken(startTime); + log.info(`预计完成时间:${estimatedCompletion}`); + } + log.info('兽肉好感已完成'); + } + + // 刷肉相关参数 + let GetMeatMode = settings.GetMeatMode ? settings.GetMeatMode : false; + let inputValue = settings.inputValue ? settings.inputValue : 300; + let runTimes = GetMeatMode ? (isNaN(inputValue) ? 50 : Math.ceil(inputValue / 6)) : 10; + // 神像相关参数 + let goStatue = settings.goStatue ? settings.goStatue : false; + let statueTimes = goStatue ? (isNaN(settings.statueTimes) ? 5 : settings.statueTimes) : 0; + // 卡时间相关参数 + if(settings.waitTimeMode){ + let maxTimes = settings.maxTimes ? settings.maxTimes : runTimes ; + let waitTimeModeDay = settings.waitTimeModeDay + const datePattern = /^\d{4}-\d{2}-\d{2}$/; // 日期正则 + if (!datePattern.test(settings.waitTimeModeDay)) { + log.error(`检测到基准日期格式错误,当前输入值为:${waitTimeModeDay}`); + waitTimeModeDay = "2025-03-31"; + log.info(`使用的基准日期为:${waitTimeModeDay}`); + } + const now = new Date(); + const benchmark = new Date(waitTimeModeDay + "T04:00:00"); + const timeDiff = now.getTime() - benchmark.getTime(); + const daysDiff = Math.floor(timeDiff / (1000 * 60 * 60 * 24)); + let period = Number(settings.waitTimeModePeriod); + if(isNaN(period)){ + log.warn(`错误的卡时间模式周期 ${period}!使用 7 天作为周期。`); + period = 7.0; + } + if(period < 1 || period > 48){ + log.warn(`卡时间模式周期 ${period} 超过范围!使用 7 天作为周期。`); + period = 7.0; + } + const daysNormalized = daysDiff >= 0 ? daysDiff : period - (Math.abs(daysDiff) % period); + runTimes = Math.ceil(maxTimes / period) * (daysNormalized % period + 1); + } + + // Main + dispatcher.addTimer(new RealtimeTimer("AutoPick", { "forceInteraction": true })); + const startTime = Date.now(); + let messages = [ + '请确保队伍满员,并为队伍配置相应的战斗策略', + `使用的七天神像周期为: ${statueTimes}`, + `计算后的运行次数为: ${runTimes}`, + ]; + for (let message of messages) { + log.info(message); + await sleep(500); + } + log.info('兽肉好感开始...'); + + // 切换队伍 + if (!!settings.partyName) { + try { + await genshin.tp(2297.60, -824.45); + await sleep(3000); + log.info("正在尝试切换至" + settings.partyName); + await genshin.switchParty(settings.partyName); + } catch { + log.warn("队伍切换失败,可能处于联机模式或其他不可切换状态"); + await genshin.returnMainUi(); + } + } else { + await genshin.returnMainUi(); + } + + await AutoFriendship(runTimes,statueTimes,GetMeatMode,startTime); + log.info(`兽肉好感运行总时长:${LogTimeTaken(startTime)}`); + +})(); \ No newline at end of file diff --git a/repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/manifest.json b/repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/manifest.json new file mode 100644 index 00000000..637f6fe9 --- /dev/null +++ b/repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/manifest.json @@ -0,0 +1,13 @@ +{ + "manifest_version": 1, + "name": "兽肉好感:自动好感度&刷两只鳄鱼兽肉&卡时间", + "version": "1.2.0", + "description": "通过突发事件:张牙舞爪的恶党刷兽肉,并顺带获取好感度(超过10次后不再获取),请使用满员好感度队伍,并为全体队伍角色配置相应的战斗策略", + "authors": [ + { + "name": "起个名字好难的喵" + } + ], + "settings_ui": "settings.json", + "main": "main.js" +} \ No newline at end of file diff --git a/repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/settings.json b/repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/settings.json new file mode 100644 index 00000000..98effd4f --- /dev/null +++ b/repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/settings.json @@ -0,0 +1,47 @@ +[ + { + "name": "partyName", + "type": "input-text", + "label": "需要切换的队伍名称(选填)" + }, + { + "name": "GetMeatMode", + "type": "checkbox", + "label": "开启刷兽肉模式【勾选才拾取兽肉】" + }, + { + "name": "inputValue", + "type": "input-text", + "label": "刷取个数(选填,默认为300)" + }, + { + "name": "waitTimeMode", + "type": "checkbox", + "label": "卡时间模式【基于运行次数、基准日期、周期确定需要运行次数】" + }, + { + "name": "waitTimeModeDay", + "type": "input-text", + "label": "卡时间模式基准日期(选填,默认为2025-03-31)" + }, + { + "name": "waitTimeModePeriod", + "type": "input-text", + "label": "卡时间模式周期(选填,默认为7天/循环)" + }, + { + "name": "maxTimes", + "type": "input-text", + "label": "最大运行次数(选填,卡时间模式下生效,默认为刷肉模式计算值)" + }, + { + "name": "goStatue", + "type": "checkbox", + "label": "开启定期前往七天神像" + }, + { + "name": "statueTimes", + "type": "input-text", + "label": "返回神像周期(选填,默认为5次/循环)" + } +] \ No newline at end of file diff --git a/repo/js/Auto好感&刷兽肉/main.js b/repo/js/Auto好感&刷兽肉/main.js deleted file mode 100644 index b13ec119..00000000 --- a/repo/js/Auto好感&刷兽肉/main.js +++ /dev/null @@ -1,166 +0,0 @@ -(async function () { - - const defaultExitDelay = 12; - const defaultLoadingDelay = 10; - - function validateAndSetDefaults(exitDelay, loadingDelay) { - if (isNaN(exitDelay) || exitDelay <= 0) { - log.warn("你没有设置退出延迟,将使用默认值:12秒"); - exitDelay = defaultExitDelay; - } - if (isNaN(loadingDelay) || loadingDelay < 0) { - log.warn("你没有设置加载延迟,将使用默认值:10秒"); - loadingDelay = defaultLoadingDelay; - } - return { exitDelay, loadingDelay }; - } - - async function ReopenTheGate() { - await sleep(1000); - keyPress("ESCAPE"); - await sleep(1000); - click(50, 1030); - await sleep(1000); - click(1000, 750); - await sleep(validatedExitDelay * 1000); - click(1000, 550); - click(1000, 750); - await sleep(1000); - click(1000, 750); - await sleep(1000); - click(1000, 750); - await sleep(1000); - click(1000, 750); - await sleep(1000); - click(1000, 750); - await sleep(1000); - click(1000, 750); - await sleep(1000); - click(1000, 750); - await sleep(1000); - click(1000, 750); - await sleep(1000); - click(1000, 750); - await sleep(1000); - click(1000, 750); - await sleep(1000); - click(1000, 750); - await sleep(1000); - click(1000, 750); - await sleep(1000); - click(1000, 750); - await sleep(1000); - click(1000, 750); - await sleep(1000); - click(1000, 750); - await sleep(1000); - click(1000, 750); - await sleep(1000); - await sleep(validatedLoadingDelay * 1000); - click(1000, 750); - await sleep(1000); - } - - async function AutoPath(locationName) { - try { - let filePath = `assets/AutoPath/${locationName}.json`; - await pathingScript.runFile(filePath); - } catch (error) { - log.error(`执行 ${locationName} 路径时发生错误`); - log.error(error.message); - } - await sleep(2000); - } - - async function AutoFriendship(times, statue_times, GetMeatMode) { - log.info(`导航至好感-张牙舞爪的恶党-触发位置(二净甸)`); - await AutoPath(`好感-张牙舞爪的恶党-触发位置(二净甸)`); - // 加个10秒延迟,避免没上报当前位置导致登录重上后退回传送锚点 - await sleep(10000); - - log.info(`自动好感开始...`); - - for (let i = 0; i < times; i++) { - if ((i + 1) % statue_times === 0) { - await genshin.tp(2297.60, -824.45); - await AutoPath(`好感-张牙舞爪的恶党-触发位置(二净甸)`); - await sleep(10000); - await ReopenTheGate(); - log.info(`当前次数:${i + 1}/${times}`); - logTimeTaken(startTime); - await AutoPath(`好感-张牙舞爪的恶党-循环${GetMeatMode ? '(二净甸刷肉版)' : '(二净甸)'}`); - } else { - await ReopenTheGate(); - log.info(`当前次数:${i + 1}/${times}`); - logTimeTaken(startTime); - await AutoPath(`好感-张牙舞爪的恶党-循环${GetMeatMode ? '(二净甸刷肉版)' : '(二净甸)'}`); - } - log.info(`已完成次数:${i + 1}/${times}`); - logTimeTaken(startTime); - } - log.info('自动好感已完成'); - } - - function logTimeTaken(startTime) { - const currentTime = Date.now(); - const totalTimeInSeconds = (currentTime - startTime) / 1000; - const minutes = Math.floor(totalTimeInSeconds / 60); - const seconds = totalTimeInSeconds % 60; - const formattedTime = `${minutes}分${seconds.toFixed(0).padStart(2, '0')}秒`; - log.info(`当前运行总时长:${formattedTime}`); - } - - let exitdelay = Number(settings.exitdelay); - let loadingdelay = Number(settings.loadingdelay); - // 肉相关 - let GetMeatMode = settings.GetMeatMode ? settings.GetMeatMode : false; - let inputValue = settings.inputValue ? settings.inputValue : 300; - let times = GetMeatMode ? (isNaN(inputValue) ? 50 : Math.ceil(inputValue / 6)) : 10; - // 神像相关 - let gostatue = settings.gostatue ? settings.gostatue : false; - let statue = settings.statue ? settings.statue : 5; - let statue_times = gostatue ? (isNaN(statue) ? 5 : statue) : 0; - - // 启用自动拾取的实时任务,并配置成启用急速拾取模式 - dispatcher.addTimer(new RealtimeTimer("AutoPick", { "forceInteraction": true })); - - const startTime = Date.now(); - setGameMetrics(1920, 1080, 1); // 设置游戏窗口大小和DPI - const { exitDelay: validatedExitDelay, loadingDelay: validatedLoadingDelay } = validateAndSetDefaults(exitdelay, loadingdelay); - const messages = [ - '请确保队伍满员,并为队伍配置相应的战斗策略', - `退出延迟: ${validatedExitDelay}秒, 加载延迟: ${validatedLoadingDelay}秒`, - `设置的七天神像周期为: ${statue_times}`, - `计算后的运行次数为: ${times}`, - ]; - for (let message of messages) { - log.info(message); - await sleep(1000); - } - log.info('自动好感开始...'); - - if (!!settings.partyName) { - try { - await genshin.tp(2297.60, -824.45); - await sleep(3000); - log.info("正在尝试切换至" + settings.partyName); - await genshin.switchParty(settings.partyName); - } catch { - log.warn("队伍切换失败,可能处于联机模式或其他不可切换状态"); - await genshin.returnMainUi(); - } - } else { - await genshin.returnMainUi(); - } - - //默认10次自动好感 - await AutoFriendship(times,statue_times,GetMeatMode); - - // 计算并输出总时长 - const endTime = Date.now(); - const totalTimeInSeconds = (endTime - startTime) / 1000; - const minutes = Math.floor(totalTimeInSeconds / 60); - const seconds = totalTimeInSeconds % 60; - const formattedTime = `${minutes}分${seconds.toFixed(0).padStart(2, '0')}秒`; - log.info(`自动好感运行总时长:${formattedTime}`); -})(); diff --git a/repo/js/Auto好感&刷兽肉/manifest.json b/repo/js/Auto好感&刷兽肉/manifest.json deleted file mode 100644 index c8d39eae..00000000 --- a/repo/js/Auto好感&刷兽肉/manifest.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "manifest_version": 1, - "name": "好感-张牙舞爪的恶党(可用于刷兽肉)", - "version": "1.1.1", - "description": "通过突发事件:张牙舞爪的恶党刷好兽肉,并顺带获取好感度(超过10次后不再获取),请使用满员好感度队伍,并为全体队伍角色配置相应的战斗策略", - "authors": [ - { - "name": "起个名字好难的喵" - } - ], - "settings_ui": "settings.json", - "main": "main.js" -} \ No newline at end of file diff --git a/repo/js/Auto好感&刷兽肉/settings.json b/repo/js/Auto好感&刷兽肉/settings.json deleted file mode 100644 index e1312a91..00000000 --- a/repo/js/Auto好感&刷兽肉/settings.json +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "name": "exitdelay", - "type": "input-text", - "label": "退出延迟(秒)(选填)" - }, - { - "name": "loadingdelay", - "type": "input-text", - "label": "加载延迟(秒)(选填)" - }, - { - "name": "partyName", - "type": "input-text", - "label": "(选填)需要切换的队伍名称" - }, - { - "name": "GetMeatMode", - "type": "checkbox", - "label": "开启刷兽肉模式(勾选才拾取散落的兽肉)" - }, - { - "name": "inputValue", - "type": "input-text", - "label": "刷取个数(选填,默认为300)" - }, - { - "name": "gostatue", - "type": "checkbox", - "label": "开启定期前往七天神像" - }, - { - "name": "statue", - "type": "input-text", - "label": "返回神像周期(选填,默认为5次/周期)" - } -] \ No newline at end of file