babalae/better-genshin-impact · error · ArgumentException
战斗策略脚本中出现未知的方法:{method}
Error message
战斗策略脚本中出现未知的方法:{method} What it means
Thrown by Method.GetEnumByCode when the provided method string does not match any alias in the known Method values. The Method class defines combat commands (skill/e, burst/q, attack, charge, wait, walk, dash, jump, etc.) with alias lists. If the input matches none, it is an unrecognized command in the combat script.
Source
Thrown at BetterGenshinImpact/GameTask/AutoFight/Script/Method.cs:95
public List<string> Alias { get; private set; }
public Method(List<string> alias)
{
Alias = alias;
}
public static Method GetEnumByCode(string method)
{
foreach (var m in Values)
{
if (m.Alias.Contains(method))
{
return m;
}
}
Logger.LogError($"战斗策略脚本中出现未知的方法:{method}");
throw new ArgumentException($"战斗策略脚本中出现未知的方法:{method}");
}
}View on GitHub (pinned to a7cb36712d)
Solutions
- Check the method name in the error message ({method}) against the supported list in Method.cs.
- Common valid names: skill/e, burst/q, attack/普攻, charge/重击, wait/after, walk, dash/冲刺, jump/j, and macro commands (click, keydown, etc.).
- Note: 'aim'/'r' is NOT available (commented out in Values) even though an Aim Method is defined.
- Fix typos and ensure the method name is one of the recognized aliases.
Example fix
// before (typo) // 香菱 skil(1),e(2) // after // 香菱 skill(1),e(2)
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-validate method name against known aliases
static readonly HashSet<string> KnownMethodAliases = new(StringComparer.OrdinalIgnoreCase)
{
"skill", "e", "burst", "q", "attack", "普攻", "普通攻击",
"charge", "重击", "wait", "after", "等待", "ready", "完成",
"check", "检测", "walk", "行走", "w", "a", "s", "d",
"dash", "冲刺", "jump", "j", "跳跃",
"mousedown", "mouseup", "click", "moveby", "keydown", "keyup", "keypress",
"scroll", "verticalscroll", "round"
};
if (!KnownMethodAliases.Contains(methodName))
Log.LogWarning("未知的方法名: {Method}", methodName); Try / catch
try
{
var method = Method.GetEnumByCode(cmd);
}
catch (ArgumentException e) when (e.Message.Contains("未知的方法"))
{
Logger.LogWarning("跳过未知指令: {Cmd}", cmd);
// Skip or prompt user to fix the script
} Prevention
- Refer to Method.cs for the complete list of valid method names and aliases.
- Note: 'aim'/'r' is defined but commented out in Values — it will throw even though it exists.
- When updating from older versions, check for renamed or removed methods.
- Test combat scripts after version updates.
When it happens
Trigger: CombatScriptParser creates a CombatCommand from a parsed command string, and the method name extracted from it is not in any Method.Alias list. For example: `香菱 unskill(1)`, `香菱 E1`, or a typo like `skil(1)`.
Common situations: User writes a TXT combat script with a misspelled or unsupported method name. Also occurs when using a method that was commented out in Values (e.g., 'aim'/'r' is commented out in the Values yield at line 57). Version updates that renamed or removed methods can also trigger this.
Related errors
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/884c60d200520de2.
Report an issue: GitHub.