def run(self, agent): if self.start_time is None: self.start_time = agent.time ball_loc = agent.ball.location.y * side(agent.team) if agent.time - self.start_time > 0.5 or agent.playstyle is agent.playstyles.Defensive or ball_loc > 2560: agent.pop() return target = Vector(y=(ball_loc + 1280) * side(agent.team)) if agent.ball.location.x > 2560: target.x = 2560 if ball_loc <= 0 else 1024 elif agent.ball.location.x < -2560: target.x = -2560 if ball_loc <= 0 else -1024 self_to_target = agent.me.location.dist(target) if self_to_target > 250: self.goto.target = target self.goto.vector = agent.ball.location self.goto.run(agent, manual=True) if self_to_target < 500: agent.controller.boost = False agent.controller.throttle = cap(agent.controller.throttle, -0.75, 0.75)
def run(self, agent): ball_slice = agent.ball_prediction_struct.slices[ agent.future_ball_location_slice].physics.location ball_loc = Vector(ball_slice.x, ball_slice.y) agent.line(ball_loc, ball_loc + Vector(z=185), agent.renderer.white()) ball_loc.y *= side(agent.team) if ball_loc.y < -2560 or (ball_loc.y < agent.ball.location.y * side(agent.team)): ball_loc = Vector(agent.ball.location.x, agent.ball.location.y * side(agent.team) + 640) distance = 1280 target = Vector(y=(ball_loc.y + distance) * side(agent.team)) agent.line(target, target + Vector(z=642), (255, 0, 255)) target.x = (abs(ball_loc.x) + (250 if target.y < -1280 else -( 1024 if abs(ball_loc.x) > 1024 else ball_loc.x))) * sign( ball_loc.x) self_to_target = agent.me.location.dist(target) if self_to_target < 250 and ball_loc.y < -640 and agent.me.velocity.magnitude( ) < 100 and abs( Vector(x=1).angle2D( agent.me.local_location(agent.ball.location))) > 0.1: agent.push(face_target(ball=True)) else: self.goto.target = target self.goto.vector = agent.ball.location self.goto.run(agent, manual=True) if self_to_target < 500: agent.controller.boost = False