+ else
+ {
+ if ( ball )
+ target = ball.origin_x + ball.velocity_x*think_speed;
+ my_pos = this.pong_ai_paddle.origin_x;
+ }
+
+ distance = this.pong_length/2 * autocvar_sv_minigames_pong_ai_tolerance
+ + autocvar_sv_minigames_pong_paddle_speed * think_speed;
+
+ if (target < my_pos - distance)
+ this.pong_keys = PONG_KEY_DECREASE;
+ else if (target > my_pos + distance)
+ this.pong_keys = PONG_KEY_INCREASE;
+ else
+ this.pong_keys = 0;
+}
+
+entity pong_ai_spawn(entity paddle)
+{
+ entity ai = msle_spawn(paddle.owner,"pong_ai");
+ ai.minigame_players = ai;
+ ai.team = paddle.team;
+ setthink(ai, pong_ai_think);
+ ai.nextthink = time;
+ ai.pong_ai_paddle = paddle;
+
+ paddle.realowner = ai;
+
+ return ai;
+}
+
+// Moves the paddle
+void pong_paddle_think(entity this)
+{
+ float think_speed = autocvar_sys_ticrate;
+ this.nextthink = time + think_speed;
+
+ if ( this.realowner.minigame_players.pong_keys == PONG_KEY_INCREASE ||
+ this.realowner.minigame_players.pong_keys == PONG_KEY_DECREASE )