Well, this is what I'll do, most likely
ENTITY* target;
action enemy()
{
my.skill80=1;//or set to anything you like
...
}
action detect_nearest_enemy()
{
you=ent_next(NULL);
target=you;
while(you!=NULL)
{
if(your.skill==80)
{
if(vec_dist(you.x,my.x)<vec_dist(target.x,my.x))
{
target=you;
}
}
you=ent_next(you);
}
...
}
Careful, though, it's not tested yet...