code
stringlengths
0
56.1M
repo_name
stringclasses
515 values
path
stringlengths
2
147
language
stringclasses
447 values
license
stringclasses
7 values
size
int64
0
56.8M
using Verse; using RimWorld; namespace rjw { /// <summary> /// FeelingBroken raise/lower severity /// </summary> public class HediffCompProperties_FeelingBrokenSeverityReduce : HediffCompProperties { public HediffCompProperties_FeelingBrokenSeverityReduce() { this.compClass = typeof(HediffComp_FeelingBrokenSeverityReduce); } public SimpleCurve severityPerDayReduce; } class HediffComp_FeelingBrokenSeverityReduce : HediffComp_SeverityPerDay { private HediffCompProperties_FeelingBrokenSeverityReduce Props { get { return (HediffCompProperties_FeelingBrokenSeverityReduce)this.props; } } public override void CompPostTick(ref float severityAdjustment) { base.CompPostTick(ref severityAdjustment); if (base.Pawn.IsHashIntervalTick(SeverityUpdateInterval)) { float num = this.SeverityChangePerDay(); num *= 0.00333333341f; if (xxx.has_traits(Pawn)) { if (xxx.RoMIsActive) if (Pawn.story.traits.HasTrait(TraitDef.Named("Succubus"))) num *= 4.0f; if (Pawn.story.traits.HasTrait(TraitDefOf.Tough)) { num *= 2.0f; } if (Pawn.story.traits.HasTrait(TraitDefOf.Tough)) { num *= 2.0f; } if (Pawn.story.traits.HasTrait(TraitDef.Named("Wimp"))) { num *= 0.5f; } if (Pawn.story.traits.HasTrait(TraitDefOf.Nerves)) { int td = Pawn.story.traits.DegreeOfTrait(TraitDefOf.Nerves); switch (td) { case -2: num *= 2.0f; break; case -1: num *= 1.5f; break; case 1: num *= 0.5f; break; case 2: num *= 0.25f; break; } } } severityAdjustment += num; } } protected override float SeverityChangePerDay() { return this.Props.severityPerDayReduce.Evaluate(this.parent.ageTicks / 60000f); } } public class HediffCompProperties_FeelingBrokenSeverityIncrease : HediffCompProperties { public HediffCompProperties_FeelingBrokenSeverityIncrease() { this.compClass = typeof(HediffComp_FeelingBrokenSeverityIncrease); } public SimpleCurve severityPerDayIncrease; } class HediffComp_FeelingBrokenSeverityIncrease : AdvancedHediffComp { private HediffCompProperties_FeelingBrokenSeverityIncrease Props { get { return (HediffCompProperties_FeelingBrokenSeverityIncrease)this.props; } } public override void CompPostMerged(Hediff other) { float num = Props.severityPerDayIncrease.Evaluate(this.parent.ageTicks / 60000f); if (xxx.has_traits(Pawn)) { if (xxx.RoMIsActive) if (Pawn.story.traits.HasTrait(TraitDef.Named("Succubus"))) num *= 0.25f; if (Pawn.story.traits.HasTrait(TraitDefOf.Tough)) { num *= 0.5f; } if (Pawn.story.traits.HasTrait(TraitDef.Named("Wimp"))) { num *= 2.0f; } if (Pawn.story.traits.HasTrait(TraitDefOf.Nerves)) { int td = Pawn.story.traits.DegreeOfTrait(TraitDefOf.Nerves); switch (td) { case -2: num *= 0.25f; break; case -1: num *= 0.5f; break; case 1: num *= 1.5f; break; case 2: num *= 2.0f; break; } } } other.Severity *= num; } } public class AdvancedHediffWithComps : HediffWithComps { public override bool TryMergeWith(Hediff other) { for (int i = 0; i < this.comps.Count; i++) { if(this.comps[i] is AdvancedHediffComp) ((AdvancedHediffComp)this.comps[i]).CompBeforeMerged(other); } return base.TryMergeWith(other); } } public class AdvancedHediffComp : HediffComp { public virtual void CompBeforeMerged(Hediff other) { } } }
Tirem12/rjw
Source/Hediffs/HediffComp_FeelingBroken.cs
C#
mit
3,685
using System.Linq; using Verse; using RimWorld; using System.Text; using Multiplayer.API; using UnityEngine; namespace rjw { //TODO figure out how this thing works and move eggs to comps [StaticConstructorOnStartup] public class HediffDef_PartBase : HediffDef { public bool discovered = false; public string Eggs = ""; //for ovi eggs, maybe public string FluidType = ""; //cummies/milk - insectjelly/honey etc public string DefaultBodyPart = ""; //Bodypart to move this part to, after fucking up with pc or other mod public float FluidAmmount = 0; //ammount of Milk/Ejaculation/Wetness public bool produceEggs; //set in xml public int minEggTick = 12000; public int maxEggTick = 120000; } }
Tirem12/rjw
Source/Hediffs/HediffDef_PartBase.cs
C#
mit
726
using RimWorld; using System.Collections.Generic; using System.Linq; using Verse; namespace rjw { public class Cocoon : HediffWithComps { public int tickNext; public override void PostMake() { Severity = 1.0f; SetNextTick(); } public override void ExposeData() { base.ExposeData(); Scribe_Values.Look(ref tickNext, "tickNext", 1000, true); } public override void Tick() { if (Find.TickManager.TicksGame >= tickNext) { //Log.Message("Cocoon::Tick() " + base.xxx.get_pawnname(pawn)); HealWounds(); SatisfyHunger(); SatisfyThirst(); SetNextTick(); } } public void HealWounds() { IEnumerable<Hediff> enumerable = from hd in pawn.health.hediffSet.hediffs where !hd.IsTended() && hd.TendableNow() select hd; if (enumerable != null) { foreach (Hediff item in enumerable) { HediffWithComps val = item as HediffWithComps; if (val != null) if (val.Bleeding) { //Log.Message("TrySealWounds " + xxx.get_pawnname(pawn) + ", Bleeding " + item.Label); //HediffComp_TendDuration val2 = HediffUtility.TryGetComp<HediffComp_TendDuration>(val); val.Heal(0.25f); //val2.tendQuality = 1f; //val2.tendTicksLeft = 10000; //pawn.health.Notify_HediffChanged(item); } // tend infections // tend lifeThreatening chronic else if ((!val.def.chronic && val.def.lethalSeverity > 0f) || (val.CurStage?.lifeThreatening ?? false)) { //Log.Message("TryHeal " + xxx.get_pawnname(pawn) + ", infection(?) " + item.Label); HediffComp_TendDuration val2 = HediffUtility.TryGetComp<HediffComp_TendDuration>(val); val2.tendQuality = 1f; val2.tendTicksLeft = 10000; pawn.health.Notify_HediffChanged(item); } } } } public void SatisfyHunger() { Need_Food need = pawn.needs.TryGetNeed<Need_Food>(); if (need == null) { return; } //pawn.PositionHeld.IsInPrisonCell(pawn.Map) //Log.Message("Cocoon::SatisfyHunger() " + xxx.get_pawnname(pawn) + " IsInPrisonCell " + pawn.PositionHeld.IsInPrisonCell(pawn.Map)); //Log.Message("Cocoon::SatisfyHunger() " + xxx.get_pawnname(pawn) + " GetRoom " + pawn.PositionHeld.GetRoom(pawn.Map)); //Log.Message("Cocoon::SatisfyHunger() " + xxx.get_pawnname(pawn) + " GetRoom " + pawn.PositionHeld.GetZone(pawn.Map)); if (need.CurLevel < 0.15f) { //Log.Message("Cocoon::SatisfyHunger() " + xxx.get_pawnname(pawn) + " need to eat"); float nutrition_amount = need.MaxLevel / 5f; pawn.needs.food.CurLevel += nutrition_amount; } } public void SatisfyThirst() { if (!xxx.DubsBadHygieneIsActive) return; Need need = pawn.needs.AllNeeds.Find(x => x.def == DefDatabase<NeedDef>.GetNamed("DBHThirst")); if (need == null) { return; } if (need.CurLevel < 0.15f) { //Log.Message("Cocoon::SatisfyThirst() " + xxx.get_pawnname(pawn) + " need to drink"); float nutrition_amount = need.MaxLevel / 5f; pawn.needs.TryGetNeed(need.def).CurLevel += nutrition_amount; } } public void SetNextTick() { //make actual tick every 16.6 sec tickNext = Find.TickManager.TicksGame + 1000; //Log.Message("Cocoon::SetNextTick() " + tickNext); } } }
Tirem12/rjw
Source/Hediffs/Hediff_Cocoon.cs
C#
mit
3,285
using Verse; namespace rjw { public class Hediff_ID : Hediff { public override string LabelBase { get { if (!pawn.health.hediffSet.HasHediff(std.hiv.hediff_def)) return base.LabelBase; else return "AIDS"; } } } }
Tirem12/rjw
Source/Hediffs/Hediff_ID.cs
C#
mit
252
using System.Linq; using Verse; using RimWorld; using System.Text; using Multiplayer.API; using UnityEngine; namespace rjw { public class Hediff_PartBaseArtifical : Hediff_Implant { public override bool ShouldRemove => false; public bool discovered = false; // Used for ovipositors. public int nextEggTick = -1; public override void ExposeData() { base.ExposeData(); Scribe_Values.Look(ref this.nextEggTick, "nextEggTick"); // Scribe_Values.Look(ref this.produceEggs, "produceEggs"); // Scribe_Defs.Look(ref this.pawnKindDefOverride, "pawnKindDefOverride"); // Scribe_Values.Look(ref this.genitalType, "genitalType"); } public override string LabelBase { get { /* * make patch to make/save capmods? if (CapMods.Count < 5) { PawnCapacityModifier pawnCapacityModifier = new PawnCapacityModifier(); pawnCapacityModifier.capacity = PawnCapacityDefOf.Moving; pawnCapacityModifier.offset += 0.5f; CapMods.Add(pawnCapacityModifier); } */ //name/kind return this.def.label; } } //public override string LabelInBrackets //{ // get // { // string size = "on fire!"; // size = (this.comps.Find(x => x is CompHediffBodyPart) as CompHediffBodyPart).Size; // return size; // //vanilla // //return (this.CurStage != null && !this.CurStage.label.NullOrEmpty()) ? this.CurStage.label : null; // } //} //overrides comps //public override string TipStringExtra //{ // get // { // StringBuilder stringBuilder = new StringBuilder(); // foreach (StatDrawEntry current in HediffStatsUtility.SpecialDisplayStats(this.CurStage, this)) // { // if (current.ShouldDisplay) // { // stringBuilder.AppendLine(current.LabelCap + ": " + current.ValueString); // } // } // //stringBuilder.AppendLine("Size: " + this.TryGetComp<CompHediffBodyPart>.Size); // //stringBuilder.AppendLine("1");// size? // //stringBuilder.AppendLine("2");// erm something? // return stringBuilder.ToString(); // } //} /// <summary> /// stack hediff in health tab? /// </summary> public override int UIGroupKey { get { if (RJWSettings.StackRjwParts) //(Label x count) return this.Label.GetHashCode(); else //dont return loadID; } } /// <summary> /// do not merge same rjw parts into one /// </summary> public override bool TryMergeWith(Hediff other) { return false; } /// <summary> /// show rjw parts in health tab or not /// </summary> public override bool Visible { get { if (RJWSettings.ShowRjwParts == RJWSettings.ShowParts.Hide) { discovered = false; } else if (!discovered) { if (RJWSettings.ShowRjwParts == RJWSettings.ShowParts.Show) { discovered = true; return discovered; } //show at game start if (Current.ProgramState != ProgramState.Playing && Prefs.DevMode) return true; //show for hero if (pawn.IsDesignatedHero() && pawn.IsHeroOwner()) { discovered = true; return discovered; } //show if no clothes if (pawn.apparel != null)// animals? { bool hasPants; bool hasShirt; pawn.apparel.HasBasicApparel(out hasPants, out hasShirt);// naked? if (!hasPants) { bool flag3 = false; foreach (BodyPartRecord current in this.pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined, null, null)) { if (current.IsInGroup(BodyPartGroupDefOf.Legs)) { flag3 = true; break; } } if (!flag3) { hasPants = true; } } if (this.def.defName.ToLower().Contains("breast") || this.def.defName.ToLower().Contains("chest")) discovered = !hasShirt; else discovered = !hasPants; } } return discovered; } } /// <summary> /// egg production ticks /// </summary> [SyncMethod] public override void Tick() { ageTicks++; if (!pawn.IsHashIntervalTick(10000)) // run every ~3min { return; } var partBase = def as HediffDef_PartBase; if (partBase != null) { if (partBase.produceEggs) { var IsPlayerFaction = pawn.Faction?.IsPlayer ?? false; //colonists/animals if (pawn.Map.IsPlayerHome || IsPlayerFaction || pawn.IsPrisonerOfColony) { ageTicks++; if (nextEggTick < 0) { nextEggTick = Rand.Range(partBase.minEggTick, partBase.maxEggTick); return; } if (pawn.health.capacities.GetLevel(PawnCapacityDefOf.Moving) <= 0.5) { return; } if (nextEggTick > 0 && ageTicks >= nextEggTick) { float maxEggsSize = (pawn.BodySize / 5) * (xxx.has_quirk(pawn, "Incubator") ? 2f : 1f) * (Genital_Helper.has_ovipositorF(pawn) ? 2f : 0.5f); float eggedsize = 0; foreach (var ownEgg in pawn.health.hediffSet.GetHediffs<Hediff_InsectEgg>()) { if (ownEgg.father != null) eggedsize += ownEgg.father.RaceProps.baseBodySize / 5; else eggedsize += ownEgg.implanter.RaceProps.baseBodySize / 5; } if (RJWSettings.DevMode) Log.Message($"{xxx.get_pawnname(pawn)} filled with {eggedsize} out of max capacity of {maxEggsSize} eggs."); if (eggedsize < maxEggsSize) { HediffDef_InsectEgg egg = null; string defname = ""; while (egg == null) { if (defname == "") { if (RJWSettings.DevMode) Log.Message(" trying to find " + pawn.kindDef.defName + " egg"); defname = pawn.kindDef.defName; } else { if (RJWSettings.DevMode) Log.Message(" no " + defname + " egg found, defaulting to Unknown egg"); defname = "Unknown"; } //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); egg = (from x in DefDatabase<HediffDef_InsectEgg>.AllDefs where x.IsParent(defname) select x) .RandomElement(); } if (RJWSettings.DevMode) Log.Message("I choose you " + egg + "!"); var genitals = Genital_Helper.get_genitalsBPR(pawn); if (genitals != null) { var addedEgg = pawn.health.AddHediff(egg, genitals) as Hediff_InsectEgg; addedEgg?.Implanter(pawn); } } // Reset for next egg. ageTicks = 0; nextEggTick = -1; } } } } } } }
Tirem12/rjw
Source/Hediffs/Hediff_PartBaseArtifical.cs
C#
mit
6,554
using System.Linq; using Verse; using RimWorld; using System.Text; using Multiplayer.API; using UnityEngine; namespace rjw { public class Hediff_PartBaseNatural : HediffWithComps { public override bool ShouldRemove => false; public bool discovered = false; // Used for ovipositors. public int nextEggTick = -1; public override void ExposeData() { base.ExposeData(); Scribe_Values.Look(ref this.nextEggTick, "nextEggTick"); // Scribe_Values.Look(ref this.produceEggs, "produceEggs"); // Scribe_Defs.Look(ref this.pawnKindDefOverride, "pawnKindDefOverride"); // Scribe_Values.Look(ref this.genitalType, "genitalType"); } public override string LabelBase { get { /* * make patch to make/save capmods? if (CapMods.Count < 5) { PawnCapacityModifier pawnCapacityModifier = new PawnCapacityModifier(); pawnCapacityModifier.capacity = PawnCapacityDefOf.Moving; pawnCapacityModifier.offset += 0.5f; CapMods.Add(pawnCapacityModifier); } */ //name/kind return this.def.label; } } //public override string LabelInBrackets //{ // get // { // string size = "on fire!"; // size = (this.comps.Find(x => x is CompHediffBodyPart) as CompHediffBodyPart).Size; // return size; // //vanilla // //return (this.CurStage != null && !this.CurStage.label.NullOrEmpty()) ? this.CurStage.label : null; // } //} //overrides comps //public override string TipStringExtra //{ // get // { // StringBuilder stringBuilder = new StringBuilder(); // foreach (StatDrawEntry current in HediffStatsUtility.SpecialDisplayStats(this.CurStage, this)) // { // if (current.ShouldDisplay) // { // stringBuilder.AppendLine(current.LabelCap + ": " + current.ValueString); // } // } // //stringBuilder.AppendLine("Size: " + this.TryGetComp<CompHediffBodyPart>.Size); // //stringBuilder.AppendLine("1");// size? // //stringBuilder.AppendLine("2");// erm something? // return stringBuilder.ToString(); // } //} /// <summary> /// stack hediff in health tab? /// </summary> public override int UIGroupKey { get { if (RJWSettings.StackRjwParts) //(Label x count) return this.Label.GetHashCode(); else //dont return loadID; } } /// <summary> /// do not merge same rjw parts into one /// </summary> public override bool TryMergeWith(Hediff other) { return false; } /// <summary> /// show rjw parts in health tab or not /// </summary> public override bool Visible { get { if (RJWSettings.ShowRjwParts == RJWSettings.ShowParts.Hide) { discovered = false; } else if (!discovered) { if (RJWSettings.ShowRjwParts == RJWSettings.ShowParts.Show) { discovered = true; return discovered; } //show at game start if (Current.ProgramState != ProgramState.Playing && Prefs.DevMode) return true; //show for hero if (pawn.IsDesignatedHero() && pawn.IsHeroOwner()) { discovered = true; return discovered; } //show if no clothes if (pawn.apparel != null)// animals? { bool hasPants; bool hasShirt; pawn.apparel.HasBasicApparel(out hasPants, out hasShirt);// naked? if (!hasPants) { bool flag3 = false; foreach (BodyPartRecord current in this.pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined, null, null)) { if (current.IsInGroup(BodyPartGroupDefOf.Legs)) { flag3 = true; break; } } if (!flag3) { hasPants = true; } } if (this.def.defName.ToLower().Contains("breast") || this.def.defName.ToLower().Contains("chest")) discovered = !hasShirt; else discovered = !hasPants; } } return discovered; } } /// <summary> /// egg production ticks /// </summary> [SyncMethod] public override void Tick() { ageTicks++; if (!pawn.IsHashIntervalTick(10000)) // run every ~3min { return; } var partBase = def as HediffDef_PartBase; if (partBase != null) { if (partBase.produceEggs) { var IsPlayerFaction = pawn.Faction?.IsPlayer ?? false; //colonists/animals var IsPlayerHome = pawn.Map?.IsPlayerHome ?? false; if (IsPlayerHome || IsPlayerFaction || pawn.IsPrisonerOfColony) { if (nextEggTick < 0) { nextEggTick = Rand.Range(partBase.minEggTick, partBase.maxEggTick); return; } if (pawn.health.capacities.GetLevel(PawnCapacityDefOf.Moving) <= 0.5) { return; } if (nextEggTick > 0 && ageTicks >= nextEggTick) { float maxEggsSize = (pawn.BodySize / 5) * (xxx.has_quirk(pawn, "Incubator") ? 2f : 1f) * (Genital_Helper.has_ovipositorF(pawn) ? 2f : 0.5f); float eggedsize = 0; foreach (var ownEgg in pawn.health.hediffSet.GetHediffs<Hediff_InsectEgg>()) { if (ownEgg.father != null) eggedsize += ownEgg.father.RaceProps.baseBodySize / 5; else eggedsize += ownEgg.implanter.RaceProps.baseBodySize / 5; } if (RJWSettings.DevMode) Log.Message($"{xxx.get_pawnname(pawn)} filled with {eggedsize} out of max capacity of {maxEggsSize} eggs."); if (eggedsize < maxEggsSize) { HediffDef_InsectEgg egg = null; string defname = ""; while (egg == null) { if (defname == "") { if (RJWSettings.DevMode) Log.Message(" trying to find " + pawn.kindDef.defName + " egg"); defname = pawn.kindDef.defName; } else { if (RJWSettings.DevMode) Log.Message(" no " + defname + " egg found, defaulting to Unknown egg"); defname = "Unknown"; } //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); egg = (from x in DefDatabase<HediffDef_InsectEgg>.AllDefs where x.IsParent(defname) select x) .RandomElement(); } if (RJWSettings.DevMode) Log.Message("I choose you " + egg + "!"); var genitals = Genital_Helper.get_genitalsBPR(pawn); if (genitals != null) { var addedEgg = pawn.health.AddHediff(egg, genitals) as Hediff_InsectEgg; addedEgg?.Implanter(pawn); } } // Reset for next egg. ageTicks = 0; nextEggTick = -1; } } } } } } }
Tirem12/rjw
Source/Hediffs/Hediff_PartBaseNatural.cs
C#
mit
6,582
using System.Linq; using Verse; namespace rjw { public class Hediff_PartsSizeChangerPC : HediffWithComps { public override void PostAdd(DamageInfo? dinfo) { foreach (Hediff hed in pawn.health.hediffSet.hediffs.Where(x => x.Part != null && x.Part == Part && (x is Hediff_PartBaseNatural || x is Hediff_PartBaseArtifical)).ToList()) { CompHediffBodyPart CompHediff = hed.TryGetComp<rjw.CompHediffBodyPart>(); if (CompHediff != null) { //Log.Message(" Hediff_PartsSizeChanger: " + hed.Label); //Log.Message(" Hediff_PartsSizeChanger: " + hed.Severity); //Log.Message(" Hediff_PartsSizeChanger: " + CompHediff.SizeBase); //Log.Message(" Hediff_PartsSizeChanger: " + "-----"); //Log.Message(" Hediff_PartsSizeChanger: " + this.Label); //Log.Message(" Hediff_PartsSizeChanger: " + this.Severity); CompHediff.SizeBase = this.CurStage.minSeverity; CompHediff.initComp(reroll: true); CompHediff.updatesize(); //Log.Message(" Hediff_PartsSizeChanger: " + "-----"); //Log.Message(" Hediff_PartsSizeChanger: " + hed.Label); //Log.Message(" Hediff_PartsSizeChanger: " + hed.Severity); //Log.Message(" Hediff_PartsSizeChanger: " + CompHediff.SizeBase); } } pawn.health.RemoveHediff(this); } } public class Hediff_PartsSizeChangerCE : HediffWithComps { public override void PostAdd(DamageInfo? dinfo) { foreach (Hediff hed in pawn.health.hediffSet.hediffs.Where(x => x.Part != null && x.Part == Part && (x is Hediff_PartBaseNatural || x is Hediff_PartBaseArtifical)).ToList()) { CompHediffBodyPart CompHediff = hed.TryGetComp<rjw.CompHediffBodyPart>(); if (CompHediff != null) { CompHediff.SizeBase = this.def.initialSeverity; CompHediff.initComp(reroll: true); CompHediff.updatesize(); } } pawn.health.RemoveHediff(this); } } }
Tirem12/rjw
Source/Hediffs/Hediff_PartsSizeChanger.cs
C#
mit
1,881
using Verse; //Hediff worker for pawns' "lay down and submit" button namespace rjw { public class Hediff_Submitting: HediffWithComps { public override bool ShouldRemove { get { Pawn daddy = pawn.CarriedBy; if (daddy != null && daddy.Faction == pawn.Faction) { return true; } else return base.ShouldRemove; } } } }
Tirem12/rjw
Source/Hediffs/Hediff_Submitting.cs
C#
mit
364
using System; using System.Collections.Generic; using System.Linq; using Verse; namespace rjw { public class PartSizeExtension : DefModExtension { /// <summary> /// Human standard would be 1.0. Null for no weight display. /// </summary> public float? density = null; public List<float> lengths; public List<float> girths; public List<float> cupSizes; public static bool TryGetLength(Hediff hediff, out float size) { return TryGetSizeFromCurve(hediff, extension => extension.lengths, true, out size); } public static bool TryGetGirth(Hediff hediff, out float size) { return TryGetSizeFromCurve(hediff, extension => extension.girths, true, out size); } public static bool TryGetCupSize(Hediff hediff, out float size) { // Cup size is already "scaled" because the same breast volume has a smaller cup size on a larger band size. return TryGetSizeFromCurve(hediff, extension => extension.cupSizes, false, out size); } public static float GetBandSize(Hediff hediff) { var size = GetUnderbustSize(hediff); size /= PartStagesDef.Instance.bandSizeInterval; size = (float)Math.Round(size, MidpointRounding.AwayFromZero); size *= PartStagesDef.Instance.bandSizeInterval; return size; } public static float GetUnderbustSize(Hediff hediff) { return PartStagesDef.Instance.bandSizeBase * GetLinearScale(hediff); } static float GetLinearScale(Hediff hediff) { return (float)Math.Pow(hediff.pawn.BodySize, 1.0 / 3.0); } public static bool TryGetOverbustSize(Hediff hediff, out float size) { if (!TryGetCupSize(hediff, out var cupSize)) { size = 0f; return false; } // Cup size is rounded up, so to do the math backwards subtract .9 size = GetUnderbustSize(hediff) + ((cupSize - .9f) * PartStagesDef.Instance.cupSizeInterval); return true; } static bool TryGetSizeFromCurve( Hediff hediff, Func<PartSizeExtension, List<float>> getList, bool shouldScale, out float size) { if (!hediff.def.HasModExtension<PartSizeExtension>()) { size = 0f; return false; } var extension = hediff.def.GetModExtension<PartSizeExtension>(); var list = getList(extension); if (list == null) { size = 0f; return false; } var curve = new SimpleCurve(hediff.def.stages.Zip(list, (stage, size) => new CurvePoint(stage.minSeverity, size))); var scaleFactor = shouldScale ? GetLinearScale(hediff) : 1.0f; size = curve.Evaluate(hediff.Severity) * scaleFactor; return true; } public static bool TryGetPenisWeight(Hediff hediff, out float weight) { if (!TryGetLength(hediff, out float length) || !TryGetGirth(hediff, out float girth)) { weight = 0f; return false; } var density = hediff.def.GetModExtension<PartSizeExtension>().density; if (density == null) { weight = 0f; return false; } var r = girth / (2.0 * Math.PI); var volume = r * r * Math.PI * length; weight = (float)(volume * density.Value / 1000f); return true; } public static bool TryGetBreastWeight(Hediff hediff, out float weight) { if (!TryGetCupSize(hediff, out float rawSize)) { weight = 0f; return false; } var density = hediff.def.GetModExtension<PartSizeExtension>().density; if (density == null) { weight = 0f; return false; } // Up a band size and down a cup size is about the same volume. var extraBandSize = PartStagesDef.Instance.bandSizeBase * (1.0f - GetLinearScale(hediff)); var extraCupSizes = extraBandSize / PartStagesDef.Instance.bandSizeInterval; var size = rawSize + extraCupSizes; var pounds = 0.765f + 0.415f * size + -0.0168f * size * size + 2.47E-03f * size * size * size; var kg = Math.Max(0, pounds * 0.45359237f); weight = kg * density.Value; return true; } } }
Tirem12/rjw
Source/Hediffs/PartSizeExtension.cs
C#
mit
3,860
using System.Collections.Generic; using System.Text; using RimWorld; using Verse; namespace rjw { internal class InteractionWorker_AnalSexAttempt : InteractionWorker { //initiator - rapist //recipient - victim public static bool AttemptAnalSex(Pawn initiator, Pawn recipient) { //--Log.Message(xxx.get_pawnname(initiator) + " is attempting to anally rape " + xxx.get_pawnname(recipient)); return true; } public override float RandomSelectionWeight(Pawn initiator, Pawn recipient) { // this interaction is triggered by the jobdriver if (initiator == null || recipient == null) return 0.0f; return 0.0f; // base.RandomSelectionWeight(initiator, recipient); } public override void Interacted(Pawn initiator, Pawn recipient, List<RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef, out LookTargets lookTargets) { //add something fancy here later? letterText = null; letterLabel = null; letterDef = null; lookTargets = recipient; //Find.LetterStack.ReceiveLetter("Rape attempt", "A wandering nymph has decided to join your colony.", LetterDefOf.NegativeEvent, recipient); if (initiator == null || recipient == null) return; //--Log.Message("[RJW] InteractionWorker_AnalRapeAttempt::Interacted( " + xxx.get_pawnname(initiator) + ", " + xxx.get_pawnname(recipient) + " ) called"); AttemptAnalSex(initiator, recipient); } } internal class InteractionWorker_VaginalSexAttempt : InteractionWorker { //initiator - rapist //recipient - victim public static bool AttemptAnalSex(Pawn initiator, Pawn recipient) { //--Log.Message(xxx.get_pawnname(initiator) + " is attempting to anally rape " + xxx.get_pawnname(recipient)); return false; } public override float RandomSelectionWeight(Pawn initiator, Pawn recipient) { // this interaction is triggered by the jobdriver if (initiator == null || recipient == null) return 0.0f; return 0.0f; // base.RandomSelectionWeight(initiator, recipient); } public override void Interacted(Pawn initiator, Pawn recipient, List<RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef, out LookTargets lookTargets) { //add something fancy here later? letterText = null; letterLabel = null; letterDef = null; lookTargets = recipient; //Find.LetterStack.ReceiveLetter("Rape attempt", "A wandering nymph has decided to join your colony.", LetterDefOf.NegativeEvent, recipient); if (initiator == null || recipient == null) return; //--Log.Message("[RJW] InteractionWorker_AnalRapeAttempt::Interacted( " + xxx.get_pawnname(initiator) + ", " + xxx.get_pawnname(recipient) + " ) called"); AttemptAnalSex(initiator, recipient); } } internal class InteractionWorker_OtherSexAttempt : InteractionWorker { //initiator - rapist //recipient - victim public static bool AttemptAnalSex(Pawn initiator, Pawn recipient) { //--Log.Message(xxx.get_pawnname(initiator) + " is attempting to anally rape " + xxx.get_pawnname(recipient)); return false; } public override float RandomSelectionWeight(Pawn initiator, Pawn recipient) { // this interaction is triggered by the jobdriver if (initiator == null || recipient == null) return 0.0f; return 0.0f; // base.RandomSelectionWeight(initiator, recipient); } public override void Interacted(Pawn initiator, Pawn recipient, List<RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef, out LookTargets lookTargets) { //add something fancy here later? letterText = null; letterLabel = null; letterDef = null; lookTargets = recipient; //Find.LetterStack.ReceiveLetter("Rape attempt", "A wandering nymph has decided to join your colony.", LetterDefOf.NegativeEvent, recipient); if (initiator == null || recipient == null) return; //--Log.Message("[RJW] InteractionWorker_AnalRapeAttempt::Interacted( " + xxx.get_pawnname(initiator) + ", " + xxx.get_pawnname(recipient) + " ) called"); AttemptAnalSex(initiator, recipient); } } }
Tirem12/rjw
Source/Interactions/InteractionWorker_SexAttempt.cs
C#
mit
4,164
using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; using Multiplayer.API; namespace rjw { public class JobDriver_BestialityForFemale : JobDriver_SexBaseInitiator { public IntVec3 SleepSpot => Bed.SleepPosOfAssignedPawn(pawn); public override bool TryMakePreToilReservations(bool errorOnFailed) { return pawn.Reserve(Target, job, 1, 0, null, errorOnFailed); } [SyncMethod] protected override IEnumerable<Toil> MakeNewToils() { setup_ticks(); this.FailOnDespawnedOrNull(iTarget); this.FailOnDespawnedNullOrForbidden(iBed); this.FailOn(() => !pawn.CanReserveAndReach(Partner, PathEndMode.Touch, Danger.Deadly)); this.FailOn(() => pawn.Drafted); this.FailOn(() => Partner.IsFighting()); this.FailOn(() => !Partner.CanReach(pawn, PathEndMode.Touch, Danger.Deadly)); yield return Toils_Reserve.Reserve(iTarget, 1, 0); Toil gotoAnimal = Toils_Goto.GotoThing(iTarget, PathEndMode.Touch); yield return gotoAnimal; Toil gotoBed = new Toil(); gotoBed.defaultCompleteMode = ToilCompleteMode.PatherArrival; gotoBed.FailOnBedNoLongerUsable(iBed); gotoBed.AddFailCondition(() => Partner.Downed); gotoBed.initAction = delegate { pawn.pather.StartPath(SleepSpot, PathEndMode.OnCell); Partner.jobs.StopAll(); Job job = JobMaker.MakeJob(JobDefOf.GotoMindControlled, SleepSpot); Partner.jobs.StartJob(job, JobCondition.InterruptForced); }; yield return gotoBed; Toil waitInBed = new Toil(); waitInBed.FailOn(() => pawn.GetRoom(RegionType.Set_Passable) == null); waitInBed.defaultCompleteMode = ToilCompleteMode.Delay; waitInBed.initAction = delegate { ticksLeftThisToil = 5000; }; waitInBed.tickAction = delegate { pawn.GainComfortFromCellIfPossible(); if (IsInOrByBed(Bed, Partner) && pawn.PositionHeld == Partner.PositionHeld) { ReadyForNextToil(); } }; yield return waitInBed; Toil StartPartnerJob = new Toil(); StartPartnerJob.defaultCompleteMode = ToilCompleteMode.Instant; StartPartnerJob.socialMode = RandomSocialMode.Off; StartPartnerJob.initAction = delegate { var gettin_loved = JobMaker.MakeJob(xxx.gettin_loved, pawn, Bed); Partner.jobs.StartJob(gettin_loved, JobCondition.InterruptForced); }; yield return StartPartnerJob; Toil loveToil = new Toil(); loveToil.AddFailCondition(() => Partner.Dead || !IsInOrByBed(Bed, Partner)); loveToil.socialMode = RandomSocialMode.Off; loveToil.defaultCompleteMode = ToilCompleteMode.Never; loveToil.handlingFacing = true; loveToil.initAction = delegate { usedCondom = CondomUtility.TryUseCondom(pawn); Start(); }; loveToil.AddPreTickAction(delegate { --ticks_left; if (pawn.IsHashIntervalTick(ticks_between_hearts)) if (xxx.is_zoophile(pawn)) ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); else ThrowMetaIcon(pawn.Position, pawn.Map, xxx.mote_noheart); SexTick(pawn, Partner); SexUtility.reduce_rest(pawn, 1); SexUtility.reduce_rest(Partner, 2); if (ticks_left <= 0) ReadyForNextToil(); }); loveToil.AddFinishAction(delegate { End(); }); yield return loveToil; Toil afterSex = new Toil { initAction = delegate { //Log.Message("JobDriver_BestialityForFemale::MakeNewToils() - Calling aftersex"); SexUtility.ProcessSex(Partner, pawn, usedCondom: usedCondom, sextype: sexType); }, defaultCompleteMode = ToilCompleteMode.Instant }; yield return afterSex; } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_BestialityForFemale.cs
C#
mit
3,562
using System.Collections.Generic; using System.Linq; using RimWorld; using Verse; using Verse.AI; using Multiplayer.API; namespace rjw { public class JobDriver_BestialityForMale : JobDriver_Rape { public override bool TryMakePreToilReservations(bool errorOnFailed) { return pawn.Reserve(Target, job, 1, 0, null, errorOnFailed); } [SyncMethod] protected override IEnumerable<Toil> MakeNewToils() { //--Log.Message("[RJW] JobDriver_BestialityForMale::MakeNewToils() called"); setup_ticks(); //this.FailOn (() => (!Partner.health.capacities.CanBeAwake) || (!comfort_prisoners.is_designated (Partner))); // Fail if someone else reserves the prisoner before the pawn arrives or colonist can't reach animal this.FailOn(() => !pawn.CanReserveAndReach(Partner, PathEndMode.Touch, Danger.Deadly)); this.FailOn(() => Partner.HostileTo(pawn)); this.FailOnDespawnedNullOrForbidden(iTarget); this.FailOn(() => pawn.Drafted); yield return Toils_Reserve.Reserve(iTarget, 1, 0); //Log.Message("[RJW] JobDriver_BestialityForMale::MakeNewToils() - moving towards animal"); yield return Toils_Goto.GotoThing(iTarget, PathEndMode.Touch); yield return Toils_Interpersonal.WaitToBeAbleToInteract(pawn); yield return Toils_Interpersonal.GotoInteractablePosition(iTarget); if (xxx.is_kind(pawn) || (xxx.CTIsActive && xxx.has_traits(pawn) && pawn.story.traits.HasTrait(TraitDef.Named("RCT_AnimalLover")))) { yield return TalkToAnimal(pawn, Partner); yield return TalkToAnimal(pawn, Partner); } if (Rand.Chance(0.6f)) yield return TalkToAnimal(pawn, Partner); yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell); SexUtility.RapeTargetAlert(pawn, Partner); Toil rape = new Toil(); rape.defaultCompleteMode = ToilCompleteMode.Delay; rape.defaultDuration = duration; rape.handlingFacing = true; rape.initAction = delegate { //--Log.Message("[RJW] JobDriver_BestialityForMale::MakeNewToils() - Setting animal job driver"); if (!(Partner.jobs.curDriver is JobDriver_SexBaseRecieverRaped dri)) { //wild animals may flee or attack if (pawn.Faction != Partner.Faction && Partner.RaceProps.wildness > Rand.Range(0.22f, 1.0f) && !(pawn.TicksPerMoveCardinal < (Partner.TicksPerMoveCardinal / 2) && !Partner.Downed && xxx.is_not_dying(Partner))) { Partner.jobs.StopAll(); // Wake up if sleeping. float aggro = Partner.kindDef.RaceProps.manhunterOnTameFailChance; if (Partner.kindDef.RaceProps.predator) aggro += 0.2f; else aggro -= 0.1f; if (Rand.Chance(aggro) && Partner.CanSee(pawn)) { Partner.rotationTracker.FaceTarget(pawn); LifeStageUtility.PlayNearestLifestageSound(Partner, (ls) => ls.soundAngry, 1.4f); ThrowMetaIcon(Partner.Position, Partner.Map, ThingDefOf.Mote_IncapIcon); ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_ColonistFleeing); //red '!' Partner.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter); if (Partner.kindDef.RaceProps.herdAnimal && Rand.Chance(0.2f)) { // 20% chance of turning the whole herd hostile... List<Pawn> packmates = Partner.Map.mapPawns.AllPawnsSpawned.Where(x => x != Partner && x.def == Partner.def && x.Faction == Partner.Faction && x.Position.InHorDistOf(Partner.Position, 24f) && x.CanSee(Partner)).ToList(); foreach (Pawn packmate in packmates) { packmate.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter); } } Messages.Message(pawn.Name.ToStringShort + " is being attacked by " + xxx.get_pawnname(Partner) + ".", pawn, MessageTypeDefOf.ThreatSmall); } else { ThrowMetaIcon(Partner.Position, Partner.Map, ThingDefOf.Mote_ColonistFleeing); LifeStageUtility.PlayNearestLifestageSound(Partner, (ls) => ls.soundCall); Partner.mindState.StartFleeingBecauseOfPawnAction(pawn); Partner.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.PanicFlee); } pawn.jobs.EndCurrentJob(JobCondition.Incompletable); } else { Job gettin_bred = JobMaker.MakeJob(xxx.gettin_bred, pawn, Partner); Partner.jobs.StartJob(gettin_bred, JobCondition.InterruptForced, null, true); (Partner.jobs.curDriver as JobDriver_SexBaseRecieverRaped)?.increase_time(ticks_left); Start(); } } else { Start(); } }; rape.tickAction = delegate { if (pawn.IsHashIntervalTick(ticks_between_hearts)) if (xxx.is_zoophile(pawn)) ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); else ThrowMetaIcon(pawn.Position, pawn.Map, xxx.mote_noheart); SexTick(pawn, Partner); /* if (pawn.IsHashIntervalTick (ticks_between_hits)) roll_to_hit (pawn, Partner); */ SexUtility.reduce_rest(Partner, 1); SexUtility.reduce_rest(pawn, 2); }; rape.AddFinishAction(delegate { End(); }); yield return rape; yield return new Toil { initAction = delegate { //Log.Message("[RJW] JobDriver_BestialityForMale::MakeNewToils() - creating aftersex toil"); SexUtility.ProcessSex(pawn, Partner, usedCondom: usedCondom, sextype: sexType); }, defaultCompleteMode = ToilCompleteMode.Instant }; } [SyncMethod] private Toil TalkToAnimal(Pawn pawn, Pawn animal) { Toil toil = new Toil(); toil.initAction = delegate { pawn.interactions.TryInteractWith(animal, SexUtility.AnimalSexChat); }; //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); toil.defaultCompleteMode = ToilCompleteMode.Delay; toil.defaultDuration = Rand.Range(120, 220); return toil; } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_BestialityForMale.cs
C#
mit
5,813
using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; using Multiplayer.API; namespace rjw { /// <summary> /// This is the driver for animals mounting breeders. /// </summary> public class JobDriver_Breeding : JobDriver_Rape { public override bool TryMakePreToilReservations(bool errorOnFailed) { return pawn.Reserve(Target, job, BreederHelper.max_animals_at_once, 0); } [SyncMethod] protected override IEnumerable<Toil> MakeNewToils() { setup_ticks(); //--Log.Message("JobDriver_Breeding::MakeNewToils() - setting fail conditions"); this.FailOnDespawnedNullOrForbidden(iTarget); this.FailOn(() => !pawn.CanReserve(Partner, BreederHelper.max_animals_at_once, 0)); // Fail if someone else reserves the target before the animal arrives. this.FailOn(() => !pawn.CanReach(Partner, PathEndMode.Touch, Danger.Some)); // Fail if animal cannot reach target. this.FailOn(() => pawn.Drafted); // Path to target yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell); //if (!(pawn.IsDesignatedBreedingAnimal() && Partner.IsDesignatedBreeding())); if (!(pawn.IsAnimal() && Partner.IsAnimal())) SexUtility.RapeTargetAlert(pawn, Partner); Toil StartPartnerJob = new Toil(); StartPartnerJob.defaultCompleteMode = ToilCompleteMode.Instant; StartPartnerJob.socialMode = RandomSocialMode.Off; StartPartnerJob.initAction = delegate { var dri = Partner.jobs.curDriver as JobDriver_SexBaseRecieverRaped; if (dri == null) { Job gettin_raped = JobMaker.MakeJob(xxx.gettin_raped, pawn); Building_Bed Bed = null; if (Partner.GetPosture() == PawnPosture.LayingInBed) Bed = Partner.CurrentBed(); Partner.jobs.StartJob(gettin_raped, JobCondition.InterruptForced, null, false, true, null); if (Bed != null) (Partner.jobs.curDriver as JobDriver_SexBaseRecieverRaped)?.Set_bed(Bed); } }; yield return StartPartnerJob; // Breed target var breed = new Toil(); breed.defaultCompleteMode = ToilCompleteMode.Delay; breed.defaultDuration = duration; breed.handlingFacing = true; breed.initAction = delegate { Start(); }; breed.tickAction = delegate { if (pawn.IsHashIntervalTick(ticks_between_hearts)) if (xxx.is_zoophile(pawn) || xxx.is_animal(pawn)) ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); else ThrowMetaIcon(pawn.Position, pawn.Map, xxx.mote_noheart); if (pawn.IsHashIntervalTick(ticks_between_hits) && !xxx.is_zoophile(Partner)) Roll_to_hit(pawn, Partner); SexTick(pawn, Partner); if (!Partner.Dead) SexUtility.reduce_rest(Partner, 1); SexUtility.reduce_rest(pawn, 2); }; breed.AddFinishAction(delegate { End(); }); yield return breed; yield return new Toil { initAction = delegate { //Log.Message("JobDriver_Breeding::MakeNewToils() - Calling aftersex"); //// Trying to add some interactions and social logs bool isRape = !(pawn.relations.DirectRelationExists(PawnRelationDefOf.Bond, Partner) || (xxx.is_animal(pawn) && (pawn.RaceProps.wildness - pawn.RaceProps.petness + 0.18f) > Rand.Range(0.36f, 1.8f))); SexUtility.ProcessSex(pawn, Partner, usedCondom: usedCondom, rape: isRape, sextype: sexType); }, defaultCompleteMode = ToilCompleteMode.Instant }; } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_Breeding.cs
C#
mit
3,382
using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; using Multiplayer.API; namespace rjw { public class JobDriver_Masturbate_Bed : JobDriver_SexBaseInitiator { public override bool TryMakePreToilReservations(bool errorOnFailed) { return pawn.Reserve(Bed, job, 1, 0, null, errorOnFailed); } [SyncMethod] new public void setup_ticks() { base.setup_ticks(); // Faster fapping when frustrated. duration = (int)(xxx.is_frustrated(pawn) ? 2500.0f * Rand.Range(0.2f, 0.7f) : 2500.0f * Rand.Range(0.2f, 0.4f)); } protected override IEnumerable<Toil> MakeNewToils() { setup_ticks(); //this.FailOn(() => PawnUtility.PlayerForcedJobNowOrSoon(pawn)); this.FailOn(() => pawn.health.Downed); this.FailOn(() => pawn.IsBurning()); this.FailOn(() => pawn.IsFighting()); this.FailOn(() => pawn.Drafted); Toil findfapspot = new Toil { initAction = delegate { pawn.pather.StartPath(Bed.Position, PathEndMode.OnCell); }, defaultCompleteMode = ToilCompleteMode.PatherArrival }; yield return findfapspot; Toil fap = Toils_General.Wait(duration); fap.handlingFacing = true; fap.initAction = delegate { Start(); }; fap.tickAction = delegate { --duration; if (pawn.IsHashIntervalTick(ticks_between_hearts)) ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); SexTick(pawn, null); SexUtility.reduce_rest(pawn, 1); if (duration <= 0) ReadyForNextToil(); }; fap.AddFinishAction(delegate { End(); }); yield return fap; yield return new Toil { initAction = delegate { SexUtility.Aftersex(pawn, xxx.rjwSextype.Masturbation); if (!SexUtility.ConsiderCleaning(pawn)) return; LocalTargetInfo own_cum = pawn.PositionHeld.GetFirstThing<Filth>(pawn.Map); Job clean = JobMaker.MakeJob(JobDefOf.Clean); clean.AddQueuedTarget(TargetIndex.A, own_cum); pawn.jobs.jobQueue.EnqueueFirst(clean); }, defaultCompleteMode = ToilCompleteMode.Instant }; } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_Masturbate_Bed.cs
C#
mit
2,071
using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; using Multiplayer.API; namespace rjw { public class JobDriver_Masturbate_Quick : JobDriver_SexBaseInitiator { public override bool TryMakePreToilReservations(bool errorOnFailed) { return true; // No reservations needed. } public IntVec3 cell => (IntVec3)job.GetTarget(iCell); [SyncMethod] new public void setup_ticks() { base.setup_ticks(); // Faster fapping when frustrated. duration = (int)(xxx.is_frustrated(pawn) ? 2500.0f * Rand.Range(0.2f, 0.7f) : 2500.0f * Rand.Range(0.2f, 0.4f)); } protected override IEnumerable<Toil> MakeNewToils() { setup_ticks(); //this.FailOn(() => PawnUtility.PlayerForcedJobNowOrSoon(pawn)); this.FailOn(() => pawn.health.Downed); this.FailOn(() => pawn.IsBurning()); this.FailOn(() => pawn.IsFighting()); this.FailOn(() => pawn.Drafted); Toil findfapspot = new Toil { initAction = delegate { pawn.pather.StartPath(cell, PathEndMode.OnCell); }, defaultCompleteMode = ToilCompleteMode.PatherArrival }; yield return findfapspot; //Log.Message("[RJW] Making new toil for QuickFap."); Toil fap = Toils_General.Wait(duration); fap.handlingFacing = true; fap.initAction = delegate { Start(); }; fap.tickAction = delegate { --duration; if (pawn.IsHashIntervalTick(ticks_between_hearts)) ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); SexTick(pawn, null); SexUtility.reduce_rest(pawn, 1); if (duration <= 0) ReadyForNextToil(); }; fap.AddFinishAction(delegate { End(); }); yield return fap; yield return new Toil { initAction = delegate { SexUtility.Aftersex(pawn, xxx.rjwSextype.Masturbation); if (!SexUtility.ConsiderCleaning(pawn)) return; LocalTargetInfo own_cum = pawn.PositionHeld.GetFirstThing<Filth>(pawn.Map); Job clean = JobMaker.MakeJob(JobDefOf.Clean); clean.AddQueuedTarget(TargetIndex.A, own_cum); pawn.jobs.jobQueue.EnqueueFirst(clean); }, defaultCompleteMode = ToilCompleteMode.Instant }; } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_Masturbate_Quick.cs
C#
mit
2,161
using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; using Multiplayer.API; namespace rjw { /// <summary> /// This is the driver for animals mating. /// </summary> public class JobDriver_Mating : JobDriver_Rape { public override bool TryMakePreToilReservations(bool errorOnFailed) { return pawn.Reserve(Target, job, BreederHelper.max_animals_at_once, 0); } [SyncMethod] protected override IEnumerable<Toil> MakeNewToils() { setup_ticks(); //--Log.Message("JobDriver_Mating::MakeNewToils() - setting fail conditions"); this.FailOnDespawnedNullOrForbidden(iTarget); this.FailOn(() => !pawn.CanReserve(Partner, BreederHelper.max_animals_at_once, 0)); // Fail if someone else reserves the target before the animal arrives. this.FailOn(() => !pawn.CanReach(Partner, PathEndMode.Touch, Danger.Some)); // Fail if animal cannot reach target. this.FailOn(() => pawn.Drafted); // Path to target yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell); Toil StartPartnerJob = new Toil(); StartPartnerJob.defaultCompleteMode = ToilCompleteMode.Instant; StartPartnerJob.socialMode = RandomSocialMode.Off; StartPartnerJob.initAction = delegate { var dri = Partner.jobs.curDriver as JobDriver_SexBaseRecieverLoved; if (dri == null) { Job gettin_loved = JobMaker.MakeJob(xxx.gettin_loved, pawn); Building_Bed Bed = null; if (Partner.GetPosture() == PawnPosture.LayingInBed) Bed = Partner.CurrentBed(); Partner.jobs.StartJob(gettin_loved, JobCondition.InterruptForced, null, false, true, null); if (Bed != null) (Partner.jobs.curDriver as JobDriver_SexBaseRecieverLoved)?.Set_bed(Bed); } }; yield return StartPartnerJob; // Mate target var mate = new Toil(); mate.defaultCompleteMode = ToilCompleteMode.Delay; mate.defaultDuration = duration; mate.handlingFacing = true; mate.initAction = delegate { Start(); }; mate.tickAction = delegate { if (pawn.IsHashIntervalTick(ticks_between_hearts)) ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); SexTick(pawn, Partner); if (!Partner.Dead) SexUtility.reduce_rest(Partner, 1); SexUtility.reduce_rest(pawn, 2); }; mate.AddFinishAction(delegate { End(); }); yield return mate; yield return new Toil { initAction = delegate { bool isRape = false; SexUtility.ProcessSex(pawn, Partner, usedCondom: usedCondom, rape: isRape, sextype: sexType); }, defaultCompleteMode = ToilCompleteMode.Instant }; } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_Mating.cs
C#
mit
2,613
using System; using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; namespace rjw { public class JobDriver_Rape : JobDriver_SexBaseInitiator { public override bool TryMakePreToilReservations(bool errorOnFailed) { return pawn.Reserve(Target, job, xxx.max_rapists_per_prisoner, 0, null, errorOnFailed); } protected override IEnumerable<Toil> MakeNewToils() { if (RJWSettings.DebugRape) Log.Message("[RJW]" + this.GetType().ToString() + "::MakeNewToils() called"); setup_ticks(); this.FailOnDespawnedNullOrForbidden(iTarget); this.FailOn(() => !pawn.CanReserve(Partner, xxx.max_rapists_per_prisoner, 0)); // Fail if someone else reserves the prisoner before the pawn arrives this.FailOn(() => pawn.IsFighting()); this.FailOn(() => Partner.IsFighting()); this.FailOn(() => pawn.Drafted); yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell); SexUtility.RapeTargetAlert(pawn, Partner); Toil StartPartnerJob = new Toil(); StartPartnerJob.defaultCompleteMode = ToilCompleteMode.Instant; StartPartnerJob.socialMode = RandomSocialMode.Off; StartPartnerJob.initAction = delegate { var dri = Partner.jobs.curDriver as JobDriver_SexBaseRecieverRaped; if (dri == null) { Job gettin_raped = JobMaker.MakeJob(xxx.gettin_raped, pawn); Building_Bed Bed = null; if (Partner.GetPosture() == PawnPosture.LayingInBed) Bed = Partner.CurrentBed(); Partner.jobs.StartJob(gettin_raped, JobCondition.InterruptForced, null, false, true, null); if (Bed != null) (Partner.jobs.curDriver as JobDriver_SexBaseRecieverRaped)?.Set_bed(Bed); } }; yield return StartPartnerJob; var rape = new Toil(); rape.FailOn(() => Partner.CurJob == null || Partner.CurJob.def != xxx.gettin_raped || Partner.IsFighting() || pawn.IsFighting()); rape.defaultCompleteMode = ToilCompleteMode.Delay; rape.defaultDuration = duration; rape.handlingFacing = true; rape.initAction = delegate { Start(); }; rape.tickAction = delegate { if (pawn.IsHashIntervalTick(ticks_between_hearts)) ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); if (pawn.IsHashIntervalTick(ticks_between_hits)) Roll_to_hit(pawn, Partner); SexTick(pawn, Partner); SexUtility.reduce_rest(Partner, 1); SexUtility.reduce_rest(pawn, 2); }; rape.AddFinishAction(delegate { End(); }); yield return rape; yield return new Toil { initAction = delegate { //// Trying to add some interactions and social logs SexUtility.ProcessSex(pawn, Partner, usedCondom: usedCondom, rape: isRape, sextype: sexType); }, defaultCompleteMode = ToilCompleteMode.Instant }; } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_Rape.cs
C#
mit
2,761
using System; using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; namespace rjw { public class JobDriver_RapeComfortPawn : JobDriver_Rape { protected override IEnumerable<Toil> MakeNewToils() { if (RJWSettings.DebugRape) Log.Message("[RJW]" + this.GetType().ToString() + "::MakeNewToils() called"); setup_ticks(); this.FailOnDespawnedNullOrForbidden(iTarget); //this.FailOn(() => (!Partner.health.capacities.CanBeAwake) || (!comfort_prisoners.is_designated(Partner)));//this is wrong this.FailOn(() => (!Partner.IsDesignatedComfort())); this.FailOn(() => !pawn.CanReserve(Partner, xxx.max_rapists_per_prisoner, 0)); // Fail if someone else reserves the prisoner before the pawn arrives this.FailOn(() => pawn.Drafted); yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell); SexUtility.RapeTargetAlert(pawn, Partner); Toil StartPartnerJob = new Toil(); StartPartnerJob.defaultCompleteMode = ToilCompleteMode.Instant; StartPartnerJob.socialMode = RandomSocialMode.Off; StartPartnerJob.initAction = delegate { var dri = Partner.jobs.curDriver as JobDriver_SexBaseRecieverRaped; if (dri == null) { Job gettin_raped = JobMaker.MakeJob(xxx.gettin_raped, pawn); Building_Bed Bed = null; if (Partner.GetPosture() == PawnPosture.LayingInBed) Bed = Partner.CurrentBed(); Partner.jobs.StartJob(gettin_raped, JobCondition.InterruptForced, null, false, true, null); if (Bed != null) (Partner.jobs.curDriver as JobDriver_SexBaseRecieverRaped)?.Set_bed(Bed); } }; yield return StartPartnerJob; Toil rape = new Toil(); rape.defaultCompleteMode = ToilCompleteMode.Delay; rape.defaultDuration = duration; rape.handlingFacing = true; rape.initAction = delegate { // Unlike normal rape try use comfort prisoner condom CondomUtility.GetCondomFromRoom(Partner); usedCondom = CondomUtility.TryUseCondom(Partner); if (RJWSettings.DebugRape) Log.Message("JobDriver_RapeComfortPawn::MakeNewToils() - reserving prisoner"); //pawn.Reserve(Partner, xxx.max_rapists_per_prisoner, 0); Start(); }; rape.tickAction = delegate { if (pawn.IsHashIntervalTick(ticks_between_hearts)) ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); if (pawn.IsHashIntervalTick(ticks_between_hits)) Roll_to_hit(pawn, Partner); SexTick(pawn, Partner); SexUtility.reduce_rest(Partner, 1); SexUtility.reduce_rest(pawn, 2); }; rape.AddFinishAction(delegate { End(); }); yield return rape; yield return new Toil { initAction = delegate { // Trying to add some interactions and social logs SexUtility.ProcessSex(pawn, Partner, usedCondom: usedCondom, rape: isRape, sextype: sexType); Partner.records.Increment(xxx.GetRapedAsComfortPawn); }, defaultCompleteMode = ToilCompleteMode.Instant }; } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_RapeComfortPawn.cs
C#
mit
2,944
using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; using Verse.Sound; namespace rjw { public class JobDriver_ViolateCorpse : JobDriver_Rape { public override bool TryMakePreToilReservations(bool errorOnFailed) { return pawn.Reserve(Target, job, 1, -1, null, errorOnFailed); } protected override IEnumerable<Toil> MakeNewToils() { if (RJWSettings.DebugRape) Log.Message("[RJW] JobDriver_ViolateCorpse::MakeNewToils() called"); setup_ticks(); this.FailOnDespawnedNullOrForbidden(iTarget); this.FailOn(() => !pawn.CanReserve(Target, 1, 0)); // Fail if someone else reserves the prisoner before the pawn arrives this.FailOn(() => pawn.IsFighting()); this.FailOn(() => pawn.Drafted); this.FailOn(Target.IsBurning); if (RJWSettings.DebugRape) Log.Message("[RJW] JobDriver_ViolateCorpse::MakeNewToils() - moving towards Target"); yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell); var alert = RJWPreferenceSettings.rape_attempt_alert == RJWPreferenceSettings.RapeAlert.Disabled ? MessageTypeDefOf.SilentInput : MessageTypeDefOf.NeutralEvent; Messages.Message(xxx.get_pawnname(pawn) + " is trying to rape a corpse of " + xxx.get_pawnname(Partner), pawn, alert); setup_ticks();// re-setup ticks on arrival var rape = new Toil(); rape.defaultCompleteMode = ToilCompleteMode.Delay; rape.defaultDuration = duration; rape.handlingFacing = true; rape.initAction = delegate { if (RJWSettings.DebugRape) Log.Message("[RJW] JobDriver_ViolateCorpse::MakeNewToils() - stripping Target"); (Target as Corpse).Strip(); Start(); }; rape.tickAction = delegate { if (pawn.IsHashIntervalTick(ticks_between_hearts)) if (xxx.is_necrophiliac(pawn)) ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); else ThrowMetaIcon(pawn.Position, pawn.Map, xxx.mote_noheart); //if (pawn.IsHashIntervalTick (ticks_between_hits)) // roll_to_hit (pawn, Target); SexTick(pawn, Target); SexUtility.reduce_rest(pawn, 2); }; rape.AddFinishAction(delegate { End(); }); yield return rape; yield return new Toil { initAction = delegate { if (RJWSettings.DebugRape) Log.Message("[RJW] JobDriver_ViolateCorpse::MakeNewToils() - creating aftersex toil"); SexUtility.ProcessSex(pawn, Partner, usedCondom: usedCondom, rape: isRape, sextype: sexType); }, defaultCompleteMode = ToilCompleteMode.Instant }; } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_RapeCorpse.cs
C#
mit
2,508
using System; using System.Collections.Generic; using System.Linq; using RimWorld; using Verse; using Verse.AI; using Multiplayer.API; namespace rjw { internal class JobDef_RapeEnemy : JobDef { public List<string> TargetDefNames = new List<string>(); public int priority = 0; protected JobDriver_RapeEnemy instance { get { if (_tmpInstance == null) { _tmpInstance = (JobDriver_RapeEnemy)Activator.CreateInstance(driverClass); } return _tmpInstance; } } private JobDriver_RapeEnemy _tmpInstance; public virtual bool CanUseThisJobForPawn(Pawn rapist) { if (rapist.CurJob != null && rapist.CurJob.def != JobDefOf.LayDown) return false; return instance.CanUseThisJobForPawn(rapist);// || TargetDefNames.Contains(rapist.def.defName); } public virtual Pawn FindVictim(Pawn rapist, Map m) { return instance.FindVictim(rapist, m); } } public class JobDriver_RapeEnemy : JobDriver_Rape { private static readonly HediffDef is_submitting = HediffDef.Named("Hediff_Submitting");//used in find_victim //override can_rape mechanics protected bool requireCanRape = true; public virtual bool CanUseThisJobForPawn(Pawn rapist) { return xxx.is_human(rapist); } // this is probably useseless, maybe there be something in future public virtual bool considerStillAliveEnemies => true; [SyncMethod] public virtual Pawn FindVictim(Pawn rapist, Map m) { if (RJWSettings.DebugRape) Log.Message($"[RJW] {this.GetType().ToString()}::TryGiveJob({xxx.get_pawnname(rapist)}) map {m?.ToString()}"); if (rapist == null || m == null) return null; if (RJWSettings.DebugRape) Log.Message($"[RJW] {this.GetType().ToString()}::TryGiveJob({xxx.get_pawnname(rapist)}) can rape = {xxx.can_rape(rapist)}"); if (requireCanRape && !xxx.can_rape(rapist)) return null; List<Pawn> validTargets = new List<Pawn>(); float min_fuckability = 0.10f; // Don't rape pawns with <10% fuckability float avg_fuckability = 0f; // Average targets fuckability, choose target higher than that var valid_targets = new Dictionary<Pawn, float>(); // Valid pawns and their fuckability Pawn chosentarget = null; // Final target pawn IEnumerable<Pawn> targets = m.mapPawns.AllPawnsSpawned.Where(x => !x.IsForbidden(rapist) && x != rapist && x.HostileTo(rapist) && rapist.CanReserveAndReach(x, PathEndMode.Touch, Danger.Some, xxx.max_rapists_per_prisoner, 0) && IsValidTarget(rapist, x)) .ToList(); if (targets.Any(x => IsBlocking(rapist, x))) { return null; } foreach (var target in targets) { if (!xxx.can_path_to_target(rapist, target.Position)) continue;// too far float fuc = GetFuckability(rapist, target); if (fuc > min_fuckability) valid_targets.Add(target, fuc); } if (valid_targets.Any()) { avg_fuckability = valid_targets.Average(x => x.Value); // choose pawns to fuck with above average fuckability var valid_targetsFiltered = valid_targets.Where(x => x.Value >= avg_fuckability); if (valid_targetsFiltered.Any()) chosentarget = valid_targetsFiltered.RandomElement().Key; } return chosentarget; } bool IsBlocking(Pawn rapist, Pawn target) { return considerStillAliveEnemies && !target.Downed && rapist.CanSee(target); } bool IsValidTarget(Pawn rapist, Pawn target) { if (!RJWSettings.bestiality_enabled) { if (xxx.is_animal(target) && xxx.is_human(rapist)) { //bestiality disabled, skip. return false; } if (xxx.is_animal(rapist) && xxx.is_human(target)) { //bestiality disabled, skip. return false; } } if (!RJWSettings.animal_on_animal_enabled) if ((xxx.is_animal(target) && xxx.is_animal(rapist))) { //animal_on_animal disabled, skip. return false; } if (target.CurJob?.def == xxx.gettin_raped || target.CurJob?.def == xxx.gettin_loved) { //already having sex with someone, skip, give chance to other victims. return false; } return Can_rape_Easily(target) && (xxx.is_human(target) || xxx.is_animal(target)) && rapist.CanReserveAndReach(target, PathEndMode.OnCell, Danger.Some, xxx.max_rapists_per_prisoner, 0); } public virtual float GetFuckability(Pawn rapist, Pawn target) { float fuckability = 0; if (target.health.hediffSet.HasHediff(is_submitting)) // it's not about attractiveness anymore, it's about showing who's whos bitch { fuckability = 2 * SexAppraiser.would_fuck(rapist, target, invert_opinion: true, ignore_bleeding: true, ignore_gender: true); } else if (SexAppraiser.would_rape(rapist, target)) { fuckability = SexAppraiser.would_fuck(rapist, target, invert_opinion: true, ignore_bleeding: true, ignore_gender: true); } if (RJWSettings.DebugRape) Log.Message($"[RJW] JobDriver_RapeEnemy::GetFuckability({xxx.get_pawnname(rapist)}, {xxx.get_pawnname(target)})"); return fuckability; } protected bool Can_rape_Easily(Pawn pawn) { return xxx.can_get_raped(pawn) && !pawn.IsBurning(); } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_RapeEnemy.cs
C#
mit
5,165
using RimWorld; using Verse; namespace rjw { internal class JobDriver_RapeEnemyByAnimal : JobDriver_RapeEnemy { public override bool CanUseThisJobForPawn(Pawn rapist) { if (rapist.CurJob != null && (rapist.CurJob.def != JobDefOf.LayDown || rapist.CurJob.def != JobDefOf.Wait_Wander || rapist.CurJob.def != JobDefOf.GotoWander)) return false; return xxx.is_animal(rapist) && !xxx.is_insect(rapist); } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_RapeEnemyByAnimal.cs
C#
mit
424
using RimWorld; using Verse; namespace rjw { internal class JobDriver_RapeEnemyByHumanlike : JobDriver_RapeEnemy { public override bool CanUseThisJobForPawn(Pawn rapist) { if (rapist.CurJob != null && (rapist.CurJob.def != JobDefOf.LayDown || rapist.CurJob.def != JobDefOf.Wait_Wander || rapist.CurJob.def != JobDefOf.GotoWander)) return false; return xxx.is_human(rapist); } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_RapeEnemyByHumanlike.cs
C#
mit
400
using System.Linq; using RimWorld; using Verse; namespace rjw { internal class JobDriver_RapeEnemyByInsect : JobDriver_RapeEnemy { public override bool CanUseThisJobForPawn(Pawn rapist) { if (rapist.CurJob != null && (rapist.CurJob.def != JobDefOf.LayDown || rapist.CurJob.def != JobDefOf.Wait_Wander || rapist.CurJob.def != JobDefOf.GotoWander)) return false; return xxx.is_insect(rapist); } public override float GetFuckability(Pawn rapist, Pawn target) { //Female plant Eggs to everyone. if (rapist.gender == Gender.Female) //Genital_Helper.has_ovipositorF(rapist); { //only rape when target dont have eggs yet //if ((from x in target.health.hediffSet.GetHediffs<Hediff_InsectEgg>() where (x.IsParent(rapist)) select x).Count() > 0) { return 1f; } } //Male rape to everyone. //Feritlize eggs to target with planted eggs. else //Genital_Helper.has_ovipositorM(rapist); { //only rape target when can fertilize //if ((from x in target.health.hediffSet.GetHediffs<Hediff_InsectEgg>() where (x.IsParent(rapist) && !x.fertilized) select x).Count() > 0) if ((from x in target.health.hediffSet.GetHediffs<Hediff_InsectEgg>() where x.IsParent(rapist) select x).Count() > 0) { return 1f; } } return 0f; } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_RapeEnemyByInsect.cs
C#
mit
1,305
using RimWorld; using Verse; namespace rjw { internal class JobDriver_RapeEnemyByMech : JobDriver_RapeEnemy { public override bool CanUseThisJobForPawn(Pawn rapist) { if (rapist.CurJob != null && (rapist.CurJob.def != JobDefOf.LayDown || rapist.CurJob.def != JobDefOf.Wait_Wander || rapist.CurJob.def != JobDefOf.GotoWander)) return false; return xxx.is_mechanoid(rapist); } public override float GetFuckability(Pawn rapist, Pawn target) { //Plant stuff into humanlikes. if (xxx.is_human(target)) return 1f; else return 0f; } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_RapeEnemyByMech.cs
C#
mit
578
using RimWorld; using Verse; namespace rjw { internal class JobDriver_RapeEnemyToParasite : JobDriver_RapeEnemy { //not implemented public JobDriver_RapeEnemyToParasite() { this.requireCanRape = false; } public override bool CanUseThisJobForPawn(Pawn rapist) { if (rapist.CurJob != null && (rapist.CurJob.def != JobDefOf.LayDown || rapist.CurJob.def != JobDefOf.Wait_Wander || rapist.CurJob.def != JobDefOf.GotoWander)) return false; return false; } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_RapeEnemyToParasite.cs
C#
mit
489
using System; using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; using Verse.Sound; namespace rjw { public class JobDriver_RandomRape : JobDriver_Rape { //Add some stuff. planning became bersek when failed to rape. } }
Tirem12/rjw
Source/JobDrivers/JobDriver_RapeRandom.cs
C#
mit
256
using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; using Verse.Sound; using Multiplayer.API; using System.Linq; namespace rjw { public abstract class JobDriver_Sex : JobDriver { public readonly TargetIndex iTarget = TargetIndex.A; //pawn or corpse public readonly TargetIndex iBed = TargetIndex.B; //bed(maybe some furniture in future?) public readonly TargetIndex iCell = TargetIndex.C; //cell/location to have sex at(fapping) public float satisfaction = 1.0f; public bool shouldreserve = true; public int stackCount = 0; public int ticks_between_hearts = 60; public int ticks_between_hits = 60; public int ticks_between_thrusts = 60; public int ticks_left = 1000; public int duration = 5000; public int ticks_remaining = 10; public bool usedCondom = false; public bool isRape = false; public bool isWhoring = false; public bool face2face = false; public Thing Target // for reservation { get { return (Thing)job.GetTarget(TargetIndex.A); } } public Pawn Partner { get { if (Target is Pawn) return (Pawn)job.GetTarget(TargetIndex.A); else if (Target is Corpse) return ((Corpse)job.GetTarget(TargetIndex.A)).InnerPawn; else return null; } } public Building_Bed Bed { get { if (pBed != null) return pBed; else if ((Thing)job.GetTarget(TargetIndex.B) is Building_Bed) return (Building_Bed)job.GetTarget(TargetIndex.B); else return null; } } //not bed; chair, maybe something else in future public Building Building { get { if ((Thing)job.GetTarget(TargetIndex.B) is Building && !((Thing)job.GetTarget(TargetIndex.B) is Building_Bed)) return (Building)job.GetTarget(TargetIndex.B); else return null; } } public Building_Bed pBed = null; //public SexProps props; public xxx.rjwSextype sexType = xxx.rjwSextype.None; [SyncMethod] public void setup_ticks() { ticks_left = (int)(2000.0f * Rand.Range(0.50f, 0.90f)); ticks_between_hearts = Rand.RangeInclusive(70, 130); ticks_between_hits = Rand.Range(xxx.config.min_ticks_between_hits, xxx.config.max_ticks_between_hits); if (xxx.is_bloodlust(pawn)) ticks_between_hits = (int)(ticks_between_hits * 0.75); if (xxx.is_brawler(pawn)) ticks_between_hits = (int)(ticks_between_hits * 0.90); ticks_between_thrusts = 120; duration = ticks_left; } public void increase_time(int min_ticks_remaining) { if (min_ticks_remaining > ticks_remaining) ticks_remaining = min_ticks_remaining; } public void Set_bed(Building_Bed newBed) { pBed = newBed; } public override void ExposeData() { base.ExposeData(); Scribe_Values.Look(ref ticks_left, "ticks_left", 0, false); Scribe_Values.Look(ref ticks_between_hearts, "ticks_between_hearts", 0, false); Scribe_Values.Look(ref ticks_between_hits, "ticks_between_hits", 0, false); Scribe_Values.Look(ref ticks_between_thrusts, "ticks_between_thrusts", 0, false); Scribe_Values.Look(ref duration, "duration", 0, false); Scribe_Values.Look(ref ticks_remaining, "ticks_remaining", 10, false); Scribe_References.Look(ref pBed, "pBed"); //Scribe_Values.Look(ref props, "props"); Scribe_Values.Look(ref usedCondom, "usedCondom"); Scribe_Values.Look(ref isRape, "isRape"); Scribe_Values.Look(ref isWhoring, "isWhoring"); Scribe_Values.Look(ref sexType, "sexType"); Scribe_Values.Look(ref face2face, "face2face"); } public void SexTick(Pawn pawn, Thing target, bool pawnnude = true, bool partnernude = true) { var partner = target as Pawn; if (pawn.IsHashIntervalTick(ticks_between_thrusts)) { ChangePsyfocus(pawn, partner); Animate(pawn, partner); PlaySexSound(); if (!isRape) { pawn.GainComfortFromCellIfPossible(); if (partner != null) partner.GainComfortFromCellIfPossible(); } } //refresh DrawNude after beating and Notify_MeleeAttackOn // Endytophiles prefer clothed sex, everyone else gets nude. if (!xxx.has_quirk(pawn, "Endytophile")) { if (pawnnude) { SexUtility.DrawNude(pawn); } if (partner != null) if (partnernude) { SexUtility.DrawNude(partner); } } } /// <summary> /// simple rjw thrust animation /// </summary> public void Animate(Pawn pawn, Thing target) { RotatePawns(pawn, Partner); //attack/ride 1x2 cell cocksleeve/dildo? //if (Building != null) // target = Building; if (target != null) { pawn.Drawer.Notify_MeleeAttackOn(target); var partner = target as Pawn; if (partner != null && !isRape) partner.Drawer.Notify_MeleeAttackOn(pawn); } } /// <summary> /// handle Psyfocus /// </summary> public void ChangePsyfocus(Pawn pawn, Thing target) { if (ModsConfig.RoyaltyActive) { if (pawn.jobs?.curDriver is JobDriver_ViolateCorpse) if (xxx.is_necrophiliac(pawn) && MeditationFocusTypeAvailabilityCache.PawnCanUse(pawn, DefDatabase<MeditationFocusDef>.GetNamedSilentFail("Morbid"))) { SexUtility.OffsetPsyfocus(pawn, 0.01f); } if (target != null) { var partner = target as Pawn; if (partner != null) { if (xxx.is_nympho(pawn)) { SexUtility.OffsetPsyfocus(pawn, 0.01f); } else if (xxx.is_zoophile(pawn) && xxx.is_animal(partner) && MeditationFocusTypeAvailabilityCache.PawnCanUse(pawn, MeditationFocusDefOf.Natural)) { SexUtility.OffsetPsyfocus(pawn, 0.01f); } if (xxx.is_nympho(partner)) { SexUtility.OffsetPsyfocus(partner, 0.01f); } else if (xxx.is_zoophile(partner) && xxx.is_animal(pawn) && MeditationFocusTypeAvailabilityCache.PawnCanUse(partner, MeditationFocusDefOf.Natural)) { SexUtility.OffsetPsyfocus(partner, 0.01f); } if (xxx.RoMIsActive) { if (xxx.has_traits(pawn)) if (pawn.story.traits.HasTrait(TraitDef.Named("Succubus"))) { SexUtility.OffsetPsyfocus(pawn, 0.01f); } if (xxx.has_traits(partner)) if (partner.story.traits.HasTrait(TraitDef.Named("Succubus"))) { SexUtility.OffsetPsyfocus(partner, 0.01f); } } if (xxx.NightmareIncarnationIsActive) { if (xxx.has_traits(pawn)) foreach (var x in pawn.AllComps?.Where(x => x.props.ToString() == "NightmareIncarnation.CompProperties_SuccubusRace")) { SexUtility.OffsetPsyfocus(pawn, 0.01f); break; } if (xxx.has_traits(partner)) foreach (var x in partner.AllComps?.Where(x => x.props.ToString() == "NightmareIncarnation.CompProperties_SuccubusRace")) { SexUtility.OffsetPsyfocus(partner, 0.01f); break; } } } } } } /// <summary> /// rotate pawns /// </summary> public void RotatePawns(Pawn pawn, Thing target) { if (Building != null) { if (face2face) pawn.Rotation = Building.Rotation.Opposite; else pawn.Rotation = Building.Rotation; return; } if (target == null) // solo { //pawn.Rotation = Rot4.South; return; } var partner = target as Pawn; if (partner == null || partner.Dead) // necro { pawn.rotationTracker.Face(target.DrawPos); return; } if (partner.jobs?.curDriver is JobDriver_SexBaseReciever) if (((JobDriver_SexBaseReciever)partner.jobs.curDriver as JobDriver_SexBaseReciever).parteners.Count > 1) return; //maybe could do a hand check for monster girls but w/e //bool partnerHasHands = Receiver.health.hediffSet.GetNotMissingParts().Any(part => part.IsInGroup(BodyPartGroupDefOf.RightHand) || part.IsInGroup(BodyPartGroupDefOf.LeftHand)); // most of animal sex is likely doggystyle. if (xxx.is_animal(pawn) && xxx.is_animal(partner)) { if (sexType == xxx.rjwSextype.Anal || sexType == xxx.rjwSextype.Vaginal || sexType == xxx.rjwSextype.DoublePenetration) { //>> //Log.Message("animal doggy"); pawn.rotationTracker.Face(partner.DrawPos); partner.Rotation = pawn.Rotation; } else { //>< //Log.Message("animal non doggy"); pawn.rotationTracker.Face(target.DrawPos); partner.rotationTracker.Face(pawn.DrawPos); } } else { if (this is JobDriver_BestialityForFemale) { if (sexType == xxx.rjwSextype.Anal || sexType == xxx.rjwSextype.Vaginal || sexType == xxx.rjwSextype.DoublePenetration) { //<< //Log.Message("bestialityFF doggy"); partner.rotationTracker.Face(pawn.DrawPos); pawn.Rotation = partner.Rotation; } else { //>< //Log.Message("bestialityFF non doggy"); pawn.rotationTracker.Face(target.DrawPos); partner.rotationTracker.Face(pawn.DrawPos); } } else if (partner.GetPosture() == PawnPosture.LayingInBed) { //x^ //Log.Message("loving/casualsex in bed"); // this could use better handling for cowgirl/reverse cowgirl and who pen who, if such would be implemented //until then... if (!face2face && sexType == xxx.rjwSextype.Anal || sexType == xxx.rjwSextype.Vaginal || sexType == xxx.rjwSextype.DoublePenetration || sexType == xxx.rjwSextype.Fisting) //if (xxx.is_female(pawn) && xxx.is_female(partner)) { // in bed loving face down pawn.Rotation = partner.CurrentBed().Rotation.Opposite; } //else if (!(xxx.is_male(pawn) && xxx.is_male(partner))) //{ // // in bed loving face down // pawn.Rotation = partner.CurrentBed().Rotation.Opposite; //} else { // in bed loving, face up pawn.Rotation = partner.CurrentBed().Rotation; } } // 30% chance of face-to-face regardless, for variety. else if (!face2face && (sexType == xxx.rjwSextype.Anal || sexType == xxx.rjwSextype.Vaginal || sexType == xxx.rjwSextype.DoublePenetration || sexType == xxx.rjwSextype.Fisting)) { //>> //Log.Message("doggy"); pawn.rotationTracker.Face(target.DrawPos); partner.Rotation = pawn.Rotation; } // non doggystyle, or face-to-face regardless else { //>< //Log.Message("non doggy"); pawn.rotationTracker.Face(target.DrawPos); partner.rotationTracker.Face(pawn.DrawPos); } } } [SyncMethod] public void Rollface2face(float chance = 0.3f) { Setface2face(Rand.Chance(chance)); } public void Setface2face(bool chance) { face2face = chance; } public static void Roll_to_hit(Pawn Pawn, Pawn Partner, bool isRape = true) { SexUtility.Sex_Beatings(Pawn, Partner, isRape); } public void ThrowMetaIcon(IntVec3 pos, Map map, ThingDef icon) { MoteMaker.ThrowMetaIcon(pos, map, icon); } public void PlaySexSound() { if (RJWSettings.sounds_enabled) SoundDef.Named("Sex").PlayOneShot(new TargetInfo(pawn.Position, pawn.Map)); } public void PlayCumSound() { if (RJWSettings.sounds_enabled) SoundDef.Named("Cum").PlayOneShot(new TargetInfo(pawn.Position, pawn.Map)); } public void PlaySexVoice() { //if (RJWSettings.sounds_enabled) //{ // SoundDef.Named("Sex").PlayOneShot(new TargetInfo(pawn.Position, pawn.Map)); //} } public void PlayOrgasmVoice() { //if (RJWSettings.sounds_enabled) //{ // SoundDef.Named("Sex").PlayOneShot(new TargetInfo(pawn.Position, pawn.Map)); //} } public void CalculateSatisfactionPerTick() { satisfaction = 1.0f; } public static bool IsInOrByBed(Building_Bed b, Pawn p) { for (int i = 0; i < b.SleepingSlotsCount; i++) { if (b.GetSleepingSlotPos(i).InHorDistOf(p.Position, 1f)) { return true; } } return false; } public override bool TryMakePreToilReservations(bool errorOnFailed) { return true; // No reservations needed. } protected override IEnumerable<Toil> MakeNewToils() { return null; } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_Sex.cs
C#
mit
12,035
using Verse; using Verse.AI; namespace rjw { public abstract class JobDriver_SexBaseInitiator : JobDriver_Sex { public void Start() { if (Partner == null) //TODO: solo sex descriptions { isRape = false; isWhoring = false; //sexType = SexUtility.DetermineSextype(pawn, Partner, isRape, isWhoring, Partner); } else if (Partner.Dead) { isRape = true; isWhoring = false; sexType = SexUtility.DetermineSextype(pawn, Partner, isRape, isWhoring, Partner); } else if (Partner.jobs?.curDriver is JobDriver_SexBaseReciever) { (Partner.jobs.curDriver as JobDriver_SexBaseReciever).parteners.AddDistinct(pawn); (Partner.jobs.curDriver as JobDriver_SexBaseReciever).increase_time(duration); //prevent Receiver standing up and interrupting rape if (Partner.health.hediffSet.HasHediff(HediffDef.Named("Hediff_Submitting"))) Partner.health.AddHediff(HediffDef.Named("Hediff_Submitting")); //(Target.jobs.curDriver as JobDriver_SexBaseReciever).parteners.Count; //TODO: add multipartner support so sex doesnt repeat, maybe, someday isRape = Partner?.CurJob.def == xxx.gettin_raped; isWhoring = pawn?.CurJob.def == xxx.whore_is_serving_visitors; sexType = SexUtility.DetermineSextype(pawn, Partner, isRape, isWhoring, Partner); } //Log.Message("sexType: " + sexType.ToString()); //props = new SexProps(pawn, Partener, sexType, isRape);//maybe merge everything into this ? } //public void Change(xxx.rjwSextype sexType) //{ // if (pawn.jobs?.curDriver is JobDriver_SexBaseInitiator) // { // (pawn.jobs.curDriver as JobDriver_SexBaseInitiator).increase_time(duration); // } // if (Partner.jobs?.curDriver is JobDriver_SexBaseReciever) // { // (Partner.jobs.curDriver as JobDriver_SexBaseReciever).increase_time(duration); // } // sexType = sexType //} public void End() { if (xxx.is_human(pawn)) pawn.Drawer.renderer.graphics.ResolveApparelGraphics(); if (Partner?.jobs?.curDriver is JobDriver_SexBaseReciever) { (Partner?.jobs.curDriver as JobDriver_SexBaseReciever).parteners.Remove(pawn); } } public override bool TryMakePreToilReservations(bool errorOnFailed) { Log.Message("shouldreserve " + shouldreserve); if (shouldreserve && Target != null) return pawn.Reserve(Target, job, xxx.max_rapists_per_prisoner, stackCount, null, errorOnFailed); else if (shouldreserve && Bed != null) return pawn.Reserve(Bed, job, Bed.SleepingSlotsCount, 0, null, errorOnFailed); else return true; // No reservations needed. //return this.pawn.Reserve(this.Partner, this.job, 1, 0, null) && this.pawn.Reserve(this.Bed, this.job, 1, 0, null); } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_SexBaseInitiator.cs
C#
mit
2,708
using System.Collections.Generic; using Verse; namespace rjw { public class JobDriver_SexBaseReciever : JobDriver_Sex { //give this poor driver some love other than (Partner.jobs?.curDriver is JobDriver_SexBaseReciever) public List<Pawn> parteners = new List<Pawn>(); public override void ExposeData() { base.ExposeData(); Scribe_Collections.Look(ref parteners, "parteners", LookMode.Reference); } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_SexBaseReciever.cs
C#
mit
422
using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; using System; namespace rjw { public class JobDriver_SexBaseRecieverLoved : JobDriver_SexBaseReciever { protected override IEnumerable<Toil> MakeNewToils() { setup_ticks(); parteners.Add(Partner);// add job starter, so this wont fail, before Initiator starts his job //--Log.Message("[RJW]JobDriver_GettinLoved::MakeNewToils is called"); float partner_ability = xxx.get_sex_ability(Partner); // More/less hearts based on partner ability. if (partner_ability < 0.8f) ticks_between_thrusts += 120; else if (partner_ability > 2.0f) ticks_between_thrusts -= 30; // More/less hearts based on opinion. if (pawn.relations.OpinionOf(Partner) < 0) ticks_between_hearts += 50; else if (pawn.relations.OpinionOf(Partner) > 60) ticks_between_hearts -= 25; this.FailOnDespawnedOrNull(iTarget); this.FailOn(() => !Partner.health.capacities.CanBeAwake); if (Partner.CurJob.def == xxx.casual_sex) { this.FailOn(() => pawn.Drafted); this.KeepLyingDown(iBed); yield return Toils_Reserve.Reserve(iTarget, 1, 0); yield return Toils_Reserve.Reserve(iBed, Bed.SleepingSlotsCount, 0); Toil get_loved = Toils_LayDown.LayDown(iBed, true, false, false, false); get_loved.FailOn(() => Partner.CurJob.def != xxx.casual_sex); get_loved.defaultCompleteMode = ToilCompleteMode.Never; get_loved.socialMode = RandomSocialMode.Off; get_loved.handlingFacing = true; get_loved.tickAction = delegate { if (pawn.IsHashIntervalTick(ticks_between_hearts)) ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); }; get_loved.AddFinishAction(delegate { if (xxx.is_human(pawn)) pawn.Drawer.renderer.graphics.ResolveApparelGraphics(); }); yield return get_loved; } else if (Partner.CurJob.def == xxx.whore_is_serving_visitors) { this.FailOn(() => Partner.CurJob == null); yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell); yield return Toils_Reserve.Reserve(iTarget, 1, 0); Toil get_loved = new Toil(); get_loved.FailOn(() => (Partner.CurJob.def != xxx.whore_is_serving_visitors)); get_loved.defaultCompleteMode = ToilCompleteMode.Never; get_loved.socialMode = RandomSocialMode.Off; get_loved.handlingFacing = true; get_loved.tickAction = delegate { --ticks_remaining; if (pawn.IsHashIntervalTick(ticks_between_hearts)) ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); }; get_loved.AddEndCondition(new Func<JobCondition>(() => { if ((ticks_remaining <= 0) || (parteners.Count <= 0)) { return JobCondition.Succeeded; } return JobCondition.Ongoing; })); get_loved.AddFinishAction(delegate { if (xxx.is_human(pawn)) pawn.Drawer.renderer.graphics.ResolveApparelGraphics(); }); yield return get_loved; } else if (Partner.CurJob.def == xxx.bestialityForFemale) { this.FailOn(() => Partner.CurJob == null); yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell); yield return Toils_Reserve.Reserve(iTarget, 1, 0); Toil get_loved = new Toil(); get_loved.FailOn(() => (Partner.CurJob.def != xxx.bestialityForFemale)); get_loved.defaultCompleteMode = ToilCompleteMode.Never; get_loved.socialMode = RandomSocialMode.Off; get_loved.handlingFacing = true; get_loved.tickAction = delegate { --ticks_remaining; if (pawn.IsHashIntervalTick(ticks_between_hearts)) ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); }; get_loved.AddEndCondition(new Func<JobCondition>(() => { if ((ticks_remaining <= 0) || (parteners.Count <= 0)) { return JobCondition.Succeeded; } return JobCondition.Ongoing; })); get_loved.AddFinishAction(delegate { if (xxx.is_human(pawn)) pawn.Drawer.renderer.graphics.ResolveApparelGraphics(); }); get_loved.socialMode = RandomSocialMode.Off; yield return get_loved; } else if (Partner.CurJob.def == xxx.animalMate) { this.FailOn(() => Partner.CurJob == null); yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell); yield return Toils_Reserve.Reserve(iTarget, 1, 0); Toil get_loved = new Toil(); get_loved.FailOn(() => (Partner.CurJob.def != xxx.animalMate)); get_loved.defaultCompleteMode = ToilCompleteMode.Never; get_loved.socialMode = RandomSocialMode.Off; get_loved.handlingFacing = true; get_loved.tickAction = delegate { --ticks_remaining; if (pawn.IsHashIntervalTick(ticks_between_hearts)) ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); }; get_loved.AddEndCondition(new Func<JobCondition>(() => { if ((ticks_remaining <= 0) || (parteners.Count <= 0)) { return JobCondition.Succeeded; } return JobCondition.Ongoing; })); get_loved.socialMode = RandomSocialMode.Off; yield return get_loved; } } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_SexBaseRecieverLoved.cs
C#
mit
5,076
using System; using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; namespace rjw { public class JobDriver_SexBaseRecieverQuickie : JobDriver_SexBaseReciever { protected override IEnumerable<Toil> MakeNewToils() { setup_ticks(); parteners.Add(Partner);// add job starter, so this wont fail, before Initiator starts his job float partner_ability = xxx.get_sex_ability(Partner); // More/less hearts based on partner ability. if (partner_ability < 0.8f) ticks_between_thrusts += 120; else if (partner_ability > 2.0f) ticks_between_thrusts -= 30; // More/less hearts based on opinion. if (pawn.relations.OpinionOf(Partner) < 0) ticks_between_hearts += 50; else if (pawn.relations.OpinionOf(Partner) > 60) ticks_between_hearts -= 25; this.FailOnDespawnedOrNull(iTarget); this.FailOn(() => !Partner.health.capacities.CanBeAwake); yield return Toils_Reserve.Reserve(iTarget, 1, 0); Toil get_loved = new Toil(); get_loved.defaultCompleteMode = ToilCompleteMode.Never; get_loved.socialMode = RandomSocialMode.Off; get_loved.initAction = delegate { pawn.pather.StopDead(); pawn.jobs.curDriver.asleep = false; }; get_loved.AddPreTickAction(delegate { if (pawn.IsHashIntervalTick(ticks_between_hearts)) ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); }); get_loved.AddEndCondition(new Func<JobCondition>(() => { if ((ticks_remaining <= 0) || (parteners.Count <= 0)) { return JobCondition.Succeeded; } return JobCondition.Ongoing; })); get_loved.AddFinishAction(delegate { if (xxx.is_human(pawn)) pawn.Drawer.renderer.graphics.ResolveApparelGraphics(); }); yield return get_loved; } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_SexBaseRecieverQuickie.cs
C#
mit
1,775
using System; using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; namespace rjw { public class JobDriver_SexBaseRecieverRaped : JobDriver_SexBaseReciever { protected override IEnumerable<Toil> MakeNewToils() { setup_ticks(); parteners.Add(Partner);// add job starter, so this wont fail, before Initiator starts his job var get_raped = new Toil(); get_raped.defaultCompleteMode = ToilCompleteMode.Never; get_raped.handlingFacing = true; get_raped.initAction = delegate { pawn.pather.StopDead(); pawn.jobs.curDriver.asleep = false; SexUtility.BeeingRapedAlert(Partner, pawn); }; get_raped.tickAction = delegate { --ticks_remaining; if ((parteners.Count > 0) && (pawn.IsHashIntervalTick(ticks_between_hearts / parteners.Count))) if (pawn.IsHashIntervalTick(ticks_between_hearts)) if (xxx.is_masochist(pawn)) ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); else ThrowMetaIcon(pawn.Position, pawn.Map, xxx.mote_noheart); }; get_raped.AddEndCondition(new Func<JobCondition>(() => { if ((ticks_remaining <= 0) || (parteners.Count <= 0)) { return JobCondition.Succeeded; } return JobCondition.Ongoing; })); get_raped.AddFinishAction(delegate { if (xxx.is_human(pawn)) pawn.Drawer.renderer.graphics.ResolveApparelGraphics(); if (Bed != null && pawn.Downed) { Job tobed = JobMaker.MakeJob(JobDefOf.Rescue, pawn, Bed); tobed.count = 1; Partner.jobs.jobQueue.EnqueueFirst(tobed); //Log.Message(xxx.get_pawnname(Initiator) + ": job tobed:" + tobed); } else if (pawn.HostileTo(Partner)) pawn.health.AddHediff(HediffDef.Named("Hediff_Submitting")); else pawn.stances.stunner.StunFor(600, pawn); }); get_raped.socialMode = RandomSocialMode.Off; yield return get_raped; } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_SexBaseRecieverRaped.cs
C#
mit
1,903
using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; namespace rjw { public class JobDriver_JoinInBed : JobDriver_SexBaseInitiator { public override bool TryMakePreToilReservations(bool errorOnFailed) { return pawn.Reserve(Target, job, xxx.max_rapists_per_prisoner, 0, null, errorOnFailed); } protected override IEnumerable<Toil> MakeNewToils() { //Log.Message("[RJW]" + this.GetType().ToString() + "::MakeNewToils() called"); setup_ticks(); this.FailOnDespawnedOrNull(iTarget); this.FailOnDespawnedOrNull(iBed); this.FailOn(() => !Partner.health.capacities.CanBeAwake); this.FailOn(() => !(Partner.InBed() || xxx.in_same_bed(Partner, pawn))); this.FailOn(() => pawn.Drafted); yield return Toils_Reserve.Reserve(iTarget, xxx.max_rapists_per_prisoner, 0); yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell); Toil StartPartnerJob = new Toil(); StartPartnerJob.defaultCompleteMode = ToilCompleteMode.Instant; StartPartnerJob.socialMode = RandomSocialMode.Off; StartPartnerJob.initAction = delegate { Job gettin_loved = JobMaker.MakeJob(xxx.gettin_loved, pawn, Bed); Partner.jobs.StartJob(gettin_loved, JobCondition.InterruptForced); }; yield return StartPartnerJob; Toil do_lovin = new Toil(); do_lovin.FailOn(() => Partner.CurJob.def != xxx.gettin_loved); do_lovin.defaultCompleteMode = ToilCompleteMode.Never; do_lovin.socialMode = RandomSocialMode.Off; do_lovin.handlingFacing = true; do_lovin.initAction = delegate { usedCondom = CondomUtility.TryUseCondom(pawn) || CondomUtility.TryUseCondom(Partner); Start(); }; do_lovin.AddPreTickAction(delegate { --ticks_left; if (pawn.IsHashIntervalTick(ticks_between_hearts)) ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); SexTick(pawn, Partner); SexUtility.reduce_rest(Partner, 1); SexUtility.reduce_rest(pawn, 2); if (ticks_left <= 0) ReadyForNextToil(); }); do_lovin.AddFinishAction(delegate { End(); }); yield return do_lovin; yield return new Toil { initAction = delegate { // Trying to add some interactions and social logs SexUtility.ProcessSex(pawn, Partner, usedCondom: usedCondom, rape: isRape, whoring: isWhoring, sextype: sexType); }, defaultCompleteMode = ToilCompleteMode.Instant }; } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_SexCasual.cs
C#
mit
2,406
using System; using System.Collections.Generic; using System.Linq; using Multiplayer.API; using RimWorld; using UnityEngine; using Verse; using Verse.AI; namespace rjw { public class JobDriver_SexQuick : JobDriver_SexBaseInitiator { // List of jobs that can be interrupted by quickies. public static readonly List<JobDef> quickieAllowedJobs = new List<JobDef> { null, JobDefOf.Wait_Wander, JobDefOf.GotoWander, JobDefOf.Clean, JobDefOf.ClearSnow, JobDefOf.CutPlant, JobDefOf.HaulToCell, JobDefOf.Deconstruct, JobDefOf.LayDown, JobDefOf.Research, JobDefOf.SmoothFloor, JobDefOf.SmoothWall, JobDefOf.SocialRelax, JobDefOf.StandAndBeSociallyActive, JobDefOf.RemoveApparel, JobDefOf.Strip, JobDefOf.Wait, JobDefOf.FillFermentingBarrel, JobDefOf.Sow, JobDefOf.Shear, JobDefOf.DeliverFood, JobDefOf.Hunt, JobDefOf.Mine, JobDefOf.RearmTurret, JobDefOf.RemoveFloor, JobDefOf.RemoveRoof, JobDefOf.Repair, JobDefOf.TakeBeerOutOfFermentingBarrel, JobDefOf.Uninstall, JobDefOf.Meditate, xxx.Masturbate_Bed}; private List<Pawn> all_pawns; private FloatRange temperature; public override bool TryMakePreToilReservations(bool errorOnFailed) { return pawn.Reserve(Target, job, xxx.max_rapists_per_prisoner, 0, null, errorOnFailed); } protected override IEnumerable<Toil> MakeNewToils() { //Log.Message("[RJW]" + this.GetType().ToString() + "::MakeNewToils() called"); setup_ticks(); this.FailOnDespawnedNullOrForbidden(iTarget); this.FailOn(() => !Partner.health.capacities.CanBeAwake); this.FailOn(() => pawn.IsFighting()); this.FailOn(() => Partner.IsFighting()); this.FailOn(() => pawn.Drafted); yield return Toils_Goto.GotoThing(iTarget, PathEndMode.OnCell); Toil findQuickieSpot = new Toil(); findQuickieSpot.defaultCompleteMode = ToilCompleteMode.PatherArrival; findQuickieSpot.initAction = delegate { //Needs this earlier to decide if current place is good enough all_pawns = pawn.Map.mapPawns.AllPawnsSpawned.Where(x => x.Position.DistanceTo(pawn.Position) < 100 && xxx.is_human(x) && x != pawn && x != Partner ).ToList(); temperature = pawn.ComfortableTemperatureRange(); float cellTemp = pawn.Position.GetTemperature(pawn.Map); if (Partner.IsPrisonerInPrisonCell() || (!MightBeSeen(all_pawns,pawn.Position,pawn,Partner) && (cellTemp > temperature.min && cellTemp < temperature.max))) { ReadyForNextToil(); } else { var spot = FindQuickieLocation(pawn, Partner); pawn.pather.StartPath(spot, PathEndMode.OnCell); Partner.jobs.StopAll(); Job job = JobMaker.MakeJob(JobDefOf.GotoMindControlled, spot); Partner.jobs.StartJob(job, JobCondition.InterruptForced); } }; yield return findQuickieSpot; Toil WaitForPartner = new Toil(); WaitForPartner.defaultCompleteMode = ToilCompleteMode.Delay; WaitForPartner.initAction = delegate { ticksLeftThisToil = 5000; }; WaitForPartner.tickAction = delegate { pawn.GainComfortFromCellIfPossible(); if (pawn.Position.DistanceTo(Partner.Position) <= 1f) { ReadyForNextToil(); } }; yield return WaitForPartner; Toil StartPartnerJob = new Toil(); StartPartnerJob.defaultCompleteMode = ToilCompleteMode.Instant; StartPartnerJob.socialMode = RandomSocialMode.Off; StartPartnerJob.initAction = delegate { Job gettingQuickie = JobMaker.MakeJob(xxx.getting_quickie, pawn, Partner); Partner.jobs.StartJob(gettingQuickie, JobCondition.InterruptForced); }; yield return StartPartnerJob; Toil doQuickie = new Toil(); doQuickie.defaultCompleteMode = ToilCompleteMode.Never; doQuickie.socialMode = RandomSocialMode.Off; doQuickie.defaultDuration = duration; doQuickie.handlingFacing = true; doQuickie.initAction = delegate { usedCondom = CondomUtility.TryUseCondom(pawn) || CondomUtility.TryUseCondom(Partner); Start(); }; doQuickie.AddPreTickAction(delegate { --ticks_left; if (pawn.IsHashIntervalTick(ticks_between_hearts)) ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); SexTick(pawn, Partner); SexUtility.reduce_rest(Partner, 1); SexUtility.reduce_rest(pawn, 1); if (ticks_left <= 0) ReadyForNextToil(); }); doQuickie.AddFinishAction(delegate { End(); }); yield return doQuickie; yield return new Toil { initAction = delegate { //// Trying to add some interactions and social logs SexUtility.ProcessSex(pawn, Partner, usedCondom: usedCondom, rape: isRape, sextype: sexType); }, defaultCompleteMode = ToilCompleteMode.Instant }; } [SyncMethod] public virtual IntVec3 FindQuickieLocation(Pawn pawn, Pawn partner) { IntVec3 position = pawn.Position; int bestPosition = -100; IntVec3 cell = pawn.Position; int maxDistance = 40; //bool is_somnophile = xxx.has_quirk(pawn, "Somnophile"); bool is_exhibitionist = xxx.has_quirk(pawn, "Exhibitionist"); //Log.Message("[RJW] Pawn is " + xxx.get_pawnname(pawn) + ", current cell is " + cell); //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); List<IntVec3> random_cells = new List<IntVec3>(); for (int loop = 0; loop < 50; ++loop) { random_cells.Add(position + IntVec3.FromVector3(Vector3Utility.HorizontalVectorFromAngle(Rand.Range(0, 360)) * Rand.RangeInclusive(1, maxDistance))); } random_cells = random_cells.Where(x => x.Standable(pawn.Map) && x.InAllowedArea(pawn) && x.GetDangerFor(pawn, pawn.Map) != Danger.Deadly && !x.ContainsTrap(pawn.Map) && !x.ContainsStaticFire(pawn.Map) ).Distinct().ToList(); //Log.Message("[RJW] Found " + random_cells.Count + " valid cells."); foreach (IntVec3 random_cell in random_cells) { if (!xxx.can_path_to_target(pawn, random_cell)) continue;// too far int score = 0; Room room = random_cell.GetRoom(pawn.Map); bool might_be_seen = MightBeSeen(all_pawns, random_cell, pawn, partner); if (is_exhibitionist) { if (might_be_seen) score += 5; else score -= 10; } else { if (might_be_seen) score -= 30; } if (random_cell.GetTemperature(pawn.Map) > temperature.min && random_cell.GetTemperature(pawn.Map) < temperature.max) score += 20; else score -= 20; if (random_cell.Roofed(pawn.Map)) score += 5; if (random_cell.HasEatSurface(pawn.Map)) score += 5; // Hide in vegetation. if (random_cell.GetDangerFor(pawn, pawn.Map) == Danger.Some) score -= 25; else if (random_cell.GetDangerFor(pawn, pawn.Map) == Danger.None) score += 5; if (random_cell.GetTerrain(pawn.Map) == TerrainDefOf.WaterShallow || random_cell.GetTerrain(pawn.Map) == TerrainDefOf.WaterMovingShallow || random_cell.GetTerrain(pawn.Map) == TerrainDefOf.WaterOceanShallow) score -= 20; if (random_cell.GetThingList(pawn.Map).Any(x => x.def.IsWithinCategory(ThingCategoryDefOf.Corpses)) && !xxx.is_necrophiliac(pawn)) score -= 20; if (random_cell.GetThingList(pawn.Map).Any(x => x.def.IsWithinCategory(ThingCategoryDefOf.Foods))) score -= 10; if (room == pawn.Position.GetRoom(pawn.MapHeld)) score -= 10; if (room.PsychologicallyOutdoors) score += 5; if (room.isPrisonCell) score += 5; if (room.IsHuge) score -= 5; if (room.ContainedBeds.Any()) score += 5; if (room.IsDoorway) score -= 10; if (!room.Owners.Any()) score += 10; else if (room.Owners.Contains(pawn)) score += 20; if (room.Role == RoomRoleDefOf.Bedroom || room.Role == RoomRoleDefOf.PrisonCell) score += 10; else if (room.Role == RoomRoleDefOf.Barracks || room.Role == RoomRoleDefOf.Laboratory || room.Role == RoomRoleDefOf.RecRoom) score += 2; else if (room.Role == RoomRoleDefOf.DiningRoom || room.Role == RoomRoleDefOf.Hospital || room.Role == RoomRoleDefOf.PrisonBarracks) score -= 5; if (room.GetStat(RoomStatDefOf.Cleanliness) < 0.01f) score -= 5; if (room.GetStat(RoomStatDefOf.GraveVisitingJoyGainFactor) > 0.1f) score -= 5; if (score <= bestPosition) continue; bestPosition = score; cell = random_cell; } return cell; //Log.Message("[RJW] Best cell is " + cell); } private bool MightBeSeen(List<Pawn> otherPawns, IntVec3 cell, Pawn pawn, Pawn partner) { return otherPawns.Any(x => GenSight.LineOfSight(x.Position, cell, pawn.Map) && x.Position.DistanceTo(cell) < 50 && x.Awake() && x != partner ); } } }
Tirem12/rjw
Source/JobDrivers/JobDriver_SexQuick.cs
C#
mit
8,609
using System.Linq; using RimWorld; using Verse; using Verse.AI; using System.Collections.Generic; using Multiplayer.API; namespace rjw { //Rape to Prisoner of QuestPrisonerWillingToJoin class JobGiver_AIRapePrisoner : ThinkNode_JobGiver { [SyncMethod] public static Pawn find_victim(Pawn pawn, Map m) { float min_fuckability = 0.10f; // Don't rape pawns with <10% fuckability float avg_fuckability = 0f; // Average targets fuckability, choose target higher than that var valid_targets = new Dictionary<Pawn, float>(); // Valid pawns and their fuckability Pawn chosentarget = null; // Final target pawn IEnumerable<Pawn> targets = m.mapPawns.AllPawns.Where(x => x != pawn && IsPrisonerOf(x, pawn.Faction) && xxx.can_get_raped(x) && pawn.CanReserveAndReach(x, PathEndMode.Touch, Danger.Some, xxx.max_rapists_per_prisoner, 0) && !x.Position.IsForbidden(pawn) ); foreach (Pawn target in targets) { if (!xxx.can_path_to_target(pawn, target.Position)) continue;// too far float fuc = SexAppraiser.would_fuck(pawn, target, true, true); if (fuc > min_fuckability) valid_targets.Add(target, fuc); } if (valid_targets.Any()) { avg_fuckability = valid_targets.Average(x => x.Value); // choose pawns to fuck with above average fuckability var valid_targetsFiltered = valid_targets.Where(x => x.Value >= avg_fuckability); if (valid_targetsFiltered.Any()) chosentarget = valid_targetsFiltered.RandomElement().Key; } return chosentarget; } protected override Job TryGiveJob(Pawn pawn) { if (RJWSettings.DebugRape) Log.Message("[RJW] JobGiver_AIRapePrisoner::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called "); if (!xxx.can_rape(pawn)) return null; if (SexUtility.ReadyForLovin(pawn) || xxx.is_hornyorfrustrated(pawn)) { // don't allow pawns marked as comfort prisoners to rape others if (xxx.is_healthy(pawn)) { Pawn prisoner = find_victim(pawn, pawn.Map); if (prisoner != null) { if (RJWSettings.DebugRape) Log.Message("[RJW] JobGiver_RandomRape::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) - found victim " + xxx.get_pawnname(prisoner)); return JobMaker.MakeJob(xxx.RapeRandom, prisoner); } } } return null; } protected static bool IsPrisonerOf(Pawn pawn,Faction faction) { if (pawn?.guest == null) return false; return pawn.guest.HostFaction == faction && pawn.guest.IsPrisoner; } } }
Tirem12/rjw
Source/JobGivers/JobGiver_AIRapePrisoner.cs
C#
mit
2,580
using RimWorld; using Verse; using Verse.AI; namespace rjw { /// <summary> /// Pawn tries to find animal to do loving/raping. /// </summary> public class JobGiver_Bestiality : ThinkNode_JobGiver { protected override Job TryGiveJob(Pawn pawn) { if (pawn.Drafted) return null; // Most checks are now done in ThinkNode_ConditionalBestiality if (!SexUtility.ReadyForLovin(pawn) && !xxx.is_frustrated(pawn)) return null; Pawn target = BreederHelper.find_breeder_animal(pawn, pawn.Map); if (target == null) return null; if (xxx.can_rape(pawn)) { return JobMaker.MakeJob(xxx.bestiality, target); } Building_Bed bed = pawn.ownership.OwnedBed; if (!xxx.can_be_fucked(pawn) || bed == null || !target.CanReach(bed, PathEndMode.OnCell, Danger.Some) || target.Downed) return null; // TODO: Should rename this to BestialityInBed or somesuch, since it's not limited to females. return JobMaker.MakeJob(xxx.bestialityForFemale, target, bed); } } }
Tirem12/rjw
Source/JobGivers/JobGiver_Bestiality.cs
C#
mit
1,000
using Verse; using Verse.AI; namespace rjw { /// <summary> /// Attempts to give a breeding job to an eligible animal. /// </summary> public class JobGiver_Breed : ThinkNode_JobGiver { protected override Job TryGiveJob(Pawn animal) { //Log.Message("[RJW] JobGiver_Breed::TryGiveJob( " + xxx.get_pawnname(animal) + " ) called0" + (SexUtility.ReadyForLovin(animal))); if (!SexUtility.ReadyForLovin(animal)) return null; if(xxx.is_healthy(animal) && xxx.can_rape(animal)) { //search for desiganted target to sex if (animal.IsDesignatedBreedingAnimal()) { Pawn designated_target = BreederHelper.find_designated_breeder(animal, animal.Map); if (designated_target != null) { return JobMaker.MakeJob(xxx.animalBreed, designated_target); } } } return null; } } }
Tirem12/rjw
Source/JobGivers/JobGiver_Breed.cs
C#
mit
832
using Verse; using Verse.AI; using RimWorld; using System.Collections.Generic; using System.Linq; using Multiplayer.API; namespace rjw { public class JobGiver_ComfortPrisonerRape : ThinkNode_JobGiver { [SyncMethod] public static Pawn find_targetCP(Pawn pawn, Map m) { if (!DesignatorsData.rjwComfort.Any()) return null; float min_fuckability = 0.10f; // Don't rape prisoners with <10% fuckability float avg_fuckability = 0f; // Average targets fuckability, choose target higher than that var valid_targets = new Dictionary<Pawn, float>(); // Valid pawns and their fuckability Pawn chosentarget = null; // Final target pawn string pawnName = xxx.get_pawnname(pawn); if (RJWSettings.DebugRape) Log.Message($"[RJW] FindComfortPrisoner({pawnName})"); IEnumerable<Pawn> targets = DesignatorsData.rjwComfort.Where(x => x != pawn && xxx.can_get_raped(x) && pawn.CanReserveAndReach(x, PathEndMode.Touch, Danger.Some, xxx.max_rapists_per_prisoner, 0) && !x.IsForbidden(pawn) && SexAppraiser.would_rape(pawn, x) ); if (RJWSettings.DebugRape) Log.Message($"[RJW] FindComfortPrisoner({pawnName}): found {targets.Count()}"); if (xxx.is_animal(pawn)) { // Animals only consider targets they can see, instead of seeking them out. targets = targets.Where(x => pawn.CanSee(x)).ToList(); } foreach (Pawn target in targets) { if (!xxx.can_path_to_target(pawn, target.Position)) continue;// too far float fuc = 0f; if (xxx.is_animal(target)) fuc = SexAppraiser.would_fuck_animal(pawn, target, true); else if (xxx.is_human(target)) fuc = SexAppraiser.would_fuck(pawn, target, true); if (RJWSettings.DebugRape) Log.Message($"[RJW] FindComfortPrisoner({pawnName}): {fuc} has to be over {min_fuckability}"); if (fuc > min_fuckability) valid_targets.Add(target, fuc); } if (valid_targets.Any()) { // avg_fuckability = valid_targets.Average(x => x.Value); // disabled for CP // choose pawns to fuck with above average fuckability var valid_targetsFiltered = valid_targets.Where(x => x.Value >= avg_fuckability); if (valid_targetsFiltered.Any()) chosentarget = valid_targetsFiltered.RandomElement().Key; } return chosentarget; } protected override Job TryGiveJob(Pawn pawn) { if (RJWSettings.DebugRape) Log.Message($"[RJW] JobGiver_ComfortPrisonerRape::TryGiveJob({xxx.get_pawnname(pawn)}) called"); if (!RJWSettings.WildMode) { // don't allow pawns marked as comfort prisoners to rape others if (RJWSettings.DebugRape) Log.Message($"[RJW] JobGiver_ComfortPrisonerRape::TryGiveJob({xxx.get_pawnname(pawn)}): is healthy = {xxx.is_healthy(pawn)}, is cp = {pawn.IsDesignatedComfort()}, is ready = {SexUtility.ReadyForLovin(pawn)}, is frustrated = {xxx.is_frustrated(pawn)}"); if (!xxx.is_healthy(pawn) || pawn.IsDesignatedComfort() || (!SexUtility.ReadyForLovin(pawn) && !xxx.is_frustrated(pawn))) return null; } if (RJWSettings.DebugRape) Log.Message($"[RJW] FindComfortPrisoner({xxx.get_pawnname(pawn)}): can rape = {xxx.can_rape(pawn)}, is drafted = {pawn.Drafted}"); if (pawn.Drafted || !xxx.can_rape(pawn)) return null; // It's unnecessary to include other job checks. Pawns seem to only look for new jobs when between jobs or laying down idle. if (!(pawn.jobs.curJob == null || pawn.jobs.curJob.def == JobDefOf.LayDown)) { if (RJWSettings.DebugRape) Log.Message($"[RJW] FindComfortPrisoner({xxx.get_pawnname(pawn)}): I already have a job ({pawn.CurJobDef})"); return null; } // Faction check. if (!(pawn.Faction?.IsPlayer ?? false) && !pawn.IsPrisonerOfColony) { if (RJWSettings.DebugRape) Log.Message($"[RJW] FindComfortPrisoner({xxx.get_pawnname(pawn)}): player faction: {pawn.Faction?.IsPlayer}, prisoner: {pawn.IsPrisonerOfColony}"); return null; } Pawn target = find_targetCP(pawn, pawn.Map); if (RJWSettings.DebugRape) Log.Message($"[RJW] JobGiver_ComfortPrisonerRape::TryGiveJob({xxx.get_pawnname(pawn)}): (" + ((target == null) ? "no target found" : xxx.get_pawnname(target))+") is the prisoner"); if (target == null) return null; if (RJWSettings.DebugRape) Log.Message($"[RJW] JobGiver_ComfortPrisonerRape::TryGiveJob({xxx.get_pawnname(pawn)}) with target {xxx.get_pawnname(target)}"); if (xxx.is_animal(target)) return JobMaker.MakeJob(xxx.bestiality, target); else return JobMaker.MakeJob(xxx.RapeCP, target); } } }
Tirem12/rjw
Source/JobGivers/JobGiver_ComfortPrisonerRape.cs
C#
mit
4,521
using RimWorld; using Verse; using Verse.AI; using System.Collections.Generic; using System.Linq; using Multiplayer.API; namespace rjw { public class JobGiver_DoFappin : ThinkNode_JobGiver { [SyncMethod] public virtual IntVec3 FindFapLocation(Pawn pawn) { IntVec3 position = pawn.Position; int bestPosition = -100; IntVec3 cell = pawn.Position; int maxDistance = 40; FloatRange temperature = pawn.ComfortableTemperatureRange(); bool is_somnophile = xxx.has_quirk(pawn, "Somnophile"); bool is_exhibitionist = xxx.has_quirk(pawn, "Exhibitionist"); List<Pawn> all_pawns = pawn.Map.mapPawns.AllPawnsSpawned.Where(x => x.Position.DistanceTo(pawn.Position) < 100 && xxx.is_human(x) && x != pawn ).ToList(); //Log.Message("[RJW] Pawn is " + xxx.get_pawnname(pawn) + ", current cell is " + cell); //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); List<IntVec3> random_cells = new List<IntVec3>(); for (int loop = 0; loop < 50; ++loop) { random_cells.Add(position + IntVec3.FromVector3(Vector3Utility.HorizontalVectorFromAngle(Rand.Range(0, 360)) * Rand.RangeInclusive(1, maxDistance))); } random_cells = random_cells.Where(x => x.Standable(pawn.Map) && x.InAllowedArea(pawn) && x.GetDangerFor(pawn, pawn.Map) != Danger.Deadly && !x.ContainsTrap(pawn.Map) && !x.ContainsStaticFire(pawn.Map) ).Distinct().ToList(); //Log.Message("[RJW] Found " + random_cells.Count + " valid cells."); foreach (IntVec3 random_cell in random_cells) { if (!xxx.can_path_to_target(pawn, random_cell)) continue;// too far int score = 0; Room room = random_cell.GetRoom(pawn.Map); bool might_be_seen = all_pawns.Any(x => GenSight.LineOfSight(x.Position, random_cell, pawn.Map) && x.Position.DistanceTo(random_cell) < 50 && x.Awake() ); if (is_exhibitionist) { if (might_be_seen) score += 5; else score -= 10; } else { if (might_be_seen) score -= 30; } if (is_somnophile) // Fap while Watching someone sleep. Not creepy at all! { if (all_pawns.Any(x => GenSight.LineOfSight(random_cell, x.Position, pawn.Map) && x.Position.DistanceTo(random_cell) < 6 && !x.Awake() )) score += 50; } if (random_cell.GetTemperature(pawn.Map) > temperature.min && random_cell.GetTemperature(pawn.Map) < temperature.max) score += 20; else score -= 20; if (random_cell.Roofed(pawn.Map)) score += 5; if (random_cell.HasEatSurface(pawn.Map)) score += 5; // Hide in vegetation. if (random_cell.GetDangerFor(pawn, pawn.Map) == Danger.Some) score -= 25; else if (random_cell.GetDangerFor(pawn, pawn.Map) == Danger.None) score += 5; if (random_cell.GetTerrain(pawn.Map) == TerrainDefOf.WaterShallow || random_cell.GetTerrain(pawn.Map) == TerrainDefOf.WaterMovingShallow || random_cell.GetTerrain(pawn.Map) == TerrainDefOf.WaterOceanShallow) score -= 20; if (random_cell.GetThingList(pawn.Map).Any(x => x.def.IsWithinCategory(ThingCategoryDefOf.Corpses)) && !xxx.is_necrophiliac(pawn)) score -= 20; if (random_cell.GetThingList(pawn.Map).Any(x => x.def.IsWithinCategory(ThingCategoryDefOf.Foods))) score -= 10; if (room == pawn.Position.GetRoom(pawn.MapHeld)) score -= 10; if (room.PsychologicallyOutdoors) score += 5; if (room.isPrisonCell) score += 5; if (room.IsHuge) score -= 5; if (room.ContainedBeds.Any()) score += 5; if (room.IsDoorway) score -= 10; if (!room.Owners.Any()) score += 10; else if (room.Owners.Contains(pawn)) score += 20; if (room.Role == RoomRoleDefOf.Bedroom || room.Role == RoomRoleDefOf.PrisonCell) score += 10; else if (room.Role == RoomRoleDefOf.Barracks || room.Role == RoomRoleDefOf.Laboratory || room.Role == RoomRoleDefOf.RecRoom) score += 2; else if (room.Role == RoomRoleDefOf.DiningRoom || room.Role == RoomRoleDefOf.Hospital || room.Role == RoomRoleDefOf.PrisonBarracks) score -= 5; if (room.GetStat(RoomStatDefOf.Cleanliness) < 0.01f) score -= 5; if (room.GetStat(RoomStatDefOf.GraveVisitingJoyGainFactor) > 0.1f) score -= 5; if (score <= bestPosition) continue; bestPosition = score; cell = random_cell; } return cell; //Log.Message("[RJW] Best cell is " + cell); } protected override Job TryGiveJob(Pawn pawn) { //--Log.Message("[RJW] JobGiver_DoFappin::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called"); if (pawn.Drafted) return null; if (!xxx.can_be_fucked(pawn) && !xxx.can_fuck(pawn)) return null; // Whores only fap if frustrated, unless imprisoned. if ((SexUtility.ReadyForLovin(pawn) && (!xxx.is_whore(pawn) || pawn.IsPrisoner || xxx.is_slave(pawn))) || xxx.is_frustrated(pawn)) { if (pawn.jobs.curDriver is JobDriver_LayDown && RJWPreferenceSettings.FapInBed) { Building_Bed bed = ((JobDriver_LayDown)pawn.jobs.curDriver).Bed; if (bed != null) return JobMaker.MakeJob(xxx.Masturbate_Bed, null, bed); } else if ((xxx.is_frustrated(pawn) || xxx.has_quirk(pawn, "Exhibitionist")) && RJWPreferenceSettings.FapEverywhere) { return JobMaker.MakeJob(xxx.Masturbate_Quick, null, null, FindFapLocation(pawn)); } } return null; } } }
Tirem12/rjw
Source/JobGivers/JobGiver_DoFappin.cs
C#
mit
5,424
using System.Collections.Generic; using System.Linq; using RimWorld; using Verse; using Verse.AI; using Multiplayer.API; namespace rjw { public class JobGiver_DoQuickie : ThinkNode_JobGiver { private const int MaxDistanceSquaredToFuck = 10000; private static bool CanFuck(Pawn target) { return xxx.can_fuck(target) || xxx.can_be_fucked(target); } [SyncMethod] private static bool roll_to_skip(Pawn pawn, Pawn target, out float fuckability) { fuckability = SexAppraiser.would_fuck(pawn, target); // 0.0 to 1.0 if (fuckability < RJWHookupSettings.MinimumFuckabilityToHookup) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] roll_to_skip(I, {xxx.get_pawnname(pawn)} won't fuck {xxx.get_pawnname(target)}), ({fuckability})"); return false; } float reciprocity = xxx.is_animal(target) ? 1.0f : SexAppraiser.would_fuck(target, pawn); if (reciprocity < RJWHookupSettings.MinimumFuckabilityToHookup) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] roll_to_skip({xxx.get_pawnname(target)} won't fuck me, {xxx.get_pawnname(pawn)}), ({reciprocity})"); return false; } float chance_to_skip = 0.9f - 0.7f * fuckability; //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); return Rand.Value < chance_to_skip; } [SyncMethod] public static Pawn find_pawn_to_fuck(Pawn pawn, Map map) { string pawnName = xxx.get_pawnname(pawn); if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({pawnName}): starting."); bool pawnIsNympho = xxx.is_nympho(pawn); bool pawnCanPickAnyone = RJWSettings.WildMode || (pawnIsNympho && RJWHookupSettings.NymphosCanPickAnyone); bool pawnCanPickAnimals = (pawnCanPickAnyone || xxx.is_zoophile(pawn)) && RJWSettings.bestiality_enabled; if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({pawnName}): nympho:{pawnIsNympho}, ignores rules:{pawnCanPickAnyone}, zoo:{pawnCanPickAnimals}"); if (!RJWHookupSettings.ColonistsCanHookup && pawn.IsFreeColonist && !pawnCanPickAnyone) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({pawnName}): is a colonist and colonist hookups are disabled in mod settings"); return null; } //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); // Check AllPawns, not just colonists, to include guests. List<Pawn> targets = map.mapPawns.AllPawns.Where(x => x != pawn && !x.InBed() && !x.IsForbidden(pawn) && xxx.IsTargetPawnOkay(x) && CanFuck(x) && x.Map == pawn.Map && !x.HostileTo(pawn) //&& (pawnCanPickAnimals || !xxx.is_animal(x)) && !xxx.is_animal(x) ).ToList(); if (!targets.Any()) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({pawnName}): no eligible targets"); return null; } if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck quickie({pawnName}): considering {targets.Count} targets"); // find lover/partner on same map List<Pawn> partners = targets.Where(x => pawn.relations.DirectRelationExists(PawnRelationDefOf.Lover, x) || pawn.relations.DirectRelationExists(PawnRelationDefOf.Fiance, x) || pawn.relations.DirectRelationExists(PawnRelationDefOf.Spouse, x) ).ToList(); if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({pawnName}): considering {partners.Count} partners"); if (partners.Any()) { partners.Shuffle(); //Randomize order. foreach (Pawn target in partners) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({pawnName}): checking lover {xxx.get_pawnname(target)}"); //interruptible jobs if (target.jobs?.curJob !=null && (target.jobs.curJob.playerForced || !JobDriver_SexQuick.quickieAllowedJobs.Contains(target.jobs.curJob.def) )) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({pawnName}): lover has important job ({target.jobs.curJob.def}), skipping"); continue; } if (pawn.Position.DistanceToSquared(target.Position) < MaxDistanceSquaredToFuck && pawn.CanReserveAndReach(target, PathEndMode.OnCell, Danger.Some, 1, 0) && target.CanReserve(pawn, 1, 0) && SexAppraiser.would_fuck(pawn, target) > 0.1f && SexAppraiser.would_fuck(target, pawn) > 0.1f) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({pawnName}): banging lover {xxx.get_pawnname(target)}"); return target; } } } // No lovers around... see if the pawn fancies a hookup. Nymphos and frustrated pawns always do! if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({pawnName}): no partners available. checking canHookup"); bool canHookup = pawnIsNympho || pawnCanPickAnyone || xxx.is_frustrated(pawn) || (xxx.is_horny(pawn) && Rand.Value < RJWHookupSettings.HookupChanceForNonNymphos); if (!canHookup) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({pawnName}): no hookup today"); return null; } // No cheating from casual hookups... would probably make colony relationship management too annoying if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({pawnName}): checking canHookupWithoutCheating"); bool hookupWouldBeCheating = xxx.HasNonPolyPartnerOnCurrentMap(pawn); if (hookupWouldBeCheating) { if (RJWHookupSettings.NymphosCanCheat && pawnIsNympho && xxx.is_frustrated(pawn)) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({pawnName}): I'm a nympho and I'm so frustrated that I'm going to cheat"); // No return here so they continue searching for hookup } else { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({pawnName}): I want to bang but that's cheating"); return null; } } Pawn best_fuckee = FindBestPartner(pawn, targets, pawnCanPickAnyone, pawnIsNympho); return best_fuckee; } /// <summary> Checks all of our potential partners to see if anyone's eligible, returning the most attractive and convenient one. </summary> protected static Pawn FindBestPartner(Pawn pawn, List<Pawn> targets, bool pawnCanPickAnyone, bool pawnIsNympho) { string pawnName = xxx.get_pawnname(pawn); Pawn best_fuckee = null; float best_fuckability_score = 0; foreach (Pawn targetPawn in targets) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] FindBestPartner({pawnName}): checking hookup {xxx.get_pawnname(targetPawn)}"); // Check to see if the mod settings for hookups allow this pairing if (!pawnCanPickAnyone && !HookupAllowedViaSettings(pawn, targetPawn)) continue; //interruptible jobs if (targetPawn.jobs?.curJob != null && (targetPawn.jobs.curJob.playerForced || !JobDriver_SexQuick.quickieAllowedJobs.Contains(targetPawn.jobs.curJob.def) )) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] FindBestPartner({pawnName}): targetPawn has important job ({targetPawn.jobs.curJob.def}, playerForced: {targetPawn.jobs.curJob.playerForced}), skipping"); continue; } // Check for homewrecking (banging a pawn who's in a relationship) if (!xxx.is_animal(targetPawn) && xxx.HasNonPolyPartnerOnCurrentMap(targetPawn)) { if (RJWHookupSettings.NymphosCanHomewreck && pawnIsNympho && xxx.is_frustrated(pawn)) { // Hookup allowed... rip colony mood } else if (RJWHookupSettings.NymphosCanHomewreckReverse && xxx.is_nympho(targetPawn) && xxx.is_frustrated(targetPawn)) { // Hookup allowed... rip colony mood } else { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] FindBestPartner({pawnName}): not hooking up with {xxx.get_pawnname(targetPawn)} to avoid homewrecking"); continue; } } // If the pawn has had sex recently and isn't horny right now, skip them. if (!SexUtility.ReadyForLovin(targetPawn) && !xxx.is_hornyorfrustrated(targetPawn)) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)} isn't ready for lovin'"); continue; } if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)} is sufficiently single"); if (!xxx.is_animal(targetPawn)) { float relations = pawn.relations.OpinionOf(targetPawn); if (relations < RJWHookupSettings.MinimumRelationshipToHookup) { if (!(relations > 0 && xxx.is_nympho(pawn))) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)}, i dont like them:({relations})"); continue; } } relations = targetPawn.relations.OpinionOf(pawn); if (relations < RJWHookupSettings.MinimumRelationshipToHookup) { if (!(relations > 0 && xxx.is_nympho(targetPawn))) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)}, dont like me:({relations})"); continue; } } float attraction = pawn.relations.SecondaryRomanceChanceFactor(targetPawn); if (attraction < RJWHookupSettings.MinimumAttractivenessToHookup) { if (!(attraction > 0 && xxx.is_nympho(pawn))) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)}, i dont find them attractive:({attraction})"); continue; } } attraction = targetPawn.relations.SecondaryRomanceChanceFactor(pawn); if (attraction < RJWHookupSettings.MinimumAttractivenessToHookup) { if (!(attraction > 0 && xxx.is_nympho(targetPawn))) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)}, doesnt find me attractive:({attraction})"); continue; } } } // Check to see if the two pawns are willing to bang, and if so remember how much attractive we find them float fuckability = 0f; if (pawn.CanReserveAndReach(targetPawn, PathEndMode.OnCell, Danger.Some, 1, 0) && targetPawn.CanReserve(pawn, 1, 0) && roll_to_skip(pawn, targetPawn, out fuckability)) // do NOT check pawnIgnoresRules here - these checks, particularly roll_to_skip, are critical { int dis = pawn.Position.DistanceToSquared(targetPawn.Position); if (dis <= 4) { // Right next to me (in my bed)? You'll do. if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)} is right next to me. we'll bang, ok?"); best_fuckability_score = 1.0e6f; best_fuckee = targetPawn; } else if (dis > MaxDistanceSquaredToFuck) { // too far if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)} is too far... distance:{dis} max:{MaxDistanceSquaredToFuck}"); continue; } else { // scaling fuckability by distance may give us more varied results and give the less attractive folks a chance float fuckability_score = fuckability / GenMath.Sqrt(GenMath.Sqrt(dis)); if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)} is totally bangable. attraction: {fuckability}, score:{fuckability_score}"); if (fuckability_score > best_fuckability_score) { best_fuckee = targetPawn; best_fuckability_score = fuckability_score; } } } } if (best_fuckee == null) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] FindBestPartner({pawnName}): couldn't find anyone to bang"); } else { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] FindBestPartner({pawnName}): found rando {xxx.get_pawnname(best_fuckee)} with score {best_fuckability_score}"); } return best_fuckee; } /// <summary> Checks to see if the mod settings allow the two pawns to hookup. </summary> protected static bool HookupAllowedViaSettings(Pawn pawn, Pawn targetPawn) { // Can prisoners hook up? if (pawn.IsPrisonerOfColony || pawn.IsPrisoner || xxx.is_slave(pawn)) { if (!RJWHookupSettings.PrisonersCanHookupWithNonPrisoner && !(targetPawn.IsPrisonerOfColony || targetPawn.IsPrisoner || xxx.is_slave(targetPawn))) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting PrisonersCanHookupWithNonPrisoner"); return false; } if (!RJWHookupSettings.PrisonersCanHookupWithPrisoner && (targetPawn.IsPrisonerOfColony || targetPawn.IsPrisoner || xxx.is_slave(targetPawn))) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting PrisonersCanHookupWithPrisoner"); return false; } } else { // Can non prisoners hook up with prisoners? if (!RJWHookupSettings.CanHookupWithPrisoner && (targetPawn.IsPrisonerOfColony || targetPawn.IsPrisoner || xxx.is_slave(targetPawn))) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting CanHookupWithPrisoner"); return false; } } // Can colonist hook up with visitors? if (pawn.IsFreeColonist && !xxx.is_slave(pawn)) { if (!RJWHookupSettings.ColonistsCanHookupWithVisitor && targetPawn.Faction != Faction.OfPlayer && !targetPawn.IsPrisonerOfColony) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting ColonistsCanHookupWithVisitor"); return false; } } // Can visitors hook up? if (pawn.Faction != Faction.OfPlayer && !pawn.IsPrisonerOfColony) { // visitors vs colonist if (!RJWHookupSettings.VisitorsCanHookupWithColonists && targetPawn.IsColonist) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting VisitorsCanHookupWithColonists"); return false; } // visitors vs visitors if (!RJWHookupSettings.VisitorsCanHookupWithVisitors && targetPawn.Faction != Faction.OfPlayer) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting VisitorsCanHookupWithVisitors"); return false; } } // TODO: Not sure if this handles all the pawn-on-animal cases. return true; } protected override Job TryGiveJob(Pawn pawn) { if (!RJWHookupSettings.HookupsEnabled || !RJWHookupSettings.QuickHookupsEnabled) return null; if (pawn.Drafted) return null; if (!SexUtility.ReadyForHookup(pawn)) return null; // We increase the time right away to prevent the fairly expensive check from happening too frequently SexUtility.IncreaseTicksToNextHookup(pawn); // If the pawn is a whore, or recently had sex, skip the job unless they're really horny if (!xxx.is_frustrated(pawn) && (xxx.is_whore(pawn) || !SexUtility.ReadyForLovin(pawn))) return null; // This check attempts to keep groups leaving the map, like guests or traders, from turning around to hook up if (pawn.mindState?.duty?.def == DutyDefOf.TravelOrLeave) { // TODO: Some guest pawns keep the TravelOrLeave duty the whole time, I think the ones assigned to guard the pack animals. // That's probably ok, though it wasn't the intention. if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJWQ] Quickie.TryGiveJob:({xxx.get_pawnname(pawn)}): has TravelOrLeave, no time for lovin!"); return null; } if (pawn.CurJob == null) { //--Log.Message(" checking pawn and abilities"); if (xxx.can_fuck(pawn) || xxx.can_be_fucked(pawn)) { //--Log.Message(" finding partner"); Pawn partner = find_pawn_to_fuck(pawn, pawn.Map); //--Log.Message(" checking partner"); if (partner == null) return null; // Interrupt current job. if (pawn.CurJob != null && pawn.jobs.curDriver != null) pawn.jobs.curDriver.EndJobWith(JobCondition.InterruptForced); //--Log.Message(" returning job"); return JobMaker.MakeJob(xxx.quick_sex, partner); } } return null; } } }
Tirem12/rjw
Source/JobGivers/JobGiver_DoQuickie.cs
C#
mit
16,912
using System.Collections.Generic; using System.Linq; using RimWorld; using Verse; using Verse.AI; using Multiplayer.API; namespace rjw { public class JobGiver_JoinInBed : ThinkNode_JobGiver { private const int MaxDistanceSquaredToFuck = 10000; private static bool CanFuck(Pawn target) { return xxx.can_fuck(target) || xxx.can_be_fucked(target); } [SyncMethod] private static bool roll_to_skip(Pawn pawn, Pawn target, out float fuckability) { fuckability = SexAppraiser.would_fuck(pawn, target); // 0.0 to 1.0 if (fuckability < RJWHookupSettings.MinimumFuckabilityToHookup) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] roll_to_skip(I, {xxx.get_pawnname(pawn)} won't fuck {xxx.get_pawnname(target)}), ({fuckability})"); return false; } float reciprocity = xxx.is_animal(target) ? 1.0f : SexAppraiser.would_fuck(target, pawn); if (reciprocity < RJWHookupSettings.MinimumFuckabilityToHookup) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] roll_to_skip({xxx.get_pawnname(target)} won't fuck me, {xxx.get_pawnname(pawn)}), ({reciprocity})"); return false; } float chance_to_skip = 0.9f - 0.7f * fuckability; //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); return Rand.Value < chance_to_skip; } [SyncMethod] public static Pawn find_pawn_to_fuck(Pawn pawn, Map map) { string pawnName = xxx.get_pawnname(pawn); if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): starting."); bool pawnIsNympho = xxx.is_nympho(pawn); bool pawnCanPickAnyone = RJWSettings.WildMode || (pawnIsNympho && RJWHookupSettings.NymphosCanPickAnyone); bool pawnCanPickAnimals = (pawnCanPickAnyone || xxx.is_zoophile(pawn)) && RJWSettings.bestiality_enabled; if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): nympho:{pawnIsNympho}, ignores rules:{pawnCanPickAnyone}, zoo:{pawnCanPickAnimals}"); if (!RJWHookupSettings.ColonistsCanHookup && pawn.IsFreeColonist && !pawnCanPickAnyone) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): is a colonist and colonist hookups are disabled in mod settings"); return null; } //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); // Check AllPawns, not just colonists, to include guests. List<Pawn> targets = map.mapPawns.AllPawns.Where(x => x.InBed() && x != pawn && !x.Position.IsForbidden(pawn) && xxx.IsTargetPawnOkay(x) && CanFuck(x) && x.Map == pawn.Map && !x.HostileTo(pawn) //&& (pawnCanPickAnimals || !xxx.is_animal(x)) && !xxx.is_animal(x) && (xxx.is_laying_down_alone(x) || xxx.in_same_bed(x, pawn)) ).ToList(); if (!targets.Any()) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): no eligible targets"); return null; } if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): considering {targets.Count} targets"); // find lover/partner on same map List<Pawn> partners = targets.Where(x => pawn.relations.DirectRelationExists(PawnRelationDefOf.Lover, x) || pawn.relations.DirectRelationExists(PawnRelationDefOf.Fiance, x) || pawn.relations.DirectRelationExists(PawnRelationDefOf.Spouse, x) ).ToList(); if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): considering {partners.Count} partners"); if (partners.Any()) { partners.Shuffle(); //Randomize order. foreach (Pawn target in partners) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): checking lover {xxx.get_pawnname(target)}"); if (pawn.Position.DistanceToSquared(target.Position) < MaxDistanceSquaredToFuck && pawn.CanReserveAndReach(target, PathEndMode.OnCell, Danger.Some, 1, 0) && target.CanReserve(pawn, 1, 0) && SexAppraiser.would_fuck(pawn, target) > 0.1f && SexAppraiser.would_fuck(target, pawn) > 0.1f) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): banging lover {xxx.get_pawnname(target)}"); return target; } } } // No lovers around... see if the pawn fancies a hookup. Nymphos and frustrated pawns always do! if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): no partners available. checking canHookup"); bool canHookup = pawnIsNympho || pawnCanPickAnyone || xxx.is_frustrated(pawn) || (xxx.is_horny(pawn) && Rand.Value < RJWHookupSettings.HookupChanceForNonNymphos); if (!canHookup) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): no hookup today"); return null; } // No cheating from casual hookups... would probably make colony relationship management too annoying if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): checking canHookupWithoutCheating"); bool hookupWouldBeCheating = xxx.HasNonPolyPartnerOnCurrentMap(pawn); if (hookupWouldBeCheating) { if (RJWHookupSettings.NymphosCanCheat && pawnIsNympho && xxx.is_frustrated(pawn)) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): I'm a nympho and I'm so frustrated that I'm going to cheat"); // No return here so they continue searching for hookup } else { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({pawnName}): I want to bang but that's cheating"); return null; } } Pawn best_fuckee = FindBestPartner(pawn, targets, pawnCanPickAnyone, pawnIsNympho); return best_fuckee; } /// <summary> Checks all of our potential partners to see if anyone's eligible, returning the most attractive and convenient one. </summary> protected static Pawn FindBestPartner(Pawn pawn, List<Pawn> targets, bool pawnCanPickAnyone, bool pawnIsNympho) { string pawnName = xxx.get_pawnname(pawn); Pawn best_fuckee = null; float best_fuckability_score = 0; foreach (Pawn targetPawn in targets) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): checking hookup {xxx.get_pawnname(targetPawn)}"); // Check to see if the mod settings for hookups allow this pairing if (!pawnCanPickAnyone && !HookupAllowedViaSettings(pawn, targetPawn)) continue; // Check for homewrecking (banging a pawn who's in a relationship) if (!xxx.is_animal(targetPawn) && xxx.HasNonPolyPartnerOnCurrentMap(targetPawn)) { if (RJWHookupSettings.NymphosCanHomewreck && pawnIsNympho && xxx.is_frustrated(pawn)) { // Hookup allowed... rip colony mood } else if (RJWHookupSettings.NymphosCanHomewreckReverse && xxx.is_nympho(targetPawn) && xxx.is_frustrated(targetPawn)) { // Hookup allowed... rip colony mood } else { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): not hooking up with {xxx.get_pawnname(targetPawn)} to avoid homewrecking"); continue; } } // If the pawn has had sex recently and isn't horny right now, skip them. if (!SexUtility.ReadyForLovin(targetPawn) && !xxx.is_hornyorfrustrated(targetPawn)) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)} isn't ready for lovin'"); continue; } if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)} is sufficiently single"); if (!xxx.is_animal(targetPawn)) { float relations = pawn.relations.OpinionOf(targetPawn); if (relations < RJWHookupSettings.MinimumRelationshipToHookup) { if (!(relations > 0 && xxx.is_nympho(pawn))) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)}, i dont like them:({relations})"); continue; } } relations = targetPawn.relations.OpinionOf(pawn); if (relations < RJWHookupSettings.MinimumRelationshipToHookup) { if (!(relations > 0 && xxx.is_nympho(targetPawn))) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)}, dont like me:({relations})"); continue; } } float attraction = pawn.relations.SecondaryRomanceChanceFactor(targetPawn); if (attraction < RJWHookupSettings.MinimumAttractivenessToHookup) { if (!(attraction > 0 && xxx.is_nympho(pawn))) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)}, i dont find them attractive:({attraction})"); continue; } } attraction = targetPawn.relations.SecondaryRomanceChanceFactor(pawn); if (attraction < RJWHookupSettings.MinimumAttractivenessToHookup) { if (!(attraction > 0 && xxx.is_nympho(targetPawn))) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)}, doesnt find me attractive:({attraction})"); continue; } } } // Check to see if the two pawns are willing to bang, and if so remember how much attractive we find them float fuckability = 0f; if (pawn.CanReserveAndReach(targetPawn, PathEndMode.OnCell, Danger.Some, 1, 0) && targetPawn.CanReserve(pawn, 1, 0) && roll_to_skip(pawn, targetPawn, out fuckability)) // do NOT check pawnIgnoresRules here - these checks, particularly roll_to_skip, are critical { int dis = pawn.Position.DistanceToSquared(targetPawn.Position); if (dis <= 4) { // Right next to me (in my bed)? You'll do. if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)} is right next to me. we'll bang, ok?"); best_fuckability_score = 1.0e6f; best_fuckee = targetPawn; } else if (dis > MaxDistanceSquaredToFuck) { // too far if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)} is too far... distance:{dis} max:{MaxDistanceSquaredToFuck}"); continue; } else { // scaling fuckability by distance may give us more varied results and give the less attractive folks a chance float fuckability_score = fuckability / GenMath.Sqrt(GenMath.Sqrt(dis)); if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): hookup {xxx.get_pawnname(targetPawn)} is totally bangable. attraction: {fuckability}, score:{fuckability_score}"); if (fuckability_score > best_fuckability_score) { best_fuckee = targetPawn; best_fuckability_score = fuckability_score; } } } } if (best_fuckee == null) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): couldn't find anyone to bang"); } else { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] FindBestPartner({pawnName}): found rando {xxx.get_pawnname(best_fuckee)} with score {best_fuckability_score}"); } return best_fuckee; } /// <summary> Checks to see if the mod settings allow the two pawns to hookup. </summary> protected static bool HookupAllowedViaSettings(Pawn pawn, Pawn targetPawn) { // Can prisoners hook up? if (pawn.IsPrisonerOfColony || pawn.IsPrisoner || xxx.is_slave(pawn)) { if (!RJWHookupSettings.PrisonersCanHookupWithNonPrisoner && !(targetPawn.IsPrisonerOfColony || targetPawn.IsPrisoner || xxx.is_slave(targetPawn))) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting PrisonersCanHookupWithNonPrisoner"); return false; } if (!RJWHookupSettings.PrisonersCanHookupWithPrisoner && (targetPawn.IsPrisonerOfColony || targetPawn.IsPrisoner || xxx.is_slave(targetPawn))) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting PrisonersCanHookupWithPrisoner"); return false; } } else { // Can non prisoners hook up with prisoners? if (!RJWHookupSettings.CanHookupWithPrisoner && (targetPawn.IsPrisonerOfColony || targetPawn.IsPrisoner || xxx.is_slave(targetPawn))) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting CanHookupWithPrisoner"); return false; } } // Can colonist hook up with visitors? if (pawn.IsFreeColonist && !xxx.is_slave(pawn)) { if (!RJWHookupSettings.ColonistsCanHookupWithVisitor && targetPawn.Faction != Faction.OfPlayer && !targetPawn.IsPrisonerOfColony) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting ColonistsCanHookupWithVisitor"); return false; } } // Can visitors hook up? if (pawn.Faction != Faction.OfPlayer && !pawn.IsPrisonerOfColony) { // visitors vs colonist if (!RJWHookupSettings.VisitorsCanHookupWithColonists && targetPawn.IsColonist) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting VisitorsCanHookupWithColonists"); return false; } // visitors vs visitors if (!RJWHookupSettings.VisitorsCanHookupWithVisitors && targetPawn.Faction != Faction.OfPlayer) { if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] find_pawn_to_fuck({xxx.get_pawnname(pawn)}): not hooking up with {xxx.get_pawnname(targetPawn)} due to mod setting VisitorsCanHookupWithVisitors"); return false; } } // TODO: Not sure if this handles all the pawn-on-animal cases. return true; } protected override Job TryGiveJob(Pawn pawn) { if (!RJWHookupSettings.HookupsEnabled) return null; if (pawn.Drafted) return null; if (!SexUtility.ReadyForHookup(pawn)) return null; // We increase the time right away to prevent the fairly expensive check from happening too frequently SexUtility.IncreaseTicksToNextHookup(pawn); // If the pawn is a whore, or recently had sex, skip the job unless they're really horny if (!xxx.is_frustrated(pawn) && (xxx.is_whore(pawn) || !SexUtility.ReadyForLovin(pawn))) return null; // This check attempts to keep groups leaving the map, like guests or traders, from turning around to hook up if (pawn.mindState?.duty?.def == DutyDefOf.TravelOrLeave) { // TODO: Some guest pawns keep the TravelOrLeave duty the whole time, I think the ones assigned to guard the pack animals. // That's probably ok, though it wasn't the intention. if (RJWSettings.DebugLogJoinInBed) Log.Message($"[RJW] JoinInBed.TryGiveJob:({xxx.get_pawnname(pawn)}): has TravelOrLeave, no time for lovin!"); return null; } if (pawn.CurJob == null || pawn.CurJob.def == JobDefOf.LayDown) { //--Log.Message(" checking pawn and abilities"); if (xxx.can_fuck(pawn) || xxx.can_be_fucked(pawn)) { //--Log.Message(" finding partner"); Pawn partner = find_pawn_to_fuck(pawn, pawn.Map); //--Log.Message(" checking partner"); if (partner == null) return null; // Can never be null, since find checks for bed. Building_Bed bed = partner.CurrentBed(); // Interrupt current job. if (pawn.CurJob != null && pawn.jobs.curDriver != null) pawn.jobs.curDriver.EndJobWith(JobCondition.InterruptForced); //--Log.Message(" returning job"); return JobMaker.MakeJob(xxx.casual_sex, partner, bed); } } return null; } } }
Tirem12/rjw
Source/JobGivers/JobGiver_JoinInBed.cs
C#
mit
16,222
using System.Linq; using RimWorld; using Verse; using Verse.AI; using System.Collections.Generic; using Multiplayer.API; namespace rjw { public class JobGiver_RandomRape : ThinkNode_JobGiver { [SyncMethod] public Pawn find_victim(Pawn pawn, Map m) { float min_fuckability = 0.10f; // Don't rape pawns with <10% fuckability float avg_fuckability = 0f; // Average targets fuckability, choose target higher than that var valid_targets = new Dictionary<Pawn, float>(); // Valid pawns and their fuckability Pawn chosentarget = null; // Final target pawn // could be prisoner, colonist, or non-hostile outsider IEnumerable<Pawn> targets = m.mapPawns.AllPawnsSpawned.Where(x => x != pawn && xxx.is_not_dying(x) && xxx.can_get_raped(x) && !x.Suspended && !x.Drafted && !x.IsForbidden(pawn) && pawn.CanReserveAndReach(x, PathEndMode.Touch, Danger.Some, xxx.max_rapists_per_prisoner, 0) && !x.HostileTo(pawn) ); //Zoo rape Animal if (xxx.is_zoophile(pawn) && RJWSettings.bestiality_enabled) { foreach (Pawn target in targets.Where(x => xxx.is_animal(x))) { if (!xxx.can_path_to_target(pawn, target.Position)) continue;// too far float fuc = SexAppraiser.would_fuck(pawn, target, true, true); if (fuc > min_fuckability) valid_targets.Add(target, fuc); } if (valid_targets.Any()) { avg_fuckability = valid_targets.Average(x => x.Value); // choose pawns to fuck with above average fuckability var valid_targetsFilteredAnimals = valid_targets.Where(x => x.Value >= avg_fuckability); if (valid_targetsFilteredAnimals.Any()) chosentarget = valid_targetsFilteredAnimals.RandomElement().Key; return chosentarget; } } valid_targets = new Dictionary<Pawn, float>(); // rape Humanlike foreach (Pawn target in targets.Where(x => !xxx.is_animal(x))) { if (!xxx.can_path_to_target(pawn, target.Position)) continue;// too far float fuc = SexAppraiser.would_fuck(pawn, target, true, true); if (fuc > min_fuckability) valid_targets.Add(target, fuc); } if (valid_targets.Any()) { avg_fuckability = valid_targets.Average(x => x.Value); // choose pawns to fuck with above average fuckability var valid_targetsFilteredAnimals = valid_targets.Where(x => x.Value >= avg_fuckability); if (valid_targetsFilteredAnimals.Any()) chosentarget = valid_targetsFilteredAnimals.RandomElement().Key; } return chosentarget; } protected override Job TryGiveJob(Pawn pawn) { //Log.Message("[RJW] JobGiver_RandomRape::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called"); if (!xxx.can_rape(pawn)) return null; if (pawn.health.hediffSet.HasHediff(HediffDef.Named("Hediff_RapeEnemyCD"))) return null; pawn.health.AddHediff(HediffDef.Named("Hediff_RapeEnemyCD"), null, null, null); Pawn victim = find_victim(pawn, pawn.Map); if (victim == null) return null; //Log.Message("[RJW] JobGiver_RandomRape::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) - found victim " + xxx.get_pawnname(victim)); return JobMaker.MakeJob(xxx.RapeRandom, victim); } } }
Tirem12/rjw
Source/JobGivers/JobGiver_RandomRape.cs
C#
mit
3,245
using Verse; using Verse.AI; using RimWorld; namespace rjw { /// <summary> /// Pawn try to find enemy to rape. /// </summary> public class JobGiver_RapeEnemy : ThinkNode_JobGiver { protected override Job TryGiveJob(Pawn pawn) { if (RJWSettings.DebugRape) Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) called0"); //Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 0 " + SexUtility.ReadyForLovin(pawn)); //Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 1 " + (xxx.need_some_sex(pawn) <= 1f)); //Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 2 " + !(SexUtility.ReadyForLovin(pawn) || xxx.need_some_sex(pawn) <= 1f)); //Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 1 " + Find.TickManager.TicksGame); //Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) 2 " + pawn.mindState.canLovinTick); if (pawn.Drafted) return null; if (pawn.health.hediffSet.HasHediff(HediffDef.Named("Hediff_RapeEnemyCD")) || !pawn.health.capacities.CanBeAwake || !(SexUtility.ReadyForLovin(pawn) || xxx.need_some_sex(pawn) <= 1f)) //if (pawn.health.hediffSet.HasHediff(HediffDef.Named("Hediff_RapeEnemyCD")) || !pawn.health.capacities.CanBeAwake || (SexUtility.ReadyForLovin(pawn) || xxx.is_human(pawn) ? xxx.need_some_sex(pawn) <= 1f : false)) return null; if (!xxx.can_rape(pawn)) return null; if (RJWSettings.DebugRape) Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) can rape"); JobDef_RapeEnemy rapeEnemyJobDef = null; int? highestPriority = null; foreach (JobDef_RapeEnemy job in DefDatabase<JobDef_RapeEnemy>.AllDefs) { if (job.CanUseThisJobForPawn(pawn)) { if (highestPriority == null) { rapeEnemyJobDef = job; highestPriority = job.priority; } else if (job.priority > highestPriority) { rapeEnemyJobDef = job; highestPriority = job.priority; } } } if (RJWSettings.DebugRape) Log.Message("[RJW] JobGiver_RapeEnemy::ChoosedJobDef( " + xxx.get_pawnname(pawn) + " ) - " + rapeEnemyJobDef.ToString() + " choosed"); Pawn victim = rapeEnemyJobDef?.FindVictim(pawn, pawn.Map); if (RJWSettings.DebugRape) Log.Message("[RJW] JobGiver_RapeEnemy::FoundVictim( " + xxx.get_pawnname(victim) + " )"); //prevents 10 job stacks error, no idea whats the prob with JobDriver_Rape //if (victim != null) pawn.health.AddHediff(HediffDef.Named("Hediff_RapeEnemyCD"), null, null, null); return victim != null ? JobMaker.MakeJob(rapeEnemyJobDef, victim) : null; /* else { if (RJWSettings.DebugRape) Log.Message("[RJW]" + this.GetType().ToString() + "::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) - unable to find victim"); pawn.mindState.canLovinTick = Find.TickManager.TicksGame + Rand.Range(75, 150); } */ //else { if (RJWSettings.DebugRape) Log.Message("[RJW] JobGiver_RapeEnemy::TryGiveJob( " + xxx.get_pawnname(pawn) + " ) - too fast to play next"); } } } }
Tirem12/rjw
Source/JobGivers/JobGiver_RapeEnemy.cs
C#
mit
3,159
using RimWorld; using Verse; using Verse.AI; using System.Collections.Generic; using System.Linq; namespace rjw { public class JobGiver_ViolateCorpse : ThinkNode_JobGiver { public static Corpse find_corpse(Pawn pawn, Map m) { float min_fuckability = 0.10f; // Don't rape pawns with <10% fuckability float avg_fuckability = 0f; // Average targets fuckability, choose target higher than that var valid_targets = new Dictionary<Corpse, float>(); // Valid pawns and their fuckability Corpse chosentarget = null; // Final target pawn IEnumerable<Thing> targets = m.spawnedThings.Where(x => x is Corpse && pawn.CanReserveAndReach(x, PathEndMode.OnCell, Danger.Some) && !x.IsForbidden(pawn) ); foreach (Corpse target in targets) { if (!xxx.can_path_to_target(pawn, target.Position)) continue;// too far // Filter out rotters if not necrophile. if (!xxx.is_necrophiliac(pawn) && target.CurRotDrawMode != RotDrawMode.Fresh) continue; float fuc = SexAppraiser.would_fuck(pawn, target, false, false); if (fuc > min_fuckability) valid_targets.Add(target, fuc); } if (valid_targets.Any()) { avg_fuckability = valid_targets.Average(x => x.Value); // choose pawns to fuck with above average fuckability var valid_targetsFilteredAnimals = valid_targets.Where(x => x.Value >= avg_fuckability); if (valid_targetsFilteredAnimals.Any()) chosentarget = valid_targetsFilteredAnimals.RandomElement().Key; } return chosentarget; } protected override Job TryGiveJob(Pawn pawn) { // Most checks are done in ThinkNode_ConditionalNecro. // filter out necro for nymphs if (!RJWSettings.necrophilia_enabled) return null; if (pawn.Drafted) return null; //--Log.Message("[RJW] JobGiver_ViolateCorpse::TryGiveJob for ( " + xxx.get_pawnname(pawn) + " )"); if (SexUtility.ReadyForLovin(pawn) || xxx.is_hornyorfrustrated(pawn)) { //--Log.Message("[RJW] JobGiver_ViolateCorpse::TryGiveJob, can love "); if (!xxx.can_rape(pawn)) return null; var target = find_corpse(pawn, pawn.Map); //--Log.Message("[RJW] JobGiver_ViolateCorpse::TryGiveJob - target is " + (target == null ? "NULL" : "Found")); if (target != null) { return JobMaker.MakeJob(xxx.RapeCorpse, target); } // Ticks should only be increased after successful sex. } return null; } } }
Tirem12/rjw
Source/JobGivers/JobGiver_ViolateCorpse.cs
C#
mit
2,503
using System.Collections.Generic; using System.Linq; using System; using Verse; using RimWorld; using RimWorld.Planet; namespace rjw.MainTab { public class MainTabWindow_Brothel : MainTabWindow_PawnTable { private static PawnTableDef pawnTableDef; protected override PawnTableDef PawnTableDef => pawnTableDef ?? (pawnTableDef = DefDatabase<PawnTableDef>.GetNamed("Brothel")); protected override IEnumerable<Pawn> Pawns => Find.CurrentMap.mapPawns.AllPawns.Where(p => xxx.is_human(p) && (p.IsColonist || p.IsPrisonerOfColony)); public override void PostOpen() { base.PostOpen(); Find.World.renderer.wantedMode = WorldRenderMode.None; } } }
Tirem12/rjw
Source/MainTab/MainTabWindow_Brothel.cs
C#
mit
667
using System; using System.Collections.Generic; using System.Linq; using Verse; using UnityEngine; using RimWorld; using Verse.Sound; namespace rjw.MainTab { public abstract class PawnColumnCheckbox_Whore : PawnColumnWorker { public const int HorizontalPadding = 2; public override void DoCell(Rect rect, Pawn pawn, PawnTable table) { if (!this.HasCheckbox(pawn)) { return; } int num = (int)((rect.width - 24f) / 2f); int num2 = Mathf.Max(3, 0); Vector2 vector = new Vector2(rect.x + (float)num, rect.y + (float)num2); Rect rect2 = new Rect(vector.x, vector.y, 24f, 24f); if (Find.TickManager.TicksGame % 60 == 0) { pawn.UpdatePermissions(); //Log.Message("GetDisabled UpdateCanDesignateService for " + xxx.get_pawnname(pawn)); //Log.Message("UpdateCanDesignateService " + pawn.UpdateCanDesignateService()); //Log.Message("CanDesignateService " + pawn.CanDesignateService()); //Log.Message("GetDisabled " + GetDisabled(pawn)); } bool disabled = this.GetDisabled(pawn); bool value; if (disabled) { value = false; } else { value = this.GetValue(pawn); } bool flag = value; Vector2 topLeft = vector; WhoreCheckbox.Checkbox(topLeft, ref value, 24f, disabled, WhoreCheckbox.WhoreCheckboxOnTex, WhoreCheckbox.WhoreCheckboxOffTex, WhoreCheckbox.WhoreCheckboxDisabledTex); if (Mouse.IsOver(rect2)) { string tip = this.GetTip(pawn); if (!tip.NullOrEmpty()) { TooltipHandler.TipRegion(rect2, tip); } } if (value != flag) { this.SetValue(pawn, value); } } public override int GetMinWidth(PawnTable table) { return Mathf.Max(base.GetMinWidth(table), 28); } public override int GetMaxWidth(PawnTable table) { return Mathf.Min(base.GetMaxWidth(table), this.GetMinWidth(table)); } public override int GetMinCellHeight(Pawn pawn) { return Mathf.Max(base.GetMinCellHeight(pawn), 24); } public override int Compare(Pawn a, Pawn b) { return this.GetValueToCompare(a).CompareTo(this.GetValueToCompare(b)); } private int GetValueToCompare(Pawn pawn) { if (!this.HasCheckbox(pawn)) { return 0; } if (!this.GetValue(pawn)) { return 1; } return 2; } protected virtual string GetTip(Pawn pawn) { return null; } protected virtual bool HasCheckbox(Pawn pawn) { return true; } protected abstract bool GetValue(Pawn pawn); protected abstract void SetValue(Pawn pawn, bool value); protected abstract bool GetDisabled(Pawn pawn); protected override void HeaderClicked(Rect headerRect, PawnTable table) { base.HeaderClicked(headerRect, table); if (Event.current.shift) { List<Pawn> pawnsListForReading = table.PawnsListForReading; for (int i = 0; i < pawnsListForReading.Count; i++) { if (this.HasCheckbox(pawnsListForReading[i])) { if (Event.current.button == 0) { if (!this.GetValue(pawnsListForReading[i])) { this.SetValue(pawnsListForReading[i], true); } } else if (Event.current.button == 1 && this.GetValue(pawnsListForReading[i])) { this.SetValue(pawnsListForReading[i], false); } } } if (Event.current.button == 0) { SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(null); } else if (Event.current.button == 1) { SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null); } } } protected override string GetHeaderTip(PawnTable table) { return base.GetHeaderTip(table) + "\n" + "CheckboxShiftClickTip".Translate(); } } }
Tirem12/rjw
Source/MainTab/PawnColumnCheckbox_Whore.cs
C#
mit
3,626
using System.Collections.Generic; using System.Linq; using System.Text; using RimWorld; using RimWorld.Planet; using UnityEngine; using Verse; namespace rjw.MainTab { [StaticConstructorOnStartup] public class PawnColumnWorker_AverageMoneyByWhore : PawnColumnWorker_TextCenter { public static readonly RecordDef EarnedMoneyByWhore = DefDatabase<RecordDef>.GetNamed("EarnedMoneyByWhore"); public static readonly RecordDef CountOfWhore = DefDatabase<RecordDef>.GetNamed("CountOfWhore"); protected internal float score; protected override string GetTextFor(Pawn pawn) { float total = pawn.records.GetValue(EarnedMoneyByWhore); float count = pawn.records.GetValue(CountOfWhore); if ((int)count == 0) { return "-"; } score = (total / count); return ((int)score).ToString(); } public override int Compare(Pawn a, Pawn b) { return GetValueToCompare(a).CompareTo(GetValueToCompare(b)); } private float GetValueToCompare(Pawn pawn) { return score; } } }
Tirem12/rjw
Source/MainTab/PawnColumnWorker_AverageMoneyByWhore.cs
C#
mit
1,011
using System.Collections.Generic; using System.Linq; using System.Text; using RimWorld; using RimWorld.Planet; using UnityEngine; using Verse; namespace rjw.MainTab { [StaticConstructorOnStartup] public class PawnColumnWorker_CountOfWhore : PawnColumnWorker_TextCenter { public static readonly RecordDef CountOfWhore = DefDatabase<RecordDef>.GetNamed("CountOfWhore"); protected internal int score; protected override string GetTextFor(Pawn pawn) { score = pawn.records.GetAsInt(CountOfWhore); return pawn.records.GetValue(CountOfWhore).ToString(); } public override int Compare(Pawn a, Pawn b) { return GetValueToCompare(a).CompareTo(GetValueToCompare(b)); } private int GetValueToCompare(Pawn pawn) { return score; } } }
Tirem12/rjw
Source/MainTab/PawnColumnWorker_CountOfWhore.cs
C#
mit
768
using System.Collections.Generic; using System.Linq; using System.Text; using RimWorld; using RimWorld.Planet; using UnityEngine; using Verse; namespace rjw.MainTab { [StaticConstructorOnStartup] public class PawnColumnWorker_EarnedMoneyByWhore : PawnColumnWorker_TextCenter { public static readonly RecordDef EarnedMoneyByWhore = DefDatabase<RecordDef>.GetNamed("EarnedMoneyByWhore"); protected internal int score; protected override string GetTextFor(Pawn pawn) { score = pawn.records.GetAsInt(EarnedMoneyByWhore); return pawn.records.GetValue(EarnedMoneyByWhore).ToString(); } public override int Compare(Pawn a, Pawn b) { return GetValueToCompare(a).CompareTo(GetValueToCompare(b)); } private int GetValueToCompare(Pawn pawn) { return score; } } }
Tirem12/rjw
Source/MainTab/PawnColumnWorker_EarnedMoneyByWhore.cs
C#
mit
798
using System.Collections.Generic; using System.Linq; using System.Text; using RimWorld; using RimWorld.Planet; using UnityEngine; using Verse; namespace rjw.MainTab { [StaticConstructorOnStartup] public class PawnColumnWorker_IsPrisoner : PawnColumnWorker_Icon { private static readonly Texture2D comfortOn = ContentFinder<Texture2D>.Get("UI/Tab/ComfortPrisoner_on"); private readonly Texture2D comfortOff = ContentFinder<Texture2D>.Get("UI/Tab/ComfortPrisoner_off"); protected override Texture2D GetIconFor(Pawn pawn) { return pawn.IsPrisonerOfColony || xxx.is_slave(pawn) ? comfortOn : null; } } }
Tirem12/rjw
Source/MainTab/PawnColumnWorker_IsPrisoner.cs
C#
mit
621
using System.Collections.Generic; using System.Linq; using System.Text; using RimWorld; using RimWorld.Planet; using UnityEngine; using Verse; namespace rjw.MainTab { [StaticConstructorOnStartup] public class PawnColumnWorker_IsWhore : PawnColumnCheckbox_Whore { protected override bool GetDisabled(Pawn pawn) { return !pawn.CanDesignateService(); } protected override bool GetValue(Pawn pawn) { return pawn.IsDesignatedService() && xxx.is_human(pawn); } protected override void SetValue(Pawn pawn, bool value) { if (value == this.GetValue(pawn)) return; pawn.ToggleService(); } /* private static readonly Texture2D serviceOn = ContentFinder<Texture2D>.Get("UI/Tab/Service_on"); private static readonly Texture2D serviceOff = ContentFinder<Texture2D>.Get("UI/Tab/Service_off"); protected override Texture2D GetIconFor(Pawn pawn) { return pawn.IsDesignatedService() ? serviceOn : null; }*/ } }
Tirem12/rjw
Source/MainTab/PawnColumnWorker_IsWhore.cs
C#
mit
953
using System.Collections.Generic; using System.Linq; using System.Text; using RimWorld; using RimWorld.Planet; using UnityEngine; using Verse; namespace rjw.MainTab { [StaticConstructorOnStartup] public class PawnColumnWorker_Mood : PawnColumnWorker_TextCenter { protected internal float score; protected override string GetTextFor(Pawn pawn) { score = pawn.needs.mood.CurLevelPercentage; return score.ToStringPercent(); } public override int Compare(Pawn a, Pawn b) { return GetValueToCompare(a).CompareTo(GetValueToCompare(b)); } private float GetValueToCompare(Pawn pawn) { return score; } } }
Tirem12/rjw
Source/MainTab/PawnColumnWorker_Mood.cs
C#
mit
640
using System.Collections.Generic; using System.Linq; using System.Text; using RimWorld; using RimWorld.Planet; using UnityEngine; using Verse; namespace rjw.MainTab { [StaticConstructorOnStartup] public class PawnColumnWorker_PriceRangeOfWhore : PawnColumnWorker_TextCenter { protected internal int min; protected internal int max; protected override string GetTextFor(Pawn pawn) { min = WhoringHelper.WhoreMinPrice(pawn); max = WhoringHelper.WhoreMaxPrice(pawn); return string.Format("{0} - {1}", min, max); } public override int Compare(Pawn a, Pawn b) { return GetValueToCompare(a).CompareTo(GetValueToCompare(b)); } protected override string GetTip(Pawn pawn) { string minPriceTip = string.Format( " Base: {0}\n Traits: {1}", WhoringHelper.baseMinPrice, (WhoringHelper.WhoreTraitAdjustmentMin(pawn) -1f).ToStringPercent() ); string maxPriceTip = string.Format( " Base: {0}\n Traits: {1}", WhoringHelper.baseMaxPrice, (WhoringHelper.WhoreTraitAdjustmentMax(pawn) -1f).ToStringPercent() ); string bothTip = string.Format( " Gender: {0}\n Age: {1}\n Injuries: {2}\n Room: {3}", (WhoringHelper.WhoreGenderAdjustment(pawn) - 1f).ToStringPercent(), (WhoringHelper.WhoreAgeAdjustment(pawn) - 1f).ToStringPercent(), (WhoringHelper.WhoreInjuryAdjustment(pawn) - 1f).ToStringPercent(), (WhoringHelper.WhoreRoomAdjustment(pawn) - 1f).ToStringPercent() ); return string.Format("Min:\n{0}\nMax:\n{1}\nBoth:\n{2}", minPriceTip, maxPriceTip, bothTip); } private int GetValueToCompare(Pawn pawn) { return min; } } }
Tirem12/rjw
Source/MainTab/PawnColumnWorker_PriceRangeOfWhore.cs
C#
mit
1,632
using System.Collections.Generic; using System.Linq; using System.Text; using RimWorld; using RimWorld.Planet; using UnityEngine; using Verse; namespace rjw.MainTab { [StaticConstructorOnStartup] public class PawnColumnWorker_RoomAdjustmentOfWhore : PawnColumnWorker_TextCenter { protected internal float score; protected override string GetTextFor(Pawn pawn) { score = WhoringHelper.WhoreRoomAdjustment(pawn); Room ownedRoom = pawn.ownership.OwnedRoom; int scoreStageIndex; string scoreStageName; if (ownedRoom == null) { scoreStageName = "No room"; scoreStageIndex = 0; } else { scoreStageName = RoomStatDefOf.Impressiveness.GetScoreStage(ownedRoom.GetStat(RoomStatDefOf.Impressiveness)).label; scoreStageIndex = RoomStatDefOf.Impressiveness.GetScoreStageIndex(ownedRoom.GetStat(RoomStatDefOf.Impressiveness)); } return string.Format("{0} ({1})", scoreStageName, score.ToStringPercent()); } public override int Compare(Pawn a, Pawn b) { return GetValueToCompare(a).CompareTo(GetValueToCompare(b)); } private float GetValueToCompare(Pawn pawn) { return score; } } }
Tirem12/rjw
Source/MainTab/PawnColumnWorker_RoomAdjustmentOfWhore.cs
C#
mit
1,153
using System.Collections.Generic; using System.Linq; using System.Text; using RimWorld; using RimWorld.Planet; using UnityEngine; using Verse; namespace rjw.MainTab { public abstract class PawnColumnWorker_TextCenter : PawnColumnWorker_Text { public override void DoCell(Rect rect, Pawn pawn, PawnTable table) { Rect rect2 = new Rect(rect.x, rect.y, rect.width, Mathf.Min(rect.height, 30f)); string textFor = GetTextFor(pawn); if (textFor != null) { Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; Text.WordWrap = false; Widgets.Label(rect2, textFor); Text.WordWrap = true; Text.Anchor = TextAnchor.UpperLeft; string tip = GetTip(pawn); if (!tip.NullOrEmpty()) { TooltipHandler.TipRegion(rect2, tip); } } } } }
Tirem12/rjw
Source/MainTab/PawnColumnWorker_TextCenter.cs
C#
mit
803
using System.Collections.Generic; using System.Linq; using System.Text; using RimWorld; using RimWorld.Planet; using UnityEngine; using Verse; namespace rjw.MainTab { [StaticConstructorOnStartup] public class PawnColumnWorker_WhoreExperience : PawnColumnWorker_TextCenter { public static readonly RecordDef CountOfWhore = DefDatabase<RecordDef>.GetNamed("CountOfWhore"); public static readonly HashSet<string> backstories = new HashSet<string>(DefDatabase<StringListDef>.GetNamed("WhoreBackstories").strings); protected override string GetTextFor(Pawn pawn) { int b = backstories.Contains(pawn.story?.adulthood?.titleShort) ? 30 : 0; int score = pawn.records.GetAsInt(CountOfWhore); return (score + b).ToString(); } } }
Tirem12/rjw
Source/MainTab/PawnColumnWorker_WhoreExperience.cs
C#
mit
751
using System; using System.Collections.Generic; using System.Linq; using RimWorld; using Verse; namespace rjw.MainTab { public class PawnTable_Whores : PawnTable { public PawnTable_Whores(PawnTableDef def, Func<IEnumerable<Pawn>> pawnsGetter, int uiWidth, int uiHeight) : base(def, pawnsGetter, uiWidth, uiHeight) { } protected override IEnumerable<Pawn> LabelSortFunction(IEnumerable<Pawn> input) { //return input.OrderBy(p => p.Name?.Numerical != false).ThenBy(p => (p.Name as NameSingle)?.Number ?? 0).ThenBy(p => p.def.label); return input.OrderBy(p => xxx.get_pawnname(p)); } protected override IEnumerable<Pawn> PrimarySortFunction(IEnumerable<Pawn> input) { ///return input.OrderByDescending(p => p.Faction?.Name); //return input.OrderBy(p => xxx.get_pawnname(p)); foreach (Pawn p in input) p.UpdatePermissions(); return input.OrderByDescending(p => p.IsColonist); } } }
Tirem12/rjw
Source/MainTab/PawnTable_Whores.cs
C#
mit
922
using System; using System.Collections.Generic; using System.Linq; using Verse; using UnityEngine; using RimWorld; using Verse.Sound; namespace rjw.MainTab { [StaticConstructorOnStartup] public static class WhoreCheckbox { public static readonly Texture2D WhoreCheckboxOnTex = ContentFinder<Texture2D>.Get("UI/Commands/Service_on"); public static readonly Texture2D WhoreCheckboxOffTex = ContentFinder<Texture2D>.Get("UI/Commands/Service_off"); public static readonly Texture2D WhoreCheckboxDisabledTex = ContentFinder<Texture2D>.Get("UI/Commands/Service_Refuse"); private static bool checkboxPainting; private static bool checkboxPaintingState; public static void Checkbox(Vector2 topLeft, ref bool checkOn, float size = 24f, bool disabled = false, Texture2D texChecked = null, Texture2D texUnchecked = null, Texture2D texDisabled = null) { WhoreCheckbox.Checkbox(topLeft.x, topLeft.y, ref checkOn, size, disabled, texChecked, texUnchecked); } public static void Checkbox(float x, float y, ref bool checkOn, float size = 24f, bool disabled = false, Texture2D texChecked = null, Texture2D texUnchecked = null, Texture2D texDisabled = null) { Rect rect = new Rect(x, y, size, size); WhoreCheckbox.CheckboxDraw(x, y, checkOn, disabled, size, texChecked, texUnchecked,texDisabled); if (!disabled) { MouseoverSounds.DoRegion(rect); bool flag = false; Widgets.DraggableResult draggableResult = Widgets.ButtonInvisibleDraggable(rect, false); if (draggableResult == Widgets.DraggableResult.Pressed) { checkOn = !checkOn; flag = true; } else if (draggableResult == Widgets.DraggableResult.Dragged) { checkOn = !checkOn; flag = true; WhoreCheckbox.checkboxPainting = true; WhoreCheckbox.checkboxPaintingState = checkOn; } if (Mouse.IsOver(rect) && WhoreCheckbox.checkboxPainting && Input.GetMouseButton(0) && checkOn != WhoreCheckbox.checkboxPaintingState) { checkOn = WhoreCheckbox.checkboxPaintingState; flag = true; } if (flag) { if (checkOn) { SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(null); } else { SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null); } } } } private static void CheckboxDraw(float x, float y, bool active, bool disabled, float size = 24f, Texture2D texChecked = null, Texture2D texUnchecked = null, Texture2D texDisabled = null) { Texture2D image; if (disabled) { image = ((!(texDisabled != null)) ? WhoreCheckbox.WhoreCheckboxDisabledTex : texDisabled); } else if (active) { image = ((!(texChecked != null)) ? WhoreCheckbox.WhoreCheckboxOnTex : texChecked); } else { image = ((!(texUnchecked != null)) ? WhoreCheckbox.WhoreCheckboxOffTex : texUnchecked); } Rect position = new Rect(x, y, size, size); GUI.DrawTexture(position, image); } } }
Tirem12/rjw
Source/MainTab/WhoreCheckbox.cs
C#
mit
2,919
using System; using System.Collections.Generic; using System.Linq; using System.Text; using RimWorld; using Verse.AI; using Verse; namespace rjw { public class MentalState_RandomRape : SexualMentalState { public override void PostStart(string reason) { base.PostStart(reason); this.pawn.mindState.canLovinTick = -1; } public override bool ForceHostileTo(Thing t) { /* //planning random raper hostile to other colonists. but now, injured raper wont rape. if ((this.pawn.jobs != null) && (this.pawn.jobs.curDriver != null) && (this.pawn.jobs.curDriver as JobDriver_Rape != null)) { return true; }*/ return false; } public override bool ForceHostileTo(Faction f) { /* if ((this.pawn.jobs != null) && (this.pawn.jobs.curDriver != null) && (this.pawn.jobs.curDriver as JobDriver_Rape != null)) { return true; }*/ return false; } public override RandomSocialMode SocialModeMax() { return RandomSocialMode.Off; } } }
Tirem12/rjw
Source/MentalStates/MentalState_RandomRape.cs
C#
mit
1,007
using System; using System.Collections.Generic; using System.Linq; using System.Text; using RimWorld; using Verse.AI; using Verse; namespace rjw { public class SexualMentalState : MentalState { public override void MentalStateTick() { if (this.pawn.IsHashIntervalTick(150)) { if (xxx.is_satisfied(pawn)) { this.RecoverFromState(); return; } } base.MentalStateTick(); } } public class SexualMentalStateWorker : MentalStateWorker { public override bool StateCanOccur(Pawn pawn) { if (base.StateCanOccur(pawn)) { return xxx.is_human(pawn) && xxx.can_rape(pawn); } else { return false; } } } public class SexualMentalBreakWorker : MentalBreakWorker { public override float CommonalityFor(Pawn pawn, bool moodCaused = false) { if (xxx.is_human(pawn)) { var need_sex = pawn.needs.TryGetNeed<Need_Sex>(); if (need_sex != null) return base.CommonalityFor(pawn) * (def as SexualMentalBreakDef).commonalityMultiplierBySexNeed.Evaluate(need_sex.CurLevelPercentage * 100f); else return 0; } else { return 0; } } } public class SexualMentalStateDef : MentalStateDef { } public class SexualMentalBreakDef : MentalBreakDef { public SimpleCurve commonalityMultiplierBySexNeed; } }
Tirem12/rjw
Source/MentalStates/SexualMentalState.cs
C#
mit
1,310
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Verse; namespace rjw { /// <summary> /// Helper class for ChJees's Androids mod. /// </summary> [StaticConstructorOnStartup] public static class AndroidsCompatibility { public static Type androidCompatType; public static readonly string typeName = "Androids.SexualizeAndroidRJW"; private static bool foundType; static AndroidsCompatibility() { try { androidCompatType = Type.GetType(typeName); foundType = true; //Log.Message("Found Type: Androids.SexualizeAndroidRJW"); } catch { foundType = false; //Log.Message("Did NOT find Type: Androids.SexualizeAndroidRJW"); } } /*private static bool TestPredicate(DefModExtension extension) { if (extension == null) return false; Log.Message($"Predicate: {extension} : {extension.GetType()?.FullName}"); return extension.GetType().FullName == typeName; }*/ public static bool IsAndroid(ThingDef def) { if (def == null || !foundType) { return false; } return def.modExtensions != null && def.modExtensions.Any(extension => extension.GetType().FullName == typeName); } public static bool IsAndroid(Thing thing) { return IsAndroid(thing.def); } public static bool AndroidPenisFertility(Pawn pawn) { //androids only fertile with archotech parts BodyPartRecord Part = Genital_Helper.get_genitalsBPR(pawn); return (pawn.health.hediffSet.hediffs.Any((Hediff hed) => (hed.Part == Part) && (hed.def == Genital_Helper.archotech_penis) )); } public static bool AndroidVaginaFertility(Pawn pawn) { //androids only fertile with archotech parts BodyPartRecord Part = Genital_Helper.get_genitalsBPR(pawn); return (pawn.health.hediffSet.hediffs.Any((Hediff hed) => (hed.Part == Part) && (hed.def == Genital_Helper.archotech_vagina) )); } } }
Tirem12/rjw
Source/Modules/Androids/AndroidsCompatibility.cs
C#
mit
1,934
using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; // Adds options to the right-click menu for bondage gear to equip the gear on prisoners/downed pawns namespace rjw { public class CompBondageGear : CompUsable { public override IEnumerable<FloatMenuOption> CompFloatMenuOptions(Pawn pawn) { if ((pawn.Map != null) && (pawn.Map == Find.CurrentMap))// && (pawn.Map.mapPawns.PrisonersOfColonyCount > 0) { if (!pawn.CanReserve(parent)) yield return new FloatMenuOption(FloatMenuOptionLabel(pawn) + " on (" + "Reserved".Translate() + ")", null, MenuOptionPriority.DisabledOption); else if (pawn.CanReach(parent, PathEndMode.Touch, Danger.Some)) foreach (Pawn other in pawn.Map.mapPawns.AllPawns) if ((other != pawn) && other.Spawned && (other.Downed || other.IsPrisonerOfColony || xxx.is_slave(other))) yield return this.make_option(FloatMenuOptionLabel(pawn) + " on " + xxx.get_pawnname(other), pawn, other, (other.IsPrisonerOfColony || xxx.is_slave(other)) ? WorkTypeDefOf.Warden : null); } } } }
Tirem12/rjw
Source/Modules/Bondage/Comps/CompBondageGear.cs
C#
mit
1,074
using System; using RimWorld; using Verse; using Multiplayer.API; namespace rjw { public class CompCryptoStamped : ThingComp { public string name; public string key; [SyncMethod] public string random_hex_byte() { //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); var rv = Rand.RangeInclusive(0x00, 0xFF); var padding = (rv < 0x10) ? "0" : ""; return padding + rv.ToString("X"); } public override void Initialize(CompProperties pro) { name = NameGenerator.GenerateName(RulePackDef.Named("EngravedName")); key = ""; for (int i = 0; i < 16; ++i) key += random_hex_byte(); } public override void PostExposeData() { base.PostExposeData(); Scribe_Values.Look<string>(ref name, "engraved_name"); Scribe_Values.Look<string>(ref key, "cryptostamp"); } public override bool AllowStackWith(Thing t) { return false; } public override string CompInspectStringExtra() { var inspect_engraving = "Engraved with the name \"" + name + "\""; var inspect_key = "Cryptostamp: " + key; return base.CompInspectStringExtra() + inspect_engraving + "\n" + inspect_key; } public override string TransformLabel(string lab) { return lab + " \"" + name + "\""; } public bool matches(CompHoloCryptoStamped other) { return String.Equals(key, other.key); } public void copy_stamp_from(CompHoloCryptoStamped other) { name = other.name; key = other.key; } } public class CompProperties_CryptoStamped : CompProperties { public CompProperties_CryptoStamped() { compClass = typeof(CompHoloCryptoStamped); } } }
Tirem12/rjw
Source/Modules/Bondage/Comps/CompCryptoStamped.cs
C#
mit
1,637
using RimWorld; using Verse; namespace rjw { public class CompGetBondageGear : CompUseEffect { public override float OrderPriority { get { return -79; } } public override void DoEffect(Pawn p) { base.DoEffect(p); var app = parent as Apparel; if ((p.apparel != null) && (app != null)) p.apparel.Wear(app); } } }
Tirem12/rjw
Source/Modules/Bondage/Comps/CompGetBondageGear.cs
C#
mit
356
using System; using RimWorld; using Verse; using Multiplayer.API; namespace rjw { public class CompHoloCryptoStamped : ThingComp { public string name; public string key; [SyncMethod] public string random_hex_byte() { //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); var rv = Rand.RangeInclusive(0x00, 0xFF); var padding = (rv < 0x10) ? "0" : ""; return padding + rv.ToString("X"); } public override void Initialize(CompProperties pro) { name = NameGenerator.GenerateName(RulePackDef.Named("EngravedName")); key = ""; for (int i = 0; i < 16; ++i) key += random_hex_byte(); } public override void PostExposeData() { base.PostExposeData(); Scribe_Values.Look<string>(ref name, "engraved_name"); Scribe_Values.Look<string>(ref key, "cryptostamp"); } public override bool AllowStackWith(Thing t) { return false; } public override string CompInspectStringExtra() { var inspect_engraving = "Engraved with the name \"" + name + "\""; var inspect_key = "Cryptostamp: " + key; return base.CompInspectStringExtra() + inspect_engraving + "\n" + inspect_key; } public override string TransformLabel(string lab) { return lab + " \"" + name + "\""; } public bool matches(CompHoloCryptoStamped other) { return String.Equals(key, other.key); } public void copy_stamp_from(CompHoloCryptoStamped other) { name = other.name; key = other.key; } } public class CompProperties_HoloCryptoStamped : CompProperties { public CompProperties_HoloCryptoStamped() { compClass = typeof(CompHoloCryptoStamped); } } }
Tirem12/rjw
Source/Modules/Bondage/Comps/CompHoloCryptoStamped.cs
C#
mit
1,649
using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; // Adds unlock options to right-click menu for holokeys. namespace rjw { public class CompStampedApparelKey : CompUsable { protected string make_label(Pawn pawn, Pawn other) { return FloatMenuOptionLabel(pawn) + " on " + ((other == null) ? "self" : xxx.get_pawnname(other)); } public override IEnumerable<FloatMenuOption> CompFloatMenuOptions(Pawn pawn) { if (!pawn.CanReserve(parent)) yield return new FloatMenuOption(FloatMenuOptionLabel(pawn) + " (" + "Reserved".Translate() + ")", null, MenuOptionPriority.DisabledOption); else if (pawn.CanReach(parent, PathEndMode.Touch, Danger.Some)) { // Option for the pawn to use the key on themself if (!pawn.is_wearing_locked_apparel()) yield return new FloatMenuOption("Not wearing locked apparel", null, MenuOptionPriority.DisabledOption); else yield return this.make_option(make_label(pawn, null), pawn, null, null); if ((pawn.Map != null) && (pawn.Map == Find.CurrentMap)) { // Options for use on colonists foreach (var other in pawn.Map.mapPawns.FreeColonists) if ((other != pawn) && other.is_wearing_locked_apparel()) yield return this.make_option(make_label(pawn, other), pawn, other, null); // Options for use on prisoners foreach (var prisoner in pawn.Map.mapPawns.PrisonersOfColony) if (prisoner.is_wearing_locked_apparel()) yield return this.make_option(make_label(pawn, prisoner), pawn, prisoner, WorkTypeDefOf.Warden); // Options for use on corpses foreach (var q in pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Corpse)) { var corpse = q as Corpse; if (corpse.InnerPawn.is_wearing_locked_apparel()) yield return this.make_option(make_label(pawn, corpse.InnerPawn), pawn, corpse, null); } } } } } }
Tirem12/rjw
Source/Modules/Bondage/Comps/CompStampedApparelKey.cs
C#
mit
1,904
using RimWorld; using Verse; namespace rjw { public class CompUnlockBondageGear : CompUseEffect { public override float OrderPriority { get { return -69; } } public override void DoEffect(Pawn p) { base.DoEffect(p); var key_stamp = parent.GetComp<CompHoloCryptoStamped>(); if ((key_stamp == null) || (p.MapHeld == null) || (p.apparel == null)) return; Apparel locked_app = null; var any_locked = false; { foreach (var app in p.apparel.WornApparel) { var app_stamp = app.GetComp<CompHoloCryptoStamped>(); if (app_stamp != null) { any_locked = true; if (app_stamp.matches(key_stamp)) { locked_app = app; break; } } } } if (locked_app != null) { //locked_app.Notify_Stripped (p); // TODO This was removed. Necessary? p.apparel.Remove(locked_app); Thing dropped = null; GenThing.TryDropAndSetForbidden(locked_app, p.Position, p.MapHeld, ThingPlaceMode.Near, out dropped, false); //this will create a new key somehow. if (dropped != null) { Messages.Message("Unlocked " + locked_app.def.label, p, MessageTypeDefOf.SilentInput); IntVec3 keyPostition = parent.Position; parent.Destroy(); } else if (PawnUtility.ShouldSendNotificationAbout(p)) { Messages.Message("Couldn't drop " + locked_app.def.label, p, MessageTypeDefOf.NegativeEvent); } } else if (any_locked) Messages.Message("The key doesn't fit!", p, MessageTypeDefOf.NegativeEvent); } } }
Tirem12/rjw
Source/Modules/Bondage/Comps/CompUnlockBondageGear.cs
C#
mit
1,547
using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; namespace rjw { public class JobDriver_StruggleInBondageGear : JobDriver { public Apparel target_gear { get { return (Apparel)TargetA.Thing; } } public override bool TryMakePreToilReservations(bool errorOnFailed) { return this.pawn.Reserve(this.target_gear, this.job, 1, -1, null, errorOnFailed); } protected override IEnumerable<Toil> MakeNewToils() { yield return new Toil { initAction = delegate { pawn.pather.StopDead(); }, defaultCompleteMode = ToilCompleteMode.Delay, defaultDuration = 60 }; yield return new Toil { initAction = delegate { if (PawnUtility.ShouldSendNotificationAbout(pawn)) { var pro = (pawn.gender == Gender.Male) ? "his" : "her"; Messages.Message(xxx.get_pawnname(pawn) + " struggles to remove " + pro + " " + target_gear.def.label + ". It's no use!", pawn, MessageTypeDefOf.NegativeEvent); } }, defaultCompleteMode = ToilCompleteMode.Instant }; } } }
Tirem12/rjw
Source/Modules/Bondage/JobDrivers/JobDriver_StruggleInBondageGear.cs
C#
mit
1,085
using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI; namespace rjw { public class JobDriver_UseItemOn : JobDriver_UseItem { public static Toil pickup_item(Pawn p, Thing item) { return new Toil { initAction = delegate { p.carryTracker.TryStartCarry(item, 1); if (item.Spawned) // If the item is still spawned that means the pawn failed to pick it up p.jobs.curDriver.EndJobWith(JobCondition.Incompletable); }, defaultCompleteMode = ToilCompleteMode.Instant }; } protected TargetIndex iitem = TargetIndex.A; protected TargetIndex itar = TargetIndex.B; protected Thing item { get { return base.job.GetTarget(iitem).Thing; } } protected Thing tar { get { return base.job.GetTarget(itar).Thing; } } protected override IEnumerable<Toil> MakeNewToils() { if (tar == null) foreach (var toil in base.MakeNewToils()) yield return toil; else { // Find the pawn to use the item on. Pawn other; { var corpse = tar as Corpse; other = (corpse == null) ? (Pawn)tar : corpse.InnerPawn; } this.FailOnDespawnedNullOrForbidden(itar); if (!other.Dead) this.FailOnAggroMentalState(itar); yield return Toils_Reserve.Reserve(itar); if ((pawn.inventory != null) && pawn.inventory.Contains(item)) { yield return Toils_Misc.TakeItemFromInventoryToCarrier(pawn, iitem); } else { yield return Toils_Reserve.Reserve(iitem); yield return Toils_Goto.GotoThing(iitem, PathEndMode.ClosestTouch).FailOnForbidden(iitem); yield return pickup_item(pawn, item); } yield return Toils_Goto.GotoThing(itar, PathEndMode.Touch); yield return new Toil { initAction = delegate { if (!other.Dead) PawnUtility.ForceWait(other, 60); }, defaultCompleteMode = ToilCompleteMode.Delay, defaultDuration = 60 }; yield return new Toil { initAction = delegate { var effective_item = item; // Drop the item if it's some kind of apparel. This is because ApparelTracker.Wear only works properly // if the apparel to wear is spawned. (I'm just assuming that DoEffect for apparel wears it, which is // true for bondage gear) if ((effective_item as Apparel) != null) { Thing dropped_thing; if (pawn.carryTracker.TryDropCarriedThing(pawn.Position, ThingPlaceMode.Near, out dropped_thing)) effective_item = dropped_thing as Apparel; else { Log.Error("Unable to drop " + effective_item.Label + " for use on " + xxx.get_pawnname(other) + " (apparel must be dropped before use)"); effective_item = null; } } if (effective_item != null) { var eff = effective_item.TryGetComp<CompUseEffect>(); if (eff != null) eff.DoEffect(other); else Log.Error("Unable to get CompUseEffect for use of " + effective_item.Label + " on " + xxx.get_pawnname(other) + " by " + xxx.get_pawnname(pawn)); } }, defaultCompleteMode = ToilCompleteMode.Instant }; } } } }
Tirem12/rjw
Source/Modules/Bondage/JobDrivers/JobDriver_UseItemOn.cs
C#
mit
3,165
using System.Collections.Generic; using RimWorld; using Verse; namespace rjw { public class Recipe_InstallChastityBelt : Recipe_InstallImplant { public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn p, RecipeDef r) { return base.GetPartsToApplyOn(p, r); } } public class Recipe_UnlockChastityBelt : Recipe_InstallImplant { public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn p, RecipeDef r) { return base.GetPartsToApplyOn(p, r); } } }
Tirem12/rjw
Source/Modules/Bondage/Recipes/Recipe_ChastityBelt.cs
C#
mit
492
using System.Collections.Generic; using RimWorld; using Verse; using Multiplayer.API; namespace rjw { public class Recipe_ForceOffGear : Recipe_Surgery { public static bool is_wearing(Pawn p, ThingDef apparel_def) { if (p.apparel != null) foreach (var app in p.apparel.WornApparel) if (app.def == apparel_def) return true; return false; } public static BodyPartRecord find_part_record(BodyPartDef part_def, Pawn p) { return p.RaceProps.body.AllParts.Find((BodyPartRecord bpr) => bpr.def == part_def); } // Puts the recipe in the operations list only if "p" is wearing the relevant apparel. The little trick here is that yielding // null causes the game to put the recipe in the list but not actually apply it to a body part. public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn p, RecipeDef generic_def) { var r = (force_off_gear_def)generic_def; if (is_wearing(p, r.removes_apparel)) yield return null; } [SyncMethod] public static void apply_burns(Pawn p, List<BodyPartDef> parts, float min_severity, float max_severity) { foreach (var part in parts) { var rec = find_part_record(part, p); if (rec != null) { //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); var to_deal = Rand.Range(min_severity, max_severity) * part.GetMaxHealth(p); var dealt = 0.0f; var counter = 0; while ((counter < 100) && (dealt < to_deal) && (!p.health.hediffSet.PartIsMissing(rec))) { var dam = Rand.RangeInclusive(3, 5); p.TakeDamage(new DamageInfo(DamageDefOf.Burn, dam, 999, -1.0f, null, rec, null)); ++counter; dealt += (float)dam; } } } } [SyncMethod] public override void ApplyOnPawn(Pawn p, BodyPartRecord null_part, Pawn surgeon, List<Thing> ingredients,Bill bill) { var r = (force_off_gear_def)recipe; if ((surgeon != null) && (p.apparel != null) && (!CheckSurgeryFail(surgeon, p, ingredients, find_part_record(r.failure_affects, p),bill))) { // Remove apparel foreach (var app in p.apparel.WornApparel) if (app.def == r.removes_apparel) { p.apparel.Remove(app); break; } // Destroy parts //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); var def_to_destroy = r.destroys_one_of.RandomElement<BodyPartDef>(); if (def_to_destroy != null) { var record_to_destroy = find_part_record(def_to_destroy, p); if (record_to_destroy != null) { var dam = (int)(1.5f * def_to_destroy.GetMaxHealth(p)); p.TakeDamage(new DamageInfo(DamageDefOf.Burn, dam, 999, -1.0f, null, record_to_destroy, null)); } } if (r.major_burns_on != null) apply_burns(p, r.major_burns_on, 0.30f, 0.60f); if (r.minor_burns_on != null) apply_burns(p, r.minor_burns_on, 0.15f, 0.35f); } } } }
Tirem12/rjw
Source/Modules/Bondage/Recipes/Recipe_ForceOffGear.cs
C#
mit
2,904
using RimWorld; using Verse; namespace rjw { public class ThoughtWorker_Bound : ThoughtWorker { protected override ThoughtState CurrentStateInternal(Pawn p) { if (p.apparel != null) { bool bound = false, gagged = false; foreach (var app in p.apparel.WornApparel) { var gear_def = app.def as bondage_gear_def; if (gear_def != null) { bound |= gear_def.gives_bound_moodlet; gagged |= gear_def.gives_gagged_moodlet; } } if (bound && gagged) return ThoughtState.ActiveAtStage(2); else if (gagged) return ThoughtState.ActiveAtStage(1); else if (bound) return ThoughtState.ActiveAtStage(0); } return ThoughtState.Inactive; } } }
Tirem12/rjw
Source/Modules/Bondage/Thoughts/ThoughtWorker_Bound.cs
C#
mit
723
using System; using System.Collections.Generic; using System.Linq; using RimWorld; using Verse; using Verse.AI; namespace rjw { public static class bondage_gear_tradeability { public static void init() { // Allows bondage gear to be selled by traders if (xxx.config.bondage_gear_enabled) { foreach (var def in DefDatabase<bondage_gear_def>.AllDefs) def.tradeability = Tradeability.Sellable; } // Forbids bondage gear to be selled by traders else { foreach (var def in DefDatabase<bondage_gear_def>.AllDefs) def.tradeability = Tradeability.None; } } } public static class bondage_gear_extensions { public static bool has_lock(this Apparel app) { return (app.TryGetComp<CompHoloCryptoStamped>() != null); } public static bool is_wearing_locked_apparel(this Pawn p) { if (p.apparel != null) foreach (var app in p.apparel.WornApparel) if (app.has_lock()) return true; return false; } // Tries to get p started on the job of using an item on either another pawn or on themself (if "other" is null). // Of course in order for this method to work, the item's useJob has to be able to handle use on another pawn. This // is true for the holokey and bondage gear in RJW but not the items in the core game public static void start_job(this CompUsable usa, Pawn p, LocalTargetInfo tar) { if (p.CanReserveAndReach(usa.parent, PathEndMode.Touch, Danger.Some) && ((tar == null) || p.CanReserveAndReach(tar, PathEndMode.Touch, Danger.Some))) { var comfor = usa.parent.GetComp<CompForbiddable>(); if (comfor != null) comfor.Forbidden = false; var job = JobMaker.MakeJob(((CompProperties_Usable)usa.props).useJob, usa.parent, tar); p.jobs.TryTakeOrderedJob(job); } } // Creates a menu option to use an item. "tar" is expected to be a pawn, corpse or null if it doesn't apply (in which // case the pawn will presumably use the item on themself). "required_work" can also be null. public static FloatMenuOption make_option(this CompUsable usa, string label, Pawn p, LocalTargetInfo tar, WorkTypeDef required_work) { if ((tar != null) && (!p.CanReserve(tar))) { string key = "Reserved"; string text = TranslatorFormattedStringExtensions.Translate(key); return new FloatMenuOption(label + " (" + text + ")", null, MenuOptionPriority.DisabledOption); } else if ((tar != null) && (!p.CanReach(tar, PathEndMode.Touch, Danger.Some))) { string key = "NoPath"; string text = TranslatorFormattedStringExtensions.Translate(key); return new FloatMenuOption(label + " (" + text + ")", null, MenuOptionPriority.DisabledOption); } else if ((required_work != null) && p.WorkTagIsDisabled(required_work.workTags)) { string key = "CannotPrioritizeWorkTypeDisabled"; string text = TranslatorFormattedStringExtensions.Translate(key, required_work.gerundLabel); return new FloatMenuOption(label + " (" + text + ")", null, MenuOptionPriority.DisabledOption); } else return new FloatMenuOption( label, delegate { usa.start_job(p, tar); }, MenuOptionPriority.Default); } } public class bondage_gear_def : ThingDef { public Type soul_type; public HediffDef equipped_hediff = null; public bool gives_bound_moodlet = false; public bool gives_gagged_moodlet = false; public bool blocks_hands = false; public bool blocks_oral = false; public bool blocks_penis = false; public bool blocks_vagina = false; public bool blocks_anus = false; public bool blocks_breasts = false; private bondage_gear_soul soul_ins = null; public List<BodyPartDef> HediffTargetBodyPartDefs; //field for optional list of targeted parts for hediff applying public List<BodyPartGroupDef> BoundBodyPartGroupDefs; //field for optional list of groups restrained of verbcasting public bondage_gear_soul soul { get { if (soul_ins == null) soul_ins = (bondage_gear_soul)Activator.CreateInstance(soul_type); return soul_ins; } } } public class bondage_gear_soul { // Adds the bondage gear's associated HediffDef and spawns a matching holokey public virtual void on_wear(Pawn wearer, Apparel gear) { var def = (bondage_gear_def)gear.def; if (def.equipped_hediff != null && def.HediffTargetBodyPartDefs != null) { foreach (BodyPartDef partDef in def.HediffTargetBodyPartDefs) //getting BodyPartDef, for example "Arm" { foreach (BodyPartRecord partRec in wearer.RaceProps.body.GetPartsWithDef(partDef)) //applying hediff to every single arm found on pawn { wearer.health.AddHediff(def.equipped_hediff, partRec); } } } else if (def.equipped_hediff != null && def.HediffTargetBodyPartDefs == null) //backward compatibility/simplified gear define without HediffTargetBodyPartDefs { //Hediff applyed to whole body wearer.health.AddHediff(def.equipped_hediff); } var gear_stamp = gear.TryGetComp<CompHoloCryptoStamped>(); if (gear_stamp != null) { var key = ThingMaker.MakeThing(ThingDef.Named("Holokey")); var key_stamp = key.TryGetComp<CompHoloCryptoStamped>(); key_stamp.copy_stamp_from(gear_stamp); if (wearer.Map != null) GenSpawn.Spawn(key, wearer.Position, wearer.Map); else wearer.inventory.TryAddItemNotForSale(key); } } // Removes the gear's HediffDef public virtual void on_remove(Apparel gear, Pawn former_wearer) { var def = (bondage_gear_def)gear.def; if (def.equipped_hediff != null && def.HediffTargetBodyPartDefs != null) { //getting all Hediffs according with equipped_hediff def List<Hediff> hediffs = former_wearer.health.hediffSet.hediffs.Where(x => x.def == def.equipped_hediff).ToList(); foreach (Hediff hedToRemove in hediffs) { if (def.HediffTargetBodyPartDefs.Contains(hedToRemove.Part.def)) //removing if applyed by this bondage_gear former_wearer.health.RemoveHediff(hedToRemove); //assuming there can be several different bondages } //with the same equipped_hediff def } else if (def.equipped_hediff != null && def.HediffTargetBodyPartDefs == null) //backward compatibility/simplified gear define without HediffTargetBodyPartDefs { var hed = former_wearer.health.hediffSet.GetFirstHediffOfDef(def.equipped_hediff); if (hed != null) former_wearer.health.RemoveHediff(hed); } } } // Give bondage gear an extremely low score when it's not being worn so pawns never equip it on themselves and give // it an extremely high score when it is being worn so pawns never try to take it off to equip something "better". public class bondage_gear : Apparel { public override float GetSpecialApparelScoreOffset() { return (Wearer == null) ? -1e5f : 1e5f; } // made this method universal for any bondage_gear, won't affect anything if gear's BoundBodyPartGroupDefs is empty or null public override bool AllowVerbCast(IntVec3 root, Map map, LocalTargetInfo targ, Verb verb) { if ((this.def as bondage_gear_def).BoundBodyPartGroupDefs != null && verb.tool != null && (this.def as bondage_gear_def).BoundBodyPartGroupDefs.Contains(verb.tool.linkedBodyPartsGroup)) { return false; } return true; } //needed for save compatibility only public override void ExposeData() { base.ExposeData(); //if (Scribe.mode == LoadSaveMode.PostLoadInit) // CheckHediffs(); } //save compatibility insurance, will prevent Armbinder hediff with 0part efficiency on whole body private void CheckHediffs() { var def = (bondage_gear_def)this.def; if (this.Wearer == null || def.equipped_hediff == null) return; bool changedHediff = false; void ApplyHediffDirect(HediffDef hedDef, BodyPartRecord partRec) { Hediff hediff = (Hediff)HediffMaker.MakeHediff(hedDef, Wearer); if (partRec != null) hediff.Part = partRec; Wearer.health.hediffSet.AddDirect(hediff); changedHediff = true; } void RemoveHediffDirect(Hediff hed) { Wearer.health.hediffSet.hediffs.Remove(hed); changedHediff = true; } List<bondage_gear> wornBondageGear = Wearer.apparel.WornApparel.Where(x => x is bondage_gear).Cast<bondage_gear>().ToList(); List<Hediff> hediffs = new List<Hediff>(); foreach (Hediff h in this.Wearer.health.hediffSet.hediffs) hediffs.Add(h); //checking current hediffs defined by bondage_gear for being on defined place, cleaning up the misplaced bool equippedHediff; bool onPlace; foreach (Hediff hed in hediffs) { equippedHediff = false; onPlace = false; foreach (bondage_gear gear in wornBondageGear) { if (hed.def == (gear.def as bondage_gear_def).equipped_hediff) { //if hediff from bondage_gear and on it's defined place then don't touch it else remove //assuming there can be several different bondages with the same equipped_hediff def and different hediff target parts, don't know why equippedHediff = true; if ((hed.Part != null && (gear.def as bondage_gear_def).HediffTargetBodyPartDefs == null)) { //pass } else if ((hed.Part == null && (gear.def as bondage_gear_def).HediffTargetBodyPartDefs == null)) { onPlace = true; break; } else if (hed.Part != null && (gear.def as bondage_gear_def).HediffTargetBodyPartDefs.Contains(hed.Part.def)) { onPlace = true; break; } } } if (equippedHediff && !onPlace) { Log.Message("Removing Hediff " + hed.Label + " from " + Wearer + (hed.Part == null ? "'s body" : "'s " + hed.Part)); RemoveHediffDirect(hed); } } // now iterating every gear for having all hediffs in place, adding missing foreach (bondage_gear gear in wornBondageGear) { if ((gear.def as bondage_gear_def).equipped_hediff == null) continue; if ((gear.def as bondage_gear_def).HediffTargetBodyPartDefs == null) //handling gear without HediffTargetBodyPartDefs { Hediff hed = Wearer.health.hediffSet.hediffs.Find(x => (x.def == (gear.def as bondage_gear_def).equipped_hediff && x.Part == null));//checking hediff defined by gear on whole body if (hed == null) //if no legit hediff, adding { Log.Message("Adding missing Hediff " + (gear.def as bondage_gear_def).equipped_hediff.label + " to " + Wearer + "'s body"); ApplyHediffDirect((gear.def as bondage_gear_def).equipped_hediff, null); } } else //handling gear with defined HediffTargetBodyPartDefs { foreach (BodyPartDef partDef in (gear.def as bondage_gear_def).HediffTargetBodyPartDefs) //getting every partDef { foreach (BodyPartRecord partRec in Wearer.RaceProps.body.GetPartsWithDef(partDef)) //checking all parts of def for applyed hediff { Hediff hed = Wearer.health.hediffSet.hediffs.Find(x => (x.def == (gear.def as bondage_gear_def).equipped_hediff && x.Part == partRec));//checking hediff defined by gear on defined place if (hed == null) //if hediff missing, adding { Log.Message("Adding missing Hediff " + (gear.def as bondage_gear_def).equipped_hediff.label + " to " + Wearer + "'s " + partRec.Label); ApplyHediffDirect((gear.def as bondage_gear_def).equipped_hediff, partRec); } } } } //possibility of several different items with THE SAME equipped_hediff def ON THE SAME PART is not considered, that's sick } if (changedHediff) { //Possible error in current toil on Notify_HediffChanged() if capacity.Manipulation is involved so making it in the end. //Probably harmless, shouldn't happen again after corrected hediffs will be saved Wearer.health.Notify_HediffChanged(null); } } } public class armbinder : bondage_gear { // Prevents pawns in armbinders from melee attacking //public override bool AllowVerbCast (IntVec3 root, TargetInfo targ) //{ // return false; //} } public class yoke : bondage_gear { // Prevents pawns in armbinders from melee attacking //public override bool AllowVerbCast (IntVec3 root, TargetInfo targ) //{ // return false; //} } public class Restraints : bondage_gear { // Prevents pawns in armbinders from melee attacking //public override bool AllowVerbCast (IntVec3 root, TargetInfo targ) //{ // return false; //} } public class force_off_gear_def : RecipeDef { public ThingDef removes_apparel; public BodyPartDef failure_affects; public List<BodyPartDef> destroys_one_of = null; public List<BodyPartDef> major_burns_on = null; public List<BodyPartDef> minor_burns_on = null; } }
Tirem12/rjw
Source/Modules/Bondage/bondage_gear.cs
C#
mit
13,237
using RimWorld; using Verse; namespace rjw { public class CompMilkableHuman : CompHasGatherableBodyResource { protected override int GatherResourcesIntervalDays => Props.milkIntervalDays; protected override int ResourceAmount => Props.milkAmount; protected override ThingDef ResourceDef => Props.milkDef; protected override string SaveKey => "milkFullness"; public CompProperties_MilkableHuman Props => (CompProperties_MilkableHuman)props; protected override bool Active { get { if (!Active) { return false; } Pawn pawn = parent as Pawn; if (pawn != null) { //idk should probably remove non rjw stuff //should merge Lactating into .cs hediff? //vanilla //C&P? //rjw human //rjw animal if ((!pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_lactating"), false)) && ((pawn.health.hediffSet.HasHediff(HediffDef.Named("Pregnant"), false) && pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("Pregnant"), false).Visible) //|| (pawn.health.hediffSet.HasHediff(HediffDef.Named("HumanPregnancy"), false) && pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("HumanPregnancy"), false).Visible) || (pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_pregnancy"), false) && pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy"), false).Visible) || (pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_pregnancy_beast"), false) && pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy_beast"), false).Visible))) { pawn.health.AddHediff(HediffDef.Named("RJW_lactating"), null, null, null); } if ((!Props.milkFemaleOnly || pawn.gender == Gender.Female) && (pawn.ageTracker.CurLifeStage.reproductive) && (pawn.RaceProps.Humanlike) && (pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_lactating"), false) //|| pawn.health.hediffSet.HasHediff(HediffDef.Named("Lactating_Permanent"), false) //|| pawn.health.hediffSet.HasHediff(HediffDef.Named("Lactating_Natural"), false) //|| pawn.health.hediffSet.HasHediff(HediffDef.Named("Lactating_Drug"), false) )) { return true; } } return false; } } public override string CompInspectStringExtra() { if (!Active) { return null; } return Translator.Translate("MilkFullness") + ": " + GenText.ToStringPercent(this.Fullness); } } }
Tirem12/rjw
Source/Modules/Milking/Comps/CompMilkableHuman.cs
C#
mit
2,444
using Verse; namespace rjw { public class CompProperties_MilkableHuman : CompProperties { public int milkIntervalDays; public int milkAmount = 8; public ThingDef milkDef; public bool milkFemaleOnly = true; public CompProperties_MilkableHuman() { compClass = typeof(CompMilkableHuman); } } }
Tirem12/rjw
Source/Modules/Milking/Comps/CompProperties_MilkableHuman.cs
C#
mit
316
using RimWorld; using Verse; namespace rjw { [DefOf] public static class JobDefOfZ { public static JobDef MilkHuman; static JobDefOfZ() { DefOfHelper.EnsureInitializedInCtor(typeof(JobDefOf)); } } }
Tirem12/rjw
Source/Modules/Milking/JobDrivers/JobDefOfZ.cs
C#
mit
216
using RimWorld; using System; using System.Collections.Generic; using Verse; using Verse.AI; namespace rjw { public abstract class JobDriver_GatherHumanBodyResources : JobDriver_GatherAnimalBodyResources { private float gatherProgress; /* //maybe change? protected abstract int GatherResourcesIntervalDays { get; } //add breastsize modifier? protected abstract int ResourceAmount { get; } //add more milks? protected abstract ThingDef ResourceDef { get; } */ protected override IEnumerable<Toil> MakeNewToils() { ToilFailConditions.FailOnDespawnedNullOrForbidden<JobDriver_GatherHumanBodyResources>(this, TargetIndex.A); ToilFailConditions.FailOnNotCasualInterruptible<JobDriver_GatherHumanBodyResources>(this, TargetIndex.A); yield return Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch); Toil wait = new Toil(); wait.initAction = delegate { Pawn milker = base.pawn; LocalTargetInfo target = base.job.GetTarget(TargetIndex.A); Pawn target2 = (Pawn)target.Thing; milker.pather.StopDead(); PawnUtility.ForceWait(target2, 15000, null, true); }; wait.tickAction = delegate { Pawn milker = base.pawn; milker.skills.Learn(SkillDefOf.Animals, 0.13f, false); gatherProgress += StatExtension.GetStatValue(milker, StatDefOf.AnimalGatherSpeed, true); if (gatherProgress >= WorkTotal) { GetComp((Pawn)base.job.GetTarget(TargetIndex.A)).Gathered(base.pawn); milker.jobs.EndCurrentJob(JobCondition.Succeeded, true); } }; wait.AddFinishAction((Action)delegate { Pawn milker = base.pawn; LocalTargetInfo target = base.job.GetTarget(TargetIndex.A); Pawn target2 = (Pawn)target.Thing; if (target2 != null && target2.CurJobDef == JobDefOf.Wait_MaintainPosture) { milker.jobs.EndCurrentJob(JobCondition.InterruptForced, true); } }); ToilFailConditions.FailOnDespawnedOrNull<Toil>(wait, TargetIndex.A); ToilFailConditions.FailOnCannotTouch<Toil>(wait, TargetIndex.A, PathEndMode.Touch); wait.AddEndCondition((Func<JobCondition>)delegate { if (GetComp((Pawn)base.job.GetTarget(TargetIndex.A)).ActiveAndFull) { return JobCondition.Ongoing; } return JobCondition.Incompletable; }); wait.defaultCompleteMode = ToilCompleteMode.Never; ToilEffects.WithProgressBar(wait, TargetIndex.A, (Func<float>)(() => gatherProgress / WorkTotal), false, -0.5f); wait.activeSkill = (() => SkillDefOf.Animals); yield return wait; } } }
Tirem12/rjw
Source/Modules/Milking/JobDrivers/JobDriver_GatherHumanBodyResources.cs
C#
mit
2,524
using RimWorld; using Verse; namespace rjw { public class JobDriver_MilkHuman : JobDriver_GatherHumanBodyResources { protected override float WorkTotal => 400f; protected override CompHasGatherableBodyResource GetComp(Pawn animal) { return ThingCompUtility.TryGetComp<CompMilkableHuman>(animal); } } }
Tirem12/rjw
Source/Modules/Milking/JobDrivers/JobDriver_MilkHuman.cs
C#
mit
318
using RimWorld; using System.Collections.Generic; using Verse; using Verse.AI; namespace rjw { public abstract class WorkGiver_GatherHumanBodyResources : WorkGiver_GatherAnimalBodyResources { public override IEnumerable<Thing> PotentialWorkThingsGlobal(Pawn pawn) { //List<Pawn> pawns = pawn.Map.mapPawns.SpawnedPawnsInFaction(pawn.Faction); //int i = 0; //if (i < pawns.Count) //{ // yield return (Thing)pawns[i]; /*Error: Unable to find new state assignment for yield return*/ // ; //} foreach (Pawn targetpawn in pawn.Map.mapPawns.FreeColonistsAndPrisonersSpawned) { yield return targetpawn; } } public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { Pawn pawn2 = t as Pawn; if (pawn2 == null || !pawn2.RaceProps.Humanlike) { return false; } CompHasGatherableBodyResource comp = GetComp(pawn2); if (comp != null && comp.ActiveAndFull && PawnUtility.CanCasuallyInteractNow(pawn2, false) && pawn2 != pawn) { LocalTargetInfo target = pawn2; bool ignoreOtherReservations = forced; if (ReservationUtility.CanReserve(pawn, target, 1, -1, null, ignoreOtherReservations)) { return true; } } return false; } } }
Tirem12/rjw
Source/Modules/Milking/WorkGivers/WorkGiver_GatherHumanBodyResources.cs
C#
mit
1,240
using RimWorld; using Verse; namespace rjw { public class WorkGiver_MilkHuman : WorkGiver_GatherHumanBodyResources { protected override JobDef JobDef => JobDefOfZ.MilkHuman; protected override CompHasGatherableBodyResource GetComp(Pawn animal) { return ThingCompUtility.TryGetComp<CompMilkableHuman>(animal); } } }
Tirem12/rjw
Source/Modules/Milking/WorkGivers/WorkGiver_MilkHuman.cs
C#
mit
331
using Verse; using RimWorld; using Multiplayer.API; namespace rjw { [StaticConstructorOnStartup] public static class RJW_Multiplayer { static RJW_Multiplayer() { if (!MP.enabled) return; // This is where the magic happens and your attributes // auto register, similar to Harmony's PatchAll. MP.RegisterAll(); /* Log.Message("RJW MP compat testing"); var type = AccessTools.TypeByName("rjw.RJWdesignations"); //Log.Message("rjw MP compat " + type.Name); Log.Message("is host " + MP.IsHosting); Log.Message("PlayerName " + MP.PlayerName); Log.Message("IsInMultiplayer " + MP.IsInMultiplayer); //MP.RegisterSyncMethod(type, "Comfort"); /* MP.RegisterSyncMethod(type, "<GetGizmos>Service"); MP.RegisterSyncMethod(type, "<GetGizmos>BreedingHuman"); MP.RegisterSyncMethod(type, "<GetGizmos>BreedingAnimal"); MP.RegisterSyncMethod(type, "<GetGizmos>Breeder"); MP.RegisterSyncMethod(type, "<GetGizmos>Milking"); MP.RegisterSyncMethod(type, "<GetGizmos>Hero"); */ // You can choose to not auto register and do it manually // with the MP.Register* methods. // Use MP.IsInMultiplayer to act upon it in other places // user can have it enabled and not be in session } //generate PredictableSeed for Verse.Rand public static int PredictableSeed() { int seed = 0; try { Map map = Find.CurrentMap; //int seedHourOfDay = GenLocalDate.HourOfDay(map); //int seedDayOfYear = GenLocalDate.DayOfYear(map); //int seedYear = GenLocalDate.Year(map); seed = (GenLocalDate.HourOfDay(map) + GenLocalDate.DayOfYear(map)) * GenLocalDate.Year(map); //int seed = (seedHourOfDay + seedDayOfYear) * seedYear; //Log.Warning("seedHourOfDay: " + seedHourOfDay + "\nseedDayOfYear: " + seedDayOfYear + "\nseedYear: " + seedYear + "\n" + seed); } catch { seed = Rand.Int; } return seed; } //generate PredictableSeed for Verse.Rand [SyncMethod] public static float RJW_MP_RAND() { return Rand.Value; } } }
Tirem12/rjw
Source/Modules/Multiplayer/Multiplayer.cs
C#
mit
2,049
using System.Linq; using RimWorld; using Verse; using Multiplayer.API; namespace rjw { public class IncidentWorker_NymphJoins : IncidentWorker { protected override bool CanFireNowSub(IncidentParms parms) { if (!RJWSettings.NymphTamed) return false; Map map = (Map)parms.target; float colonist_count = map.mapPawns.FreeColonistsCount; float nymph_count = map.mapPawns.FreeColonists.Count(xxx.is_nympho); float nymph_fraction = nymph_count / colonist_count; return colonist_count >= 1 && (nymph_fraction < xxx.config.max_nymph_fraction); } [SyncMethod] protected override bool TryExecuteWorker(IncidentParms parms) { //--Log.Message("IncidentWorker_NymphJoins::TryExecute() called"); if (!RJWSettings.NymphTamed) return false; if (MP.IsInMultiplayer) return false; Map map = (Map) parms.target; if (map == null) { //--Log.Message("IncidentWorker_NymphJoins::TryExecute() - map is null, abort!"); return false; } else { //--Log.Message("IncidentWorker_NymphJoins::TryExecute() - map is ok"); } //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); if (!RCellFinder.TryFindRandomPawnEntryCell(out IntVec3 loc, map, CellFinder.EdgeRoadChance_Friendly + 0.2f)) { //--Log.Message("IncidentWorker_NymphJoins::TryExecute() - no entry, abort!"); return false; } Pawn pawn = Nymph_Generator.GenerateNymph(loc, ref map); //generates with null faction, mod conflict ?! pawn.SetFaction(Faction.OfPlayer); GenSpawn.Spawn(pawn, loc, map); Find.LetterStack.ReceiveLetter("Nymph Joins", "A wandering nymph has decided to join your settlement.", LetterDefOf.PositiveEvent, pawn); return true; } } }
Tirem12/rjw
Source/Modules/Nymphs/Incidents/IncidentWorker_NymphJoins.cs
C#
mit
1,721
using System.Linq; using RimWorld; using Verse; using Multiplayer.API; namespace rjw { public class IncidentWorker_NymphVisitor : IncidentWorker { [SyncMethod] protected override bool TryExecuteWorker(IncidentParms parms) { //--Log.Message("IncidentWorker_NymphVisitor::TryExecute() called"); if (!RJWSettings.NymphWild) return false; if (MP.IsInMultiplayer) return false; Map map = (Map) parms.target; if (map == null) { //--Log.Message("IncidentWorker_NymphVisitor::TryExecute() - map is null, abort!"); return false; } else { //--Log.Message("IncidentWorker_NymphVisitor::TryExecute() - map is ok"); } //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); if (!RCellFinder.TryFindRandomPawnEntryCell(out IntVec3 loc, map, CellFinder.EdgeRoadChance_Friendly + 0.2f)) { //--Log.Message("IncidentWorker_NymphVisitor::TryExecute() - no entry, abort!"); return false; } Pawn pawn = Nymph_Generator.GenerateNymph(loc, ref map); //generates with null faction, mod conflict ?! GenSpawn.Spawn(pawn, loc, map); pawn.ChangeKind(PawnKindDefOf.WildMan); //if (pawn.Faction != null) // pawn.SetFaction(null); if (RJWSettings.NymphPermanentManhunter) pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent); else pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter); Find.LetterStack.ReceiveLetter("Nymph! ", "A wandering nymph has decided to visit your settlement.", LetterDefOf.ThreatSmall, pawn); return true; } } }
Tirem12/rjw
Source/Modules/Nymphs/Incidents/IncidentWorker_NymphVisitor.cs
C#
mit
1,608
using RimWorld; using Verse; using Multiplayer.API; namespace rjw { public class IncidentWorker_NymphVisitorGroupEasy : IncidentWorker_NeutralGroup { private static readonly SimpleCurve PointsCurve = new SimpleCurve { new CurvePoint(45f, 0f), new CurvePoint(50f, 1f), new CurvePoint(100f, 1f), new CurvePoint(200f, 0.25f), new CurvePoint(300f, 0.1f), new CurvePoint(500f, 0f) }; [SyncMethod] protected override void ResolveParmsPoints(IncidentParms parms) { if (!(parms.points >= 0f)) { parms.points = Rand.ByCurve(PointsCurve); } } [SyncMethod] protected override bool TryExecuteWorker(IncidentParms parms) { //--Log.Message("IncidentWorker_NymphVisitorGroup::TryExecute() called"); if (!RJWSettings.NymphRaidEasy) return false; if (MP.IsInMultiplayer) return false; Map map = (Map)parms.target; if (map == null) { //--Log.Message("IncidentWorker_NymphJoins::TryExecute() - map is null, abort!"); return false; } else { //--Log.Message("IncidentWorker_NymphJoins::TryExecute() - map is ok"); } //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); if (!RCellFinder.TryFindRandomPawnEntryCell(out IntVec3 loc, map, CellFinder.EdgeRoadChance_Friendly + 0.2f)) { //--Log.Message("IncidentWorker_NymphJoins::TryExecute() - no entry, abort!"); return false; } //var PlayerHomeMap = Find.Maps.Find(map => map.IsPlayerHome); var count = (Find.World.worldPawns.AllPawnsAlive.Count + map.mapPawns.FreeColonistsAndPrisonersSpawnedCount); //Log.Message("IncidentWorker_NymphJoins::TryExecute() -count:" + count + " map:" + PlayerHomeMap); for (int i = 1; i <= count || i <= 100; ++i) { Pawn pawn = Nymph_Generator.GenerateNymph(loc, ref map); //pawn.SetFaction(Faction.OfPlayer); GenSpawn.Spawn(pawn, loc, map); pawn.ChangeKind(PawnKindDefOf.WildMan); //if (pawn.Faction != null) // pawn.SetFaction(null); if (RJWSettings.NymphPermanentManhunter) pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent); else pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter); } Find.LetterStack.ReceiveLetter("Nymphs!!!", "A group of nymphs has wandered into your settlement.", LetterDefOf.ThreatBig, null); return true; } } }
Tirem12/rjw
Source/Modules/Nymphs/Incidents/IncidentWorker_NymphVisitorGroupE.cs
C#
mit
2,383
using RimWorld; using Verse; using Multiplayer.API; namespace rjw { public class IncidentWorker_NymphVisitorGroupHard : IncidentWorker_NeutralGroup { private static readonly SimpleCurve PointsCurve = new SimpleCurve { new CurvePoint(45f, 0f), new CurvePoint(50f, 1f), new CurvePoint(100f, 1f), new CurvePoint(200f, 0.25f), new CurvePoint(300f, 0.1f), new CurvePoint(500f, 0f) }; [SyncMethod] protected override void ResolveParmsPoints(IncidentParms parms) { if (!(parms.points >= 0f)) { parms.points = Rand.ByCurve(PointsCurve); } } [SyncMethod] protected override bool TryExecuteWorker(IncidentParms parms) { //--Log.Message("IncidentWorker_NymphVisitorGroup::TryExecute() called"); if (!RJWSettings.NymphRaidHard) return false; if (MP.IsInMultiplayer) return false; Map map = (Map)parms.target; if (map == null) { //--Log.Message("IncidentWorker_NymphJoins::TryExecute() - map is null, abort!"); return false; } else { //--Log.Message("IncidentWorker_NymphJoins::TryExecute() - map is ok"); } //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); if (!RCellFinder.TryFindRandomPawnEntryCell(out IntVec3 loc, map, CellFinder.EdgeRoadChance_Friendly + 0.2f)) { //--Log.Message("IncidentWorker_NymphJoins::TryExecute() - no entry, abort!"); return false; } var count = map.mapPawns.AllPawnsSpawnedCount; //Log.Message("IncidentWorker_NymphJoins::TryExecute() -count:" + count); for (int i = 1; i <= count || i <= 1000; ++i) { Pawn pawn = Nymph_Generator.GenerateNymph(loc, ref map); //pawn.SetFaction(Faction.OfPlayer); GenSpawn.Spawn(pawn, loc, map); pawn.ChangeKind(PawnKindDefOf.WildMan); //if (pawn.Faction != null) // pawn.SetFaction(null); if (RJWSettings.NymphPermanentManhunter) pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent); else pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter); } Find.LetterStack.ReceiveLetter("Nymphs!!!", "A huge group of nymphs has wandered into your settlement.", LetterDefOf.ThreatBig, null); return true; } } }
Tirem12/rjw
Source/Modules/Nymphs/Incidents/IncidentWorker_NymphVisitorGroupH.cs
C#
mit
2,233
using System; using RimWorld; using Verse; using Multiplayer.API; namespace rjw { public class IncidentWorker_TestInc : IncidentWorker { public static void list_backstories() { foreach (var bs in BackstoryDatabase.allBackstories.Values) Log.Message("Backstory \"" + bs.title + "\" has identifier \"" + bs.identifier + "\""); } public static void inject_designator() { //var des = new Designator_ComfortPrisoner(); //Find.ReverseDesignatorDatabase.AllDesignators.Add(des); //Find.ReverseDesignatorDatabase.AllDesignators.Add(new Designator_Breed()); } // Applies permanent damage to a randomly chosen colonist, to test that this works [SyncMethod] public static void damage_virally(Map m) { var vir_dam = DefDatabase<DamageDef>.GetNamed("ViralDamage"); var p = m.mapPawns.FreeColonists.RandomElement(); var lun = p.RaceProps.body.AllParts.Find((BodyPartRecord bpr) => String.Equals(bpr.def.defName, "LeftLung")); var dam_def = HealthUtility.GetHediffDefFromDamage(vir_dam, p, lun); var inj = (Hediff_Injury)HediffMaker.MakeHediff(dam_def, p, null); inj.Severity = 2.0f; inj.TryGetComp<HediffComp_GetsPermanent>().IsPermanent = true; p.health.AddHediff(inj, lun, null); } // Gives all colonists on the map a severe syphilis or HIV infection [SyncMethod] public static void infect_the_colonists(Map m) { foreach (var p in m.mapPawns.FreeColonists) { if (Rand.Value < 0.50f) std_spreader.infect(p, std.syphilis); // var std_hed_def = (Rand.Value < 0.50f) ? std.syphilis.hediff_def : std.hiv.hediff_def; // p.health.AddHediff (std_hed_def); // p.health.hediffSet.GetFirstHediffOfDef (std_hed_def).Severity = Rand.Range (0.50f, 0.90f); } } // Reduces the sex need of the selected pawn public static void reduce_sex_need_on_select(Map m) { Pawn pawn = Find.Selector.SingleSelectedThing as Pawn; if (pawn != null) { if (pawn.needs.TryGetNeed<Need_Sex>() != null) { //--Log.Message("[RJW]TestInc::reduce_sex_need_on_select is called"); pawn.needs.TryGetNeed<Need_Sex>().CurLevel -= 0.5f; } } } protected override bool TryExecuteWorker(IncidentParms parms) { var m = (Map)parms.target; // list_backstories (); // inject_designator (); // spawn_nymphs (m); // damage_virally (m); //infect_the_colonists(m); reduce_sex_need_on_select(m); return true; } } }
Tirem12/rjw
Source/Modules/Nymphs/Incidents/IncidentWorker_TestInc.cs
C#
mit
2,433
using RimWorld; using UnityEngine; using Verse; namespace rjw { public class IncidentWorker_TestInc2 : IncidentWorker { // Testing the mechanism of some build-in functions public static void test_funcion() { float a = Mathf.InverseLerp(0, 2, 3); //gives 1 float b = Mathf.InverseLerp(0.2f, 2, 0.1f); //gives 0 float c = Mathf.InverseLerp(2f, 1, 2.5f); //gives 0 //--Log.Message("[RJW]TestInc2::test_function is called - value a is " + a); //--Log.Message("[RJW]TestInc2::test_function is called - value b is " + b); //--Log.Message("[RJW]TestInc2::test_function is called - value c is " + c); } // Gives the wanted information of the selected thing public static void info_on_select(Map m) { Pawn p = Find.Selector.SingleSelectedThing as Pawn; if (p != null) { //--Log.Message("[RJW]TestInc2::info_on_select is called"); foreach (var q in m.mapPawns.AllPawns) { SexAppraiser.would_fuck(p, q, true); } } } protected override bool TryExecuteWorker(IncidentParms parms) { var m = (Map)parms.target; info_on_select(m); return true; } } }
Tirem12/rjw
Source/Modules/Nymphs/Incidents/IncidentWorker_TestInc2.cs
C#
mit
1,162
using System.Collections.Generic; using RimWorld; using Verse; using Multiplayer.API; using System.Linq; using System.Linq.Expressions; namespace rjw { public struct nymph_story { public Backstory child; public Backstory adult; public List<Trait> traits; } public struct nymph_passion_chances { public float major; public float minor; public nymph_passion_chances(float maj, float min) { major = maj; minor = min; } } public static class nymph_backstories { public struct child { public static Backstory vatgrown_sex_slave; }; public struct adult { public static Backstory feisty; public static Backstory curious; public static Backstory tender; public static Backstory chatty; public static Backstory broken; public static Backstory homekeeper; }; public static void init() { { Backstory bs = new Backstory(); bs.identifier = ""; // identifier will be set by ResolveReferences MiscTranslationDef MTdef = DefDatabase<MiscTranslationDef>.GetNamedSilentFail("rjw_vatgrown_sex_slave"); if (MTdef != null) { bs.SetTitle(MTdef.label, MTdef.label); bs.SetTitleShort(MTdef.stringA, MTdef.stringA); bs.baseDesc = MTdef.description; } else { bs.SetTitle("Vat-Grown Sex Slave", "Vat-Grown Sex Slave"); bs.SetTitleShort("SexSlave", "SexSlave"); bs.baseDesc = "SexSlave Nymph"; } // bs.skillGains = new Dictionary<string, int> (); bs.skillGainsResolved.Add(SkillDefOf.Social, 8); // bs.skillGainsResolved = new Dictionary<SkillDef, int> (); // populated by ResolveReferences bs.workDisables = WorkTags.Intellectual; bs.requiredWorkTags = WorkTags.None; bs.slot = BackstorySlot.Childhood; bs.spawnCategories = new List<string>() { "rjw_nymphsCategory", "Slave" }; // Not necessary (I Think) Unprivater.SetProtectedValue("bodyTypeGlobal", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeFemale", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeMale", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeGlobalResolved", bs, BodyTypeDefOf.Thin); Unprivater.SetProtectedValue("bodyTypeFemaleResolved", bs, BodyTypeDefOf.Thin); Unprivater.SetProtectedValue("bodyTypeMaleResolved", bs, BodyTypeDefOf.Thin); //bs.bodyTypeFemale = BodyType.Female; //bs.bodyTypeMale = BodyType.Thin; bs.forcedTraits = new List<TraitEntry>(); bs.forcedTraits.Add(new TraitEntry(xxx.nymphomaniac, 0)); bs.disallowedTraits = new List<TraitEntry>(); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesMen, 0)); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesWomen, 0)); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.TooSmart, 0)); bs.shuffleable = true; bs.ResolveReferences(); BackstoryDatabase.AddBackstory(bs); child.vatgrown_sex_slave = bs; //--Log.Message("[RJW]nymph_backstories::init() succeed0"); } { Backstory bs = new Backstory(); bs.identifier = ""; MiscTranslationDef MTdef = DefDatabase<MiscTranslationDef>.GetNamedSilentFail("rjw_feisty"); if (MTdef != null) { bs.SetTitle(MTdef.label, MTdef.label); bs.SetTitleShort(MTdef.stringA, MTdef.stringA); bs.baseDesc = MTdef.description; } else { bs.SetTitle("Feisty Nymph", "Feisty Nymph"); bs.SetTitleShort("Nymph", "Nymph"); bs.baseDesc = "Feisty Nymph"; } bs.skillGainsResolved.Add(SkillDefOf.Social, -3); bs.skillGainsResolved.Add(SkillDefOf.Shooting, 2); bs.skillGainsResolved.Add(SkillDefOf.Melee, 9); bs.workDisables = (WorkTags.Cleaning | WorkTags.Animals | WorkTags.Caring | WorkTags.Artistic | WorkTags.ManualSkilled); bs.requiredWorkTags = WorkTags.None; bs.slot = BackstorySlot.Adulthood; bs.spawnCategories = new List<string>() { "rjw_nymphsCategory", "Slave" }; // Not necessary (I Think) Unprivater.SetProtectedValue("bodyTypeGlobal", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeFemale", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeMale", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeGlobalResolved", bs, BodyTypeDefOf.Thin); Unprivater.SetProtectedValue("bodyTypeFemaleResolved", bs, BodyTypeDefOf.Thin); Unprivater.SetProtectedValue("bodyTypeMaleResolved", bs, BodyTypeDefOf.Thin); bs.forcedTraits = new List<TraitEntry>(); bs.forcedTraits.Add(new TraitEntry(xxx.nymphomaniac, 0)); bs.disallowedTraits = new List<TraitEntry>(); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesMen, 0)); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesWomen, 0)); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.TooSmart, 0)); bs.shuffleable = true; bs.ResolveReferences(); BackstoryDatabase.AddBackstory(bs); adult.feisty = bs; //--Log.Message("[RJW]nymph_backstories::init() succeed1"); } { Backstory bs = new Backstory(); bs.identifier = ""; MiscTranslationDef MTdef = DefDatabase<MiscTranslationDef>.GetNamedSilentFail("rjw_curious"); if (MTdef != null) { bs.SetTitle(MTdef.label, MTdef.label); bs.SetTitleShort(MTdef.stringA, MTdef.stringA); bs.baseDesc = MTdef.description; } else { bs.SetTitle("Curious Nymph", "Curious Nymph"); bs.SetTitleShort("Nymph", "Nymph"); bs.baseDesc = "Curious Nymph"; } bs.skillGainsResolved.Add(SkillDefOf.Construction, 2); bs.skillGainsResolved.Add(SkillDefOf.Crafting, 6); bs.workDisables = (WorkTags.Animals | WorkTags.Artistic | WorkTags.Caring | WorkTags.Cooking | WorkTags.Mining | WorkTags.PlantWork | WorkTags.Violent | WorkTags.ManualDumb); bs.requiredWorkTags = WorkTags.None; bs.slot = BackstorySlot.Adulthood; bs.spawnCategories = new List<string>() { "rjw_nymphsCategory", "Slave" }; // Not necessary (I Think) Unprivater.SetProtectedValue("bodyTypeGlobal", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeFemale", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeMale", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeGlobalResolved", bs, BodyTypeDefOf.Thin); Unprivater.SetProtectedValue("bodyTypeFemaleResolved", bs, BodyTypeDefOf.Thin); Unprivater.SetProtectedValue("bodyTypeMaleResolved", bs, BodyTypeDefOf.Thin); bs.forcedTraits = new List<TraitEntry>(); bs.forcedTraits.Add(new TraitEntry(xxx.nymphomaniac, 0)); bs.disallowedTraits = new List<TraitEntry>(); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesMen, 0)); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesWomen, 0)); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.TooSmart, 0)); bs.shuffleable = true; bs.ResolveReferences(); BackstoryDatabase.AddBackstory(bs); adult.curious = bs; //--Log.Message("[RJW]nymph_backstories::init() succeed2"); } { Backstory bs = new Backstory(); bs.identifier = ""; MiscTranslationDef MTdef = DefDatabase<MiscTranslationDef>.GetNamedSilentFail("rjw_tender"); if (MTdef != null) { bs.SetTitle(MTdef.label, MTdef.label); bs.SetTitleShort(MTdef.stringA, MTdef.stringA); bs.baseDesc = MTdef.description; } else { bs.SetTitle("Tender Nymph", "Tender Nymph"); bs.SetTitleShort("Nymph", "Nymph"); bs.baseDesc = "Tender Nymph"; } bs.skillGainsResolved.Add(SkillDefOf.Medicine, 4); bs.workDisables = (WorkTags.Animals | WorkTags.Artistic | WorkTags.Hauling | WorkTags.Violent | WorkTags.ManualSkilled); bs.requiredWorkTags = WorkTags.None; bs.slot = BackstorySlot.Adulthood; bs.spawnCategories = new List<string>() { "rjw_nymphsCategory", "Slave" }; // Not necessary (I Think) Unprivater.SetProtectedValue("bodyTypeGlobal", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeFemale", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeMale", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeGlobalResolved", bs, BodyTypeDefOf.Thin); Unprivater.SetProtectedValue("bodyTypeFemaleResolved", bs, BodyTypeDefOf.Thin); Unprivater.SetProtectedValue("bodyTypeMaleResolved", bs, BodyTypeDefOf.Thin); bs.forcedTraits = new List<TraitEntry>(); bs.forcedTraits.Add(new TraitEntry(xxx.nymphomaniac, 0)); bs.disallowedTraits = new List<TraitEntry>(); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesMen, 0)); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesWomen, 0)); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.TooSmart, 0)); bs.shuffleable = true; bs.ResolveReferences(); BackstoryDatabase.AddBackstory(bs); adult.tender = bs; //--Log.Message("[RJW]nymph_backstories::init() succeed3"); } { Backstory bs = new Backstory(); bs.identifier = ""; MiscTranslationDef MTdef = DefDatabase<MiscTranslationDef>.GetNamedSilentFail("rjw_chatty"); if (MTdef != null) { bs.SetTitle(MTdef.label, MTdef.label); bs.SetTitleShort(MTdef.stringA, MTdef.stringA); bs.baseDesc = MTdef.description; } else { bs.SetTitle("Chatty Nymph", "Chatty Nymph"); bs.SetTitleShort("Nymph", "Nymph"); bs.baseDesc = "Chatty Nymph"; } bs.skillGainsResolved.Add(SkillDefOf.Social, 6); bs.workDisables = (WorkTags.Animals | WorkTags.Caring | WorkTags.Artistic | WorkTags.Violent | WorkTags.ManualDumb | WorkTags.ManualSkilled); bs.requiredWorkTags = WorkTags.None; bs.slot = BackstorySlot.Adulthood; bs.spawnCategories = new List<string>() { "rjw_nymphsCategory", "Slave" }; // Not necessary (I Think) Unprivater.SetProtectedValue("bodyTypeGlobal", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeFemale", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeMale", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeGlobalResolved", bs, BodyTypeDefOf.Thin); Unprivater.SetProtectedValue("bodyTypeFemaleResolved", bs, BodyTypeDefOf.Thin); Unprivater.SetProtectedValue("bodyTypeMaleResolved", bs, BodyTypeDefOf.Thin); bs.forcedTraits = new List<TraitEntry>(); bs.forcedTraits.Add(new TraitEntry(xxx.nymphomaniac, 0)); bs.disallowedTraits = new List<TraitEntry>(); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesMen, 0)); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesWomen, 0)); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.TooSmart, 0)); bs.shuffleable = true; bs.ResolveReferences(); BackstoryDatabase.AddBackstory(bs); adult.chatty = bs; //--Log.Message("[RJW]nymph_backstories::init() succeed4"); } { Backstory bs = new Backstory(); bs.identifier = ""; MiscTranslationDef MTdef = DefDatabase<MiscTranslationDef>.GetNamedSilentFail("rjw_broken"); if (MTdef != null) { bs.SetTitle(MTdef.label, MTdef.label); bs.SetTitleShort(MTdef.stringA, MTdef.stringA); bs.baseDesc = MTdef.description; } else { bs.SetTitle("Broken Nymph", "Broken Nymph"); bs.SetTitleShort("Nymph", "Nymph"); bs.baseDesc = "Broken Nymph"; } bs.skillGainsResolved.Add(SkillDefOf.Social, -5); bs.skillGainsResolved.Add(SkillDefOf.Artistic, 8); bs.workDisables = (WorkTags.Cleaning | WorkTags.Animals | WorkTags.Caring | WorkTags.Violent | WorkTags.ManualSkilled); bs.requiredWorkTags = WorkTags.None; bs.slot = BackstorySlot.Adulthood; bs.spawnCategories = new List<string>() { "rjw_nymphsCategory", "Slave" }; // Not necessary (I Think) Unprivater.SetProtectedValue("bodyTypeGlobal", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeFemale", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeMale", bs, "Thin"); Unprivater.SetProtectedValue("bodyTypeGlobalResolved", bs, BodyTypeDefOf.Thin); Unprivater.SetProtectedValue("bodyTypeFemaleResolved", bs, BodyTypeDefOf.Thin); Unprivater.SetProtectedValue("bodyTypeMaleResolved", bs, BodyTypeDefOf.Thin); bs.forcedTraits = new List<TraitEntry>(); bs.forcedTraits.Add(new TraitEntry(xxx.nymphomaniac, 0)); bs.disallowedTraits = new List<TraitEntry>(); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesMen, 0)); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesWomen, 0)); bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.TooSmart, 0)); bs.shuffleable = true; bs.ResolveReferences(); BackstoryDatabase.AddBackstory(bs); adult.broken = bs; //--Log.Message("[RJW]nymph_backstories::init() succeed5"); } //{ // Backstory bs = new Backstory(); // bs.identifier = ""; // MiscTranslationDef MTdef = DefDatabase<MiscTranslationDef>.GetNamedSilentFail("rjw_homekeeper"); // if (MTdef != null) // { // bs.SetTitle(MTdef.label, MTdef.label); // bs.SetTitleShort(MTdef.stringA, MTdef.stringA); // bs.baseDesc = MTdef.description; // } // else // { // bs.SetTitle("Home keeper Nymph", "Home keeper Nymph"); // bs.SetTitleShort("Nymph", "Nymph"); // bs.baseDesc = "Home keeper Nymph"; // } // bs.skillGainsResolved.Add(SkillDefOf.Cooking, 8); // bs.workDisables = (WorkTags.Animals | WorkTags.Caring | WorkTags.Violent | WorkTags.Artistic | WorkTags.Crafting | WorkTags.PlantWork | WorkTags.Mining); // bs.requiredWorkTags = (WorkTags.Cleaning | WorkTags.Cooking); // bs.slot = BackstorySlot.Adulthood; // bs.spawnCategories = new List<string>() { "rjw_nymphsCategory", "Slave" }; // Not necessary (I Think) // Unprivater.SetProtectedValue("bodyTypeGlobal", bs, "Thin"); // Unprivater.SetProtectedValue("bodyTypeFemale", bs, "Thin"); // Unprivater.SetProtectedValue("bodyTypeMale", bs, "Thin"); // Unprivater.SetProtectedValue("bodyTypeGlobalResolved", bs, BodyTypeDefOf.Thin); // Unprivater.SetProtectedValue("bodyTypeFemaleResolved", bs, BodyTypeDefOf.Thin); // Unprivater.SetProtectedValue("bodyTypeMaleResolved", bs, BodyTypeDefOf.Thin); // bs.forcedTraits = new List<TraitEntry>(); // bs.forcedTraits.Add(new TraitEntry(xxx.nymphomaniac, 0)); // bs.disallowedTraits = new List<TraitEntry>(); // bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesMen, 0)); // bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.DislikesWomen, 0)); // bs.disallowedTraits.Add(new TraitEntry(TraitDefOf.TooSmart, 0)); // bs.shuffleable = true; // bs.ResolveReferences(); // BackstoryDatabase.AddBackstory(bs); // adult.homekeeper = bs; // //--Log.Message("[RJW]nymph_backstories::init() succeed6"); //} } public static nymph_passion_chances get_passion_chances(Backstory child_bs, Backstory adult_bs, SkillDef skill_def) { var maj = 0.0f; var min = 0.0f; if (adult_bs == adult.feisty) { if (skill_def == SkillDefOf.Melee) { maj = 0.50f; min = 1.00f; } else if (skill_def == SkillDefOf.Shooting) { maj = 0.25f; min = 0.75f; } else if (skill_def == SkillDefOf.Social) { maj = 0.10f; min = 0.67f; } } else if (adult_bs == adult.curious) { if (skill_def == SkillDefOf.Construction) { maj = 0.15f; min = 0.40f; } else if (skill_def == SkillDefOf.Crafting) { maj = 0.50f; min = 1.00f; } else if (skill_def == SkillDefOf.Social) { maj = 0.20f; min = 1.00f; } } else if (adult_bs == adult.tender) { if (skill_def == SkillDefOf.Medicine) { maj = 0.20f; min = 0.60f; } else if (skill_def == SkillDefOf.Social) { maj = 0.50f; min = 1.00f; } } else if (adult_bs == adult.chatty) { if (skill_def == SkillDefOf.Social) { maj = 1.00f; min = 1.00f; } } else if (adult_bs == adult.broken) { if (skill_def == SkillDefOf.Artistic) { maj = 0.50f; min = 1.00f; } else if (skill_def == SkillDefOf.Social) { maj = 0.00f; min = 0.33f; } } else if (adult_bs == adult.homekeeper) { if (skill_def == SkillDefOf.Cooking) { maj = 0.50f; min = 1.00f; } else if (skill_def == SkillDefOf.Social) { maj = 0.00f; min = 0.33f; } } return new nymph_passion_chances(maj, min); } // Randomly chooses backstories and traits for a nymph [SyncMethod] public static nymph_story generate() { var tr = new nymph_story(); tr.child = child.vatgrown_sex_slave; tr.traits = new List<Trait>(); tr.traits.Add(new Trait(xxx.nymphomaniac, 0, true)); //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); var beauty = 0; var rv2 = Rand.Value; var story = (BackstoryDatabase.allBackstories.Where(x => x.Value.spawnCategories.Contains("rjw_nymphsCategory") && x.Value.slot == BackstorySlot.Adulthood)).ToList().RandomElement().Value; if (story == adult.feisty) { tr.adult = adult.feisty; beauty = Rand.RangeInclusive(0, 2); if (rv2 < 0.33) tr.traits.Add(new Trait(TraitDefOf.Brawler)); else if (rv2 < 0.67) tr.traits.Add(new Trait(TraitDefOf.Bloodlust)); else tr.traits.Add(new Trait(xxx.rapist)); } else if (story == adult.curious) { tr.adult = adult.curious; beauty = Rand.RangeInclusive(0, 2); if (rv2 < 0.33) tr.traits.Add(new Trait(TraitDefOf.Transhumanist)); } else if (story == adult.tender) { tr.adult = adult.tender; beauty = Rand.RangeInclusive(1, 2); if (rv2 < 0.50) tr.traits.Add(new Trait(TraitDefOf.Kind)); } else if (story == adult.chatty) { tr.adult = adult.chatty; beauty = 2; if (rv2 < 0.33) tr.traits.Add(new Trait(TraitDefOf.Greedy)); } else if (story == adult.broken) { tr.adult = adult.broken; beauty = Rand.RangeInclusive(0, 2); if (rv2 < 0.33) tr.traits.Add(new Trait(TraitDefOf.DrugDesire, 1)); else if (rv2 < 0.67) tr.traits.Add(new Trait(TraitDefOf.DrugDesire, 2)); } //else //{ // tr.adult = adult.homekeeper; // beauty = Rand.RangeInclusive(1, 2); // if (rv2 < 0.33) // tr.traits.Add(new Trait(TraitDefOf.Kind)); //} if (beauty > 0) tr.traits.Add(new Trait(TraitDefOf.Beauty, beauty, false)); return tr; } } }
Tirem12/rjw
Source/Modules/Nymphs/Pawns/Nymph_Backstories.cs
C#
mit
17,936
using System.Collections.Generic; using RimWorld; using UnityEngine; using Verse; using System; using Multiplayer.API; namespace rjw { public static class Nymph_Generator { /// <summary> /// Returns true if the given pawnGenerationRequest is for a nymph pawnKind. /// </summary> public static bool IsNymph(PawnGenerationRequest pawnGenerationRequest) { return pawnGenerationRequest.KindDef != null && pawnGenerationRequest.KindDef.defName == "Nymph"; } private static bool is_trait_conflicting_or_duplicate(Pawn pawn, Trait t) { foreach (var existing in pawn.story.traits.allTraits) if ((existing.def == t.def) || (t.def.ConflictsWith(existing))) return true; return false; } public static bool IsNymphBodyType(Pawn pawn) { return pawn.story.bodyType == BodyTypeDefOf.Female || pawn.story.bodyType == BodyTypeDefOf.Thin; } [SyncMethod] public static Gender RandomNymphGender() { //with males 100% its still 99%, coz im to lazy to fix it //float rnd = Rand.Value; //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); float chance = RJWSettings.male_nymph_chance; Gender Pawngender = Rand.Chance(chance) ? Gender.Male: Gender.Female; //Log.Message("[RJW] setnymphsex: " + (rnd < chance) + " rnd:" + rnd + " chance:" + chance); //Log.Message("[RJW] setnymphsex: " + Pawngender); return Pawngender; } /// <summary> /// Replaces a pawn's backstory and traits to turn it into a nymph /// </summary> [SyncMethod] public static void set_story(Pawn pawn) { var gen_sto = nymph_backstories.generate(); pawn.story.childhood = gen_sto.child; pawn.story.adulthood = gen_sto.adult; // add broken body to broken nymph if (pawn.story.adulthood == nymph_backstories.adult.broken) { pawn.health.AddHediff(xxx.feelingBroken); //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); (pawn.health.hediffSet.GetFirstHediffOfDef(xxx.feelingBroken)).Severity = Rand.Range(0.4f, 1.0f); } //The mod More Trait Slots will adjust the max number of traits pawn can get, and therefore, //I need to collect pawns' traits and assign other_traits back to the pawn after adding the nymph_story traits. Stack<Trait> other_traits = new Stack<Trait>(); int numberOfTotalTraits = 0; if (!pawn.story.traits.allTraits.NullOrEmpty()) { foreach (Trait t in pawn.story.traits.allTraits) { other_traits.Push(t); ++numberOfTotalTraits; } } pawn.story.traits.allTraits.Clear(); var trait_count = 0; foreach (var t in gen_sto.traits) { pawn.story.traits.GainTrait(t); ++trait_count; } while (trait_count < numberOfTotalTraits) { Trait t = other_traits.Pop(); if (!is_trait_conflicting_or_duplicate(pawn, t)) pawn.story.traits.GainTrait(t); ++trait_count; } } [SyncMethod] private static int sum_previous_gains(SkillDef def, Pawn_StoryTracker sto, Pawn_AgeTracker age) { int total_gain = 0; int gain; // Gains from backstories if (sto.childhood.skillGainsResolved.TryGetValue(def, out gain)) total_gain += gain; if (sto.adulthood.skillGainsResolved.TryGetValue(def, out gain)) total_gain += gain; // Gains from traits foreach (var trait in sto.traits.allTraits) if (trait.CurrentData.skillGains.TryGetValue(def, out gain)) total_gain += gain; // Gains from age //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); var rgain = Rand.Value * (float)total_gain * 0.35f; var age_factor = Mathf.Clamp01((age.AgeBiologicalYearsFloat - 17.0f) / 10.0f); // Assume nymphs are 17~27 total_gain += (int)(age_factor * rgain); return Mathf.Clamp(total_gain, 0, 20); } /// <summary> /// Set a nymph's initial skills & passions from backstory, traits, and age /// </summary> [SyncMethod] public static void set_skills(Pawn pawn) { foreach (var skill_def in DefDatabase<SkillDef>.AllDefsListForReading) { var rec = pawn.skills.GetSkill(skill_def); if (!rec.TotallyDisabled) { //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); rec.Level = sum_previous_gains(skill_def, pawn.story, pawn.ageTracker); rec.xpSinceLastLevel = rec.XpRequiredForLevelUp * Rand.Range(0.10f, 0.90f); var pas_cha = nymph_backstories.get_passion_chances(pawn.story.childhood, pawn.story.adulthood, skill_def); var rv = Rand.Value; if (rv < pas_cha.major) rec.passion = Passion.Major; else if (rv < pas_cha.minor) rec.passion = Passion.Minor; else rec.passion = Passion.None; } else rec.passion = Passion.None; } } public static PawnKindDef GetFixedNymphPawnKindDef() { var def = PawnKindDef.Named("Nymph"); // This is 18 in the xml but something is overwriting it to 5. def.minGenerationAge = 18; return def; } [SyncMethod] public static Pawn GenerateNymph(IntVec3 around_loc, ref Map map, Faction faction = null) { // Most of the special properties of nymphs are in harmony patches to PawnGenerator. PawnGenerationRequest request = new PawnGenerationRequest( kind: GetFixedNymphPawnKindDef(), faction: faction, tile: map.Tile, forceGenerateNewPawn: true, canGeneratePawnRelations: true, colonistRelationChanceFactor: 0.0f, inhabitant: true, relationWithExtraPawnChanceFactor: 0 ); //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); Pawn pawn = PawnGenerator.GeneratePawn(request); //Log.Message(""+ pawn.Faction); //IntVec3 spawn_loc = CellFinder.RandomClosewalkCellNear(around_loc, map, 6);//RandomSpawnCellForPawnNear could be an alternative //GenSpawn.Spawn(pawn, spawn_loc, map); return pawn; } } }
Tirem12/rjw
Source/Modules/Nymphs/Pawns/Nymph_Generator.cs
C#
mit
5,807
using System; using RimWorld; using Verse; namespace rjw { public class BackstoryDef : Def { public BackstoryDef() { this.slot = BackstorySlot.Childhood; } public static BackstoryDef Named(string defName) { return DefDatabase<BackstoryDef>.GetNamed(defName, true); } public override void ResolveReferences() { base.ResolveReferences(); if (BackstoryDatabase.allBackstories.ContainsKey(this.defName)) { Log.Error("BackstoryDatabase already contains: " + this.defName); return; } { //Log.Warning("BackstoryDatabase does not contains: " + this.defName); } if (!this.title.NullOrEmpty()) { Backstory backstory = new Backstory(); backstory.SetTitle(this.title, this.titleFemale); backstory.SetTitleShort(this.titleShort, this.titleFemaleShort); backstory.baseDesc = this.baseDescription; backstory.slot = this.slot; backstory.spawnCategories.Add(this.categoryName); backstory.ResolveReferences(); backstory.PostLoad(); backstory.identifier = this.defName; BackstoryDatabase.allBackstories.Add(backstory.identifier, backstory); //Log.Warning("BackstoryDatabase added: " + backstory.identifier); //Log.Warning("BackstoryDatabase added: " + backstory.spawnCategories.ToCommaList()); } } public string baseDescription; public string title; public string titleShort; public string titleFemale; public string titleFemaleShort; public string categoryName; public BackstorySlot slot; } }
Tirem12/rjw
Source/Modules/Pregnancy/BackstoryDef.cs
C#
mit
1,516
using System.Collections.Generic; using Verse; using Multiplayer.API; namespace rjw { //MicroComputer internal class Hediff_MicroComputer : Hediff_MechImplants { protected int nextEventTick = 60000; public override void ExposeData() { base.ExposeData(); Scribe_Values.Look<int>(ref this.nextEventTick, "nextEventTick", 60000, false); } [SyncMethod] public override void PostMake() { base.PostMake(); //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); nextEventTick = Rand.Range(mcDef.minEventInterval, mcDef.maxEventInterval); } [SyncMethod] public override void Tick() { base.Tick(); if (this.pawn.IsHashIntervalTick(1000)) { if (this.ageTicks >= nextEventTick) { HediffDef randomEffectDef = DefDatabase<HediffDef>.GetNamed(randomEffect); if (randomEffectDef != null) { pawn.health.AddHediff(randomEffectDef); } else { //--Log.Message("[RJW]" + this.GetType().ToString() + "::Tick() - There is no Random Effect"); } this.ageTicks = 0; } } } protected HediffDef_MechImplants mcDef { get { return ((HediffDef_MechImplants)def); } } protected List<string> randomEffects { get { return mcDef.randomHediffDefs; } } protected string randomEffect { get { //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); return randomEffects.RandomElement<string>(); } } } }
Tirem12/rjw
Source/Modules/Pregnancy/Hediffs/HeDiff_MicroComputer.cs
C#
mit
1,492
using System.Collections.Generic; using Verse; using System.Linq; namespace rjw { [StaticConstructorOnStartup] internal class HediffDef_EnemyImplants : HediffDef { //single parent eggs public string parentDef = ""; //multiparent eggs public List<string> parentDefs = new List<string>(); //for implanting eggs public bool IsParent(string defnam) { return //predefined parent eggs parentDef == defnam || parentDefs.Contains(defnam) || //dynamic egg (parentDef == "Unknown" && defnam == "Unknown" && RJWPregnancySettings.egg_pregnancy_implant_anyone); } } [StaticConstructorOnStartup] internal class HediffDef_InsectEgg : HediffDef_EnemyImplants { //this is filled from xml //1 day = 60000 ticks public float eggsize = 1; public bool selffertilized = false; } [StaticConstructorOnStartup] internal class HediffDef_MechImplants : HediffDef_EnemyImplants { public List<string> randomHediffDefs = new List<string>(); public int minEventInterval = 30000; public int maxEventInterval = 90000; } }
Tirem12/rjw
Source/Modules/Pregnancy/Hediffs/HediffDef_EnemyImplants.cs
C#
mit
1,065
using System; using System.Collections.Generic; using RimWorld; using Verse; using UnityEngine; using System.Text; using Multiplayer.API; using System.Linq; using RimWorld.Planet; namespace rjw { public abstract class Hediff_BasePregnancy : HediffWithComps { ///<summary> ///This hediff class simulates pregnancy. ///</summary> //Static fields private const int MiscarryCheckInterval = 1000; protected const int TicksPerDay = 60000; protected const string starvationMessage = "MessageMiscarriedStarvation"; protected const string poorHealthMessage = "MessageMiscarriedPoorHealth"; protected static readonly HashSet<string> non_genetic_traits = new HashSet<string>(DefDatabase<StringListDef>.GetNamed("NonInheritedTraits").strings); //Fields ///All babies should be premade and stored here protected List<Pawn> babies; ///Reference to daddy, goes null sometimes public Pawn father; ///Is pregnancy visible? protected bool is_discovered; protected bool ShouldMiscarry = false; ///Is pregnancy type checked? public bool is_checked = false; ///Mechanoid pregnancy, false - spawn aggressive mech public bool is_hacked = false; ///Contractions duration, effectively additional hediff stage, a dirty hack to make birthing process notable protected int contractions; ///Gestation progress per tick protected float progress_per_tick; // // Properties // public float GestationProgress { get => Severity; private set => Severity = value; } private bool IsSeverelyWounded { get { float num = 0; List<Hediff> hediffs = pawn.health.hediffSet.hediffs; foreach (Hediff h in hediffs) { if (h is Hediff_Injury && (!h.IsPermanent() || !h.IsTended())) { num += h.Severity; } } List<Hediff_MissingPart> missingPartsCommonAncestors = pawn.health.hediffSet.GetMissingPartsCommonAncestors(); foreach (Hediff_MissingPart mp in missingPartsCommonAncestors) { if (mp.IsFresh) { num += mp.Part.def.GetMaxHealth(pawn); } } return num > 38 * pawn.RaceProps.baseHealthScale; } } /// <summary> /// Indicates pregnancy can be aborted using usual means. /// </summary> public virtual bool canBeAborted { get { return true; } } /// <summary> /// Indicates pregnancy can be miscarried. /// </summary> public virtual bool canMiscarry { get { return true; } } public override void PostMake() { // Ensure the hediff always applies to the torso, regardless of incorrect directive base.PostMake(); BodyPartRecord torso = pawn.RaceProps.body.AllParts.Find(x => x.def.defName == "Torso"); if (Part != torso) Part = torso; //(debug->add heddif) //init empty preg, instabirth, cause error during birthing //Initialize(pawn, father); } public override bool Visible => is_discovered; public virtual void DiscoverPregnancy() { is_discovered = true; if (PawnUtility.ShouldSendNotificationAbout(this.pawn)) { if (!is_checked) { string key1 = "RJW_PregnantTitle"; string message_title = TranslatorFormattedStringExtensions.Translate(key1, pawn.LabelIndefinite()); string key2 = "RJW_PregnantText"; string message_text = TranslatorFormattedStringExtensions.Translate(key2, pawn.LabelIndefinite()); Find.LetterStack.ReceiveLetter(message_title, message_text, LetterDefOf.NeutralEvent, pawn, null); } else { PregnancyMessage(); } } } public virtual void CheckPregnancy() { is_checked = true; if (!is_discovered) DiscoverPregnancy(); else PregnancyMessage(); } public virtual void PregnancyMessage() { string key1 = "RJW_PregnantTitle"; string message_title = TranslatorFormattedStringExtensions.Translate(key1, pawn.LabelIndefinite()); string key2 = "RJW_PregnantNormal"; string message_text = TranslatorFormattedStringExtensions.Translate(key2, pawn.LabelIndefinite()); Find.LetterStack.ReceiveLetter(message_title, message_text, LetterDefOf.NeutralEvent, pawn, null); } // Quick method to simply return a body part instance by a given part name internal static BodyPartRecord GetPawnBodyPart(Pawn pawn, String bodyPart) { return pawn.RaceProps.body.AllParts.Find(x => x.def == DefDatabase<BodyPartDef>.GetNamed(bodyPart)); } public virtual void Miscarry() { pawn.health?.RemoveHediff(this); } /// <summary> /// Called on abortion (noy implemented yet) /// </summary> public virtual void Abort() { } /// <summary> /// Mechanoids can remove pregnancy /// </summary> public virtual void Kill() { pawn.health?.RemoveHediff(this); } [SyncMethod] public Pawn partstospawn(Pawn baby, Pawn mother, Pawn dad) { //decide what parts to inherit //default use own parts Pawn partstospawn = baby; //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); //spawn with mother parts if (mother != null && Rand.Range(0, 100) <= 10) partstospawn = mother; //spawn with father parts if (dad != null && Rand.Range(0, 100) <= 10) partstospawn = dad; //Log.Message("[RJW] Pregnancy partstospawn " + partstospawn); return partstospawn; } [SyncMethod] public bool spawnfutachild(Pawn baby, Pawn mother, Pawn dad) { int futachance = 0; if (mother != null && Genital_Helper.is_futa(mother)) futachance = futachance + 25; if (dad != null && Genital_Helper.is_futa(dad)) futachance = futachance + 25; //Log.Message("[RJW] Pregnancy spawnfutachild " + futachance); //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); //theres 1% change baby will be futa //bug ... or ... feature ... nature finds a way return (Rand.Range(0, 100) <= futachance); } [SyncMethod] public static Pawn Trytogetfather(ref Pawn mother) { //birthing with debug has no father //Postmake.initialize() has no father Log.Warning("Hediff_BasePregnancy::Trytogetfather() - debug? no father defined, trying to add one"); Pawn pawn = mother; Pawn father = null; //possible fathers List<Pawn> partners = pawn.relations.RelatedPawns.Where(x => Genital_Helper.has_penis_fertile(x) && !x.Dead && (pawn.relations.DirectRelationExists(PawnRelationDefOf.Lover, x) || pawn.relations.DirectRelationExists(PawnRelationDefOf.Fiance, x) || pawn.relations.DirectRelationExists(PawnRelationDefOf.Spouse, x)) ).ToList(); //add bonded animal if (xxx.is_zoophile(mother) && RJWSettings.bestiality_enabled) partners.AddRange(pawn.relations.RelatedPawns.Where(x => Genital_Helper.has_penis_fertile(x) && pawn.relations.DirectRelationExists(PawnRelationDefOf.Bond, x)).ToList()); if (partners.Any()) { father = partners.RandomElement(); Log.Warning("Hediff_BasePregnancy::Trytogetfather() - father set to: " + xxx.get_pawnname(father)); } return father; } [SyncMethod] public override void Tick() { ageTicks++; GestationProgress += progress_per_tick; if (pawn.IsHashIntervalTick(1000)) { if (canMiscarry) { //Log.Message("[RJW] Pregnancy is ticking for " + pawn + " this is " + this.def.defName + " will end in " + 1/progress_per_tick/TicksPerDay + " days resulting in "+ babies[0].def.defName); //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); //miscarry after starving 0.5 day if (pawn.needs.food != null && pawn.needs.food.CurCategory == HungerCategory.Starving && Rand.MTBEventOccurs(0.5f, TicksPerDay, MiscarryCheckInterval)) { var hed = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.Malnutrition); if (hed.Severity > 0.4) { if (Visible && PawnUtility.ShouldSendNotificationAbout(pawn)) { string text = "MessageMiscarriedStarvation".Translate(pawn.LabelIndefinite()).CapitalizeFirst(); Messages.Message(text, pawn, MessageTypeDefOf.NegativeHealthEvent); } Miscarry(); return; } } //let beatings only be important when pregnancy is developed somewhat //miscarry after SeverelyWounded 0.5 day if (Visible && ((IsSeverelyWounded && Rand.MTBEventOccurs(0.5f, TicksPerDay, MiscarryCheckInterval)) || ShouldMiscarry)) { if (Visible && PawnUtility.ShouldSendNotificationAbout(pawn)) { string text = "MessageMiscarriedPoorHealth".Translate(pawn.LabelIndefinite()).CapitalizeFirst(); Messages.Message(text, pawn, MessageTypeDefOf.NegativeHealthEvent); } Miscarry(); return; } } // Check if pregnancy is far enough along to "show" for the body type if (!is_discovered) { BodyTypeDef bodyT = pawn?.story?.bodyType; //float threshold = 0f; if ((bodyT == BodyTypeDefOf.Thin && GestationProgress > 0.25f) || (bodyT == BodyTypeDefOf.Female && GestationProgress > 0.35f) || (GestationProgress > 0.50f)) // todo: Modded bodies? (FemaleBB for, example) DiscoverPregnancy(); //switch (bodyT) //{ //case BodyType.Thin: threshold = 0.3f; break; //case BodyType.Female: threshold = 0.389f; break; //case BodyType.Male: threshold = 0.41f; break; //default: threshold = 0.5f; break; //} //if (GestationProgress > threshold){ DiscoverPregnancy(); } } if (CurStageIndex == 3) { if (contractions == 0) { if (PawnUtility.ShouldSendNotificationAbout(pawn)) { string text = "RJW_Contractions".Translate(pawn.LabelIndefinite()); Messages.Message(text, pawn, MessageTypeDefOf.NeutralEvent); } contractions++; } if (GestationProgress >= 1 && (pawn.CarriedBy == null || pawn.CarriedByCaravan()))//birthing takes an hour { if (PawnUtility.ShouldSendNotificationAbout(pawn)) { string message_title = "RJW_GaveBirthTitle".Translate(pawn.LabelIndefinite()); string message_text = "RJW_GaveBirthText".Translate(pawn.LabelIndefinite()); string baby_text = ((babies.Count == 1) ? "RJW_ABaby".Translate() : "RJW_NBabies".Translate(babies.Count)); message_text = message_text + baby_text; Find.LetterStack.ReceiveLetter(message_title, message_text, LetterDefOf.PositiveEvent, pawn); } GiveBirth(); } } } } // //These functions are different from CnP // public override void ExposeData()//If you didn't know, this one is used to save the object for later loading of the game... and to load the data into the object, <sigh> { base.ExposeData(); Scribe_References.Look(ref father, "father"); Scribe_Values.Look(ref is_checked, "is_checked"); Scribe_Values.Look(ref is_hacked, "is_hacked"); Scribe_Values.Look(ref is_discovered, "is_discovered"); Scribe_Values.Look(ref ShouldMiscarry, "ShouldMiscarry"); Scribe_Values.Look(ref contractions, "contractions"); Scribe_Collections.Look(ref babies, saveDestroyedThings: true, label: "babies", lookMode: LookMode.Deep, ctorArgs: new object[0]); Scribe_Values.Look(ref progress_per_tick, "progress_per_tick", 1); } //This should generate pawns to be born in due time. Should take into account all settings and parent races [SyncMethod] protected virtual void GenerateBabies() { Pawn mother = pawn; //Log.Message("Generating babies for " + this.def.defName); if (mother == null) { Log.Error("Hediff_BasePregnancy::GenerateBabies() - no mother defined"); return; } if (father == null) { father = Trytogetfather(ref mother); } //Babies will have average number of traits of their parents, this way it will hopefully be compatible with various mods that change number of allowed traits //int trait_count = 0; // not anymore. Using number of traits originally generated by game as a guide //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); List<Trait> traitpool = new List<Trait>(); // if both parents has the same trait chanses to give it to child are doubled. // It was a bug, now it is a feature. float skin_whiteness = Rand.Range(0, 1); //Log.Message("[RJW]Generating babies " + traitpool.Count + " traits at first"); if (xxx.has_traits(mother) && mother.RaceProps.Humanlike) { foreach (Trait momtrait in mother.story.traits.allTraits) { if (!RJWPregnancySettings.trait_filtering_enabled || !non_genetic_traits.Contains(momtrait.def.defName)) traitpool.Add(momtrait); } skin_whiteness = mother.story.melanin; //trait_count = mother.story.traits.allTraits.Count; } if (father != null && xxx.has_traits(father) && father.RaceProps.Humanlike) { foreach (Trait poptrait in father.story.traits.allTraits) { if (!RJWPregnancySettings.trait_filtering_enabled || !non_genetic_traits.Contains(poptrait.def.defName)) traitpool.Add(poptrait); } skin_whiteness = Rand.Range(skin_whiteness, father.story.melanin); //trait_count = Mathf.RoundToInt((trait_count + father.story.traits.allTraits.Count) / 2f); } //this probably doesnt matter in 1.0 remove it and wait for bug reports =) //trait_count = trait_count > 2 ? trait_count : 2;//Tynan has hardcoded 2-3 traits per pawn. In the above, result may be less than that. Let us not have disfunctional babies. //Log.Message("[RJW]Generating babies " + traitpool.Count + " traits aFter parents"); Pawn parent = mother; //race of child Pawn parent2 = father; //name for child //Decide on which parent is first to be inherited if (father != null && RJWPregnancySettings.use_parent_method) { //Log.Message("The baby race needs definition"); //humanality if (xxx.is_human(mother) && xxx.is_human(father)) { //Log.Message("It's of two humanlikes"); if (!Rand.Chance(RJWPregnancySettings.humanlike_DNA_from_mother)) { //Log.Message("Mother will birth father race"); parent = father; } else { //Log.Message("Mother will birth own race"); } } else { //bestiality if ((!xxx.is_human(mother) && xxx.is_human(father)) || (xxx.is_human(mother) && !xxx.is_human(father))) { if (RJWPregnancySettings.bestiality_DNA_inheritance == 0.0f) { //Log.Message("mother will birth beast"); if (xxx.is_human(mother)) parent = father; else parent = mother; } else if (RJWPregnancySettings.bestiality_DNA_inheritance == 1.0f) { //Log.Message("mother will birth humanlike"); if (xxx.is_human(mother)) parent = mother; else parent = father; } else { if (!Rand.Chance(RJWPregnancySettings.bestial_DNA_from_mother)) { //Log.Message("Mother will birth father race"); parent = father; } else { //Log.Message("Mother will birth own race"); } } } //animality else if (!Rand.Chance(RJWPregnancySettings.bestial_DNA_from_mother)) { //Log.Message("Mother will birth father race"); parent = father; } else { //Log.Message("Mother will birth own race"); } } } //androids can only birth non androids if (AndroidsCompatibility.IsAndroid(mother) && !AndroidsCompatibility.IsAndroid(father)) { parent = father; } else if (!AndroidsCompatibility.IsAndroid(mother) && AndroidsCompatibility.IsAndroid(father)) { parent = mother; } else if (AndroidsCompatibility.IsAndroid(mother) && AndroidsCompatibility.IsAndroid(father)) { Log.Warning("Both parents are andoids, what have you done monster!"); //this should never happen but w/e } //slimes birth only other slimes if (xxx.is_slime(mother)) { parent = mother; } if (father != null) if (xxx.is_slime(father)) { parent = father; } //Log.Message("[RJW] The main parent is " + parent); //Log.Message("Mother: " + xxx.get_pawnname(mother) + " kind: " + mother.kindDef); //Log.Message("Father: " + xxx.get_pawnname(father) + " kind: " + father.kindDef); //Log.Message("Baby base: " + xxx.get_pawnname(parent) + " kind: " + parent.kindDef); // Surname passing string last_name = ""; if (xxx.is_human(father)) last_name = NameTriple.FromString(father.Name.ToStringFull).Last; if (xxx.is_human(mother) && last_name == "") last_name = NameTriple.FromString(mother.Name.ToStringFull).Last; //Log.Message("[RJW] Bady surname will be " + last_name); if (parent.kindDef.defName == "Nymph") parent.kindDef = PawnKindDefOf.Colonist; //Pawn generation request PawnKindDef spawn_kind_def = parent.kindDef; Faction spawn_faction = mother.IsPrisoner ? null : mother.Faction; PawnGenerationRequest request = new PawnGenerationRequest( kind: spawn_kind_def, faction: spawn_faction, forceGenerateNewPawn: true, newborn: true, canGeneratePawnRelations: false, colonistRelationChanceFactor: 0, allowFood: false, allowAddictions: false, relationWithExtraPawnChanceFactor: 0, fixedMelanin: skin_whiteness, fixedLastName: last_name ); //Log.Message("[RJW] Generated request, making babies"); //Litter size. Let's use the main parent litter size, increased by fertility. float litter_size = (parent.RaceProps.litterSizeCurve == null) ? 1 : Rand.ByCurve(parent.RaceProps.litterSizeCurve); //Log.Message("[RJW] base Litter size " + litter_size); litter_size *= Math.Min(mother.health.capacities.GetLevel(xxx.reproduction), 1); litter_size *= Math.Min(father == null ? 1 : father.health.capacities.GetLevel(xxx.reproduction), 1); litter_size = Math.Max(1, litter_size); //Log.Message("[RJW] Litter size (w fertility) " + litter_size); //Babies size vs mother body size //assuming mother belly is 1/3 of mother body size float baby_size = spawn_kind_def.RaceProps.lifeStageAges[0].def.bodySizeFactor * spawn_kind_def.RaceProps.baseBodySize; // adult size/5 //Log.Message("[RJW] Baby size " + baby_size); float max_litter = 1f / 3f / baby_size; //Log.Message("[RJW] Max size " + max_litter); max_litter *= (mother.Has(Quirk.Breeder) || mother.Has(Quirk.Incubator)) ? 2 : 1; //Log.Message("[RJW] Max size (w quirks) " + max_litter); //Generate random amount of babies within litter/max size litter_size = (Rand.Range(litter_size, max_litter)); //Log.Message("[RJW] Litter size roll 1:" + litter_size); litter_size = Mathf.RoundToInt(litter_size); //Log.Message("[RJW] Litter size roll 2:" + litter_size); litter_size = Math.Max(1, litter_size); //Log.Message("[RJW] final Litter size " + litter_size); for (int i = 0; i < litter_size; i++) { Pawn baby = PawnGenerator.GeneratePawn(request); //Choose traits to add to the child. Unlike CnP this will allow for some random traits if (xxx.is_human(baby) && traitpool.Count > 0) { updateTraits(baby, traitpool); } babies.Add(baby); } } /// <summary> /// Update pawns traits /// Uses original pawns trains and given list of traits as a source of traits to select. /// </summary> /// <param name="pawn">humanoid pawn</param> /// <param name="traitpool">list of parent traits</param> /// <param name="traitLimit">maximum allowed number of traits</param> void updateTraits(Pawn pawn, List<Trait> parenttraitpool, int traitLimit = -1) { if (pawn?.story?.traits == null) { return; } if (traitLimit == -1) { traitLimit = pawn.story.traits.allTraits.Count; } //Personal pool List<Trait> personalTraitPool = new List<Trait>(pawn.story.traits.allTraits); //Parents pool if (parenttraitpool != null) { personalTraitPool.AddRange(parenttraitpool); } //Game suggested traits. var forcedTraits = personalTraitPool .Where(x => x.ScenForced) .Distinct(new TraitComparer(ignoreDegree: true)); // result can be a mess, because game allows this mess to be created in scenario editor List<Trait> selectedTraits = new List<Trait>(); selectedTraits.AddRange(forcedTraits); // enforcing scenario forced traits var comparer = new TraitComparer(); // trait comparision implementation, because without game compares traits *by reference*, makeing them all unique. while (selectedTraits.Count < traitLimit && personalTraitPool.Count > 0) { int index = Rand.Range(0, personalTraitPool.Count); // getting trait and removing from the pull var trait = personalTraitPool[index]; personalTraitPool.RemoveAt(index); if (!selectedTraits.Any(x => comparer.Equals(x, trait) || // skipping traits conflicting with already added x.def.ConflictsWith(trait))) { selectedTraits.Add(new Trait(trait.def, trait.Degree, false)); } } pawn.story.traits.allTraits = selectedTraits; } //Handles the spawning of pawns and adding relations //this is extended by other scripts public abstract void GiveBirth(); public virtual void PostBirth(Pawn mother, Pawn father, Pawn baby) { //inject RJW_BabyState to the newborn if RimWorldChildren is not active //cnp patches its hediff right into pawn generator, so its already in if it can if (xxx.RimWorldChildrenIsActive) { if (xxx.is_human(mother)) { //BnC compatibility if (DefDatabase<HediffDef>.GetNamedSilentFail("BnC_RJW_PostPregnancy") == null) { mother.health.AddHediff(HediffDef.Named("PostPregnancy"), null, null); mother.health.AddHediff(HediffDef.Named("Lactating"), mother.RaceProps.body.AllParts.Find(x => x.def.defName == "Chest"), null); } if (xxx.is_human(baby)) if (mother.records.GetAsInt(xxx.CountOfBirthHuman) == 0 && mother.records.GetAsInt(xxx.CountOfBirthAnimal) == 0 && mother.records.GetAsInt(xxx.CountOfBirthEgg) == 0) { mother.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("IGaveBirthFirstTime")); } else { mother.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("IGaveBirth")); } } if (xxx.is_human(baby)) if (xxx.is_human(father)) { father.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("PartnerGaveBirth")); } } BabyPostBirth(mother, father, baby); if (baby.playerSettings != null && mother.playerSettings != null) { baby.playerSettings.AreaRestriction = mother.playerSettings.AreaRestriction; } //spawn futa bool isfuta = spawnfutachild(baby, mother, father); if (isfuta) { SexPartAdder.add_genitals(baby, partstospawn(baby, mother, father), Gender.Male); SexPartAdder.add_genitals(baby, partstospawn(baby, mother, father), Gender.Female); SexPartAdder.add_breasts(baby, partstospawn(baby, mother, father), Gender.Female); baby.gender = Gender.Female; //set gender to female for futas, should cause no errors since babies already generated with relations n stuff } else { SexPartAdder.add_genitals(baby, partstospawn(baby, mother, father)); SexPartAdder.add_breasts(baby, partstospawn(baby, mother, father)); } SexPartAdder.add_anus(baby, partstospawn(baby, mother, father)); if (mother.Spawned) { // Move the baby in front of the mother, rather than on top if (mother.CurrentBed() != null) { baby.Position = baby.Position + new IntVec3(0, 0, 1).RotatedBy(mother.CurrentBed().Rotation); } // Spawn guck FilthMaker.TryMakeFilth(mother.Position, mother.Map, ThingDefOf.Filth_AmnioticFluid, mother.LabelIndefinite(), 5); mother.caller?.DoCall(); baby.caller?.DoCall(); father?.caller?.DoCall(); } if (xxx.is_human(baby)) mother.records.AddTo(xxx.CountOfBirthHuman, 1); if (xxx.is_animal(baby)) mother.records.AddTo(xxx.CountOfBirthAnimal, 1); if ((mother.records.GetAsInt(xxx.CountOfBirthHuman) > 10 || mother.records.GetAsInt(xxx.CountOfBirthAnimal) > 20)) { mother.Add(Quirk.Breeder); mother.Add(Quirk.ImpregnationFetish); } } public static void BabyPostBirth(Pawn mother, Pawn father, Pawn baby) { if (!xxx.is_human(baby)) return; baby.story.childhood = null; baby.story.adulthood = null; if (!xxx.RimWorldChildrenIsActive) { try { Backstory bs = null; BackstoryDatabase.TryGetWithIdentifier("rjw_childC", out bs); if (mother.story.GetBackstory(BackstorySlot.Adulthood) != null && mother.story.GetBackstory(BackstorySlot.Adulthood).spawnCategories.Contains("Tribal")) BackstoryDatabase.TryGetWithIdentifier("rjw_childT", out bs); else if(mother.story.GetBackstory(BackstorySlot.Adulthood) == null && mother.story.GetBackstory(BackstorySlot.Childhood).spawnCategories.Contains("Tribal")) BackstoryDatabase.TryGetWithIdentifier("rjw_childT", out bs); baby.story.childhood = bs; } catch (Exception e) { Log.Warning(e.ToString()); } if (baby.ageTracker.CurLifeStageIndex <= 1 && baby.ageTracker.AgeBiologicalYears < 1 && !baby.Dead) { // Clean out drugs, implants, and stuff randomly generated //no support for custom race stuff, if there is any //baby.health.hediffSet.Clear(); baby.health.AddHediff(HediffDef.Named("RJW_BabyState"), null, null);//RJW_Babystate.tick_rare actually forces CnP switch to CnP one if it can, don't know wat do Hediff_SimpleBaby babystate = (Hediff_SimpleBaby)baby.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_BabyState")); if (babystate != null) { babystate.GrowUpTo(0, true); } } } else { Log.Message("[RJW]PostBirth:: Rewriting story of " + baby); //var disabledBaby = BackstoryDatabase.allBackstories["CustomBackstory_NA_Childhood_Disabled"]; // should be this, but bnc/cnp is broken and cant undisable work var BabyStory = BackstoryDatabase.allBackstories["CustomBackstory_NA_Childhood"]; if (BabyStory != null) { baby.story.childhood = BabyStory; } else { Log.Error("Couldn't find the required Backstory: CustomBackstory_NA_Childhood!"); } //BnC compatibility if (DefDatabase<HediffDef>.GetNamedSilentFail("BnC_RJW_PostPregnancy") != null) { baby.health.AddHediff(HediffDef.Named("BabyState"), null, null); baby.health.AddHediff(HediffDef.Named("NoManipulationFlag"), null, null); } } foreach (var skill in baby.skills?.skills) skill.Level = 0; if (baby.health.hediffSet.HasHediff(HediffDef.Named("DeathAcidifier"))) { baby.health.RemoveHediff(baby.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("DeathAcidifier"))); } //foreach (Hediff hd in baby.health.hediffSet.hediffs) //{ // if (hd is Hediff_Implant) // baby.health.RestorePart(hd.Part); //} } //This method is doing the work of the constructor since hediffs are created through HediffMaker instead of normal oop way //This can't be in PostMake() because there wouldn't be father. public virtual void Initialize(Pawn mother, Pawn dad) { BodyPartRecord torso = mother.RaceProps.body.AllParts.Find(x => x.def.defName == "Torso"); mother.health.AddHediff(this, torso); //Log.Message("[RJW]" + this.GetType().ToString() + " pregnancy hediff generated: " + this.Label); //Log.Message("[RJW]" + this.GetType().ToString() + " mother: " + mother + " father: " + dad); father = dad; if (father != null) { babies = new List<Pawn>(); contractions = 0; //Log.Message("[RJW]" + this.GetType().ToString() + " generating babies before: " + this.babies.Count); GenerateBabies(); } //progress_per_tick = babies.NullOrEmpty() ? 1f : (1.0f) / (babies[0].RaceProps.gestationPeriodDays * TicksPerDay/50); progress_per_tick = babies.NullOrEmpty() ? 1f : (1.0f) / (babies[0].RaceProps.gestationPeriodDays * TicksPerDay); if (pawn.Has(Quirk.Breeder) || pawn.health.hediffSet.HasHediff(HediffDef.Named("FertilityEnhancer"))) progress_per_tick *= 1.25f; if (xxx.ImmortalsIsActive && (mother.health.hediffSet.HasHediff(xxx.IH_Immortal) || father.health.hediffSet.HasHediff(xxx.IH_Immortal))) { ShouldMiscarry = true; } //Log.Message("[RJW]" + this.GetType().ToString() + " generating babies after: " + this.babies.Count); } private static Dictionary<Type, string> _hediffOfClass = null; protected static Dictionary<Type, string> hediffOfClass { get { if (_hediffOfClass == null) { _hediffOfClass = new Dictionary<Type, string>(); var allRJWPregnancies = AppDomain.CurrentDomain.GetAssemblies() .SelectMany( a => a .GetTypes() .Where(t => t.IsSubclassOf(typeof(Hediff_BasePregnancy))) ); foreach (var pregClass in allRJWPregnancies) { var attribute = (RJWAssociatedHediffAttribute)pregClass.GetCustomAttributes(typeof(RJWAssociatedHediffAttribute), false).FirstOrDefault(); if (attribute != null) { _hediffOfClass[pregClass] = attribute.defName; } } } return _hediffOfClass; } } /// <summary> /// Creates pregnancy hediff and assigns it to mother /// </summary> /// <typeparam name="T">type of pregnancy, should be subclass of Hediff_BasePregnancy</typeparam> /// <param name="mother"></param> /// <param name="father"></param> /// <returns>created hediff</returns> public static T Create<T>(Pawn mother, Pawn father) where T : Hediff_BasePregnancy { if (mother == null) return null; //if (mother.RaceHasOviPregnancy() && !(T is Hediff_MechanoidPregnancy)) //{ // //return null; //} //else //{ //} BodyPartRecord torso = mother.RaceProps.body.AllParts.Find(x => x.def.defName == "Torso"); string defName = hediffOfClass.ContainsKey(typeof(T)) ? hediffOfClass[typeof(T)] : "RJW_pregnancy"; if (RJWSettings.DevMode) Log.Message($"Hediff_BasePregnancy::create hediff:{defName} class:{typeof(T).FullName}"); T hediff = HediffHelper.MakeHediff<T>(HediffDef.Named(defName), mother, torso); hediff.Initialize(mother, father); return hediff; } /// <summary> /// list of all known RJW pregnancy hediff names (new can be regicreted by mods) /// </summary> /// <returns></returns> public static IEnumerable<string> KnownPregnancies() { return hediffOfClass.Values.Distinct(); // todo: performance } public override string DebugString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(base.DebugString()); stringBuilder.AppendLine("Gestation progress: " + GestationProgress.ToStringPercent()); //stringBuilder.AppendLine("Time left: " + ((int)((1f - GestationProgress) * babies[0].RaceProps.gestationPeriodDays * TicksPerDay/50)).ToStringTicksToPeriod()); stringBuilder.AppendLine("Time left: " + ((int)((1f - GestationProgress) * babies[0].RaceProps.gestationPeriodDays * TicksPerDay)).ToStringTicksToPeriod()); stringBuilder.AppendLine(" Father: " + xxx.get_pawnname(father)); return stringBuilder.ToString(); } } }
Tirem12/rjw
Source/Modules/Pregnancy/Hediffs/Hediff_BasePregnancy.cs
C#
mit
31,162
using System.Collections.Generic; using System.Linq; using RimWorld; using Verse; namespace rjw { ///<summary> ///This hediff class simulates pregnancy with animal children, mother may be human. It is not intended to be reasonable. ///Differences from humanlike pregnancy are that animals are given some training and that less punishing relations are used for parent-child. ///</summary> [RJWAssociatedHediff("RJW_pregnancy_beast")] public class Hediff_BestialPregnancy : Hediff_BasePregnancy { private static readonly PawnRelationDef relation_birthgiver = DefDatabase<PawnRelationDef>.AllDefs.FirstOrDefault(d => d.defName == "RJW_Sire"); private static readonly PawnRelationDef relation_spawn = DefDatabase<PawnRelationDef>.AllDefs.FirstOrDefault(d => d.defName == "RJW_Pup"); //static int max_train_level = TrainableUtility.TrainableDefsInListOrder.Sum(tr => tr.steps); public override void PregnancyMessage() { string message_title = "RJW_PregnantTitle".Translate(pawn.LabelIndefinite()); string message_text1 = "RJW_PregnantText".Translate(pawn.LabelIndefinite()); string message_text2 = "RJW_PregnantStrange".Translate(); Find.LetterStack.ReceiveLetter(message_title, message_text1 + "\n" + message_text2, LetterDefOf.NeutralEvent, pawn); } //Makes half-human babies start off better. They start obedient, and if mother is a human, they get hediff to boost their training protected void train(Pawn baby, Pawn mother, Pawn father) { bool _; if (!xxx.is_human(baby) && baby.Faction == Faction.OfPlayer) { if (xxx.is_human(mother) && baby.Faction == Faction.OfPlayer && baby.training.CanAssignToTrain(TrainableDefOf.Obedience, out _).Accepted) { baby.training.Train(TrainableDefOf.Obedience, mother); } if (xxx.is_human(mother) && baby.Faction == Faction.OfPlayer && baby.training.CanAssignToTrain(TrainableDefOf.Tameness, out _).Accepted) { baby.training.Train(TrainableDefOf.Tameness, mother); } } //baby.RaceProps.TrainableIntelligence.LabelCap. //if (xxx.is_human(mother)) //{ // Let the animals be born as colony property // if (mother.IsPrisonerOfColony || mother.IsColonist) // { // baby.SetFaction(Faction.OfPlayer); // } // let it be trained half to the max // var baby_int = baby.RaceProps.TrainableIntelligence; // int max_int = TrainableUtility.TrainableDefsInListOrder.FindLastIndex(tr => (tr.requiredTrainableIntelligence == baby_int)); // if (max_int == -1) // return; // Log.Message("RJW training " + baby + " max_int is " + max_int); // var available_tricks = TrainableUtility.TrainableDefsInListOrder.GetRange(0, max_int + 1); // int max_steps = available_tricks.Sum(tr => tr.steps); // Log.Message("RJW training " + baby + " vill do " + max_steps/2 + " steps"); // int t_score = Rand.Range(Mathf.RoundToInt(max_steps / 4), Mathf.RoundToInt(max_steps / 2)); // for (int i = 1; i <= t_score; i++) // { // var tr = available_tricks.Where(t => !baby.training.IsCompleted(t)). RandomElement(); // Log.Message("RJW training " + baby + " for " + tr); // baby.training.Train(tr, mother); // } // baby.health.AddHediff(HediffDef.Named("RJW_smartPup")); //} } //Handles the spawning of pawns and adding relations public override void GiveBirth() { Pawn mother = pawn; if (mother == null) return; try { //fail if hediff added through debug, since babies not initialized if (babies.Count > 9999) Log.Message("RJW beastiality/animal pregnancy birthing pawn count: " + babies.Count); } catch { if (father == null) { Log.Message("RJW beastiality/animal pregnancy father is null(debug?), setting father to mother"); father = mother; } Initialize(mother, father); } List<Pawn> siblings = new List<Pawn>(); foreach (Pawn baby in babies) { PawnUtility.TrySpawnHatchedOrBornPawn(baby, mother); Need_Sex sex_need = mother.needs.TryGetNeed<Need_Sex>(); if (mother.Faction != null && !(mother.Faction?.IsPlayer ?? false) && sex_need != null) { sex_need.CurLevel = 1.0f; } baby.relations.AddDirectRelation(relation_birthgiver, mother); mother.relations.AddDirectRelation(relation_spawn, baby); if (father != null && mother != father) { baby.relations.AddDirectRelation(relation_birthgiver, father); father.relations.AddDirectRelation(relation_spawn, baby); } foreach (Pawn sibling in siblings) { baby.relations.AddDirectRelation(PawnRelationDefOf.Sibling, sibling); } siblings.Add(baby); train(baby, mother, father); PostBirth(mother, father, baby); mother.health.RemoveHediff(this); } } } }
Tirem12/rjw
Source/Modules/Pregnancy/Hediffs/Hediff_BestialPregnancy.cs
C#
mit
4,750
using System; using System.Collections.Generic; using System.Text; using RimWorld; using Verse; using UnityEngine; namespace rjw { [RJWAssociatedHediff("RJW_pregnancy")] public class Hediff_HumanlikePregnancy : Hediff_BasePregnancy ///<summary> ///This hediff class simulates pregnancy resulting in humanlike childs. ///</summary> { //Handles the spawning of pawns and adding relations public override void GiveBirth() { Pawn mother = pawn; if (mother == null) return; try { //fail if hediff added through debug, since babies not initialized if (babies.Count > 9999) Log.Message("RJW humanlike pregnancy birthing pawn count: " + babies.Count); } catch { if (father == null) { Log.Message("RJW humanlike pregnancy father is null(debug?), setting father to mother"); father = mother; } Initialize(mother, father); } List<Pawn> siblings = new List<Pawn>(); foreach (Pawn baby in babies) { PawnUtility.TrySpawnHatchedOrBornPawn(baby, mother); var sex_need = mother.needs.TryGetNeed<Need_Sex>(); if (mother.Faction != null && !(mother.Faction?.IsPlayer ?? false) && sex_need != null) { sex_need.CurLevel = 1.0f; } if (mother.Faction != null) { if (mother.Faction != baby.Faction) baby.SetFaction(mother.Faction); } if (mother.IsPrisonerOfColony) { baby.guest.CapturedBy(Faction.OfPlayer); } baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, mother); if (father != null) { baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, father); } foreach (Pawn sibling in siblings) { baby.relations.AddDirectRelation(PawnRelationDefOf.Sibling, sibling); } siblings.Add(baby); PostBirth(mother, father, baby); mother.health.RemoveHediff(this); } } } }
Tirem12/rjw
Source/Modules/Pregnancy/Hediffs/Hediff_HumanlikePregnancy.cs
C#
mit
1,870
using System.Collections.Generic; using RimWorld; using RimWorld.Planet; using Verse; using System.Text; using Verse.AI.Group; using Multiplayer.API; using System.Linq; namespace rjw { public class Hediff_InsectEgg : HediffWithComps { public int bornTick = 5000; public int abortTick = 0; public string parentDef { get { return ((HediffDef_InsectEgg)def).parentDef; } } public List<string> parentDefs { get { return ((HediffDef_InsectEgg)def).parentDefs; } } public Pawn father; //can be parentkind defined in egg public Pawn implanter; //can be any pawn public bool canbefertilized = true; public bool fertilized => father != null; public float eggssize = 0.1f; protected List<Pawn> babies; ///Contractions duration, effectively additional hediff stage, a dirty hack to make birthing process notable //protected const int TicksPerHour = 2500; protected int contractions = 0; public override string LabelBase { get { if (Prefs.DevMode) { if (father != null) return father.kindDef.race.label + " egg"; else if (implanter != null) return implanter.kindDef.race.label + " egg"; } if (eggssize <= 0.10f) return "Small egg"; if (eggssize <= 0.3f) return "Medium egg"; else if (eggssize <= 0.5f) return "Big egg"; else return "Huge egg"; //return Label; } } public override string LabelInBrackets { get { if (Prefs.DevMode) { if (fertilized) return "Fertilized"; else return "Unfertilized"; } return null; } } public float GestationProgress { get => Severity; private set => Severity = value; } public override bool TryMergeWith(Hediff other) { return false; } public override void PostAdd(DamageInfo? dinfo) { //--Log.Message("[RJW]Hediff_InsectEgg::PostAdd() - added parentDef:" + parentDef+""); base.PostAdd(dinfo); } public override void Tick() { ageTicks++; if (pawn.IsHashIntervalTick(1000)) { //birthing takes an hour if (ageTicks >= bornTick - 2500 && contractions == 0) { if (PawnUtility.ShouldSendNotificationAbout(pawn) && (pawn.IsColonist || pawn.IsPrisonerOfColony)) { string key = "RJW_EggContractions"; string text = TranslatorFormattedStringExtensions.Translate(key, pawn.LabelIndefinite()); Messages.Message(text, pawn, MessageTypeDefOf.NeutralEvent); } contractions++; pawn.health.AddHediff(HediffDef.Named("Hediff_Submitting")); } if (ageTicks >= bornTick && (pawn.CarriedBy == null || pawn.CarriedByCaravan())) { if (PawnUtility.ShouldSendNotificationAbout(pawn) && (pawn.IsColonist || pawn.IsPrisonerOfColony)) { string key1 = "RJW_GaveBirthEggTitle"; string message_title = TranslatorFormattedStringExtensions.Translate(key1, pawn.LabelIndefinite()); string key2 = "RJW_GaveBirthEggText"; string message_text = TranslatorFormattedStringExtensions.Translate(key2, pawn.LabelIndefinite()); //Find.LetterStack.ReceiveLetter(message_title, message_text, LetterDefOf.NeutralEvent, pawn, null); Messages.Message(message_text, pawn, MessageTypeDefOf.SituationResolved); } GiveBirth(); //someday add dmg to vag? //var dam = Rand.RangeInclusive(0, 1); //p.TakeDamage(new DamageInfo(DamageDefOf.Burn, dam, 999, -1.0f, null, rec, null)); } } } public override void ExposeData() { base.ExposeData(); Scribe_Values.Look<int>(ref bornTick, "bornTick"); Scribe_Values.Look<int>(ref abortTick, "abortTick"); Scribe_References.Look<Pawn>(ref father, "father", false); Scribe_References.Look<Pawn>(ref implanter, "implanter", false); Scribe_Collections.Look(ref babies, saveDestroyedThings: true, label: "babies", lookMode: LookMode.Deep, ctorArgs: new object[0]); } public override void Notify_PawnDied() { base.Notify_PawnDied(); GiveBirth(); } protected virtual void GenerateBabies() { } //should someday remake into birth eggs and then within few ticks hatch them [SyncMethod] public void GiveBirth() { Pawn mother = pawn; Pawn baby = null; //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); if (fertilized) { //Log.Message("[RJW]Hediff_InsectEgg::BirthBaby() - Egg of " + parentDef + " in " + mother.ToString() + " birth!"); PawnKindDef spawn_kind_def = father.kindDef; //egg mostlikely insect or implanter spawned factionless through debug, set to insect Faction spawn_faction = Faction.OfInsects; //Log.Message("[RJW]Hediff_InsectEgg::BirthBaby() - insect " + (implanter.Faction == Faction.OfInsects || father.Faction == Faction.OfInsects || mother.Faction == Faction.OfInsects)); //Log.Message("[RJW]Hediff_InsectEgg::BirthBaby() - human " + (xxx.is_human(implanter) && xxx.is_human(father))); //Log.Message("[RJW]Hediff_InsectEgg::BirthBaby() - animal1 " + (!xxx.is_human(implanter) && !(implanter.Faction?.IsPlayer ?? false))); //Log.Message("[RJW]Hediff_InsectEgg::BirthBaby() - animal2 "); //this is probably fucked up, idk how to filter insects from non insects/spiders etc //core Hive Insects... probably if (implanter.Faction == Faction.OfInsects || father.Faction == Faction.OfInsects || mother.Faction == Faction.OfInsects) { //Log.Message("[RJW]Hediff_InsectEgg::BirthBaby() - insect "); spawn_faction = Faction.OfInsects; int chance = 5; //random chance to make insect neutral/tamable if (father.Faction == Faction.OfInsects) chance = 5; if (father.Faction != Faction.OfInsects) chance = 10; if (father.Faction == Faction.OfPlayer) chance = 25; if (implanter.Faction == Faction.OfPlayer) chance += 25; if (implanter.Faction == Faction.OfPlayer && xxx.is_human(implanter)) chance += (int)(25 * implanter.GetStatValue(StatDefOf.PsychicSensitivity)); if (Rand.Range(0, 100) <= chance) spawn_faction = null; //chance tame insect on birth if (spawn_faction == null) if (implanter.Faction == Faction.OfPlayer && xxx.is_human(implanter)) if (Rand.Range(0, 100) <= (int)(50 * implanter.GetStatValue(StatDefOf.PsychicSensitivity))) spawn_faction = Faction.OfPlayer; } //humanlikes else if (xxx.is_human(implanter) && xxx.is_human(father)) { spawn_faction = implanter.Faction; } //TODO: humnlike + animal, merge with insect stuff? //else if (xxx.is_human(implanter) && !xxx.is_human(father)) //{ // spawn_faction = implanter.Faction; //} //animal, spawn implanter faction (if not player faction/not tamed) else if (!xxx.is_human(implanter) && !(implanter.Faction?.IsPlayer ?? false)) { spawn_faction = implanter.Faction; } //spawn factionless(tamable, probably) else { spawn_faction = null; } if (spawn_kind_def.defName == "Nymph") spawn_kind_def = PawnKindDefOf.Colonist; //Log.Message("[RJW]Hediff_InsectEgg::BirthBaby() " + spawn_kind_def + " of " + spawn_faction + " in " + (int)(50 * implanter.GetStatValue(StatDefOf.PsychicSensitivity)) + " chance!"); PawnGenerationRequest request = new PawnGenerationRequest( kind: spawn_kind_def, faction: spawn_faction, forceGenerateNewPawn: true, newborn: true, canGeneratePawnRelations: false, colonistRelationChanceFactor: 0, allowFood: false, allowAddictions: false, relationWithExtraPawnChanceFactor: 0 ); baby = PawnGenerator.GeneratePawn(request); Hediff_BasePregnancy.BabyPostBirth(mother, father, baby); Sexualizer.sexualize_pawn(baby); if (PawnUtility.TrySpawnHatchedOrBornPawn(baby, mother)) { if (spawn_faction == Faction.OfInsects || (spawn_faction != null && (spawn_faction.def.defName.Contains("insect") || spawn_faction == implanter.Faction))) { //Log.Message("[RJW]Hediff_InsectEgg::BirthBaby() GetLord"); //Log.Message("[RJW]Hediff_InsectEgg::BirthBaby() " + implanter.GetLord()); //add ai to pawn? //LordManager.lords Lord lord = implanter.GetLord(); if (lord != null) { //Log.Message("[RJW]Hediff_InsectEgg::BirthBaby() lord: " +lord); //Log.Message("[RJW]Hediff_InsectEgg::BirthBaby() LordJob: " + lord.LordJob); //Log.Message("[RJW]Hediff_InsectEgg::BirthBaby() CurLordToil: " + lord.CurLordToil); lord.AddPawn(baby); } else { //Log.Message("[RJW]Hediff_InsectEgg::BirthBaby() lord null"); //LordJob_DefendAndExpandHive lordJob = new LordJob_DefendAndExpandHive(); //lord = LordMaker.MakeNewLord(baby.Faction, lordJob, mother.Map); //lord.AddPawn(baby); //lord.SetJob(lordJob); } //Log.Message("[RJW]Hediff_InsectEgg::BirthBaby() " + baby.GetLord().DebugString()); } } else { if (spawn_faction == mother.Faction) { if (mother.IsPlayerControlledCaravanMember()) mother.GetCaravan().AddPawn(baby, true); else if (mother.IsCaravanMember()) mother.GetCaravan().AddPawn(baby, false); } else Find.WorldPawns.PassToWorld(baby, PawnDiscardDecideMode.Discard); } // Move the baby in front of the mother, rather than on top if (mother.Spawned) if (mother.CurrentBed() != null) { baby.Position = baby.Position + new IntVec3(0, 0, 1).RotatedBy(mother.CurrentBed().Rotation); } /* if (Visible && baby != null) { string key = "MessageGaveBirth"; string text = TranslatorFormattedStringExtensions.Translate(key, mother.LabelIndefinite()).CapitalizeFirst(); Messages.Message(text, baby, MessageTypeDefOf.NeutralEvent); } */ mother.records.AddTo(xxx.CountOfBirthEgg, 1); if (mother.records.GetAsInt(xxx.CountOfBirthEgg) > 100) { mother.Add(Quirk.Incubator); mother.Add(Quirk.ImpregnationFetish); } } else { if (PawnUtility.ShouldSendNotificationAbout(pawn) && (pawn.IsColonist || pawn.IsPrisonerOfColony)) { string key = "EggDead"; string text = TranslatorFormattedStringExtensions.Translate(key, pawn.LabelIndefinite()).CapitalizeFirst(); Messages.Message(text, pawn, MessageTypeDefOf.SituationResolved); } } // Post birth if (mother.Spawned) { // Spawn guck if (mother.caller != null) { mother.caller.DoCall(); } if (baby != null) { if (baby.caller != null) { baby.caller.DoCall(); } } FilthMaker.TryMakeFilth(mother.Position, mother.Map, ThingDefOf.Filth_AmnioticFluid, mother.LabelIndefinite(), 5); int howmuch = xxx.has_quirk(mother, "Incubator") ? Rand.Range(1, 3) * 2 : Rand.Range(1, 3); int i = 0; if (xxx.is_insect(baby) || xxx.is_insect(mother)) { while (i++ < howmuch) { Thing jelly = ThingMaker.MakeThing(ThingDefOf.InsectJelly); jelly.SetForbidden(true, false); GenPlace.TryPlaceThing(jelly, mother.InteractionCell, mother.Map, ThingPlaceMode.Direct); } } } mother.health.RemoveHediff(this); } //set father/final egg type public void Fertilize(Pawn Pawn) { if (xxx.ImmortalsIsActive && (Pawn.health.hediffSet.HasHediff(xxx.IH_Immortal) || pawn.health.hediffSet.HasHediff(xxx.IH_Immortal))) { return; } if (!AndroidsCompatibility.IsAndroid(pawn)) if (!fertilized && canbefertilized && ageTicks < abortTick) { if (RJWSettings.DevMode) Log.Message(xxx.get_pawnname(pawn) + " fertilize eggs:" + this.ToString()); father = Pawn; ChangeEgg(father); } } //set implanter/base egg type public void Implanter(Pawn Pawn) { if (implanter == null) { if (RJWSettings.DevMode) Log.Message("Hediff_InsectEgg:: set implanter:" + xxx.get_pawnname(Pawn)); implanter = Pawn; ChangeEgg(implanter); if (!implanter.health.hediffSet.HasHediff(xxx.sterilized)) { if (((HediffDef_InsectEgg)def).selffertilized) Fertilize(implanter); } else canbefertilized = false; } } //Change egg type after implanting/fertilizing public void ChangeEgg(Pawn Pawn) { if (Pawn != null) { eggssize = Pawn.RaceProps.baseBodySize / 5; float gestationPeriod = Pawn.RaceProps?.gestationPeriodDays * 60000 ?? 450000; //float gestationPeriod = 10000 ; gestationPeriod = (xxx.has_quirk(pawn, "Incubator") || pawn.health.hediffSet.HasHediff(HediffDef.Named("FertilityEnhancer"))) ? gestationPeriod / 2 : gestationPeriod; bornTick = (int)(gestationPeriod * Pawn.RaceProps.baseBodySize + 0.5f); abortTick = (int)(bornTick / 3); if (!Genital_Helper.has_ovipositorF(pawn)) Severity = eggssize; else if (eggssize > 0.1f) Severity = 0.1f; else Severity = eggssize; } } //for setting implanter/fertilize eggs public bool IsParent(Pawn parent) { //anyone can fertilize if (RJWPregnancySettings.egg_pregnancy_fertilize_anyone) return true; //only set egg parent or implanter can fertilize else return parentDef == parent.kindDef.defName || parentDefs.Contains(parent.kindDef.defName) || implanter.kindDef == parent.kindDef; // unknown eggs } public override string DebugString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(base.DebugString()); stringBuilder.AppendLine(" Gestation progress: " + ((float)ageTicks / bornTick).ToStringPercent()); if (RJWSettings.DevMode) stringBuilder.AppendLine(" Implanter: " + xxx.get_pawnname(implanter)); if (RJWSettings.DevMode) stringBuilder.AppendLine(" Father: " + xxx.get_pawnname(father)); if (RJWSettings.DevMode) stringBuilder.AppendLine(" bornTick: " + bornTick); //stringBuilder.AppendLine(" potential father: " + parentDef); return stringBuilder.ToString(); } } }
Tirem12/rjw
Source/Modules/Pregnancy/Hediffs/Hediff_InsectEggPregnancy.cs
C#
mit
13,949
using RimWorld; using System.Linq; using Verse; using Verse.AI; namespace rjw { public class Hediff_Orgasm : HediffWithComps { public override void PostAdd(DamageInfo? dinfo) { string key = "FeltOrgasm"; string text = TranslatorFormattedStringExtensions.Translate(key, pawn.LabelIndefinite()).CapitalizeFirst(); Messages.Message(text, pawn, MessageTypeDefOf.NeutralEvent); } } public class Hediff_TransportCums : HediffWithComps { public override void PostAdd(DamageInfo? dinfo) { if (pawn.gender == Gender.Female) { string key = "CumsTransported"; string text = TranslatorFormattedStringExtensions.Translate(key, pawn.LabelIndefinite()).CapitalizeFirst(); Messages.Message(text, pawn, MessageTypeDefOf.NeutralEvent); PawnGenerationRequest req = new PawnGenerationRequest(PawnKindDefOf.Drifter, fixedGender:Gender.Male ); Pawn cumSender = PawnGenerator.GeneratePawn(req); Find.WorldPawns.PassToWorld(cumSender); //Pawn cumSender = (from p in Find.WorldPawns.AllPawnsAlive where p.gender == Gender.Male select p).RandomElement<Pawn>(); //--Log.Message("[RJW]" + this.GetType().ToString() + "PostAdd() - Sending " + xxx.get_pawnname(cumSender) + "'s cum into " + xxx.get_pawnname(pawn) + "'s vagina"); PregnancyHelper.impregnate(pawn, cumSender, xxx.rjwSextype.Vaginal); } pawn.health.RemoveHediff(this); } } public class Hediff_TransportEggs : HediffWithComps { public override void PostAdd(DamageInfo? dinfo) { if (pawn.gender == Gender.Female) { string key = "EggsTransported"; string text = TranslatorFormattedStringExtensions.Translate(key, pawn.LabelIndefinite()).CapitalizeFirst(); Messages.Message(text, pawn, MessageTypeDefOf.NeutralEvent); PawnKindDef spawn = PawnKindDefOf.Megascarab; PawnGenerationRequest req1 = new PawnGenerationRequest(spawn, fixedGender:Gender.Female ); PawnGenerationRequest req2 = new PawnGenerationRequest(spawn, fixedGender:Gender.Male ); Pawn implanter = PawnGenerator.GeneratePawn(req1); Pawn fertilizer = PawnGenerator.GeneratePawn(req2); Find.WorldPawns.PassToWorld(implanter); Find.WorldPawns.PassToWorld(fertilizer); Sexualizer.sexualize_pawn(implanter); Sexualizer.sexualize_pawn(fertilizer); //Pawn cumSender = (from p in Find.WorldPawns.AllPawnsAlive where p.gender == Gender.Male select p).RandomElement<Pawn>(); //--Log.Message("[RJW]" + this.GetType().ToString() + "PostAdd() - Sending " + xxx.get_pawnname(cumSender) + "'s cum into " + xxx.get_pawnname(pawn) + "'s vagina"); PregnancyHelper.impregnate(pawn, implanter, xxx.rjwSextype.Vaginal); PregnancyHelper.impregnate(pawn, fertilizer, xxx.rjwSextype.Vaginal); } pawn.health.RemoveHediff(this); } } }
Tirem12/rjw
Source/Modules/Pregnancy/Hediffs/Hediff_MCEvents.cs
C#
mit
2,768
using System.Collections.Generic; using Verse; namespace rjw { internal class Hediff_MechImplants : HediffWithComps { public override bool TryMergeWith(Hediff other) { return false; } } }
Tirem12/rjw
Source/Modules/Pregnancy/Hediffs/Hediff_MechImplants.cs
C#
mit
203
using System.Collections.Generic; using RimWorld; using Verse; using Verse.AI.Group; using System.Linq; using UnityEngine; namespace rjw { ///<summary> ///This hediff class simulates pregnancy with mechanoids, mother may be human. It is not intended to be reasonable. ///Differences from bestial pregnancy are that ... it is lethal ///TODO: extend with something "friendlier"? than Mech_Scyther.... two Mech_Scyther's? muhahaha ///</summary> [RJWAssociatedHediff("RJW_pregnancy_mech")] public class Hediff_MechanoidPregnancy : Hediff_BasePregnancy { public override bool canBeAborted { get { return false; } } public override bool canMiscarry { get { return false; } } public override void PregnancyMessage() { string message_title = "RJW_PregnantTitle".Translate(pawn.LabelIndefinite()); string message_text1 = "RJW_PregnantText".Translate(pawn.LabelIndefinite()); string message_text2 = "RJW_PregnantMechStrange".Translate(); Find.LetterStack.ReceiveLetter(message_title, message_text1 + "\n" + message_text2, LetterDefOf.ThreatBig, pawn); } public void Hack() { is_hacked = true; } public override void Notify_PawnDied() { base.Notify_PawnDied(); GiveBirth(); } //Handles the spawning of pawns public override void GiveBirth() { Pawn mother = pawn; if (mother == null) return; if (!babies.NullOrEmpty()) foreach (Pawn baby in babies) baby.Discard(true); Faction spawn_faction = null; if (!is_hacked) spawn_faction = Faction.OfMechanoids; PawnGenerationRequest request = new PawnGenerationRequest( kind: PawnKindDef.Named("Mech_Scyther"), faction: spawn_faction, forceGenerateNewPawn: true, newborn: true ); Pawn mech = PawnGenerator.GeneratePawn(request); PawnUtility.TrySpawnHatchedOrBornPawn(mech, mother); if (!is_hacked) { LordJob_MechanoidsDefend lordJob = new LordJob_MechanoidsDefend(); Lord lord = LordMaker.MakeNewLord(mech.Faction, lordJob, mech.Map); lord.AddPawn(mech); } FilthMaker.TryMakeFilth(mech.PositionHeld, mech.MapHeld, mother.RaceProps.BloodDef, mother.LabelIndefinite()); IEnumerable<BodyPartRecord> source = from x in mother.health.hediffSet.GetNotMissingParts() where x.IsInGroup(BodyPartGroupDefOf.Torso) && !x.IsCorePart //&& x.groups.Contains(BodyPartGroupDefOf.Torso) //&& x.depth == BodyPartDepth.Inside //&& x.height == BodyPartHeight.Bottom //someday include depth filter //so it doesnt cut out external organs (breasts)? //vag is genital part and genital is external //anal is internal //make sep part of vag? //&& x.depth == BodyPartDepth.Inside select x; if (source.Any()) { foreach (BodyPartRecord part in source) { mother.health.DropBloodFilth(); } foreach (BodyPartRecord part in source) { Hediff_MissingPart hediff_MissingPart = (Hediff_MissingPart)HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, mother, part); hediff_MissingPart.lastInjury = HediffDefOf.Cut; hediff_MissingPart.IsFresh = true; mother.health.AddHediff(hediff_MissingPart); } } mother.health.RemoveHediff(this); } } }
Tirem12/rjw
Source/Modules/Pregnancy/Hediffs/Hediff_MechanoidPregnancy.cs
C#
mit
3,335
using RimWorld; using RimWorld.Planet; using UnityEngine; using Verse; using Multiplayer.API; namespace rjw { internal class Hediff_Parasite : Hediff_Pregnant { [SyncMethod] new public static void DoBirthSpawn(Pawn mother, Pawn father) { //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); int num = (mother.RaceProps.litterSizeCurve == null) ? 1 : Mathf.RoundToInt(Rand.ByCurve(mother.RaceProps.litterSizeCurve)); if (num < 1) { num = 1; } PawnGenerationRequest request = new PawnGenerationRequest( kind: father.kindDef, faction: father.Faction, forceGenerateNewPawn: true, newborn: true, canGeneratePawnRelations: false, mustBeCapableOfViolence: true, colonistRelationChanceFactor: 0, allowFood: false, allowAddictions: false, relationWithExtraPawnChanceFactor: 0 ); Pawn pawn = null; for (int i = 0; i < num; i++) { pawn = PawnGenerator.GeneratePawn(request); if (PawnUtility.TrySpawnHatchedOrBornPawn(pawn, mother)) { if (pawn.playerSettings != null && mother.playerSettings != null) { pawn.playerSettings.AreaRestriction = father.playerSettings.AreaRestriction; } if (pawn.RaceProps.IsFlesh) { pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, mother); if (father != null) { pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, father); } } } else { Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard); } } if (mother.Spawned) { FilthMaker.TryMakeFilth(mother.Position, mother.Map, ThingDefOf.Filth_AmnioticFluid, mother.LabelIndefinite(), 5); if (mother.caller != null) { mother.caller.DoCall(); } if (pawn.caller != null) { pawn.caller.DoCall(); } } } } }
Tirem12/rjw
Source/Modules/Pregnancy/Hediffs/Hediff_ParasitePregnancy.cs
C#
mit
1,864