ok i wrote this code for you

action blabla()
{
while(vec_dist(my.x,player.x)>500)wait(1);
while (1)
{
vec_set(temp.x,player.x);
vec_sub(temp.x,my.x);
vec_to_angle(my.pan,temp.x);
c_move (my, vector(5, 0, 0), nullvector, GLIDE+IGNORE_ME+IGNORE_YOU);
wait(1);
}
}
so thats the whole code for let an NPC walk to player if the lpayer is nearer than 500 quants, rotate it to the player and move it to the player. you made it too complicated, its easier than it seems

@Progger
Your code has nothing to do with this topic. this code just set ups an Entity in front of the player and let it rotate with the player.