RimWorld

RimWorld

Better Gene Inheritance
264 Comments
Simikiel Aug 27 @ 7:18am 
@DeathOnArrival Oh does it? Well there goes my theory then! And no worries, my ass is often smart. Gets me in trouble sometimes!

Thank you for the solid answer though. I'd been playing with the mod active since I'd posted here without issue just dreading something going wrong lol
Torkkar Aug 20 @ 7:58pm 
ok so I'm looking for a mod that STOPS babies being born as Baseliners and thats ALL.

so in my current run I've a Customised VRE-Insector race with a "Queen" type that uses Parthenogenasis to Self impregnate the Chest burst prisoners to get more babies. The Ideologion they follow preffers their custom Xenotype but thats not happening because all the babies are "born" as Baseliners DESPITE being "Purebread" Custon Insectors.

so does this mod stop baseliner babies between custom Xenotypes?
DeathOnArrival Aug 17 @ 7:02pm 
@Simikiel & @Ridigan: Alpha Books actually adds 2 combat abilities and 2 materials that, obviously, need to be patched for CE (the latter must be patched specifically because of power armor, it seems) - you can just look up the patches' xml on CE's github. As for this mod - not to be a smartass about it - since it doesn't add/change any combat -related genes, it doesn't need a Combat Extended patch.
Eclair Aug 17 @ 2:05pm 
@RedMattis Idk whether I'm wrong or not, but I mean, I didn't talk about the percentage of the second parent. I did say that the percentage of the xenogenes inherit was set to 0%. The percentage of the second parent was set to 50% or so of course. But if that was how you took my word at first, then I was wrong. I don't get the reason though. As for VRE - waster problem, that was literally what happened...
RedMattis  [author] Aug 17 @ 1:13pm 
@GoblinEngineer
Noted, I'll make a note to make sure that doesn't happen.

@Eclair
Working as intended then?
The percentage is of the second parent. If you set it to 0% it will be 100% of the first parent.

Meanwhile 100% means 100% of the second parent, meaning all of their genes will be applied (and override any conflicting from the first).

I'm not sure what you're saying happens with the VRE Wasters?
Eclair Aug 13 @ 4:50pm 
Hi, I think I found two bugs. First, with VRE - waster enabled, the xenotype label of baby is not gonna be named like "Hybrid <xenotype> or xenotype". Maybe overridden by the mod? Second, with the probability of xenogenes inherit set to 0, and the primary parent is impid and the second parent is genie for instance, the genes of the birthed baby will be a whole impid genes 100% regardless of the % settings in the game.
GoblinEngineer Aug 12 @ 6:36pm 
Hey RedMattis, I just wanted to let you know I seem to have run into a bug, but no errors are produced from it. I have several Sanguo-hybrid children, but one of them inherited both "Hemogen Drain" and "Bloodfeeder", but did not inherit the "Hemogenic" gene when it's required for both of the other two.
Simikiel Aug 12 @ 5:24pm 
I noticed that too, but while I'm obviously not certain, I'm kinda of the opinion that it's only there because the CE devs have so many of the mods made my Oskar Potocki and Sarg Bjornson that they just listed all the mods that *do* work, even if a patch wasn't needed for them.

