From 0032913a578840147e0c46766fda11cc68e8f502 Mon Sep 17 00:00:00 2001 From: Vegapnk Date: Thu, 11 Jul 2024 12:35:40 +0200 Subject: [PATCH] Added Feminization #63 --- CHANGELOG.md | 17 ++- .../Genes/Special/Patches/Patch_Feminizer.cs | 120 ++++++++++++++++++ Source/Rjw-Genes.csproj | 1 + 3 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 Source/Genes/Special/Patches/Patch_Feminizer.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f19243..0afadbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -91,7 +91,21 @@ and might try to add a gene that already exists - then nothing happens. - (Major) Beauty Pretty - (Major) Fertile Anus +*Feminization Genepool*: +- (Minor) Long Hair +- (Minor) No-Beard +- (Minor) Small Male Genitals +- (Minor) No Cum +- (Minor) Big Breasts (will only show later) +- (Major) Female Only +- (Major) No Penis +- (Major) Minor Vulnerability + These are currently hardcoded but I can change them on popular demand. +In general minor changes are only cosmetic and wont change metabolism. + +*Why are these changes Genetic?* +Because this is the genes mod, and I find things here quite robust. ## Changelog @@ -110,7 +124,8 @@ These are currently hardcoded but I can change them on popular demand. - Gene: Sexual Genetic Swap. Pawns have a chance to switch a random gene with their sexpartner. - (Archite) Gene: Sexual Genetic Thief. Pawns have a chance to steal a gene from their sexpartner. Genetic Disease Immunity shields against this. - Gene: Sperm Displacement. Pawns might overwrite an existing pregnancy, becoming the new father. The pregnancy will stay in its gestation progress. -- Gene: Twinkification. Pawns turn their (male) sexual partners into breedable twinks. +- Gene: Twinkification: Pawns turn their (male) sexual partners into breedable twinks. +- Gene: Feminization: Pawns turn their (male) sexual partners into women. - Pawns will have negative thoughts about pawns with more genetic diseases than themselves. - Faction Penalties for spreading diseases, stealing genes and aging pawns with age transfer - Patch for [Imphilee Xeno](https://steamcommunity.com/sharedfiles/filedetails/?id=2990674516) by @Bunuffin diff --git a/Source/Genes/Special/Patches/Patch_Feminizer.cs b/Source/Genes/Special/Patches/Patch_Feminizer.cs new file mode 100644 index 0000000..952f63a --- /dev/null +++ b/Source/Genes/Special/Patches/Patch_Feminizer.cs @@ -0,0 +1,120 @@ +using HarmonyLib; +using rjw; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace RJW_Genes +{ + /// + /// This patch handles the changes produced by `rjw_genes_feminizer`. + /// It requires the hediff `rjw_genes_feminzation_in_progress` which is managed separately, in `Patch_HediffIncreaseOnSex`. + /// + [HarmonyPatch(typeof(SexUtility), "Aftersex")] + public static class Patch_Feminizer + { + const float MINOR_APPLICATION_CHANCE = 0.25f; // = 25% to have a minor transformation + const float MAJOR_APPLICATION_CHANCE = 0.10f; // = 10% to have a major transformation + + public static void Postfix(SexProps props) + { + if (props == null || props.pawn == null || !props.hasPartner() || props.partner == null) + return; + if (props.pawn.IsAnimal() || props.partner.IsAnimal()) + return; + + ApplyFeminization(props.pawn); + ApplyFeminization(props.partner); + } + + private static void ApplyFeminization(Pawn pawn) + { + if (pawn == null) return; + Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.rjw_genes_feminization_progress); + if (hediff == null) return; + + var Random = new Random(); + // DevNote: I first had a switch (hediff.SeverityLabel) but SeverityLabel was null. + // So now I have this approach which feels a bit more robust. + // I was thinking about looking for strings in the label, but I think that will break the logic in case of translations. + switch (hediff.Severity) + { + case float f when f > 0.8f: + { + if (Random.NextDouble() < MAJOR_APPLICATION_CHANCE) + MajorChange(pawn); + } break; + case float f when f > 0.6f: + { + if (Random.NextDouble() < MINOR_APPLICATION_CHANCE) + MinorChange(pawn); + } break; + default: + { + ModLog.Debug($"Tried to feminize {pawn} - severity of feminization was too low ({hediff.def} @ {hediff.Severity} - {hediff.Label})") ; + } break; + } + + } + + private static void MinorChange(Pawn pawn) + { + List possibleGenes = new List() { + GeneDefOf.rjw_genes_small_male_genitalia, + GeneDefOf.rjw_genes_big_breasts, + GeneDefOf.rjw_genes_no_cum, + DefDatabase.GetNamed("Beard_NoBeardOnly"), + DefDatabase.GetNamed("Hair_LongOnly") + }; + + GeneDef chosen = possibleGenes.RandomElement(); + if (chosen == null) + { + ModLog.Warning($"Error in retrieving a minor-feminization gene for feminizing {pawn}"); + return; + } + + // DevNote: I could do "hasActiveGene" but that could lead to the gene being there but not active. + if (!pawn.genes.GenesListForReading.Any(p => p.def == chosen)) + { + ModLog.Debug($"{pawn} experienced a minor feminization change; {pawn} got new gene {chosen}."); + pawn.genes.AddGene(chosen, !RJW_Genes_Settings.rjw_genes_genetic_disease_as_endogenes); + } else + { + ModLog.Debug($"Tryed a minor feminization for {pawn} - {pawn} already had {chosen}"); + } + } + + private static void MajorChange(Pawn pawn) + { + List possibleGenes = new List() { + GeneDefOf.rjw_genes_female_only, + GeneDefOf.rjw_genes_no_penis, + GeneDefOf.rjw_genes_minor_vulnerability, + }; + + GeneDef chosen = possibleGenes.RandomElement(); + if (chosen == null) + { + ModLog.Warning($"Error in retrieving a minor-feminization gene for feminizing {pawn}"); + return; + } + + // DevNote: I could do "hasActiveGene" but that could lead to the gene being there but not active. + if (!pawn.genes.GenesListForReading.Any(p => p.def == chosen)) + { + ModLog.Debug($"{pawn} experienced a major feminization change; {pawn} got new gene {chosen}."); + pawn.genes.AddGene(chosen, !RJW_Genes_Settings.rjw_genes_genetic_disease_as_endogenes); + } + else + { + ModLog.Debug($"Tryed a major feminization for {pawn} - {pawn} already had {chosen}"); + ModLog.Debug($"Trying minor feminization for {pawn} instead ..."); + MinorChange(pawn); + } + } + } +} diff --git a/Source/Rjw-Genes.csproj b/Source/Rjw-Genes.csproj index 8300996..763d2db 100644 --- a/Source/Rjw-Genes.csproj +++ b/Source/Rjw-Genes.csproj @@ -197,6 +197,7 @@ +