Have CalculatedImplantChance use the cached ovulation chance

This commit is contained in:
lutepickle 2023-05-02 08:35:39 -07:00
parent e43a50522b
commit a38d81424a
1 changed files with 3 additions and 5 deletions

View File

@ -336,8 +336,7 @@ namespace RJW_Menstruation
// Implant factor will be based solely on pawn age, plus any rollover from ovulation chance
StatPart_FertilityByGenderAge fertilityStatPart = StatDefOf.Fertility.GetStatPart<StatPart_FertilityByGenderAge>();
fertilityStatPart?.TransformValue(StatRequest.For(Pawn), ref factor);
float ovulationOverflow = OvulationChance;
if (ovulationOverflow > 1.0f) factor *= ovulationOverflow;
if (OvulationChance > 1.0f) factor *= OvulationChance;
return Props.baseImplantationChanceFactor * FertilityModifier * factor;
}
else
@ -1642,10 +1641,9 @@ namespace RJW_Menstruation
eggnum *= ovulationFactor;
int toOvulate = (int)eggnum + eggstack;
float ovulationChance = OvulationChance;
int ovulated = 0;
for (int i = 0; i < toOvulate; i++)
if (i < eggstack || Rand.Chance(ovulationChance)) // eggstack comes from drugs and are guaranteed ovulated
if (i < eggstack || Rand.Chance(OvulationChance)) // eggstack comes from drugs and are guaranteed ovulated
{
eggs.Add(new Egg((int)(EggLifespanTicks / CycleFactor)));
++ovulated;
@ -1653,7 +1651,7 @@ namespace RJW_Menstruation
ovarypower -= ovulated;
eggstack = 0;
if (Configurations.Debug && ovulated != toOvulate)
Log.Message($"{Pawn} ovulated {ovulated}/{toOvulate} eggs ({ovulationChance.ToStringPercent()} chance)");
Log.Message($"{Pawn} ovulated {ovulated}/{toOvulate} eggs ({OvulationChance.ToStringPercent()} chance)");
GoNextStage(Stage.Luteal);
}