babalae/better-genshin-impact · error · Exception

初始识别失败且切换区域后依然无效

Error message

初始识别失败且切换区域后依然无效

What it means

Thrown by GetInitialMoveMapState when all strategies to obtain the starting map position fail: initial recognition, zoom-based recovery, force-jump to the target area, then a second round of recognition and zoom recovery all return failure. This is the initial state acquisition before panning begins, so if the map can't be located at all, the operation cannot proceed.

Source

Thrown at BetterGenshinImpact/GameTask/AutoTrackPath/TpTask.cs:1534

        var jumpedCenterPoint = await ForceJumpToTargetArea(x, y, mapName);
        if (jumpedCenterPoint != null)
        {
            return (GetMoveMapState(jumpedCenterPoint.Value, x, y, recoveredState.ZoomLevel), recoveredState.ZoomLevel);
        }

        if (TryGetRecognizedMoveMapState(mapName, x, y, recoveredState.ZoomLevel, out moveState))
        {
            return (moveState, recoveredState.ZoomLevel);
        }

        recoveredState = await TryRecoverMoveMapStateByZoom(mapName, x, y, recoveredState.ZoomLevel);
        if (recoveredState.Success)
        {
            return (recoveredState.MoveState, recoveredState.ZoomLevel);
        }

        throw new Exception("初始识别失败且切换区域后依然无效");
    }

    private async Task<(bool Success, MapMoveState MoveState, double ZoomLevel)> TryRecoverMoveMapStateByZoom(
        string mapName,
        double x,
        double y,
        double currentZoomLevel)
    {
        if (!_tpConfig.MapZoomEnabled)
        {
            return (false, default, currentZoomLevel);
        }

        var targetZoomLevel = GetMapPositionRecognitionRecoveryZoomLevel(currentZoomLevel, mapName);
        if (IsZoomCloseEnough(currentZoomLevel, targetZoomLevel))
        {
            return (false, default, currentZoomLevel);
        }

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Ensure the big map is fully open and rendered before invoking the teleport task.
  2. Verify map assets are up to date for the current game version.
  3. Enable MapZoomEnabled in the teleport config so zoom-based recovery can be attempted.
  4. Check that the target coordinates fall within a known/loaded map region.
  5. Restart the task after ensuring the game is in the correct map UI state.
Defensive patterns

Strategy: try-catch

Validate before calling

// Before calling, verify the game is on the big map
using var ra = task.CaptureToRectArea();
using var btn = ra.Find(task.GetQuickTeleportRecognitionObject("MapScaleButton", ra));
if (!btn.IsExist())
{
    // Open the map first
}

Try / catch

try
{
    await task.MoveMapTo(x, y, mapName);
}
catch (Exception ex) when (ex.Message == "初始识别失败且切换区域后依然无效")
{
    Logger.LogError("Failed to acquire initial map position. Ensure the big map is open.");
    throw;
}

Prevention

When it happens

Trigger: Called from MoveMapToCore → GetInitialMoveMapState. TryGetRecognizedMoveMapState fails, TryRecoverMoveMapStateByZoom fails (or MapZoomEnabled is false), ForceJumpToTargetArea returns null, and the second attempt at both recognition and zoom recovery also fails.

Common situations: Game is not on the big map screen when the method starts; map area assets are corrupted or outdated; the target map region is in an area not covered by assets; display resolution/scaling prevents recognition.

Related errors


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