Merge branch 'master' into unmerged-rjw

This commit is contained in:
amevarashi 2022-03-02 18:19:40 +05:00
commit 6455c529e2
7 changed files with 303 additions and 424 deletions

View file

@ -33,9 +33,7 @@ namespace RJWSexperience
[DebugAction("RJW Sexperience", "Reset lust", false, false, actionType = DebugActionType.ToolMapForPawns, allowedGameStates = AllowedGameStates.PlayingOnMap)] [DebugAction("RJW Sexperience", "Reset lust", false, false, actionType = DebugActionType.ToolMapForPawns, allowedGameStates = AllowedGameStates.PlayingOnMap)]
private static void ResetLust(Pawn p) private static void ResetLust(Pawn p)
{ {
float lust; float lust = RecordRandomizer.RandomizeLust(p);
if (xxx.is_nympho(p)) lust = p.RecordRandomizer(VariousDefOf.Lust, Configurations.AvgLust, Configurations.MaxLustDeviation, 0);
else lust = p.RecordRandomizer(VariousDefOf.Lust, Configurations.AvgLust, Configurations.MaxLustDeviation, float.MinValue);
MoteMaker.ThrowText(p.TrueCenter(), p.Map, "Lust: " + lust); MoteMaker.ThrowText(p.TrueCenter(), p.Map, "Lust: " + lust);
} }

View file

