diff --git a/assets/templates/ui/view/quest_skill_btn.png b/assets/templates/ui/view/quest_skill_btn.png new file mode 100644 index 0000000..4224fe2 Binary files /dev/null and b/assets/templates/ui/view/quest_skill_btn.png differ diff --git a/config/game.ini b/config/game.ini index b925c51..33c30c4 100644 --- a/config/game.ini +++ b/config/game.ini @@ -129,6 +129,7 @@ left_panel_header=0,0,450,54 right_panel_header=830,0,450,54 npc_dialogue=458,4,21,140 bind_skill=516,619,251,29 +quest_skill_btn=284,455,710,121 [path] ; static pathes in format: x0,y0, x1,y1, x2,y2, ... diff --git a/src/health_manager.py b/src/health_manager.py index c7b63ba..8bfc27b 100644 --- a/src/health_manager.py +++ b/src/health_manager.py @@ -76,9 +76,7 @@ class HealthManager: # Wait until the flag is reset by main.py if self._did_chicken or self._pausing: continue img = grab() - # TODO: Check if in town or not! Otherwise risk endless chicken loop - match = detect_screen_object(ScreenObjects.InGame, img) - if match.valid: + if detect_screen_object(ScreenObjects.InGame, img).valid: health_percentage = meters.get_health(img) mana_percentage = meters.get_mana(img) # check rejuv @@ -105,8 +103,7 @@ class HealthManager: belt.drink_potion("mana", stats=[health_percentage, mana_percentage]) self._last_mana = time.time() # check merc - match = detect_screen_object(ScreenObjects.MercIcon) - if match.valid: + if detect_screen_object(ScreenObjects.MercIcon, img).valid: merc_health_percentage = meters.get_merc_health(img) last_drink = time.time() - self._last_merc_heal if merc_health_percentage < Config().char["merc_chicken"]: @@ -118,6 +115,9 @@ class HealthManager: elif merc_health_percentage < Config().char["heal_merc"] and last_drink > 7.0: belt.drink_potion("health", merc=True, stats=[merc_health_percentage]) self._last_merc_heal = time.time() + if detect_screen_object(ScreenObjects.QuestSkillBtn, img).valid: + Logger.warning(f"Skill, stats, or quest button appeared--quit to avoid accidental allocations.") + self._do_chicken(img) Logger.debug("Stop health monitoring") diff --git a/src/ui_manager.py b/src/ui_manager.py index aac37ce..c19e46a 100644 --- a/src/ui_manager.py +++ b/src/ui_manager.py @@ -262,6 +262,12 @@ class ScreenObjects: color_match=Config().colors["red"], use_grayscale=True ) + QuestSkillBtn=ScreenObject( + ref="QUEST_SKILL_BTN", + threshold=0.9, + use_grayscale=True, + roi="quest_skill_btn" + ) def detect_screen_object(screen_object: ScreenObject, img: np.ndarray = None) -> TemplateMatch: roi = Config().ui_roi[screen_object.roi] if screen_object.roi else None