Evade ranged weapons and rush target

This commit is contained in:
Tanner committed 2026-11-17 23:45:21 +00:00
1 parent dbd2831dda
commit 0722924263
10 files changed
+474 -14

No files matched your search

+17 -1
View File
@@ -697,7 +697,7 @@ class Game(LegacyGame):
self.g.yaw_target_override = None
self.g.unopenable_doors = self.g.get('unopenable_doors') or set()
from mosfet.protocol.packets import SetHealthPacket
from mosfet.protocol.packets import SetEquipmentPacket, SetHealthPacket
# Health is a protocol-777 packet, not the legacy UpdateHealthPacket.
# Register its decoder on an already-running reactor as well, so a
# hot reload can enable health tracking without reconnecting. Rebuild
@@ -710,6 +710,7 @@ class Game(LegacyGame):
for packet in reactor.__class__.get_clientbound_packets(context)
}
reactor.clientbound_packets[SetHealthPacket.id] = SetHealthPacket
reactor.clientbound_packets[SetEquipmentPacket.id] = SetEquipmentPacket
reactor.clientbound_packets[UpdateTimePacket.id] = UpdateTimePacket
self.g.connection.register_packet_listener(
self.handle_set_health, SetHealthPacket)
@@ -721,6 +722,7 @@ class Game(LegacyGame):
self.g.setdefault('time_base', None)
self.g.setdefault('time_update_received_at', None)
self.g.setdefault('clock_rate', 1.0)
self.g.setdefault('sprinting', False)
if not self.g.get('health_update_received', False):
self.g.health = None
@@ -1084,6 +1086,20 @@ class Game(LegacyGame):
self.next_swing_at = now + self.ARM_SWING_INTERVAL
return True
def set_sprinting(self, enabled):
"""Tell the server when the bot starts or stops a sprint burst."""
enabled = bool(enabled)
if self.g.get('sprinting', False) == enabled:
return False
entity_id = self.g.get('eid')
if entity_id is None:
return False
self._send_action(PlayerCommandPacket(
entity_id=entity_id, action_id=1 if enabled else 2,
jump_boost=0))
self.g.sprinting = enabled
return True
def respawn(self):
self.g.respawn_requested_at = time.monotonic()
self.g.connection.write_packet(