make front a global variable and check in the enemies action if front==me then you know (for each enemy if he is ment).

Code:
action player(){
   ...
   c_scan(...)
   front=you;
   ...
}

action enemy(){
   ...
   // I was ment by the player
   if(front==me){
     ....  // defend
   }else{
     ....  // attack
   }
}

mercuryus