I went down something of a rabbit hole with the end-of-play conditions yesterday. Here's what I've come up with:
Single-lemming LevelsIf the initial lem count is 1, and 1 lemming dies, then the level doesn't end. This works nicely, and obviously works for levels with cloners as well (since, if the lemming is cloned once, and then 1 lemming dies, there is still another lemming in the level to keep it active. If
that lemming then dies, the level should end anyway).
The only thing I'd like to add here is some sort of on-screen message such as "No lemmings remain. Rewind, Restart or Exit" to make it clear that there's a reason play is continuing with no lemmings on-screen.
If this works, the behaviour could extend to any condition where no lemmings remain (including when only zombies remain, which brings us nicely to...)
Only Zombies RemainIdeally, now that we have a Kill All Zombies talisman, we don't want levels to end when only zombies remain. Thankfully, the talisman code includes a CheckForZombiesKilled method which can be used to prevent the level ending unless it returns true. That part ended up being easy enough (although further testing is needed to make sure that it behaves properly in all cases).
However, there is still the problem of what to do when only zombies remain and the user nukes. At the moment, the level ends instantly (only 1 frame of nuke animation is seen; the beginning of the countdown appears above one or two zombies); I've scoured the code and can't find any obvious cause for this, but ideally we want the nuke animation to play out before the level ends, otherwise it looks like an unintentional bug. It's not
massively important, since it's purely aesthetic, but I do want to tidy up as many of these loose ends as possible.
Time Is UpThis has ended up being my favourite one to work on. The 'lems freezing mid-exit' behaviour is gone for now (since I always thought it looked a bit buggy), but I've left the code in comments in case we want to bring it back for any reason.
We still have our "overtime" period, where the time counter starts counting upwards in purple, and no actions taken during this period count towards the level result. But, I've made a few improvements:
Instead of freezing mid-exit, lems now
fully exit
and then re-spawn from the entrance hatch, creating an infinite loop which allows the player to start from the beginning of the level and work their way across again (with all previous skill usage - builder bridges, basher tunnels, etc - still present on the map). To compliment this, the skill count is set to infinite-of-each so that the player can fully experiment with the available skillset (although, at present, it isn't possible to assign skills to
re-spawned lems - not sure why

).
If I can get this fully working, it seems a shame to relegate this behaviour only to levels with time limits (especially since most levels tend to get made without time limits nowadays). It might be worth creating a hotkey which allows the player to activate this mode on the fly, for example if they're stuck on a level. Doing so would obviously have to instantly fail the level (so, if the level is exited during this state, the level would count as a no-solve), whilst pressing the hotkey again could revert to the previous state (before the hotkey was first pressed), so that the level can be completed from there if the player has come up with a solution in the meantime. This is pie in the sky at the moment, but the behaviour itself works perfectly for TimeUp conditions and can therefore be tested for potential usefulness elsewhere.
Plenty to think about.