mirror of
				https://github.com/vegapnk/RJW-Genes.git
				synced 2024-08-15 00:23:31 +00:00 
			
		
		
		
	Fixed PregnancyOVerwrite by only taking into account male fertility
This commit is contained in:
		
							parent
							
								
									991edfdff0
								
							
						
					
					
						commit
						980458e4fa
					
				
					 3 changed files with 10 additions and 26 deletions
				
			
		| 
						 | 
				
			
			@ -153,21 +153,4 @@
 | 
			
		|||
    <biostatMet>0</biostatMet>
 | 
			
		||||
  </GeneDef>
 | 
			
		||||
 | 
			
		||||
  <GeneDef ParentName="BreedingBase">
 | 
			
		||||
    <defName>rjw_genes_pregnancy_overwrite</defName>
 | 
			
		||||
    <label>Sperm Displacement</label>
 | 
			
		||||
    <description>Carriers of this gene can 'overwrite' an existing pregnancy, keeping the progress but effectively replacing the father.</description>
 | 
			
		||||
    <iconPath>Genes/Icons/RJW_Genes_PheromoneSpit</iconPath>
 | 
			
		||||
    <displayOrderInCategory>75</displayOrderInCategory>
 | 
			
		||||
 | 
			
		||||
    <biostatCpx>4</biostatCpx>
 | 
			
		||||
    <biostatMet>-2</biostatMet>
 | 
			
		||||
    <modExtensions>
 | 
			
		||||
        <!-- DevNote: The chance will be multiplied by both pawns' Fertility! -->
 | 
			
		||||
        <li Class="RJW_Genes.ChanceExtension">
 | 
			
		||||
            <chance>0.5</chance>
 | 
			
		||||
        </li>
 | 
			
		||||
    </modExtensions>
 | 
			
		||||
  </GeneDef>
 | 
			
		||||
 | 
			
		||||
</Defs>
 | 
			
		||||
| 
						 | 
				
			
			@ -60,7 +60,7 @@
 | 
			
		|||
    <biostatMet>-1</biostatMet>
 | 
			
		||||
    <modExtensions>
 | 
			
		||||
      <li Class="RJW_Genes.MultiplierExtension">
 | 
			
		||||
        <multiplier>20.0</multiplier>
 | 
			
		||||
        <multiplier>15.0</multiplier>
 | 
			
		||||
      </li>
 | 
			
		||||
    </modExtensions>
 | 
			
		||||
  </GeneDef>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,8 +40,6 @@ namespace RJW_Genes
 | 
			
		|||
            if (!pawn.IsPregnant() && !partner.IsPregnant())
 | 
			
		||||
                return;
 | 
			
		||||
 | 
			
		||||
            ModLog.Debug("Firing Pregnancy Overwrite Patch - Passed Simple NullChecks");
 | 
			
		||||
 | 
			
		||||
            if (pawn.IsPregnant() 
 | 
			
		||||
                && GeneUtility.HasGeneNullCheck(partner, GeneDefOf.rjw_genes_pregnancy_overwrite))
 | 
			
		||||
                    TryReplacePregnancy(partner, pawn);
 | 
			
		||||
| 
						 | 
				
			
			@ -63,8 +61,9 @@ namespace RJW_Genes
 | 
			
		|||
        public static void TryReplacePregnancy(Pawn replacer, Pawn pregnant)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            ModLog.Debug($"Firing Pregnancy Overwrite for {replacer} and {pregnant}");
 | 
			
		||||
 | 
			
		||||
            // DevNote:
 | 
			
		||||
            // There are some issues with just checking PregnancyUtility.PregnancyChanceForPartners or rjw.PregnancyHelper.CanImpregnate
 | 
			
		||||
            // Both do give 0.0 chance when the pawn is already pregnant, which does not help me :/
 | 
			
		||||
            Hediff pregnancyHediff = PregnancyUtility.GetPregnancyHediff(pregnant);
 | 
			
		||||
            if (pregnancyHediff == null)
 | 
			
		||||
                return;
 | 
			
		||||
| 
						 | 
				
			
			@ -77,10 +76,12 @@ namespace RJW_Genes
 | 
			
		|||
 | 
			
		||||
            ChanceExtension chanceExt = GeneDefOf.rjw_genes_pregnancy_overwrite.GetModExtension<ChanceExtension>();
 | 
			
		||||
            float chance = chanceExt != null ? chanceExt.chance : 0.25f;
 | 
			
		||||
            chance *= PregnancyUtility.PregnancyChanceForPartners(pregnant, replacer);
 | 
			
		||||
 | 
			
		||||
            if ((new Random()).Next() < chance)
 | 
			
		||||
            float replacerFert = replacer.GetStatValueForPawn(StatDefOf.Fertility, replacer);
 | 
			
		||||
            chance *=  replacerFert ;
 | 
			
		||||
            double roll = (new Random()).NextDouble();
 | 
			
		||||
            if (roll < chance)
 | 
			
		||||
            {
 | 
			
		||||
                ModLog.Debug($"Pregnancy-Overwrite for {replacer} and {pregnant}.");
 | 
			
		||||
                float gestationProgress = pregnancyHediff.Severity;
 | 
			
		||||
 | 
			
		||||
                PregnancyUtility.ForceEndPregnancy(pregnant);
 | 
			
		||||
| 
						 | 
				
			
			@ -92,7 +93,7 @@ namespace RJW_Genes
 | 
			
		|||
                FactionUtility.HandleFactionGoodWillPenalties(replacer, pregnant, "rjw_genes_GoodwillChangedReason_OverwritePregnancy", FACTION_GOODWILL_CHANGE);
 | 
			
		||||
            } else
 | 
			
		||||
            {
 | 
			
		||||
                ModLog.Debug($"Did not Pregnancy-Overwrite for {replacer} and {pregnant}. Failed: roll<({chanceExt.chance} x {PregnancyUtility.PregnancyChanceForPartners(pregnant,replacer)}[PregnancyChance for Pawns])");
 | 
			
		||||
                ModLog.Debug($"Did not Pregnancy-Overwrite for {replacer} and {pregnant}. Failed: Rolled {roll} <({chanceExt.chance}[XML-Chance] x {replacerFert} [Fert:{replacer}])");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue