I only skimmed through your code for issues so there may be other things I missed.
First mod:
Your code uses the interpersonal relationship score dict to search for grandparents, which requires that they must either be a parent or sibling to the child or have met the just conceived baby. Given that the latter is impossible, it seems that you assumed that the game considers grandparents to be related to the child, but that is not vanilla behavior and I see no indication that it was added by anyone. Rather than searching blindly for them, it seems like it would be better to simply ask relativesdata who the grandparents are; this code adds a function to achieve this. Note, the forum converts tabs to spaces, so you will need to convert them back if you copy this code (also, check for typos, I haven't smoke tested it).
# attempts to get person's relative, else returns the person # way only supports 'mother' or 'father' func getRelative(person, way): var entry = globals.state.relativesdata.get(person.id) if entry && entry[way] != -1: var temp = globals.state.findslave(entry[way]) if temp: return temp return person
var mothersMother = getRelative(mother, 'mother') var mothersFather = getRelative(mother, 'father') var fathersMother = getRelative(father, 'mother') var fathersFather = getRelative(father, 'father')
Your standard deviation calculations are wrong, and may not work if right. It is missing a + so the result is only the last race. The results do not exclude zero genes so it will be biased with a higher SD such that every gene will tend to be within 1 or 2 SD. The most important issue is that genMedian will tend to be quite low in most cases as the genes are biased towards many smaller genes and few larger genes, thus even if you remove genes further than just 1xSD it will rarely make any changes. People with small gene counts greater than or equal to their larger gene counts will never be affected. This has the interesting effects of purging small genes from people with several larger genes and never purging small genes from nearly purebloods. It's not a bad idea, but I'm not sure it was quite the right approach.
Minor nitpicks:
Large unchanging reference variables like mutationPerGenealogy can be declared in the file scope(outside of a function) to greatly improve the speed of a function (saves a couple microseconds), but more importantly it greatly reduces the size of the function.
For simplicity if you want to limit both the max and min of a value, use clamp(). It changes 5 lines to 1 line in each case, saving 16 lines total. Though currently this appears unnecessary as the values should only vary by up to 22.5 from 50 (27.5 to 72.5), safety is fine.
var mutationWomb = clamp( rand_range(mutationMin, mutationMax), 0, 100 )
genSD can be calculated faster and simpler with the power function.
genSD += pow( person.genealogy[race] - genMedian, 2)
Calculating maxGen and foundMax in separate loops doesn't make much sense as they are used for the same thing, so it is basically repeating the same calculation. Either calculate both for everyone or only for atavism.
"+ -" appears twice more than it should. Though harmless, it looks weird.
Second mod:
This mod has a significant chance of producing errors incorrect results when growing tits, penises, or balls as sizearray and genitaliaarray only contain vanilla sizes and not the aric's mod sizes. Use titssizearray and penissizearray instead. For height it will not break since heightarrayexp adds "tiny", which when not found is -1, plus 1 is zero resulting in "petite" in heightarray, and for asses this will not break since sizearray is identical to asssizearray, but both of these may not be a safe assumptions. Also, spelling out the last items in the size arrays is not as safe as using array.back(), though I don't expect them to change.
The relative check for spontaneous futa transistion would also benefit from using relativedata to find the parents over searching relations for matches. Especially since relatedCheck(person1, person2) only returns 'mother' or 'father' when person1 is the parent of person2, which is the opposite of how you are using it.
Minor nitpicks:
endMutiplayerPerGenealogy is a large unchanging reference variable like mutationPerGenealogy, see above.
toMatture is using 0 and 1 where false and true would be far simpler to understand.
findslave() calls findnpc() if it doesn't find a person, so calling it yourself immediately afterwards is redundant.
Besides the fact that the spontaneous futa transition seems like something that should require a bit of toxicity, it is also lackluster as it does not account for possible penis types by race nor the possibility of futa balls.