Simplify ally/enemy logic using bitfields

This greatly simplifies the logic.