Skip to content

Commit 9234ae9

Browse files
committed
feat: 自动战斗支持切换后援
1 parent f0127ea commit 9234ae9

14 files changed

Lines changed: 186 additions & 3 deletions

File tree

assets/game_data/screen_info/_od_merged.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,20 @@
408408
template_match_threshold: 0.7
409409
color_range: null
410410
goto_list: []
411+
- area_name: 按键-切换后援
412+
id_mark: false
413+
pc_rect:
414+
- 1615
415+
- 776
416+
- 1726
417+
- 877
418+
text: ''
419+
lcs_percent: 0.5
420+
template_sub_dir: battle
421+
template_id: btn_switch_backup_1
422+
template_match_threshold: 0.7
423+
color_range: null
424+
goto_list: []
411425
- area_name: 连携技-1
412426
id_mark: false
413427
pc_rect:
@@ -675,6 +689,20 @@
675689
template_match_threshold: 0.7
676690
color_range: null
677691
goto_list: []
692+
- area_name: 按键-切换后援标记
693+
id_mark: false
694+
pc_rect:
695+
- 1658
696+
- 891
697+
- 1661
698+
- 897
699+
text: ''
700+
lcs_percent: 0.5
701+
template_sub_dir: ''
702+
template_id: ''
703+
template_match_threshold: 0.7
704+
color_range: null
705+
goto_list: []
678706
- screen_id: battle_menu
679707
screen_name: 战斗-菜单
680708
pc_alt: false
@@ -1297,20 +1325,41 @@
12971325
- 770
12981326
- 1110
12991327
- 830
1328+
text: ''
1329+
lcs_percent: null
1330+
template_sub_dir: ''
1331+
template_id: ''
1332+
template_match_threshold: null
1333+
color_range: null
1334+
goto_list: []
13001335
- area_name: 对话框内容
13011336
id_mark: false
13021337
pc_rect:
13031338
- 418
13041339
- 831
13051340
- 1500
13061341
- 980
1342+
text: ''
1343+
lcs_percent: null
1344+
template_sub_dir: ''
1345+
template_id: ''
1346+
template_match_threshold: null
1347+
color_range: null
1348+
goto_list: []
13071349
- area_name: 右侧选项区域
13081350
id_mark: false
13091351
pc_rect:
13101352
- 1438
13111353
- 536
13121354
- 1914
13131355
- 830
1356+
text: ''
1357+
lcs_percent: null
1358+
template_sub_dir: ''
1359+
template_id: ''
1360+
template_match_threshold: null
1361+
color_range: null
1362+
goto_list: []
13141363
- area_name: 中间选项区域
13151364
id_mark: false
13161365
pc_rect:
@@ -1402,6 +1451,13 @@
14021451
- 213
14031452
- 565
14041453
- 285
1454+
text: ''
1455+
lcs_percent: null
1456+
template_sub_dir: ''
1457+
template_id: ''
1458+
template_match_threshold: null
1459+
color_range: null
1460+
goto_list: []
14051461
- area_name: 按钮-短信-关闭
14061462
id_mark: false
14071463
pc_rect:

assets/game_data/screen_info/battle.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ area_list:
4444
template_match_threshold: 0.7
4545
color_range: null
4646
goto_list: []
47+
- area_name: 按键-切换后援
48+
id_mark: false
49+
pc_rect:
50+
- 1615
51+
- 776
52+
- 1726
53+
- 877
54+
text: ''
55+
lcs_percent: 0.5
56+
template_sub_dir: battle
57+
template_id: btn_switch_backup_1
58+
template_match_threshold: 0.7
59+
color_range: null
60+
goto_list: []
4761
- area_name: 连携技-1
4862
id_mark: false
4963
pc_rect:
@@ -311,3 +325,17 @@ area_list:
311325
template_match_threshold: 0.7
312326
color_range: null
313327
goto_list: []
328+
- area_name: 按键-切换后援标记
329+
id_mark: false
330+
pc_rect:
331+
- 1658
332+
- 891
333+
- 1661
334+
- 897
335+
text: ''
336+
lcs_percent: 0.5
337+
template_sub_dir: ''
338+
template_id: ''
339+
template_match_threshold: 0.7
340+
color_range: null
341+
goto_list: []
380 Bytes
Loading
5.78 KB
Loading
389 Bytes
Loading
9.12 KB
Loading

