Presumably, from your initial description of the problem, you know A and B so I would not mess with searching for objects in shapes. You have the two objects.
int GetIsFacingTarget(object oSelf, object oTarget, int nViewArc) {
float fViewArc = IntToFloat(nViewArc);
float AngleOffset = fabs(fabs(VectorToAngle(GetPosition(oSelf) - GetPosition(oTarget)) - GetFacing(oSelf)) - 180.0);
return (AngleOffset < fViewArc/2.0);
}
This routine will tell if oSelf is facing oTarget, with "facing" being defined by the given nViewArc. A simple way to do what you want is to call this twice, switching the arguments, and then check the distance between your A and B. e.g.:
if ((GetDistanceBetween(A,B) <= 15.0) && GetIsFacingTarget(A,B) && GetIsFacingTarget(B,A)) {
// Do stuff
}
There is certainly also a way to write a routine that did the work of both calls to GetIsFacingTarget at once, but I leave that as an exercise for the reader '>