RimWorld

RimWorld

Better Gene Inheritance
228 Comments
Wyrd 6 Jul @ 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 3 Jul @ 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] 3 Jul @ 1:36pm 
@ShadowX116
Alpha Genes has their own logic for the eggs. Same with stuff like the AG parasitic implantation.
ShadowX116 1 Jul @ 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 30 Jun @ 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] 30 Jun @ 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 29 Jun @ 7:57pm 
And that is why i am
https://steamhost.cn/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] 29 Jun @ 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 29 Jun @ 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 29 Jun @ 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 29 Jun @ 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] 28 Jun @ 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 28 Jun @ 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] 28 Jun @ 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.
cat monke 27 Jun @ 8:33pm 
@Sithril the RIMMSqol mod allows editing existing xenotypes easily.
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=1084452457
Kaedys 27 Jun @ 12:21am 
Unfortunately, editing built-in xenotypes (base game or modded) requires an XML patch, it's not something the game natively allows through the xenotype editor. It's not the most difficult type of XML patch, but it's still more difficult than simply picking the genes you want in the UI.
Sithril 25 Jun @ 5:49pm 
Thanks for the 1.6 update!
Also I see you added the inheritence related genes - many thanks! I love this addition.

On that note: does anyone have a good way to apply these genes to existing xenotypes? (be it Biotech or modded). TY
μuKnew 9 Jun @ 2:22pm 
Does the archite inheritance slider determine the final likelyhood of archite inheritance, or is it affected by the secondary parent modifer? For example, if I have a 50% chance per gene on secondary parent, and a 100% modifer on archite inheritance, does it result in a 50% chance overall, or a 100% chance?

Also, two minor suggestions:
1. Customizable primary parent values for inheritance, as right now inheritance appears to be either: both parents' genes are inherited at 100%, or one parent disproportionately affects the child's genome (100% for primary parent, barring overrides from secondary that are randomly inherited?), based on config.
μuKnew 9 Jun @ 2:22pm 
For example, I would like a 65-75% inheritance from both parents, as 50% would be realistic, but likely to extinct exotic genes over a few generations due to the low population size of a colony. At the same time, I don't want every colonist to have nearly every gene in the colony after a few generations either as a result of, effectively, everybody being related.

2. An FAQ would be nice

That all being said, great job making a mod that fixes a lot of the issues with inheritance in vanilla.
RedMattis  [author] 31 May @ 4:16am 
@GladioSanctus, Vampire
Just set the mod config to inherit 100% of both.

Keep in mind that unless you're using mods that reduce gene costs it may run over budget. Also conflicting genes will always get overwritten (E.g. Strong Immunity + Perfect Immunity)
Kaedys 30 May @ 12:26am 
Sanguophage are a xenogerm type, so they're not inheritable by default. This mod has an option to allow xenogenes to be inherited, so disabling that will prevent the sanguophage genes from being passed on (you can use the sanguophage's Gene Implanter to injected them to a pawn, though). Alternatively, applying any xenogerm to the pawn, even if it has only a single trivial gene in it (I believe even hair and skin color genes qualify, but I'd have to test it), will completely overwrite the xenogenes of the target pawn, erasing their Sanguophage heritage.
Evono 29 May @ 10:28am 
Will sangouphage genes be inherites too ? or can i filter genes ? dont want to end up with hundreds of vampires haha
GladioSanctus 19 May @ 10:47am 
Is there any way to make it so a child will 100 percent inherit both parents genes? Especially if im playing with archite and some genes from mods that makes metabolism cost nothing?
Vampire 16 May @ 4:59pm 
So if I wanted children to inherit 100% of the genes from both parents, what would the ideal configuration for that be?
Kaedys 14 May @ 11:41am 
Ya, the game determines genotype not by the combination of genes, but by very specific logic. A pawn only has a specific genotype if that genotype was directly applied to them (ex. a xenogerm), or if the genotype is considered inheritable (vanilla, only germlines, with this mod, optionally xenotypes as well) and BOTH parents are of that exact genotype. If the parents differ on genotype, even if the child ends up with all of the genes from one genotype and none from the other, the game still considers them a "hybrid". This mod would have to Harmony patch that method (PregnancyUtility.ShouldBeHybrid()) to make the dominant and recessive genes avoid that. I noted that issue here a couple years ago, but it didn't really go anywhere.
Meikai 12 May @ 7:15pm 
Hmmmmm. So dominant genes on a custom germline xenotype will make it so any offspring they have with baseliners will come out with only the custom xenotype's genes... but as far as I can tell, they won't technically be of that xenotype? Like if you made Asari from Mass Effect and wanted them to be able to mate with baseliners, their kids would come out blue with squigly heads but the game would still consider them baseliners instead of Asari.

Is there a way to make it so the dominant gene xenotype is inherited along with everything else when using dominant genes? I mean I can just use character editor to fix any kids who come out baseliner, but it'd be cool to not need to do that.
Momon 5 May @ 10:06am 
But seeing the baby's genetics should already tell you enough.
Momon 5 May @ 10:05am 
Use the character editor mod and change the age of the baby then just load a previous save from before you altered the age of the baby.
Juroguy Johnson 8 Apr @ 12:59pm 
well its from vanilla expanded, which is made by one of the devs. so i dont know.

the problem is i have to wait 30 ingame days for the child too be born so testing it is slow as hell
RedMattis  [author] 7 Apr @ 12:16pm 
@Juroguy Johnson
That is from a mod as well, right? If so it depends on how the modder coded it. :)
Juroguy Johnson 7 Apr @ 11:12am 
thanks for answering btw
Juroguy Johnson 7 Apr @ 11:12am 
does oviparous work? if not then it'll just have too be for more baseline pawns.
RedMattis  [author] 7 Apr @ 8:35am 
@Juroguy Johnson
It doesn't work for things that have their own method for calculating genes, which the chestburster gene does, iirc.
Juroguy Johnson 7 Apr @ 8:32am 
Binary inheritance doesnt seem too work with insectors chestburster gene, babies are a random xenotype but with all of their inherited genes from one parents added onto that xenotype.
Juroguy Johnson 3 Apr @ 1:49pm 
If i use the Xenogene/endogene parasite implanter, and my colonist has binary inheritance, does it guarantee that the child only has their genes and none from the victim?
Hive colonists have a nasty problem of constantly being "Mutants" according too the game due too the 25% gene inheritance from the victim chance.
makeshiftwings 3 Apr @ 1:38pm 
@RedMattis Cool thanks! About the second one, I had a Nephilim from the Nephilm mod that has "Grace" powers that work kind of like hemogen, and the power genes are marked as Required: Grace, but they had a child that had the powers but not the Grace gene.
RedMattis  [author] 3 Apr @ 10:20am 
@makeshiftwings
1. It randomizes between those ranges, but the final result is clamped to 0%-100%.

