From 65f74e7369a4f555b111bc382d200566d8bbd879 Mon Sep 17 00:00:00 2001 From: Vegapnk Date: Sun, 22 Oct 2023 16:25:52 +0200 Subject: [PATCH] Added a simple social worker for aphrodisiac genes, closes #50 --- CHANGELOG.md | 3 +- Common/Defs/ThoughtDefs/Thoughts_Special.xml | 18 ++++++ .../Genes/Gene_Aphrodisiac_Pheromones.cs | 4 +- ...ghtWorker_Aphrodisiac_Pheromones_Social.cs | 60 +++++++++++++++++++ Source/Rjw-Genes.csproj | 1 + Source/ThoughtDefOf.cs | 2 + 6 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 Common/Defs/ThoughtDefs/Thoughts_Special.xml create mode 100644 Source/Genes/Special/Thoughts/ThoughtWorker_Aphrodisiac_Pheromones_Social.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index a372057..1723022 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,13 +3,14 @@ **Changes** - Added patches for Alpha-Genes Animusen, Drakonori and Malachai (Closes #65, thanks @Stars22223) +- Little Social Boost for Pawns affected by pheromones (Closes #50) **Fixes:** - XML Missmatch for Succubus Letter (Fixed in #64, thanks @mwcrow) - Made constructor for Empathetic Lifeforce explicitly `public` to not hang up in character creation (Fixes #66) -# 1.3.0 +# 1.3.0 (19-09-2023) **Changes:** diff --git a/Common/Defs/ThoughtDefs/Thoughts_Special.xml b/Common/Defs/ThoughtDefs/Thoughts_Special.xml new file mode 100644 index 0000000..b669317 --- /dev/null +++ b/Common/Defs/ThoughtDefs/Thoughts_Special.xml @@ -0,0 +1,18 @@ + + + + + + rjw_genes_pheromone_carrier_nearby + Thought_SituationalSocial + RJW_Genes.ThoughtWorker_Aphrodisiac_Pheromones_Social + +
  • + + {0} has a special vibe, we should hang out more often. + +3 +
  • +
    +
    + +
    diff --git a/Source/Genes/Special/Genes/Gene_Aphrodisiac_Pheromones.cs b/Source/Genes/Special/Genes/Gene_Aphrodisiac_Pheromones.cs index 0d13fb6..db50ab6 100644 --- a/Source/Genes/Special/Genes/Gene_Aphrodisiac_Pheromones.cs +++ b/Source/Genes/Special/Genes/Gene_Aphrodisiac_Pheromones.cs @@ -11,7 +11,7 @@ namespace RJW_Genes // This means that adding +.25 equals 1.5h of Libido. // Tick Speed is hence set to 0.5h - const int APHRODISIAC_DISTANCE_FALLBACK = 25; + public const int APHRODISIAC_DISTANCE_FALLBACK = 25; const int TICK_INTERVAL_FALLBACK = 60000 / 48 ; // 60k = 1 day, we want 0.5h which is 1/48th of 1 day. const float SEXFREQ_THRESHOLD = 0.5f; @@ -83,6 +83,8 @@ namespace RJW_Genes aphrodisiac = HediffMaker.MakeHediff(HediffDefOf.rjw_genes_aphrodisiac_pheromone, pawn); aphrodisiac.Severity = 0.5f; pawn.health.AddHediff(aphrodisiac); + + } } diff --git a/Source/Genes/Special/Thoughts/ThoughtWorker_Aphrodisiac_Pheromones_Social.cs b/Source/Genes/Special/Thoughts/ThoughtWorker_Aphrodisiac_Pheromones_Social.cs new file mode 100644 index 0000000..ee2c4f0 --- /dev/null +++ b/Source/Genes/Special/Thoughts/ThoughtWorker_Aphrodisiac_Pheromones_Social.cs @@ -0,0 +1,60 @@ +using RimWorld; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; +using Verse; + +namespace RJW_Genes +{ + public class ThoughtWorker_Aphrodisiac_Pheromones_Social : ThoughtWorker + { + protected override ThoughtState CurrentSocialStateInternal(Pawn pawn, Pawn other) + { + // Return for trivial errors + if (pawn == null || other == null || pawn == other) + return (ThoughtState)false; + // Check for position-existance + if (pawn.Position == null || other.Position == null || pawn.Map == null || other.Map == null) + return (ThoughtState)false; + // Do nothing if pawn is carried + if (pawn.CarriedBy != null) + return (ThoughtState)false; + // Do nothing if Pawn is Baby or Child (#25) + if (!pawn.ageTracker.Adult) + return (ThoughtState)false; + // Only check if they are spawned humans + if (!pawn.Spawned || !other.Spawned) + return (ThoughtState)false; + if (!pawn.RaceProps.Humanlike) + return (ThoughtState)false; + if (!other.RaceProps.Humanlike) + return (ThoughtState)false; + + if (!RelationsUtility.PawnsKnowEachOther(pawn, other)) + return (ThoughtState)false; + // If the pawn is not on Map (e.g. caravan), no mali + if (!HiveUtility.PawnIsOnHomeMap(pawn)) + return (ThoughtState)false; + + + // Do nothing for pawns that also have pheromones + if (GeneUtility.HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_aphrodisiac_pheromones)) + + return (ThoughtState)false; + + // Actual Logic: + // Pawn qualifies in right distance and needs line of sight. + var pos = other.Position; + int effectDistance = ModExtensionHelper.GetDistanceFromModExtension(GeneDefOf.rjw_genes_aphrodisiac_pheromones, Gene_Aphrodisiac_Pheromones.APHRODISIAC_DISTANCE_FALLBACK); + if (pos.DistanceTo(pawn.Position) < effectDistance && GenSight.LineOfSight(pos, pawn.Position, pawn.Map)) + { + return (ThoughtState)true; + } + + return (ThoughtState)false; + } + } +} diff --git a/Source/Rjw-Genes.csproj b/Source/Rjw-Genes.csproj index 148f8d4..7dbbdb0 100644 --- a/Source/Rjw-Genes.csproj +++ b/Source/Rjw-Genes.csproj @@ -153,6 +153,7 @@ + diff --git a/Source/ThoughtDefOf.cs b/Source/ThoughtDefOf.cs index aefcfa8..387aeca 100644 --- a/Source/ThoughtDefOf.cs +++ b/Source/ThoughtDefOf.cs @@ -13,6 +13,8 @@ namespace RJW_Genes public static readonly ThoughtDef rjw_genes_cock_eaten; public static readonly ThoughtDef rjw_genes_seduced; + public static readonly ThoughtDef rjw_genes_pheromone_carrier_nearby; + //Others with same names but other defs than in genedefof public static readonly InteractionDef rjw_genes_flirt; }