# 注册"到点启动游戏 -> 合成模块 -> 关掉游戏"的计划任务。 # # 用法: # powershell -ExecutionPolicy Bypass -File scripts\install_convert_task.ps1 # powershell -ExecutionPolicy Bypass -File scripts\install_convert_task.ps1 -EveryHours 6 # powershell -ExecutionPolicy Bypass -File scripts\install_convert_task.ps1 -Uninstall # # 节奏怎么定(体力恢复速度): # Limbus 的体力每 6 分钟回 1 点, 上限 126。 # 合成 1 个模块要 20 点体力, 所以: # 每 2 小时 -> 约 20 点 -> 1 个模块 # 每 4 小时 -> 约 40 点 -> 2 个模块(默认) # 每 6 小时 -> 约 60 点 -> 3 个模块 # 只要不顶到 126 上限就不浪费恢复量, 所以更勤快些也不会亏。 # 4 小时是"每次都能换到东西"和"别老折腾游戏启动"之间的折中。 # # 这个任务和 LcMCPDailyCycle 是分开的: 用户明确要求这次不打任何关卡, # 只挂机攒模块, 所以不能把刷取任务一起打开。 param( [double]$EveryHours = 4, [string]$Python = "", [switch]$Uninstall ) $ErrorActionPreference = "Stop" $Repo = Split-Path -Parent $PSScriptRoot $TaskName = "LcMCPConvertModules" if ($Uninstall) { Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false -ErrorAction SilentlyContinue Write-Output "uninstalled $TaskName" exit 0 } if (-not $Python) { $Python = Join-Path $Repo "vendor\aalc\.venv\Scripts\pythonw.exe" } if (-not (Test-Path $Python)) { throw "找不到 python: $Python" } $script = Join-Path $PSScriptRoot "convert_modules.py" if (-not (Test-Path $script)) { throw "找不到脚本: $script" } # 以当前用户运行。无人值守要点: 不要勾"只在用户登录时运行", 否则注销后不跑。 $principal = New-ScheduledTaskPrincipal -UserId "$env:USERDOMAIN\$env:USERNAME" ` -LogonType Interactive -RunLevel Limited $action = New-ScheduledTaskAction -Execute $Python -WorkingDirectory $Repo ` -Argument "-X utf8 `"$script`"" # 一次跑 5 分钟足够: 启动游戏 + 进主界面 + 合成 + 关掉。给宽一点防止启动慢。 $limit = New-TimeSpan -Minutes 15 # -Once + 长周期重复, 这样才能设成"每 N 小时" $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(2) ` -RepetitionInterval (New-TimeSpan -Minutes ($EveryHours * 60)) ` -RepetitionDuration (New-TimeSpan -Days 3650) $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries ` -StartWhenAvailable -ExecutionTimeLimit $limit -MultipleInstances IgnoreNew Register-ScheduledTask -TaskName $TaskName -Action $action -Trigger $trigger ` -Principal $principal -Settings $settings -Force | Out-Null Write-Output "registered $TaskName (every $EveryHours h, limit=$limit)" Write-Output "reports -> $env:USERPROFILE\lc_mcp\modules\convert_*.json" Write-Output "log -> $env:USERPROFILE\lc_mcp\modules\convert.log"