@ -1,16 +1,10 @@
using System; using HarmonyLib;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using RimWorld; using RimWorld;
using Verse;
using rjw; using rjw;
using System;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using Verse;
namespace RJWSexperience namespace RJWSexperience
{ {
@ -21,98 +15,11 @@ namespace RJWSexperience
{ {
if (Configurations.EnableRecordRandomizer && __result != null && !request.Newborn && xxx.is_human(__result)) if (Configurations.EnableRecordRandomizer && __result != null && !request.Newborn && xxx.is_human(__result))
{ {
int avgsex = -500; RecordRandomizer.Randomize(__result);
bool isvirgin = Rand.Chance(Configurations.VirginRatio);
int totalsex = 0;
int totalbirth = 0;
int deviation = (int)Configurations.MaxSexCountDeviation;
if (__result.story != null)
{
float lust;
if (xxx.is_nympho(__result)) lust = __result.RecordRandomizer(VariousDefOf.Lust, Configurations.AvgLust, Configurations.MaxLustDeviation, 0);
else lust = __result.RecordRandomizer(VariousDefOf.Lust, Configurations.AvgLust, Configurations.MaxLustDeviation, float.MinValue);
int sexableage = 0;
int minsexage = 0;
if (Configurations.MinSexableFromLifestage)
minsexage = (int)__result.RaceProps.lifeStageAges.Find(x => x.def.reproductive).minAge;
else
minsexage = (int)(__result.RaceProps.lifeExpectancy * Configurations.MinSexablePercent);
if (__result.ageTracker.AgeBiologicalYears > minsexage)
{
sexableage = __result.ageTracker.AgeBiologicalYears - minsexage;
avgsex = (int)(sexableage * Configurations.SexPerYear * __result.LustFactor());
} }
__result.AddVirginTrait();
if (__result.relations != null && __result.gender == Gender.Female)
{
totalbirth += __result.relations.ChildrenCount;
totalsex += totalbirth;
__result.records?.AddTo(xxx.CountOfSexWithHumanlikes, totalbirth);
__result.records?.SetTo(xxx.CountOfBirthHuman, totalbirth);
if (totalbirth > 0) isvirgin = false;
}
if (!isvirgin)
{
if (xxx.is_rapist(__result))
{
if (xxx.is_zoophile(__result))
{
if (__result.Has(Quirk.ChitinLover)) totalsex += __result.RecordRandomizer(xxx.CountOfRapedInsects, avgsex, deviation);
else totalsex += __result.RecordRandomizer(xxx.CountOfRapedAnimals, avgsex, deviation);
}
else totalsex += __result.RecordRandomizer(xxx.CountOfRapedHumanlikes, avgsex, deviation);
avgsex /= 8;
}
if (xxx.is_zoophile(__result))
{
if (__result.Has(Quirk.ChitinLover)) totalsex += __result.RecordRandomizer(xxx.CountOfRapedInsects, avgsex, deviation);
else totalsex += __result.RecordRandomizer(xxx.CountOfSexWithAnimals, avgsex, deviation);
avgsex /= 10;
}
else if (xxx.is_necrophiliac(__result))
{
totalsex += __result.RecordRandomizer(xxx.CountOfSexWithCorpse, avgsex, deviation);
avgsex /= 4;
}
if (__result.IsSlave)
{
totalsex += __result.RecordRandomizer(xxx.CountOfBeenRapedByAnimals, Rand.Range(-50, 10), Rand.Range(0, 10) * sexableage);
totalsex += __result.RecordRandomizer(xxx.CountOfBeenRapedByHumanlikes, 0, Rand.Range(0, 100) * sexableage);
}
totalsex += __result.RecordRandomizer(xxx.CountOfSexWithHumanlikes, avgsex, deviation);
if (totalsex > 0) __result.records.AddTo(VariousDefOf.SexPartnerCount, Math.Max(1, Rand.Range(0, totalsex/7)));
} }
} }
__result.records?.SetTo(xxx.CountOfSex, totalsex);
RJWUtility.GenerateSextypeRecords(__result, totalsex);
}
if (__result.story?.traits != null)
{
if (__result.IsVirgin())
{
int degree = 0;
if (__result.gender == Gender.Female) degree = 2;
Trait virgin = new Trait(VariousDefOf.Virgin, degree ,true);
__result.story.traits.GainTrait(virgin);
}
else if (__result.gender == Gender.Female && Rand.Chance(0.05f))
{
Trait virgin = new Trait(VariousDefOf.Virgin, 1, true);
__result.story.traits.GainTrait(virgin);
}
}
}
}
[HarmonyPatch(typeof(FloatMenuMakerMap), "AddHumanlikeOrders")] [HarmonyPatch(typeof(FloatMenuMakerMap), "AddHumanlikeOrders")]
public class HumanlikeOrder_Patch public class HumanlikeOrder_Patch
@ -124,17 +31,13 @@ namespace RJWSexperience
if (pawn.health.hediffSet.HasHediff(RJW_SemenoOverlayHediffDefOf.Hediff_Bukkake)) if (pawn.health.hediffSet.HasHediff(RJW_SemenoOverlayHediffDefOf.Hediff_Bukkake))
foreach (LocalTargetInfo t in targets) foreach (LocalTargetInfo t in targets)
{ {
Building building = t.Thing as Building; if (t.Thing is Building_CumBucket building)
if (building != null)
{
if (building is Building_CumBucket)
{ {
opts.AddDistinct(MakeMenu(pawn, building)); opts.AddDistinct(MakeMenu(pawn, building));
break; break;
} }
} }
} }
}
public static FloatMenuOption MakeMenu(Pawn pawn, LocalTargetInfo target) public static FloatMenuOption MakeMenu(Pawn pawn, LocalTargetInfo target)
{ {
@ -146,5 +49,4 @@ namespace RJWSexperience
return option; return option;
} }
} }
} }

View file

@ -74,6 +74,7 @@
<Compile Include="Patches\DefInjection.cs" /> <Compile Include="Patches\DefInjection.cs" />
<Compile Include="Patches\GetGizmos.cs" /> <Compile Include="Patches\GetGizmos.cs" />
<Compile Include="Recipe_HymenSurgery.cs" /> <Compile Include="Recipe_HymenSurgery.cs" />
<Compile Include="SexHistory\RecordRandomizer.cs" />
<Compile Include="RJWUtility.cs" /> <Compile Include="RJWUtility.cs" />
<Compile Include="SexHistory\HistoryUtility.cs" /> <Compile Include="SexHistory\HistoryUtility.cs" />
<Compile Include="SexHistory\SexHistory.cs" /> <Compile Include="SexHistory\SexHistory.cs" />

View file

@ -35,8 +35,7 @@ namespace RJWSexperience
/// </summary> /// </summary>
public static bool IsVirgin(this Pawn pawn) public static bool IsVirgin(this Pawn pawn)
{ {
if (pawn.records.GetValue(VariousDefOf.VaginalSexCount) == 0) return true; return pawn.records.GetValue(VariousDefOf.VaginalSexCount) == 0;
return false;
} }
public static bool HasHymen(this Pawn pawn) public static bool HasHymen(this Pawn pawn)
{ {
@ -132,10 +131,8 @@ namespace RJWSexperience
DetermineGiversAndReceivers(props, out Pawn giver, out Pawn receiver); DetermineGiversAndReceivers(props, out Pawn giver, out Pawn receiver);
if (partner != null) if (partner != null)
{ {
switch (sextype) switch (sextype)
{ {
case xxx.rjwSextype.Vaginal: case xxx.rjwSextype.Vaginal:
@ -151,7 +148,7 @@ namespace RJWSexperience
{ {
IncreaseRecords(giver, receiver, VariousDefOf.OralSexCount, VariousDefOf.BlowjobCount); IncreaseRecords(giver, receiver, VariousDefOf.OralSexCount, VariousDefOf.BlowjobCount);
} }
else if (Genital_Helper.has_penis_infertile(receiver) || Genital_Helper.has_penis_infertile(receiver)) else if (Genital_Helper.has_penis_fertile(receiver) || Genital_Helper.has_penis_infertile(receiver))
{ {
IncreaseRecords(giver, receiver, VariousDefOf.BlowjobCount, VariousDefOf.OralSexCount); IncreaseRecords(giver, receiver, VariousDefOf.BlowjobCount, VariousDefOf.OralSexCount);
} }
@ -251,90 +248,6 @@ namespace RJWSexperience
partner.records?.AddTo(recordforpartner, 1); partner.records?.AddTo(recordforpartner, 1);
} }
public static void GenerateSextypeRecords(Pawn pawn, int totalsex)
{
float totalweight =
RJWPreferenceSettings.vaginal +
RJWPreferenceSettings.anal +
RJWPreferenceSettings.fellatio +
RJWPreferenceSettings.cunnilingus +
RJWPreferenceSettings.rimming +
RJWPreferenceSettings.double_penetration +
RJWPreferenceSettings.breastjob +
RJWPreferenceSettings.handjob +
RJWPreferenceSettings.mutual_masturbation +
RJWPreferenceSettings.fingering +
RJWPreferenceSettings.footjob +
RJWPreferenceSettings.scissoring +
RJWPreferenceSettings.fisting +
RJWPreferenceSettings.sixtynine;
Gender prefer = pawn.PreferGender();
int sex = (int)(totalsex * RJWPreferenceSettings.vaginal / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.VaginalSexCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.anal / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.AnalSexCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.fellatio / totalweight);
totalsex -= sex;
if (prefer == Gender.Male) pawn.records.AddTo(VariousDefOf.BlowjobCount, sex);
else pawn.records.AddTo(VariousDefOf.OralSexCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.cunnilingus / totalweight);
totalsex -= sex;
if (prefer == Gender.Male) pawn.records.AddTo(VariousDefOf.OralSexCount, sex);
else pawn.records.AddTo(VariousDefOf.CunnilingusCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.rimming / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.MiscSexualBehaviorCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.double_penetration / totalweight) / 2;
totalsex -= sex;
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.VaginalSexCount, sex);
pawn.records.AddTo(VariousDefOf.AnalSexCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.breastjob / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.MiscSexualBehaviorCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.handjob / totalweight);
totalsex -= sex;
if (prefer == Gender.Male) pawn.records.AddTo(VariousDefOf.HandjobCount, sex);
else pawn.records.AddTo(VariousDefOf.GenitalCaressCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.fingering / totalweight);
totalsex -= sex;
if (prefer == Gender.Female) pawn.records.AddTo(VariousDefOf.FingeringCount, sex);
else pawn.records.AddTo(VariousDefOf.GenitalCaressCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.mutual_masturbation / totalweight);
totalsex -= sex;
if (prefer == Gender.Male) pawn.records.AddTo(VariousDefOf.HandjobCount, sex);
else pawn.records.AddTo(VariousDefOf.FingeringCount, sex);
pawn.records.AddTo(VariousDefOf.GenitalCaressCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.footjob / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.FootjobCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.scissoring / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.MiscSexualBehaviorCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.fisting / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.MiscSexualBehaviorCount, sex);
pawn.records.AddTo(VariousDefOf.OralSexCount, totalsex);
if (prefer == Gender.Male) pawn.records.AddTo(VariousDefOf.BlowjobCount, totalsex);
else pawn.records.AddTo(VariousDefOf.CunnilingusCount, totalsex);
}
public static Gender PreferGender(this Pawn pawn) public static Gender PreferGender(this Pawn pawn)
{ {
if (pawn.gender == Gender.Male) if (pawn.gender == Gender.Male)
@ -349,18 +262,6 @@ namespace RJWSexperience
} }
} }
public static bool GetRapist(this SexProps props, out Pawn rapist)
{
if (!props.isRape)
{
rapist = null;
return false;
}
rapist = props.pawn;
return true;
}
public static bool IsBestiality(this SexProps props) public static bool IsBestiality(this SexProps props)
{ {
if (props.partner != null) if (props.partner != null)
@ -426,7 +327,5 @@ namespace RJWSexperience
} }
} }
} }
} }
} }

