Пример #1
0
 public static bool IsExclusivelyGynephilic(Pawn pawn)
 {
     if (PsycheHelper.PsychologyEnabled(pawn) && PsychologyBase.ActivateKinsey())
     {
         int kinsey = PsycheHelper.Comp(pawn).Sexuality.kinseyRating;
         if (pawn.gender == Gender.Female && kinsey == 6)
         {
             return(true);
         }
         if (pawn.gender == Gender.Male && kinsey == 0)
         {
             return(true);
         }
     }
     else
     {
         if (pawn.gender == Gender.Female && pawn.story.traits.HasTrait(TraitDefOf.Gay))
         {
             return(true);
         }
         if (pawn.gender == Gender.Male && pawn.story.traits.HasTrait(TraitDefOf.Gay) == false)
         {
             return(true);
         }
     }
     return(false);
 }
        public override void GiveThoughts(Pawn initiator, Pawn recipient, out List <RulePackDef> yetMoreSentencePacks)
        {
            yetMoreSentencePacks = new List <RulePackDef> {
            };
            float interpretChance = 1f;

            if (PsycheHelper.PsychologyEnabled(initiator))
            {
                interpretChance *= 0.5f + PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOfGR.Optimistic);
                interpretChance *= 0.5f + Mathf.Abs(1 - PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Empathetic));
                interpretChance  = Mathf.InverseLerp(0.50f, 2f, interpretChance);
            }
            else
            {
                interpretChance = 0.5f;
            }

            if (Rand.Value < interpretChance)
            {
                yetMoreSentencePacks.Add(RulePackDefOfGR.Sentence_InterpretFlirtPositively);
                initiator.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfGR.RomanticTension, recipient);
            }
            else
            {
                initiator.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfGR.RomanticDisinterest, recipient);
            }
        }
Пример #3
0
        public static float PropensityToBeSeduced(Pawn pawn)
        {
            float propensity = 1f;

            if (pawn.story.traits.HasTrait(TraitDefOfPsychology.Lecher))
            {
                propensity *= 1.5f;
            }
            if (pawn.story.traits.HasTrait(TraitDefOfPsychology.Prude))
            {
                propensity *= 0.5f;
            }
            if (pawn.story.traits.HasTrait(TraitDefOfPsychology.Codependent))
            {
                propensity *= 0.75f;
            }
            if (pawn.story.traits.HasTrait(TraitDefOfGR.Shy))
            {
                propensity *= 2f;
            }
            if (PsycheHelper.PsychologyEnabled(pawn))
            {
                CompPsychology comp = PsycheHelper.Comp(pawn);
                propensity *= comp.Psyche.GetPersonalityRating(PersonalityNodeDefOfGR.Adventurous) + 0.5f;
                propensity *= 1.5f - comp.Psyche.GetPersonalityRating(PersonalityNodeDefOfGR.Confident);
                propensity *= 1.5f - comp.Psyche.GetPersonalityRating(PersonalityNodeDefOf.Pure);
                propensity *= comp.Sexuality.AdjustedSexDrive;
            }
            return(propensity);
        }
