babalae/better-genshin-impact · error · PartySetupFailedException

切换角色:等待单机图标、联机状态及 top_left 玩家标记超时({timeoutMilliseconds / 100

Error message

切换角色:等待单机图标、联机状态及 top_left 玩家标记超时({timeoutMilliseconds / 1000} 秒),最后结果:{lastResult}

What it means

DetectPlayerIndex polls for up to timeoutMilliseconds (5000ms) trying to confirm the play mode: either the StandAloneIcon asset (single-player), a stable MultiGameStatus, or a unique top_left player marker (1P-4P). If none resolves uniquely within the deadline it throws, because the controllable-slot layout cannot be configured.

Source

Thrown at BetterGenshinImpact/GameTask/Common/Job/SwitchCharacterStateMachineTask.cs:1237

            }
            finally
            {
                foreach (var match in matches)
                {
                    match.Region.Dispose();
                }
            }

            var remainingMilliseconds = deadline - Environment.TickCount64;
            if (remainingMilliseconds <= 0)
            {
                break;
            }

            await Delay((int)Math.Min(retryIntervalMilliseconds, remainingMilliseconds), ct);
        } while (Environment.TickCount64 < deadline);

        throw new PartySetupFailedException(
            $"切换角色:等待单机图标、联机状态及 top_left 玩家标记超时({timeoutMilliseconds / 1000} 秒),最后结果:{lastResult}");
    }

    private void ConfigureOperableSlots()
    {
        int[] physicalSlots = (_multiGamePlayerCount, _playerIndex) switch
        {
            (1, _) => [1, 2, 3, 4],
            (2, 1) => [1, 2],
            (2, 2) => [3, 4],
            (3, 1) => [1, 2],
            (3, 2) => [3],
            (3, 3) => [4],
            (4, 1) => [1],
            (4, 2) => [2],
            (4, 3) => [3],
            (4, 4) => [4],
            _ => throw new PartySetupFailedException(

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Guarantee DetectPlayerIndex runs on the main UI — return to main UI first and wait for Bv.IsInMainUi before calling.
  2. Update RecognitionAssets StandAloneIcon and 1P-4PTopLeft templates for the current game version and capture scale.
  3. Raise timeoutMilliseconds or retryIntervalMilliseconds if co-op status is known to stabilize slowly.
  4. Inspect 'lastResult' in the message: '无' means no markers ever matched (asset/scale issue); a comma list means ambiguous/flickering detection (need longer settle).
Defensive patterns

Strategy: retry

Validate before calling

if (!Bv.IsInMainUi(CaptureToRectArea()))
{
    await _returnMainUiTask.Start(ct);
}

Try / catch

try { await switchTask.Start(...); }
catch (PartySetupFailedException ex) when (ex.Message.Contains("等待单机图标"))
{ _logger.LogWarning(ex, "联机状态识别超时,建议确认处于主界面后重试"); }

Prevention

When it happens

Trigger: The do/while loop in DetectPlayerIndex exhausts the 5000ms deadline without (a) StandAloneIcon.IsExist, (b) a 1-player multi-game status, or (c) exactly one matchedPlayers entry whose index <= _multiGamePlayerCount. 'lastResult' in the message records the final partial finding.

Common situations: Called while not actually on the main UI (loading screen, dialog open); capture not updating; assets StandAloneIcon / NPTopLeft mismatch the current game version or scale; multiple top_left markers flicker so matchedPlayers.Length != 1 for the whole window; PartyAvatarSideIndexHelper.DetectedMultiGameStatus kept throwing (transient co-op detection instability).

Understand the failure class

Related errors


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