Пример #1
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);
        }
Пример #2
0
 private static float RelationshipFactorForFlirtStyle(PawnRelationDef relation, FlirtStyleDef flirtStyle)
 {
     if (relation == PawnRelationDefOf.Spouse || relation == PawnRelationDefOf.ExSpouse)
     {
         return(flirtStyle.spouseFactor);
     }
     if (relation == PawnRelationDefOf.Fiance || relation == PawnRelationDefOf.Lover || relation == PawnRelationDefOf.ExLover)
     {
         return(flirtStyle.loverFactor);
     }
     if (relation == PawnRelationDefOfGR.Lovefriend || relation == PawnRelationDefOfGR.ExLovefriend || relation == PawnRelationDefOfGR.Paramour)
     {
         return(flirtStyle.lovefriendFactor);
     }
     if (relation == PawnRelationDefOfGR.Lovebuddy)
     {
         return(flirtStyle.loveBuddyFactor);
     }
     if (relation == PawnRelationDefOfGR.Sweetheart)
     {
         return(flirtStyle.sweetheartFactor);
     }
     return(flirtStyle.acquaitanceFactor);
 }
Пример #3
0
        private float CalculateFlirtStyleWeight(FlirtStyleDef flirtStyle, Pawn pawn, Pawn other)
        {
            string flirtLog = pawn.Name.ToStringShort + " => " + other.Name.ToStringShort + " considers " + flirtStyle.defName + ": ";

            //if a pawn has a canceling trait, we abort immediately
            for (int i = 0; i < flirtStyle.cancelingTraits.Count(); i++)
            {
                if (pawn.story.traits.HasTrait(flirtStyle.cancelingTraits[i]))
                {
                    flirtLog += "canceled by " + flirtStyle.cancelingTraits[i].defName + ".";
                    LogFlirt(flirtLog);
                    return(0f);
                }
            }
            //we start with base weight chance
            float weight = flirtStyle.baseChance;

            //add relationship factor
            weight   *= RelationshipFactorForFlirtStyle(RelationshipUtility.MostAdvancedRomanceOrExStage(pawn, other), flirtStyle);
            flirtLog += "base " + weight.ToString() + " ";
            //calculate attraction factors

            /*
             * weight *= recipientPhysicalAttraction * flirtStyle.baseSexiness;
             * flirtLog += "physical " + weight.ToString() + " ";
             * weight *= recipientRomanticAttraction * flirtStyle.baseRomance;
             * flirtLog += "romantic " + weight.ToString() + " ";
             * weight *= recipientSocialAttraction * flirtStyle.baseLogic;
             * flirtLog += "logical " + weight.ToString() + " ";
             */


            //calculate promoting traits
            for (int i = 0; i < flirtStyle.traitModifiers.Count(); i++)
            {
                if (pawn.story.traits.HasTrait(flirtStyle.traitModifiers[i].trait))
                {
                    weight    = weight * flirtStyle.traitModifiers[i].modifier;
                    flirtLog += flirtStyle.traitModifiers[i].trait.defName + ": " + weight.ToString() + " ";
                }
            }
            if (PsycheHelper.PsychologyEnabled(pawn) && GradualRomanceMod.AttractionCalculation == GradualRomanceMod.AttractionCalculationSetting.Complex)
            {
                //calculate contributing personality traits
                for (int i = 0; i < flirtStyle.moreLikelyPersonalities.Count(); i++)
                {
                    PersonalityNodeModifier currentModifier = flirtStyle.moreLikelyPersonalities[i];
                    weight    = weight * Mathf.Pow(Mathf.Lerp(0.5f, 1.5f, PsycheHelper.Comp(pawn).Psyche.GetPersonalityRating(currentModifier.personalityNode)), currentModifier.modifier);
                    flirtLog += currentModifier.personalityNode.defName + "+: " + weight.ToString() + " ";
                }
                for (int i = 0; i < flirtStyle.lessLikelyPersonalities.Count(); i++)
                {
                    PersonalityNodeModifier currentModifier = flirtStyle.lessLikelyPersonalities[i];
                    weight    = weight * Mathf.Pow(Mathf.Lerp(0.5f, 1.5f, Mathf.Abs(1 - PsycheHelper.Comp(pawn).Psyche.GetPersonalityRating(currentModifier.personalityNode))), currentModifier.modifier);
                    flirtLog += currentModifier.personalityNode.defName + "-: " + weight.ToString() + " ";
                }
            }
            if (flirtStyle.incompetent)
            {
                weight   *= pressureCache;
                flirtLog += "pressure: " + weight.ToString() + " ";
            }

            flirtLog += "end.";
            LogFlirt(flirtLog);
            return(weight);
        }