Cataclysm 2

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

Anonymous asked: When there will be limited visual in the future? like you only see in front of the you, and any where else will be covered by fogs, unless you turn around direction, and other monster and people will have limited visual too? so the sneaking will be lot easier?

Anonymous asked: First off, thank you for responding to my question regarding updates/stability/modding. I just finished reading over your ideas about skills and books. One route to go is that if a skill is unlearned you can find and read an introductory book that gives you knowledge about the skill. This would then allow you to to go out and start using it at its basic level. Once you gain some experience you could then find the next level book which would give you knowledge of more advanced uses. And so forth.

I’m not sure I understand your idea.  It seems like a re-wording of the skill cap.  You need to read a book to raise your cap, so you can start using experience to increase it… then later you need to find the next level book, so you can train it higher.  That’s the cap system!  Can you flesh the idea out more, if I’m misunderstanding it?

Anonymous asked: What's up. I'm currently trying to create a 3d clone of the original cataclysm game in UE4, because I thought it would be really fun. Can you give a very high-level, big picture explanation of how you generated the roadways? I.E.: did you use an L-system, or use purely noisemaps? I'm trying to come up with a nice algorithm for doing the roadways myself, but I'm having trouble figuring out which system would give me an easier time.

Sounds awesome!  I’m excited to see what you come up with - let me know once you have anything that’s working or at all interesting, and I’ll repost it here (with your permission of course).

When you say “how I generated the roadways” I assume you mean on the world map, not the player scale.  The player scale generation is simple and boring.

On the world map scale, well, the way it was done in Cataclysm 1 is very different from how it was done in Cataclysm 2.  I don’t know what L-systems or noisemaps are, and a quick google makes me pretty confident I didn’t use either one.

In Cataclysm 1, the first step was to generate a list of points that need to be connected by roads.  The center tile of every city are the most obvious one; also included are special locations (labs, hospitals, etc) and a few points on each edge of the world map (so that roads will lead to neighboring world maps).  Once we have that list of points, we iterate over it; for each point, we find the first point that’s close enough to it; or if no points are close enough, whichever is closest.  For example, let’s say we have 4 points in our list.  We start with point 0, and define “close enough” as 50.  The distance to point 1 is 68; the distance point 2 is 43, so we stop there, even though the distance to point 3 is 28.

One issue with this algorithm is that it doesn’t guarantee that all roads will be connected in a network.  But I was okay with that I guess.

To actually build the road between those two points, we start at one of them - call it the origin.  Let’s say our origin is at (10, 10) and our destination is at (20, 20) - so we need to move north and east.

From our current position, we look at all adjacent (diagonals are not allowed) points.  If one of them is already a road, and is closer to our destination, then we’re done. Otherwise, we randomly pick a tile that’s closer to our destination and move there - keeping track of whether we just moved horizontally (east/west) or vertically (north/south).

We then continue.  At each step, we prefer to continue in the same direction - that is, if our last step was horizontal, then our next step should be too.  There are two exceptions to this rule.  First, once we get in-line with our destination on one axis, we ignore the direction rule.  In our example, once we get to an X-value of 20, we’re going to change our Y-value no matter what - since the X-value is correct, we don’t want to change it.  The other exception is random - on every step, there is a 1-in-12 chance that we’ll switch from horizontal to vertical, or vice versa.

Finally, if we ever hit a river, we just continue across it in a straight line until we reach the opposite bank.  This is occasionally problematic; there’s no check for how long that will be, so if we hit the river parallel to its general direction, we could wind up with a very long bridge.

This algorithm is riddled with problems.  It’s not very interesting, it doesn’t handle problems (like getting cornered somehow) very well, it may hit a road and stop without actually connecting to our destination, and we wind up with an unrealistic zig-zag structure, that never doubles back or curves around stuff.

Cataclysm 2 has a much better solution.  It uses A* pathfinding.  If you’re not familiar with it, A* is an algorithm that checks a lot of possible routes, and uses whichever is the shortest.  This means we’re guaranteed to always wind up with a successful, often interesting, path.

To make the path more interesting, each world terrain type has a variable called road_cost.  This variable represents how much we want to avoid building a road on that terrain.  Our A* path multiples each step by the weight.  So a path that’s 10 tiles long, and each tile has a weight of 5, is actually better (total score: 50) than a path that’s 5 tiles long, and each tile has a weight of 12 (total score: 60).  Some examples here are fields - cost 100; beach - cost 110; forest - cost 150; swamp - cost 200; river - cost 500; and road - cost 1.

This produces roads that curve around small forests and swamps, but goes through large forests directly.  Forests often have patches of field inside, little clearings, and that makes roads more interesting as they’ll curve a bit to take advantage of the field.  Our roads will double back and serpentine as they move, all in fairly-realistic way.  The ultra-low road_cost of roads themselves means that when building a road, we’ll use pre-existing roads IF they take us closer to our destination.  And once we get close to our destination, we’ll branch off from the existing road to create a new one.

