Moved threat detecting/reacting code around

This should help reduce computational load when horses are around
threats, and will help when I later move this code into an AI behavior
again.