2. Yes, that is possible. I think I already do that, but I'm not completely sure.
makeshiftwings 3 Apr @ 9:27am 
Hi, I had two questions:
1) In the settings, you can move the "Max percent from second parent" past 100% up to 200%. What does that mean? How would inheriting 200% of their genes do anything?

2) Is it possible to make it so that a child can't inherit genes with "Requires X" unless it also inherits X? For example if you inherit hemogen powers that require hemogen to use but you don't have the hemogen gene, then you can't use the powers but you still pay the metabolism cost for all those useless genes.
kahvipensas 22 Mar @ 9:51am 
Really like the new settings,especially the min%. There used to be too many cases of a baby becoming almost a copy of one parent and getting almost nothing from the other one. Now I can fiddle with the balance (and get on with my slightly deranged breeding experiments)
Vulkandrache 18 Mar @ 7:21am 
The chance is heavily reduced without mods.
But its still possible and the inbred gene exists.

But im sorry, i confused this mod with
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2881479142
which is what i am actualy using.
RedMattis  [author] 18 Mar @ 5:45am 
@Vulkandrache
Probably not no. I only check the parents genes. Though Iirc. Rimworld doesn't normally let pawns that are blood relatives get into relationships to begin with.
Vulkandrache 17 Mar @ 8:20am 
Am i correct in assuming that using this mod there will never be pawns born
with the inbreed gene?
Because im not getting any.
CobaltFox28 14 Mar @ 11:34am 
Nice! I installed the mod anyway but haven't got any new genes yet. Can't wait to try it
RedMattis  [author] 13 Mar @ 12:47am 
@CobaltFox28
Yes, you can mix and match genes over multiple generations.
CobaltFox28 12 Mar @ 9:40pm 
Does this mod allow hybrids to pass on genes?
RedMattis  [author] 12 Mar @ 12:18am 
@Huehuecóyotl
That is correct.

The only exception is mods that add alternate pregnancies (e.g. eggs) since they may have their own logic instead.
Huehuecóyotl 11 Mar @ 10:07pm 
So if every pawn in the game had your mod's Binary gene, it would always force newborns to be a complete genotype selected randomly between the parents instead of a hybrid, no matter the circumstances? A baseliner with binary and an impid with binary would ONLY make baseliner or impid babies, never a hybrid for example? That would be pretty much perfect if that's the case, and a patch to apply the gene dynamically to every genotype would be absolutely amazing. I've been trying to find a mod to do this for literal months.
RedMattis  [author] 8 Mar @ 4:25am 
@C00p3r
Primary would mean that the primary parents genes will always be inherited excepting any genes that ended up overwritten by a randomly migrated gene from the Secondary parent.

@AGrey
This mod patches the event to check the parents. It is possible Alpha Genes is grabbing a random other pawn for Asexual Fission.

@Huehuecóyotl
You' have to patch the "Binary" gene unto every xenotype in that case. It would be fairly simple as a patch operation if you don't me writing one of those though.

@Colossus of Chodes
That is unfortunately a bit beyond the scope of this mod. Vanilla Expanded has a version of that gene that works for endogenes though,
C00p3r 6 Mar @ 10:41pm 
If I breed two xenotypes with Primary Genes and Secondary genes, respectively, will that work like Binary Inheritance with odds skewed towards taking the primary parent's genes?
AGrey 18 Feb @ 10:30am 
I ran into a weird bug with Alpha Genes.

One of the genes allows pawns to reproduce asexually - they just pop out a baby every 25 days.

But for some reason, the baby had all of the genes from its parent, and all of the genes from a completely random colonist who wasn't even in a relationship with the parent (who had actually joined the colony just days prior, so I know for a fact that they didn't have sex at any point)

Not sure if this is from your inheritance mod, or if this is a problem with Alpha genes.