Set a particular skill or a flag for one of the teams. Let's say that the red team has its flag1 set to on, while the blue team doesn't have it set. Then, make them all scan around; if a model belongs to the red team and detects an entity with its flag1 set to on, it shouldn't attack it (it's from the same red team); otherwise, if its flag1 isn't on, it is from the blue team so it should be attacked. That's how any team-based AI code works.