[mod idea] Worldmap road building

Started by Loconeko73, December 05, 2018, 12:13:16 AM

Previous topic - Next topic

Loconeko73

Hello fellow Rimworlders,

I was not an early adopter of Rimworld, and followed it for 3 years before I decided to jump in a few weeks ago. It's fair to say this game is everything I expected and more, I'm basically borderline addicted :P

I originally posted this in a Facebook group, but I think this forum is more adapted. Here's the idea : I'd love to be able to build roads on the planet map, like RimRoads did until 1.0 But it seems that mod is incompatible with 1.0 because of changes made to the way roads are managed. I have a fair bit of experience in programming, but not in C# and was wondering if any of you here would be interested in trying to join me for this purpose or if you know of another modder currently working on it.

Though I'm really trying to figure out everything I can by myself, I will run into problems I don't know how to solve. So if any one here can help and would like to see a worldmap road building mod, please reply to this post and let me know so we can start a discussion and hopefully a Github repo.

My rough roadmap for this mod is as follows :


  • <dev mode / proof of concept> On the world map, get a simple action to place a dirt road section, confirm it survives saving & loading
  • Add a caravan job to build dirt road
  • Add types of roads : Dirt road, Stone road , Asphalt road , Asphalt highway. Tweak the movement modifiers of those roads (better roads for faster speed)
  • Add material & work cost
  • Add terrain cost modifier (example : explosives for mountains, more stones for swamps, more work with altitude...) including optionally the ability for roads to allow travel through impassable areas.
  • Add bridge cost modifier
  • Add a com console menu to ask friendly factions for help on the construction of a road
  • <very optional / distant future> Add rail roads & simple trains

Looking forward to your feedback.

5thHorseman

It doesn't seem to be maintained, but RimRoads does a lot of what you're asking for.
Toolboxifier - Soil Clarifier
I never got how pawns in the game could have such insanely bad reactions to such mundane things.
Then I came to the forums.

Loconeko73

Thanks for your answer! Yes, I mentioned RimRoads in my post without a link, which might be why you missed it. That mod breaks in 1.0, so I'd like to try to make my own.

5thHorseman

Oy I did. I read the first paragraph and then scanned the plan, and thought 'That sounds like Rimroads' which I guess makes sense :D

Sadly while I know some C, I'm nowhere near capable of doing anything for this.
Toolboxifier - Soil Clarifier
I never got how pawns in the game could have such insanely bad reactions to such mundane things.
Then I came to the forums.

Canute

You can spend jecrell a coffee, maybe visit him on Discord.
Then your chances for a faster update will increase.

Loconeko73

Of course I could lobby to get RimRoads updated, but I also want to try my hand at modding. It's been ages since I learned a new language, so this sounds like a nice challenge !

For the moment, I can't even get the modding tutorial complete, so we're not off to wonderful beginnings  :P

But I appreciate any support !

Canute

Then you should visit him on discord, i think he will give you some support how to update his mod.

Loconeko73

Thanks, Canute.

I don't think I'm ready to ask for help yet, as I haven't done my homework on a lot of topics that will pop up while I code this. For starters, C# is still very new to me, and I'm still discovering the depth of the RimWorld namespace ! I don't want to reach out to Jecrell & end up wasting his time.

But I have managed to create a skeleton mod with some test stuff that already show up in-game, so once I feel a bit more confident, I certainly will.

In any case, thanks a bunch for your interest  :)

Quote from: Canute on December 06, 2018, 03:39:03 AM
Then you should visit him on discord, i think he will give you some support how to update his mod.

Mehni

Why not attempt to update RimRoads instead?

No need to reinvent the wheel.

Loconeko73

I thought I would try that initially, but I have read the code and I have no idea what's going on in there  ;D

So in order to learn at the same time, I'm starting from scratch. Maybe I'll end up updating RimRoads anyway once I get a better understanding of the whole modding process.

Quote from: Mehni on December 07, 2018, 05:07:06 AM
Why not attempt to update RimRoads instead?

No need to reinvent the wheel.

Loconeko73

Quick update : I am actually slowly making progress, and finding the whole modding thing quite exciting  ;)

Let's see if I can get this done !

Loconeko73


Hello everyone,

For those who have an interest in this project, and are willing to help, here is a quick update & a request :

I now have the ability to create & remove road construction sites on the world map, but I'm struggling to add content to them beyond what's already available in a default WorldObject. I assume I need to use a comp, but the tutorial on the topic is missing the part on how to use them ! If any modder out there reads this and can point me to some code that extends a WorldObject, that would be great. I have checked "Setup camp" already (interesting mod !) but it uses existing comp properties like timeout, not a custom one like what I want to do.

Any help appreciated.

For info, here is my goal to release the first beta :

- Give a caravan the ability to create a road construction site of a certain type (dirt road, stone road, asphalt road) [DONE]
- Give a caravan the ability to remove a road construction site [DONE]
- In the construction site, indicate to which neighbouring tile the road will go to [TO DO]
- In the construction site, save time & materials needed & already spent to complete the road (e.g. 2000 stones , 500 wood , 500 steel , 50 chemfuel , 6000 work) [TO DO]
- Give a caravan the ability to work on a construction site [TO DO]
- Create the road once work is complete [TO DO]

At the moment, my mod would not do a multi-tile road like what RimRoads does. I could add this later but it would involve picking more than just a neighbouring tile, as well as automatically moving the caravan when construction of one tile is done, which is harder. For a Beta, I think it's fine to build roads tile by tile.

Would love to hear some feedback.

Cheers !

Albion

#12
I'm not exactly sure what you're trying to say but if you want to add an additional comp, all you need to do is create your own WorldObjectDef similar to the ones in the core and add some additional comps.
Make sure though that your custom objectDef gets created though.
Anyway, the major benefit of comps is that they have various methods that get called at different times so you can use them as a hook to inject your programming. Just check the base class and see what you can override.
Examples are: postSpawn or something that gets called after initial generation.
And most importantly: tick, which gets called every tick so you can check if certain conditions are met.
You can also check out the code from my Sparkling Worlds mod. I use some comp stuff for the psychic emitter event and a custom world object class for the doctor event.

Edit: the source code is available both on steam and the manual download. Check the events subfolder in the source folder.

Loconeko73

Thanks, Albion !

I think I was way out of my league to try making custom comps from the get go. My issue was much more basic : I didn't understand what needed to go into the ExposeData() method in order to save properties of my custom WorldObjectDef. Now I have & I can save all the information I need about construction sites in the save file.

Comps will still be needed though, for exactly what you describe below : tick to allow me to complete the road once work is done.

In any case, thanks a bunch for taking the time to help a complete noob !  ;D

Kori

Good luck with your project, being able to build roads again would be very nice! :)