Update AutismBotIngame/python/ingamefollowct.py

This commit is contained in:
Metroid_Skittles 2026-02-07 08:02:07 +01:00
parent 6715d2a07c
commit 15a8093138

View File

@ -90,6 +90,7 @@ def exit_handler():
subprocess.getoutput(f"pkill -9 -u {whoami}") subprocess.getoutput(f"pkill -9 -u {whoami}")
def bot_process_movement(input_line): def bot_process_movement(input_line):
try:
dist_target = input_line[input_line.index("dist_target:") + len("dist_target:"):input_line.index("enemy_distance")] dist_target = input_line[input_line.index("dist_target:") + len("dist_target:"):input_line.index("enemy_distance")]
enemy_distance = input_line[input_line.index("enemy_distance:") + len("enemy_distance:"):input_line.index("targeteam:")] enemy_distance = input_line[input_line.index("enemy_distance:") + len("enemy_distance:"):input_line.index("targeteam:")]
targeteam = input_line[input_line.index("targeteam:") + len("targeteam:"):input_line.index("state:")] targeteam = input_line[input_line.index("targeteam:") + len("targeteam:"):input_line.index("state:")]
@ -99,6 +100,9 @@ def bot_process_movement(input_line):
dist_target = float(dist_target) dist_target = float(dist_target)
enemy_distance = float(enemy_distance) enemy_distance = float(enemy_distance)
targeteam = int(targeteam) targeteam = int(targeteam)
except (ValueError, IndexError):
# Ignore malformed movement packets instead of crashing the main loop.
return
global last_forward_time global last_forward_time
strInput = "cl_minmodels 1; wait 2; " strInput = "cl_minmodels 1; wait 2; "
@ -106,6 +110,9 @@ def bot_process_movement(input_line):
if targeteam == 3: if targeteam == 3:
strInput = "cl_minmodels 1; wait 2; " strInput = "cl_minmodels 1; wait 2; "
def forward_burst(wait_ticks):
return f"+forward; wait {wait_ticks}; -forward; "
# Keep movement fluid: avoid frequent full stops. # Keep movement fluid: avoid frequent full stops.
should_push_forward = False should_push_forward = False
if state >= 3 or state == 1 or state == 8: if state >= 3 or state == 1 or state == 8:
@ -116,7 +123,7 @@ def bot_process_movement(input_line):
should_push_forward = True should_push_forward = True
if should_push_forward: if should_push_forward:
strInput += "+forward; wait 2;" strInput += forward_burst(2)
last_forward_time = time.time() last_forward_time = time.time()
else: else:
strInput += "wait 2;" strInput += "wait 2;"
@ -124,13 +131,14 @@ def bot_process_movement(input_line):
#print('dist_target: ', dist_target, ' enemy distance: ', enemy_distance, ' targeteam: ', targeteam, ' state:', state) #print('dist_target: ', dist_target, ' enemy distance: ', enemy_distance, ' targeteam: ', targeteam, ' state:', state)
if dist_target > team_follow_distance: if dist_target > team_follow_distance:
# Favor forward movement when drifting away from teammates. # Favor forward movement when drifting away from teammates.
strInput += f"+forward; wait {random.randint(min_forward_wait, max_forward_wait)}; " strInput += forward_burst(random.randint(min_forward_wait, max_forward_wait))
elif enemy_distance <= enemy_chase_distance: elif enemy_distance <= enemy_chase_distance:
# Close enemy: keep pressure by closing distance. # Close enemy: keep pressure by closing distance.
strInput += f"+forward; wait {random.randint(min_forward_wait, max_forward_wait)}; " strInput += forward_burst(random.randint(min_forward_wait, max_forward_wait))
if enemy_distance <= infect_chase_distance: if enemy_distance <= infect_chase_distance:
# Chase and attack at close range. # Chase and attack at close range.
strInput += "+forward; wait 10; +attack; wait 20; -attack; " strInput += forward_burst(10)
strInput += "+attack; wait 20; -attack; "
if dist_target <= team_follow_distance: if dist_target <= team_follow_distance:
# Keep subtle strafes to avoid robotic straight lines. # Keep subtle strafes to avoid robotic straight lines.
strInput = strinput_append(strInput, 2) strInput = strinput_append(strInput, 2)