Added two genes for steal and swap genes on sex

This commit is contained in:
Vegapnk 2024-07-04 16:04:51 +02:00
parent b15f0c4d56
commit b12e9afbc0
8 changed files with 192 additions and 3 deletions

View file

@ -68,7 +68,7 @@ but they are meant mostly to have infectors immune against their own diseases.
**Additions:** **Additions:**
- Passive Gene: *Genetic Disease Immunity* - cannot get infected by any genetic diseases, and won't be affected by some other genes (see relevant genes) - Passive Gene: Genetic Disease Immunity. cannot get infected by any genetic diseases, and won't be affected by some other genes (see relevant genes)
- Disease Gene: Vulnerability. Pawn is likelier to be raped - Disease Gene: Vulnerability. Pawn is likelier to be raped
- Disease Gene: Infectious Hypersexuality - Disease Gene: Infectious Hypersexuality
- Disease Gene: Infectious Homosexuality & Bisexuality - Disease Gene: Infectious Homosexuality & Bisexuality
@ -78,6 +78,8 @@ but they are meant mostly to have infectors immune against their own diseases.
- Disease Gene: Size Blinded. Pawns have a higher chance for hooking up with pawns with a big cock, lower chance for small cocks. - Disease Gene: Size Blinded. Pawns have a higher chance for hooking up with pawns with a big cock, lower chance for small cocks.
- Infector Gene: Genetic Stretcher. Pawns can infect other pawns with *Size Blinded* - Infector Gene: Genetic Stretcher. Pawns can infect other pawns with *Size Blinded*
- Gene: Hardwired Progenity. Pawns with this get a malus on having no-children, and bonus on having a lot. - Gene: Hardwired Progenity. Pawns with this get a malus on having no-children, and bonus on having a lot.
- 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.
- 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.
**Fixes:** **Fixes:**

View file

@ -140,7 +140,7 @@
<GeneDef ParentName="SpecialBase"> <GeneDef ParentName="SpecialBase">
<defName>rjw_genes_sex_tamer</defName> <defName>rjw_genes_sex_tamer</defName>
<label>Sexual Tamer</label> <label>sexual tamer</label>
<labelShortAdj>sextamer</labelShortAdj> <labelShortAdj>sextamer</labelShortAdj>
<description>Bestiality has a chance to tame animals or advance their training.</description> <description>Bestiality has a chance to tame animals or advance their training.</description>
<iconPath>Genes/Icons/RJW_Genes_SexualTamer</iconPath> <iconPath>Genes/Icons/RJW_Genes_SexualTamer</iconPath>
@ -149,4 +149,35 @@
<biostatMet>-1</biostatMet> <biostatMet>-1</biostatMet>
</GeneDef> </GeneDef>
<GeneDef ParentName="SpecialBase">
<defName>rjw_genes_sexual_genetic_swap</defName>
<label>sexual genetic swap</label>
<description>Carriers with this gene may switch a gene with their sex-partner. Switched Genes are always endogenes.</description>
<iconPath>UI/Icons/Genes/Gene_PsychicBonding</iconPath>
<displayOrderInCategory>20</displayOrderInCategory>
<biostatCpx>3</biostatCpx>
<biostatMet>0</biostatMet>
<modExtensions>
<li Class="RJW_Genes.ChanceExtension">
<chance>0.1</chance>
</li>
</modExtensions>
</GeneDef>
<GeneDef ParentName="SpecialBase">
<defName>rjw_genes_sexual_genetic_thief</defName>
<label>sexual gene thief</label>
<description>Carriers with this gene may steal a gene from their sex-partner. Stolen genes are always xenogenes.</description>
<iconPath>UI/Icons/Genes/Gene_PsychicBonding</iconPath>
<displayOrderInCategory>21</displayOrderInCategory>
<biostatCpx>5</biostatCpx>
<biostatMet>-2</biostatMet>
<biostatArc>1</biostatArc>
<modExtensions>
<li Class="RJW_Genes.ChanceExtension">
<chance>0.2</chance>
</li>
</modExtensions>
</GeneDef>
</Defs> </Defs>

View file

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace RJW_Genes
{
public class ChanceExtension : DefModExtension
{
public float chance;
}
}

View file