Пример #4
0
 public static void AddAnxiety(MentalBreaker __instance, ref bool __result)
 {
     if (__result)
     {
         Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();
         int  intensity;
         int.TryParse("" + (byte)Traverse.Create(__instance).Property("CurrentDesiredMoodBreakIntensity").GetValue <MentalBreakIntensity>(), out intensity);
         Hediff hediff     = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOfPsychology.Anxiety);
         float  PTSDChance = (0.25f - (0.075f * intensity));
         if (pawn.story.traits.HasTrait(TraitDefOfPsychology.Desensitized))
         {
             PTSDChance *= 0.75f;
         }
         if (PsycheHelper.PsychologyEnabled(pawn))
         {
             //Laid-back pawns are less likely to get anxiety from mental breaks.
             PTSDChance -= pawn.GetComp <CompPsychology>().Psyche.GetPersonalityRating(PersonalityNodeDefOf.LaidBack) / 10f;
         }
         if (hediff != null)
         {
             hediff.Severity += 0.15f - (intensity * 0.5f);
         }
         else if (Rand.Chance(PTSDChance))
         {
             Hediff newHediff = HediffMaker.MakeHediff(HediffDefOfPsychology.Anxiety, pawn, pawn.health.hediffSet.GetBrain());
             newHediff.Severity = 0.75f - (intensity * 0.25f);
             Letter newAnxiety = LetterMaker.MakeLetter("LetterLabelPTSD".Translate(), "LetterPTSD".Translate().AdjustedFor(pawn), LetterDefOf.NegativeEvent, pawn);
             Find.LetterStack.ReceiveLetter(newAnxiety);
             pawn.health.AddHediff(newHediff, null, null);
         }
     }
 }
        // Plundered and adapted from Psychology
        public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
        {
            if (!GRPawnRelationUtility.HasInformalRelationship(initiator, recipient) && !LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient))
            {
                return(0f);
            }
            else if (initiator.story.traits.HasTrait(TraitDefOfPsychology.Codependent))
            {
                return(0f);
            }
            float chance         = 0.02f * GradualRomanceMod.BaseBreakupChance;
            float romanticFactor = 1f;

            if (PsycheHelper.PsychologyEnabled(initiator))
            {
                chance         = 0.05f * GradualRomanceMod.BaseBreakupChance;
                romanticFactor = Mathf.InverseLerp(1.05f, 0f, PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic));
            }
            float opinionFactor = Mathf.InverseLerp(100f, -100f, (float)initiator.relations.OpinionOf(recipient));
            float spouseFactor  = 1f;

            if (initiator.relations.DirectRelationExists(PawnRelationDefOf.Spouse, recipient))
            {
                spouseFactor = 0.4f;
            }
            return(chance * romanticFactor * opinionFactor * spouseFactor);
        }
Пример #6
0
        public static bool NewGRFormula(ref float __result, Pawn pawn)
        {
            float num = 1f;

            num /= 1f - pawn.health.hediffSet.PainTotal;
            float level = pawn.health.capacities.GetLevel(PawnCapacityDefOf.Consciousness);

            if (level < 0.5f)
            {
                num /= level * 2f;
            }
            float sexDriveFactor;

            if (PsycheHelper.PsychologyEnabled(pawn))
            {
                sexDriveFactor = PsycheHelper.Comp(pawn).Sexuality.AdjustedSexDrive;
            }
            else
            {
                sexDriveFactor = GenMath.FlatHill(0f, 0.75f, 1f, 2f, 3f, 0.2f, AgeCalculationUtility.GetMaturity(pawn));
            }

            __result = num / sexDriveFactor;

            return(false);
        }
Пример #7
0
        // Plundered and adapted from Psychology
        public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
        {
            if (!RelationshipUtility.HasInformalRelationship(initiator, recipient) && !LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient))
            {
                return(0f);
            }
            else if (initiator.story.traits.HasTrait(TraitDefOfPsychology.Codependent))
            {
                return(0f);
            }
            float chance         = 0.02f * GradualRomanceMod.BaseBreakupChance;
            float romanticFactor = 1f;

            if (PsycheHelper.PsychologyEnabled(initiator))
            {
                chance         = 0.05f * GradualRomanceMod.BaseBreakupChance;
                romanticFactor = Mathf.InverseLerp(1.05f, 0f, PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic));
            }
            float           opinionFactor = Mathf.InverseLerp(100f, -100f, (float)initiator.relations.OpinionOf(recipient));
            float           spouseFactor  = 1f;
            PawnRelationDef relation      = RelationshipUtility.MostAdvancedRelationshipBetween(initiator, recipient);

            spouseFactor = relation.GetModExtension <RomanticRelationExtension>().baseAffairReluctance;
            float justificationFactor = 0.75f;

            if (BreakupUtility.HasReasonForBreakup(initiator, recipient))
            {
                justificationFactor = 2f;
            }
            return(chance * romanticFactor * opinionFactor * spouseFactor * justificationFactor);
        }
        public static bool NewSelectionWeight(InteractionWorker_Breakup __instance, ref float __result, Pawn initiator, Pawn recipient)
        {
            /* Also this one. */
            if (!LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient))
            {
                __result = 0f;
                return(false);
            }
            else if (initiator.story.traits.HasTrait(TraitDefOfPsychology.Codependent))
            {
                __result = 0f;
                return(false);
            }
            float chance         = 0.02f;
            float romanticFactor = 1f;

            if (PsycheHelper.PsychologyEnabled(initiator))
            {
                chance         = 0.05f;
                romanticFactor = Mathf.InverseLerp(1.05f, 0f, PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic));
            }
            float opinionFactor = Mathf.InverseLerp(100f, -100f, (float)initiator.relations.OpinionOf(recipient));
            float spouseFactor  = 1f;

            if (initiator.relations.DirectRelationExists(PawnRelationDefOf.Spouse, recipient))
            {
                spouseFactor = 0.4f;
            }
            __result = chance * romanticFactor * opinionFactor * spouseFactor;
            return(false);
        }
