Eliminate egg if there is an error implanting it.

This commit is contained in:
lutepickle 2023-07-29 14:42:46 -07:00
parent f0c971eba0
commit 0c38513084
4 changed files with 70 additions and 59 deletions

Binary file not shown.

View file

@ -1413,6 +1413,8 @@ namespace RJW_Menstruation
continue; continue;
} }
else if (Rand.Chance(Configurations.ImplantationChance * ImplantChance * InterspeciesImplantFactor(egg.fertilizer))) else if (Rand.Chance(Configurations.ImplantationChance * ImplantChance * InterspeciesImplantFactor(egg.fertilizer)))
{
try
{ {
if (Configurations.Debug) Log.Message($"Implanting fertilized egg of {Pawn} into {parent}, father {egg.fertilizer}"); if (Configurations.Debug) Log.Message($"Implanting fertilized egg of {Pawn} into {parent}, father {egg.fertilizer}");
if (pregnancy != null) if (pregnancy != null)
@ -1471,7 +1473,7 @@ namespace RJW_Menstruation
case Configurations.PregnancyType.Biotech: case Configurations.PregnancyType.Biotech:
if (Configurations.Debug) Log.Message($"Creating new biotech pregnancy"); if (Configurations.Debug) Log.Message($"Creating new biotech pregnancy");
pregnancy = HediffMaker.MakeHediff(HediffDefOf.PregnantHuman, Pawn); pregnancy = HediffMaker.MakeHediff(HediffDefOf.PregnantHuman, Pawn);
if(Configurations.EnableBiotechTwins) if (Configurations.EnableBiotechTwins)
pregnancy.TryGetComp<HediffComp_PregeneratedBabies>().AddNewBaby(Pawn, egg.fertilizer); pregnancy.TryGetComp<HediffComp_PregeneratedBabies>().AddNewBaby(Pawn, egg.fertilizer);
((Hediff_Pregnant)pregnancy).SetParents(Pawn, egg.fertilizer, PregnancyUtility.GetInheritedGeneSet(egg.fertilizer, Pawn)); ((Hediff_Pregnant)pregnancy).SetParents(Pawn, egg.fertilizer, PregnancyUtility.GetInheritedGeneSet(egg.fertilizer, Pawn));
Pawn.health.AddHediff(pregnancy); Pawn.health.AddHediff(pregnancy);
@ -1487,12 +1489,18 @@ namespace RJW_Menstruation
} }
} }
} }
catch (Exception ex)
{
Log.Error($"Error creating pregnancy in {Pawn}'s womb, father {egg.fertilizer}: {ex}");
deadeggs.Add(egg);
}
}
else else
{ {
if (Configurations.Debug) if (Configurations.Debug)
{ {
float implantChance = Configurations.ImplantationChance * ImplantChance * InterspeciesImplantFactor(egg.fertilizer); float implantChance = Configurations.ImplantationChance * ImplantChance * InterspeciesImplantFactor(egg.fertilizer);
Log.Message($"Fertilized egg of {Pawn} failed to implant (chance {implantChance.ToStringPercent()}, father {egg.fertilizer})"); if (Configurations.Debug) Log.Message($"Fertilized egg of {Pawn} failed to implant (chance {implantChance.ToStringPercent()}, father {egg.fertilizer})");
} }
deadeggs.Add(egg); deadeggs.Add(egg);
} }

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest> <Manifest>
<identifier>RJW Menstruation</identifier> <identifier>RJW Menstruation</identifier>
<version>1.0.9.1</version> <version>1.0.9.2</version>
<dependencies> <dependencies>
</dependencies> </dependencies>
<incompatibleWith /> <incompatibleWith />

View file

@ -1,3 +1,6 @@
Version 1.0.9.2
- Prevent repeated pregnancies when some errors occur.
Version 1.0.9.1 Version 1.0.9.1
- Japanese translation for most text by Lokuzt. - Japanese translation for most text by Lokuzt.
- New womb, cum, and fetus graphics by Euldrop. - New womb, cum, and fetus graphics by Euldrop.