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

优化今武门

修复今汐有时候不喷
This commit is contained in:
firedcto@gmail.com 2024-08-19 01:30:33 +08:00
parent c45fdc7da7
commit 5b003214d3
3 changed files with 63 additions and 28 deletions

View File

@ -11,7 +11,7 @@ class Jinhsi(BaseChar):
self.has_free_intro = False
self.incarnation = False
self.incarnation_cd = False
self.last_fly_e_time = time.time()
self.last_fly_e_time = 0
def do_perform(self):
if self.incarnation:
@ -59,18 +59,35 @@ class Jinhsi(BaseChar):
self.incarnation = False
self.logger.info(f'handle_incarnation click_resonance start')
start = time.time()
animation_start = 0
last_op = 'resonance'
self.task.in_liberation = False
while True:
self.task.click(interval=0.1)
current_res = self.current_resonance()
if current_res > 0 and not self.has_cd('resonance'):
self.logger.info(f'handle_incarnation current_res: {current_res} breaking')
if self.task.debug:
self.task.screenshot(f'handle_incarnation e available')
# self.send_resonance_key()
if time.time() - start > 5:
self.logger.info(f'handle incarnation too long')
break
if time.time() - animation_start < 1.5:
continue
self.task.next_frame()
if self.task.in_team()[0]:
if last_op == 'resonance':
self.task.click(interval=0.1)
last_op = 'click'
else:
self.send_resonance_key()
last_op = 'resonance'
if self.task.in_liberation:
self.logger.info(f'Jinhsi handle_incarnation done')
break
else:
if animation_start == 0:
self.logger.info(f'Jinhsi handle_incarnation start animation')
animation_start = time.time()
self.task.in_liberation = True
self.check_combat()
self.click_resonance(has_animation=True, animation_min_duration=1)
self.task.in_liberation = False
if not self.click_echo():
self.task.click()
# if self.task.debug:
@ -79,17 +96,34 @@ class Jinhsi(BaseChar):
def handle_intro(self):
# self.task.screenshot(f'handle_intro start')
self.logger.info(f'handle_intro start')
self.logger.info(f'handle_intro start')
start = time.time()
while not self.has_cd('resonance'):
self.send_resonance_key(interval=0.1)
self.check_combat()
if time.time() - start < 1.2:
self.logger.info(f'handle_intro fly e in_cd {time.time() - start}')
if self.time_elapsed_accounting_for_freeze(self.last_fly_e_time) < 10.5:
self.incarnation_cd = True
if not self.click_echo():
self.task.click()
self.click_echo()
self.logger.info(f'handle_intro in cd switch {start - self.last_fly_e_time}')
return
while True:
self.task.next_frame()
self.check_combat()
if not self.has_cd('resonance'):
self.send_resonance_key(interval=0.1)
if time.time() - self.last_fly_e_time > 7:
self.last_fly_e_time = time.time()
continue
if time.time() - start < 4:
self.task.click(interval=0.1)
continue
if self.task.debug:
self.task.screenshot(f'handle_intro e end {time.time() - start}')
break
# if time.time() - start < 2:
# self.logger.info(f'handle_intro fly e in_cd {time.time() - start}')
# self.incarnation_cd = True
# if not self.click_echo():
# self.task.click()
# return
self.last_fly_e_time = start
if self.click_liberation(send_click=True):
self.continues_normal_attack(0.3)

View File

@ -151,7 +151,7 @@ class CombatCheck:
def in_combat(self, rechecked=False):
if self.in_liberation or self.recent_liberation():
logger.debug('in liberation return True')
# logger.debug('in liberation return True')
return True
if self._in_combat:
now = time.time()

View File

@ -130,7 +130,8 @@ class BaseCombatTask(BaseWWTask, FindFeature, OCR, CombatCheck):
if time.time() - current_char.last_perform < 0.1:
current_char.continues_normal_attack(0.2)
logger.warning(f"can't find next char to switch to, performing too fast add a normal attack")
return current_char.switch_next_char()
return self.switch_next_char(current_char, post_action=post_action, free_intro=free_intro,
target_low_con=target_low_con)
switch_to.has_intro = has_intro
logger.info(f'switch_next_char {current_char} -> {switch_to} has_intro {has_intro}')
last_click = 0
@ -142,18 +143,17 @@ class BaseCombatTask(BaseWWTask, FindFeature, OCR, CombatCheck):
last_click = now
in_team, current_index, size = self.in_team()
if not in_team:
logger.info(f'not in team while switching chars_{current_char}_to_{switch_to} {now - start}')
if self.debug:
self.screenshot(f'not in team while switching chars_{current_char}_to_{switch_to} {now - start}')
confirm = self.wait_feature('revive_confirm_hcenter_vcenter', threshold=0.8, time_out=3)
confirm = self.wait_feature('revive_confirm_hcenter_vcenter', threshold=0.8, time_out=2)
if confirm:
self.log_info(f'char dead')
self.raise_not_in_combat(f'char dead', exception_type=CharDeadException)
# else:
# self.raise_not_in_combat(
# f'not in team while switching chars_{current_char}_to_{switch_to}')
if now - start > 10:
self.raise_not_in_combat(
f'switch too long failed chars_{current_char}_to_{switch_to}, {now - start}')
if now - start > 5:
self.raise_not_in_combat(
f'switch too long failed chars_{current_char}_to_{switch_to}, {now - start}')
continue
if current_index != switch_to.index:
has_intro = free_intro if free_intro else current_char.is_con_full()
switch_to.has_intro = has_intro
@ -184,6 +184,7 @@ class BaseCombatTask(BaseWWTask, FindFeature, OCR, CombatCheck):
has_dot = False
number_count = 0
invalid_count = 0
# dot = None
# output_image = cropped.copy()
for i in range(1, num_labels):
# Check if the connected co mponent touches the border
@ -195,7 +196,7 @@ class BaseCombatTask(BaseWWTask, FindFeature, OCR, CombatCheck):
# self.logger.debug(f"{box_name} Area of connected component {i}: {area} pixels {width}x{height} ")
if 16 / 3840 / 2160 <= area / self.frame.shape[0] / self.frame.shape[
1] <= 90 / 3840 / 2160 and abs(width - height) / (
width + height) < 0.3:
width + height) < 0.3 and top / cropped.shape[0] > 0.6:
# if top < (
# box.height / 2) and left > box.width * 0.2 and left + width < box.width * 0.8:
has_dot = True
@ -205,7 +206,7 @@ class BaseCombatTask(BaseWWTask, FindFeature, OCR, CombatCheck):
elif 25 / 2160 <= height / self.screen_height <= 45 / 2160 and 5 / 2160 <= width / self.screen_height <= 35 / 2160:
number_count += 1
else:
self.logger.debug(f"{box_name} has invalid return False")
# self.logger.debug(f"{box_name} has invalid return False")
invalid_count += 1
# return False