Update AutismBotIngame/python/ingamefollowct.py
This commit is contained in:
parent
6715d2a07c
commit
15a8093138
@ -90,15 +90,19 @@ def exit_handler():
|
||||
subprocess.getoutput(f"pkill -9 -u {whoami}")
|
||||
|
||||
def bot_process_movement(input_line):
|
||||
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:")]
|
||||
targeteam = input_line[input_line.index("targeteam:") + len("targeteam:"):input_line.index("state:")]
|
||||
state = input_line[input_line.index("state:") + len("state:"):]
|
||||
try:
|
||||
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:")]
|
||||
targeteam = input_line[input_line.index("targeteam:") + len("targeteam:"):input_line.index("state:")]
|
||||
state = input_line[input_line.index("state:") + len("state:"):]
|
||||
|
||||
state = int(state.strip())
|
||||
dist_target = float(dist_target)
|
||||
enemy_distance = float(enemy_distance)
|
||||
targeteam = int(targeteam)
|
||||
state = int(state.strip())
|
||||
dist_target = float(dist_target)
|
||||
enemy_distance = float(enemy_distance)
|
||||
targeteam = int(targeteam)
|
||||
except (ValueError, IndexError):
|
||||
# Ignore malformed movement packets instead of crashing the main loop.
|
||||
return
|
||||
|
||||
global last_forward_time
|
||||
strInput = "cl_minmodels 1; wait 2; "
|
||||
@ -106,6 +110,9 @@ def bot_process_movement(input_line):
|
||||
if targeteam == 3:
|
||||
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.
|
||||
should_push_forward = False
|
||||
if state >= 3 or state == 1 or state == 8:
|
||||
@ -116,7 +123,7 @@ def bot_process_movement(input_line):
|
||||
should_push_forward = True
|
||||
|
||||
if should_push_forward:
|
||||
strInput += "+forward; wait 2;"
|
||||
strInput += forward_burst(2)
|
||||
last_forward_time = time.time()
|
||||
else:
|
||||
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)
|
||||
if dist_target > team_follow_distance:
|
||||
# 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:
|
||||
# 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:
|
||||
# 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:
|
||||
# Keep subtle strafes to avoid robotic straight lines.
|
||||
strInput = strinput_append(strInput, 2)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user