One part of my code was a bit like this:
witch=self.findByType("witch")[0]
for i in friends:
if witch:
self.command(i,"attack",witch)
else:
#attack other enemies
However, after killing the witch the allies would just stop and do nothing.
I found that checking the witch’s health made them continue on to the next part after killing the witch
for i in friends:
if witch and witch.health>0:
self.command(i,"attack",witch)
else:
#do next part
In fact, the “and witch.health>0” part was the difference between between winning with bonus and not winning.
I don’t think I had to check the enemy’s health in any other level.
Edit: You’re right, trotod, I did store the witch variable outside of the loop. This wasn’t an issue for me in other levels since I always used self.findEnemies() to get a new array of enemies every step so enemies with 0 health were filtered out.