babalae/better-genshin-impact · error · Exception

实际战斗次数({pathingTask.SuccessFight})<预期战斗次数({fightCount}),判定失败

Error message

实际战斗次数({pathingTask.SuccessFight})<预期战斗次数({fightCount}),判定失败,触发异常!

What it means

Thrown when the actual fight count (pathingTask.SuccessFight) is less than the expected fight count derived from the pathing JSON's Fight-type positions, but only for farming scripts (PrimaryTarget != 'disable') when AutoRestart is enabled and IsFightFailureExceptional is true. This validates that all expected combats were engaged during a farming route.

Source

Thrown at BetterGenshinImpact/Core/Script/Group/ScriptGroupProject.cs:277

            if (task.FarmingInfo.AllowFarmingCount)
            {
                var successFight = pathingTask.SuccessEnd;
                var fightCount = 0;
               
                //未走完完整路径下,才校验打架次数
                if (!successFight)
                {
                    fightCount = task.Positions.Count(pos => pos.Action == ActionEnum.Fight.Code);
                    successFight = pathingTask.SuccessFight >= fightCount;
                    //判断为锄地脚本
                    if (task.FarmingInfo.PrimaryTarget!="disable")
                    {

                        if (autoRestart.Enabled
                            &&autoRestart.IsFightFailureExceptional
                            &&!successFight)
                        {
                            throw new Exception($"实际战斗次数({pathingTask.SuccessFight})<预期战斗次数({fightCount}),判定失败,触发异常!");
                        }
                    }
                }

                if (successFight)
                {
                    //每日锄地记录
                    FarmingStatsRecorder.RecordFarmingSession(task.FarmingInfo, new FarmingRouteInfo
                    {
                        GroupName = GroupInfo?.Name ?? "",
                        FolderName = FolderName,
                        ProjectName = Name
                    });
                }
                else
                {
                    TaskControl.Logger.LogWarning($"实际战斗次数({pathingTask.SuccessFight})<预期战斗次数({fightCount}),判定失败,此次不纳入成功锄地规划的统计上限!");
                }

View on GitHub (pinned to a7cb36712d)

Solutions

  1. If you don't want auto-restart on fight failures, disable IsFightFailureExceptional in AutoRestartConfig.
  2. Review the pathing JSON — reduce expected Fight positions or improve combat waypoints.
  3. Check combat detection settings and enemy recognition thresholds.
  4. Verify the game is in the correct state (not in dialogue, menus, etc.) during farming.
Defensive patterns

Strategy: try-catch

Try / catch

try
{
    await project.Run();
}
catch (Exception ex) when (ex.Message.Contains("实际战斗次数"))
{
    TaskControl.Logger.LogWarning("Fight count mismatch: {Message}", ex.Message);
    // Log detailed farming stats, retry or skip
}

Prevention

When it happens

Trigger: Executing a Pathing task where task.FarmingInfo.AllowFarmingCount is true, the route didn't fully complete (SuccessEnd=false), pathingTask.SuccessFight < number of positions with Action == Fight, and FarmingInfo.PrimaryTarget is not 'disable', with autoRestart.Enabled and autoRestart.IsFightFailureExceptional both true.

Common situations: Enemies were not detected or engaged during farming. The pathing script skipped combat positions due to navigation issues. Enemy detection threshold too high or combat interrupted by game events. This is a quality-assurance check for farming route completion.

Related errors


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