diff --git a/src/task/AutoPickTask.py b/src/task/AutoPickTask.py index 0f817ab..7dae2d6 100644 --- a/src/task/AutoPickTask.py +++ b/src/task/AutoPickTask.py @@ -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: diff --git a/src/task/BaseCombatTask.py b/src/task/BaseCombatTask.py index 126c43c..7cc435c 100644 --- a/src/task/BaseCombatTask.py +++ b/src/task/BaseCombatTask.py @@ -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 diff --git a/src/task/BaseWWTask.py b/src/task/BaseWWTask.py index 03ff5c6..5513618 100644 --- a/src/task/BaseWWTask.py +++ b/src/task/BaseWWTask.py @@ -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 diff --git a/src/task/FarmEchoTask.py b/src/task/FarmEchoTask.py index 2ae8807..a1be803 100644 --- a/src/task/FarmEchoTask.py +++ b/src/task/FarmEchoTask.py @@ -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: diff --git a/src/task/FarmWorldBossTask.py b/src/task/FarmWorldBossTask.py index d00b35c..8e51620 100644 --- a/src/task/FarmWorldBossTask.py +++ b/src/task/FarmWorldBossTask.py @@ -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) diff --git a/src/task/SkipDialogTask.py b/src/task/SkipDialogTask.py index 1af137b..ee1d65a 100644 --- a/src/task/SkipDialogTask.py +++ b/src/task/SkipDialogTask.py @@ -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)