View file

@ -0,0 +1,196 @@
using rjw;
using System;
using Verse;
using RimWorld;
using UnityEngine;
namespace RJWSexperience
{
public static class RecordRandomizer
{
public static void Randomize(Pawn pawn)
{
int avgsex = -500;
bool isvirgin = Rand.Chance(Configurations.VirginRatio);
int totalsex = 0;
int totalbirth = 0;
int deviation = (int)Configurations.MaxSexCountDeviation;
if (pawn.story != null)
{
_ = RandomizeLust(pawn);
int sexableage = 0;
int minsexage = 0;
if (Configurations.MinSexableFromLifestage)
minsexage = (int)pawn.RaceProps.lifeStageAges.Find(x => x.def.reproductive).minAge;
else
minsexage = (int)(pawn.RaceProps.lifeExpectancy * Configurations.MinSexablePercent);
if (pawn.ageTracker.AgeBiologicalYears > minsexage)
{
sexableage = pawn.ageTracker.AgeBiologicalYears - minsexage;
avgsex = (int)(sexableage * Configurations.SexPerYear * StatPart_Lust.GetLustFactor(pawn));
}
if (pawn.relations != null && pawn.gender == Gender.Female)
{
totalbirth += pawn.relations.ChildrenCount;
totalsex += totalbirth;
pawn.records?.AddTo(xxx.CountOfSexWithHumanlikes, totalbirth);
pawn.records?.SetTo(xxx.CountOfBirthHuman, totalbirth);
if (totalbirth > 0) isvirgin = false;
}
if (!isvirgin)
{
if (xxx.is_rapist(pawn))
{
if (xxx.is_zoophile(pawn))
{
if (pawn.Has(Quirk.ChitinLover)) totalsex += RandomizeRecord(pawn, xxx.CountOfRapedInsects, avgsex, deviation);
else totalsex += RandomizeRecord(pawn, xxx.CountOfRapedAnimals, avgsex, deviation);
}
else
{
totalsex += RandomizeRecord(pawn, xxx.CountOfRapedHumanlikes, avgsex, deviation);
}
avgsex /= 8;
}
if (xxx.is_zoophile(pawn))
{
if (pawn.Has(Quirk.ChitinLover)) totalsex += RandomizeRecord(pawn, xxx.CountOfRapedInsects, avgsex, deviation);
else totalsex += RandomizeRecord(pawn, xxx.CountOfSexWithAnimals, avgsex, deviation);
avgsex /= 10;
}
else if (xxx.is_necrophiliac(pawn))
{
totalsex += RandomizeRecord(pawn, xxx.CountOfSexWithCorpse, avgsex, deviation);
avgsex /= 4;
}
if (pawn.IsSlave)
{
totalsex += RandomizeRecord(pawn, xxx.CountOfBeenRapedByAnimals, Rand.Range(-50, 10), Rand.Range(0, 10) * sexableage);
totalsex += RandomizeRecord(pawn, xxx.CountOfBeenRapedByHumanlikes, 0, Rand.Range(0, 100) * sexableage);
}
totalsex += RandomizeRecord(pawn, xxx.CountOfSexWithHumanlikes, avgsex, deviation);
if (totalsex > 0) pawn.records.AddTo(VariousDefOf.SexPartnerCount, Math.Max(1, Rand.Range(0, totalsex / 7)));
}
}
pawn.records?.SetTo(xxx.CountOfSex, totalsex);
GenerateSextypeRecords(pawn, totalsex);
}
public static float RandomizeLust(Pawn pawn)
{
float value = Utility.RandGaussianLike(Configurations.AvgLust - Configurations.MaxLustDeviation, Configurations.AvgLust + Configurations.MaxLustDeviation);
float minValue;
if (xxx.is_nympho(pawn))
minValue = 0;
else
minValue = float.MinValue;
value = Mathf.Clamp(value, minValue, float.MaxValue);
float recordvalue = pawn.records.GetValue(VariousDefOf.Lust);
pawn.records.AddTo(VariousDefOf.Lust, value - recordvalue);
return value;
}
private static int RandomizeRecord(Pawn pawn, RecordDef record, int avg, int dist, int min = 0, int max = int.MaxValue)
{
int value = (int)Mathf.Clamp(Utility.RandGaussianLike(avg - dist, avg + dist), min, max);
int recordvalue = pawn.records.GetAsInt(record);
pawn.records.AddTo(record, value - recordvalue);
return value;
}
private static void GenerateSextypeRecords(Pawn pawn, int totalsex)
{
float totalweight =
RJWPreferenceSettings.vaginal +
RJWPreferenceSettings.anal +
RJWPreferenceSettings.fellatio +
RJWPreferenceSettings.cunnilingus +
RJWPreferenceSettings.rimming +
RJWPreferenceSettings.double_penetration +
RJWPreferenceSettings.breastjob +
RJWPreferenceSettings.handjob +
RJWPreferenceSettings.mutual_masturbation +
RJWPreferenceSettings.fingering +
RJWPreferenceSettings.footjob +
RJWPreferenceSettings.scissoring +
RJWPreferenceSettings.fisting +
RJWPreferenceSettings.sixtynine;
Gender prefer = pawn.PreferGender();
int sex = (int)(totalsex * RJWPreferenceSettings.vaginal / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.VaginalSexCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.anal / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.AnalSexCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.fellatio / totalweight);
totalsex -= sex;
if (prefer == Gender.Male) pawn.records.AddTo(VariousDefOf.BlowjobCount, sex);
else pawn.records.AddTo(VariousDefOf.OralSexCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.cunnilingus / totalweight);
totalsex -= sex;
if (prefer == Gender.Male) pawn.records.AddTo(VariousDefOf.OralSexCount, sex);
else pawn.records.AddTo(VariousDefOf.CunnilingusCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.rimming / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.MiscSexualBehaviorCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.double_penetration / totalweight) / 2;
totalsex -= sex;
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.VaginalSexCount, sex);
pawn.records.AddTo(VariousDefOf.AnalSexCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.breastjob / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.MiscSexualBehaviorCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.handjob / totalweight);
totalsex -= sex;
if (prefer == Gender.Male) pawn.records.AddTo(VariousDefOf.HandjobCount, sex);
else pawn.records.AddTo(VariousDefOf.GenitalCaressCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.fingering / totalweight);
totalsex -= sex;
if (prefer == Gender.Female) pawn.records.AddTo(VariousDefOf.FingeringCount, sex);
else pawn.records.AddTo(VariousDefOf.GenitalCaressCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.mutual_masturbation / totalweight);
totalsex -= sex;
if (prefer == Gender.Male) pawn.records.AddTo(VariousDefOf.HandjobCount, sex);
else pawn.records.AddTo(VariousDefOf.FingeringCount, sex);
pawn.records.AddTo(VariousDefOf.GenitalCaressCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.footjob / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.FootjobCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.scissoring / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.MiscSexualBehaviorCount, sex);
sex = (int)(totalsex * RJWPreferenceSettings.fisting / totalweight);
totalsex -= sex;
pawn.records.AddTo(VariousDefOf.MiscSexualBehaviorCount, sex);
pawn.records.AddTo(VariousDefOf.OralSexCount, totalsex);
if (prefer == Gender.Male) pawn.records.AddTo(VariousDefOf.BlowjobCount, totalsex);
else pawn.records.AddTo(VariousDefOf.CunnilingusCount, totalsex);
}
}
}

