Added Feminization #63

This commit is contained in:
Vegapnk 2024-07-11 12:35:40 +02:00
parent c82b81011f
commit 0032913a57
3 changed files with 137 additions and 1 deletions

View file

@ -91,7 +91,21 @@ and might try to add a gene that already exists - then nothing happens.
- (Major) Beauty Pretty - (Major) Beauty Pretty
- (Major) Fertile Anus - (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. 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 ## 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. - 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. - (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: 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. - 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 - 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 - Patch for [Imphilee Xeno](https://steamcommunity.com/sharedfiles/filedetails/?id=2990674516) by @Bunuffin

View file

@ -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
{
/// <summary>
/// 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`.
/// </summary>
[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<GeneDef> possibleGenes = new List<GeneDef>() {
GeneDefOf.rjw_genes_small_male_genitalia,
GeneDefOf.rjw_genes_big_breasts,
GeneDefOf.rjw_genes_no_cum,
DefDatabase<GeneDef>.GetNamed("Beard_NoBeardOnly"),
DefDatabase<GeneDef>.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<GeneDef> possibleGenes = new List<GeneDef>() {
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);
}
}
}
}

View file

@ -197,6 +197,7 @@
<Compile Include="Genes\Special\Patches\Patch_OrgasmMytosis.cs" /> <Compile Include="Genes\Special\Patches\Patch_OrgasmMytosis.cs" />
<Compile Include="Genes\Special\Patches\Patch_PregnancyOverwrite.cs" /> <Compile Include="Genes\Special\Patches\Patch_PregnancyOverwrite.cs" />
<Compile Include="Genes\Special\Patches\Patch_SexualTamer.cs" /> <Compile Include="Genes\Special\Patches\Patch_SexualTamer.cs" />
<Compile Include="Genes\Special\Patches\Patch_Feminizer.cs" />
<Compile Include="Genes\Special\Patches\Patch_Twinkifier.cs" /> <Compile Include="Genes\Special\Patches\Patch_Twinkifier.cs" />
<Compile Include="Genes\Special\Thoughts\ThoughtWorker_Aphrodisiac_Pheromones_Social.cs" /> <Compile Include="Genes\Special\Thoughts\ThoughtWorker_Aphrodisiac_Pheromones_Social.cs" />
<Compile Include="LetterDefOf.cs" /> <Compile Include="LetterDefOf.cs" />