From d9a6e7ce400d9aadcd42af1da9f54f72732adf82 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 10 Jun 2026 17:58:31 +0200 Subject: [PATCH] feat: per-NPC body/pose thresholds (Malah 0.35/200); skip pickit while mobs alive User-tuned detection thresholds and a safety guard against teleporting into live packs during loot phases. Co-Authored-By: Claude Fable 5 --- src/item/pickit.py | 5 +++++ src/npc_manager.py | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/item/pickit.py b/src/item/pickit.py index fb8ee24..e7064c0 100644 --- a/src/item/pickit.py +++ b/src/item/pickit.py @@ -184,6 +184,11 @@ class PickIt: :param char: The character used to pick up the item TODO :return: return a list of the items that were picked up """ + # Safety: skip pickup if mobs are still alive — prevents teleporting into + # enemy packs during trash clearing (CS/ROF) which tanks HP to chicken levels. + from target_detect import get_visible_targets + if get_visible_targets(): + return False # Re-detect window position to mitigate 1282x720 vs 1280x720 template drift from screen import find_and_set_window_position find_and_set_window_position(force=True) diff --git a/src/npc_manager.py b/src/npc_manager.py index 5fa9956..618d354 100644 --- a/src/npc_manager.py +++ b/src/npc_manager.py @@ -63,7 +63,9 @@ def _build_npcs(): }, "template_group": ["MALAH_FRONT", "MALAH_BACK", "MALAH_45", "MALAH_SIDE", "MALAH_SIDE_2"], "roi": [383, 193, (762-383), (550-193)], - "poses": [[445, 485], [526, 473], [602, 381], [623, 368], [641, 323], [605, 300], [622, 272], [638, 284], [677, 308], [710, 288]] + "poses": [[445, 485], [526, 473], [602, 381], [623, 368], [641, 323], [605, 300], [622, 272], [638, 284], [677, 308], [710, 288]], + "body_threshold": 0.35, + "pose_tolerance": 200, }, Npc.LARZUK: { "name_tag_white": color_filter(template_finder.get_template("LARZUK_NAME_TAG_WHITE"), Config().colors["white"])[1], @@ -382,8 +384,12 @@ def open_npc_menu(npc_key: Npc) -> bool: else: in_npc_roi = True name_tag_confirmed = (res_w.valid or res_g.valid) and in_npc_roi - body_confident = result["score"] >= 0.40 - pose_confirmed = "poses" in npcs[npc_key] and result["min_dist"] < 150 + # Per-NPC thresholds for body confidence and pose distance. + # Malah's templates are weaker (0.36-0.41) so she needs lower thresholds. + npc_body_threshold = npcs[npc_key].get("body_threshold", 0.40) + npc_pose_tolerance = npcs[npc_key].get("pose_tolerance", 150) + body_confident = result["score"] >= npc_body_threshold + pose_confirmed = "poses" in npcs[npc_key] and result["min_dist"] < npc_pose_tolerance if name_tag_confirmed: Logger.info(f"Clicking on {npc_key} at {mouse.get_position()} (name tag confirmed)")