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

改回ocr判断 声骸拾取

This commit is contained in:
firedcto@gmail.com 2024-07-24 21:11:55 +08:00
parent 9a8fa4edfd
commit ac26c60f74
6 changed files with 22 additions and 12 deletions

View File

@ -29,13 +29,14 @@ class AutoPickTask(TriggerTask, BaseWWTask, FindFeature):
name='search_dialog')
dialog_3_dots = self.find_feature('dialog_3_dots', box=dialog_search,
threshold=0.8)
if dialog_3_dots and self.absorb_echo_feature:
search_absorb = dialog_3_dots[0].copy(x_offset=f.width * 2, width_offset=f.width * 10,
if dialog_3_dots and self.absorb_echo_text:
search_absorb = dialog_3_dots[0].copy(x_offset=f.width * 2, width_offset=f.width * 6,
height_offset=1.4 * f.height,
y_offset=-0.7 * f.height)
absorb = self.find_one(self.absorb_echo_feature, box=search_absorb, canny_lower=75, canny_higher=150,
threshold=0.65)
logger.debug(f'auto_pick try to search for absorb {self.absorb_echo_feature} {absorb}')
# absorb = self.find_one(self.absorb_echo_feature, box=search_absorb, canny_lower=75, canny_higher=150,
# threshold=0.65)
absorb = self.ocr(box=search_absorb, match=self.absorb_echo_text, log=True, target_height=480)
logger.debug(f'auto_pick try to search for absorb {self.absorb_echo_text} {absorb}')
if absorb:
return True
if not dialog_3_dots:

View File

@ -86,7 +86,7 @@ class BaseCombatTask(BaseWWTask, FindFeature, OCR, CombatCheck):
if total_index > 2 and (total_index + 1) % 2 == 0:
duration += step
picked = self.send_key_and_wait_f(direction, False, time_out=duration, running=True,
target_text=self.absorb_echo_feature)
target_text=self.absorb_echo_text)
if picked:
self.mouse_up(key="right")
return True

View File

@ -1,3 +1,5 @@
import re
from ok.feature.FindFeature import FindFeature
from ok.logging.Logger import get_logger
from ok.ocr.OCR import OCR
@ -11,6 +13,13 @@ class BaseWWTask(BaseTask, FindFeature, OCR):
def __init__(self):
super().__init__()
@property
def absorb_echo_text(self):
if self.game_lang == 'zh_CN' or self.game_lang == 'en_US':
return re.compile(r'(吸收|Absorb)')
else:
return None
@property
def absorb_echo_feature(self):
return self.get_feature_by_lang('absorb')
@ -35,9 +44,9 @@ class BaseWWTask(BaseTask, FindFeature, OCR):
def find_f_with_text(self, target_text=None):
f = self.find_one('pick_up_f', box=self.f_search_box, threshold=0.8)
if f and target_text:
search_text_box = f.copy(x_offset=f.width * 5, width_offset=f.width * 12, height_offset=1 * f.height,
y_offset=-0.5 * f.height)
text = self.find_one(target_text, box=search_text_box, canny_lower=75, canny_higher=150, threshold=0.65)
search_text_box = f.copy(x_offset=f.width * 5, width_offset=f.width * 7, height_offset=1.5 * f.height,
y_offset=-0.8 * f.height, name='search_text_box')
text = self.ocr(box=search_text_box, match=target_text)
logger.debug(f'found f with text {text}, target_text {target_text}')
if not text:
return None

View File

@ -48,7 +48,7 @@ class FarmEchoTask(BaseCombatTask):
self.combat_once()
logger.info(f'farm echo move {self.config.get("Entrance Direction")} walk_until_f to find echo')
if self.config.get('Entrance Direction') == 'Forward':
dropped = self.walk_until_f(time_out=4, target_text=self.absorb_echo_feature,
dropped = self.walk_until_f(time_out=4, target_text=self.absorb_echo_text,
raise_if_not_found=False, backward_time=1) # find and pick echo
logger.debug(f'farm echo found echo move forward walk_until_f to find echo')
else:

View File

@ -176,7 +176,7 @@ class FarmWorldBossTask(BaseCombatTask):
logger.info(f'sleep for the Boss model to disappear')
self.sleep(5)
logger.info(f'farm echo move forward walk_until_f to find echo')
if self.walk_until_f(time_out=6, backward_time=1, target_text=self.absorb_echo_feature,
if self.walk_until_f(time_out=6, backward_time=1, target_text=self.absorb_echo_text,
raise_if_not_found=False): # find and pick echo
logger.debug(f'farm echo found echo move forward walk_until_f to find echo')
self.incr_drop(True)

View File

@ -23,7 +23,7 @@ class AutoDialogTask(TriggerTask, FindFeature, OCR):
pass
def trigger(self):
skip = self.ocr(0.03, 0.03, 0.11, 0.10, use_grayscale=True, match=re.compile('SKIP'), threshold=0.9)
skip = self.ocr(0.03, 0.03, 0.11, 0.10, target_height=480, match=re.compile('SKIP'), threshold=0.9)
if skip:
logger.info('Click Skip Dialog')
self.click_box(skip, move_back=True)