Cataclysm 2

A development blog for Cataclysm 2, the sequel to the popular post-apocalyptic roguelike.

Anonymous asked: Hi ! A thing that bugs me (being programmer myself) in DDA is the very small radius around the player where things are actually simulated: By clearing a small zone around your house you would never be in danger ever again. Not to mention fires still burning weeks after you came back to a fire camp you lit earlier. Given that C2 is taking place is a finite island, can we expect proper update of all game agents everywhere or a believable simulation of it ?

Ohhh, DDA.

Yes, I’ll be going back to the way C1 does it which doesn’t have any of those problems.  Spawns move about so there’s no permanently clearing a space, and when you revisit a location after being away for a while, the game quickly simulates the passage of however much time you were away, so fires will go out etc.


… and the leak’s fixed.  Forgot to cache maps of Z-level > 0.  Oops.

God Damn It

So, I “fixed” my runaway memory problem, by periodically caching map data to the hard drive, ensuring that we never have more than a given amount of map data in memory at any given time.

But… it appears that there is an actual memory leak somewhere.  Every time you move from one submap to another - basically from one map to another - it uses up a large amount of memory.  Even if you just move back and forth from one road tile to the one next to it, it’ll consume a few dozen MB each time.  Not good.  So… I’m going to spend a bit of time hunting that one down…

Anonymous asked: Hi, I asked the question about the jagged coast. Thanks for replying so fast! I was actually asking about the coast on the minimap, or the one that the player is on. Is the effect achieved kind of the same way?

Oh!  Nope…. that one is actually just hard-coded, haha.  Or rather, it’s in the .map file for places adjacent to the ocean.  Take a look at and examine adj1_ocean_whales and adj2_ocean_whales.  The x’s at the top will be either deep or shallow water, the a’s are all shallow water, and the b’s provide a bit of randomization by either being “nothing” (which means “don’t change, leave it as-is” so probably sand) or being shallow water.

But yeah, mostly just hand-crafted, not much randomization.  Sorry if that’s a disappointment!

vipches asked: And, whale, If you think keeping smoke is good idea, then mabye you can fix unreality smoke physics, I remember in CDDA's cave, those poison gas just never stop diffusion, soon it covered all over the place, I can't even tell where I supposed to go, the poison gas even covered the stair, so I was trapped, can't even find the way get out, so, whale, if you insist keeping the smoke and gas, then at least you can fix the situation like this, sounds fair enough?

Hmmm, I wasn’t aware that DDA had something like that.  But that kind of thing definitely won’t appear in C2.

Anonymous asked: Hi. So the first thing I noticed after playing cataclysm 2 is the jagged coastline, one thing that really bugged me in the first one. I am making a roguelike now that has a coast that looks very similar to yours but doesn't work quite as well. I was wondering, what file I can find the code for this in? I've looked around and I just cant seem to find it.

This effect was achieved using code first written for Edigotia. You can find it in worldmap_generate.cpp - that file is a bit of a mess, and sorely needs cleaning up and divisions into functions. Look for add_island() or something like that.

The basic idea is centered on a height map. Any heights above 0 are land; anything 0 or below is ocean.

To create an island, we pick a center tile and set its height to 100 (or less, for smaller islands). Next, copy that tile’s height to all adjacent tiles, and do one of the following to each:
Reduce its height by a random number from 0 to 10
Rarely, reduce its height by 0 to 100.
Rarely, don’t reduce its height at all.
Repeat for each adjacent tile.

This has the effect of introducing inlets (areas where the height went from a high number to a low number suddenly) and peninsulas (areas where the height didn’t diminish at all). Both are rare, but appear often enough to have a noticeable impact. Places where neither happens tend to have a steady, slightly-random progression to sea, which creates a slightly jagged coastline.

Finally, anything withing X tiles of ocean gets beachified. For plains, X is 1 and they become beach. For swamps, X is 3 and they become salt marsh, etc.

Play around with the basic algorithm! It’s simple, but very robust and versatile. It can also work in reverse to create lakes, or not placing ocean to create hills.

Let me know if you come up with anything cool!

A note on Triffid Queens

This post is as much a reminder for myself as it is news for you guys!

In Cataclysm 1, there was an enemy called the Triffid Queen.  This “miniboss” was the toughest type of triffid (a type of mobile plant), aside from the real boss of the triffids, which was a building-sized enemy.

