+
@@ -113,6 +120,52 @@
+
+ HediffWithComps
+ Hediff_AffectedByPheromones
+
+ A condition caused by being around someone in estrus. Sex drive and satisfaction is increased by the scent of heat.
+ (1.00,0.60,0.75)
+ false
+ false
+ false
+ false
+ 1.0
+
+ true
+
+
+
+
+
+ 1.1
+ 1.0
+
+
+
+ 0.4
+
+
+ 1.4
+ 1.1
+
+
+
+ 0.8
+
+
+ 2.0
+ 1.2
+
+
+
+
+
+ -1.0
+
+
+
+
HediffWithComps
diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Pheromones.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Pheromones.cs
new file mode 100644
index 0000000..f70c29b
--- /dev/null
+++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Pheromones.cs
@@ -0,0 +1,102 @@
+
+
+using RimWorld;
+using rjw;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Verse;
+
+namespace RJW_Menstruation
+{
+ public class CompProperties_Pheromones : HediffCompProperties
+ {
+ public float daysToMaxSeverity;
+ public float range;
+ public float intensity = 1.0f;
+
+ public CompProperties_Pheromones()
+ {
+ compClass = typeof(HediffComp_Pheromones);
+ }
+ }
+
+ public class HediffComp_Pheromones : HediffComp
+ {
+ public CompProperties_Pheromones Props => (CompProperties_Pheromones)props;
+ public const int emitInterval = GenTicks.TickRareInterval;
+ public float emitRatio => (float)emitInterval / GenDate.TicksPerDay;
+
+ public override void CompPostTick(ref float severityAdjustment)
+ {
+ try
+ {
+ if (!Pawn.RaceProps.Humanlike) return;
+ if (!Pawn.IsHashIntervalTick(emitInterval)) return;
+ if (!Pawn.SpawnedOrAnyParentSpawned) return;
+
+ foreach (Pawn pawn in AffectedPawns())
+ ApplyEffectToPawn(pawn);
+ }
+ catch (Exception ex)
+ {
+ Log.Error($"Error when trying to emit pheromones: {ex}");
+ }
+ }
+
+ protected IEnumerable AffectedPawns()
+ {
+ Map mapHeld = Pawn.MapHeld;
+ if (mapHeld == null) yield break;
+ foreach (Pawn pawn in mapHeld.mapPawns.AllPawnsSpawned)
+ {
+ if (pawn == Pawn) continue;
+ if (!pawn.RaceProps.Humanlike) continue;
+ if (Pawn.PositionHeld.InHorDistOf(pawn.PositionHeld, Props.range) && Pawn.GetRoom() == pawn.GetRoom())
+ yield return pawn;
+ }
+ }
+
+ protected float GetEffectOnPawn(Pawn target)
+ {
+ if (target.Suspended || target.Dead) return 0.0f;
+ if (target.needs?.TryGetNeed(VariousDefOf.SexNeed) == null) return 0.0f;
+ if (!xxx.can_do_loving(target)) return 0.0f;
+ if (target.story?.traits.HasTrait(TraitDefOf.Asexual) ?? true) return 0.0f;
+ float penisEffect;
+ if (Genital_Helper.has_penis_fertile(target)) penisEffect = 1.0f;
+ else if (target.gender == Gender.Male) penisEffect = 0.25f;
+ else return 0.0f;
+
+ BodyDef body = target.RaceProps.body;
+ if (!PawnCapacityUtility.BodyCanEverDoCapacity(body, PawnCapacityDefOf.Breathing)) return 0.0f;
+ HediffSet hediffs = target.health.hediffSet;
+ float breathingEffect = PawnCapacityUtility.CalculateCapacityLevel(hediffs, PawnCapacityDefOf.Breathing);
+ float noseEffect = 1.0f;
+ List noses = body.GetPartsWithDef(BodyPartDefOf.Nose);
+ if (noses.Any()) // if the body doesn't have a nose but still breathes, then let it be affected
+ noseEffect = noses.Average(nose => PawnCapacityUtility.CalculatePartEfficiency(hediffs, nose));
+
+ return penisEffect * breathingEffect * noseEffect;
+ }
+
+ protected void ApplyEffectToPawn(Pawn target)
+ {
+ float intensity = Props.intensity * GetEffectOnPawn(target);
+ if (intensity <= 0.0f) return;
+ Hediff pheromones = target.health.hediffSet.GetFirstHediffOfDef(VariousDefOf.Hediff_AffectedByPheromones);
+ float decay = VariousDefOf.Hediff_AffectedByPheromones.CompProps().severityPerDay;
+ float raiseSeverityPerDay = intensity / Props.daysToMaxSeverity - decay; // Desired increase plus enough to overcome pheromone decay
+ float amountToApply = emitRatio * raiseSeverityPerDay;
+ if (pheromones != null)
+ pheromones.Severity += amountToApply;
+ else
+ {
+ pheromones = HediffMaker.MakeHediff(VariousDefOf.Hediff_AffectedByPheromones, target);
+ pheromones.Severity = amountToApply;
+ target.health.AddHediff(pheromones);
+ }
+ return;
+ }
+ }
+}
diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj b/1.4/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj
index f2f1834..0c4aa45 100644
--- a/1.4/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj
+++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj
@@ -69,6 +69,7 @@
+
diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/VariousDefOf.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/VariousDefOf.cs
index 6d307cf..2fc4f47 100644
--- a/1.4/source/RJW_Menstruation/RJW_Menstruation/VariousDefOf.cs
+++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/VariousDefOf.cs
@@ -1,7 +1,5 @@
using RimWorld;
using rjw;
-using rjw.Modules.Interactions.Rules.PartKindUsageRules.Implementation;
-using System;
using System.Collections.Generic;
using System.Linq;
using Verse;
@@ -20,6 +18,7 @@ namespace RJW_Menstruation
public static readonly HediffDef Hediff_MenstrualCramp = DefDatabase.GetNamed("Hediff_MenstrualCramp");
public static readonly HediffDef Hediff_Estrus = DefDatabase.GetNamed("Hediff_Estrus");
public static readonly HediffDef Hediff_Estrus_Concealed = DefDatabase.GetNamed("Hediff_Estrus_Concealed");
+ public static readonly HediffDef Hediff_AffectedByPheromones = DefDatabase.GetNamed("Hediff_AffectedByPheromones");
public static readonly HediffDef Hediff_ASA = DefDatabase.GetNamed("Hediff_ASA");
public static readonly StatDef MaxAbsorbable = DefDatabase.GetNamed("MaxAbsorbable");
public static readonly NeedDef SexNeed = DefDatabase.GetNamed("Sex");
diff --git a/About/Manifest.xml b/About/Manifest.xml
index 3299391..028cc7b 100644
--- a/About/Manifest.xml
+++ b/About/Manifest.xml
@@ -1,7 +1,7 @@
RJW Menstruation
- 1.0.9.0
+ 1.0.9.1