Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]

Author Topic: Guide to inducing pregnancies via DFhack?  (Read 8484 times)

Nolimit

  • Bay Watcher
    • View Profile
Re: Guide to inducing pregnancies via DFhack?
« Reply #15 on: September 26, 2017, 02:42:06 pm »

So how does a unit with a father with a different species behave? Do they just take the mothers information?

Haven't tested it myself, but my assumption is that spouse_id used only for relationships and legends, race of a future child is probably taken from mother without checking father at all, and genes used for appearance and colors (maybe with some sort of recombination with mother's genes). So if some random creature is used for spose_id, but for genes used normal genes suitable for mother's race, then child would be just a normal dwarf (or whatever mother's race is), but with some demon/deity/forgotten beast/whatever-else-race father listed in legends mode and relations screen. Again, that's just my assumption, so I would like to see some testing, maybe would do it later myself.

Edit: Just tried it on already pregnant human in my fort. Changed spouse_id to 1 (turned out to be some male dragon) and changed pregnancy timer to 1. Normal human girl was born, but in relationships screen dragon listed as a father. Opened legends with 'open-legends' and that baby is listed as a child for a dragon and her actual mother. Couldn't find the baby herself, but so as other kids of this mother(I don’t think it’s related to my manipulations). In unit.relationship_ids.Father there is some unit id, but no such unit exist (pretty sure game take that id from historical figure of a dragon, where unit_id can be stored even after unit is removed from the memory). With all that it works just fine, next thing I'll try to test is how to predict crashes with appearances and colors.
« Last Edit: September 26, 2017, 04:43:16 pm by Nolimit »
Logged

D_E

  • Bay Watcher
    • View Profile
Re: Guide to inducing pregnancies via DFhack?
« Reply #16 on: September 26, 2017, 04:22:18 pm »

Quote
Haven't tested it myself, but my assumption is that spouse_id used only for relationships and legends, race of a future child is probably taken from mother without checking father at all, and genes used for appearance and colors (maybe with some sort of recombination with mother's genes). So if some random creature is used for spose_id, but for genes used normal genes suitable for mother's race, then child would be just a normal dwarf (or whatever mother's race is), but with some demon/deity/forgotten beast/whatever-else-race father listed in legends mode and relations screen. Again, that's just my assumption, so I would like to see some testing, maybe would do it later myself.

Exactly, yes.  spouse_id appears to be used for legends/relationships screen only.  At the start of the thread I plugged in random hist fig ids into that field, and it seems literally anything works. (Hm, actually, I didn't check what would happen if you plugged in a deity ID.  Since deities are not like other creatures (don't actually exist) it's possible this would cause a crash).

The mother's genes are not recorded anywhere, probably because she is guaranteed to be present when the baby is born.  Eggs, on the other hand, have fields for both the mother and the father's genes.

Quote
So how does a unit with a father with a different species behave? Do they just take the mothers information?

When inducing a pregnancy, you have to provide something to use as the father's genes, it's not automatic.  In my tests, this has been a second copy of the mother's genes (which results in the child being a clone of the mother).

Based on what I now understand about the actual fields involved, attempting to use a different-species-father's actual genes would be a potential crash and overall wouldn't work right (possibly two races could be set up to have compatible appearance modifier lists, in which case perhaps the father's genes could be used directly without issue).  If you want the father's appearance to be reflected in the child's appearance, I think you have to manually translate the father's genes into a valid set of genes for the mother's species.

...

How much of a unit's appearance is heritable in DF?  Color is, but is stuff like height and earlobes and what-have-you heritable?  The genes structure certainly has fields for those aspects of appearance, but is it known whether they actually get used?
Logged
Mods I've done:
Zelda mod-mod, Beta in the Wild DF 47.04
Illithid Empire mod DF 31.25 (update canceled)
Spotter's Guide to Illithids (Genesis mod-mod) genesis 3.19a4 (update canceled)

Nolimit

  • Bay Watcher
    • View Profile
Re: Guide to inducing pregnancies via DFhack?
« Reply #17 on: September 26, 2017, 05:08:58 pm »

What's interesting is that most creatures don't have bp_modifiers except dwarves, elves, humans, goblins, basically those who have more in-depth descriptions. And because of this genes.appearance for most creatures have only 2-3 values, which probably used for body_modifiers and size_modifier, while dwarves and such have 34 or so values. All values can be changed from 0 to 255 without causing crashes. Not sure about array size though. Need to test if creature with only 3 possible modifiers could accept genes.appearance with bigger size without crash.

After testing it a little bit more came to conclusion that main causes of crashes are colors. At this point I have no idea how to determine which color set is acceptable for a creature and which not.
Logged

D_E

  • Bay Watcher
    • View Profile
Re: Guide to inducing pregnancies via DFhack?
« Reply #18 on: September 26, 2017, 06:35:49 pm »

After testing it a little bit more came to conclusion that main causes of crashes are colors. At this point I have no idea how to determine which color set is acceptable for a creature and which not.

Is it not just "if the creature raw for species A has more color options than the creature raw for species B, giving a member of species B the color genes of a member of species A may cause a crash"?

Although...

Possibly also if one creature sets the color of a given tissue layer (cats with white fur on their paws?) and one doesn't (dwarves don't have fur on their hands, let alone a specified color for it), then their genes are incompatible.

