Ejemplo n.º 1
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 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 romance characters with which they have a mild relationship
            if (!RelationshipUtility.HasInformalRelationship(initiator, recipient))
            {
                return(0f);
            }
            //Pawns won't hit on their spouses.
            if (LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient))
            {
                return(0f);
            }
            //Codependents won't romance anyone if they are in a relationship
            if (LovePartnerRelationUtility.HasAnyLovePartner(initiator) && initiator.story.traits.HasTrait(TraitDefOfPsychology.Codependent))
            {
                return(0f);
            }
            //Only lechers will romance someone that has less than +5 opinion of them
            if (recipient.relations.OpinionOf(initiator) < 5 && !initiator.story.traits.HasTrait(TraitDefOfPsychology.Lecher))
            {
                return(0f);
            }
            //People only hit on people if they would consider a formal relationship with them.
            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);
            }
            int   opinion       = initiator.relations.OpinionOf(recipient);
            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 romance is based on how Aggressive and Romantic they are.
                float personalityFactor = Mathf.Pow(20f, PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Aggressive)) * Mathf.Pow(12f, (1f - PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic)));
                romanceChance *= personalityFactor * 0.02f;
            }
            //If their 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.4f;
            }
            lastInitiator = initiator;
            lastRecipient = recipient;

            return(romanceChance * attractiveness);
        }