Only decrement ovary power by eggs actually ovulated, debug log under-ovulations

This commit is contained in:
lutepickle 2023-03-11 10:21:25 -08:00
parent 65b69eaf76
commit c05d8bad79

View file

@ -1595,7 +1595,6 @@ namespace RJW_Menstruation
{ {
estrusflag = false; estrusflag = false;
float eggnum; float eggnum;
int ovulated;
try try
{ {
eggnum = Math.Max(Rand.ByCurve(Pawn.def.race.litterSizeCurve), 1f); eggnum = Math.Max(Rand.ByCurve(Pawn.def.race.litterSizeCurve), 1f);
@ -1610,13 +1609,19 @@ namespace RJW_Menstruation
eggnum = 1f; eggnum = 1f;
} }
eggnum *= ovulationFactor; eggnum *= ovulationFactor;
ovulated = (int)eggnum + eggstack; int toOvulate = (int)eggnum + eggstack;
float ovulationChance = OvulationChance; float ovulationChance = OvulationChance;
for (int i = 0; i < ovulated; i++) 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)(EggLifespanHours / CycleFactor))); eggs.Add(new Egg((int)(EggLifespanHours / CycleFactor)));
++ovulated;
}
ovarypower -= ovulated; ovarypower -= ovulated;
if (Configurations.Debug && ovulated != toOvulate)
Log.Message($"{Pawn} ovulated {ovulated}/{toOvulate} eggs ({ovulationChance.ToStringPercent()} chance)");
eggstack = 0; eggstack = 0;
if (EggHealth <= 0) if (EggHealth <= 0)