>>30793257So, I'm looking at the part of the code that determines ability, you can check it at line 273. This is about to get a bit technical, so yea.
Line 273 makes a call for gfl2::math::Random::Next(v6[3], 100u), which seems to get the next random value from the generator and put it in a [0, 99] range, including only integers. A guess would be that 100 is an upper bound that can't be reached and u says it's an unsigned integer. Similar function call happened before where 2u was passed instead, and it had a comment saying "50%", so I'd assume this is correct.
It then checks if you're breeding with a ditto, in which case the pokemon to inherit ability from is the first one (non-ditto). Otherwise, it always chooses the female. It then checks and branches control flow based on the parent's ability. From what I understand, 0 is ability 1, 1 is ability 2, and 2 is hidden ability.
If parent has ability value 0, it compares the random value it generated with 80, and if it is smaller, the child inherits ability 1. Otherwise, it gets ability 2. If the parent has ability value 1 however, it compares the value with 20, and then inherits ability 1 if the roll is smaller than 20, otherwise giving it ability 2. This basically proves my intuition on the 80-20 / 20-80 thing was right, it seems.
Now, if the parent has the hidden ability, it checks the random value against 20. If it is smaller, child is given ability 1. It then checks against 40. If it is smaller, child is given ability 2. If it is greater than or equal to 40, child gets the hidden ability.
So effectively, for non-HA parents, the roll is 80-20 for ability 1, 20-80 for ability 2. For a HA parent, the roll is 20-20-60. Other anon that said 20-60-20 was pretty close.
So there you have it, ability inheritance for gen 7 explained.