babalae/better-genshin-impact · error · PartySetupFailedException
切换角色:未找到目标角色 {_currentRole.Name}
Error message
切换角色:未找到目标角色 {_currentRole.Name} What it means
HandleFindAndClickAvatar could not locate the target character's avatar in the (filtered) character grid after all search attempts — direct recognition failed, and the friendship-sort loop (up to FriendshipSortSearchAttemptCount=3 toggling sort direction) also failed. The role is therefore unavailable on this account or unrecognizable, so the switch is aborted.
Source
Thrown at BetterGenshinImpact/GameTask/Common/Job/SwitchCharacterStateMachineTask.cs:858
avatarFound = true;
break;
}
_logger.LogDebug(
"切换角色:好感排序第 {Attempt}/{AttemptCount} 次未找到 {Name}",
attempt,
FriendshipSortSearchAttemptCount,
_currentRole.Name);
}
}
else
{
avatarFound = await FindAndClickAvatar(_currentRole, Recognizer, _ct);
}
if (!avatarFound)
{
throw new PartySetupFailedException($"切换角色:未找到目标角色 {_currentRole.Name}");
}
if (!TryClickAnyText(page, ["更换", "加入"], Rect1080(382, 994, 87, 51)))
{
_logger.LogWarning("切换角色:未识别到“更换”或“加入”按钮");
return StateHandlerResult.Retry;
}
if (_isAppendingRole)
{
_currentTeamSlots.Add(new TeamSlotSnapshot(_currentRole.Slot, _currentRole.PrimaryCandidateName));
_currentTeamSlots = _currentTeamSlots.OrderBy(slot => slot.Slot).ToList();
_expectedTeamCount++;
}
else
{
_currentTeamSlots = _currentTeamSlots
.Select(slot => slot.Slot == _currentRole.SlotView on GitHub (pinned to a7cb36712d)
Solutions
- Verify the character is actually owned and not excluded by the active element/weapon filter (check _pendingFilterElementType/_pendingFilterWeaponType for this role).
- Confirm the character's avatar is present in the recognizer's trained set; add/retrain if missing.
- Lower/raise assetScale or MatchThreshold only after confirming capture resolution; re-run on a known 1080p capture.
- Check the role's CandidateNames includes all in-game display variants (costume/alias) so Matches/FindAndClickAvatar can hit.
Defensive patterns
Strategy: try-catch
Validate before calling
// before starting, confirm the character is plausibly available
var owned = await CheckOwnedCharacters(ct); // user-supplied
foreach (var name in requestedNames)
if (!owned.Contains(name))
throw new ArgumentException($"账号未拥有角色 {name}"); Try / catch
try { await switchTask.Start(...); }
catch (PartySetupFailedException ex) when (ex.Message.Contains("未找到目标角色"))
{ _logger.LogError(ex, "目标角色在筛选网格中未找到:检查账号拥有情况、筛选条件与识别器模型"); } Prevention
- Verify the character is owned and not excluded by the element/weapon filter.
- Keep AvatarGridIconRecognizer models current with new characters/costumes.
- Provide all display-name aliases in CandidateNames.
When it happens
Trigger: FindAndClickAvatar(role, Recognizer, ct) returned false for every attempt; either UseFriendshipSort was true and all 3 sort-direction iterations missed, or it was false and the single direct scan missed.
Common situations: The character does not exist on the account (typo in config, not yet owned); element/weapon filter excluded it so it never appears in the grid; AvatarGridIconRecognizer model does not contain the character's icon (new/unreleased character, costume variant); grid card detection (DetectCharacterCards) rejected the card; game rendering at a different scale dropped the match below MatchThreshold=0.7.
Related errors
- 切换角色:{slot.Slot} 号位角色识别为空
- 切换角色:角色列表队伍识别不完整,期望 {expectedTeamCount} 个,末次检测到 {lastDetecte
- 切换角色:连续 3 次未检测到合法角色卡片
- 切换角色:未找到 {misplaced.Slot} 号位的换下按钮
- 切换角色:筛选面板缺少武器筛选项
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/cdbd686272ba4104.
Report an issue: GitHub.