Along with a reproduction overhaul, better health, combat and death systems are the biggest parts of the planned 0.4.x updates. Though we probably won't see these for half a year at least, it'd be useful to get a proper understanding of how they should work before we start implementing them. It's important to note that we need something close to what the finished mechanics will be, but not necessarily the finished mechanics themselves. We have some preliminary systems in place now, but they're so far from what we eventually want that the game isn't exactly fun. And of course, if it turns out preliminary mechanics are more fun than anything else planned, we can go with those for the final microbe stage.
Health is a difficult concept in the game, because we can't just slap on a hitpoint system (as we're using now). Microbes should run on a simulated metabolism, so their health is dependent on all the elements of that metabolism running smoothly. A poorly designed cell (e.g. one with no mitochondria) should die, just as a starved cell should.
The simplest way I see of fixing this is having a clearly defined death state and having multiple paths lead up to it. A cell bursting is a pretty obvious death state, but even this is complicated for reasons I'll cover later. For most purposes though, let's treat a cell bursting as the moment of death.
I think there's unanimous agreement elsewhere that the player should see their cell's remnants for a few seconds to see why they died, then they're transferred to another member of their species with lower compound reserves. If all members of their species are dead, they go extinct and lose the game. When a cell dies, it spills both its stored and locked up compounds into the environment (either as clouds or in intact organelles), as well as an intact nucleus. If the player collects the nucleus, they receive 25 extra MP next editor session.
So how do you get to cell bursting? Here are a couple of ways I can think of:
Perhaps the most obvious, enemy cells can puncture membranes with predatory pili. How easy should this be? Should an un-upgraded pili be able to rip apart a membrane with a single touch? This sounds a bit overpowered, so I think we need to add some fudge factor here. We could add a membrane health meter which decreases as pili attack it, and more powerful pili do more damage. This system is simple and player-friendly, even if not all that realistic. We can worry about balancing damage levels later.
Cells can evolve progressively stronger cell walls, which in this system would have much larger health meters, at the expense of maneuverability. This adds some complication for other things, discussed below.
I think pili should be player-activated. It probably won't be fun to just passively puncture everything you swim past, so I suggest having a hotkey to extend the pilus and do damage.
We have engulfment in the game now, but it's pretty basic and not player-friendly at all. Eventually we'll want engulfment animations to indicate what's happening, but the mechanics need rewriting too. Engulfing edges, which can be placed on the hexes at a cell's edge like organelles, were proposed a while ago, and I think they're the best option. Each hex of engulfing edge allows a certain size of microbe to be ingested, so longer engulfing edges mean a cell can swallow bigger prey. This also gives a purpose for cytoplasm as a defense, since it makes a cell bigger.
When a cell is ingested, it's attacked by "digestive juices" and bursts, fulfilling the death requirement.
As with pili, engulfment should be player (or AI) triggered, i.e. a cell with an engulfing edge which moves over a smaller cell won't automatically start engulfing it. In the player's case, this would be a hotkey (such as G we currently have for engulf mode) which extends part of the membrane to overlap another cell.
Engulfment can be countered by, among other things, slime. Slime is a special type of agent which is stored in a slime gland. Pressing a hotkey causes a slime gland to burst, disabling the engulfing edges of any cell nearby for a certain amount of time.
Agent production and resistance has kind of been worked out. It's still a bit confusing, but the jist is that agents are randomly generated and have levels of damage against different organelles. For a cell bursting, the organelle will be the membrane. Perhaps the health meter is the same one used for pili?
So yeah, this is the really complicated one. The idea here is that a cell which can't process compounds properly will eventually die due to its inability to regulate the concentration gradients between its internal structure and the water outside. Whatever the exact mechanics, the end goal remains the same: any cell with a sufficiently damaged or ineffective metabolism should die.
ATP is the obvious measure of how effective a cell's inner workings are. If a cell can produce lots of ATP, it's an indication that everything is working correctly. At the same time though, a lack of ATP shouldn't automatically lead to death, since it may be able to find more compounds shortly after and get everything working again. I suggest then we tie this into the organelle health system. The player (or AI) can deactivate organelles at will if they're drawing too much ATP (all organelles, even ATP producers like mitochondria, should draw ATP if they don't have any compound inflow), but doing so will damage said organelles gradually until they collapse completely (this can also happen if an organelle is repeatedly targeted by agents). This basically gives the player a safe mode, where they'll draw less ATP but can't perform certain functions until they produce more. If they do come across more compounds and start processing them, they can revive organelles one by one.
Since agents will tend to target organelles a lot, the player should also be able to spend compounds to heal themselves. I believe this was proposed in the reproduction thread: damage to organelles can be repaired by drawing from compounds locked in storage for reproduction. The amount of compounds required should scale with level of damage.
So how does all this actually lead to death? Even if a cell has every organelle turned off, it will still need to expend ATP to keep osmoregulation in check. With no compound input, cytoplasm, like every other organelle, will draw ATP. If a cell has zero ATP, the ion pumps won't be able to function and the cell will start to expand as water flows in along the concentration gradient. If more ATP is produced, the expansion reverses and all is well. If it isn't, the expansion continues until the cell bursts. This should take a few seconds to give the player a final chance at saving their cell.
However...there is one complication to this whole osmoregulation process. Cell walls.
Slime protects against engulfment, neutralising agents protect against agents, and cell walls protect against pili and osmolysis. Obviously each of these needs to be balanced correctly relative to the attacking method, but they should create a pretty good arms race.
But cell walls do pose a problem as, while everything else mitigates damage, they can prevent death entirely. Agents and pili can damage them like a regular membrane and the cell wall can fail like a regular membrane, but when it comes to osmolysis a cell wall stops the expansion, so a cell will never burst. A cell could shut down every function, but if it has a cell wall it can continue floating along with zero ATP and no ability to move of its own accord until it reaches more compounds. While this is ok, what if they never find other compounds? Is the cell going to drift forever in a comatose state?
This is where the suicide button comes in. The suicide button would always be available anyway, and if the player clicks it they just burst there and then, whatever the health of their cell. If locked waiting to drift into higher compound concentrations thanks to a cell wall, the player can choose whether to wait it out or give up. There are two options for the AI: either the AI is actually written to deal intelligently with this situation, or after a set time with zero ATP the AI commits suicide anyway.
EDIT: Come to think of it, it might be useful to get a prototype of all this done before implementing it into the game.