The Triffid Queen had a unique special attack.  It would periodically cause plants to grow around it; walls would come crashing down, pavement would be obliterated, and underbrush and small trees would crop up in the surrounding area, potentially piercing the body of the player as they grew.

This effect was, potentially, very interesting.  Rather than being yet another direct damaging attack on the player, it had the power to change the tactical situation drastically, as that wall between you and a swarm of triffids suddenly tumbled down, or your escape route was blocked by a tangle of vines and trees.  It was also a great moment of panic when the player, in the middle of patching up their armor or crafting a new weapon, suddenly had a grove burst down a corner of their safehouse.

Unfortunately, the effect was also very obnoxious.  After the Queen was slayed, the trees would remain, potentially trapping the character where they stood, unless they had a machete or axe handy.  Then it was a slow road to starvation - a very boring death, in a game full of hilarious deaths.

I want the Triffid Queen, or at least something like it, to make a return in Cataclysm 2.  I really think that the tactical implications can turn yet another straightforward fight into something that forces the player to adapt and think on their toes.  But I also want there to be minimal long-lasting effects.  I also want to remove the “cheated” feeling of suffering a totally unavoidable death due to a tree suddenly splitting you up the middle.

To that effect, there will be a few changes.  The most simple one is to nerf the Queen’s attack a bit.  The amount of terrain it can change will be limited, and walls and other sturdy constructions will not come down quite as easily.  Cataclysm 2 gives HP to all terrain, so this will be as simple as reducing the target terrain’s HP by some amount, rather than destroying it outright.  Additionally, the Queen won’t be able to grow a tree directly underneath the player or any other entities.  Underbrush and entangling roots, sure; but the sudden tree attack is gone.

A more complex change involves adding a new low-level feature.  I want the Queen’s terrain changes to be temporary; her trees grow rapidly, but to balance that, they also die off rapidly.  To implement this, I’m going to add a feature to map tiles that says, “In X turns, change to terrain T.”

So when the Queen creates a tree, we change that floor tile to a tree; but we also tell the tile, “In 10 turns, change to a mound of dirt.”  This way, yes, there’s 10 turns of having to deal with a tree in your way, but after that the tree will fade away.  Maybe I’ll even have it leave a few units of wood, as a bonus for crafty players.

The only downside here is that we won’t see evidence of a Triffid Queen fight any more.  It was a neat moment in Cataclysm 1 to be walking along, and suddenly come across a bizarre copse of trees growing out of the middle of a house.  it could even tell a story; you might see a trail of trees leading from one house to the next, where it becomes thicker and gnarlier… and in the center of the dense grove, a dead body (and a bunch of free gear!).

Instead, we’ll get a path of slightly-more-generic destruction; any pavement, floors, or walls that the trees burst through will be left as a mound of dirt.  Yes, it’s still annoying to have part of your safehouse turned into rubble, but in Cataclysm, safehouses are never permanent; something always comes along and wreaks havoc.  Time to rebuild…

New monster features

I’m plugging away steadily, working on new features.  Mostly a lot of bugfixes, or minor features, or enhancements to map files and stuff.  Not too exciting, but important!

There are a couple slightly-exciting enhancements to monsters, one finished and one in progress: sounds and abilities.

Sounds are, well, the sounds that a monster makes.  They come in two flavors - idle and attacking.  All monster types (and monster genera) have a idle_sound_chance and an attack_sound_chance.  Using the ever-popular zombies as an example, their idle_sound_chance is 60, meaning that they have a 1-in-60 chance to make a sound each turn.  That may not seem like a lot, but if there’s 25 zombies in play, there’ll be a lot of sounds happening.

They also have a list of possible sounds; like everything else in Cataclysm 2, this is a weighted list.  For zombies, their idle sound list is “w:10 moan / w:1 gurgle”.  This means that, when idle, they will either moan or gurgle; moans will happen 10 times as often.  Similarly, their attack sounds are “w:10 snarl / w:3 grunt”.  Their attack_sound_chance is 15 - zombies get a lot noisier when they’re chasing something!

Finally, we have a single volume for idle and attack sounds.  Zombies’ idle volume is 8; their attack volume is 14.  This means they’ll attract a lot more attention when attacking.  I considered given each individual sound its own volume, but for consistency and simplicity there’s a single volume for each category.

