A proposal for implementing multistory buildings using existing features

To start off- I’ve done a bit of searching, but wasn’t able to find too much information on earlier conversations about z-levels, multistory buildings, etc. I don’t know how controversial this topic is or how much effort has already been put into some variation on this idea, but I feel like that adding multistory buildings to the game would add a lot to gameplay. I’ve got no idea what any of these proposals would do to performance, game balance, etc. at this time.

I’m a developer by trade but I’m not intimately familiar with the codebase for the CDDA project. Anything below is based on a week or two playing .9+ and a few wandering investigations of the github repository.

My intention is to start a discussion on how currently existing features could be leveraged to add more depth to the game map.

The big thing I think most people could agree on is that to add any sort of z-levels you don’t want to overhaul the current engine or mapgen process. Discarding already existing content due to changes in the engine would also be right out. Underground area generation is simplified because everything can be populated “freeform” and doesn’t require a priori knowledge of the contents of upper or lower z-levels beyond transition points (staircases, manhole covers, etc.) I’ve been thinking on how we could re-use existing systems to expand the world of cataclysm without a massive re-work, and in no particular order here are some talking points:

Proposal 1- where does all this second-story content come from?
Copy z=0 maps to z=1+ for appropriate map blocks after z=0 has been generated. This is similar to the current system for labs, sewers, basements, etc. but will ensure a matching floor footprint. For example, if an “up” staircase exists in a house, copy the dimensions of that z=0 floor and use that to generate the second story. For now lets not worry about things like exterior doors and whether or not people should have kitchens upstairs. This simplifies the map generation process since we already know we have a logical construction footprint. The current JSON map system could also be easily expanded to cover custom upper stories if that’s deemed worthwhile. The immediate impact of this is multilevel buildings (albeit somewhat janky ones) without much development effort beyond adding stair placement logic.

Proposal 2- but what about the massive amounts of data?
Only generate Z>0 map content for appropriate locations. As I understand it, the current system uses a mapblock or chunk system to generate map regions. This proposal is just that a given Z level will not be added to the map unless there is a building with a floor at that level. Tower blocks might end up ~10 levels high, but the adjacent block with a couple houses and a store would not need to be generated above 2 stories. This cuts down on the amount of data to save and process, as the system won’t need to generate and track all the “empty air” above buildings. Areas like forests would remain largely the same.

Proposal 3- what the heck is outside the second story?
Above z=0, exterior map squares (as in not “floor”) adopt the contents, type, and appearance of z=0. I don’t know what this implies in the code, but ignoring the z-level when retrieving square contents seems to make sense. I don’t know if this is feasible, but hey- it’s a proposal.

Proposal 4- The nitty-gritty of interacting with exterior squares above ground
This builds off of (1). Implement air as an area affect/trap that is applied to a map square. A teleport trap, to be precise. I believe this is already available in the current code in the form of a teleporter or explosive trap that displaces objects. When a character, monster, NPC, or item enters a square with the “Open Air” trap, they are teleported to (i,j,z=0) and take some amount of damage as deemed appropriate by the devs. Something like (20-STR)(Zstart-Zend)^2 damage to each zone would imply that a one-or-two story leap is survivable but dangerous but a 3+ story fall is probably deadly. Items take (weight)(Zstart-Zend) damage or something like that, destroying large glass containers and the like. As with other traps, there should probably be a “are you sure you want to walk into open air?” warning and certain items or skills would reduce or negate the effects- similar to wearing rubber boots and walking through spitter acid (that’s a thing, right?). If possible, the trap/template should also restrict retrieving items and exploring the square, so things can only be “dropped” and “viewed”. The trap should also apply a visual modifier to the square (gray background or something) similar to the acid splash or electric cloud effect. The perception requirements to perceive it’s a trap could be set arbitrarily high so that the player doesn’t see “it’s an open air trap” or something like that.

This seems like a nice way to implement falling as it’s easy to understand and still applicable even if there are eventually wacky scenarios like hot air balloons or helicopters or something. By default this could be applied to any map square above z=0 that isn’t “floor”.

Proposal 5- ranged weaponry
Targetable range is not affected by z-level, but accuracy/hit chance is. I’ve not looked at the ranged weapon code, so I’m making the assumption that the range is calculated again based on the map square distance after the fire action has been selected. I would imagine having squares above ground “adopt” the contents of the ground-level square as per proposal (3) would simplify this.

