From 348c22cd35d542c81051b0479de371e6c17985a6 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Tue, 7 May 2024 23:03:40 +0800 Subject: [PATCH] Fix: Handle enemy during rotation_set() --- tasks/map/control/control.py | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/tasks/map/control/control.py b/tasks/map/control/control.py index 865e0aa64..90d752fa3 100644 --- a/tasks/map/control/control.py +++ b/tasks/map/control/control.py @@ -59,8 +59,11 @@ class MapControl(Combat, AimDetectorMixin): skip_first_screenshot: Returns: - bool: If swiped rotation + list[str]: A list of walk result + Enemy may attack character during rotation_set, function returns walk result """ + logger.hr('Rotation set') + result = [] interval = Timer(1, count=2) while 1: if skip_first_screenshot: @@ -70,15 +73,27 @@ class MapControl(Combat, AimDetectorMixin): self.minimap.update_rotation(self.device.image) self.minimap.log_minimap() - # End - if self.minimap.is_rotation_near(target, threshold=threshold): - logger.info(f'Rotation is now at: {target}') - break + # Additional + if self.is_combat_executing(): + logger.info('Walk result add: enemy') + result.append('enemy') + logger.hr('Combat', level=2) + self.combat_execute() + if self.walk_additional(): + continue - if interval.reached(): - if self.handle_rotation_set(target, threshold=threshold): - interval.reset() - continue + if self.is_in_main(): + # End + if self.minimap.is_rotation_near(target, threshold=threshold): + logger.info(f'Rotation is now at: {target}') + break + # Swipe + if interval.reached(): + if self.handle_rotation_set(target, threshold=threshold): + interval.reset() + continue + + return result def walk_additional(self) -> bool: """