Btw, what happens if goals are not met in the bonus stages? I mean, how can you set up the bonus stage to be cleared or failed, and display an appropiate message? Because the timer ends and it might not allow you to spawn something else, right?
Thanks! I will try to explain, because each bonus work in a different way.
First bonus (doors):
Currently, if you fail, the level simply ends (I should change this in the future; it was the first bonus I programmed).
If you manage to break all the doors (they are obstacles that behave like enemies via script), the next group has an invisible enemy and an entity that displays the victory message and forces the end of the stage.
Second bonus (barrels):
This is another one that should change soon.
The barrels (which have a fixed position in the spawn) are also obstacles that behave like enemies via script. As a "takedamagescript," I'm using a code from Kratus that saves a counter in a global variable, linked to the player's number.
I have an invisible entity—which could be an updatescript—that counts these values and puts them on the signs you see in the video.
The idea here is to do a final count, freezing all players and displaying a message of who won (or if there was a tie). I haven't programmed this yet, but it's easy to execute.
Third bonus (forklift)
This one is more complex. I programmed a custom timer, which allows me to use a different font color, make the number flash when time is running out, and add a sound effect.
If time runs out, this entity paralyzes all players, forces them into a custom lose animation, displays the message on the screen, and forces the level to end.
If you defeat the forklift, it forces the timer to change animation (since it controls everything), which interrupts the countdown, paralyzes all players, forces them into a custom victory animation - I don't use the VICTORY or LOSE animations, displays the message on the screen, and forces the level to end.
Fourth bonus (samurai showdown)
It does everything the forklift bonus does. The difference is that the straw dummies are arranged in different groups, and they have a script that randomizes their position - whether on the ground or in the air.
There are 3 colors, which vary in the amount of HP, with the difference that there is a script in the DEATH animation that detects if the palette is red, since this is the final character that only appears if you defeat all the others.
If it is the red palette, it kills the counter and the level proceeds normally, with the same routine of using an invisible enemy that paralyzes all players, forces them into a custom victory animation, and ends the level.