Пример #9
0
 public static bool KinseyException(ref Pawn pawn, PawnGenerationRequest request)
 {
     if (PsycheHelper.PsychologyEnabled(pawn))
     {
         if (PsychologyBase.ActivateKinsey())
         {
             while (PsycheHelper.Comp(pawn).Sexuality.kinseyRating > 2 && !request.AllowGay)
             {
                 PsycheHelper.Comp(pawn).Sexuality.GenerateSexuality();
             }
             if (LovePartnerRelationUtility.HasAnyLovePartnerOfTheSameGender(pawn) || LovePartnerRelationUtility.HasAnyExLovePartnerOfTheSameGender(pawn))
             {
                 while (PsycheHelper.Comp(pawn).Sexuality.kinseyRating < 2)
                 {
                     PsycheHelper.Comp(pawn).Sexuality.GenerateSexuality();
                 }
             }
             else if (LovePartnerRelationUtility.HasAnyLovePartnerOfTheOppositeGender(pawn) || LovePartnerRelationUtility.HasAnyExLovePartnerOfTheOppositeGender(pawn))
             {
                 while (PsycheHelper.Comp(pawn).Sexuality.kinseyRating > 4)
                 {
                     PsycheHelper.Comp(pawn).Sexuality.GenerateSexuality();
                 }
             }
         }
     }
     return(true);
 }
        public static bool NewInteracted(InteractionWorker_Breakup __instance, Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks)
        {
            /* If you want to patch this method, you can stuff it. */
            Thought thought = __instance.RandomBreakupReason(initiator, recipient);

            if (initiator.relations.DirectRelationExists(PawnRelationDefOf.Spouse, recipient))
            {
                initiator.relations.RemoveDirectRelation(PawnRelationDefOf.Spouse, recipient);
                initiator.relations.AddDirectRelation(PawnRelationDefOf.ExSpouse, recipient);
                recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.DivorcedMe, initiator);
                recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.BrokeUpWithMeCodependent, initiator);
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried);
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.HoneymoonPhase, recipient);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.HoneymoonPhase, initiator);
            }
            else
            {
                initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.Lover, recipient);
                initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.Fiance, recipient);
                if (PsycheHelper.PsychologyEnabled(initiator) && PsycheHelper.PsychologyEnabled(recipient))
                {
                    BreakupHelperMethods.AddExLover(initiator, recipient);
                    //AddExLover(realRecipient, realInitiator);
                    BreakupHelperMethods.AddBrokeUpOpinion(recipient, initiator);
                    BreakupHelperMethods.AddBrokeUpMood(recipient, initiator);
                    BreakupHelperMethods.AddBrokeUpMood(initiator, recipient);
                }
                else
                {
                    initiator.relations.AddDirectRelation(PawnRelationDefOf.ExLover, recipient);
                    recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.BrokeUpWithMe, initiator);
                    recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.BrokeUpWithMeCodependent, initiator);
                }
            }
            if (initiator.ownership.OwnedBed != null && initiator.ownership.OwnedBed == recipient.ownership.OwnedBed)
            {
                Pawn pawn = (Rand.Value >= 0.5f) ? recipient : initiator;
                pawn.ownership.UnclaimBed();
            }
            TaleRecorder.RecordTale(TaleDefOf.Breakup, new object[]
            {
                initiator,
                recipient
            });
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("LetterNoLongerLovers".Translate(initiator, recipient));
            if (thought != null)
            {
                stringBuilder.AppendLine();
                stringBuilder.AppendLine("FinalStraw".Translate(thought.CurStage.label));
            }
            if (PawnUtility.ShouldSendNotificationAbout(initiator) || PawnUtility.ShouldSendNotificationAbout(recipient))
            {
                Find.LetterStack.ReceiveLetter("LetterLabelBreakup".Translate(), stringBuilder.ToString(), LetterDefOf.NegativeEvent, initiator, null);
            }
            return(false);
        }
 public static float PersonalityChance(Pawn pawn)
 {
     if (PsycheHelper.PsychologyEnabled(pawn))
     {
         return(1f - PsycheHelper.Comp(pawn).Psyche.GetPersonalityNodeOfDef(PersonalityNodeDefOf.Aggressive).AdjustedRating);
     }
     return(0.5f);
 }
 public static bool LearnSexuality(Pawn initiator, Pawn recipient)
 {
     if (PsycheHelper.PsychologyEnabled(initiator) && PsycheHelper.PsychologyEnabled(recipient) && PsychologyBase.ActivateKinsey())
     {
         PsycheHelper.Comp(initiator).Sexuality.LearnSexuality(recipient);
     }
     return(true);
 }