@ -105,6 +105,8 @@ namespace RJW_Genes
public static readonly GeneDef rjw_genes_hormonal_saliva; public static readonly GeneDef rjw_genes_hormonal_saliva;
public static readonly GeneDef rjw_genes_cocoonweaver; public static readonly GeneDef rjw_genes_cocoonweaver;
public static readonly GeneDef rjw_genes_sex_tamer; public static readonly GeneDef rjw_genes_sex_tamer;
public static readonly GeneDef rjw_genes_sexual_genetic_swap;
public static readonly GeneDef rjw_genes_sexual_genetic_thief;
// Cosmetic // Cosmetic
public static readonly GeneDef rjw_genes_succubus_tail; public static readonly GeneDef rjw_genes_succubus_tail;

View file

@ -0,0 +1,69 @@
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
{
[HarmonyPatch(typeof(SexUtility), "Aftersex")]
public class Patch_GeneticSexSwap
{
public static void Postfix(SexProps props)
{
if (props == null || props.pawn == null || props.partner == null || props.partner.IsAnimal())
{
return;
}
Pawn pawn = props.pawn;
Pawn partner = props.partner;
if (pawn.genes == null || partner.genes == null) return;
// If both have the swap gene, nothing happens
if (GeneUtility.HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_sexual_genetic_swap)
&& GeneUtility.HasGeneNullCheck(partner, GeneDefOf.rjw_genes_sexual_genetic_swap))
return;
// If neither has the swap gene, nothing happens
if (!GeneUtility.HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_sexual_genetic_swap)
&& !GeneUtility.HasGeneNullCheck(partner, GeneDefOf.rjw_genes_sexual_genetic_swap))
return;
ChanceExtension chanceExt = GeneDefOf.rjw_genes_sexual_genetic_swap.GetModExtension<ChanceExtension>();
if (chanceExt != null && (new Random()).NextDouble() < chanceExt.chance)
SwapOneRandomGene(pawn, partner);
}
/// <summary>
/// Removes a random gene from one pawn and adds it too the other as xenogene.
/// The "gene swap" gene cannot be swapped!
/// </summary>
private static void SwapOneRandomGene(Pawn a, Pawn b, bool AddAsXenogene = true)
{
var geneFromA = a.genes.GenesListForReading
.Where(gene => a.genes.HasActiveGene(gene.def))
.Where(gene => gene.def != GeneDefOf.rjw_genes_sexual_genetic_swap)
.RandomElement();
var geneFromB = b.genes.GenesListForReading
.Where(gene => b.genes.HasActiveGene(gene.def))
.Where(gene => gene.def != GeneDefOf.rjw_genes_sexual_genetic_swap)
.RandomElement();
if (geneFromA == null || geneFromB == null) return;
ModLog.Debug($"Sexual Genetic Swap: Swapping {geneFromA.def} from {a} with {geneFromB.def} from {b}");
a.genes.AddGene(geneFromB.def, AddAsXenogene);
b.genes.AddGene(geneFromA.def, AddAsXenogene);
a.genes.RemoveGene(geneFromA);
b.genes.RemoveGene(geneFromB);
}
}
}

View file

@ -0,0 +1,68 @@
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
{
[HarmonyPatch(typeof(SexUtility), "Aftersex")]
public class Patch_GeneticSexThief
{
public static void Postfix(SexProps props)
{
if (props == null || props.pawn == null || props.partner == null || props.partner.IsAnimal())
{
return;
}
Pawn pawn = props.pawn;
Pawn partner = props.partner;
if (pawn.genes == null || partner.genes == null) return;
// If both have the swap gene, nothing happens
if (GeneUtility.HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_sexual_genetic_thief)
&& GeneUtility.HasGeneNullCheck(partner, GeneDefOf.rjw_genes_sexual_genetic_thief))
return;
if (GeneUtility.HasGeneNullCheck(pawn,GeneDefOf.rjw_genes_sexual_genetic_thief) &&
!GeneUtility.HasGeneNullCheck(partner, GeneDefOf.rjw_genes_genetic_disease_immunity))
{
ChanceExtension chanceExt = GeneDefOf.rjw_genes_sexual_genetic_thief.GetModExtension<ChanceExtension>();
if (chanceExt != null && (new Random()).NextDouble() < chanceExt.chance)
StealRandomGene(pawn, partner);
}
if (GeneUtility.HasGeneNullCheck(partner, GeneDefOf.rjw_genes_sexual_genetic_thief) &&
!GeneUtility.HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_genetic_disease_immunity))
{
ChanceExtension chanceExt = GeneDefOf.rjw_genes_sexual_genetic_thief.GetModExtension<ChanceExtension>();
if (chanceExt != null && (new Random()).NextDouble() < chanceExt.chance)
StealRandomGene(partner, pawn);
}
}
/// <summary>
/// Removes a random gene from one pawn and adds it too the other as xenogene.
/// </summary>
private static void StealRandomGene(Pawn stealer, Pawn victim, bool AddAsXenogene = true)
{
var stolenGene = victim.genes.GenesListForReading
.Where(gene => victim.genes.HasActiveGene(gene.def))
.RandomElement();
if (stolenGene == null) return;
ModLog.Debug($"Sexual Gene Thief: {stealer} steals {stolenGene.def} from {victim}");
stealer.genes.AddGene(stolenGene.def, AddAsXenogene);
victim.genes.RemoveGene(stolenGene);
}
}
}

