I wish to disable certain world factions.

Started by Xcallono, June 22, 2020, 05:41:43 AM

Previous topic - Next topic

Xcallono

Hi! I'm a brand new modder whose trying to make a simple mod but has an idea for the mod I'm working on to expand on later.

My mod is about having multiple new starting factions that and accompanying scenarios to allow you to make a new start with a technology level you've never played with before(IE:Spacer or medieval). I also wish to populate the world with factions with such tech levels, but I believe that some players may only want the vanilla factions. I also do not want to split the idea in two, so I'm now left with one good option.

What I wish to accomplish is relatively simple on paper. I simply want to add a toggle button in the mod settings(or maybe world generation?) that allows you to disable the world factions that accompany the mod. How would I go about this? I assume it has something to do with C#, but I have no idea where to start on this idea. Is there a function within the game that lets me disable the spawning of certain elements in world generation, or perhaps enable the spawning of said elements?
I'm a mechanical man.

Xcallono

Normally I wouldn't bump but since I basically reworded the entire forum post, I might as well. Consider the rewriting of the original post as THE content, so I don't break rule 16.

Seriously please help, I have no idea how Rimworld handles factions internally past the def .xml files I created...
I'm a mechanical man.

LWM

Let me rephrase your Subject:  You wish to have an option to NOT add new world factions.

Making mod settings does involve C#.  I made a fancy function that magically makes (boolean - true/false) mod options available as XML hooks - feel free to see what I did (and it's all open source ^.^ ). 

https://github.com/lilwhitemouse/RimWorld-LWM.MinorChanges/blob/master/Source/MinorChanges.cs - setting up mod settings
https://github.com/lilwhitemouse/RimWorld-LWM.MinorChanges/blob/master/Source/PatchOpLWMMC.cs - the patch operation
https://github.com/lilwhitemouse/RimWorld-LWM.MinorChanges/blob/master/Source/Settings.cs#L92 - the magic bit that checks if the option is set.  There's a comment note at the top that mentions what you have to do (okay, it's not "fancy" enough to do it all magically).

If you really want to go "super fancy" Project RimFactory has a crazy-powerful XML->ModSettings engine, but I don't know where to point you at there.

Xcallono

#3
Quote from: LWM on June 29, 2020, 11:51:51 AM
Let me rephrase your Subject:  You wish to have an option to NOT add new world factions.
Yes, this was... What I was after. Sort of... I'm also looking into potentially disabling existing factions(maybe from other mods or just the vanilla ones), hence my weird wording. The only thing I'm really good at is really extending essays past a certain word limit. It's a bad habit I'm trying to kick.
Quote from: LWM on June 29, 2020, 11:51:51 AM
Making mod settings does involve C#.  I made a fancy function that magically makes (boolean - true/false) mod options available as XML hooks - feel free to see what I did (and it's all open source ^.^ ). 
I know coding the options, and I was perfectly fine with that. In fact, I already finished that bit(to a degree, it's functional for testing.) The problem is that I don't know how to prevent spawning a world faction through coding, rather than the C# coding of the option.
Although, thanks for pointing me towards this, this should help me understand the inner workings of Rimworld a bit better.
I'm a mechanical man.

LWM

Quote[already knew settings]
Awesome!

This approach bypassed the entire question of "keep RW from spawning the faction" by keeping them from ever being created in the first place.

Actually - that might be an approach to the vanilla ones, too - you add the factions via XML, right? If so, you could also patch the vanilla ones away.

Xcallono

Quote from: LWM on June 30, 2020, 11:32:17 AM
Actually - that might be an approach to the vanilla ones, too - you add the factions via XML, right? If so, you could also patch the vanilla ones away.
Wouldn't that be the exact opposite of what I want? I don't want to just make it impossible for the faction to spawn under all circumstances, I just want it so that it wouldn't spawn if I enabled/disabled a certain setting in the mod options menu.
Unless there was some way to patch it through a setting rather than just automatically, which might be the case and I may have been blind to that. I'll take your advice and look closer into patching rather than my cursory glance from earlier.
I'm a mechanical man.

LWM

That's what my MinorChanges mod does so much of - applies patches only if a mod setting is set!

Xcallono

Quote from: LWM on July 01, 2020, 11:47:26 AM
That's what my MinorChanges mod does so much of - applies patches only if a mod setting is set!
Oh... That could've been made far clearer. My bad. Thanks for helping me!
I'm a mechanical man.

LWM

 :-[  I knew what I was talking about anyway  ::) ;D  You can find me on discord or message me here if you have any questions I can help with.