mirror of
https://github.com/ok-oldking/ok-wuthering-waves.git
synced 2025-04-24 08:25:16 +00:00
优化寻路刷大地图
This commit is contained in:
parent
12aa21eeb5
commit
96add8943b
Binary file not shown.
@ -671,3 +671,48 @@ msgstr ""
|
||||
|
||||
msgid "found red dot feature: Box(name='red_dot', x=221, y=577, width=31, height=32, confidence=100)"
|
||||
msgstr ""
|
||||
|
||||
msgid "16"
|
||||
msgstr ""
|
||||
|
||||
msgid "17"
|
||||
msgstr ""
|
||||
|
||||
msgid "18"
|
||||
msgstr ""
|
||||
|
||||
msgid "19"
|
||||
msgstr ""
|
||||
|
||||
msgid "Auto Enhance and Tune Echo after you add EXP Material"
|
||||
msgstr ""
|
||||
|
||||
msgid "Auto Pick Echo After Combat"
|
||||
msgstr ""
|
||||
|
||||
msgid "Farm Map with Star Path"
|
||||
msgstr ""
|
||||
|
||||
msgid "Farm world map with a marked path of stars, start in the map screen"
|
||||
msgstr ""
|
||||
|
||||
msgid "Fleurdelys"
|
||||
msgstr ""
|
||||
|
||||
msgid "Loaded 19 from 19 Stars"
|
||||
msgstr ""
|
||||
|
||||
msgid "Stars"
|
||||
msgstr ""
|
||||
|
||||
msgid "changed direction -150.3112134396332 None -> s"
|
||||
msgstr ""
|
||||
|
||||
msgid "reached star Box(name='big_map_star', x=600, y=408, width=30, height=28, confidence=93) 19.313207915827967 27"
|
||||
msgstr ""
|
||||
|
||||
msgid "reached star Box(name='big_map_star', x=640, y=447, width=30, height=28, confidence=96) 24.041630560342615 27"
|
||||
msgstr ""
|
||||
|
||||
msgid "reached star Box(name='big_map_star', x=694, y=480, width=30, height=28, confidence=97) 18.35755975068582 27"
|
||||
msgstr ""
|
||||
|
Binary file not shown.
@ -495,3 +495,14 @@ msgstr "自动强化声骸"
|
||||
msgid "Auto Enhance and Tune Echo after you add EXP Material"
|
||||
msgstr "在添加经验素材后自动强化声骸和调谐"
|
||||
|
||||
msgid "Auto Pick Echo After Combat"
|
||||
msgstr "战斗后自动拾取声骸"
|
||||
|
||||
msgid "Farm Map with Star Path"
|
||||
msgstr "标记寻路刷大地图"
|
||||
|
||||
msgid "Farm world map with a marked path of stars, start in the map screen"
|
||||
msgstr "刷用星星标记的路径, 传送到起点后, 在大地图界面开始"
|
||||
|
||||
msgid "Stars"
|
||||
msgstr "星星标记"
|
||||
|
@ -99,7 +99,7 @@ class BaseChar:
|
||||
self.click(interval=interval)
|
||||
|
||||
def click(self, *args: Any, **kwargs: Any):
|
||||
self.logger.debug(f'click {args} {kwargs}')
|
||||
# self.logger.debug(f'click {args} {kwargs}')
|
||||
self.task.click(*args, **kwargs)
|
||||
|
||||
def do_perform(self):
|
||||
@ -444,7 +444,7 @@ class BaseChar:
|
||||
# white_percent = total_area / box.width / box.height
|
||||
# if self.task.debug:
|
||||
# self.task.screenshot(f'{self}_forte_{white_percent}')
|
||||
self.logger.debug(f'is_forte_full {white_percent}')
|
||||
# self.logger.debug(f'is_forte_full {white_percent}')
|
||||
box.confidence = white_percent
|
||||
self.task.draw_boxes('forte_full', box)
|
||||
return white_percent > 0.08
|
||||
|
@ -267,7 +267,7 @@ class BaseCombatTask(CombatCheck):
|
||||
# if self.debug:
|
||||
# self.screenshot(f'{self}_{box_name}_has_cd', output_image)
|
||||
has_cd = (has_dot and 2 <= number_count <= 3)
|
||||
self.logger.debug(f'{box_name} has_cd {has_cd} {invalid_count} {number_count} {has_dot}')
|
||||
# self.logger.debug(f'{box_name} has_cd {has_cd} {invalid_count} {number_count} {has_dot}')
|
||||
return has_cd
|
||||
|
||||
def get_current_char(self, raise_exception=True) -> BaseChar:
|
||||
|
@ -19,13 +19,17 @@ class BigMap(WWOneTimeTask, BaseCombatTask):
|
||||
self.big_map_frame = None
|
||||
self.stars = None
|
||||
self.bounding_box = None
|
||||
self.sorted = False
|
||||
|
||||
|
||||
def reset(self):
|
||||
self.frame = None
|
||||
self.big_map_frame = None
|
||||
self.stars = None
|
||||
self.bounding_box = None
|
||||
self.sorted = False
|
||||
|
||||
def load_stars(self):
|
||||
self.reset()
|
||||
self.click_relative(0.94, 556 / 1080, after_sleep=1)
|
||||
self.big_map_frame = self.frame
|
||||
self.stars = self.find_feature('big_map_star', threshold=0.7, frame=self.big_map_frame, box=Box(0,0,self.big_map_frame.shape[1],self.big_map_frame.shape[0]))
|
||||
@ -89,8 +93,7 @@ class BigMap(WWOneTimeTask, BaseCombatTask):
|
||||
# self.log_debug(f'turn_east max_conf: {max_conf} {max_angle}')
|
||||
return max_angle
|
||||
|
||||
def find_direction_angle(self):
|
||||
my_box = self.find_my_location()
|
||||
def find_closest(self, my_box):
|
||||
min_distance = 100000
|
||||
min_star = None
|
||||
if len(self.stars) == 0:
|
||||
@ -100,13 +103,45 @@ class BigMap(WWOneTimeTask, BaseCombatTask):
|
||||
if distance < min_distance:
|
||||
min_distance = distance
|
||||
min_star = star
|
||||
return min_star
|
||||
|
||||
def sort_stars(self, my_box):
|
||||
if self.sorted:
|
||||
return
|
||||
remaining_boxes = self.stars[:] # Make a copy
|
||||
sorted_boxes = []
|
||||
# Start with the first box in the original list
|
||||
current_box = self.find_closest(my_box)
|
||||
remaining_boxes.remove(current_box)
|
||||
sorted_boxes.append(current_box)
|
||||
while remaining_boxes:
|
||||
min_dist = float('inf')
|
||||
best_idx = -1
|
||||
# Find the box in remaining_boxes closest to the current_box
|
||||
for i, box in enumerate(remaining_boxes):
|
||||
dist = current_box.center_distance(box)
|
||||
if dist < min_dist:
|
||||
min_dist = dist
|
||||
best_idx = i
|
||||
# Add the closest box to the sorted list and remove from remaining
|
||||
next_box = remaining_boxes.pop(best_idx)
|
||||
sorted_boxes.append(next_box)
|
||||
current_box = next_box # Update the reference point
|
||||
self.stars = sorted_boxes
|
||||
self.sorted = True
|
||||
|
||||
def find_direction_angle(self):
|
||||
if len(self.stars) == 0:
|
||||
return None, 0, 0
|
||||
my_box = self.find_my_location()
|
||||
self.sort_stars(my_box)
|
||||
min_star = self.stars[0]
|
||||
min_distance = my_box.center_distance(min_star)
|
||||
self.draw_boxes('star', min_star, color='green')
|
||||
# if self.debug:
|
||||
# self.screenshot('parse_read_big_map', frame=self.big_map_frame, show_box=True)
|
||||
direction_angle = calculate_angle_clockwise(my_box, min_star)
|
||||
my_angle = self.get_my_angle()
|
||||
to_turn = self.get_angle_between(my_angle, direction_angle)
|
||||
self.log_debug(f'direction_angle {to_turn} {my_angle} {direction_angle} min_distance {min_distance} min_star {min_star} ')
|
||||
# self.log_debug(f'direction_angle {to_turn} {my_angle} {direction_angle} min_distance {min_distance} min_star {min_star} ')
|
||||
return min_star, min_distance, to_turn
|
||||
|
||||
def remove_star(self, star):
|
||||
@ -202,6 +237,7 @@ class FarmMapTask(BigMap):
|
||||
current_direction = None
|
||||
self.center_camera()
|
||||
current_adjust = None
|
||||
too_far_count = 0
|
||||
while True:
|
||||
self.sleep(0.01)
|
||||
self.middle_click(interval=1, after_sleep=0.2)
|
||||
@ -211,10 +247,12 @@ class FarmMapTask(BigMap):
|
||||
self.send_key_up(current_direction)
|
||||
current_direction = None
|
||||
self.combat_once()
|
||||
while self.yolo_find_echo(use_color=False, walk=False)[1]:
|
||||
self.incr_drop(True)
|
||||
while True:
|
||||
dropped, has_more = self.yolo_find_echo(use_color=False, walk=False)[1]
|
||||
self.incr_drop(dropped)
|
||||
self.sleep(0.5)
|
||||
continue
|
||||
if not dropped or not has_more:
|
||||
break
|
||||
star, distance, angle = self.find_direction_angle()
|
||||
# self.draw_boxes('next_star', star, color='green')
|
||||
if not star:
|
||||
@ -224,12 +262,16 @@ class FarmMapTask(BigMap):
|
||||
self.log_info(f'reached star {star} {distance} {self.star_move_distance_threshold}')
|
||||
self.remove_star(star)
|
||||
continue
|
||||
elif distance >= self.height_of_screen(0.35):
|
||||
self.log_error('too far from next star, stop farming', notify=True)
|
||||
elif distance >= self.height_of_screen(0.4):
|
||||
too_far_count += 1
|
||||
if self.debug:
|
||||
self.screenshot('too_far',frame=self.big_map_frame,show_box=True)
|
||||
self.screenshot('far',frame=self.get_box_by_name('box_minimap').crop(self.frame))
|
||||
break
|
||||
self.screenshot('far',frame=self.get_box_by_name('box_minimap').crop_frame(self.frame))
|
||||
if too_far_count >= 3:
|
||||
self.log_error('too far from next star, stop farming', notify=True)
|
||||
break
|
||||
else:
|
||||
continue
|
||||
elif distance == self.last_distance:
|
||||
logger.info(f'might be stuck, try {[self.stuck_index % 3]}')
|
||||
self.send_key(self.stuck_keys[self.stuck_index % 3][0], down_time=self.stuck_keys[self.stuck_index % 3][1], after_sleep=0.5)
|
||||
|
Loading…
x
Reference in New Issue
Block a user