Edit: Er, to be completely clear, I'm just speculating there, I haven't tested either guess.
Logged
Mods I've done:
Zelda mod-mod, Beta in the Wild DF 47.04
Illithid Empire mod DF 31.25 (update canceled)
Spotter's Guide to Illithids (Genesis mod-mod) genesis 3.19a4 (update canceled)

Nolimit

  • Bay Watcher
    • View Profile
Re: Guide to inducing pregnancies via DFhack?
« Reply #19 on: September 27, 2017, 04:32:28 am »

Tested it a little bit more. I don't think that interspecies pregnancies will cause crashes at all. I created a small script to make one unit pregnant with genes of another, and no combinations of units caused crashes so far. Animals and animal people always were born with normal for their race colors, no matter what colors are set in pregnancy_genes.colors. As for appearances, animals don't use as many modifiers as regular civ races, and as I said before appearances generally aren't the cause of crashes. But that also means that there is not so much appearance inherited by animals mixed with, for example, dwarves. I think for animals it mostly affects their size modifiers. As for civilized creatures, such as dwarves, goblins, humans and elves (maybe some other races) - I'm pretty sure they can mix just fine. They can inherit colors, all of bp_modifiers, body_modifiers and size_modifier. And by making dwarven child with goblin father you may end up with green dwarven baby (edit: I tested it and so far all of the babies have dwarven variations of skin color, no ash grey color of their goblin father. Maybe I’m just unlucky, though). Dwarven kids of animal fathers also work fine. I even made gila monster demon baby whose father is female gazelle:
Spoiler (click to show/hide)
Father isn't listed only because gazelle isn't a historical figure.

Here's the script:
Code: [Select]
pregUnits=pregUnits or {unit1=nil, unit2=nil}

local unit = dfhack.gui.getSelectedUnit(true)
if unit then
if pregUnits.unit1==nil then
pregUnits.unit1=unit
print("First unit selected")
else
pregUnits.unit2=unit
print("Second unit selected")
preg(pregUnits.unit1, pregUnits.unit2)
pregUnits.unit1=nil
pregUnits.unit2=nil
end
else
print("No unit")
end

function preg(u1, u2)
local mother
local father
local genes
if u1.sex==0 then
mother=u1
father=u2
elseif u2.sex==0 then
mother=u2
father=u1
else
print("At least one unit should be female")
return
end
genes=father.appearance.genes:new()
mother.pregnancy_timer=1
mother.pregnancy_caste=father.caste
mother.pregnancy_spouse=father.hist_figure_id
mother.pregnancy_genes=genes
print("Seed planted")
end
It's for 0.43.05. (may not work in 0.43.03, 'cause if I recall correctly pregnancy related addresses located in unit.relations in that version)
Save it as .lua file in hack/scripts directory. Select first unit, enter script's name in dfhack console. Select second unit and enter it again. Unpause the game and baby would be born. At least one of the units should be female, if both are female then first selected will end up as a mother and second sa a father. Egg laying animals wouldn't make babies using this script, 'cause they require nests to lay eggs.

There is still a possibility that it can cause crashes, I obviously haven't tried it on ALL combinations of races. In my opinion game uses some sort of default sets of colors if pregnancy_genes provide wrong color sets for that race, but I may be wrong.
« Last Edit: September 27, 2017, 11:08:29 am by Nolimit »
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: Guide to inducing pregnancies via DFhack?
« Reply #20 on: September 27, 2017, 05:46:22 am »

You recall correctly about the addresses. They're also differently named. The way I solved it was to use one, and if it wasn't present the other.

Did pregnant gay male couples not work out? I thought from this comment's they do.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Guide to inducing pregnancies via DFhack?
« Reply #21 on: September 27, 2017, 05:59:28 am »

They ought to. You have to change the birthing individual to female for the length of the pregnancy or they miscarry, but it works otherwise.

dorftales

  • Escaped Lunatic
    • View Profile
Re: Guide to inducing pregnancies via DFhack?
« Reply #22 on: September 29, 2017, 01:28:15 am »

Fun fact: I used the script on a rescued human from a goblin civ, and the baby had a goblin-language name (even though the human was no longer a gob civ member).
Logged
Pages: 1 [2]