Code:
function AIObject()
{

while(vec_dist(my.x,player.x) > 200){wait(1);}

// player is closer than 200 to me, do something...

}