Exemplo n.º 1
0
        public override float Calculate(Pawn observer, Pawn assessed)
        {
            float affairReluctance  = 1f;
            float affairReluctance2 = 1f;

            if (observerCuckold != null)
            {
                affairReluctance  = GRPawnRelationUtility.AffairReluctance(GRPawnRelationUtility.MostAdvancedRelationshipBetween(observer, observerCuckold));
                affairReluctance *= Mathf.Pow(Mathf.InverseLerp(-100f, 5f, observer.relations.OpinionOf(observerCuckold)), -0.33f);
            }
            if (assessedCuckold != null)
            {
                affairReluctance2  = GRPawnRelationUtility.AffairReluctance(GRPawnRelationUtility.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 && GRPawnRelationUtility.MostAdvancedRelationshipBetween(pawn, partner) != null && GRPawnRelationUtility.ShouldShareBed(pawn, partner) == false
                                             select partner;

            if (bedPartners.Count() == 0)
            {
                return(ThoughtState.Inactive);
            }
            else
            {
                return(ThoughtState.ActiveAtStage(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 = GRPawnRelationUtility.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, GRPawnRelationUtility.MostAdvancedRelationshipBetween(initiator, recipient));
            }
            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 (GRPawnRelationUtility.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 (GRPawnRelationUtility.IsInformalRelationship(relation) && GradualRomanceMod.informalRomanceLetters == false)
            {
                letterDef   = null;
                letterLabel = null;
                letterText  = null;
            }
            else
            {
                letterText = stringBuilder.ToString();
            }
        }
Exemplo n.º 4
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 (GRPawnRelationUtility.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);
        }