From 59eccac2560d7bbeddd8755c59eb42def46ca412 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Sun, 9 Jul 2023 17:48:11 +0800 Subject: [PATCH] Fix: Handle destructible object nearby Stagnant_Shadow_Blaze --- tasks/dungeon/dungeon.py | 47 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/tasks/dungeon/dungeon.py b/tasks/dungeon/dungeon.py index 159e518fc..4d3aaee8e 100644 --- a/tasks/dungeon/dungeon.py +++ b/tasks/dungeon/dungeon.py @@ -1,6 +1,7 @@ +from module.base.utils import area_offset from module.logger import logger from tasks.combat.combat import Combat -from tasks.dungeon.keywords import DungeonList +from tasks.dungeon.keywords import DungeonList, KEYWORDS_DUNGEON_LIST from tasks.dungeon.ui import DungeonUI @@ -17,6 +18,10 @@ class Dungeon(DungeonUI, Combat): self.config.Scheduler_Enable = False self.config.task_stop() + if dungeon == KEYWORDS_DUNGEON_LIST.Stagnant_Shadow_Blaze: + if self.handle_destructible_around_blaze(): + self.dungeon_goto(dungeon) + self.combat(team) # Scheduler @@ -28,3 +33,43 @@ class Dungeon(DungeonUI, Combat): cover = max(limit - self.state.TrailblazePower, 0) * 6 logger.info(f'Currently has {self.state.TrailblazePower} need {cover} minutes to reach {limit}') self.config.task_delay(minute=cover) + + def handle_destructible_around_blaze(self): + """ + Stagnant_Shadow_Blaze has a destructible object nearby, attacks are aimed at it first + so destroy it first + + Returns: + bool: If handled. + + Pages: + in: COMBAT_PREPARE + out: page_main, map position changed if handled + """ + logger.hr('Handle destructible around blaze') + self.combat_exit() + # Check if there's a front sight at bottom-left corner + area = area_offset((-50, -150, 0, 0), offset=self.config.ASSETS_RESOLUTION) + + skip_first_screenshot = True + self._map_A_timer.reset() + handled = False + while 1: + if skip_first_screenshot: + skip_first_screenshot = False + else: + self.device.screenshot() + + if self.image_color_count(area, color=(48, 170, 204), threshold=221, count=50): + logger.info(f'Found destructible object') + if self.handle_map_A(): + handled = True + continue + else: + logger.info(f'No destructible object') + if not handled: + break + if self._map_A_timer.reached(): + break + + return handled