diff --git a/config/game.ini b/config/game.ini index b6bde8b..50ef88a 100644 --- a/config/game.ini +++ b/config/game.ini @@ -25,9 +25,9 @@ red_slot=161,204,28,197,240,64 tab_text=0,0,125,180,255,255 [ui_pos] -screen_width=1280 +screen_width=1282 screen_height=720 -center_x=640 +center_x=641 center_y=360 ; some distance skill_bar_height=67 @@ -88,7 +88,7 @@ play_btn=426,616,320,71 difficulty_select=536,236,210,320 gold_btn=997,521,20,18 inventory_gold=980,510,150,40 -gold_btn_stash=160,520,25,25 +gold_btn_stash=158,518,30,30 vendor_gold_digits=186,509,97,16 stash_gold_digits=184,527,100,16 inventory_gold_digits=1017,523,100,16 @@ -97,16 +97,16 @@ health_globe=160,580,240,140 mana_globe=887,580,240,140 health_slice=309,610,7,101 mana_slice=961,610,7,101 -cut_skill_bar=0,0,1280,653 +cut_skill_bar=0,0,1284,653 reduce_to_center=120,60,1040,540 -search_npcs=120,0,1040,620 +search_npcs=120,0,1042,620 merc_icon=10,9,56,56 loading_left_black=0,0,350,720 death=444,198,397,71 tp_search=353,120,547,400 repair_btn=318,473,90,80 -left_inventory=35,86,378,378 -right_inventory=866,348,379,152 +left_inventory=33,84,382,382 +right_inventory=868,348,379,152 transmute_third_slot=242,342,38,38 skill_right=664,673,41,41 skill_right_expanded=655,375,385,255 @@ -128,12 +128,12 @@ cube_btn_roi=160,368,125,57 xp_bar_text=369,630,554,34 corpse=459,195,414,213 chat_icon=7,555,43,41 -left_panel_header=0,0,450,54 -right_panel_header=830,0,450,54 -npc_dialogue=458,4,21,140 +left_panel_header=0,0,455,56 +right_panel_header=830,0,455,56 +npc_dialogue=456,0,30,150 bind_skill=516,619,251,29 quest_skill_btn=284,455,710,121 -left_inventory_tabs=31,62,385,28 +left_inventory_tabs=29,60,389,30 tab_indicator=31,71,385,14 stash_page_select_left=155,475,20,20 stash_page_select_right=270,475,20,20 diff --git a/src/char/i_char.py b/src/char/i_char.py index 0d0b151..3774cda 100644 --- a/src/char/i_char.py +++ b/src/char/i_char.py @@ -266,6 +266,9 @@ class IChar: # will check if tp is available and select the skill if not skills.has_tps(): 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) mouse.click(button="right") consumables.increment_need("tp", 1) roi_mouse_move = [ diff --git a/src/town/town_manager.py b/src/town/town_manager.py index f697cba..4029129 100644 --- a/src/town/town_manager.py +++ b/src/town/town_manager.py @@ -96,12 +96,18 @@ class TownManager: return curr_loc def buy_consumables(self, curr_loc: Location, items: list = None): + Logger.info(f"TownManager buy_consumables: starting from {curr_loc}") curr_act = TownManager.get_act_from_location(curr_loc) - if curr_act is None: return False, items - # check if we can buy pots in current act + if curr_act is None: + Logger.error("TownManager buy_consumables: could not determine act from location") + return False, items if self._acts[curr_act].can_buy_pots(): + Logger.info(f"TownManager buy_consumables: calling open_trade_menu") new_loc = self._acts[curr_act].open_trade_menu(curr_loc) - if not (new_loc and common.wait_for_left_inventory()): return False, items + Logger.info(f"TownManager buy_consumables: open_trade_menu returned {new_loc}") + if not (new_loc and common.wait_for_left_inventory()): + Logger.error("TownManager buy_consumables: left inventory not detected after opening trade menu") + return False, items img=grab() def buy_best_available_potion(potion_templates: list[str], quantity: int, shift_click: bool) -> bool: for idx, template_name in enumerate(potion_templates): @@ -154,7 +160,10 @@ class TownManager: Logger.error("buy_consumables: Error purchasing keys") # Sell items, if any if items: + Logger.info(f"TownManager buy_consumables: selling {len(items)} items") items = personal.transfer_items(items, action = "sell") + Logger.info(f"TownManager buy_consumables: transfer_items returned {len(items) if items else 0} remaining items") + Logger.info("TownManager buy_consumables: closing vendor") common.close() return new_loc, items Logger.warning(f"Could not buy consumables in {curr_act}. Continue.") @@ -243,8 +252,11 @@ class TownManager: return new_loc, items def repair(self, curr_loc: Location, items: list = None): + Logger.info(f"TownManager repair: starting from {curr_loc}") curr_act = TownManager.get_act_from_location(curr_loc) - if curr_act is None: return False, False + if curr_act is None: + Logger.error("TownManager repair: could not determine act from location") + return False, False repair_preference = (Config().char.get("repair_npc") or "a4_halbu").lower() # check if we can rapair in current act if curr_act == Location.A5_TOWN_START and repair_preference in ["a4_halbu", "halbu", "act4"]: @@ -252,48 +264,63 @@ class TownManager: new_loc = self.go_to_act(4, curr_loc) if not new_loc: return False, False + Logger.info("TownManager repair: opening Halbu trade/repair menu") new_loc = self._acts[Location.A4_TOWN_START].open_trade_and_repair_menu(new_loc) + Logger.info(f"TownManager repair: open_trade_and_repair_menu returned {new_loc}") if not new_loc: return False, False if items: + Logger.info(f"TownManager repair: selling {len(items)} items before repair") items = personal.transfer_items(items, "sell") + Logger.info("TownManager repair: calling vendor.repair()") vendor.repair() wait(0.1, 0.2) common.close() return new_loc, items if self._acts[curr_act].can_trade_and_repair(): + Logger.info(f"TownManager repair: opening trade/repair menu at {curr_act}") new_loc = self._acts[curr_act].open_trade_and_repair_menu(curr_loc) + Logger.info(f"TownManager repair: open_trade_and_repair_menu returned {new_loc}") if new_loc: if items: + Logger.info(f"TownManager repair: selling {len(items)} items before repair") items = personal.transfer_items(items, "sell") + Logger.info("TownManager repair: calling vendor.repair()") vendor.repair() wait(0.1, 0.2) common.close() return new_loc, items if curr_act == Location.A5_TOWN_START: Logger.warning("A5 repair failed, attempting Act 4 Halbu fallback") - # We already traversed to Larzuk before failure, so start fallback from Larzuk - # to avoid reusing a stale town-start location. new_loc = self.go_to_act(4, Location.A5_LARZUK) if not new_loc: return False, False + Logger.info("TownManager repair: fallback - opening Halbu trade/repair menu") new_loc = self._acts[Location.A4_TOWN_START].open_trade_and_repair_menu(new_loc) + Logger.info(f"TownManager repair: fallback open_trade_and_repair_menu returned {new_loc}") if not new_loc: return False, False if items: + Logger.info(f"TownManager repair: selling {len(items)} items before repair (fallback)") items = personal.transfer_items(items, "sell") + Logger.info("TownManager repair: calling vendor.repair() (fallback)") vendor.repair() wait(0.1, 0.2) common.close() return new_loc, items return False, False + Logger.info("TownManager repair: going to A5 for repair") new_loc = self.go_to_act(5, curr_loc) if not new_loc: return False, False + Logger.info("TownManager repair: opening Larzuk trade/repair menu") new_loc = self._acts[Location.A5_TOWN_START].open_trade_and_repair_menu(new_loc) + Logger.info(f"TownManager repair: open_trade_and_repair_menu returned {new_loc}") if not new_loc: return False, False if items: + Logger.info(f"TownManager repair: selling {len(items)} items before repair") items = personal.transfer_items(items, "sell") + Logger.info("TownManager repair: calling vendor.repair()") vendor.repair() wait(0.1, 0.2) common.close()