Because the CE page says the only mods that need a patch are mods that "add weapons, animals, turrets, new pawn types (such as aliens, robots, or new factions)"
Ridigan Aug 12 @ 4:54pm 
scratch what I said, if Alpha Books needs a Combat Extended patch then maybe be wary for conflicts with Better Gene Inheritance
Ridigan Aug 12 @ 4:44pm 
@Simikiel I'm not RedMattis, but I would hazard a guess and say that Combat Extended shouldn't conflict with this mod since this mod just changes how genes are inherited (unless Combat Extended is such a huge overhaul of the game's various mechanics beyond combat that it also changes how genes are inherited)
Simikiel Aug 12 @ 4:32pm 
Really sorry to be that person who seems to be on every mod page ever, but does this work with Combat Extended? I did my due diligence and looked at supported mods on CE's Github, but this wasn't there, but it was mentioned that some mods do their own patches for it. I know that mods that add pawns need patches, but I don't know about genes.
Neuron Aug 12 @ 8:44am 
@RedMattis
Yup, that was exactly it, thank you!
Haven't really 'played' with the mod yet, new colony, with no kids yet etc, so i haven't seen it in action 😅 And from the description i (mis)understood that inherited xenogenes remains 'xeno' in the babies too.
Ridigan Aug 11 @ 12:33pm 
I see, picking one parent as the base so that the child will resemble the parents rather than drifting towards being a baseliner does make a lot of sense.

also, the idea of a fragile runner and a slow tank giving birth to a glass slug baby that only needs to eat once a week is pretty funny
RedMattis  [author] Aug 11 @ 9:15am 
@Neuron
All the genes will become endogenes/germline for the baby. No babies are born with xenogenes.

Or were you asking something else? I'm not sure if I'm reading the question right.

@Ridigan
Yes, that is correct. The reason for using one parent as the "base" is to make sure the children will gravitate towards one or the other.

Ludeon's 50%/50% chance basically means children will slowly gravitate towards baseliners without genes. If you go back a few pages here I think the was a discussion about this.

Re: high metabolism
Yes, they can end up with a very positive metabolism. This may happen if you for example breed a fragile speedster with a sluggish tank. You may end up with a fragile slug with amazing metabolic efficiency.
Neuron Aug 11 @ 2:20am 
Loving the idea of your mod, just wanted to mention a possible feature - which im not sure if already implemented, from the screenshot it kinda seems so, but it's not mentioned.
Could we (or do we) have the option to make inherited xenogenes "naturalized", meaning inherited xenogenes (if enabled) then become endogenes and part of the pawns 'core' germline.
Ridigan Aug 3 @ 6:14pm 
also is it possible to get a child with a lot of negative effects and an absurdly high metabolism efficiency, since there doesn't seem to be a clamp with the highest metabolism efficiency compared to the lowest?
Ridigan Aug 3 @ 6:11pm 
I see. I'm a little confused by what first and second parents mean, unless I'm misreading this. Correct me if I am wrong, but it seems to say that the mod will pick one parent's genes at random to serve as all the genes the baby will inherit at a base level (called the first parent). Then the second parent's genes have a mod-setting modifiable amount of their genes (10-100% by default) be inherited by the child. Genes shared by both parents are always inherited first, but if it goes over the metabolism limit then genes may be removed to correct the imbalance, preferring genes not shared by both parents.

Anything wrong with that reading? Just making sure I'm reading this correctly.
Kaedys Aug 3 @ 5:41pm 
Base game doesn't even have a concept of "primary" parent. IIRC, in the base game, when a pregnancy starts, the game gives the infant a 70% chance for [-1,1], a 20% chance for [-2, 2], and a 10% chance for [-3, 3], for minimum and maximum metabolic efficiency. It then goes through the genes from each parent (I believe it picks one at random to start, but I'd have to double check). Genes present on both have a 100% chance of being inherited, 50% otherwise, except that if adding a gene would push the pawn outside of the above range, the gene will be skipped instead. So the order the genes are evaluated in also matters for that.
Ridigan Aug 3 @ 2:04pm 
is the default 10-100% gene inheritance from the secondary parent how it is in default Biotech?
Johnny Aug 1 @ 4:28am 
@RedMattis
Thanks, this solution worked.
RedMattis  [author] Aug 1 @ 1:28am 
@Johnny
Try deleting your old mod config for the mod. It has an invalid value in there.

And maybe try resubbing, because I think the key to that one should have changed to avoid that issue.
Johnny Aug 1 @ 1:07am 
Getting error while loading game:

Exception parsing node <inheritArchiteGenes>False</inheritArchiteGenes> into a System.Single:
System.FormatException: Input string was not in a correct format.
[Ref 335A9D4C]
at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey)...
Natrukei [ ] Jul 31 @ 2:05am 
So there might be a certain edge case where there is a possibility that it might take effect but given this mod that would be an unintended behavior?

Lots of ifs an dwhens but I think I got you :p
RedMattis  [author] Jul 31 @ 1:31am 
@Droider
If both parents are of the same xenotype/custom xenotype it should avoid hybrids.

100% second parent's gene could create a hybrid simply due to having a bunch of _extra_ genes neither parent's xeno possesses.

@Natrukei [ ]
This mod replaces all gene inheritance logic in Rimworld for regular pregnancies (stuff like Alpha Genes parasitic implantation not included...).

The two mods you name modify Ludeon's code, but since that never gets run for regular pregnancies they won't do much in those cases.
Natrukei [ ] Jul 31 @ 12:41am 
I don't fully understand, does this mod replace "Offspring Inherit Xenogenes" and "Consistent Gene Inheritance" or work alongside them / does something completely different?
Droider Jul 30 @ 3:47pm 
so, if i set second parent's gene % too 100%, will that mean no hybrids?
RedMattis  [author] Jul 29 @ 12:17pm 
Xenotype/Custom Xenotype/Runtime generated Xenotypes will now be aggressively applied to babies.

Let's end the 2x xenos breeding "Baseliner" babies once and for all! (hopefully).

Also various fallback to try to find a proper icon.
Azathoth Jul 26 @ 11:14pm 
Thanks that's probably a good alternative lol :)
RedMattis  [author] Jul 26 @ 1:04pm 
@Azathoth
Possibly by editing the setting file's xml and then making sure not to open the setting window again. ^_^;;

