Jelajahi Sumber

feat(WantedQuests): Add multi-scale GIF matching for YunJingLangYuan costume support #1697 云景阆苑

neptine 3 bulan lalu
induk
melakukan
7b6eaa8250
3 mengubah file dengan 27 tambahan dan 2 penghapusan
  1. 12 0
      module/atom/gif.py
  2. 7 1
      tasks/Exploration/version.py
  3. 8 1
      tasks/WantedQuests/explore.py

+ 12 - 0
module/atom/gif.py

@@ -44,6 +44,18 @@ class RuleGif:
                 return True, target
         return False, None
 
+    def search_with_multi_scale(self, image, roi=None, threshold=None, scale_range=(0.8, 1.1, 0.05)):
+        image = self.pre_process(image)
+        threshold = self.targets[0].threshold if threshold is None else threshold
+        roi = self.targets[0].roi_back if roi is None else roi
+        for target in self.targets:
+            target.roi_back = roi
+            if target.match_multi_scale(image, threshold=threshold, scale_range=scale_range):
+                self.roi_front = target.roi_front
+                self.appear_target = target
+                return True, target
+        return False, None
+
     def match(self, image, threshold: float = None) -> bool:
         return self.search(image, threshold=threshold)[0]
 

+ 7 - 1
tasks/Exploration/version.py

@@ -56,11 +56,17 @@ class HighlightGif(RuleGif):
     def pre_process(self, image):
         return highlight(image)
 
+    def match_with_multi_scale(self, image, threshold=None, scale_range=(0.8, 1.1, 0.05)):
+        return self.search_with_multi_scale(image, threshold=threshold, scale_range=scale_range)[0]
+
+    def match_origin(self, image, threshold: float = None) -> bool:
+        return self.search(image, threshold=threshold)[0]
+
 
 class HighLight(BaseTask, ExplorationAssets):
 
     @cached_property
-    def TEMPLATE_GIF(self) -> RuleGif:
+    def TEMPLATE_GIF(self) -> HighlightGif:
         return HighlightGif(
             targets=[
                 self.I_LIGHT1, self.I_LIGHT2, self.I_LIGHT3, self.I_LIGHT4, self.I_LIGHT5,

+ 8 - 1
tasks/WantedQuests/explore.py

@@ -27,6 +27,13 @@ class WQExplore(BaseExploration, HighLight):
         _cnt_exploration = 0
         search_fail_cnt = 0
         search_fail_timer = Timer(3.2)  # 这里设置的时间一定要大于S_SWIPE_BACKGROUND_RIGHT滑动的时间
+        # https://github.com/runhey/OnmyojiAutoScript/pull/1697 云景阆苑 皮肤
+        from tasks.Component.Costume.config import MainType
+        if self.config.model.global_game.costume_config.costume_main_type == MainType.COSTUME_MAIN_13:
+            self.TEMPLATE_GIF.match = self.TEMPLATE_GIF.match_with_multi_scale
+            logger.info("Costume '云景阆苑' detected, enable multi-scale matching for highlight")
+        else:
+            self.TEMPLATE_GIF.match = self.TEMPLATE_GIF.match_origin
         while 1:
             self.screenshot()
             if self.appear(self.I_UI_BACK_YELLOW) and self.appear(self.I_E_EXPLORATION_CLICK):
@@ -112,4 +119,4 @@ if __name__ == '__main__':
     config = Config('oas1')
     device = Device(config)
     t = WQExplore(config, device)
-    t.explore(goto=WantedQuestsAssets.I_GOTO_1, num=2)
+    t.explore(goto=WantedQuestsAssets.I_GOTO_1, num=2)