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);
}

View file

@ -3,6 +3,7 @@ Version 1.0.7.1
- Nipple size/transition system rewritten to be simpler under the hood. Should work with existing saves, but you might find sizes to be different, especially for very large or very small breasts.
- Identical twins conceived after this update will have identical sex part sizes, properties, etc. upon being born.
- Replaced HugsLib-based scheduler with normal ticking. This should reduce some 'phantom cycle' bugs.
- Redone calculation to determine low eggs remaining. This should cause climacteric to be applied at a more appropriate time in the pawn's life, especially for those with very long cycles.
- For modders:
- The function Hediff_MultiplePregnancy.ProcessIdenticalSibling is called on every identical sibling when born except the first. Any race-specfic genetic properties can be patched in there.
- Any mods that add comps to RJW parts should copy what they need to on a postfix to Hediff_MultiplePregnancy.CopyBodyPartProperties, e.g. how menstruation itself does in that function.