action player_move()
{
...//movement code
c_scan(my.x, my.pan, vector(360, 180, 200), IGNORE_ME);
}
function got_scanned()
{
my.event = NULL; // the entities will follow the magnet from now on
VECTOR temp_pos;
while (1)
{
if (vec_dist (player.x, my.x) > 100) // the object isn't close enough to the magnet?
{
vec_set(temp_pos, player.x);
vec_sub(temp_pos, my.x);
vec_to_angle(my.pan, temp_pos);
// the entity is oriented towards the magnet here
c_move (my, vector(6 * time_step, 6 * time_step, 6 * time_step), nullvector, GLIDE); //AFTER THAT THE ERROR APPEARS
}
wait (1);
}
}
// the entities that have this action attached to them are sensitive to the magnet entity
action sensitive_ents()
{
my.emask |= ENABLE_SCAN; // make this entity sensitive to scanning
my.event = got_scanned;
}