Skip to content

Commit dc2f2f7

Browse files
resolve conflicts
2 parents ab42470 + 398ce9d commit dc2f2f7

14 files changed

Lines changed: 335 additions & 100 deletions

File tree

agent/custom/action/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .AutoFish.auto_sell_fish import *
55
from .auto_make_coffee import *
66
from .Common.click import *
7+
from .realtime_task import *
78

89

910
__all__ = [
@@ -13,4 +14,5 @@
1314
"AutoBuyFishBait",
1415
"AutoSellFish",
1516
"ClickOverride",
17+
"RealTimeTaskAction",
1618
]
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import json
2+
from typing import List
3+
4+
from maa.agent.agent_server import AgentServer
5+
from maa.custom_action import CustomAction
6+
from maa.context import Context
7+
8+
9+
HOLDER_NODE_NAME = "__RealTimeTaskAction_Holder"
10+
11+
12+
def _parse_nodes(custom_action_param: str) -> List[str]:
13+
if not custom_action_param:
14+
raise ValueError("RealTimeTaskAction: empty custom_action_param")
15+
16+
params = json.loads(custom_action_param)
17+
if not isinstance(params, dict):
18+
raise ValueError(f"RealTimeTaskAction: invalid JSON object: {custom_action_param}")
19+
20+
nodes = params.get("nodes")
21+
if not isinstance(nodes, list) or len(nodes) == 0:
22+
raise ValueError(f"RealTimeTaskAction: 'nodes' missing, not an array, or empty: {custom_action_param}")
23+
24+
for v in nodes:
25+
if not isinstance(v, str):
26+
raise ValueError("RealTimeTaskAction: every entry in 'nodes' must be a string")
27+
28+
return nodes
29+
30+
31+
def _build_pipeline_override(nodes: List[str]) -> dict:
32+
return {HOLDER_NODE_NAME: {"next": nodes}}
33+
34+
35+
@AgentServer.custom_action("RealTimeTaskAction")
36+
class RealTimeTaskAction(CustomAction):
37+
def run(self, context: Context, argv: CustomAction.RunArg) -> CustomAction.RunResult:
38+
nodes = _parse_nodes(argv.custom_action_param)
39+
pipeline_override = _build_pipeline_override(nodes)
40+
41+
while not context.tasker.stopping:
42+
result = context.run_task(HOLDER_NODE_NAME, pipeline_override)
43+
if result is None:
44+
print("RealTimeTaskAction: RunTask returned None, continue loop")
45+
46+
print("RealTimeTaskAction: tasker stopping signal received, exit loop")
47+
return CustomAction.RunResult(success=True)

