it seem you have not checked out the image.
you dont need any variables, you just check math and set animation:
at the end of the formula you divide by 90 not 45, because you only have 4 directions.
the conditions are the same, in actions replace the 8+ with 4+
and the /45 with /90 and ure good to go.
this formula, as you can see, does not work with the angles of the object, only the pathfinding notes. so it works with rotation disabled.
E: this is, assuming your animation number 0 is idle:
same works for the cows.
idk exactly what you mean with selfblocking cows, but you can give the cows a pathfinding obstacle behavior and set them to impassible.