That obviously doesn’t cover everything, but hey- I figure it’s enough to start a conversation on the topic. I’ve been loving this game but I was pretty bummed when I found out office towers only have one story and a massive parking garage below ground. I’d also be more than happy to contribute to seeing this done if it’s something the community thinks is worth tackling.

Thoughts?

We’ve had many, many, disscusions about z-levels, and we’ve never had one from an outside dev. Which is nice, and you should get in contact with the main devs and see what they think about your ideas.

Oh wait, you wanted feedback. I like it! +1 mate.


This is pretty much, word for word, exactly what LazyCat attempted to do.

It doesn’t work well, and it’s incredibly hackish. The trap system isn’t designed to handle it and if you are going to rewrite it significantly in order to handle it you are probably better off just starting work on a new system for Z-levels. And that’s not all, you also run into major problems dealing with anything moving from one level to another, due to other z-levels being offloaded once you aren’t present on them. Also items don’t work well, and simply forcing a duplication on a lower level would consume both memory and time, and runs into difficulties with potential duplication.

Not to put a damper on your suggestions (we always welcome more, and though we may not include many we are always willing to listen to new ones), but trust me, it doesn’t work. I’ve spent plenty of time looking into it along with many other devs, and the current system just can’t handle z-levels that aren’t either on ground level or underground (and even those work really weird fairly often).

Thanks for the feedback, guys!

I’ve also recently discovered that the forum’s search engine is pretty worthless. Google it is from now on.

FunsizeNinja123- Thanks, I’d guessed as much about the previous conversations. As for contacting the devs, is this the appropriate forum? Is there a github forum or something else that’s commonly used?

i2amroy- I wasn’t aware of LazyCat’s efforts, but it looks like whatever happened there was unfortunate for a number of reasons. Based on some Googling my impression is that the situation isn’t something that’s worth discussing here.

w.r.t. the hackishness needed to use the current trap system, what specifically are the failure points? Too many objects needing to be updated? Triggering? Teleporting objects or characters? Interaction with map squares that have traps? Overlays? Logic for trap placement? resetting the things? Doing all of this at once? Keep in mind that I’m not familiar with the code, although I’ll probably take a look at that bit soonish.

Similarly for the duplication issues and map square lookup- It sounds like the root of the problem might be that the current engine only crunches one z-level at a time (the “offloading” you’re referencing), is that correct? It seems like monsters can track up/down stairs, but are things outside of a certain radius just not updated? If so, then yeah, I agree that it’s not worth the effort to try and work around the problem.

If the primary concern is the “duplication” of map tiles, then I would naively suppose that retrieving information for one map square is equivalent to retrieving information for another map square and that the memory and time requirements required to update a “duplicated” square and apply a trap would be no worse than crunching the contents of that square if it was updated independently. If it’s something like the game just can’t handle that much data, or that there’s no way to know when a particular square or z-level has been processed or has changed, then again, yeah I can see why it’s not been pursued.

Either way, is there a better place I should be looking for more information on these previous discussions? I’d like to dig through that a bit and I don’t want to waste anyone’s time. I realize that people that are far, far more familiar with the issues and probably more generally competent than I have been over this before, but man- I’d really, really like to be able to clear out a massive apartment building or hotel full of zombies in CDDA.

Thanks!

The biggest failure point is the inability for things to transfer between levels easily and correctly. At the current moment all teleportation and other types of movement are designed to transport only within the same z-level, the only current transportation we have between z-levels is with stairs, and for monsters even that is a horrible implementation (it basically looks around, picks random monsters it thinks might potentially make it to the stairs at some point, and teleports them to the stairs on the level above). This is the same reason why underground levels work, there isn’t transfer from level to level on underground levels, which is why the current system handles them ok (though it’s still not a good implementation by any stretch).

The problem is also further exacerbated by the several different coordinate systems used by the game simultaneously (another large project which we eventually hope to remedy into a single system). And the fact that the trap code has some inefficiencies that are fine in small amounts, but not anywhere near as fine when you have an entire level full of them.