Пример #13
0
 public static bool IsAsexual(Pawn pawn)
 {
     if (PsycheHelper.PsychologyEnabled(pawn))
     {
         return(PsycheHelper.Comp(pawn).Sexuality.AdjustedSexDrive < 0.01f);
     }
     return(false);
 }
Пример #14
0
        public static void PsychologyFormula(ref float __result, Pawn generated, Pawn other, PawnGenerationRequest request, bool ex)
        {
            /* Throw away the existing result and substitute our own formula. */
            float sexualityFactor = 1f;

            if (PsycheHelper.PsychologyEnabled(generated) && PsycheHelper.PsychologyEnabled(other) && PsychologyBase.ActivateKinsey())
            {
                float kinsey  = 3 - PsycheHelper.Comp(generated).Sexuality.kinseyRating;
                float kinsey2 = 3 - PsycheHelper.Comp(other).Sexuality.kinseyRating;
                float h**o    = (generated.gender == other.gender) ? 1f : -1f;
                sexualityFactor *= Mathf.InverseLerp(3f, 0f, kinsey * h**o);
                sexualityFactor *= Mathf.InverseLerp(3f, 0f, kinsey2 * h**o);
            }
            else
            {
                sexualityFactor = (generated.gender != other.gender) ? 1f : 0.01f;
            }
            float existingExLoverFactor = 1f;

            if (ex)
            {
                int exLovers = 0;
                List <DirectPawnRelation> directRelations = other.relations.DirectRelations;
                for (int i = 0; i < directRelations.Count; i++)
                {
                    if (LovePartnerRelationUtility.IsExLovePartnerRelation(directRelations[i].def))
                    {
                        exLovers++;
                    }
                }
                existingExLoverFactor = Mathf.Pow(0.2f, (float)exLovers);
            }
            else if (LovePartnerRelationUtility.HasAnyLovePartner(other))
            {
                __result = 0f;
                return;
            }
            float generationChanceAgeFactor    = Traverse.Create(typeof(LovePartnerRelationUtility)).Method("GetGenerationChanceAgeFactor", new[] { typeof(Pawn) }).GetValue <float>(new object[] { generated });
            float generationChanceAgeFactor2   = Traverse.Create(typeof(LovePartnerRelationUtility)).Method("GetGenerationChanceAgeFactor", new[] { typeof(Pawn) }).GetValue <float>(new object[] { other });
            float generationChanceAgeGapFactor = Traverse.Create(typeof(LovePartnerRelationUtility)).Method("GetGenerationChanceAgeGapFactor", new[] { typeof(Pawn), typeof(Pawn), typeof(bool) }).GetValue <float>(new object[] { generated, other, ex });
            float incestFactor = 1f;

            if (generated.GetRelations(other).Any((PawnRelationDef x) => x.familyByBloodRelation))
            {
                incestFactor = 0.01f;
            }
            float melaninFactor;

            if (request.FixedMelanin.HasValue)
            {
                melaninFactor = ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin);
            }
            else
            {
                melaninFactor = PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin);
            }
            __result = existingExLoverFactor * sexualityFactor * generationChanceAgeFactor * generationChanceAgeFactor2 * generationChanceAgeGapFactor * incestFactor * melaninFactor;
        }
 public static void NewFormula(ref float __result, Pawn initiator, Pawn recipient)
 {
     if (PsycheHelper.PsychologyEnabled(initiator))
     {
         SimpleCurve opinionCurve = Traverse.Create(typeof(NegativeInteractionUtility)).Field("CompatibilityFactorCurve").GetValue <SimpleCurve>();
         __result /= opinionCurve.Evaluate(initiator.relations.CompatibilityWith(recipient));
         __result *= 2f * PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Aggressive);
     }
 }
Пример #16
0
 public static bool WouldConsiderFormalRelationship(Pawn pawn, Pawn other)
 {
     if (PsycheHelper.PsychologyEnabled(pawn) && PsychologyBase.ActivateKinsey())
     {
         if (other.gender == Gender.Male)
         {
             int kinsey = PsycheHelper.Comp(pawn).Sexuality.kinseyRating;
             if (pawn.gender == Gender.Female && kinsey >= 5)
             {
                 return(false);
             }
             if (pawn.gender == Gender.Male && kinsey <= 1)
             {
                 return(false);
             }
         }
         else
         {
             int kinsey = PsycheHelper.Comp(pawn).Sexuality.kinseyRating;
             if (pawn.gender == Gender.Female && kinsey <= 1)
             {
                 return(false);
             }
             if (pawn.gender == Gender.Male && kinsey >= 5)
             {
                 return(false);
             }
         }
     }
     else
     {
         if (other.gender == Gender.Male)
         {
             if (pawn.gender == Gender.Female && pawn.story.traits.HasTrait(TraitDefOf.Gay))
             {
                 return(false);
             }
             if (pawn.gender == Gender.Male && pawn.story.traits.HasTrait(TraitDefOf.Gay) == false)
             {
                 return(false);
             }
         }
         else
         {
             if (pawn.gender == Gender.Male && pawn.story.traits.HasTrait(TraitDefOf.Gay))
             {
                 return(false);
             }
             if (pawn.gender == Gender.Female && pawn.story.traits.HasTrait(TraitDefOf.Gay) == false)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
 public static void Disable(ref ThoughtState __result, Pawn p, Pawn other)
 {
     if (__result.StageIndex != ThoughtState.Inactive.StageIndex)
     {
         if (PsycheHelper.PsychologyEnabled(p) && PsycheHelper.PsychologyEnabled(other))
         {
             __result = false;
         }
     }
 }
 public static bool BreakRelations(Pawn pawn, ref List <Pawn> oldLoversAndFiances)
 {
     oldLoversAndFiances = new List <Pawn>();
     while (true)
     {
         Pawn firstDirectRelationPawn = pawn.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Lover, null);
         if (firstDirectRelationPawn != null && (!firstDirectRelationPawn.story.traits.HasTrait(TraitDefOfPsychology.Polygamous) || !pawn.story.traits.HasTrait(TraitDefOfPsychology.Polygamous)))
         {
             pawn.relations.RemoveDirectRelation(PawnRelationDefOf.Lover, firstDirectRelationPawn);
             Pawn recipient = firstDirectRelationPawn;
             if (PsycheHelper.PsychologyEnabled(pawn) && PsycheHelper.PsychologyEnabled(recipient))
             {
                 BreakupHelperMethods.AddExLover(pawn, recipient);
                 BreakupHelperMethods.AddExLover(recipient, pawn);
                 BreakupHelperMethods.AddBrokeUpOpinion(recipient, pawn);
                 BreakupHelperMethods.AddBrokeUpMood(recipient, pawn);
                 BreakupHelperMethods.AddBrokeUpMood(pawn, recipient);
             }
             else
             {
                 pawn.relations.AddDirectRelation(PawnRelationDefOf.ExLover, firstDirectRelationPawn);
             }
             oldLoversAndFiances.Add(firstDirectRelationPawn);
         }
         else
         {
             Pawn firstDirectRelationPawn2 = pawn.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Fiance, null);
             if (firstDirectRelationPawn2 == null)
             {
                 break;
             }
             else if (!firstDirectRelationPawn2.story.traits.HasTrait(TraitDefOfPsychology.Polygamous) || !pawn.story.traits.HasTrait(TraitDefOfPsychology.Polygamous))
             {
                 pawn.relations.RemoveDirectRelation(PawnRelationDefOf.Fiance, firstDirectRelationPawn2);
                 Pawn recipient2 = firstDirectRelationPawn2;
                 if (PsycheHelper.PsychologyEnabled(pawn) && PsycheHelper.PsychologyEnabled(recipient2))
                 {
                     BreakupHelperMethods.AddExLover(pawn, recipient2);
                     BreakupHelperMethods.AddExLover(recipient2, pawn);
                     BreakupHelperMethods.AddBrokeUpOpinion(recipient2, pawn);
                     BreakupHelperMethods.AddBrokeUpMood(recipient2, pawn);
                     BreakupHelperMethods.AddBrokeUpMood(pawn, recipient2);
                 }
                 else
                 {
                     pawn.relations.AddDirectRelation(PawnRelationDefOf.ExLover, firstDirectRelationPawn2);
                 }
                 oldLoversAndFiances.Add(firstDirectRelationPawn2);
             }
         }
     }
     return(false);
 }
Пример #19
0
 public static bool IsWeaklyBisexual(Pawn pawn)
 {
     if (PsycheHelper.PsychologyEnabled(pawn) && PsychologyBase.ActivateKinsey())
     {
         int kinsey = PsycheHelper.Comp(pawn).Sexuality.kinseyRating;
         if (kinsey == 1 || kinsey == 5)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #20
0
 public static void ResolveBreakup(Pawn lover, Pawn ex, PawnRelationDef relation, float intensity = 1f)
 {
     if (intensity > 0f && PsycheHelper.PsychologyEnabled(lover) && PsycheHelper.PsychologyEnabled(ex))
     {
         float loverIntensity = Mathf.Clamp(Mathf.Round(intensity * (relation.opinionOffset / 5)), 0f, 10f);
         float exIntensity    = Mathf.Clamp(Mathf.Round(intensity * (relation.opinionOffset / 5) / 3), 0f, 10f);
         AddBrokeUpMood(lover, ex, loverIntensity);
         AddBrokeUpMood(ex, lover, exIntensity);
         AddBrokeUpOpinion(ex, lover, exIntensity);
     }
     RelationToEx(lover, ex, relation);
 }
        public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
        {
            //Don't hit on people in mental breaks... unless you're really freaky.
            if (recipient.InMentalState && PsycheHelper.PsychologyEnabled(initiator) && PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Experimental) < 0.8f)
            {
                return(0f);
            }
            //Pawns will only ask their girlfriend/boyfriend to move in
            if (!initiator.relations.DirectRelationExists(PawnRelationDefOfGR.Lovefriend, recipient))
            {
                return(0f);
            }
            if (!AttractionUtility.WouldConsiderFormalRelationship(initiator, recipient))
            {
                return(0f);
            }
            if (!AttractionUtility.QuickCheck(initiator, recipient))
            {
                return(0f);
            }
            EmptyReasons();
            float attractiveness = AttractionUtility.CalculateAttraction(initiator, recipient, false, true, out veryLowInitiatorReasons, out lowInitiatorReasons, out highInitiatorReasons, out veryHighInitiatorReasons, out AttractionFactorDef reasonForInstantFailure);

            if (attractiveness == 0f)
            {
                return(0f);
            }

            float romanceChance = GradualRomanceMod.BaseRomanceChance;

            if (!PsycheHelper.PsychologyEnabled(initiator))
            {
                //Vanilla: Straight women are 15% as likely to romance anyone.
                romanceChance *= (!initiator.story.traits.HasTrait(TraitDefOf.Gay)) ? ((initiator.gender != Gender.Female) ? romanceChance : romanceChance * 0.15f) : romanceChance;
            }
            else
            {
                //Psychology: A pawn's likelihood to ask to move in.
                float personalityFactor = Mathf.Pow(12f, (1f - PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic)));
                romanceChance *= personalityFactor * 0.02f;
            }
            //If their potential partner wouldn't consider a relationship with them, they're less likely to try and hit on them. But it doesn't put them off that much.
            if (AttractionUtility.WouldConsiderFormalRelationship(recipient, initiator))
            {
                romanceChance *= 0.2f;
            }

            lastInitiator = initiator;
            lastRecipient = recipient;

            return(romanceChance * attractiveness);
        }
        public static void AddBrokeUpOpinion(Pawn lover, Pawn ex)
        {
            ThoughtDef brokeUpDef = new ThoughtDef();

            brokeUpDef.defName      = "BrokeUpWithMe" + lover.LabelShort + Find.TickManager.TicksGame;
            brokeUpDef.durationDays = 40f;
            brokeUpDef.thoughtClass = typeof(Thought_MemorySocialDynamic);
            ThoughtStage brokeUpStage = new ThoughtStage();

            brokeUpStage.label             = "broke up with me";
            brokeUpStage.baseOpinionOffset = Mathf.RoundToInt(-50f * PsycheHelper.Comp(lover).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic) * Mathf.InverseLerp(5f, 100f, lover.relations.OpinionOf(ex)));
            brokeUpDef.stages.Add(brokeUpStage);
            lover.needs.mood.thoughts.memories.TryGainMemory(brokeUpDef, ex);
        }