The idea behind the sound system is to provide a bit of immersion, and give the player non-visual clues about what’s nearby (you might hear moans behind a door - don’t go in!  Or if you hear snarls and barks, there’s probably a zombie fighting a dog in there… so wait until one wins, then finish off the survivor).  Additionally, loud attack sounds will draw the attention of other nearby monsters.  Imagine you’re being chased by a zombie.  Its snarls attract the attention of four more zombies - now you’re really in trouble!  But then, the combined sound of all four of them alerts a pack of wolves to their presence, who scurry in and take our your pursuers.  Pretty awesome.

The other feature, in progress, is monster abilities.  Now, monsters already have ranged attacks, which does a lot for us.  It allows spitter zombies to throw a pool of acid at your feet, smoke zombies to block your vision with thick smoke, and spiked frogs to give you a stabbing with their tongue.  However, I have a bunch of ideas for other things I want monsters to do:

  • Be surrounded by an aura of intense heat, which damages the player and may set fire to terrain
  • Randomly teleport a few squares every few turns
  • Spawn lesser monsters to aid them (think of a large robot sending out small eyebots to track you down, or a slime creature that loses part of its body to create smaller slimes)
  • Alter the terrain around them (like the much-maligned Queen Triffid from C1, which caused trees to grow around it

And so on.  In Cataclysm 1, stuff like this was done quickly and easily - in code.  Every monster with a special ability had bespoke code written for it.  This was quick and easy for me, but hard for others to contribute new monsters with abilities (near impossible if they couldn’t code).  It also led to a lot of reusing of code - bad practice in software.

One of Cataclysm 2’s main features is being as data-driven as possible, and I want to stick to that here.  Sadly, short of adding Lua bindings (which I still might do one day!) there’s really no way around writing code for each monster ability.

But I can abstract it a bit.  This means just writing a single generic “spawn monster” function - and making it flexible.  I write that once, and then in data you can have:

Ability: spawn

Type: eyebot

Verb: launches

Range: 4

Maximum: 3

Child_behavior: search


for a robot that can launch up to 3 eyebots, up to 4 tiles away from it.  The eyebots will be programmed to search out the player.


Ability: spawn

Type: blob

Verb: splits to form

Range: 1

HP_Cost: 10

Child_behavior: attack


for a slime beast that can “split to form a blob.”  The blobs will appear adjacent to their parent, and will attack the player (or other enemies).  There is no limit to how many blobs can form, but the parent monster will lose 10 HP each time they create one.

Other abilities, of course, can be just as configurable.  If you want to add an entirely new ability, it’ll require code, yes; but hopefully I’ll provide a good enough variety (I’m thinking 8 - 10 distinct abilities) that most monster designers will already have what they need.

vipches asked: Also about building,we all know the public places building is definitely have a air duct inside,to prevent the air pollution, and I think that definitely work on game,and definitely reality,or whale,You could just blow off the wall,so the wind to send those smoke and gas out the building,Whale,I know you a busy man, but we both want make the game more Interesting,more fun to catch,I really can't stand will those smoke blocking my sight will enemy close to me,or mabye some goggles can help too?

I can tell you hate smoke… but I’m afraid you’re just going to have to live with it!  Smoke is a deliberately-included challenge, and it really breaks the game up a bit to have your vision blocked so you can only see nearby enemies.  There’s even a smoke zombie, who will fill the area with smoke!

There are options… like heat-vision goggles which let you ignore smoke (at least for warm-blooded enemies… won’t work on lizards!).  And yes, you can blow a hole in the wall or ceiling and the smoke will eventually escape.  But that might not be the best strategy - explosives are expensive, and will draw attention!

Mostly, you’re just going to have to learn to deal with smoke sometimes.  You can also use smoke to your advantage.  If there’s four guys with rifles, and all you have is a shotgun, you’ll be shot before you can reach them!  But if you throw a smoke bomb or two, you can hide in the smoke until you get close enough to shoot them.

vipches asked: many month ago, we have discuss about some idea against smoke and gas, I rembaer I make a idea about vacuum cleaner, but, I make other idea, mabye violence but definitely work, I am start think about physics stystem in the game, If you seen a poison gas in the cave, why not just blow up the the top of the cave to create a hole let the posion gas drain out from the hole so you wont worry any more about gas, and also crush enemy below, a win-win situation don't you think?

Yes, in the current game it will absolutely work to blow a hole in the ceiling to let gases of any kind escape.  It won’t make rubble fall and crush anyone - yet.

I’m also hoping to eventually include a support simulator - so that if you destroy too much of one floor, the ceiling above will fall down and crush anyone inside.