[1.0][WIP] Real Ruins

Started by mr_teterew, October 27, 2018, 04:25:55 PM

Previous topic - Next topic

mr_teterew


"Everyone is dead or gone. This story is over.
Perhaps someone else will find a use for the ruins of this place."


Have you ever wondered who is that person which will find a use for those ruins?
With this mod it might be any other RimWord player, and you will find ruins of other players' bases as well.

What for?
There is no algorithm that can generate really variable and still sane structures on the map. We can procedurally generate terrain and landscapes, but bases and cities are still just a combination of templates and strict rules which result into maps, resembling each other pretty closely. However there are some people who spend a lot of time constructing a vast variety of colonies. That's all of us. Why should we keep our bases to ourselves? Let's exchange that data to spice up each other's game.

So, how does this mod work?
Each time you save a game or when your colony is dead, this mod uploads your home area snapshot to the server. The snapshot contains constructible floors, structures, furniture, items and roof presence layer. No any user info, just anonymous game data.
Each time you launch the game it downloads up to 50 new snapshots from the server to make sure you won't run out of blueprints during your upcoming game session.
When you generate a new map there is a custom generation step executed, which adds some structures based on those downloaded blueprints. Every blueprint is heavy postprocessed before being placed on the map, so you'll get small deteriorated and scavenged piece of someone's formerly shiny and polished original base.

Compatibility
This mod is compatible with version 1.0. I haven't encounter any conflicts with a bunch of other mods during development. If a blueprint includes items from missing mods, those items are just silently ignored.
You can start using this mod on your existing save games, it will work on your next generated map only, so it can't break existing colony.
RealRuins requires HugsLib to be installed.

Details
I'm not sure I'm doing postprocessing the best possible way, so I'll describe it here in details. Every advice is appreciated.

Postprocessing consists of the following steps:
1) Random circular area of the blueprint is selected and cut out. All following steps will apply to this small area only, because bases usually are pretty big and ruins should be pretty small to keep the game balanced. Average ruin is a circular area 10-20 tiles across.
2) The mod finds all closed rooms in the selected area and marks them as "core". Everything around the core is heavily deteriorated. Everything inside the core have pretty big chance to be kept relatively intact. Also there is a gradient of deterioration chance outside the walls, so floor can extend 3-7 tiles further buildng's outline.
3) After doing initial deterioration, all survived items are sorted by cost to weight ratio and then "scavenging" is simulated. Virtual raiders scavenge most valuable things. Scavenging activity is a random value, but in future I'll make it dependent on distance to the nearest settlement. Each ruins has it's "age" parameter, older ruins experience more "raids" and there are much less valueables left. Hope you'll be lucky enough to once discover freshly abandoned luxury golden room.
4) After simulated raids you will usually get only cheapest items like walls, doors, wooden furniture and probably some former owner's stock like cut stone or cloth. However, there is a small chance that something really valuable will be left after raids. You can also find some food, but most likely it will be some rice on the edge of being rot. Now the mod generously applies dirt, trash, rubble, stone and iron chunks, and makes ruins look really ruined. You'll have to do a really good cleaning and repairing job to put this ruins to use.
5) The last step is adding some surprises. Corpses, traps, mechanoids ambush, whatever. This step is actually not completed yet, so you will most likey find a couple of dead bodies and nothing more.

Plans for the nearest future
1) Dense ruins biome. Will it be ruined city or abandoned base, it should be a biome with a much more ruins presence. With much more loot left and with deadly inhabitants inside, or other scavengers like you, or both.
2) Transferring extended info. One of core concepts of this mod is not only sharing bases, but sharing stories. So I think it should be very nice if not only items are transferred, but also actual colonist from graves or cryptocaskets, art object attached stories and so on.
3) Special events and encounters. I.e. "while travelling you've noticed some abandoned ruins, would you like to investigate", or "your scouts found a small outpost which was abandoned just a few days ago. If you hurry you'll be there first"
4) Road story. A mod based scenario where you forced to constantly move ahead, running from a storm/disease/mystery nanite fog/whatever, so your only way to survive is scavenging ruins, fighting hostile parties, trading with friendly, freeing prisoners, whatever.

