I am puzzling around with this for quite a while now.
My AI should target the nearest suitable enemy.
The ENTITY of it's enemy is locally stored in the definition "my.enemy".
function find_enemy()
{
for(you=ent_next(NULL); you!=NULL; you=ent_next(you))
{
if ((you != my) && (you.team != my.team) && (you.health>0))// go through all models with the correct specs
{
//somehow determine the nearest suitable enemy
my.enemy = you;//
}
//////////
//somehow repeat the function, so that the AI can find new targets, if one happens to die or if another is closer.
}
}