If your obstacles are models your can use c_scan with to find the next one. The event function could look like this:
Code:
ENTITY *nextObs == NULL;

void searchNextObs() {
     if(event_type == EVENT_SCAN) {
          if(nextObs == NULL) {
          nextObst = me;
          } else {
               if(vec_dist(nextObst.x,you.x) > vec_dist(me.x,you.x)) { //if this obstacle is closer to the scanning entity than the saved obstacle
               nextObs = me;
               }
          }
     }
}

action act_obstacle() {
my.emask = ENABLE_SCAN;
my.event = searchNextObs;
}