And somewhere in between I'll probably do some server interaction optimisations, because now it costs me much more than I've initially planned :)

Links
Steam Workshop release
Download
GitHub

Roolo

Great work! I really love this idea. I tried it already (also uploaded 2 bases) and it's lovely to see player made structures appearing. Moreover, I love the postprocessing, as it really makes the structures appear like ruins. I am getting some errors though that result in the ruin generation process to terminate, resulting in only 1 ruin being spawned in. I'm not getting this error consistently, so I think a certain ruin being loaded results in the error. Here's the full log:

https://git.io/fxHHo

By the way, there's even more potential in this concept when you'd use it for world quests, or faction bases, though I think you already realize that. But I think you made a good choice by restricting yourself to ruins in the first place so you can flesh out the concept.

Morbo513

This sounds really awesome. The only issue I could foresee is that there are a lot of mods which add walls and floors (Eg. Fluffy's Concrete, which I make heavy use of). Is there any way this mod could recognise walls that aren't from core, and replace them in the blueprint/snapshot with any from vanilla?

mr_teterew

Roolo, thans for your input ald logs, I've fixed several errors and now mod should not crash on minified things, animal corpses and rooms spreading  out of bounds. Release link is updated and contains fixed version of the mod.

Morbo513, that's fair enough. Flooar are not crucial though, but walls are needed for all room-based mechanics to work, and closed rooms also have one very important thing inside: fog of war. So I'll definitely try to find a way to degrade custom walls to stock ones. In current blueprints there is no way to determine if an item is a wall or not (if corresponding mod is missing), but in future versions I'll add probably some kind of flag, indicating that this cell should be filled with impassable stone/rubble/whatever in case it can't be instantiated as is. Also this can be applied to fix holes after air conditioners and autodoors are scavenged (as those are first targets for scavengers due to relatively high cost/weight ratio).

Morbo513

#4
Quote from: mr_teterew on October 28, 2018, 02:24:02 PM
Roolo, thans for your input ald logs, I've fixed several errors and now mod should not crash on minified things, animal corpses and rooms spreading  out of bounds. Release link is updated and contains fixed version of the mod.

Morbo513, that's fair enough. Flooar are not crucial though, but walls are needed for all room-based mechanics to work, and closed rooms also have one very important thing inside: fog of war. So I'll definitely try to find a way to degrade custom walls to stock ones. In current blueprints there is no way to determine if an item is a wall or not (if corresponding mod is missing), but in future versions I'll add probably some kind of flag, indicating that this cell should be filled with impassable stone/rubble/whatever in case it can't be instantiated as is. Also this can be applied to fix holes after air conditioners and autodoors are scavenged (as those are first targets for scavengers due to relatively high cost/weight ratio).
Sounds great man. I'm looking forwards to this
Quote- Probably a good idea is to add an "abandoned settlement" biome which will have much more ruins than an average map (and it will be visible on the world map)
especially, would be great for the likes of Zombieland.
I think I'll have to wait until upload/download is controllable before I give the mod a go, last time I checked my rimworld saves folder got pretty hefty so I don't know what this would end up looking like after so and so many additions to the database

Oh, and another question I had; What are the chances of this being co-opted to replace (at least some of) the randomly-generated faction bases? The small assortment of squares gets boring to attack pretty fast.
See: https://ludeon.com/forums/index.php?topic=46416.msg441228#msg441228
I go on about different-sized bases and their relative value, but I'd be just as happy - if not more so, if most/all faction settlements were pulled from player-made bases, while the proc-gen oblongs were reserved for bandit camps quests and the likes.

Of course, this is different to taking a snapshot of a player base and then turning it to ruins, but the infrastructure behind this sounds like it fits the bill

Anyway, I'm about to run the game with the mod now. Would you like me to try use a base with non-vanilla walls and such? Otherwise, I'm gonna go ahead and just use devmode to make some hopefully interesting bases.

Another question, how does map size factor in? If I make a base that spans the largest possible map-size, will it just be cut-off when generated for a user of this mod, or will the map size used to create that colony carry over?
Also, what about terrain? Does this only factor buildings/rooms, or are rivers, mountains etc placed as they were originally?

Ed: So while I was in the process of making such a base, I realised that because of autosave, the database will be getting snapshots of each in-game day of its construction. Is there any way, except disabling autosave, to make the export of the snapshot something that mush be actioned once the creator deems it either completed, or game lost?

mr_teterew

Quote from: Morbo513last time I checked my rimworld saves folder got pretty hefty so I don't know what this would end up looking like after so and so many additions to the database
The mod saves it's data in it's own folder, so it is shared for all games and does not influence saved games. Also now amount of content is pretty small, so it should not take more than a couple of tens megabytes in foreseeable future

Quote from: Morbo513Oh, and another question I had; What are the chances of this being co-opted to replace (at least some of) the randomly-generated faction bases?..
I'm also thinking about this, but it has a couple of difficulties: real player's base can be not defended well enough relatively to stored valuables inside, so I either need to add procedural defences or reduce amount of loot. On the other hand, you do not know is a base well defended or not, so you have to prepare carefully to the raid, and it the base have low defence barriers, it's just a luck for you. Sometimes raiders assault your mining outpost where you don't have much defence, and this seems fair enough for them, why it should be the other way for you as a player?
So I'll wait a bit to get more stored blueprints so I can see if I'm able to develop some algorithm which can select a suitable blueprint to create an interesting assault event.

Quote from: Morbo513Anyway, I'm about to run the game with the mod now. Would you like me to try use a base with non-vanilla walls and such? Otherwise, I'm gonna go ahead and just use devmode to make some hopefully interesting bases.
Yes, of course. Both ways are great. You also should note that each world+map pair has it's unique identifier, so when I update the mod to store additional "wall" flag, it will just overwrite your older blueprint. So if you want to create some blueprints in dev mode, you need to start at least a new map each time you want to add a separate blueprint.

Quote from: Morbo513Another question, how does map size factor in? If I make a base that spans the largest possible map-size, will it just be cut-off when generated for a user of this mod, or will the map size used to create that colony carry over?
Also, what about terrain? Does this only factor buildings/rooms, or are rivers, mountains etc placed as they were originally?
For small ruins the mod just cuts a small piece from a blueprint, so original size does not matter at all. For using blueprint as a complete base prototype the mod should probably select suitable size.
Terrain and landscape is not transferred, but "terrain affordance needed" parameter is accounted. So stone walls won't be spawned on top of a swamp, but if there originally was a bridge, both the bridge and the walls will be spawned on top of the swamp or mud. Ruins intersections with non-original landmarks can create interesting effects like "half-sunken base" or "base buried under collapsed mountain"

Quote from: Morbo513Ed: So while I was in the process of making such a base, I realised that because of autosave, the database will be getting snapshots of each in-game day of its construction. Is there any way, except disabling autosave, to make the export of the snapshot something that mush be actioned once the creator deems it either completed, or game lost?
No problem, the mod will use only the most recent snapshot of your world+map combination.

And by the way I'm really excited to see how snapshots count goes up in the database bucket!

mr_teterew

Ok, so I've added hole covering step, now every "should-be-a-wall" tile, which is missing due to scavengers or not installed mod or whatever is repalced with "crushed stones" tile, which is also impassable and acts basically like a wall.
And a bunch of small fixes: ensuring there won't be doors, hanging in the air, fixing a bug with wooden floors spawned on top of water, etc.
Added traps just to test mechanics.
Updated link in the top post.

Next steps are:
- adding hostile units to some of closed rooms
- adding a way to control traffic and local store size
- gather a bit more data to ensure there are no significant issues

And we probably can call it v1.0, moving to biomes and raiders' bases.
Also I'm thinking about a scenario idea when your task is to reach a certain point on the global map, and you're running from toxic disaster, raiders, mysterios killer-fog, whatever. The point is you can't stay long in one place, so you have to move constantly and your only source of, basically, anything is scavenging the ruins you encounter during your journey. Pretty different experience in the same setting.

raydarken

Fantastic idea and looks brilliantly executed! Your description really covered all the bases, answered questions I had. I'm looking forward to trying this!

Headshotkill

I think a major problem with current faction bases is the fact they're very small. If you manually generate a faction base and use a big plot of land like 4x a regular faction base they start to become more interesting.

TeflonJim

#9
*Edit* Tempted to disregard this. I don't have the best internet connection in the world. It worked this morning and downloaded 5MB of stuff.

I can't seem to get past the timeout when starting this unfortunately. Is the initial download large?

Exception during loading object: System.Exception: timed out
  at HugsLib.Utils.HugsLibUtility+<>c__DisplayClass22_0.<AwaitUnityWebResponse>b__0 () [0x00000] in <filename unknown>:0
Verse.Log:Message(String, Boolean)
RealRuins.<>c:<AmazonS3DownloadSnapshot>g__failureHandler|10_1(Exception)
HugsLib.Utils.<>c__DisplayClass22_0:<AwaitUnityWebResponse>b__0()
HugsLib.Utils.DoLaterScheduler:InvokeCallbacks(Queue`1)
HugsLib.Utils.DoLaterScheduler:OnUpdate()
HugsLib.HugsLibController:OnUpdate()
HugsLib.Patches.Root_Patch:UpdateHook()
Verse.Root:Update_Patch1(Object)


*Edit* Tempted to disregard this. I don't have the best internet connection in the world. It worked this morning and downloaded 5MB of stuff.

Jagerius

Hi!

Great mod, adds much needed variety to the maps, which is always good!

One question though, sometimes I get ruins with quite powerfull stuff in there, like a stack of 150 glitterworld medicine, or the psychic emanator. Maybe there should be a limit to these kind of things? Just a thought!

Morbo513

#11
Interesting, I'm 90% certain the one in the OP image is the one I built, but the doors were plasteel autodoors and there was a normal vanilla vent where the collapsed rocks are.
ed: Here's the full thing for comparison: https://i.imgur.com/IksQTHj.jpg

Will you experiment with different parameters for ruin generation? For example, I think it'd be cool to be able to come across a map that's an entire base, but pretty much just its walls, floors and roofs with every other couple tiles missing, and a miniscule chance of finding any buildings or items leftover. A big base that all the factions got to know about, then looted dry but left otherwise intact, with potential dangers left lurking about. Of course it'd be fairly unbalanced, so there could be an option for the player to always have their initial site clear of ruins.

Quote from: mr_teterew on October 29, 2018, 02:25:16 PM
Also I'm thinking about a scenario idea when your task is to reach a certain point on the global map, and you're running from toxic disaster, raiders, mysterios killer-fog, whatever. The point is you can't stay long in one place, so you have to move constantly and your only source of, basically, anything is scavenging the ruins you encounter during your journey. Pretty different experience in the same setting.
This sounds like a really cool idea

avilmask

#12
Finding masterwork and legendary stuff is a common. Also sometimes you can find a large stack of very expensive stuff.
I think, by default all randomly created ruins  outside of events must not have anything of value, normal quality at best, and mostly low value things.
But I'm looking forward to see events, like "item stash", changed. Infiltrating old ruins for GOOD STUFF is quite more interesting, than a little hut with occasional manhunting ambush.
Having expensive buildings and furniture not in starting location is fine, since they weight a lot most of the times, and hard to carry to the base.

PhantomFav

This mod is great! This should be a vanilla feature!

Quote4) Road story. A mod based scenario where you forced to constantly move ahead, running from a storm/disease/mystery nanite fog/whatever, so your only way to survive is scavenging ruins, fighting hostile parties, trading with friendly, freeing prisoners, whatever.

I think that scenario would be the ultimate method to eliminate the late stage boredom, physiologic of Rimworld. At the moment I'm playing with the Set Up Camp mod ( https://github.com/Syrchalis/SetUpCamp/releases ) and as well as working perfectly with your mod, it should help a lot the player during the migration.

raydarken

Hi mr_teterew, thank you for your hard work on this mod, I'm one of your patreon supporters! I love this mod that much haha.

Anyway, I was interested in making a local backup of my downloaded ruins files but I couldn't find the storage location of the ruins files. I'm using Windows 10, can you let me know where those files are located? The reason I'm interested is because it never hurts to have backups, and in case something crazy happens to the server or if things get messed up by bad uploads somehow I'd like to have the ability to restore a set of ruins which I'm confident are working well for me now.

Thanks!