assets/interface.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,27 @@
1111
"mirrorchyan_multiplatform": true,
1212
"controller": [
1313
{
14-
"name": "桌面端-默认",
14+
"name": "Win32-Front",
15+
"label": "桌面端-前台",
1516
"type": "Win32",
16-
"permission_required": true,
1717
"win32": {
18-
"class_regex": "UnrealWindow",
18+
"class_regex": ".*",
1919
"window_regex": "^\\s*(异环|NTE)\\s*$",
2020
"screencap": "PrintWindow",
21-
"mouse": "SendMessageWithWindowPos",
21+
"mouse": "Seize",
2222
"keyboard": "PostMessage"
2323
}
2424
},
2525
{
26-
"name": "桌面端-前台",
26+
"name": "Win32-Background",
27+
"label": "桌面端-后台",
2728
"type": "Win32",
29+
"permission_required": true,
2830
"win32": {
29-
"class_regex": ".*",
31+
"class_regex": "UnrealWindow",
3032
"window_regex": "^\\s*(异环|NTE)\\s*$",
3133
"screencap": "PrintWindow",
32-
"mouse": "Seize",
34+
"mouse": "SendMessageWithWindowPos",
3335
"keyboard": "PostMessage"
3436
}
3537
}
3.27 KB
Loading
4.54 KB
Loading
1.64 KB
Loading
4.46 KB
Loading
Lines changed: 21 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,27 @@
11
{
22
"RealTimeTaskMain": {
3-
"recognition": "DirectHit",
4-
"action": "DoNothing",
5-
"next": [
6-
"RealTimeSkipPlot",
7-
"RealTimeTeleportWitte",
8-
"RealTimeTeleportPhone",
9-
"RealTimeSleep"
10-
]
11-
},
12-
"RealTimeSkipPlot": {
13-
"recognition": {
14-
"type": "TemplateMatch",
15-
"param": {
16-
"template": "realtime_assist/skip_story_btn.png",
17-
"roi": [1000, 0, 1280, 100],
18-
"threshold": 0.8
19-
}
20-
},
21-
"action": {
22-
"type": "Click"
23-
},
24-
"post_delay": 500,
25-
"next": ["RealTimeSleep"]
26-
},
27-
"RealTimeTeleportWitte": {
28-
"recognition": {
29-
"type": "TemplateMatch",
30-
"param": {
31-
"template": "realtime_assist/teleport_target_witte.png",
32-
"roi": [920, 0, 1280, 140],
33-
"threshold": 0.8
34-
}
35-
},
36-
"post_delay": 500,
37-
"next": ["RealTimeConfirmTeleportWitte"]
38-
},
39-
"RealTimeConfirmTeleportWitte": {
40-
"recognition": {
41-
"type": "TemplateMatch",
42-
"param": {
43-
"template": "realtime_assist/teleport_btn_witte.png",
44-
"roi": [920, 600, 1280, 660],
45-
"threshold": 0.8
46-
}
47-
},
48-
"action": {
49-
"type": "Click"
50-
},
51-
"post_delay": 2000,
52-
"next": ["RealTimeSleep"]
53-
},
54-
"RealTimeTeleportPhone": {
55-
"recognition": {
56-
"type": "TemplateMatch",
57-
"param": {
58-
"template": "realtime_assist/teleport_target_phone.png",
59-
"roi": [920, 0, 1280, 140],
60-
"threshold": 0.8
61-
}
62-
},
63-
"post_delay": 500,
64-
"next": ["RealTimeConfirmTeleportPhone"]
65-
},
66-
"RealTimeConfirmTeleportPhone": {
67-
"recognition": {
68-
"type": "TemplateMatch",
69-
"param": {
70-
"template": "realtime_assist/teleport_btn_phone.png",
71-
"roi": [920, 600, 1280, 660],
72-
"threshold": 0.8
73-
}
74-
},
75-
"action": {
76-
"type": "Click"
77-
},
78-
"post_delay": 2000,
79-
"next": ["RealTimeSleep"]
3+
"desc": "实时任务主入口",
4+
"action": "Custom",
5+
"custom_action": "RealTimeTaskAction",
6+
"custom_action_param": {
7+
"nodes": [
8+
"RealTimeTeleportWitte",
9+
"RealTimeTeleportPhone",
10+
"RealTimeSkipStory",
11+
"RealTimeSkipStoryDialog",
12+
"RealTimeSleep"
13+
]
14+
},
15+
"attach": {
16+
"enable_skland_map": true
17+
}
8018
},
8119
"RealTimeSleep": {
82-
"recognition": "DirectHit",
83-
"action": "DoNothing",
84-
"post_delay": 500,
85-
"next": ["RealTimeTaskMain"]
20+
"pre_delay": 0,
21+
"post_delay": 200
22+
},
23+
"RealTimeFakeTrue": {
24+
"pre_delay": 0,
25+
"post_delay": 0
8626
}
8727
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"RealTimeSkipStory": {
3+
"desc": "跳过剧情",
4+
"recognition": {
5+
"type": "TemplateMatch",
6+
"param": {
7+
"template": [
8+
"realtime_assist/skip_story_btn.png",
9+
"realtime_assist/skip_story_btn_hover.png"
10+
],
11+
"roi": [1210, 20, 50, 50],
12+
"threshold": 0.7
13+
}
14+
},
15+
"action": {
16+
"type": "Click"
17+
},
18+
"post_delay": 0,
19+
"next": [
20+
"RealTimeSkipStoryDialog",
21+
"RealTimeFakeTrue"
22+
]
23+
},
24+
"RealTimeSkipStoryDialog": {
25+
"desc": "跳过剧情对话框",
26+
"recognition": {
27+
"type": "TemplateMatch",
28+
"param": {
29+
"template": ["realtime_assist/skip_story_dialog.png"],
30+
"roi": [420, 275, 450, 50],
31+
"threshold": 0.8
32+
}
33+
},
34+
"action": "DoNothing",
35+
"post_delay": 0,
36+
"next": ["RealTimeSkipStoryDialogCheckbox"],
37+
"on_error": ["RealTimeFakeTrue"]
38+
},
39+
"RealTimeSkipStoryDialogCheckbox": {
40+
"desc": "跳过今日剧情复选框",
41+
"recognition": {
42+
"type": "TemplateMatch",
43+
"param": {
44+
"template": "realtime_assist/skip_story_dialog_checkbox.png",
45+
"roi": [550, 350, 50, 50],
46+
"threshold": 0.8
47+
}
48+
},
49+
"action": {
50+
"type": "LongPress",
51+
"param": {
52+
"duration": 500
53+
}
54+
},
55+
"pre_delay": 500,
56+
"post_delay": 200,
57+
"next": ["RealTimeSkipStoryDialogConfirm"]
58+
},
59+
"RealTimeSkipStoryDialogConfirm": {
60+
"desc": "确认跳过剧情对话框确认按钮",
61+
"recognition": {
62+
"type": "TemplateMatch",
63+
"param": {
64+
"template": "realtime_assist/skip_story_dialog_confirm.png",
65+
"roi": [700, 410, 250, 70],
66+
"threshold": 0.8
67+
}
68+
},
69+
"action": {
70+
"type": "Click"
71+
},
72+
"post_delay": 300,
73+
"next": ["RealTimeFakeTrue"]
74+
}
75+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"RealTimeTeleportWitte": {
3+
"desc": "传送至维特海默塔",
4+
"recognition": {
5+
"type": "TemplateMatch",
6+
"param": {
7+
"template": "realtime_assist/teleport_target_witte.png",
8+
"roi": [920, 0, 1280, 140],
9+
"threshold": 0.8
10+
}
11+
},
12+
"action": "DoNothing",
13+
"post_delay": 0,
14+
"next": [
15+
"RealTimeConfirmTeleportWitte",
16+
"RealTimeFakeTrue"
17+
]
18+
},
19+
"RealTimeConfirmTeleportWitte": {
20+
"desc": "确认传送至维特海默塔",
21+
"recognition": {
22+
"type": "TemplateMatch",
23+
"param": {
24+
"template": "realtime_assist/teleport_btn_witte.png",
25+
"roi": [930, 610, 350, 60],
26+
"threshold": 0.8
27+
}
28+
},
29+
"action": {
30+
"type": "LongPress",
31+
"param": {
32+
"duration": 100
33+
}
34+
},
35+
"post_delay": 0,
36+
"next": ["RealTimeFakeTrue"]
37+
},
38+
"RealTimeTeleportPhone": {
39+
"desc": "传送至电话亭",
40+
"recognition": {
41+
"type": "TemplateMatch",
42+
"param": {
43+
"template": "realtime_assist/teleport_target_phone.png",
44+
"roi": [920, 0, 1280, 140],
45+
"threshold": 0.8
46+
}
47+
},
48+
"action": "DoNothing",
49+
"post_delay": 0,
50+
"next": [
51+
"RealTimeConfirmTeleportPhone",
52+
"RealTimeFakeTrue"
53+
]
54+
},
55+
"RealTimeConfirmTeleportPhone": {
56+
"desc": "确认传送至电话亭",
57+
"recognition": {
58+
"type": "TemplateMatch",
59+
"param": {
60+
"template": "realtime_assist/teleport_btn_phone.png",
61+
"roi": [930, 610, 350, 60],
62+
"threshold": 0.8
63+
}
64+
},
65+
"action": {
66+
"type": "LongPress",
67+
"param": {
68+
"duration": 100
69+
}
70+
},
71+
"post_delay": 0,
72+
"next": ["RealTimeFakeTrue"]
73+
}
74+
}

0 commit comments

Comments
 (0)