if(my.state==reachcover)
{
if ((c_scan(my.x, my.pan, vector(360, 60, 5000), IGNORE_ME | IGNORE_FLAG2 | SCAN_LIMIT) > 0) && (you.state == coverplace ))
{
dummy=you;
// ent_turnto & ent_faceto freezes the code till it turns toward target
// ent_faceto(me,dummy.x,1);
// wait_for(ent_faceto);
//it doesn't work too the entity runs toward random directions.
// if(abs(ang(dummy-my.pan)) > 1)
// {
// my.pan += clamp(ang(dummy-my.pan),-5,5)*time_step;
// }
// else // your entity faces now the desired direction
// {
vec_set(a,dummy.x);
vec_sub(a,my.x);
vec_to_angle(my.pan,a);
c_move (my, vector(8*time_step,0,0), nullvector, GLIDE | IGNORE_PASSABLE);
ent_animate(my, "run", my.animation, ANM_CYCLE);
my.animation += 8 * time_step;
if(vec_dist(my.x,dummy.x)<1)
{
my.state=iamincover;
set(dummy,FLAG2);
}
// }
}
}