So all in all, I’d strongly recommend using Cataclysm 2’s A* based algortihm.  Good luck!

New skills plan

So I’m working on fleshing out skills - what skills they are, how they work, how you improve them, and so on.

In Cataclysm 1, we had skills books. You could read a skill book to improve the related skill, up to a limit. A basic book would improve your skill up to level 3; then once you found an advanced book, you could improve it up to 7, etc. You could, of course, also improve the skill by using the skill (provided you had some XP).

This was kinda neat, but grindy (you spent a lot of time hitting “Read mechanics book, Read mechanics book” again and again). It was also a high value (free skills without needing XP!) for near-zero risk or expenditure (you’d get hungry & thirsty while reading but that’s it).

I really want to keep books in Cataclysm 2. It’s good flavor, and provides some incentive for high intelligence. But they clearly need an overhaul. So here’s the plan I’m considering; thoughts/suggestions/well-thought-out criticism is welcome!

In C2, I’m going to divide skills into two types: Applied and Mental (or Theory, or…?)

Applied skills are things like firearms, melee, dodge, etc. You are free to improve these as much as you like by spending XP. To recap a previous post, this is done manually, NOT by using the skill.

Mental skills are things like computers, mechanics, first aid, etc. These are also improved by manually spending XP. However, each one has a cap. The cap starts at 1 + Int/5, so for an Int 10 character, it’s 3; for Int 17, it’s 4. Once your skills level hits the cap, that’s it - no more improving the skill.

The skill cap can be increased in two ways: finding an NPC who will train you, and reading a book. Any NPC whose skill level is higher than yours can train you. They’ll be willing to train you if you’re allied, they owe you a favor, you pay for training, or you coerce them into it. Once you’re trained, your base cap is increased by 1 permanently.

Books change your cap to a certain level, as long as you’re carrying them. This bonus may be improved by Intelligence. There’s still different levels of books. For instance, the book “Mechanics 101” changes your cap to 4 (5 with Int 14 or more). “Advanced Mechanics” changes your cap to 7 (8 with Int 14 or more, 6 with Int 7 or less). “The Art of Engineering” requires Int 12, and changes your cap to 12 (14 with Int 15 or more). There’s not much need for a mechanics skill higher than that, but to improve it further you’ll need to find the rare “Applied Quantum Dynamics” which removes the cap altogether, provided your Intelligence is at least 13.

This is just a rough draft of the idea. I like the idea of the bonus always applying when you’re carrying the book (or it’s nearby). This eliminates grindy/boring reading altogether, and encourages a personal library stash.

However, I’m a little uncertain about how it will play. It basically makes “Mechanics 101” totally useless once you find “Advanced Mechanics.” I might instead make books provide a permanent increase to your cap once you sit down and read them. I will, of course, make reading less tedious; a single “Read Book” action would give you +1 to your cap, so you’d only have to read it a few times.

Anonymous asked: When you finally have a stable (ish) release for public testing, how often can we expect updates and/or new releases. Hopefully it won't be like DDA where there are like 1,000 new experimental builds every day injecting a ton of fluff and nothing stable. I have not been keeping up with the development of this game as I would like to but I am assuming you will support mods for CATA 2. Having tons of new updates every day of so makes it a pain, in my experience, to mod anything worthwhile.

Take a look at my commit history at https://github.com/Whales/Cataclysm2/commits/master - that is pretty indicative of how often I’ll update, and what the updates will look like.  Also remember that I occasionally take a break for 1-8 weeks at a stretch.

I’ll definitely make a concerted effort to have a stable, well-balanced release every few months or something.  The majority of updates will be feature-centric, not content-centric, so you don’t have to worry about fluff.

Cataclysm 2 is entirely (well, almost) data-driven.  This means that making a mod for the game - say, a total conversion to a medieval world with dragons, orcs, castles, and no trace of modern towns / technology - is possible without writing a single line of code.  So that kind of modding will definitely be supported and encouraged.  Adding content to the normal game as well.  Everything is backwards/forwards compatible, including save files, so no matter what updates I make to the game, content mods will remain valid, as will your old saves.

Code-mods are also encouraged, but before merging them into the main game I’ll definitely vet them carefully.  I would recommend writing a mod against the stable release, then later on merging it in.

Anonymous asked: When you say spawns will move and that you can never clear a space, does this mean it will be possible for enemies to spawn inside your house?

no it means that you won’t be permanently safe once you kill zombies in/around your house - they’ll still keep showing up and attacking

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.

Hooray

… 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 https://github.com/Whales/Cataclysm2/blob/master/data/mapgen/ocean.map 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!