0
0
mirror of https://github.com/ok-oldking/ok-wuthering-waves.git synced 2025-06-07 09:25:34 +00:00

optimze auto combat

This commit is contained in:
firedcto@gmail.com 2024-07-06 09:59:56 +08:00
parent 9f75f15af6
commit 77167e9eab
3 changed files with 51 additions and 21 deletions

View File

@ -258,7 +258,6 @@ class BaseChar:
self.logger.debug(f'click_liberation liberation_available click')
now = time.time()
self.task.in_liberation = True
clicked = True
if now - last_click > 0.1:
self.task.send_key(self.get_liberation_key())
self.liberation_available_mark = False
@ -267,6 +266,7 @@ class BaseChar:
self.task.raise_not_in_combat('too long clicking a liberation')
self.task.next_frame()
while not self.task.in_team()[0]:
clicked = True
self.task.in_liberation = True
if send_click:
self.task.click(interval=0.1)
@ -543,9 +543,9 @@ forte_white_color = {
}
dot_color = {
'r': (245, 255), # Red range
'g': (245, 255), # Green range
'b': (245, 255) # Blue range
'r': (235, 255), # Red range
'g': (235, 255), # Green range
'b': (235, 255) # Blue range
}
con_colors = [

View File

@ -57,7 +57,13 @@ class Jinhsi(BaseChar):
self.logger.info(f'handle_incarnation click_resonance start')
start = time.time()
liberated = False
while self.has_cd('resonance'):
while True:
current_res = self.current_resonance()
if current_res > 0 and not self.has_cd('resonance'):
self.logger.debug(f'handle_incarnation current_res: {current_res} breaking')
if self.task.debug:
self.task.screenshot(f'handle_incarnation e available')
break
self.task.click(interval=0.1)
# if time.time() - start > 1.8 and not liberated:
# liberated = True
@ -71,7 +77,8 @@ class Jinhsi(BaseChar):
self.click_resonance(has_animation=True, send_click=True)
if not self.click_echo():
self.task.click()
# self.task.screenshot(f'handle_incarnation click_resonance end {time.time() - start}')
if self.task.debug:
self.task.screenshot(f'handle_incarnation click_resonance end {time.time() - start}')
self.logger.info(f'handle_incarnation click_resonance end {time.time() - start}')
def handle_intro(self):

View File

@ -33,21 +33,30 @@ class CombatCheck:
return False
def check_count_down(self):
count_down_area = self.box_of_screen(1820 / 3840, 266 / 2160, 2100 / 3840,
340 / 2160, name="check_count_down")
count_down = self.calculate_color_percentage(text_white_color,
self.box_of_screen(1820 / 3840, 266 / 2160, 2088 / 3840,
330 / 2160, name="check_count_down"))
count_down_area)
if self.has_count_down:
if count_down < 0.03:
# self.screenshot(f'out of combat because of count_down disappeared {count_down:.2f}%')
logger.info(f'out of combat because of count_down disappeared {count_down:.2f}%')
numbers = self.ocr(box=count_down_area, match=count_down_re)
if self.debug:
self.screenshot(f'count_down disappeared {count_down:.2f}%')
logger.info(f'count_down disappeared {numbers} {count_down:.2f}%')
if not numbers:
self.has_count_down = False
return False
else:
return True
else:
self.has_count_down = count_down > 0.03
logger.info(f'set count_down to {self.has_count_down} {count_down:.2f}%')
return True
else:
if count_down > 0.03:
numbers = self.ocr(box=count_down_area, match=count_down_re)
if numbers:
self.has_count_down = True
logger.info(f'set count_down to {self.has_count_down} {numbers} {count_down:.2f}%')
return self.has_count_down
def check_boss(self):
@ -61,7 +70,8 @@ class CombatCheck:
self.screenshot_boss_lv(current, f'boss lv not detected by edge {max_val}')
logger.debug(f'boss lv not detected by edge')
if not self.find_boss_lv_text(): # double check by text
if not (self.in_team()[0] and self.check_health_bar()) and not self.check_count_down():
if not self.in_team()[
0] and not self.check_health_bar() and not self.check_count_down() and not self.find_target_enemy():
if self.debug:
self.screenshot_boss_lv(current, 'out_of combat boss_health disappeared')
logger.info(f'out of combat because of boss_health disappeared, res:{max_val}')
@ -114,6 +124,7 @@ class CombatCheck:
if not self.target_enemy():
logger.error('target_enemy failed, break out of combat')
return self.reset_to_false()
return True
else:
logger.debug(
'check in combat pass')
@ -122,16 +133,25 @@ class CombatCheck:
else:
return True
else:
in_combat = self.in_team()[0] and self.check_health_bar() and (
(
self.boss_health_box is not None or self.boss_lv_edge is not None or self.has_count_down) or self.target_enemy())
in_combat = self.in_team()[0] and self.check_health_bar()
if in_combat:
in_combat = self.boss_health_box is not None or self.boss_lv_edge is not None or self.has_count_down
if in_combat:
self.target_enemy(wait=False)
else:
in_combat = self.target_enemy()
if in_combat:
logger.info(
f'enter combat boss_lv_edge:{self.boss_lv_edge is not None} boss_health_box:{self.boss_health_box} has_count_down:{self.has_count_down}')
self._in_combat = True
return True
def target_enemy(self):
def target_enemy(self, wait=True):
if not wait:
self.middle_click()
else:
if self.find_target_enemy():
return True
self.middle_click()
return self.wait_until(self.find_target_enemy, time_out=2)
@ -191,6 +211,9 @@ class CombatCheck:
return image, area
count_down_re = re.compile(r'\d\d')
def process_target_enemy_area(frame):
frame[frame != 255] = 0
return frame