babalae/better-genshin-impact · error · Exception
未能获取到我方角色卡位置
Error message
未能获取到我方角色卡位置
What it means
Thrown by GeniusInvokationControl.WhatCharacterDefeated when the input rects list is null or does not contain exactly 3 elements. The method expects 3 character card rectangles (one per character in the TCG duel) to perform template matching for defeated-character detection. An invalid rects collection means upstream character card position detection failed.
Source
Thrown at BetterGenshinImpact/GameTask/AutoGeniusInvokation/GeniusInvokationControl.cs:930
/// <summary>
/// 出战角色是否被打倒
/// </summary>
/// <returns></returns>
public bool IsActiveCharacterTakenOut()
{
using var ra = CaptureGameRectArea();
return !ra.Find(GetRecognitionObject("CharacterTakenOut", ra)).IsEmpty();
}
/// <summary>
/// 哪些出战角色被打倒了
/// </summary>
/// <returns>true 是已经被打倒</returns>
public bool[] WhatCharacterDefeated(List<Rect> rects)
{
if (rects == null || rects.Count != 3)
{
throw new System.Exception("未能获取到我方角色卡位置");
}
using var greyMat = CaptureGameGreyMat();
var pList = MatchTemplateHelper.MatchTemplateMulti(greyMat, _assets.CharacterDefeatedMat, 0.8);
var res = new bool[3];
foreach (var p in pList)
{
for (var i = 0; i < rects.Count; i++)
{
if (IsOverlap(rects[i],
new Rect(p.X, p.Y, _assets.CharacterDefeatedMat.Width, _assets.CharacterDefeatedMat.Height)))
{
res[i] = true;
}
}
}
View on GitHub (pinned to a7cb36712d)
Solutions
- Ensure the game runs at a supported resolution (1920x1080) so character card positions are detected correctly during duel setup.
- Check logs for earlier warnings about character card position detection during the duel initialization phase.
- Verify no overlay or window is obscuring the character card area.
- If the issue persists, the character card detection templates may need updating after a game UI patch.
Defensive patterns
Strategy: try-catch
Validate before calling
// Before calling WhatCharacterDefeated, verify character card rects were detected
if (duel.CharacterCardRects == null || duel.CharacterCardRects.Count != 3)
{
_logger.LogWarning("角色卡位置未正确检测,跳过阵亡检测");
return;
} Try / catch
try
{
var defeated = control.WhatCharacterDefeated(duel.CharacterCardRects);
}
catch (Exception e) when (e.Message.Contains("未能获取到我方角色卡位置"))
{
_logger.LogError("角色卡位置检测失败,可能分辨率不正确: {Msg}", e.Message);
// This indicates upstream position detection failed; check resolution and logs
} Prevention
- Ensure 1920x1080 resolution so character card positions are detected during duel setup.
- Check for earlier warnings during duel initialization about character card detection.
- Keep the game window unobstructed and in focus.
- After UI patches, card position templates may need updating.
When it happens
Trigger: Called from DoWhenCharacterDefeated with duel.CharacterCardRects that is null or has != 3 entries. The character card positions are detected earlier in the duel setup; if that detection failed or returned partial results, this guard fires when a character is defeated and the system tries to determine which one.
Common situations: Game resolution or UI layout changes causing character card position detection to fail during duel initialization. The failure cascades: position detection fails silently, then when a character is defeated, WhatCharacterDefeated cannot proceed. Could also occur if the duel started with fewer than 3 characters due to upstream logic errors.
Related errors
- 识别骰子数量不正确,重试超时,停止自动打牌!
- 骰子数量与预期不符,重试次数过多,可能出现了未知错误!
- 等待对方行动超时,停止自动打牌!
- 角色【{characterCard.Name}】卡牌配置解析失败:{e.Message}。请自行进行角色定义
- 请先打开合成界面。
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/f53e45857f376aeb.
Report an issue: GitHub.