babalae/better-genshin-impact · error · Exception

未匹配到任何战斗脚本

Error message

未匹配到任何战斗脚本

What it means

Error "未匹配到任何战斗脚本" thrown in babalae/better-genshin-impact.

Source

Thrown at BetterGenshinImpact/GameTask/AutoFight/Script/CombatScriptBag.cs:45

                    matchCount++;
                }

                if (matchCount != avatars.Count) continue;
                // Logger.LogInformation("匹配到战斗脚本:{Name},共{Cnt}条指令,涉及角色:{Str}", 
                // combatScript.Name, combatScript.CombatCommands.Count, string.Join(",", combatScript.AvatarNames)); 
                Logger.LogInformation("匹配到战斗脚本:{Name}", combatScript.Name); 
                return combatScript.CombatCommands;
            }

            combatScript.MatchCount = matchCount;
        }

        // 没有找到匹配的战斗脚本
        // 按照匹配数量降序排序
        CombatScripts.Sort((a, b) => b.MatchCount.CompareTo(a.MatchCount));
        if (CombatScripts[0].MatchCount == 0)
        {
            throw new Exception("未匹配到任何战斗脚本");
        }

        Logger.LogWarning("未完整匹配到四人队伍,使用匹配度最高的队伍:{Name}", CombatScripts[0].Name);
        return CombatScripts[0].CombatCommands;
    }
}

View on GitHub (pinned to a7cb36712d)

Solutions

  1. 确认战斗脚本中的角色名与当前队伍角色匹配
  2. 检查战斗脚本文件是否被正确加载
  3. 为当前队伍编写或选择合适的战斗脚本

Example fix

放入与当前队伍角色匹配的txt脚本;检查日志中脚本解析失败警告并修正脚本格式。

When it happens

Trigger: CombatScriptBag.FindCombatScript 遍历所有脚本后匹配数最高的脚本 MatchCount 仍为0,即没有任何脚本角色与当前队伍重合时抛出。

Common situations: 脚本目录中的战斗脚本与当前队伍完全不相关,或脚本全部解析失败被跳过。


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