Ideally the best fix (off the top of my head) would be to replace our current system with a 3D array of some sort (there are a few different ways of doing this, obviously) that tracked everything. That would allow for easy reassignment, and would allow the game to have multiple z-levels loaded simultaneously. The biggest problem of implementing this is simply the massive amount of rewriting that it would require. Many, many things reference position at some point or another, and every single one of them would need to be updated to any new system, and was one of the reasons said system was intended for our hired full-time dev to pursue soon (before he mysteriously disappeared :confused: ).

Aha- yeah, that makes a lot of sense. Everything kind of breaks down if it’s difficult or inefficient to determine where things are relative to other squares. I wasn’t aware of the jankiness with routing monsters up/down levels, but that does mesh with the behavior I’ve seen. It sounds like an overhaul of the system is the (painful) way to do things.

Perhaps this could be worked out in stages by way of (temporary) interpreters that map old content to a universal 3D coordinate system?

That would probably work fairly well, it’s just a matter of finding a person who is willing to put in the work to do it (The everbane of open source games :P).

I need to learn whatever language this is in so i can help out. Maybe one day, for now all I can do is HTML.

Hey, thanks for bringing this up, and it is really neat that a Dev-type person from somewhere else showed up here, askin’ and trying to help. Really Neat to see. ^-^

I’d love to see them implement a 3D mapping system. I’d help, but I’ve yet to find a teacher who adequately explains the nitty gritty of Coding itself. I get the concepts, But the coding itself is, well, another language.

+1, for fighting your way out of a 10 story office building as a Cubical Worker.

This would be amazing to have watch towers etc but off course it would be huge amounts of work and I have no idea how to code what so ever :frowning:

Seems to be the common vein of the population here with cataclysm. as i2amroy pointed out with this being an open source game finding dedicated help is almost pure luck.

unfortunately I’m in the same position: desire to help but no coding experience. The least I can do is put my considerable problem solving skills to work and crunch bugs if I see them :slight_smile:

+1 for the idea! its clear and concise, just looks like our code base isn’t up to snuff.

yeah I have zero code skills :(.

But I would love to help test.

Thanks

Thanks for the feedback all!

For anyone that thinks that coding is some insurmountable hurdle- the secret is that half of learning a programming language is just copying and pasting and the other half is Googling things like syntax (i before e except after c… hah) or operators (&&, !=, *(/w)) you don’t understand. If you’ve been helping with the JSON stuff and puzzling over the logic of how some new feature mechanic should work, then you’re already 9/10 there. If you think of it like a traditional (spoken) language, a basic understanding of grammar and a mediocre vocabulary can still get you a chicken sandwich and the location of the nearest bus stop.

Open-source projects like this are also nice because you can fork and make changes and attempt build things yourself without having to worry about breaking everyone else’s fun. There are also going to be people checking your additions before they go in. CDDA even has (much) better documentation than most on how to actually do all this in the wiki and GitHub repo! Start with something like adding a new monster variant (acid-spitting spiders, anyone?) and I’d bet that things’ll click faster than you expected.

Bigger stuff like changing how the game tracks the positions of things on a global scale is certainly a lot more work and know-how required, but hey- gotta start somewhere.

I learned some Lua and JS the above mentioned way but C is just black magic to me…

Python is my only language.

I cannot use C for the life of me.

Thanks for putting the thought into it, it’s unfortunate that we’re constrained the way we are.
I’ll try and be consise, the pain points (performance-wise mostly):
#1 Calculating LOS across multiple levels.
#2 Calculating scent across multiple levels.
#3 having more monsters loaded at once.
#4 having more terrain loaded at once.
They rapidly diminish in difficulty, #1 requires generalizing the shadowmapping code we’re using to 3D, and likely some agressive buffering.
I think the scent might actually be ok, it’s a little complicated, but I think the current solution will easily generalize to 3D, the bigger deal with scent is other stuff like propogating monster scents.
More monsters and more terrain is pretty much a nonissue, we actually have ALL the terrain loaded all the time right now, we just don’t access it all at once, and we can handle thousands of monsters just fine.

The other major issue is handling the UI for displaying lower and higher levels, our rendering isn’t nearly as flexible as df’s, so we can’t really do the same thing.

Hrrrmmm… I’ll have to look into it then. Not now though, Because Having sleep is a Requirement to be alive.