- self.nextthink = time + think_speed;
-
- float distance = self.pong_length/2 * autocvar_sv_minigames_pong_ai_tolerance;
- distance += autocvar_sv_minigames_pong_paddle_speed * think_speed;
- float target;
- float self_pos;
-
- entity ball = world;
- self.pong_keys = 0;
- while ( ( ball = findentity(ball,owner,self.owner) ) )
- if ( ball.classname == "pong_ball" )
- {
- if ( self.team <= 2 )
- {
- target = ball.origin_y + ball.velocity_y*think_speed;
- if ( ( self.team == 1 && ball.origin_x < 0.5 && ball.velocity_x < 0 ) ||
- ( self.team == 2 && ball.origin_x > 0.5 && ball.velocity_x > 0 ) )
- target = 0.5;
- self_pos = self.pong_ai_paddle.origin_y;
- }
- else
+ this.nextthink = time + think_speed;
+
+ float distance;
+ float next_distance;
+ float min_distance = 1;
+ entity ball = NULL;
+ entity mayball = NULL;
+ while ( ( mayball = findentity(mayball,owner,this.owner) ) )
+ if ( mayball.classname == "pong_ball" )
+ {
+ distance = vlen(mayball.origin-this.pong_ai_paddle.origin);
+ next_distance = vlen(mayball.origin+mayball.velocity-this.pong_ai_paddle.origin);
+ if ( distance < min_distance && ( distance < 0.5 || next_distance < distance ) )