Change OvaryPowerThreshold to better handle very long cycles. Also have climacteric severity use an InverseLerp.

This commit is contained in:
lutepickle 2022-08-09 21:02:08 -07:00
parent f19494fd5a
commit 592fcad088
5 changed files with 19 additions and 3 deletions

Binary file not shown.

View file

@ -137,7 +137,22 @@ namespace RJW_Menstruation
{
get
{
if (opcache < 0) opcache = (int)(72f * parent.pawn.def.race.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy);
if (opcache >= 0) return opcache;
// Climacteric will set in 6 (human) years before egg exhaustion
float avglittersize;
try
{
avglittersize = Mathf.Max(Rand.ByCurveAverage(parent.pawn.def.race.litterSizeCurve), 1.0f);
}
catch
{
// Any exceptions in that will have been reported elsewhere in the code by now
avglittersize = 1.0f;
};
opcache = (int)(RaceCyclesPerYear() *
avglittersize *
6f *
(parent.pawn.def.race.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy));
return opcache;
}
}
@ -1035,7 +1050,7 @@ namespace RJW_Menstruation
else if (ovarypower < OvaryPowerThreshold)
{
Hediff hediff = HediffMaker.MakeHediff(VariousDefOf.Hediff_Climacteric, parent.pawn);
hediff.Severity = 0.008f * (OvaryPowerThreshold - ovarypower);
hediff.Severity = Mathf.InverseLerp(OvaryPowerThreshold, 0, ovarypower);
parent.pawn.health.AddHediff(hediff, Genital_Helper.get_genitalsBPR(parent.pawn));
}
}
@ -1391,7 +1406,7 @@ namespace RJW_Menstruation
else if (Configurations.EnableMenopause && ovarypower < OvaryPowerThreshold)
{
Hediff hediff = HediffMaker.MakeHediff(VariousDefOf.Hediff_Climacteric, parent.pawn);
hediff.Severity = 0.008f * i;
hediff.Severity = Mathf.InverseLerp(OvaryPowerThreshold, 0, ovarypower);
parent.pawn.health.AddHediff(hediff, Genital_Helper.get_genitalsBPR(parent.pawn));
GoNextStage(Stage.ClimactericLuteal);
}