0
0
mirror of https://github.com/ok-oldking/ok-wuthering-waves.git synced 2025-06-06 17:05:54 +00:00

optimize combat liberation check

This commit is contained in:
firedcto@gmail.com 2024-07-12 17:46:49 +08:00
parent 488d1c761c
commit 8c2225ff44
3 changed files with 25 additions and 26 deletions

View File

@ -262,7 +262,7 @@ class BaseChar:
self.task.raise_not_in_combat('too long clicking a liberation')
self.task.next_frame()
if clicked:
if self.task.wait_until(lambda: not self.task.in_team()[0], time_out=1):
if self.task.wait_until(lambda: not self.task.in_team()[0], time_out=0.6):
self.logger.debug(f'not in_team successfully casted liberation')
else:
self.task.in_liberation = False
@ -277,7 +277,6 @@ class BaseChar:
self.task.in_liberation = False
if clicked:
liberation_time = f'{(time.time() - start):.2f}'
self.task.info[f'{self} liberation time'] = liberation_time
self.logger.info(f'click_liberation end {liberation_time}')
return clicked
@ -424,17 +423,17 @@ class BaseChar:
return False
else:
return self.is_available(snap, 'liberation')
else:
mark_to_check = char_lib_check_marks[self.index]
box = self.task.get_box_by_name(mark_to_check)
box = box.copy(x_offset=-box.width, y_offset=-box.height, width_offset=box.width * 2,
height_offset=box.height * 2)
for match in char_lib_check_marks:
mark = self.task.find_one(match, box=box, canny_lower=10, canny_higher=80, threshold=0.6)
if mark is not None:
self.logger.debug(f'{self.__repr__()} liberation ready by checking mark {mark}')
self.liberation_available_mark = True
return True
# else:
# mark_to_check = char_lib_check_marks[self.index]
# box = self.task.get_box_by_name(mark_to_check)
# box = box.copy(x_offset=-box.width, y_offset=-box.height, width_offset=box.width * 2,
# height_offset=box.height * 2)
# for match in char_lib_check_marks:
# mark = self.task.find_one(match, box=box, canny_lower=10, canny_higher=80, threshold=0.8)
# if mark is not None:
# self.logger.debug(f'{self.__repr__()} liberation ready by checking mark {mark}')
# self.liberation_available_mark = True
# return True
def __str__(self):
return self.__repr__()

View File

@ -60,20 +60,15 @@ class BaseCombatTask(BaseTask, FindFeature, OCR, CombatCheck):
def run_in_circle_to_find_echo(self, circle_count=3):
directions = ['w', 'a', 's', 'd']
step = 1
duration = 1
step = 1.5
duration = 0.5
total_index = 0
for count in range(circle_count):
logger.debug(f'running first circle_count{circle_count} circle {total_index} duration:{duration}')
for direction in directions:
if total_index > 2 and (total_index + 1) % 2 == 0:
duration += step
# self.send_key_down(direction)
# self.sleep(0.02)
# self.mouse_down(key="right")
picked = self.send_key_and_wait_f(direction, False, time_out=duration, running=True)
# self.mouse_up(key="right")
# self.send_key_up(direction)
if picked:
self.mouse_up(key="right")
return True
@ -219,12 +214,15 @@ class BaseCombatTask(BaseTask, FindFeature, OCR, CombatCheck):
else:
logger.warning(f"can't find the f to enter")
return False
remaining = time.time() - start
self.send_key('f')
if self.handle_claim_button():
self.sleep(0.5)
self.send_key_down(direction)
if running:
self.mouse_down(key='right')
self.sleep(time.time() - start)
self.sleep(remaining + 0.2)
if running:
self.mouse_up(key='right')
self.send_key_up(direction)

View File

@ -56,7 +56,8 @@ class FarmEchoTask(BaseCombatTask):
self.wait_in_team_and_world(time_out=20)
self.sleep(1)
self.walk_until_f(time_out=10,
direction='w' if self.config.get('Entrance Direction') == 'Forward' else 's')
direction='w' if self.config.get('Entrance Direction') == 'Forward' else 's',
raise_if_not_found=True)
logger.info(f'enter success')
stam = self.wait_ocr(0.75, 0.02, 0.85, 0.09, match=re.compile('240'), raise_if_not_found=True)
logger.info(f'found stam {stam}')
@ -103,16 +104,17 @@ class FarmEchoTask(BaseCombatTask):
# continue
logger.info(f'choose level {start}')
self.click_relative(x, y + (start - 1) * distance)
# self.sleep(1)
self.sleep(0.5)
# self.click_relative(x, y + (start - 1) * distance)
self.wait_click_feature('gray_button_challenge', raise_if_not_found=True, use_gray_scale=True)
self.wait_click_feature('gray_button_challenge', raise_if_not_found=True, use_gray_scale=True,
click_after_delay=0.5)
# self.sleep(1)
# confirm_button = self.find_one('gray_confirm_exit_button', use_gray_scale=True, threshold=0.7)
self.wait_click_feature('gray_confirm_exit_button', relative_x=-1, raise_if_not_found=False,
use_gray_scale=True, time_out=3, click_after_delay=0.5)
use_gray_scale=True, time_out=3, click_after_delay=0.5, threshold=0.8)
self.wait_click_feature('gray_start_battle', relative_x=-1, raise_if_not_found=True,
use_gray_scale=True, click_after_delay=0.5)
use_gray_scale=True, click_after_delay=0.5, threshold=0.8)
def find_echo_drop(self):
# self.click_relative(0.5, 0.5)