From d6aeca7249675f5a738371a6679a698c9a7fff1b Mon Sep 17 00:00:00 2001 From: Vegapnk Date: Sun, 22 Jan 2023 09:59:16 +0100 Subject: [PATCH] Added Settings for RJW Genes, minor Cleanups --- CHANGELOG.md | 2 + Common/Defs/JobDefs/Jobs_LifeForce.xml | 2 +- Source/Genes/GeneUtility.cs | 3 + .../Abilities/CompAbilityEffect_PussyHeal.cs | 15 +---- .../JobGivers/JobGiver_GetLifeForce.cs | 2 +- .../Patch_SatisfyPersonal_LifeForceGain.cs | 10 ++- .../Patches/Patch_SexTicks_ChangePsyfocus.cs | 63 ++++++++++--------- Source/HarmonyInit.cs | 1 + Source/Rjw-Genes.csproj | 2 + Source/Settings/RJW_Genes_Settings.cs | 38 +++++++++++ .../Settings/RJW_Genes_SettingsController.cs | 22 +++++++ 11 files changed, 115 insertions(+), 45 deletions(-) create mode 100644 Source/Settings/RJW_Genes_Settings.cs create mode 100644 Source/Settings/RJW_Genes_SettingsController.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 0db6c9f..08005c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Features: - RJW Race-Support Compatibility (#12,#13, Shabakur) - Animal Gene Inheritance Gene-Chance Multiplier per Setting (#13, Shabakur) - Lots of Debug-Only Logging for Animal Gene Inheritance +- Mod-Settings Succubus: @@ -22,6 +23,7 @@ Fixes: - Futa Gene only triggers if Pawn is not a futa already (#2) - Genitalia Resizing triggers on 20th Birthday (#11) - RJW-Gene-Inheritance Settings now do things (#13, Shabakur) +- Check for Animals in Orgasm Rush, no Orgasm Rush for and from Animals (#15) # 1.0.1 (2022-12-20) diff --git a/Common/Defs/JobDefs/Jobs_LifeForce.xml b/Common/Defs/JobDefs/Jobs_LifeForce.xml index 3e35062..13dd1e3 100644 --- a/Common/Defs/JobDefs/Jobs_LifeForce.xml +++ b/Common/Defs/JobDefs/Jobs_LifeForce.xml @@ -11,7 +11,7 @@ rjw_genes_lifeforce_healpussy RJW_Genes.JobDriver_CastAbilityAfterSex - Healing someone with sex. + Tending someones wounds with sex. false diff --git a/Source/Genes/GeneUtility.cs b/Source/Genes/GeneUtility.cs index 9ec55c4..66cfd74 100644 --- a/Source/Genes/GeneUtility.cs +++ b/Source/Genes/GeneUtility.cs @@ -38,6 +38,7 @@ namespace RJW_Genes } } + public static bool HasLowLifeForce(Pawn pawn) { if (HasLifeForce(pawn)) @@ -118,5 +119,7 @@ namespace RJW_Genes public static bool HasParalysingKiss(Pawn pawn) { return HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_paralysingkiss); } public static bool HasSeduce(Pawn pawn) { return HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_seduce); } public static bool IsSexualDrainer(Pawn pawn) { return HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_drainer); } + public static bool IsCumEater(Pawn pawn) { return HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_cum_eater); } + } } \ No newline at end of file diff --git a/Source/Genes/Life_Force/Abilities/CompAbilityEffect_PussyHeal.cs b/Source/Genes/Life_Force/Abilities/CompAbilityEffect_PussyHeal.cs index 009588d..fdb0c7c 100644 --- a/Source/Genes/Life_Force/Abilities/CompAbilityEffect_PussyHeal.cs +++ b/Source/Genes/Life_Force/Abilities/CompAbilityEffect_PussyHeal.cs @@ -1,13 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; using Verse; -using UnityEngine; using RimWorld; using rjw; -using rjw.Modules.Interactions.Helpers; namespace RJW_Genes { @@ -31,11 +25,8 @@ namespace RJW_Genes bool any_wound_tended = AbilityUtility.Heal(pawn, this.Props.tendQualityRange); if (any_wound_tended) { - MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Sex healed wounds", 3.65f); - //pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.Pussy_Healed, pawn, null); + MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Sex tended wounds", 3.65f); } - //this.AfterSex(any_wound_tended); - //FleckMaker.AttachedOverlay(pawn, FleckDefOf.FlashHollow, Vector3.zero, 1.5f, -1f); } //Not yet implemented, but the heal should also trigger after normal sex @@ -77,7 +68,7 @@ namespace RJW_Genes } return false; } - //AbilityUtility.ValidateHasTendableWound(pawn, throwMessages, this.parent); + //TODO: Only make pawns targetable that have tendable wounds } return base.Valid(target, throwMessages); diff --git a/Source/Genes/Life_Force/JobGivers/JobGiver_GetLifeForce.cs b/Source/Genes/Life_Force/JobGivers/JobGiver_GetLifeForce.cs index b40f221..3c0eff6 100644 --- a/Source/Genes/Life_Force/JobGivers/JobGiver_GetLifeForce.cs +++ b/Source/Genes/Life_Force/JobGivers/JobGiver_GetLifeForce.cs @@ -39,7 +39,7 @@ namespace RJW_Genes { return null; } - int num = Mathf.RoundToInt(((gene_lifeforce.targetValue - gene_lifeforce.Value) * 100 + 10) / ingestionOutcomeDoer.FERTILIN_PER_UNIT); + int num = Mathf.RoundToInt(((gene_lifeforce.targetValue - gene_lifeforce.Value) * 100 + 10) / IngestionOutcomeDoer_LifeForceOffset.FERTILIN_PER_UNIT); if (gatheredCum != null && num > 0) { Job job = JobMaker.MakeJob(RimWorld.JobDefOf.Ingest, gatheredCum); diff --git a/Source/Genes/Life_Force/Patches/Patch_SatisfyPersonal_LifeForceGain.cs b/Source/Genes/Life_Force/Patches/Patch_SatisfyPersonal_LifeForceGain.cs index e601952..fb032d2 100644 --- a/Source/Genes/Life_Force/Patches/Patch_SatisfyPersonal_LifeForceGain.cs +++ b/Source/Genes/Life_Force/Patches/Patch_SatisfyPersonal_LifeForceGain.cs @@ -103,6 +103,12 @@ namespace RJW_Genes multiplier *= absorb_percentage; //Currently taking the sum of all penises, maybe I should just consider one at random float valuechange = TotalFertilinAmount(props, multiplier); + + if (props.partner.IsAnimal()) + { + valuechange *= RJW_Genes_Settings.rjw_genes_fertilin_from_animals_factor; + } + GeneUtility.OffsetLifeForce(GeneUtility.GetLifeForceGene(props.partner), valuechange); //gene.Resource.Value += CumUtility.GetTotalFluidAmount(props.pawn) / 100 * absorb_factor * multiplier; } @@ -129,7 +135,7 @@ namespace RJW_Genes /// /// The summary of the sex act, used for checking conditions. /// The pawn that might gain LifeForce through this method. - /// + /// A factor between 0 and 1 how much of output-fertilin will be used for input-lifeforce public static float BaseDom(SexProps props, Pawn PawnWithLifeForce) { float absorb_factor = 0f; @@ -145,7 +151,7 @@ namespace RJW_Genes /// /// The summary of the sex act, used for checking conditions. /// The pawn that might gain LifeForce through this method. - /// + /// A factor between 0 and 1 how much of output-fertilin will be used for input-lifeforce public static float BaseSub(SexProps props, Pawn PawnWithLifeForce) { float absorb_factor = 0f; diff --git a/Source/Genes/Life_Force/Patches/Patch_SexTicks_ChangePsyfocus.cs b/Source/Genes/Life_Force/Patches/Patch_SexTicks_ChangePsyfocus.cs index ea0d9d6..dfc359b 100644 --- a/Source/Genes/Life_Force/Patches/Patch_SexTicks_ChangePsyfocus.cs +++ b/Source/Genes/Life_Force/Patches/Patch_SexTicks_ChangePsyfocus.cs @@ -11,47 +11,52 @@ using Verse; namespace RJW_Genes { - //[HarmonyPatch(typeof(JobDriver_Sex), nameof(JobDriver_Sex.ChangePsyfocus))] + /// + /// This patch enables cum-eater pawns to drain cumflations for more fertilin drain by passively having sex. + /// It is hooked after RJWs Change-Psyfocus so that pawns that are having prolonged sex (e.g. by overdrive) can fully drain the cumflation over time. + /// + /// It is conditionally loaded only when LicentiaLabs is enabled, as this is the necessary source for cumflation-hediffs. + /// The patched function is: [HarmonyPatch(typeof(JobDriver_Sex), nameof(JobDriver_Sex.ChangePsyfocus))] + /// public static class Patch_SexTicks_ChangePsyfocus { + public const float LIFEFORCE_GAIN_PER_TICK = 0.05f; + public const float CUMFLATION_SEVERITY_LOSS_PER_TICK = 0.1f; + //Using ChangePsyfocus as it is something that fires every 60 ticks public static void Postfix(ref JobDriver_Sex __instance, ref Pawn pawn, ref Thing target) { - if (__instance.Sexprops.sexType == xxx.rjwSextype.Cunnilingus) - { - if (target != null) - { - Pawn pawn2 = target as Pawn; - if (pawn2 != null) - { - //We need to know who the pawn on top is and if reverse we need to make the sub the pawn on top - if (__instance.Sexprops.isRevese) - { - - DrinkCumflation(pawn2, pawn); - } - else - { - // - DrinkCumflation(pawn, pawn2); - return; - } - } + SexProps props = __instance.Sexprops; + if (props != null && props.sexType == xxx.rjwSextype.Cunnilingus && props.partner != null && target != null) + { + Pawn pawn2 = target as Pawn; + // Case 1: Pawn is "drinking" and has CumEater Gene + if (props.isRevese && GeneUtility.IsCumEater(pawn)) + { + if (RJW_Genes_Settings.rjw_genes_detailed_debug) + ModLog.Message($"{pawn.Name} is draining {pawn2.Name}'s cumflation for additional fertilin (CumEater-Gene ChangePsyFocus-Trigger)."); + DrinkCumflation(pawn2, pawn); + } + // Case 2: Pawn2 is "drinking" and has CumEater Gene + else if (GeneUtility.IsCumEater(pawn2)) + { + if (RJW_Genes_Settings.rjw_genes_detailed_debug) + ModLog.Message($"{pawn.Name} is draining {pawn2.Name}'s cumflation for additional fertilin (CumEater-Gene ChangePsyFocus-Trigger)."); + DrinkCumflation(pawn, pawn2); } - } } - public static void DrinkCumflation(Pawn dom, Pawn sub) + public static void DrinkCumflation(Pawn source, Pawn consumer) { - if (GeneUtility.HasLifeForce(sub) && GeneUtility.HasGeneNullCheck(sub,GeneDefOf.rjw_genes_cum_eater)&& dom.health.hediffSet.HasHediff(HediffDef.Named("Cumflation"))) + if (GeneUtility.HasLifeForce(consumer) && GeneUtility.IsCumEater(consumer) + && source.health.hediffSet.HasHediff(HediffDef.Named("Cumflation"))) { - Hediff cumflation = dom.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("Cumflation")); - Gene_LifeForce gene_LifeForce = sub.genes.GetFirstGeneOfType(); - cumflation.Severity -= 0.1f; - gene_LifeForce.Resource.Value += 0.05f; + Hediff cumflation = source.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("Cumflation")); + Gene_LifeForce gene_LifeForce = consumer.genes.GetFirstGeneOfType(); + cumflation.Severity = Math.Max(0f,cumflation.Severity - CUMFLATION_SEVERITY_LOSS_PER_TICK); + gene_LifeForce.Resource.Value += LIFEFORCE_GAIN_PER_TICK; } } - //Maybe I can store gene and hediff so I dont need to look them up every time } } diff --git a/Source/HarmonyInit.cs b/Source/HarmonyInit.cs index 8c5f3d6..b0f8295 100644 --- a/Source/HarmonyInit.cs +++ b/Source/HarmonyInit.cs @@ -27,6 +27,7 @@ namespace RJW_Genes // Gene: Generous Donor [Postfix Patch] harmony.Patch(AccessTools.Method(typeof(LicentiaLabs.CumflationHelper), nameof(LicentiaLabs.CumflationHelper.TransferNutrition)), postfix: new HarmonyMethod(typeof(Patch_TransferNutrition), nameof(Patch_TransferNutrition.Postfix))); + // Gene: CumEater [Postfix Patch] harmony.Patch(AccessTools.Method(typeof(rjw.JobDriver_Sex), nameof(rjw.JobDriver_Sex.ChangePsyfocus)), postfix: new HarmonyMethod(typeof(Patch_SexTicks_ChangePsyfocus), nameof(Patch_SexTicks_ChangePsyfocus.Postfix))); } diff --git a/Source/Rjw-Genes.csproj b/Source/Rjw-Genes.csproj index 6a44288..026661f 100644 --- a/Source/Rjw-Genes.csproj +++ b/Source/Rjw-Genes.csproj @@ -175,6 +175,8 @@ + + diff --git a/Source/Settings/RJW_Genes_Settings.cs b/Source/Settings/RJW_Genes_Settings.cs new file mode 100644 index 0000000..ba1d69a --- /dev/null +++ b/Source/Settings/RJW_Genes_Settings.cs @@ -0,0 +1,38 @@ +using System; +using Verse; +using UnityEngine; + +namespace RJW_Genes +{ + public class RJW_Genes_Settings : ModSettings + { + public static void DoWindowContents(Rect inRect) + { + //Copied from RJW settings mostly + Rect outRect = new Rect(0f, 30f, inRect.width, inRect.height - 30f); + Rect rect = new Rect(0f, 0f, inRect.width - 16f, inRect.height + 300f); + //Widgets.BeginScrollView(outRect, ref RJWSettings.scrollPosition, rect, true); + Listing_Standard listing_Standard = new Listing_Standard(); + listing_Standard.maxOneColumn = true; + listing_Standard.ColumnWidth = rect.width / 2.05f; + listing_Standard.Begin(rect); + listing_Standard.Gap(24f); + listing_Standard.Label("Fertlin-Gain from Animals" + ": " + + Math.Round((double)(RJW_Genes_Settings.rjw_genes_fertilin_from_animals_factor * 100f), 0).ToString() + "%", -1f, "of fertilin gained (compared to human-baseline)."); + RJW_Genes_Settings.rjw_genes_fertilin_from_animals_factor = listing_Standard.Slider(RJW_Genes_Settings.rjw_genes_fertilin_from_animals_factor, 0f, 3f); + listing_Standard.Gap(5f); + listing_Standard.CheckboxLabeled("detailed-debug", ref rjw_genes_detailed_debug, "Adds detailed information to the log about interactions and genes.", 0f, 1f); + listing_Standard.End(); + } + + public override void ExposeData() + { + base.ExposeData(); + Scribe_Values.Look(ref RJW_Genes_Settings.rjw_genes_fertilin_from_animals_factor, "rjw_genes_fertilin_from_animals_factor", RJW_Genes_Settings.rjw_genes_fertilin_from_animals_factor, true); + Scribe_Values.Look(ref RJW_Genes_Settings.rjw_genes_detailed_debug, "rjw_genes_detailed_debug", RJW_Genes_Settings.rjw_genes_detailed_debug, true); + } + + public static bool rjw_genes_detailed_debug = false; + public static float rjw_genes_fertilin_from_animals_factor = 0.1f; + } +} diff --git a/Source/Settings/RJW_Genes_SettingsController.cs b/Source/Settings/RJW_Genes_SettingsController.cs new file mode 100644 index 0000000..7236b14 --- /dev/null +++ b/Source/Settings/RJW_Genes_SettingsController.cs @@ -0,0 +1,22 @@ +using Verse; +using UnityEngine; + +namespace RJW_Genes +{ + public class RJW_Genes_SettingsController : Mod + { + public RJW_Genes_SettingsController(ModContentPack content) : base(content) + { + base.GetSettings(); + } + + public override string SettingsCategory() + { + return "RJW Genes - General"; + } + public override void DoSettingsWindowContents(Rect inRect) + { + RJW_Genes_Settings.DoWindowContents(inRect); + } + } +}