Tried to fixed issue of failed teleport at start. Fixed issue that prevented potions from being picked up. Fixed item inspection issue with tooltip.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
@@ -172,11 +172,14 @@ class IChar:
|
||||
def select_tp(self):
|
||||
return skills.select_tp(Config().char["teleport"])
|
||||
|
||||
def pre_move(self):
|
||||
def pre_move(self, wait_tp: bool = False):
|
||||
# if teleport hotkey is set and if teleport is not already selected
|
||||
if self.capabilities.can_teleport_natively:
|
||||
self.select_tp()
|
||||
self._set_active_skill("right", "teleport")
|
||||
if wait_tp:
|
||||
if skills.wait_until_right_skill_selected("TELE_ACTIVE") == False:
|
||||
Logger.error("timeout waiting for tele skill to activate")
|
||||
|
||||
def move(self, pos_monitor: tuple[float, float], force_tp: bool = False, force_move: bool = False):
|
||||
factor = Config().advanced_options["pathing_delay_factor"]
|
||||
|
||||
@@ -118,11 +118,11 @@ def crop_item_tooltip(image: np.ndarray, model: str = "hover-eng_inconsolata_inv
|
||||
# check to see if contour overlaps right inventory
|
||||
right_inv = Config().ui_roi["right_inventory"]
|
||||
overlaps_inventory = not (
|
||||
x+w < right_inv[0] or right_inv[0]+right_inv[2] < x or y+h+60 < right_inv[1] or right_inv[1]+right_inv[3] < y)
|
||||
x+w < right_inv[0] or right_inv[0]+right_inv[2] < x or y+h+70 < right_inv[1] or right_inv[1]+right_inv[3] < y)
|
||||
if not overlaps_inventory:
|
||||
left_inv = Config().ui_roi["left_inventory"]
|
||||
overlaps_inventory |= not (
|
||||
x+w < left_inv[0] or left_inv[0]+left_inv[2] < x or y+h+60 < left_inv[1] or left_inv[1]+left_inv[3] < y)
|
||||
x+w < left_inv[0] or left_inv[0]+left_inv[2] < x or y+h+70 < left_inv[1] or left_inv[1]+left_inv[3] < y)
|
||||
if not overlaps_inventory:
|
||||
continue
|
||||
|
||||
|
||||
@@ -293,8 +293,8 @@ def inspect_items(inp_img: np.ndarray = None, close_window: bool = True, game_st
|
||||
box.need_id = False
|
||||
is_unidentified = True
|
||||
# recapture box after ID
|
||||
mouse.move(x_m, y_m, randomize = 4, delay_factor = delay)
|
||||
wait(0.05, 0.1)
|
||||
mouse.move(x_m, y_m, randomize = 4, delay_factor = [0.2, 0.3])
|
||||
wait(0.2, 0.3)
|
||||
hovered_item = grab(True)
|
||||
item_properties, item_box = d2r_image.get_hovered_item(hovered_item)
|
||||
|
||||
|
||||
@@ -73,13 +73,16 @@ class PickIt:
|
||||
def _ignore_consumable(item: GroundItem):
|
||||
# ignore item if it's a consumable AND there's no need for that consumable
|
||||
need_exists = True
|
||||
for consumable_type in ITEM_CONSUMABLES_MAP.keys():
|
||||
if not item.Name.lower() == consumable_type:
|
||||
continue
|
||||
need_exists = consumables.get_needs(consumable_type) > 0
|
||||
if need_exists:
|
||||
consumables.increment_need(consumable_type, -1)
|
||||
if item.Name.lower() in ITEM_CONSUMABLES_MAP:
|
||||
need_exists = consumables.get_needs(item.Name.lower()) > 0
|
||||
return (not need_exists)
|
||||
|
||||
@staticmethod
|
||||
def _decrement_need_if_consumable(item: GroundItem):
|
||||
if item.Name.lower() in ITEM_CONSUMABLES_MAP:
|
||||
consumables.increment_need(item.Name.lower(), -1)
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def _yoink_item(item: GroundItem, char: IChar, force_tp=False) -> PickedUpResult:
|
||||
@@ -160,22 +163,24 @@ class PickIt:
|
||||
if item.ID in self._cached_pickit_items:
|
||||
if self._cached_pickit_items[item.ID] and not (self._ignore_consumable(item) or self._ignore_gold(item)):
|
||||
pick_up_res = self._pick_up_item(char, item)
|
||||
Logger.debug(f"Pick up expression: {raw_expression}")
|
||||
Logger.info(f"Attempt to pick up {item.Name}")
|
||||
else:
|
||||
item_dict = item.as_dict()
|
||||
# if the item shouldn't be ignored, check if it should be picked up
|
||||
if not (self._ignore_gold(item) or self._ignore_consumable(item)):
|
||||
pickup, raw_expression = should_pickup(item_dict)
|
||||
self._cached_pickit_items[item.ID] = pickup
|
||||
self._cached_pickit_items[item.ID] = pickup
|
||||
if pickup:
|
||||
pick_up_res = self._pick_up_item(char, item)
|
||||
Logger.debug(f"Pick up expression: {raw_expression}")
|
||||
Logger.info(f"Attempt to pick up {item.Name}")
|
||||
match pick_up_res:
|
||||
case PickedUpResult.InventoryFull:
|
||||
if pickup:
|
||||
Logger.warning(f"Inventory is full, could not pick {item.Name}. Stop pickit") #TODO Create logic to handle inventory full
|
||||
Logger.warning(f"Inventory is full, could not pick {item.Name}. Stop pickit") #TODO Create logic to handle inventory full
|
||||
break
|
||||
case PickedUpResult.PickedUp:
|
||||
self._decrement_need_if_consumable(item)
|
||||
self._picked_up_items.append(item)
|
||||
self._picked_up_item = pick_up_res == PickedUpResult.PickedUp
|
||||
item_count+=1
|
||||
|
||||
@@ -505,32 +505,29 @@ class Pather:
|
||||
error_msg = "Teleport is required for static pathing"
|
||||
Logger.error(error_msg)
|
||||
raise ValueError(error_msg)
|
||||
char.pre_move()
|
||||
char.pre_move(wait_tp = True)
|
||||
if type(key) == str:
|
||||
path = Config().path[key]
|
||||
else:
|
||||
path = key
|
||||
i = 0
|
||||
stuck_count = 0
|
||||
#stuck_count = 0
|
||||
while i < len(path):
|
||||
x_m, y_m = convert_screen_to_monitor(path[i])
|
||||
x_m += int(random.random() * 6 - 3)
|
||||
y_m += int(random.random() * 6 - 3)
|
||||
t0 = grab(force_new=True)
|
||||
#t0 = grab(force_new=True)
|
||||
char.move((x_m, y_m))
|
||||
t1 = grab(force_new=True)
|
||||
#t1 = grab(force_new=True)
|
||||
# check difference between the two frames to determine if tele was good or not
|
||||
diff = cv2.absdiff(t0, t1)
|
||||
diff = cv2.cvtColor(diff, cv2.COLOR_BGR2GRAY)
|
||||
_, mask = cv2.threshold(diff, 13, 255, cv2.THRESH_BINARY)
|
||||
score = (float(np.sum(mask)) / mask.size) * (1/255.0)
|
||||
if score > 0.15:
|
||||
i += 1
|
||||
else:
|
||||
stuck_count += 1
|
||||
Logger.debug(f"Teleport cancel detected. Try same teleport action again. ({score:.4f})")
|
||||
if stuck_count >= 5:
|
||||
return False
|
||||
#diff = cv2.absdiff(t0, t1)
|
||||
#diff = cv2.cvtColor(diff, cv2.COLOR_BGR2GRAY)
|
||||
#_, mask = cv2.threshold(diff, 13, 255, cv2.THRESH_BINARY)
|
||||
#score = (float(np.sum(mask)) / mask.size) * (1/255.0)
|
||||
i += 1
|
||||
#if score <= 0.15:
|
||||
# Logger.debug(f"Teleport cancel detected: ({score:.4f})")
|
||||
|
||||
# if type(key) == str and ("_save_dist" in key or "_end" in key):
|
||||
# cv2.imwrite(f"./log/screenshots/info/nil_path_{key}_" + time.strftime("%Y%m%d_%H%M%S") + ".png", grab())
|
||||
return True
|
||||
|
||||
@@ -65,6 +65,15 @@ def is_right_skill_selected(template_list: list[str]) -> bool:
|
||||
return True
|
||||
return False
|
||||
|
||||
def wait_until_right_skill_selected(template: str, timeout: float = 1) -> bool:
|
||||
"""
|
||||
:return: Bool if skill gets selected on the right skill slot within the timeout.
|
||||
"""
|
||||
skill_right_ui_roi = Config().ui_roi["skill_right"]
|
||||
if template_finder.search_and_wait(template, roi=skill_right_ui_roi, timeout = timeout, threshold=0.84).valid:
|
||||
return True
|
||||
return False
|
||||
|
||||
def get_skill_charges(img: np.ndarray = None):
|
||||
if img is None:
|
||||
img = grab()
|
||||
|
||||