Another walkaround would be to
The AI’s send “There is an AI alive” message to the player all the time (use Always->Skip to skip a few frames, no need to do it every frame).
Now, the player has a property “Everyone dead” , that he increments automatically every frame
(or every other frames, with Skip as well).
But every time he receives “There is an AI alive” from AI, he makes “Everone dead” back to zero.
Now, when all AI are dead, he will stop zeroing “Everyone dead”, so it will eventually become
larger than, say, 10.
So if “Everyone dead” becomes sufficiently large, it should mean that there are no AI’s left
to send the “There is an AI alive” message.
This is how I would do it. The downside is that once they are all dead, it takes some time for
the player to realize that. But that is not necessarily bad, as the game might go on for a couple
seconds and then change scene to Victory! or whatever needs be done.
PS: To clear the AI after a task has been completed, you can do something similar with the
player sending a message to everyone and the AI’s have a counter. When they stop receiving
the message and the counter goes over a value, they endObject() themselves. I suppose it is
possible for the player to send a message to everyone (I do not know for a fact), so it should be