View file

@ -1,65 +1,70 @@
using System; using RimWorld;
using System.Collections.Generic; using System;
using System.Linq; using UnityEngine;
using System.Text;
using System.Threading.Tasks;
using rjw;
using RimWorld;
using Verse; using Verse;
namespace RJWSexperience namespace RJWSexperience
{ {
/// <summary>
/// Lust changes SexFrequency stat
/// </summary>
public class StatPart_Lust : StatPart public class StatPart_Lust : StatPart
{ {
public float factor; public float factor; // Value is loaded from XML
public override string ExplanationPart(StatRequest req) public override string ExplanationPart(StatRequest req)
{ {
Pawn pawn = req.Thing as Pawn; if (req.HasThing && (req.Thing is Pawn pawn))
return Keyed.LustStatFactor(String.Format("{0:0.##}", pawn.LustFactor() * factor * 100)); {
return Keyed.LustStatFactor(String.Format("{0:0.##}", GetLustFactor(pawn) * factor * 100));
}
return null;
} }
public override void TransformValue(StatRequest req, ref float val) public override void TransformValue(StatRequest req, ref float val)
{ {
Pawn pawn = req.Thing as Pawn; if (req.HasThing && (req.Thing is Pawn pawn))
if (pawn != null) val *= pawn.LustFactor() * factor; val *= GetLustFactor(pawn) * factor;
} }
public static float GetLustFactor(Pawn pawn)
{
float lust = pawn.records.GetValue(VariousDefOf.Lust) * Configurations.LustEffectPower;
if (lust < 0)
{
lust = Mathf.Exp((lust + 200f * Mathf.Log(10f)) / 100f) - 100f;
}
else
{
lust = Mathf.Sqrt(100f * (lust + 25f)) - 50f;
} }
return 1 + lust / 100f;
}
}
/// <summary>
/// Make slaves more vulnurable
/// </summary>
public class StatPart_Slave : StatPart public class StatPart_Slave : StatPart
{ {
public float factor; public float factor; // Value is loaded from XML
public override string ExplanationPart(StatRequest req) public override string ExplanationPart(StatRequest req)
{ {
float fact = factor * 100; if (req.HasThing && ((req.Thing as Pawn)?.IsSlave == true))
Pawn pawn = req.Thing as Pawn;
if (pawn != null)
{ {
if (pawn.IsSlave) return Keyed.SlaveStatFactor(String.Format("{0:0.##}", factor * 100));
{
return Keyed.SlaveStatFactor(String.Format("{0:0.##}", fact));
}
} }
return Keyed.SlaveStatFactorDefault; return Keyed.SlaveStatFactorDefault;
} }
public override void TransformValue(StatRequest req, ref float val) public override void TransformValue(StatRequest req, ref float val)
{ {
Pawn pawn = req.Thing as Pawn; if (req.HasThing && ((req.Thing as Pawn)?.IsSlave == true))
if (pawn != null)
{
if (pawn.IsSlave)
{ {
val *= factor; val *= factor;
} }
} }
} }
}
} }

