The idea for the "doom" affect type comes from Thomas Biskup's roguelike Ancient Domains of Mystery. In that game, it's possible for a player to become "doomed" by doing various things like insulting the gods, eating a cute puppy corpse, and so on. Once doomed, all hell breaks loose. It's much worse than the simple "-2 hitroll, can't recall" of a normal curse. It actually causes the fates to conspire against the player, and I attempt to reflect that in this code snippet. It does things like, try to make the player flee in the worst possible direction, try to make equipment damage be as bad as possible, and so on. Its in-battle effects are not a flat formula, but are dynamic so they come up at the worst time: the player's defenses are almost unaffected when the player's at full health, but when the player's at low health, suddenly the doom starts interfering a lot more.
DOWNLOAD THE DOOM CODE SNIPPET