I've managed to test twins (and quadruplets and quintuplets) and in every case only one child was ever actually born
The quad and quin were from the player, and a slave respectively, and were after I edited the fertilisation process to prevent ghost babies. (if the mother had ovulation type 2, or gave birth to eggs it would count the first 3 children twice.
I have managed to get the birthing of multiple children working though, with the same quad and quin that weren't working before. All 9 children were successfully born. To fix it instead of repeatedly calling the birthing function, I store the birthing mother in the same manor as the baby being born, then at the end of the birthing function right before closing the birthing panel, if the mother has more children to birth I call the start of the function.
There are 3 relevant blocks of code that were changed/moved to make all this work all of them are in the Mansion.gd file.
First I created a new variable right next to the baby variable above the childbirth function that I called birthing mother, it doesn't really matter where the variable is in the code long as it isn't in a function:
...
var baby
var birthingMother
func childbirth(person,baby_id):
...
next in the nextdayevents function right at the start where it checks for pregnant character to give birth, instead of calling the looping function I set the aforementioned birthingMother variable to the mother giving birth then call the childbirth function directly:
...
func nextdayevents():
get_node("FinishDayPanel").hide()
var player = globals.player
if player.preg.duration > variables.pregduration && player.preg.is_preg == true:
birthingMother = player
childbirth(player, player.preg.unborn_baby[0].id)
checkforevents = true
return
for i in globals.slaves:
###---Added by Expansion---### Hybrid Support
if i.preg.baby != null && (i.preg.duration > variables.pregduration || (i.race.find('Goblin') >= 0 && i.preg.duration > variables.pregduration/2)):
if i.race.find('Goblin') >= 0:
i.away.duration = 2
###---End Expansion---###
else:
i.away.duration = 3
i.away.at = 'in labor'
birthingMother = i
childbirth(i, i.preg.unborn_baby[0].id)
checkforevents = true
return
...
finaly at the end of the babyage function after adding the baby to the list of slaves but before closing the panel I remove the newly born baby from the mother and then if there are any more children to be born call the clidbirth function again for the next baby that they are carrying:
...
globals.slaves = baby
globals.state.relativesdata[baby.id].name = baby.name_long()
globals.state.relativesdata[baby.id].state = 'normal'
globals.state.babylist.erase(baby)
birthingMother.preg.baby_count -= 1
birthingMother.preg.unborn_baby.erase(birthingMother.preg.unborn_baby[0])
baby = null
get_node("birthpanel/raise/childpanel").hide()
if birthingMother.preg.baby_count > 0:
childbirth(birthingMother, birthingMother.preg.unborn_baby[0].id)
else:
birthingMother.metrics.birth += 1
birthingMother.preg.is_preg = false
birthingMother.preg.duration = 0
birthingMother.preg.ovulation_stage = 2
birthingMother.preg.ovulation_day = -5
birthingMother = null
get_node("birthpanel").hide()
...
The bolded lines are the lines that I changed/added or moved from the original state.