mirror of
				https://gitgud.io/lutepickle/rjw_menstruation.git
				synced 2024-08-14 22:46:52 +00:00 
			
		
		
		
	Add a proper weighted random algo for selecting paternity
This commit is contained in:
		
							parent
							
								
									8b48fe51e5
								
							
						
					
					
						commit
						c082c70e68
					
				
					 2 changed files with 29 additions and 7 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -1115,17 +1115,39 @@ namespace RJW_Menstruation
 | 
				
			||||||
        protected Pawn Fertilize()
 | 
					        protected Pawn Fertilize()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (cums.NullOrEmpty()) return null;
 | 
					            if (cums.NullOrEmpty()) return null;
 | 
				
			||||||
            foreach (Cum cum in cums)
 | 
					            float totalFertPower = 0;
 | 
				
			||||||
 | 
					            List<Cum> eligibleCum = cums.FindAll(c => c.FertVolume > 0 && (RJWPregnancySettings.bestial_pregnancy_enabled || xxx.is_animal(parent.pawn) == xxx.is_animal(c.pawn)));
 | 
				
			||||||
 | 
					            if (eligibleCum.Count == 0) return null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            foreach (Cum cum in eligibleCum)
 | 
				
			||||||
 | 
					                totalFertPower += cum.FertVolume;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (Rand.Range(0.0f, 1.0f) > totalFertPower * Configurations.FertilizeChance * Props.basefertilizationChanceFactor)
 | 
				
			||||||
 | 
					                return null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            float selection = Rand.Range(0.0f, totalFertPower);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            foreach (Cum cum in eligibleCum)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                float rand = Rand.Range(0.0f, 1.0f);
 | 
					                selection -= cum.FertVolume;
 | 
				
			||||||
                if (cum.pawn != null && !cum.notcum && rand < cum.FertVolume * Configurations.FertilizeChance * Props.basefertilizationChanceFactor)
 | 
					                if (selection <= 0) return cum.pawn;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // We shouldn't reach here, but floating point errors exist, so just to be sure, select whomever came the most
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            float mostCum = 0;
 | 
				
			||||||
 | 
					            Pawn mostCummer = null;
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            foreach (Cum cum in eligibleCum)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if(cum.FertVolume > mostCum)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    if (!RJWPregnancySettings.bestial_pregnancy_enabled && (xxx.is_animal(parent.pawn) ^ xxx.is_animal(cum.pawn))) continue;
 | 
					                    mostCum = cum.FertVolume;
 | 
				
			||||||
                    parent.pawn.records.AddTo(VariousDefOf.AmountofFertilizedEggs, 1);
 | 
					                    mostCummer = cum.pawn;
 | 
				
			||||||
                    return cum.pawn;
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return null;
 | 
					
 | 
				
			||||||
 | 
					            return mostCummer;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue