Esempio n. 1
0
        public static bool HasReasonForBreakup(Pawn pawn, Pawn other)
        {
            PawnRelationDef relation = RelationshipUtility.MostAdvancedRelationshipBetween(pawn, other);

            if (relation == null)
            {
                return(false);
            }
            if (AttractionUtility.GetRelationshipUnmodifiedOpinion(pawn, other) < unmodifiedRelationshipBreakupThreshold)
            {
                return(true);
            }
            if (pawn.needs.mood.thoughts.memories.Memories.Any <Thought_Memory>(x => x.def.defName == "CheatedOnMe" && x.otherPawn == other))
            {
                return(true);
            }
            if (pawn.needs.mood.thoughts.memories.Memories.Any <Thought_Memory>(x => x.def.defName == "CaughtFlirting" && x.otherPawn == other))
            {
                return(true);
            }
            if (ThoughtDetector.HasSocialSituationalThought(pawn, other, ThoughtDefOfGR.FeelingNeglected))
            {
                return(true);
            }
            return(false);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public override float Calculate(Pawn observer, Pawn assessed)
        {
            float affairReluctance  = 1f;
            float affairReluctance2 = 1f;

            if (observerCuckold != null)
            {
                affairReluctance  = RelationshipUtility.AffairReluctance(RelationshipUtility.MostAdvancedRelationshipBetween(observer, observerCuckold));
                affairReluctance *= Mathf.Pow(Mathf.InverseLerp(-100f, 5f, observer.relations.OpinionOf(observerCuckold)), -0.33f);
            }
            if (assessedCuckold != null)
            {
                affairReluctance2  = RelationshipUtility.AffairReluctance(RelationshipUtility.MostAdvancedRelationshipBetween(assessed, assessedCuckold));
                affairReluctance2 *= Mathf.Pow(Mathf.InverseLerp(-100f, 5f, observer.relations.OpinionOf(assessedCuckold)), -0.33f);
            }
            return(Mathf.Min(affairReluctance, affairReluctance2));
        }
        protected override ThoughtState CurrentStateInternal(Pawn pawn)
        {
            if (pawn.ownership.OwnedBed == null)
            {
                return(ThoughtState.Inactive);
            }
            IEnumerable <Pawn> bedPartners = from partner in pawn.ownership.OwnedBed.AssignedPawns
                                             where partner != pawn && RelationshipUtility.MostAdvancedRelationshipBetween(pawn, partner) != null && RelationshipUtility.ShouldShareBed(pawn, partner) == false
                                             select partner;

            if (bedPartners.Count() == 0)
            {
                return(ThoughtState.Inactive);
            }
            else
            {
                return(ThoughtState.ActiveAtStage(0));
            }
        }
Esempio n. 5
0
        public static bool ShouldBeJealous(Pawn observer, Pawn initiator, Pawn recipient)
        {
            if (RelationshipUtility.IsPolygamist(observer))
            {
                return(false);
            }
            PawnRelationDef initiatorRelationship = RelationshipUtility.MostAdvancedRelationshipBetween(observer, initiator);
            PawnRelationDef recipientRelationship = RelationshipUtility.MostAdvancedRelationshipBetween(observer, recipient);

            if (initiatorRelationship == null)
            {
                return(false);
            }
            if (!initiatorRelationship.GetModExtension <RomanticRelationExtension>().caresAboutCheating)
            {
                return(false);
            }
            if (recipientRelationship != null && !observer.story.traits.HasTrait(TraitDefOfGR.Jealous))
            {
                return(false);
            }
            return(true);
        }
        protected override ThoughtState CurrentSocialStateInternal(Pawn pawn, Pawn other)
        {
            if (!other.RaceProps.Humanlike || !RelationsUtility.PawnsKnowEachOther(pawn, other))
            {
                return(false);
            }
            PawnRelationDef pawnRelationDef = RelationshipUtility.MostAdvancedRelationshipBetween(pawn, other);

            if (pawnRelationDef == null)
            {
                return(false);
            }
            if (!pawnRelationDef.GetModExtension <RomanticRelationExtension>().isFormalRelationship)
            {
                return(false);
            }
            if (RelationshipUtility.LevelOfTension(pawn, other) == 0)
            {
                return(ThoughtState.ActiveDefault);
            }

            return(false);
        }
Esempio n. 7
0
        private float CalculateFlirtReactionWeight(FlirtStyleDef flirtStyle, FlirtReactionDef flirtReaction, Pawn initiator, Pawn recipient)
        {
            float  chance = GradualRomanceMod.RomanticSuccessRate * flirtReaction.baseChance;
            string log    = "Reaction " + flirtReaction.defName + ": base chance " + chance.ToString();

            if (successImpossible && flirtReaction.successful)
            {
                log += ". Canceled, success impossible.";
                LogFlirt(log);
                return(0f);
            }
            if (successImpossible == false)
            {
                chance *= Mathf.Pow(flirtReaction.sexyReaction * initiatorPhysicalAttraction, flirtStyle.baseSexiness);
                log    += " sexiness " + chance.ToString();
                chance *= Mathf.Pow(flirtReaction.romanticReaction * initiatorRomanticAttraction, flirtStyle.baseRomance);
                log    += " romance " + chance.ToString();
                chance *= Mathf.Pow(flirtReaction.logicalReaction * initiatorSocialAttraction, flirtStyle.baseLogic);
                log    += " logic " + chance.ToString();
            }
            chance *= Mathf.Pow(flirtReaction.obscureReaction, flirtStyle.baseObscurity);
            log    += " obscurity " + chance.ToString();
            //risky flirts are less risky if the two pawns are familiar with each other.
            if (RelationshipUtility.MostAdvancedRelationshipBetween(initiator, recipient) == null)
            {
                chance *= Mathf.Pow(flirtReaction.riskyReaction, flirtStyle.baseRiskiness);
            }
            else
            {
                chance *= Mathf.Pow(Mathf.Pow(flirtReaction.riskyReaction, flirtStyle.baseRiskiness), FamiliarityFactor);
            }
            chance *= Mathf.Pow(flirtReaction.riskyReaction, flirtStyle.baseRiskiness);
            log    += " riskiness " + chance.ToString();
            chance *= Mathf.Pow(flirtReaction.awkwardReaction, flirtStyle.baseAwkwardness);
            log    += " awkward " + chance.ToString() + "; ";

            if (GradualRomanceMod.AttractionCalculation == GradualRomanceMod.AttractionCalculationSetting.Complex)
            {
                for (int i = 0; i < flirtReaction.personalityModifiers.Count(); i++)
                {
                    PersonalityNodeModifier node = flirtReaction.personalityModifiers[i];
                    if (node.modifier >= 0)
                    {
                        chance = chance * Mathf.Pow(Mathf.Lerp(0.5f, 1.5f, PsycheHelper.Comp(recipient).Psyche.GetPersonalityRating(node.personalityNode)), node.modifier);
                        log   += node.personalityNode.defName + "+: " + chance.ToString() + ", ";
                    }
                    else
                    {
                        chance = chance * Mathf.Pow(Mathf.Lerp(0.5f, 1.5f, Mathf.Abs(1 - PsycheHelper.Comp(recipient).Psyche.GetPersonalityRating(node.personalityNode))), Mathf.Abs(node.modifier));
                        log   += node.personalityNode.defName + "-: " + chance.ToString() + ", ";
                    }
                }
            }
            for (int i = 0; i < flirtReaction.traitModifiers.Count(); i++)
            {
                if (recipient.story.traits.HasTrait(flirtReaction.traitModifiers[i].trait))
                {
                    chance *= flirtReaction.traitModifiers[i].modifier;
                    log    += flirtReaction.traitModifiers[i].trait.defName + " " + chance.ToString() + ", ";
                }
            }

            /*
             * if (flirtReaction.successful == true)
             * {
             *  chance *= initiator.GetStatValue(StatDefOf.SocialImpact);
             *  log += "social impact: " + chance.ToString() + ", ";
             *  //chance *= recipientCircumstances;
             * }*/
            log += "end.";
            LogFlirt(log);
            return(chance);
        }
Esempio n. 8
0
        public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef)
        {
            ///Stitched in from Psychology.
            Thought         thought  = this.RandomBreakupReason(initiator, recipient);
            PawnRelationDef relation = RelationshipUtility.MostAdvancedRelationshipBetween(initiator, recipient);

            if (initiator.relations.DirectRelationExists(PawnRelationDefOf.Spouse, recipient))
            {
                BreakupUtility.RelationToEx(initiator, recipient, PawnRelationDefOf.Spouse);
                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
            {
                BreakupUtility.ResolveBreakup(initiator, recipient, RelationshipUtility.MostAdvancedRelationshipBetween(initiator, recipient));
            }
            //Idea - who gets the bedroom? Could be interesting.
            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();

            if (RelationshipUtility.IsInformalRelationship(relation))
            {
                stringBuilder.AppendLine("LetterInformalRelationsEnds".Translate(initiator.Named("PAWN1"), recipient.Named("PAWN2")));
                letterDef   = LetterDefOf.NeutralEvent;
                letterLabel = "LetterLabelInformalRelationsEnds".Translate();
            }
            else
            {
                stringBuilder.AppendLine("LetterNoLongerLovers".Translate(initiator.LabelShort, recipient.LabelShort, initiator.Named("PAWN1"), recipient.Named("PAWN2")));
                letterDef   = LetterDefOf.NegativeEvent;
                letterLabel = "LetterLabelBreakup".Translate();
            }

            if (thought != null)
            {
                stringBuilder.AppendLine();
                stringBuilder.AppendLine("FinalStraw".Translate(thought.CurStage.label.CapitalizeFirst()));
            }
            if (PawnUtility.ShouldSendNotificationAbout(initiator) || PawnUtility.ShouldSendNotificationAbout(recipient))
            {
                letterDef   = null;
                letterLabel = null;
                letterText  = null;
            }
            else if (RelationshipUtility.IsInformalRelationship(relation) && GradualRomanceMod.informalRomanceLetters == false)
            {
                letterDef   = null;
                letterLabel = null;
                letterText  = null;
            }
            else
            {
                letterText = stringBuilder.ToString();
            }
        }
        public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
        {
            PawnRelationDef pawnRelation = RelationshipUtility.MostAdvancedRelationshipBetween(initiator, recipient);

            if (!AttractionUtility.QuickCheck(initiator, recipient))
            {
                return(0f);
            }
            if (GradualRomanceMod.SeductionMode == GradualRomanceMod.SeductionModeSetting.NoSeduction)
            {
                return(0f);
            }
            else if (GradualRomanceMod.SeductionMode == GradualRomanceMod.SeductionModeSetting.OnlyRelationship)
            {
                if (pawnRelation == null || !RelationshipUtility.IsSexualRelationship(pawnRelation))
                {
                    return(0f);
                }
            }
            else if (GradualRomanceMod.SeductionMode == GradualRomanceMod.SeductionModeSetting.RelationshipAndNonColonists)
            {
                if (pawnRelation == null && recipient.IsColonist)
                {
                    return(0f);
                }
                if (pawnRelation != null && !RelationshipUtility.IsSexualRelationship(pawnRelation) && recipient.IsColonist)
                {
                    return(0f);
                }
            }

            //shouldn't seduce if you can't move
            if (initiator.health.capacities.GetLevel(PawnCapacityDefOf.Consciousness) <= 0.5f || initiator.health.capacities.GetLevel(PawnCapacityDefOf.Moving) <= 0.25f)
            {
                return(0f);
            }
            if (recipient.health.capacities.GetLevel(PawnCapacityDefOf.Consciousness) <= 0.5f || recipient.health.capacities.GetLevel(PawnCapacityDefOf.Moving) <= 0.25f)
            {
                return(0f);
            }
            //shouldn't seduce while working
            TimeAssignmentDef initiatorAssignment = initiator.timetable.GetAssignment(GenLocalDate.HourOfDay(initiator.Map));
            TimeAssignmentDef recipientAssignment = recipient.timetable.GetAssignment(GenLocalDate.HourOfDay(recipient.Map));

            if (initiatorAssignment != TimeAssignmentDefOf.Joy || initiatorAssignment != TimeAssignmentDefOf.Anything)
            {
                return(0f);
            }
            if (recipientAssignment != TimeAssignmentDefOf.Joy || recipientAssignment != TimeAssignmentDefOf.Anything)
            {
                return(0f);
            }
            EmptyReasons();
            AttractionFactorDef whoCares;

            initiatorAttraction = AttractionUtility.CalculateAttraction(initiator, recipient, false, false, out veryLowInitiatorReasons, out lowInitiatorReasons, out highInitiatorReasons, out veryHighInitiatorReasons, out whoCares);
            float tensionFactor = 1.33f * RelationshipUtility.LevelOfSexualTension(initiator, recipient);

            tensionFactor = Mathf.Max(1f, tensionFactor);
            lastInitiator = initiator;
            lastRecipient = recipient;
            return(GradualRomanceMod.BaseSeductionChance * initiatorAttraction * tensionFactor * AttractionUtility.PropensityToSeduce(initiator));
        }