babalae/better-genshin-impact · error · Exception

当前选择的自动战斗策略文件不存在

Error message

当前选择的自动战斗策略文件不存在

What it means

Validate 在补全 CombatStrategyPath 后用 File.Exists 和 Directory.Exists 双重检查战斗策略文件,都不存在即抛 Exception。这是战斗脚本来源缺失,后续无法匹配队伍脚本。

Source

Thrown at BetterGenshinImpact/GameTask/AutoBoss/AutoBossTask.cs:1020

        if (_taskParam.SpecifyRunCount && _taskParam.RunCount < 1)
        {
            throw new Exception("指定讨伐次数必须大于 0");
        }

        if (!_taskParam.SpecifyRunCount && (_taskParam.UseTransientResin || _taskParam.UseFragileResin))
        {
            throw new Exception("只有指定讨伐次数模式才能开启须臾树脂或脆弱树脂补充");
        }

        if (string.IsNullOrWhiteSpace(_taskParam.CombatStrategyPath))
        {
            _taskParam.SetCombatStrategyPath(_taskParam.StrategyName);
        }

        if (!File.Exists(_taskParam.CombatStrategyPath) && !Directory.Exists(_taskParam.CombatStrategyPath))
        {
            throw new Exception("当前选择的自动战斗策略文件不存在");
        }

        foreach (var route in GetRequiredRouteFiles(_taskParam.BossName))
        {
            if (!File.Exists(BuildPathingAssetPath(route)))
            {
                throw new FileNotFoundException($"未找到首领路线文件:{route}", BuildPathingAssetPath(route));
            }
        }
    }

    /// <summary>
    /// 获取指定 Boss 启动任务前必须存在的路线文件名。
    /// </summary>
    /// <param name="bossName">Boss 名称。</param>
    /// <returns>需要校验的路线文件名序列。</returns>
    private static IEnumerable<string> GetRequiredRouteFiles(string bossName)
    {

View on GitHub (pinned to a7cb36712d)

Solutions

  1. 在界面重新选择有效的战斗策略文件/目录。
  2. 检查 _taskParam.CombatStrategyPath 的绝对路径是否存在(注意 SetCombatStrategyPath 的拼接逻辑)。
  3. 确认用户目录下的策略文件夹完整。
Defensive patterns

Strategy: validation

Validate before calling

if (!File.Exists(_taskParam.CombatStrategyPath) && !Directory.Exists(_taskParam.CombatStrategyPath))
{
    // UI 启动前检查并提示用户重新选择
}

Prevention

When it happens

Trigger: StrategyName 对应的策略文件被删除/移动;配置中 CombatStrategyPath 指向不存在路径;工作目录变化导致相对路径失效。

Common situations: 用户清理/迁移用户目录;手动改配置填错路径;程序版本变更策略目录结构。

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/f1e773a09eebfbfa. Report an issue: GitHub.