View file

@ -12,7 +12,6 @@ namespace RJW_Genes
[HarmonyPatch(typeof(SexUtility), "Aftersex")] [HarmonyPatch(typeof(SexUtility), "Aftersex")]
public class Patch_HormonalSaliva public class Patch_HormonalSaliva
{ {
// TODO: Reduce to 0.02 after debug.
const float SIZE_INCREMENT_FALLBACK = 0.02f; const float SIZE_INCREMENT_FALLBACK = 0.02f;
const float MAX_BODY_SIZE_FALLBACK = 2.5f; const float MAX_BODY_SIZE_FALLBACK = 2.5f;
const float CUM_MULTIPLIER_FALLBACK = 1.05f; const float CUM_MULTIPLIER_FALLBACK = 1.05f;

View file

@ -56,6 +56,7 @@
<Compile Include="Animal_Inheritance\Settings\RJW_BGSSettings.cs" /> <Compile Include="Animal_Inheritance\Settings\RJW_BGSSettings.cs" />
<Compile Include="Animal_Inheritance\Settings\RJW_BGSSettingsController.cs" /> <Compile Include="Animal_Inheritance\Settings\RJW_BGSSettingsController.cs" />
<Compile Include="Animal_Inheritance\Defs\BestialityGeneInheritanceDef.cs" /> <Compile Include="Animal_Inheritance\Defs\BestialityGeneInheritanceDef.cs" />
<Compile Include="Common\Defs\ChanceExtension.cs" />
<Compile Include="Common\Defs\DistanceExtension.cs" /> <Compile Include="Common\Defs\DistanceExtension.cs" />
<Compile Include="Common\Defs\ModExtensionHelper.cs" /> <Compile Include="Common\Defs\ModExtensionHelper.cs" />
<Compile Include="Common\Defs\TickBasedChanceExtension.cs" /> <Compile Include="Common\Defs\TickBasedChanceExtension.cs" />
@ -188,6 +189,8 @@
<Compile Include="Genes\Special\Defs\AgeTransferExtension.cs" /> <Compile Include="Genes\Special\Defs\AgeTransferExtension.cs" />
<Compile Include="Genes\Special\Defs\HormonalSalivaExtension.cs" /> <Compile Include="Genes\Special\Defs\HormonalSalivaExtension.cs" />
<Compile Include="Genes\Special\Patches\Patch_AgeDrain.cs" /> <Compile Include="Genes\Special\Patches\Patch_AgeDrain.cs" />
<Compile Include="Genes\Special\Patches\Patch_GeneticSexSwap.cs" />
<Compile Include="Genes\Special\Patches\Patch_GeneticSexThief.cs" />
<Compile Include="Genes\Special\Patches\Patch_HormonalSaliva.cs" /> <Compile Include="Genes\Special\Patches\Patch_HormonalSaliva.cs" />
<Compile Include="Genes\Special\Patches\Patch_OrgasmMytosis.cs" /> <Compile Include="Genes\Special\Patches\Patch_OrgasmMytosis.cs" />
<Compile Include="Genes\Special\Patches\Patch_SexualTamer.cs" /> <Compile Include="Genes\Special\Patches\Patch_SexualTamer.cs" />