diff --git a/src/bot.py b/src/bot.py index 146d0fb..f6c1072 100644 --- a/src/bot.py +++ b/src/bot.py @@ -199,8 +199,10 @@ class Bot: return bot._curr_location = Location.NIHLATHAK_PORTAL wait(0.2, 0.4) - bot._char.select_by_template("A5_RED_PORTAL") - bot._template_finder.search_and_wait("PINDLE_STONE") + self.success &= bot._char.select_by_template("A5_RED_PORTAL") + self.success &= bot._template_finder.search_and_wait("PINDLE_STONE", time_out=15)[0] + if not self.success: + return bot._char.pre_buff() wait(0.2, 0.4) bot._pather.traverse_nodes_fixed("PINDLE", bot._char) diff --git a/src/template_finder.py b/src/template_finder.py index b2421fc..579b510 100644 --- a/src/template_finder.py +++ b/src/template_finder.py @@ -106,7 +106,7 @@ class TemplateFinder: return True, ref_point return False, None - def search_and_wait(self, ref: str, roi: List[float] = None, time_out: float = None, threshold: float = 0.7) -> Tuple[float, float]: + def search_and_wait(self, ref: str, roi: List[float] = None, time_out: float = None, threshold: float = 0.7) -> Tuple[bool, Tuple[float, float]]: Logger.debug(f"Waiting for Template {ref}") start = time.time() while 1: @@ -130,7 +130,7 @@ if __name__ == "__main__": template_finder = TemplateFinder(screen) while 1: img = screen.grab() - success, pos = template_finder.search("BLUE_PORTAL", img) + success, pos = template_finder.search("BLUE_PORTAL", img, threshold=0.67) print(template_finder.debug_last_score) if success: cv2.circle(img, pos, 7, (255, 0, 0), thickness=5)