Hi,
one problem comes from removing the sign to 'target_ang'.

Code:
var target_ang = ang(bbox.pan - my.pan);
if (abs(target_ang) < 45) { // [-45, 45]
   // front
} else if (abs(target_ang < 135) { // [-135, -45], [45, 135]
   if (target_ang > 0) { // [45, 135]
      // left
   } else { // [-135, -45]
      // right
   }
} else { // [< -135][135 >]
   // back
}



if it is only to find the correct animation you might store their names in a TEXT and find its index from the angles.

Code:
TEXT *txtAnim = { string = ("front", "left", "back", "right"); }
...
var animIndex = floor((180 + ang(bbox.pan - my.pan - 22.5)) / 90);
ent_animate(me, (txtAnim.pstring)[animIndex], ...);



Salud!