Add combat error beacon and adjust combat recovery

This commit is contained in:
王鹏
2026-04-20 15:32:35 +08:00
parent 6ec468a78b
commit 66b8edf8e4
4 changed files with 82 additions and 12 deletions

View File

@@ -88,6 +88,22 @@ def _tri_state_label(value, low_mid_high):
return low_mid_high[2]
_COMBAT_ERROR_SIGNALS = (50, 100, 150, 200, 220, 255)
_COMBAT_ERROR_LABELS = {
50: '需转身',
100: '距离远',
150: '不在视野',
200: '技能CD',
220: '资源不足',
255: '正常',
}
def _combat_error_signal_from_g(channel_byte):
"""Lua G 通道离散状态码还原为最近的约定值。"""
return min(_COMBAT_ERROR_SIGNALS, key=lambda t: abs(t - int(channel_byte)))
def format_game_state_line(state):
"""单行状态文字(中文),供 CLI 与 GUI 共用。"""
death_txt = ('存活', '尸体', '灵魂')[state.get('death_state', 0)]
@@ -108,12 +124,16 @@ def format_game_state_line(state):
state.get('follow', 0),
('未跟随', '需补跟随', '跟随中'),
)
combat_error_txt = state.get('combat_error_label') or _COMBAT_ERROR_LABELS.get(
state.get('combat_error_signal', 255), '未知'
)
return (
f"{hp_part} | "
f"{combat_txt} {target_txt} | "
f"空格:{state.get('free_slots', 0)} 耐久:{state.get('durability', 0):.0%} {death_txt} | "
f"x:{state['x']} y:{state['y']} 朝向:{state['facing']:.1f}° | "
f"{flight_txt} {mounted_txt} {flyable_txt} {follow_txt}"
f"{flight_txt} {mounted_txt} {flyable_txt} {follow_txt} | "
f"战斗信号:{combat_error_txt}"
)
@@ -213,6 +233,8 @@ def parse_game_state():
# 第 10 像素Lua pixels[10]R=跟随信号
p10 = get_val(8)
state['follow'] = _tri_state_from_r(p10[0])
state['combat_error_signal'] = _combat_error_signal_from_g(p10[1])
state['combat_error_label'] = _COMBAT_ERROR_LABELS.get(state['combat_error_signal'], '未知')
return state