Пример #23
0
 public SaveRecordPsycheV4(Pawn pawn)
 {
     if (PsycheHelper.PsychologyEnabled(pawn))
     {
         nodes      = PsycheHelper.Comp(pawn).Psyche.PersonalityNodes;
         upbringing = PsycheHelper.Comp(pawn).Psyche.upbringing;
         if (PsychologyBase.ActivateKinsey())
         {
             sexDrive      = PsycheHelper.Comp(pawn).Sexuality.sexDrive;
             romanticDrive = PsycheHelper.Comp(pawn).Sexuality.romanticDrive;
             kinseyRating  = PsycheHelper.Comp(pawn).Sexuality.kinseyRating;
         }
     }
 }
Пример #24
0
        public static void CancelJob(ref Job __result, Pawn pawn)
        {
            Pawn partner = LovePartnerRelationUtility.GetPartnerInMyBed(pawn);

            if (PsycheHelper.PsychologyEnabled(pawn) && PsycheHelper.PsychologyEnabled(partner) && PsychologyBase.ActivateKinsey())
            {
                float random  = Rand.ValueSeeded((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 2) * 60) * 391));
                float random2 = Rand.ValueSeeded((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(partner) + GenLocalDate.Year(partner) + (int)(GenLocalDate.DayPercent(partner) * 2) * 60) * 391));
                if (random > PsycheHelper.Comp(pawn).Sexuality.AdjustedSexDrive&& random2 > PsycheHelper.Comp(partner).Sexuality.AdjustedSexDrive)
                {
                    __result = null;
                }
            }
        }
