I don't quite understand the first bit. Do you want the direction the enemy is moving or the direction from the enemy to the player?
if you're using a behavior they often have a angleofmotion expression or x and y velocity expressions from which you can calculate the angle of motion with angle(0,0,veloctyx,velocityY).
As for calculating a value of 0 to 7 for animation.
This converts a from the range (-180,180) to (0,360):
This rounds the angle to the nearest 45degree angle 0 to 7. The 22.5 is half of 45 and is needed to round correctly.
If you are using the move at angle action to move the object then you should keep track of the direction you moved. Another way is to save the objects position to variables oldx and oldy before you move and calculate the angle of motion with angle(oldx,oldy,sprite.x,sprite.y) after you move.