Open door when room cleared

By LadylexUK

I used this in my FPS game Wonderland Attacks. In my game you have various waves of enemies which you had to kill before the door would be unlocked.

There are various ways to do this. If you have a boss that only appears after all the other enemies are killed then you only need to determine if he is dead before releasing the door, something like

WHEN [IWP: boss][is dead]
…WHEN [detect][player] DO [power on]

In Wonderland Attacks I created an object set that contained all the live enemies. The enemy brains contained code like this:

WHEN [once] DO[global] [objset: live enemies][incremented by][me]
WHEN [starting to][is dead] DO [global][objset: live enemies][decremented by][me]

The spawning cube counted the number of waves. So when the waves had reached its highest number and all there were no live enemies the door would open (or be available to open). This worked fine in my game as I would start each wave when they had got down to only 1 enemy from the previous wave still alive. If you want to clear all enemies before each wave there may be a frame where there are no live enemies because you havent spawned them yet, so be careful if you have the door open automatically – just put a countdown timer in your kode between checking the wave and checking the enemy count if this happens.

WHEN [IWP: spawner][numvar:wave][equal to][3][and][global][objset:live enemies][count][equal to][0]
…WHEN [detect][player] DO [power on]

You can also combine this with [or] statements.


Comments are closed.

Website Powered by

Up ↑

%d bloggers like this: