babalae/better-genshin-impact · error · Exception

等待对方行动超时,停止自动打牌!

Error message

等待对方行动超时,停止自动打牌!

What it means

Thrown by the first WaitOpponentAction loop (around line 1000) when the opponent's action has not ended after 60 retries (each with 1s sleep, ~60s total). The loop waits for IsInMyAction() to become true (with a 3-confirmation count) or IsDuelEnd(). If neither occurs within ~60s, the duel is considered stuck and aborted.

Source

Thrown at BetterGenshinImpact/GameTask/AutoGeniusInvokation/GeniusInvokationControl.cs:1031

                else
                {
                    // 多延迟2s // 保证被击败提示已经完成显示
                    inMyActionCount++;
                    if (inMyActionCount == 3)
                    {
                        break;
                    }
                }
            }
            else if (IsDuelEnd())
            {
                throw new NormalEndException("对战已结束,停止自动打牌!");
            }

            retryCount++;
            if (retryCount >= 60)
            {
                throw new System.Exception("等待对方行动超时,停止自动打牌!");
            }

            _logger.LogInformation("对方仍在行动中,继续等待(次数{Count})...", retryCount);
            Sleep(1000);
        }
    }

    /// <summary>
    /// 等待对方回合 和 回合结束阶段
    /// 我方角色可能在此期间阵亡
    /// </summary>
    public void WaitOpponentAction(Duel duel)
    {
        var rd = new Random();
        Sleep(3000 + rd.Next(1, 1000));
        // 判断对方行动是否已经结束
        var retryCount = 0;
        while (true)

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Ensure the game is running smoothly without lag (close background apps, check GPU/CPU load).
  2. Verify the game window is in focus and the capture region is correct.
  3. If the opponent genuinely has long turns, the 60s timeout may need adjustment in source.
  4. Check for game UI updates that may have changed the state-recognition templates (IsInMyAction, IsDuelEnd).
Defensive patterns

Strategy: try-catch

Try / catch

// The TCG automation runner should catch this at the task level
try
{
    control.WaitOpponentAction(duel);
}
catch (Exception e) when (e.Message.Contains("等待对方行动超时"))
{
    _logger.LogError("等待对方行动超时,停止自动打牌: {Msg}", e.Message);
    // Notify user — likely game lag, focus loss, or UI recognition failure
}
catch (NormalEndException)
{
    // Expected — duel ended normally
}

Prevention

When it happens

Trigger: During the opponent's action phase, the game does not transition back to the player's action phase within ~60 seconds. The loop checks IsInMyAction() and IsDuelEnd() each iteration; if neither fires, retryCount increments until 60. Causes: game frozen/crashed, extremely long opponent animation chain, network desync, or UI recognition failure where neither state is detected.

Common situations: Opponent has a very long action sequence (many cards/skills), game lag or hang, UI changed so IsInMyAction/IsDuelEnd recognition fails, or the game window lost focus. Also occurs if the opponent is performing actions that the recognition templates don't cover (new game content).

Related errors


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