But if you need less than -99 you probably want one of the mods that just makes all genes cost 0 instead. :)
Azathoth Jul 26 @ 11:56am 
Is there a way to drop the metabolism limit lower than -99?
RedMattis  [author] Jul 24 @ 11:48pm 
The mod will now fake-apply xenotypes if enough genes are shared with a parent of that xenotype. In other words they will show a xenotype instead of the generic "Hybrid" or dreaded "Baseliner" (with a ton of genes).

Also, if not quite hitting that threshold they will be labeled a "hybrid [xenotype]" instead of just hybrid. E.g. "Hybrid Nekomata", "Hybrid Yttakin", ...

@Otoya
It already has settings for metabolism going all the way to 99.

@whitecloud67, abc
Looks like a mod setting is scribed to the wrong value. Probably from an old install of this mod. I tried swapping that save-key to fix it for people in the future.

@ShadowX116
The "Baseliner" issue should be fixed now.
Otoya Jul 22 @ 6:56am 
Can you allow for lower metabolism?
Otoya Jul 22 @ 6:53am 
Wyrd you probably want https://steamcommunity.com/sharedfiles/filedetails/?id=3460624058 - now I a not sure if its compatible, but the problem with this mod is that you don't get the xenotype inherited. This mod does not enforce xenotype, only gene inheritance. In other words, if an Impid has a child with a baseliner, the child could have all the Impid genes but not be considered an Impid xenotype by the game.

That's the problem you currently face with Rimdark, and so do I.
whitecloud67 Jul 21 @ 6:21am 
I just installed Harmony, HugsLib, and this mod and ran the game, and immediately a debug log appeared. I don't know what the problem is, so I'm uploading the log file. https://gist.github.com/HugsLibRecordKeeper/ed0bb342b0a8b85d4c7d457c7393769f
ohluitvaenri Jul 20 @ 3:46am 
@ShadowX116 late response but theres a mod called Cyanobots Genes that has some caste related genes + combined with the custom xenotype exporter mod u can prolly make it work
abc Jul 19 @ 8:21am 
Getting an error on startup, I checked with just this mod and Harmony enabled so it's not a compatibility issue.
Here's the stack trace https://pastebin.com/5DhNF2fW
Wyrd Jul 6 @ 5:36am 
Any possibility of getting a gene that causes the child to either be the other parent or a Baseliner if both parents have the gene? Thinking it would be useful for patching into xenotypes that are applied via other means (specifically thinking of the Rimdark 40k marines here)
ShadowX116 Jul 3 @ 5:53pm 
It also seems to be happening for other endo species I have that don't lay eggs.
In their case, it obeys the dominant gene set, but still labels the babies as Baseliners.
I've heard this might be a Character Editor issue, but switching to the other one (can't remember the name atm) has issues with some mods I have.

Any suggestions there, or am I just stuck reapplying genes thru Character Editor?
RedMattis  [author] Jul 3 @ 1:36pm 
@ShadowX116
Alpha Genes has their own logic for the eggs. Same with stuff like the AG parasitic implantation.
ShadowX116 Jul 1 @ 8:39pm 
Hey so.. I'm running an Ant colony where I have a Queen ant (species) and a Drone ant (species).
The Queen has the recessive gene and set to not inheritable genes (xenogerm).
The Drone has the dominant gene and set to inheritable genes (endogerm).

The idea is that the Queen only produces Drones via eggs (alpha genes I think?), but the game is still throwing "baseliner" babies with genes that stray from my Drone species when they hatch. I've had to resort to using Character Editor to fix the genes.

This mod's settings are the following:
Min % from second parent: 0.10
Max % from second parent: 1.00
Xenogenes can be inherited: 0.00
Archite genes shared by both: (Yes)
Lowest permitted metabolism: 0 (Both parents have flat 0 metabolism)

How do I make the game understand I want the babies to be the Drone species only?
Kaedys Jun 30 @ 1:50pm 
Ya, the other big issue with recessive genes is that, afaik, a mod can't actually control which of several competing genes is actually active in a given pawn without much more invasive patching. So the best the mod could do would be add both competing genes, and let the game's own random selection pick which is active. That would work just fine for your average coupling, since the idea is random inclusion of genes anyway, but falls apart when it comes to Dominant, Recessive, or Binary.
RedMattis  [author] Jun 30 @ 12:56am 
@Vulkandrache
That's the benefit of mods, you can pick the one you prefer. :D

As for: "when overridden by a competing one as that means the gene cant turn up later as the dominant one in one of the descendants."

Ideally the game would track recessive genes to handle such thing, but for the typical rimworld game, where you rarely see more than one or two generations I think this works fine.