View file

@ -10,7 +10,6 @@ using UnityEngine;
namespace RJWSexperience namespace RJWSexperience
{ {
public static class Utility public static class Utility
{ {
public static System.Random random = new System.Random(Environment.TickCount); public static System.Random random = new System.Random(Environment.TickCount);
@ -46,44 +45,8 @@ namespace RJWSexperience
records.AddTo(record, value - recordval); records.AddTo(record, value - recordval);
} }
public static float RecordRandomizer(this Pawn pawn, RecordDef record, float avg, float dist, float min = 0, float max = float.MaxValue)
{
float value = Mathf.Clamp(RandGaussianLike(avg - dist,avg + dist),min,max);
float recordvalue = pawn.records.GetValue(record);
pawn.records.AddTo(record, value - recordvalue);
return value;
}
public static int RecordRandomizer(this Pawn pawn, RecordDef record, int avg, int dist, int min = 0, int max = int.MaxValue)
{
int value = (int)Mathf.Clamp(RandGaussianLike(avg - dist, avg + dist), min, max);
int recordvalue = pawn.records.GetAsInt(record);
pawn.records.AddTo(record, value - recordvalue);
return value;
}
public static float LustFactor(this Pawn pawn)
{
float lust = pawn.records.GetValue(VariousDefOf.Lust) * Configurations.LustEffectPower;
if (lust < 0)
{
lust = Mathf.Exp((lust + 200f * Mathf.Log(10f)) / 100f) - 100f;
}
else
{
lust = Mathf.Sqrt(100f*(lust + 25f)) - 50f;
}
return 1 + lust / 100f;
}
public static T GetAdjacentBuilding<T>(this Pawn pawn) where T : Building public static T GetAdjacentBuilding<T>(this Pawn pawn) where T : Building
{ {
if (pawn.Spawned) if (pawn.Spawned)
{ {
EdificeGrid edifice = pawn.Map.edificeGrid; EdificeGrid edifice = pawn.Map.edificeGrid;
@ -97,7 +60,6 @@ namespace RJWSexperience
return null; return null;
} }
public static float GetCumVolume(this Pawn pawn) public static float GetCumVolume(this Pawn pawn)
{ {
List<Hediff> hediffs = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn)); List<Hediff> hediffs = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn));
@ -112,11 +74,9 @@ namespace RJWSexperience
if (part == null) part = hediffs?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("ovipositorm")).InRandomOrder().FirstOrDefault()?.TryGetComp<CompHediffBodyPart>(); if (part == null) part = hediffs?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("ovipositorm")).InRandomOrder().FirstOrDefault()?.TryGetComp<CompHediffBodyPart>();
if (part == null) part = hediffs?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("tentacle")).InRandomOrder().FirstOrDefault()?.TryGetComp<CompHediffBodyPart>(); if (part == null) part = hediffs?.FindAll((Hediff hed) => hed.def.defName.ToLower().Contains("tentacle")).InRandomOrder().FirstOrDefault()?.TryGetComp<CompHediffBodyPart>();
return pawn.GetCumVolume(part); return pawn.GetCumVolume(part);
} }
public static float GetCumVolume(this Pawn pawn, CompHediffBodyPart part) public static float GetCumVolume(this Pawn pawn, CompHediffBodyPart part)
{ {
float res; float res;
@ -134,10 +94,8 @@ namespace RJWSexperience
return res; return res;
} }
public static float Normalization(this float num, float min, float max) public static float Normalization(this float num, float min, float max)
{ {
return (num - min)/(max - min); return (num - min)/(max - min);
} }
@ -152,89 +110,9 @@ namespace RJWSexperience
{ {
if (Configurations.EnableRecordRandomizer && pawn != null && xxx.is_human(pawn)) if (Configurations.EnableRecordRandomizer && pawn != null && xxx.is_human(pawn))
{ {
int avgsex = -500; RecordRandomizer.Randomize(pawn);
bool isvirgin = Rand.Chance(Configurations.VirginRatio);
int totalsex = 0;
int totalbirth = 0;
int deviation = (int)Configurations.MaxSexCountDeviation;
if (pawn.story != null)
{
float lust;
if (xxx.is_nympho(pawn)) lust = pawn.RecordRandomizer(VariousDefOf.Lust, Configurations.AvgLust, Configurations.MaxLustDeviation, 0);
else lust = pawn.RecordRandomizer(VariousDefOf.Lust, Configurations.AvgLust, Configurations.MaxLustDeviation, float.MinValue);
int sexableage = 0;
int minsexage = (int)(pawn.RaceProps.lifeExpectancy * Configurations.MinSexablePercent);
if (pawn.ageTracker.AgeBiologicalYears > minsexage)
{
sexableage = pawn.ageTracker.AgeBiologicalYears - minsexage;
avgsex = (int)(sexableage * Configurations.SexPerYear * pawn.LustFactor());
}
if (pawn.relations != null && pawn.gender == Gender.Female)
{
totalbirth += pawn.relations.ChildrenCount;
totalsex += totalbirth;
pawn.records?.AddTo(xxx.CountOfSexWithHumanlikes, totalbirth);
pawn.records?.SetTo(xxx.CountOfBirthHuman, totalbirth);
if (totalbirth > 0) isvirgin = false;
}
if (!isvirgin)
{
if (xxx.is_rapist(pawn))
{
if (xxx.is_zoophile(pawn))
{
if (pawn.Has(Quirk.ChitinLover)) totalsex += pawn.RecordRandomizer(xxx.CountOfRapedInsects, avgsex, deviation);
else totalsex += pawn.RecordRandomizer(xxx.CountOfRapedAnimals, avgsex, deviation);
}
else totalsex += pawn.RecordRandomizer(xxx.CountOfRapedHumanlikes, avgsex, deviation);
avgsex /= 8;
}
if (xxx.is_zoophile(pawn))
{
if (pawn.Has(Quirk.ChitinLover)) totalsex += pawn.RecordRandomizer(xxx.CountOfRapedInsects, avgsex, deviation);
else totalsex += pawn.RecordRandomizer(xxx.CountOfSexWithAnimals, avgsex, deviation);
avgsex /= 10;
}
else if (xxx.is_necrophiliac(pawn))
{
totalsex += pawn.RecordRandomizer(xxx.CountOfSexWithCorpse, avgsex, deviation);
avgsex /= 4;
}
if (pawn.IsSlave)
{
totalsex += pawn.RecordRandomizer(xxx.CountOfBeenRapedByAnimals, Rand.Range(-50, 10), Rand.Range(0, 10) * sexableage);
totalsex += pawn.RecordRandomizer(xxx.CountOfBeenRapedByHumanlikes, 0, Rand.Range(0, 100) * sexableage);
}
totalsex += pawn.RecordRandomizer(xxx.CountOfSexWithHumanlikes, avgsex, deviation);
if (totalsex > 0) pawn.records.AddTo(VariousDefOf.SexPartnerCount, Math.Max(1, Rand.Range(0, totalsex / 7)));
}
}
pawn.records?.SetTo(xxx.CountOfSex, totalsex);
RJWUtility.GenerateSextypeRecords(pawn, totalsex);
}
if (pawn.story?.traits != null)
{
if (pawn.IsVirgin())
{
int degree = 0;
if (pawn.gender == Gender.Female) degree = 2;
Trait virgin = new Trait(VariousDefOf.Virgin, degree, true);
pawn.story.traits.GainTrait(virgin);
}
else if (pawn.gender == Gender.Female && Rand.Chance(0.05f))
{
Trait virgin = new Trait(VariousDefOf.Virgin, 1, true);
pawn.story.traits.GainTrait(virgin);
}
} }
pawn.AddVirginTrait();
} }
else else
{ {