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:
parent
935608591c
commit
c45fdc7da7
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
updates/
|
||||
working/
|
||||
tesseract
|
||||
models
|
||||
fonts
|
||||
|
@ -4,4 +4,17 @@ from src.char.BaseChar import BaseChar
|
||||
class Baizhi(BaseChar):
|
||||
|
||||
def count_base_priority(self):
|
||||
return - 1
|
||||
return -1
|
||||
|
||||
def do_perform(self):
|
||||
if self.has_intro:
|
||||
self.logger.debug('has_intro wait click 1.2 sec')
|
||||
self.continues_normal_attack(1.2, click_resonance_if_ready_and_return=True)
|
||||
self.click_liberation(con_less_than=1)
|
||||
self.click_resonance()
|
||||
self.click_echo()
|
||||
if not self.is_con_full():
|
||||
self.logger.debug('continues_normal_attack')
|
||||
self.continues_normal_attack(1.1 - self.time_elapsed_accounting_for_freeze(self.last_perform),
|
||||
until_con_full=True)
|
||||
self.switch_next_char()
|
||||
|
@ -5,7 +5,7 @@ from typing import Any
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
from ok.color.Color import get_connected_area_by_color, color_range_to_bound
|
||||
from ok.color.Color import color_range_to_bound
|
||||
from ok.config.Config import Config
|
||||
from ok.logging.Logger import get_logger
|
||||
from src import text_white_color
|
||||
@ -97,46 +97,7 @@ class BaseChar:
|
||||
self.switch_next_char()
|
||||
|
||||
def has_cd(self, box_name):
|
||||
box = self.task.get_box_by_name(f'box_{box_name}')
|
||||
cropped = box.crop_frame(self.task.frame)
|
||||
num_labels, stats, labels = get_connected_area_by_color(cropped, dot_color, connectivity=8, gray_range=22)
|
||||
big_area_count = 0
|
||||
has_dot = False
|
||||
number_count = 0
|
||||
invalid_count = 0
|
||||
# output_image = cropped.copy()
|
||||
for i in range(1, num_labels):
|
||||
# Check if the connected co mponent touches the border
|
||||
left, top, width, height, area = stats[i]
|
||||
if area / self.task.frame.shape[0] / self.task.frame.shape[
|
||||
1] > 20 / 3840 / 2160:
|
||||
big_area_count += 1
|
||||
if left > 0 and top > 0 and left + width < box.width and top + height < box.height:
|
||||
# self.logger.debug(f"{box_name} Area of connected component {i}: {area} pixels {width}x{height} ")
|
||||
if 16 / 3840 / 2160 <= area / self.task.frame.shape[0] / self.task.frame.shape[
|
||||
1] <= 90 / 3840 / 2160 and abs(width - height) / (
|
||||
width + height) < 0.3:
|
||||
# if top < (
|
||||
# box.height / 2) and left > box.width * 0.2 and left + width < box.width * 0.8:
|
||||
has_dot = True
|
||||
# self.logger.debug(f"{box_name} multiple dots return False")
|
||||
# return False
|
||||
# dot = stats[i]
|
||||
elif 25 / 2160 <= height / self.task.screen_height <= 45 / 2160 and 5 / 2160 <= width / self.task.screen_height <= 35 / 2160:
|
||||
number_count += 1
|
||||
else:
|
||||
# self.logger.debug(f"{box_name} has invalid return False")
|
||||
invalid_count += 1
|
||||
return False
|
||||
|
||||
# Draw the connected component with a random color
|
||||
# mask = labels == i
|
||||
# output_image[mask] = np.random.randint(0, 255, size=3)
|
||||
# if self.task.debug:
|
||||
# self.task.screenshot(f'{self}_{box_name}_has_cd', output_image)
|
||||
has_cd = invalid_count == 0 and (has_dot and 2 <= number_count <= 3)
|
||||
# self.logger.debug(f'{box_name} has_cd {has_cd} {invalid_count} {number_count} {has_dot}')
|
||||
return has_cd
|
||||
return self.task.has_cd(box_name)
|
||||
|
||||
def is_available(self, percent, box_name):
|
||||
return percent == 0 or not self.has_cd(box_name)
|
||||
|
@ -44,7 +44,7 @@ class Jinhsi(BaseChar):
|
||||
return super().do_get_switch_priority(current_char, has_intro)
|
||||
|
||||
def count_base_priority(self):
|
||||
return 0
|
||||
return -3
|
||||
|
||||
def count_resonance_priority(self):
|
||||
return 0
|
||||
@ -60,6 +60,7 @@ class Jinhsi(BaseChar):
|
||||
self.logger.info(f'handle_incarnation click_resonance start')
|
||||
start = time.time()
|
||||
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')
|
||||
@ -67,7 +68,6 @@ class Jinhsi(BaseChar):
|
||||
self.task.screenshot(f'handle_incarnation e available')
|
||||
# self.send_resonance_key()
|
||||
break
|
||||
self.task.click(interval=0.1)
|
||||
self.check_combat()
|
||||
|
||||
self.click_resonance(has_animation=True, animation_min_duration=1)
|
||||
|
@ -10,7 +10,7 @@ class Yuanwu(BaseChar):
|
||||
return 0
|
||||
|
||||
def count_base_priority(self):
|
||||
return -1
|
||||
return -2
|
||||
|
||||
def do_perform(self):
|
||||
self.click_liberation(con_less_than=1)
|
||||
@ -19,4 +19,6 @@ class Yuanwu(BaseChar):
|
||||
if self.is_forte_full():
|
||||
self.send_resonance_key(down_time=0.7, post_sleep=0.2)
|
||||
self.click_echo()
|
||||
self.continues_normal_attack(1.1 - self.time_elapsed_accounting_for_freeze(self.last_perform),
|
||||
until_con_full=True)
|
||||
self.switch_next_char()
|
||||
|
@ -4,13 +4,14 @@ import time
|
||||
|
||||
import win32api
|
||||
|
||||
from ok.color.Color import get_connected_area_by_color
|
||||
from ok.config.ConfigOption import ConfigOption
|
||||
from ok.feature.FindFeature import FindFeature
|
||||
from ok.logging.Logger import get_logger
|
||||
from ok.ocr.OCR import OCR
|
||||
from ok.util.list import safe_get
|
||||
from src.char import BaseChar
|
||||
from src.char.BaseChar import Priority
|
||||
from src.char.BaseChar import Priority, dot_color
|
||||
from src.char.CharFactory import get_char_by_pos
|
||||
from src.combat.CombatCheck import CombatCheck
|
||||
from src.task.BaseWWTask import BaseWWTask
|
||||
@ -129,7 +130,7 @@ 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.perform()
|
||||
return current_char.switch_next_char()
|
||||
switch_to.has_intro = has_intro
|
||||
logger.info(f'switch_next_char {current_char} -> {switch_to} has_intro {has_intro}')
|
||||
last_click = 0
|
||||
@ -172,6 +173,52 @@ class BaseCombatTask(BaseWWTask, FindFeature, OCR, CombatCheck):
|
||||
post_action()
|
||||
logger.info(f'switch_next_char end {(current_char.last_switch_time - start):.3f}s')
|
||||
|
||||
def has_resonance_cd(self):
|
||||
return self.has_cd('resonance')
|
||||
|
||||
def has_cd(self, box_name):
|
||||
box = self.get_box_by_name(f'box_{box_name}')
|
||||
cropped = box.crop_frame(self.frame)
|
||||
num_labels, stats, labels = get_connected_area_by_color(cropped, dot_color, connectivity=8, gray_range=22)
|
||||
big_area_count = 0
|
||||
has_dot = False
|
||||
number_count = 0
|
||||
invalid_count = 0
|
||||
# output_image = cropped.copy()
|
||||
for i in range(1, num_labels):
|
||||
# Check if the connected co mponent touches the border
|
||||
left, top, width, height, area = stats[i]
|
||||
if area / self.frame.shape[0] / self.frame.shape[
|
||||
1] > 20 / 3840 / 2160:
|
||||
big_area_count += 1
|
||||
if left > 0 and top > 0 and left + width < box.width and top + height < box.height:
|
||||
# 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:
|
||||
# if top < (
|
||||
# box.height / 2) and left > box.width * 0.2 and left + width < box.width * 0.8:
|
||||
has_dot = True
|
||||
# self.logger.debug(f"{box_name} multiple dots return False")
|
||||
# return False
|
||||
# dot = stats[i]
|
||||
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")
|
||||
invalid_count += 1
|
||||
# return False
|
||||
|
||||
# Draw the connected component with a random color
|
||||
# mask = labels == i
|
||||
# import numpy as np
|
||||
# output_image[mask] = np.random.randint(0, 255, size=3)
|
||||
# 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}')
|
||||
return has_cd
|
||||
|
||||
def get_current_char(self) -> BaseChar:
|
||||
for char in self.chars:
|
||||
if char.is_current_char:
|
||||
|
Loading…
x
Reference in New Issue
Block a user