No solution is going to end up perfect, and my main goal is always whatever I believe plays and feels best within the scope of a rimworld typical run.
Vulkandrache Jun 29 @ 7:57pm 
And that is why i am
https://steamcommunity.com/sharedfiles/filedetails/?id=3225695697
instead of yours. I dont want a main parent. And i dont want genes to be lost
when overridden by a competing one as that means the gene cant turn up later as the dominant one in one of the descendants.
A simple 50% chance per parent per gene makes for far more interesting long-term breeding.

I do understand your reasoning with mixed Xenotypes failing a 50% roll on either parents gene
and thus ending up with the human version of that bodypart.
But that is a price im willing to pay to get the important stuff passed on properly.
RedMattis  [author] Jun 29 @ 2:36pm 
@μuKnew
Thing is, lost genes isn't... lost genes.

If you lose trotter hands you gain human hands.

If you lose an insectoid mantis head you gain exactly a human's head complete with teeth and all.

If an slime that reproduces via division loses that gene they gain the exact reproduction mechanism of a human.

- - -

If a lost gene meant drifting towards some sort of generic default it would have been different ofc, but that isn't really the case.

For that reason I think the best way to handle "lost" genes is by removing genes that get overridden or fail to carry over from the second parent.

Finally, dramatic non-crippling/killing mutations in nature are rare. It is far more likely to lose a because a gene from another parent took that place.
Kaedys Jun 29 @ 2:15pm 
The exception installed for baseliners also tends to fall down when breeding one race with a lot of genes and one race with only a couple metabolic genes. You end up with the same issue, a 50% chance of the child being essentially 100% the larger-genetic parent, with maybe 1-2 extra or overridden genes.

Instead, I'd recommend an altered algorithm somewhat based on vanilla (but much less restrictive). First, all genes shared by both parents are automatically inherited. Next, the metabolic complexity of the child is computed and compared to the average of the two parents, with some random slush (say +- 20%?). Non-shared genes are randomly added until the child reaches that threshold. All remaining non-shared genes then have a 50% chance of being added (or perhaps, if you want to get fancy, a scaling reduction based on how many were forced in by metabolic threshold). Net is that the average metabolic complexity would tend towards the average of all ancestors.
μuKnew Jun 29 @ 8:11am 
That's kind of true. Technically, as long as you got roughly 50% of the genes from each parent, you wouldn't drift back to baseline, just like in real life (aside from if one parent is a baseliner, but that makes sense). There's no "baseline" human irl because genes don't disappear because we get 50% from each parent. But like I posted a couple weeks ago, 65% makes more sense since then you wouldn't end up with rare genes disappearing as often (for example, because of a xenotype that is rare in your colony not having as many "opportunities" to proliferate).

100% isn't always optimal, though I see your reasoning, because that means that you end up with "yattakin plus" kinds of hybrids instead of "yattakin+impid hybrid" kinds of hybrids.
μuKnew Jun 29 @ 8:11am 
Were you to breed orcs, goblins, and hobgoblins together over several generations, you'd expect a homogenized set of genetics, relatively similar between colonists. What would be produced with the current system would be homogenized, but still broadly representative of each starting xenotype. Effectively, each generation would gain more of the other xenotype's genes instead of "mixing".

100% orc +15% goblin + 15% hobgoblin + 15% goblin... etc, as opposed to ~33% orc ~33% goblin ~33% hobgoblin. While it's possible that some traits may be lost due to the low population size, that can happen in nature as well due to random chance (again, in small populations). The saving grace against that possiblity is that siblings could carry that gene instead.

But anyways, that's just one way of looking at it, and my personal reasoning as to why a primary parent inheritance slider makes sense as a config option.
RedMattis  [author] Jun 28 @ 12:28pm 
@μuKnew
The primary parent will always be 100%, otherwise they'd randomly lose genes.

Losing genes entirely would basically make them drift towards baseliners (remember, no genes at all means you're a basic human), and it doesn't make sense that breeding a bunch of orcs, goblins, and hobgoblins together would eventually result in a human after a few dozen generations.
μuKnew Jun 28 @ 10:40am 
Thanks for the help! Any chance there may be a config option to change the inheritance from the primary parent in the future? Especially if there's a possibility that such a thing could also be configured separately for genotypes with the primary/secondary/binary inheritance genes? (so as to not break single-sex xenotypes)
RedMattis  [author] Jun 28 @ 12:38am 
@μuKnew
It is always 100% if both parents have a gene, assuming there are no conflicting genes.

100% of the primary (randomly picked usually) parent's genes are always applied, but can get overriden by the second parent.

E.g. Pigskin Impid hybrid child may lose strong immuity due to the impid ending up the second parent and hitting the 50% chance to force-transfer weak immunity.