config/auto_battle/全配队通用.merged.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12206,6 +12206,10 @@
1220612206
- "op_name": "等待秒数"
1220712207
"seconds": 0.1
1220812208
"states": "([按键-切换角色-下一个, 0, 0.1] | [按键-切换角色-上一个, 0, 0.1]) | [自定义-连携跳过, 0, 0.1]"
12209+
- "debug_name": "切换后援可用"
12210+
"operations":
12211+
- "op_name": "按键-切换后援"
12212+
"states": "[按键可用-切换后援, 0, 1] & ![按键-切换后援, 0, 2]"
1220912213
- "states": ""
1221012214
"sub_handlers":
1221112215
- "interrupt_states": "[前台-能量, 0, 0.1] & ![前台-莱卡恩]"

config/auto_battle/全配队通用.sample.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,17 @@ scenes:
128128
sub_handlers:
129129
- state_template: "轮换-合轴-全角色"
130130

131+
- triggers: ["按键可用-切换后援"]
132+
priority: 70
133+
interval: 0.1
134+
handlers:
135+
- states: "![自定义-终结技被强制释放, 0, 1]"
136+
debug_name: "切换后援可用"
137+
operations:
138+
- op_name: "按键-切换后援"
139+
- op_name: "等待秒数"
140+
seconds: 0.1
141+
131142
- triggers: []
132143
priority: 9
133144
interval: 0.02

docs/develop/zzz/auto_battle.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# 自动战斗补充说明
2+
3+
## 队伍角色识别兜底
4+
5+
自动战斗中的队伍角色识别,原本会在连续多次识别结果一致后,停止全量匹配,转为基于当前队伍信息的低成本识别。
6+
7+
当游戏内出现同一队伍在战斗中循环切换的新模式时,旧的低成本识别可能会因为候选角色被固定,导致当前画面一个角色都识别不到。
8+
9+
针对这个场景,当前实现增加了一个兜底策略:
10+
11+
- 当普通攻击按钮可用,说明当前仍处于战斗画面。
12+
- 如果这一帧角色识别结果为“一个角色都识别不到”,则不立即常驻开启全量识别。
13+
- 仅将下一次角色识别强制切回“全量匹配所有角色”,并重置识别节流时间。
14+
15+
这样可以在兼容新模式的同时,尽量减少常规战斗中的模板匹配压力。
16+
17+
## 战斗按钮提示
18+
19+
战斗画面中的部分按钮会通过模板匹配写入状态,供自动战斗状态判断与调试提示使用。
20+
21+
- 普通攻击按钮用于快速判断当前是否仍处于战斗画面。
22+
- 切换后援按钮每 1 秒检测一次,识别命中时会写入状态 `按键可用-切换后援`
23+
- 自动战斗可直接执行原子操作 `按键-切换后援`,默认键盘键位为 `R`

src/zzz_od/auto_battle/atomic_op/btn_common.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
import threading
44
import time
5-
from enum import StrEnum, IntEnum
6-
from typing import TYPE_CHECKING, Callable
5+
from collections.abc import Callable
6+
from enum import IntEnum, StrEnum
7+
from typing import TYPE_CHECKING
78

89
from one_dragon.base.conditional_operation.atomic_op import AtomicOp
910
from one_dragon.base.conditional_operation.operation_def import OperationDef
@@ -62,6 +63,8 @@ def __init__(self, ctx: AutoBattleContext, op_def: OperationDef):
6263
self._method = self.ctx.switch_next
6364
elif op_name == BattleStateEnum.BTN_SWITCH_PREV.value:
6465
self._method = self.ctx.switch_prev
66+
elif op_name == BattleStateEnum.BTN_SWITCH_BACKUP.value:
67+
self._method = self.ctx.switch_backup
6568
elif op_name == BattleStateEnum.BTN_SWITCH_NORMAL_ATTACK.value:
6669
self._method = self.ctx.normal_attack
6770
elif op_name == BattleStateEnum.BTN_SWITCH_SPECIAL_ATTACK.value:
@@ -93,7 +96,7 @@ def execute(self):
9396
return
9497
self._status = BtnRunStatus.RUNNING
9598

96-
for i in range(self.repeat_times):
99+
for _i in range(self.repeat_times):
97100
if self._status != BtnRunStatus.RUNNING:
98101
break
99102

0 commit comments

Comments
 (0)