Bugfix: Chicken if stats/skill icons pop up to avoid accidental allocations (#618)

* init

* simplify

* undo
This commit is contained in:
mgleed
2022-03-09 15:39:44 -05:00
committed by GitHub
parent 6b378a4606
commit 54203ff036
4 changed files with 12 additions and 5 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

+1
View File
@@ -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, ...
+5 -5
View File
@@ -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")
+6
View File
@@ -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