33import cv2
44import re
55
6- from ok import Logger , TaskDisabledException , Box , find_color_rectangles
6+ from ok import Logger , TaskDisabledException , Box , find_color_rectangles , color_range_to_bound
77from src .tasks .DNAOneTimeTask import DNAOneTimeTask
88from src .tasks .CommissionsTask import CommissionsTask , QuickMoveTask , Mission
99
@@ -43,6 +43,7 @@ def do_run(self):
4343 self .init_param ()
4444 self .load_char ()
4545 _skill_time = 0
46+ _excavator_count = 0
4647 while True :
4748 if self .in_team ():
4849 self .progressing = self .find_target_health_bar ()
@@ -51,25 +52,32 @@ def do_run(self):
5152 _skill_time = self .use_skill (_skill_time )
5253 else :
5354 if _skill_time > 0 :
54- self . soundBeep ( 1 )
55+ _excavator_count += 1
5556 _skill_time = 0
56- self .sleep (1 )
57+ if _excavator_count < 3 :
58+ self .soundBeep (1 )
5759 self .quick_move_task .run ()
5860
5961 _status = self .handle_mission_interface (stop_func = self .stop_func )
6062 if _status == Mission .START :
6163 self .wait_until (self .in_team , time_out = 30 )
62- self .log_info_notify ("任务完成 " )
64+ self .log_info_notify ("任务开始 " )
6365 self .soundBeep ()
6466 self .init_param ()
67+ _excavator_count = 0
68+ _skill_time = 0
6569 elif _status == Mission .STOP :
6670 self .quit_mission ()
6771 self .init_param ()
6872 self .log_info ("任务中止" )
6973 elif _status == Mission .CONTINUE :
7074 self .wait_until (self .in_team , time_out = 30 )
75+ self .sleep (2 )
7176 self .log_info ("任务继续" )
72- self .soundBeep ()
77+ _excavator_count = 0
78+ _skill_time = 0
79+ if not self .find_target_health_bar ():
80+ self .soundBeep (1 )
7381
7482 self .sleep (0.2 )
7583
@@ -91,9 +99,30 @@ def find_target_health_bar(self, threshold: float = 0.6):
9199 self .draw_boxes (boxes = health_bar )
92100 return health_bar
93101
102+ def find_track_point (self , threshold : float = 0 , box : Box | None = None , template = None ) -> Box | None :
103+ if box is None :
104+ box = self .box_of_screen_scaled (2560 , 1440 , 454 , 265 , 2110 , 1094 , name = "find_track_point" , hcenter = True )
105+ if template is None :
106+ template = filter_track_point_color (self .get_feature_by_name ("track_point" ).mat )
107+ return self .find_one ("track_point" , threshold = threshold , box = box , template = template )
108+
109+
110+ def filter_track_point_color (img ):
111+ lower_bound , upper_bound = color_range_to_bound (track_point_color )
112+ mask = cv2 .inRange (img , lower_bound , upper_bound )
113+ img_modified = img .copy ()
114+ img_modified [mask == 0 ] = 0
115+ return img_modified
116+
94117
95118green_health_bar_color = {
96119 "r" : (135 , 150 ), # Red range
97120 "g" : (200 , 215 ), # Green range
98121 "b" : (150 , 165 ), # Blue range
99122}
123+
124+ track_point_color = {
125+ "r" : (121 , 255 ), # Red range
126+ "g" : (116 , 255 ), # Green range
127+ "b" : (34 , 211 ), # Blue range
128+ }
0 commit comments