Don't pick up bed items near other bots

This commit is contained in:
Tanner committed 2026-11-10 18:35:10 +00:00
1 parent 032b4cfd33
commit 185cefced9
4 files changed
+142 -1

No files matched your search

+20 -1
View File
@@ -38,6 +38,7 @@ class GrabSuppliesStates:
self.checked_ground_items = set()
self.checked_ground_groups = set()
self.checked_supply_chests = set()
self.protected_ground_items_logged = set()
self.ground_stack_counts = {}
self.failed_drop_slots = set()
self.pending_drop_slot = None
@@ -49,6 +50,21 @@ class GrabSuppliesStates:
print('Aborting getting supplies, none specified')
self.state = self.cleanup
def _ground_bed_reserved_by_nearby_bot(self, obj):
if obj.item_id not in items.BED_IDS:
return False
position = (obj.x, obj.y, obj.z)
nearby_bots = utils.find_nearby_bots(self.g, position, 4)
if nearby_bots:
logged = getattr(self, 'protected_ground_items_logged', set())
if obj.entity_id not in logged:
print('Leaving bed drop for nearby bot {} at {}'.format(
nearby_bots[0]['name'], utils.pint(position)))
logged.add(obj.entity_id)
self.protected_ground_items_logged = logged
return True
return False
def _has_nearby_ground_items(self, item_ids, maximum_stacks):
if (maximum_stacks and
self.ground_stack_counts.get(item_ids, 0) >= maximum_stacks):
@@ -56,6 +72,7 @@ class GrabSuppliesStates:
p = utils.pint(self.g.pos)
return any(
obj.entity_id not in self.checked_ground_items and
not self._ground_bed_reserved_by_nearby_bot(obj) and
utils.phyp(p, (obj.x, obj.y, obj.z)) <= 16
for obj in self.g.world.find_objects(item_ids))
@@ -223,7 +240,8 @@ class GrabSuppliesStates:
p, (obj.x, obj.y, obj.z)))
for obj in ground_items:
if obj.entity_id in self.checked_ground_items:
if (obj.entity_id in self.checked_ground_items or
self._ground_bed_reserved_by_nearby_bot(obj)):
continue
current_count = self.g.game.count_items(self.target_items)
if utils.phyp(p, (obj.x, obj.y, obj.z)) > 16:
@@ -579,6 +597,7 @@ class GrabSuppliesStates:
self.wait_time = 0
self.failed_drop_slots = set()
self.pending_drop_slot = None
self.protected_ground_items_logged = set()
def run(self):
self._refresh_useless_chests()