Minor tweaks to pickup

This commit is contained in:
Randi
2026-03-13 22:21:47 -04:00
parent 9512856cfc
commit b2afbaab93
3 changed files with 24 additions and 19 deletions
+20 -16
View File
@@ -89,8 +89,8 @@ class IChar:
def on_capabilities_discovered(self, capabilities: CharacterCapabilities):
pass
def pick_up_item(self, pos: tuple[float, float], item_name: str = None, distance: int = 0, tele: bool = True):
if tele and self.capabilities.can_teleport_natively and (distance >= Config().ui_pos["item_dist"]) and item_name != "Chest":
def pick_up_item(self, pos: tuple[float, float], item_name: str = None, distance: int = 0, force_run: bool = False):
if not force_run and self.capabilities.can_teleport_natively and (distance >= Config().ui_pos["item_dist"]) and item_name != "Chest":
self.pre_move()
self.move(pos, force_tp=True)
self._stationary = True #We teleported so we should be guaranteed stationary now
@@ -102,21 +102,25 @@ class IChar:
time.sleep(0.1)
mouse.click(button="left")
#When character moves, it typically doesn't move less than 30
if distance < 30:
distance = 30
#Current logic only sets force_run if we previously teled.
#Therefore, we only need to perform run delay if force_run is not set
if not force_run:
#When character moves, it typically doesn't move less than 30
if distance < 30:
distance = 30
#By default we ignore pickup distance and do a full delay in case we misclick
pickup_distance = 0
#If we are stationary, we can account for pickup distance to potentially allow instant pickups
if self._stationary:
pickup_distance = 110 #we can instant pickup items 110 units away
if distance > pickup_distance:
run_time = 0.003125 * (distance-pickup_distance) #estimated run speed of (2sec/640pixels) = 0.003125
wait(run_time, run_time) #wait until we move to item and pick it up
#By default we ignore pickup distance and do a full delay in case we misclick
pickup_distance = 0
#If we are stationary, we can account for pickup distance to potentially allow instant pickups
if self._stationary:
pickup_distance = 110 #we can instant pickup items 110 units away
self._stationary = False #Moving so we don't guarantee stationary state (delay is accurate not exorbitant)
if distance > pickup_distance:
run_time = 0.003125 * (distance-pickup_distance) #estimated run speed of (2sec/640pixels) = 0.003125
wait(run_time, run_time) #wait until we move to item and pick it up
self._stationary = False #Moving so we don't guarantee stationary state (delay is accurate not exorbitant)
return True
def select_by_template(
+2 -2
View File
@@ -25,7 +25,7 @@ class Sorceress(IChar):
self._action_frame = 4
self._action_duration = self._action_frame * 0.04
def pick_up_item(self, pos: tuple[float, float], item_name: str = None, distance: int = 0, tele: bool = True):
def pick_up_item(self, pos: tuple[float, float], item_name: str = None, distance: int = 0, force_run: bool = False):
if self._skill_hotkeys["telekinesis"] and any(x in item_name for x in ['Potion', 'GOLD', 'Scroll of', 'Chest']):
keyboard.send(self._skill_hotkeys["telekinesis"])
mouse.move(pos[0], pos[1])
@@ -35,7 +35,7 @@ class Sorceress(IChar):
self._stationary = True #We used telekinesis so we should be guaranteed stationary now
return True
else:
return super().pick_up_item(pos, item_name, distance, tele)
return super().pick_up_item(pos, item_name, distance, force_run)
def select_by_template(
self,
+2 -1
View File
@@ -94,7 +94,7 @@ class PickIt:
if item.Name == i.Name:
tele_success = True
Logger.info(f"Teled to pickup item {i.Name} and now at distance {i.Distance}")
char.pick_up_item((i.CenterMonitor['x'], i.CenterMonitor['y']), item_name=i.Name, distance=i.Distance, tele=False)
char.pick_up_item((i.CenterMonitor['x'], i.CenterMonitor['y']), item_name=i.Name, distance=i.Distance, force_run=True)
break
if not tele_success:
Logger.warning(f"Failed to scan item {i.Name} after tele.")
@@ -139,6 +139,7 @@ class PickIt:
self._reset_state()
keyboard.send(Config().char["show_items"])
wait(0.16, 0.16) #wait 4 frames for items to refresh
char._stationary = True #Character should start out stationary when pickup starts
pickit_phase_start = time.time()
items, img = self._locate_items()