From cbc5d4d786bcc8dc72e8f05f530183df66a300f9 Mon Sep 17 00:00:00 2001 From: aaahai00 <108205808+aaahai00@users.noreply.github.com> Date: Sun, 19 Nov 2023 19:04:11 +0800 Subject: [PATCH 1/3] Update support.py (#200) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 对改问题的修复https://github.com/LmeSzinc/StarRailCopilot/issues/195 --- tasks/combat/support.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/combat/support.py b/tasks/combat/support.py index bb0f2a123..cc638cdd2 100644 --- a/tasks/combat/support.py +++ b/tasks/combat/support.py @@ -27,7 +27,7 @@ class SupportCharacter: _image_cache = {} _crop_area = COMBAT_SUPPORT_LIST_GRID.matched_button.area - def __init__(self, name, screenshot, similarity=0.85): + def __init__(self, name, screenshot, similarity=0.75): self.name = name self.image = self._scale_character() self.screenshot = crop(screenshot, SupportCharacter._crop_area) From 4ef3dd26e28446c637ad5c2cad7cf919a36764f6 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Mon, 20 Nov 2023 01:46:31 +0800 Subject: [PATCH 2/3] Fix: Wait if team not prepared as game client saves team characters now --- route/daily/ForgottenHallStage1.py | 3 ++- tasks/daily/use_technique.py | 3 ++- tasks/forgotten_hall/team.py | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/route/daily/ForgottenHallStage1.py b/route/daily/ForgottenHallStage1.py index 05e6cd5bb..26fc3196e 100644 --- a/route/daily/ForgottenHallStage1.py +++ b/route/daily/ForgottenHallStage1.py @@ -25,7 +25,8 @@ class Route(RouteBase, ForgottenHallUI): logger.hr('Forgotten hall stage 1') self.stage_goto(KEYWORDS_DUNGEON_LIST.The_Last_Vestiges_of_Towering_Citadel, KEYWORDS_FORGOTTEN_HALL_STAGE.Stage_1) - self.team_choose_first_4() + if not self.team_is_prepared(): + self.team_choose_first_4() self.enter_forgotten_hall_dungeon() self.map_init(plane=Jarilo_BackwaterPass, position=(369.4, 643.4)) diff --git a/tasks/daily/use_technique.py b/tasks/daily/use_technique.py index eff114cdc..f7f15a3c7 100644 --- a/tasks/daily/use_technique.py +++ b/tasks/daily/use_technique.py @@ -56,7 +56,8 @@ class UseTechniqueUI(MapControlJoystick, ForgottenHallUI): logger.hr('Use techniques', level=2) self.stage_goto(KEYWORDS_DUNGEON_LIST.The_Last_Vestiges_of_Towering_Citadel, KEYWORDS_FORGOTTEN_HALL_STAGE.Stage_1) - self.team_choose_first() + if not self.team_is_prepared(): + self.team_choose_first_4() self.enter_forgotten_hall_dungeon() self._use_technique(count, skip_first_screenshot=skip_first_screenshot) self.exit_dungeon() diff --git a/tasks/forgotten_hall/team.py b/tasks/forgotten_hall/team.py index 9e4eadbab..0d4cfe34d 100644 --- a/tasks/forgotten_hall/team.py +++ b/tasks/forgotten_hall/team.py @@ -1,6 +1,7 @@ import cv2 import numpy as np +from module.base.timer import Timer from module.base.utils import color_similarity_2d, get_color from module.logger import logger from tasks.base.ui import UI @@ -72,3 +73,24 @@ class ForgottenHallTeam(UI): self.device.click(character) # Casual sleep, game may not respond that fast self.device.sleep((0.1, 0.2)) + + def team_is_prepared(self, skip_first_screenshot=True) -> bool: + """ + Pages: + in: ENTRANCE_CHECKED, ENTER_FORGOTTEN_HALL_DUNGEON + """ + characters = [CHARACTER_1, CHARACTER_2, CHARACTER_3, CHARACTER_4] + timeout = Timer(1, count=5).start() + while 1: + if skip_first_screenshot: + skip_first_screenshot = False + else: + self.device.screenshot() + + if timeout.reached(): + logger.info('Team not prepared') + return False + chosen_list = [self.is_character_chosen(c) for c in characters] + if all(chosen_list): + logger.info("Team already prepared") + return True From 0c5a1e1f42f667d8d9b4f610fe1ad7c0ee66250d Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Mon, 20 Nov 2023 01:48:30 +0800 Subject: [PATCH 3/3] Fix: Lower item threshold to 10 --- tasks/map/interact/aim.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/map/interact/aim.py b/tasks/map/interact/aim.py index e2f097018..d10acaf58 100644 --- a/tasks/map/interact/aim.py +++ b/tasks/map/interact/aim.py @@ -233,7 +233,7 @@ class Aim: self.draw_item = cv2.multiply(draw, 4) # Find peaks - points = inrange(draw, lower=12) + points = inrange(draw, lower=10) points = Points(points).group(threshold=10) if points.shape[0] > 3: logger.warning(f'AimDetector.predict_item() too many peaks: {points.shape}')