Пример #25
0
 public static void Disable(ref ThoughtState __result, Pawn pawn, Pawn other)
 {
     if (__result.StageIndex != ThoughtState.Inactive.StageIndex)
     {
         if (pawn.health.capacities.GetLevel(PawnCapacityDefOf.Sight) == 0f)
         {
             __result = false;
         }
         if (PsycheHelper.PsychologyEnabled(pawn) && PsycheHelper.PsychologyEnabled(other))
         {
             __result = false;
         }
     }
 }
Пример #26
0
 public override bool Check(Pawn observer, Pawn assessed)
 {
     if (assessed.gender != Gender.Female)
     {
         return(false);
     }
     if (PsychologyBase.ActivateKinsey() && PsycheHelper.PsychologyEnabled(observer))
     {
         if (PsycheHelper.Comp(observer).Sexuality.kinseyRating == 3)
         {
             return(false);
         }
     }
     return(true);
 }
Пример #27
0
        public static void TryAddCheaterThought(Pawn pawn, Pawn cheater, Pawn cheaterLover)
        {
            {
                if (pawn.Dead)
                {
                    return;
                }
                if (RelationshipUtility.IsPolygamist(pawn))
                {
                    pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfGR.CheatedOnMePolygamist, cheater);
                }
                else
                {
                    float toleranceChance = 0.4f;
                    //people who are codependent are more tolerant of cheating, even though they are less likely to cheat
                    if (pawn.story.traits.HasTrait(TraitDefOfPsychology.Codependent))
                    {
                        toleranceChance *= 2f;
                    }
                    //moralistic characters are less tolerant of cheating.
                    if (PsycheHelper.PsychologyEnabled(pawn))
                    {
                        toleranceChance *= (1.5f - PsycheHelper.Comp(pawn).Psyche.GetPersonalityRating(PersonalityNodeDefOfGR.Moralistic));
                    }
                    //they are more likely to tolerate cheating if they like the person who the cheater is cheating with.
                    toleranceChance *= Mathf.Min(0f, Mathf.InverseLerp(-80f, 30f, pawn.relations.OpinionOf(cheaterLover)));
                    toleranceChance  = Mathf.Clamp01(toleranceChance);

                    if (Rand.Value < toleranceChance)
                    {
                        pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfGR.CheatedOnMeTolerated, cheater);
                    }
                    else
                    {
                        if (pawn.relations.OpinionOf(cheaterLover) >= 30f)
                        {
                            pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfGR.CheatedOnMeHighOpinion, cheater);
                        }
                        else
                        {
                            pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.CheatedOnMe, cheater);
                        }
                    }
                    pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfGR.LoversLover, cheaterLover);
                    //cheaterLover.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfGR.LoversLover, pawn);
                }
            }
        }
 internal static void _RandomSelectionWeight(InteractionWorker_MarriageProposal __instance, ref float __result, Pawn initiator, Pawn recipient)
 {
     if (PsycheHelper.PsychologyEnabled(initiator))
     {
         if (initiator.gender == Gender.Female)
         {
             /* Undo the effect of this in the postfixed method. */
             __result /= 0.2f;
         }
         __result *= 0.1f + PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Aggressive) + PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic);
         if (PsychologyBase.ActivateKinsey())
         {
             __result *= PsycheHelper.Comp(initiator).Sexuality.AdjustedRomanticDrive;
         }
     }
 }
Пример #29
0
        protected override ThoughtState CurrentStateInternal(Pawn pawn)
        {
            if (PsycheHelper.PsychologyEnabled(pawn) && PsychologyBase.ActivateKinsey())
            {
                if (PsycheHelper.Comp(pawn).Sexuality.kinseyRating >= 2)
                {
                    return(ThoughtState.ActiveAtStage(0));
                }

                return(false);
            }
            if (pawn.story.traits.HasTrait(TraitDefOf.Gay))
            {
                return(ThoughtState.ActiveAtStage(0));
            }
            return(false);
        }
Пример #30
0
        public static bool IsWeaklyGynephilic(Pawn pawn)
        {
            if (PsycheHelper.PsychologyEnabled(pawn) && PsychologyBase.ActivateKinsey())
            {
                int kinsey = PsycheHelper.Comp(pawn).Sexuality.kinseyRating;
                if (pawn.gender == Gender.Female && kinsey == 1)
                {
                    return(true);
                }
                if (pawn.gender == Gender.Male && kinsey == 5)
                {
                    return(true);
                }
            }

            return(false);
        }