result = path_scan(me, my.x, my.pan, vector(90, 80, 400));
if (result) {movement_enabled = 1;}
path_getnode (my, 1, pos_node, NULL);
vec_to_angle (my.pan, vec_diff (temp_angle, pos_node, my.x));
while(players_health > 0 && players_life > 0)
{
if(my.state == 0)
{
while(1)
{
if(vec_dist(my.x,player.x) < 550 && players_health > 0)
{
my.state = 1;
break;
}
if(froze == 1)
{
break;
}
if(movement_enabled)
{
entity_speed = minv(5, entity_speed + 0.5 * time_step);
ent_animate(my, "frame", my.skill60, ANM_CYCLE);
my.skill60 += 5 * time_step;
my.skill60 %= 100;
c_move(my, vector(entity_speed * time_step, 0, 0), nullvector, IGNORE_PASSABLE | GLIDE);
vec_to_angle (my.pan, vec_diff (temp_angle, pos_node, my.x));
}
dist_to_node = vec_dist(my.x, pos_node);
if(dist_to_node < 10)
{
current_node = path_nextnode(my, current_node, 1);
if (!current_node) {current_node = 1;}
path_getnode (my, current_node, pos_node, NULL);
}
wait(1);
}
}
if(froze == 1)
{
set(my, PASSABLE);
set(my, UNLIT | BRIGHT | PASSABLE);
my.skin = 2;
my.lightrange = 200;
my.ambient = 100;
my.blue = 200;
var counter = total_secs + 15;
while(total_secs < counter)
{
if (vec_dist(player.x, my.x) < 80) // if the player comes close
{
set(my, INVISIBLE);
my.skin = 1;
my.lightrange = 0;
my.ambient = 0;
total_ghost += 1;
break;
}
wait(1);
}
wait(-15);
reset(my, INVISIBLE);
froze = 0;
my.skin = 1;
my.lightrange = 0;
my.ambient = 0;
my.state = 0;
}
}