protected override ThoughtState CurrentSocialStateInternal(Pawn pawn, Pawn other)
 {
     if (!other.RaceProps.Humanlike || !RelationsUtility.PawnsKnowEachOther(pawn, other))
     {
         return(false);
     }
     else if (pawn.def.GetModExtension <XenoRomanceExtension>().faceCategory != pawn.def.GetModExtension <XenoRomanceExtension>().faceCategory)
     {
         return(false);
     }
     else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight))
     {
         return(false);
     }
     else
     {
         int num = other.story.traits.DegreeOfTrait(TraitDefOf.Beauty);
         if (num == -1)
         {
             return(ThoughtState.ActiveAtStage(0));
         }
         else if (num == -2)
         {
             return(ThoughtState.ActiveAtStage(1));
         }
         else if (num == -3)
         {
             return(ThoughtState.ActiveAtStage(2));
         }
         else if (num == -4)
         {
             return(ThoughtState.ActiveAtStage(3));
         }
         else
         {
             return(false);
         }
     }
 }
 protected override ThoughtState CurrentSocialStateInternal(Pawn pawn, Pawn other)
 {
     if (pawn != null && other != null)
     {
         if (!other.RaceProps.Humanlike || other.Dead)
         {
             return(false);
         }
         if (!RelationsUtility.PawnsKnowEachOther(pawn, other))
         {
             return(false);
         }
         if (pawn.RaceProps.Humanlike && other.RaceProps.Humanlike)
         {
             if (TM_Calc.IsMightUser(pawn) && !pawn.story.traits.HasTrait(TorannMagicDefOf.TM_BoundlessTD) && other.story.traits.HasTrait(TorannMagicDefOf.TM_BoundlessTD))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        protected override ThoughtState CurrentSocialStateInternal(Pawn p, Pawn other)
        {
            if (!other.RaceProps.Humanlike)
            {
                return(false);
            }
            if (!RelationsUtility.PawnsKnowEachOther(p, other))
            {
                return(false);
            }
            Predicate <Tale> validator = delegate(Tale t)
            {
                return(other == t.DominantPawn);
            };
            var tale = VSIE_Utils.GetLatestTale(this.def.taleDef, validator);

            if (tale != null)
            {
                return(true);
            }
            return(false);
        }
 protected override ThoughtState CurrentSocialStateInternal(Pawn pawn, Pawn other)
 {
     if (pawn != null && other != null)
     {
         if (!other.RaceProps.Humanlike || other.Dead)
         {
             return(false);
         }
         if (!RelationsUtility.PawnsKnowEachOther(pawn, other))
         {
             return(false);
         }
         if (pawn.RaceProps.Humanlike && other.RaceProps.Humanlike)
         {
             if ((pawn.story.traits.HasTrait(TorannMagicDefOf.Paladin) || pawn.story.traits.HasTrait(TorannMagicDefOf.Druid) || pawn.story.traits.HasTrait(TorannMagicDefOf.Priest)) && other.story.traits.HasTrait(TorannMagicDefOf.Necromancer))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 5
0
        protected override ThoughtState CurrentSocialStateInternal(Pawn pawn, Pawn other)
        {
            if (pawn != null && other != null)
            {
                if (!other.RaceProps.Humanlike || other.Dead)
                {
                    return(false);
                }
                if (!RelationsUtility.PawnsKnowEachOther(pawn, other))
                {
                    return(false);
                }
                if (pawn.story.traits.HasTrait(TorannMagicDefOf.Undead) || pawn.story.traits.HasTrait(TorannMagicDefOf.Lich) || pawn.story.traits.HasTrait(TraitDefOf.Transhumanist) || pawn.story.traits.HasTrait(TorannMagicDefOf.Enchanter))
                {
                    return(false);
                }
                if (other.health.hediffSet.HasHediff(TorannMagicDefOf.TM_EnchantedBodyHD, false))
                {
                    CompAbilityUserMagic comp = other.GetComp <CompAbilityUserMagic>();

                    if (comp != null)
                    {
                        if (pawn.story.traits.HasTrait(TraitDefOf.BodyPurist))
                        {
                            return(ThoughtState.ActiveAtStage(6));
                        }
                        else if (pawn.story.traits.HasTrait(TraitDefOf.Transhumanist))
                        {
                            return(ThoughtState.ActiveAtStage(5));
                        }
                        else
                        {
                            return(ThoughtState.ActiveAtStage(comp.MagicData.MagicPowerSkill_EnchantedBody.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_EnchantedBody_pwr").level));
                        }
                    }
                }
            }
            return(false);
        }
Exemplo n.º 6
0
        protected override ThoughtState CurrentSocialStateInternal(Pawn p, Pawn other)
        {
            if (!other.RaceProps.Humanlike)
            {
                return(false);
            }
            if (!RelationsUtility.PawnsKnowEachOther(p, other))
            {
                return(false);
            }
            Predicate <Tale_DoublePawn> validator = delegate(Tale_DoublePawn t)
            {
                return(t.firstPawnData.pawn.relations.GetDirectRelation(PawnRelationDefOf.Bond, p) != null && t.secondPawnData.pawn == other);
            };
            var tale = VSIE_Utils.GetLatestDoublePawnTale(def.taleDef, validator);

            if (tale != null)
            {
                return(true);
            }
            return(false);
        }
 protected override ThoughtState CurrentSocialStateInternal(Pawn pawn, Pawn other)
 {
     if (pawn != null && other != null)
     {
         if (!other.RaceProps.Humanlike || other.Dead)
         {
             return(false);
         }
         if (!RelationsUtility.PawnsKnowEachOther(pawn, other))
         {
             return(false);
         }
         if (pawn.story.traits.HasTrait(TorannMagicDefOf.Undead))
         {
             return(false);
         }
         if (other.story.traits.HasTrait(TorannMagicDefOf.Succubus))
         {
             if (pawn.story.traits.HasTrait(TorannMagicDefOf.Succubus) || pawn.gender == Gender.Male)
             {
                 return(false);
             }
             if (pawn.gender == Gender.Female && !pawn.story.traits.HasTrait(TraitDefOf.Gay))
             {
                 int num = pawn.story.traits.DegreeOfTrait(TraitDefOf.Beauty);
                 if (num >= 1)
                 {
                     return(ThoughtState.ActiveAtStage(1));
                 }
                 else
                 {
                     return(ThoughtState.ActiveAtStage(0));
                 }
             }
         }
     }
     return(false);
 }
Exemplo n.º 8
0
        protected override ThoughtState CurrentSocialStateInternal(Pawn p, Pawn otherPawn)
        {
            if (!RelationsUtility.PawnsKnowEachOther(p, otherPawn))
            {
                return(false);
            }
            float time = p.records.GetValue(RecordDefOf.TimeAsColonistOrColonyAnimal);

            if (time >= GenDate.TicksPerYear)
            {
                float otherTime = otherPawn.records.GetValue(RecordDefOf.TimeAsColonistOrColonyAnimal);
                if (time >= (GenDate.TicksPerYear * 6) && otherTime >= (GenDate.TicksPerYear * 6))
                {
                    return(ThoughtState.ActiveAtStage(5));
                }
                if (time >= (GenDate.TicksPerYear * 5) && otherTime >= (GenDate.TicksPerYear * 5))
                {
                    return(ThoughtState.ActiveAtStage(4));
                }
                if (time >= (GenDate.TicksPerYear * 4) && otherTime >= (GenDate.TicksPerYear * 4))
                {
                    return(ThoughtState.ActiveAtStage(3));
                }
                if (time >= (GenDate.TicksPerYear * 3) && otherTime >= (GenDate.TicksPerYear * 3))
                {
                    return(ThoughtState.ActiveAtStage(2));
                }
                if (time >= (GenDate.TicksPerYear * 2) && otherTime >= (GenDate.TicksPerYear * 2))
                {
                    return(ThoughtState.ActiveAtStage(1));
                }
                if (otherTime >= (GenDate.TicksPerYear * 1))
                {
                    return(ThoughtState.ActiveAtStage(0));
                }
            }
            return(ThoughtState.Inactive);
        }
        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);
        }
Exemplo n.º 10
0
 protected override ThoughtState CurrentSocialStateInternal(Pawn pawn, Pawn other)
 {
     if (pawn != null && other != null)
     {
         if (!other.RaceProps.Humanlike || other.Dead)
         {
             return(false);
         }
         if (!RelationsUtility.PawnsKnowEachOther(pawn, other))
         {
             return(false);
         }
         if (!other.story.traits.HasTrait(TorannMagicDefOf.Undead))
         {
             return(false);
         }
         if (pawn.story.traits.HasTrait(TorannMagicDefOf.Necromancer) || pawn.story.traits.HasTrait(TorannMagicDefOf.Lich) || pawn.story.traits.HasTrait(TraitDefOf.Psychopath) || pawn.story.traits.HasTrait(TraitDefOf.Bloodlust) || pawn.story.traits.HasTrait(TraitDef.Named("M*******t")))
         {
             return(false);
         }
     }
     return(true);
 }
        protected override ThoughtState CurrentSocialStateInternal(Pawn pawn, Pawn other)
        {
            bool pawn_is_apini = false;
            bool other_pawn_is_apini = false;
            //PawnKindDef apini_kind_def = ApiniDefOf.ApiniPlayer;
            //if (apini_kind_def == null)
            //    return false;
            if (pawn.kindDef.IsApini())
            {
                pawn_is_apini = true;
            }
            if (other.kindDef.IsApini())
            {
                other_pawn_is_apini = true;
            }
            if (!other.RaceProps.Humanlike || !RelationsUtility.PawnsKnowEachOther(pawn, other))
            {
                return false;
            }
            //TraitDef trait_def = ApiniDefOf.ApiniHiveDiscord;
            TraitDef trait_def = null;
            if (trait_def == null)
                return false;

            if (other.story.traits.HasTrait(trait_def))
            {
                if(pawn_is_apini)
                {
                    if (other_pawn_is_apini)
                        return ThoughtState.ActiveAtStage(1);
                    else
                        return ThoughtState.ActiveAtStage(0);
                }
            }

            return false;
        }
Exemplo n.º 12
0
        public static int LovinLevel(Pawn pawn, Pawn partner)
        {
            // get pawns fertility stat, manipulation stat and mutual attraction to generate a random lovin' experience
            var performance = pawn.health.capacities.GetLevel(PawnCapacityDefOf.Reproduction) *
                              partner.health.capacities.GetLevel(PawnCapacityDefOf.Reproduction) *
                              pawn.health.capacities.GetLevel(RimWorld.PawnCapacityDefOf.Manipulation) *
                              partner.health.capacities.GetLevel(RimWorld.PawnCapacityDefOf.Manipulation);

            // talking helps if positive, otherwise _shut up_.
            performance *= Mathf.Max(1f, partner.health.capacities.GetLevel(RimWorld.PawnCapacityDefOf.Talking)) *
                           Mathf.Max(1f, pawn.health.capacities.GetLevel(RimWorld.PawnCapacityDefOf.Talking));

            // opinion factors in too
            performance *= (pawn.relations.OpinionOf(partner) / 100f) + 1f; // opinion is on a -100 -- 100 scale, divide by 100, add 1 to get a 0, 2 scale

            // note; while I believe attraction should factor in heavily, the main proxy variables we have available are
            // traits, age, skinColor and gender. These are largely the factors that went into generating the relationship
            // in the first place, and - with the exception of traits - I don't feel they should have much effect on the success of lovin`
            if (pawn.health.capacities.CapableOf(RimWorld.PawnCapacityDefOf.Sight))
            {
                if (RelationsUtility.IsDisfigured(partner))
                {
                    performance *= .8f;
                }
                performance *= (partner.story.traits.DegreeOfTrait(TraitDefOf.Beauty) / 10f) + 1;
                // 2 = beautiful, 1 = pretty, 0 = inactive. / 10 + 1 gives 1 - 1.4 scale.
            }

            // we now have a number. Lets get another number with an N(2,.5) distribution, multiply with our number,
            // and floor it. That will give us a number from 0-3, corresponding to the stages of the thoughtdef.
            var random           = RandomNormal(2, .5f);
            int performanceLevel = Mathf.FloorToInt(random * performance);

            performanceLevel = Mathf.Clamp(performanceLevel, 0, 3);

            return(performanceLevel);
        }
 protected override ThoughtState CurrentSocialStateInternal(Pawn p, Pawn other)
 {
     if (!p.RaceProps.Humanlike)
     {
         return((ThoughtState)false);
     }
     if (!p.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart))
     {
         return((ThoughtState)false);
     }
     if (!other.RaceProps.Humanlike)
     {
         return((ThoughtState)false);
     }
     if (!RelationsUtility.PawnsKnowEachOther(p, other))
     {
         return((ThoughtState)false);
     }
     if (!other.story.traits.HasTrait(TraitDefOf.Psychopath))
     {
         return((ThoughtState)false);
     }
     return((ThoughtState)true);
 }
Exemplo n.º 14
0
        protected override ThoughtState CurrentSocialStateInternal(Pawn p, Pawn other)
        {
            if (!p.RaceProps.Humanlike)
            {
                return((ThoughtState)false);
            }

            if (!RelationsUtility.PawnsKnowEachOther(p, other))
            {
                return((ThoughtState)false);
            }

            Religion thisPawnReligion  = p.GetReligionComponent().Religion;
            Religion otherPawnReligion = other.GetReligionComponent().Religion;

            ReligionSettings_Social opinionSettings = thisPawnReligion.GetSettings <ReligionSettings_Social>(SettingsTagDefOf.OpinionTag);

            if (opinionSettings == null)
            {
                return((ThoughtState)false);
            }

            if (otherPawnReligion.GroupTag == null)
            {
                return((ThoughtState)false);
            }

            ReligionProperty property = opinionSettings.GetPropertyByObject(p, otherPawnReligion.GroupTag, other);

            if (property == null || property.Witness == null || property.Witness.OpinionThought == null || property.Witness.OpinionThought != this.def)
            {
                return((ThoughtState)false);
            }

            return(ThoughtState.ActiveAtStage(p.GetReligionComponent().PietyTracker.PietyNeed.CurCategoryInt, otherPawnReligion.GroupTag.LabelCap));
        }
Exemplo n.º 15
0
 public static int GetEnemiesInColony(this Pawn guest)
 {
     return(GetPawnsFromBase(guest.MapHeld).Where(p => RelationsUtility.PawnsKnowEachOther(guest, p) && guest.relations.OpinionOf(p) <= MaxOpinionForEnemy).Sum(p => GetRelationValue(p, guest)));
 }
Exemplo n.º 16
0
        public static int GetFriendsSeniorityInColony(this Pawn guest)
        {
            float requiredOpinion = GetMinRecruitOpinion(guest);

            return(GetPawnsFromBase(guest.MapHeld).Where(p => p.royalty?.MostSeniorTitle != null && RelationsUtility.PawnsKnowEachOther(guest, p) && guest.relations.OpinionOf(p) >= requiredOpinion).Sum(pawn => pawn.royalty.MostSeniorTitle.def.seniority));
        }
Exemplo n.º 17
0
        public static int GetFriendsInColony(this Pawn guest)
        {
            float requiredOpinion = GetMinRecruitOpinion(guest);

            return(GetPawnsFromBase(guest.MapHeld).Where(p => RelationsUtility.PawnsKnowEachOther(guest, p) && guest.relations.OpinionOf(p) >= requiredOpinion).Sum(pawn => GetRelationValue(pawn, guest)));
        }
Exemplo n.º 18
0
 protected override ThoughtState CurrentSocialStateInternal(Pawn p, Pawn otherPawn) =>
 p.def != otherPawn.def && p.RaceProps.Humanlike && otherPawn.RaceProps.Humanlike && RelationsUtility.PawnsKnowEachOther(p1: p, p2: otherPawn) &&
 !(otherPawn.def is ThingDef_AlienRace par && par.alienRace.generalSettings.notXenophobistTowards.Contains(item: p.def.defName)) &&
Exemplo n.º 19
0
 protected override ThoughtState CurrentSocialStateInternal(Pawn p, Pawn otherPawn) =>
 p.RaceProps.Humanlike && otherPawn.RaceProps.Humanlike && p.story.traits.HasTrait(tDef: AlienDefOf.Xenophobia) && otherPawn.story.traits.HasTrait(tDef: AlienDefOf.Xenophobia) &&
 p.story.traits.DegreeOfTrait(tDef: AlienDefOf.Xenophobia) != otherPawn.story.traits.DegreeOfTrait(tDef: AlienDefOf.Xenophobia) && RelationsUtility.PawnsKnowEachOther(p1: p, p2: otherPawn);
Exemplo n.º 20
0
        // Token: 0x0600002F RID: 47 RVA: 0x00002870 File Offset: 0x00000A70
        public static void DoTend(Pawn doctor, Pawn patient, Cloakgen medkit)
        {
            bool flag = patient.health.HasHediffsNeedingTend(false);

            if (flag)
            {
                bool flag2 = medkit != null && medkit.Destroyed;
                if (flag2)
                {
                    Log.Warning("Tried to use destroyed medkit.", false);
                    medkit = null;
                }
                float num = HealthShardTendUtility.CalculateBaseTendQuality(doctor, patient, medkit.kitComp.Props.medicine ?? null);
                HealthShardTendUtility.GetOptimalHediffsToTendWithSingleTreatment(patient, medkit.kitComp.Props.medicine != null, HealthShardTendUtility.tmpHediffsToTend, null);
                for (int i = 0; i < HealthShardTendUtility.tmpHediffsToTend.Count; i++)
                {
                    HealthShardTendUtility.tmpHediffsToTend[i].Tended(num, i);
                }
                bool flag3 = doctor != null && doctor.Faction == Faction.OfPlayer && patient.Faction != doctor.Faction && !patient.IsPrisoner && patient.Faction != null;
                if (flag3)
                {
                    patient.mindState.timesGuestTendedToByPlayer++;
                }
                bool flag4 = doctor != null && doctor.IsColonistPlayerControlled;
                if (flag4)
                {
                    patient.records.AccumulateStoryEvent(StoryEventDefOf.TendedByPlayer);
                }
                bool flag5 = doctor != null && doctor.RaceProps.Humanlike && patient.RaceProps.Animal;
                if (flag5)
                {
                    bool flag6 = RelationsUtility.TryDevelopBondRelation(doctor, patient, 0.004f);
                    if (flag6)
                    {
                        bool flag7 = doctor.Faction != null && doctor.Faction != patient.Faction;
                        if (flag7)
                        {
                            InteractionWorker_RecruitAttempt.DoRecruit(doctor, patient, 1f, false);
                        }
                    }
                }
                patient.records.Increment(RecordDefOf.TimesTendedTo);
                bool flag8 = doctor != null;
                if (flag8)
                {
                    doctor.records.Increment(RecordDefOf.TimesTendedOther);
                }
                bool flag9 = doctor == patient && !doctor.Dead;
                if (flag9)
                {
                    doctor.mindState.Notify_SelfTended();
                }
                bool flag10 = medkit.kitComp.Props.medicine != null;
                if (flag10)
                {
                    bool flag11 = patient.Spawned || (doctor != null && doctor.Spawned);
                    if (flag11)
                    {
                        bool flag12 = medkit.kitComp.Props.medicine != null && StatExtension.GetStatValueAbstract(medkit.kitComp.Props.medicine, StatDefOf.MedicalPotency, null) > StatExtension.GetStatValueAbstract(ThingDefOf.MedicineIndustrial, StatDefOf.MedicalPotency, null);
                        if (flag12)
                        {
                            SoundStarter.PlayOneShot(SoundDefOf.TechMedicineUsed, new TargetInfo(patient.Position, patient.Map, false));
                        }
                    }
                }
            }
        }
Exemplo n.º 21
0
        public static void DoRecruitAlien(Pawn recruiter, Pawn recruitee, float recruitChance, bool useAudiovisualEffects = true)
        {
            string text = recruitee.LabelIndefinite();

            if (recruitee.guest != null)
            {
                recruitee.guest.SetGuestStatus(null, false);
            }
            bool flag = recruitee.Name != null;

            if (recruitee.Faction != recruiter.Faction)
            {
                if (recruitee.kindDef.race.ToString().Contains("Alien"))
                {
                    Log.Message("RecruitingAlienPawn");
                    var       x             = recruitee.kindDef;
                    AlienPawn temprecruitee = recruitee as AlienPawn;
                    temprecruitee.SetFaction(recruiter.Faction, recruiter);
                    temprecruitee.kindDef = x;
                    Log.Message("Pawn Converted to Kind:  " + recruitee.kindDef.race.ToString());
                }
                else
                {
                    recruitee.SetFaction(recruiter.Faction, recruiter);
                }
            }
            if (recruitee.RaceProps.Humanlike)
            {
                if (useAudiovisualEffects)
                {
                    Find.LetterStack.ReceiveLetter("LetterLabelMessageRecruitSuccess".Translate(), "MessageRecruitSuccess".Translate(new object[]
                    {
                        recruiter,
                        recruitee,
                        recruitChance.ToStringPercent()
                    }), LetterType.Good, recruitee, null);
                }
                TaleRecorder.RecordTale(TaleDefOf.Recruited, new object[]
                {
                    recruiter,
                    recruitee
                });
                recruiter.records.Increment(RecordDefOf.PrisonersRecruited);
                recruitee.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOf.RecruitedMe, recruiter);
            }
            else
            {
                if (useAudiovisualEffects)
                {
                    if (!flag)
                    {
                        Messages.Message("MessageTameAndNameSuccess".Translate(new object[]
                        {
                            recruiter.LabelShort,
                            text,
                            recruitChance.ToStringPercent(),
                            recruitee.Name.ToStringFull
                        }).AdjustedFor(recruitee), recruitee, MessageSound.Benefit);
                    }
                    else
                    {
                        Messages.Message("MessageTameSuccess".Translate(new object[]
                        {
                            recruiter.LabelShort,
                            text,
                            recruitChance.ToStringPercent()
                        }), recruitee, MessageSound.Benefit);
                    }
                    MoteMaker.ThrowText((recruiter.DrawPos + recruitee.DrawPos) / 2f, "TextMote_TameSuccess".Translate(new object[]
                    {
                        recruitChance.ToStringPercent()
                    }), 8f);
                }
                recruiter.records.Increment(RecordDefOf.AnimalsTamed);
                RelationsUtility.TryDevelopBondRelation(recruiter, recruitee, 0.05f);
                float num = Mathf.Lerp(0.02f, 1f, recruitee.RaceProps.wildness);
                if (Rand.Value < num)
                {
                    TaleRecorder.RecordTale(TaleDefOf.TamedAnimal, new object[]
                    {
                        recruiter,
                        recruitee
                    });
                }
            }
            if (recruitee.caller != null)
            {
                recruitee.caller.DoCall();
            }
        }
Exemplo n.º 22
0
        public static void DoTend(Pawn doctor, Pawn patient, Thing medicine)
        {
            if (patient.health.HasHediffsNeedingTend(false))
            {
                if (medicine != null && medicine.Destroyed)
                {
                    Log.Warning("Tried to use destroyed repair kit.", false);
                    medicine = null;
                }

                //float quality = 1f; //CalculateBaseTendQuality
                GetOptimalHediffsToTendWithSingleTreatment(patient, medicine != null, tmpHediffsToTend, null);

                for (int i = 0; i < tmpHediffsToTend.Count; i++)
                {
                    //tmpHediffsToTend[i].Tended(quality, i);
                    if (medicine == null)
                    {
                        tmpHediffsToTend[i].Tended(0.1f, i);
                    }
                    else
                    {
                        patient.health.RemoveHediff(tmpHediffsToTend[i]);
                    }
                }
                if (doctor != null && doctor.Faction == Faction.OfPlayer && patient.Faction != doctor.Faction && !patient.IsPrisoner && patient.Faction != null)
                {
                    patient.mindState.timesGuestTendedToByPlayer++;
                }
                if (doctor != null && doctor.IsColonistPlayerControlled)
                {
                    patient.records.AccumulateStoryEvent(StoryEventDefOf.TendedByPlayer);
                }
                if (doctor != null && doctor.RaceProps.Humanlike && patient.RaceProps.Animal)
                {
                    if (RelationsUtility.TryDevelopBondRelation(doctor, patient, 0.004f))
                    {
                        if (doctor.Faction != null && doctor.Faction != patient.Faction)
                        {
                            InteractionWorker_RecruitAttempt.DoRecruit(doctor, patient, 1f, false);
                        }
                    }
                }
                patient.records.Increment(RecordDefOf.TimesTendedTo);
                if (doctor != null)
                {
                    doctor.records.Increment(RecordDefOf.TimesTendedOther);
                }
                if (doctor == patient && !doctor.Dead)
                {
                    doctor.mindState.Notify_SelfTended();
                }
                if (medicine != null)
                {
                    if (patient.Spawned || (doctor != null && doctor.Spawned))
                    {
                        //if (medicine != null && medicine.GetStatValue(StatDefOf.MedicalPotency, true) > RimWorld.ThingDefOf.MedicineIndustrial.GetStatValueAbstract(StatDefOf.MedicalPotency, null))
                        {
                            SoundDefOf.Building_Complete.PlayOneShot(new TargetInfo(patient.Position, patient.Map, false));
                        }
                    }
                    if (medicine.stackCount > 1)
                    {
                        medicine.stackCount--;
                    }
                    else if (!medicine.Destroyed)
                    {
                        medicine.Destroy(DestroyMode.Vanish);
                    }
                }
            }
        }
Exemplo n.º 23
0
 public static int GetRoyalEnemiesSeniorityInColony(this Pawn guest)
 {
     return(GetPawnsFromBase(guest.MapHeld).Where(p => p.royalty?.MostSeniorTitle != null && RelationsUtility.PawnsKnowEachOther(guest, p) && guest.relations.OpinionOf(p) <= MaxOpinionForEnemy).Sum(p => p.royalty.MostSeniorTitle.def.seniority));
 }
Exemplo n.º 24
0
        internal static void _DoTend(Pawn doctor, Pawn patient, Medicine medicine)
        {
            if (!patient.health.HasHediffsNeedingTend(false))
            {
                return;
            }
            if (medicine != null && medicine.Destroyed)
            {
                Log.Warning("Tried to use destroyed medicine.");
                medicine = null;
            }
            float        num          = (medicine == null) ? 0.2f : medicine.def.GetStatValueAbstract(StatDefOf.MedicalPotency, null);
            float        num2         = num;
            Building_Bed building_Bed = patient.CurrentBed();

            if (building_Bed != null)
            {
                num2 += building_Bed.GetStatValue(StatDefOf.MedicalTendQualityOffset, true);
            }
            if (doctor != null)
            {
                num2 *= doctor.GetStatValue(StatDefOf.HealingQuality, true);
            }
            num2 = Mathf.Clamp01(num2);
            if (patient.health.hediffSet.GetInjuriesTendable().Any <Hediff_Injury>())
            {
                float num3 = 0f;
                int   num4 = 0;
                foreach (Hediff_Injury current in from x in patient.health.hediffSet.GetInjuriesTendable()
                         orderby x.Severity descending
                         select x)
                {
                    float num5 = Mathf.Min(current.Severity, 20f);
                    if (num3 + num5 > 20f)
                    {
                        break;
                    }
                    num3 += num5;
                    current.Tended(num2, num4);
                    if (medicine == null)
                    {
                        break;
                    }
                    num4++;
                }
            }
            else
            {
                bleedingStumps.Clear();
                List <Hediff_MissingPart> missingPartsCommonAncestors = patient.health.hediffSet.GetMissingPartsCommonAncestors();
                for (int i = 0; i < missingPartsCommonAncestors.Count; i++)
                {
                    if (missingPartsCommonAncestors[i].IsFresh)
                    {
                        bleedingStumps.Add(missingPartsCommonAncestors[i]);
                    }
                }
                if (bleedingStumps.Count > 0)
                {
                    bleedingStumps.RandomElement <Hediff_MissingPart>().IsFresh = false;
                    bleedingStumps.Clear();
                }
                else
                {
                    otherHediffs.Clear();
                    otherHediffs.AddRange(patient.health.hediffSet.GetTendableNonInjuryNonMissingPartHediffs());
                    Hediff hediff;
                    if (otherHediffs.TryRandomElement(out hediff))
                    {
                        HediffCompProperties_TendDuration hediffCompProperties_TendDuration = hediff.def.CompProps <HediffCompProperties_TendDuration>();
                        if (hediffCompProperties_TendDuration != null && hediffCompProperties_TendDuration.tendAllAtOnce)
                        {
                            int num6 = 0;
                            for (int j = 0; j < otherHediffs.Count; j++)
                            {
                                if (otherHediffs[j].def == hediff.def)
                                {
                                    otherHediffs[j].Tended(num2, num6);
                                    num6++;
                                }
                            }
                        }
                        else
                        {
                            hediff.Tended(num2, 0);
                        }
                    }
                    otherHediffs.Clear();
                }
            }
            if (doctor != null && patient.HostFaction == null && patient.Faction != null && patient.Faction != doctor.Faction)
            {
                patient.Faction.AffectGoodwillWith(doctor.Faction, 0.3f);
            }
            if (doctor != null && doctor.RaceProps.Humanlike && patient.RaceProps.Animal && RelationsUtility.TryDevelopBondRelation(doctor, patient, 0.004f) && doctor.Faction != null && doctor.Faction != patient.Faction)
            {
                InteractionWorker_RecruitAttempt.DoRecruit(doctor, patient, 1f, false);
            }
            patient.records.Increment(RecordDefOf.TimesTendedTo);
            if (doctor != null)
            {
                doctor.records.Increment(RecordDefOf.TimesTendedOther);
                doctor.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOfPsychology.DoctorBleedingHeart, patient);
            }
            if (medicine != null)
            {
                if ((patient.Spawned || (doctor != null && doctor.Spawned)) && num > 1f)
                {
                    SoundDef.Named("TechMedicineUsed").PlayOneShot(new TargetInfo(patient.Position, patient.Map, false));
                }
                if (medicine.stackCount > 1)
                {
                    medicine.stackCount--;
                }
                else if (!medicine.Destroyed)
                {
                    medicine.Destroy(DestroyMode.Vanish);
                }
            }
        }
Exemplo n.º 25
0
        public static void DoTend(Pawn doctor, Pawn patient, Medicine medicine)
        {
            if (!patient.health.HasHediffsNeedingTend(false))
            {
                return;
            }
            if (medicine != null && medicine.Destroyed)
            {
                Log.Warning("Tried to use destroyed medicine.");
                medicine = null;
            }
            float        num          = (medicine == null) ? 0.2f : medicine.def.GetStatValueAbstract(StatDefOf.MedicalPotency, null);
            float        quality      = num;
            Building_Bed building_Bed = patient.CurrentBed();

            if (building_Bed != null)
            {
                quality += building_Bed.GetStatValue(StatDefOf.MedicalTendQualityOffset, true);
            }
            if (doctor != null)
            {
                quality *= doctor.GetStatValue(StatDefOf.HealingQuality, true);
            }
            quality = Mathf.Clamp01(quality);
            if (patient.health.hediffSet.GetInjuriesTendable().Any <Hediff_Injury>())
            {
                float maxSeverity   = 0f;
                int   batchPosition = 0;

                // added prio by bleeding, everything else vanilla
                foreach (Hediff_Injury current in from x in patient.health.hediffSet.GetInjuriesTendable().Where(x => x.BleedRate > 0)
                         orderby x.BleedRate descending
                         select x)
                {
                    float severity = Mathf.Min(current.Severity, 20f);
                    if (maxSeverity + severity > 20f)
                    {
                        break;
                    }
                    maxSeverity += severity;
                    current.Tended(quality, batchPosition);
                    if (medicine == null)
                    {
                        break;
                    }
                    batchPosition++;
                }

                foreach (Hediff_Injury current in from x in patient.health.hediffSet.GetInjuriesTendable()
                         orderby x.Severity descending
                         select x)
                {
                    float severity = Mathf.Min(current.Severity, 20f);
                    if (maxSeverity + severity > 20f)
                    {
                        break;
                    }
                    maxSeverity += severity;
                    current.Tended(quality, batchPosition);
                    if (medicine == null)
                    {
                        break;
                    }
                    batchPosition++;
                }
            }
            else
            {
                _TendUtility.bleedingStumps.Clear();
                List <Hediff_MissingPart> missingPartsCommonAncestors = patient.health.hediffSet.GetMissingPartsCommonAncestors();
                for (int i = 0; i < missingPartsCommonAncestors.Count; i++)
                {
                    if (missingPartsCommonAncestors[i].IsFresh)
                    {
                        _TendUtility.bleedingStumps.Add(missingPartsCommonAncestors[i]);
                    }
                }
                if (_TendUtility.bleedingStumps.Count > 0)
                {
                    _TendUtility.bleedingStumps.RandomElement <Hediff_MissingPart>().IsFresh = false;
                    _TendUtility.bleedingStumps.Clear();
                }
                else
                {
                    _TendUtility.otherHediffs.Clear();
                    _TendUtility.otherHediffs.AddRange(patient.health.hediffSet.GetTendableNonInjuryNonMissingPartHediffs());
                    Hediff hediff;
                    if (_TendUtility.otherHediffs.TryRandomElement(out hediff))
                    {
                        HediffCompProperties_TendDuration hediffCompProperties_TendDuration = hediff.def.CompProps <HediffCompProperties_TendDuration>();
                        if (hediffCompProperties_TendDuration != null && hediffCompProperties_TendDuration.tendAllAtOnce)
                        {
                            int num6 = 0;
                            for (int j = 0; j < _TendUtility.otherHediffs.Count; j++)
                            {
                                if (_TendUtility.otherHediffs[j].def == hediff.def)
                                {
                                    _TendUtility.otherHediffs[j].Tended(quality, num6);
                                    num6++;
                                }
                            }
                        }
                        else
                        {
                            hediff.Tended(quality, 0);
                        }
                    }
                    _TendUtility.otherHediffs.Clear();
                }
            }
            if (doctor != null && patient.HostFaction == null && patient.Faction != null && patient.Faction != doctor.Faction)
            {
                patient.Faction.AffectGoodwillWith(doctor.Faction, 0.3f);
            }
            if (doctor != null && doctor.RaceProps.Humanlike && patient.RaceProps.Animal && RelationsUtility.TryDevelopBondRelation(doctor, patient, ChanceToDevelopBondRelationOnTended) && doctor.Faction != null && doctor.Faction != patient.Faction)
            {
                InteractionWorker_RecruitAttempt.DoRecruit(doctor, patient, 1f, false);
            }
            patient.records.Increment(RecordDefOf.TimesTendedTo);
            if (doctor != null)
            {
                doctor.records.Increment(RecordDefOf.TimesTendedOther);
            }
            if (medicine != null)
            {
                if ((patient.Spawned || (doctor != null && doctor.Spawned)) && num > 1f)
                {
                    SoundDef.Named("TechMedicineUsed").PlayOneShot(new TargetInfo(patient.Position, patient.Map, false));
                }
                if (medicine.stackCount > 1)
                {
                    medicine.stackCount--;
                }
                else if (!medicine.Destroyed)
                {
                    medicine.Destroy(DestroyMode.Vanish);
                }
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// recruits the sapient animal
        /// </summary>
        /// <param name="recruiter">The recruiter.</param>
        /// <param name="recruitee">The recruitee.</param>
        /// <param name="recruitChance">The recruit chance.</param>
        /// <param name="letterLabel">The letter label.</param>
        /// <param name="letter">The letter.</param>
        /// <param name="useAudiovisualEffects">if set to <c>true</c> [use audiovisual effects].</param>
        /// <param name="sendLetter">if set to <c>true</c> [send letter].</param>
        public static void DoRecruit(
            Pawn recruiter,
            Pawn recruitee,
            float recruitChance,
            out string letterLabel,
            out string letter,
            bool useAudiovisualEffects = true,
            bool sendLetter            = true)
        {
            letterLabel   = null;
            letter        = null;
            recruitChance = Mathf.Clamp01(recruitChance);
            string str = recruitee.LabelIndefinite();

            if (recruitee.guest != null)
            {
                recruitee.guest.SetGuestStatus(null);
            }
            bool flag = recruitee.Name != null;

            if (recruitee.Faction != recruiter.Faction)
            {
                recruitee.SetFaction(recruiter.Faction, recruiter);
            }
            if (recruitee.IsHumanlike())
            {
                if (useAudiovisualEffects)
                {
                    letterLabel = "LetterLabelMessageRecruitSuccess".Translate() + ": " + recruitee.LabelShortCap;
                    if (sendLetter)
                    {
                        Find.LetterStack.ReceiveLetter((TaggedString)letterLabel,
                                                       "MessageRecruitSuccess".Translate((NamedArgument)recruiter,
                                                                                         (NamedArgument)recruitee,
                                                                                         (NamedArgument)recruitChance
                                                                                         .ToStringPercent(),
                                                                                         recruiter.Named("RECRUITER"),
                                                                                         recruitee.Named("RECRUITEE")),
                                                       LetterDefOf.PositiveEvent, recruitee);
                    }
                }

                TaleRecorder.RecordTale(RimWorld.TaleDefOf.Recruited, (object)recruiter, (object)recruitee);
                recruiter.records.Increment(RecordDefOf.PrisonersRecruited);
                if (recruitee.needs.mood != null)
                {
                    recruitee.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.RecruitedMe, recruiter);
                }
                QuestUtility.SendQuestTargetSignals(recruitee.questTags, "Recruited", recruitee.Named("SUBJECT"));
            }
            else
            {
                if (useAudiovisualEffects)
                {
                    if (!flag)
                    {
                        Messages.Message("MessageTameAndNameSuccess".Translate((NamedArgument)recruiter.LabelShort, (NamedArgument)str, (NamedArgument)recruitChance.ToStringPercent(), (NamedArgument)recruitee.Name.ToStringFull, recruiter.Named("RECRUITER"), recruitee.Named("RECRUITEE")).AdjustedFor(recruitee),
                                         recruitee, MessageTypeDefOf.PositiveEvent);
                    }
                    else
                    {
                        Messages.Message("MessageTameSuccess".Translate((NamedArgument)recruiter.LabelShort, (NamedArgument)str, (NamedArgument)recruitChance.ToStringPercent(), recruiter.Named("RECRUITER")),
                                         recruitee, MessageTypeDefOf.PositiveEvent);
                    }
                    if (recruiter.Spawned && recruitee.Spawned)
                    {
                        MoteMaker.ThrowText((recruiter.DrawPos + recruitee.DrawPos) / 2f, recruiter.Map,
                                            "TextMote_TameSuccess".Translate((NamedArgument)recruitChance.ToStringPercent()),
                                            8f);
                    }
                }

                recruiter.records.Increment(RecordDefOf.AnimalsTamed);
                RelationsUtility.TryDevelopBondRelation(recruiter, recruitee, 0.01f);
                if (Rand.Chance(Mathf.Lerp(0.02f, 1f, recruitee.RaceProps.wildness)) || recruitee.IsWildMan())
                {
                    TaleRecorder.RecordTale(RimWorld.TaleDefOf.TamedAnimal, (object)recruiter, (object)recruitee);
                }
                if (PawnsFinder.AllMapsWorldAndTemporary_Alive.Count(p =>
                {
                    if (p.playerSettings != null)
                    {
                        return(p.playerSettings.Master == recruiter);
                    }
                    return(false);
                })
                    >= 5)
                {
                    TaleRecorder.RecordTale(RimWorld.TaleDefOf.IncreasedMenagerie, (object)recruiter, (object)recruitee);
                }
            }

            if (recruitee.caller == null)
            {
                return;
            }
            recruitee.caller.DoCall();
        }
Exemplo n.º 27
0
        private static float GetBodyFactor(Pawn f****r, Pawn f****d)
        {
            float body_factor;             //0.4 to 1.6

            {
                if (f****r.health.hediffSet.HasHediff(HediffDef.Named("AlcoholHigh")))
                {
                    if (!xxx.is_zoophile(f****r) && xxx.is_animal(f****d))
                    {
                        body_factor = 0.8f;
                    }
                    else
                    {
                        body_factor = 1.25f;                         //beer lens
                    }
                }
                else if (xxx.is_zoophile(f****r) && !xxx.is_animal(f****d))
                {
                    body_factor = 0.7f;
                }
                else if (!xxx.is_zoophile(f****r) && xxx.is_animal(f****d))
                {
                    body_factor = 0.45f;
                }
                else if (Quirk.Teratophile.IsSatisfiedBy(f****r, f****d))
                {
                    body_factor = 1.4f;
                }
                else if (f****d.story != null)
                {
                    if (f****d.story.bodyType == BodyTypeDefOf.Female)
                    {
                        body_factor = 1.25f;
                    }
                    else if (f****d.story.bodyType == BodyTypeDefOf.Fat)
                    {
                        body_factor = 1.0f;
                    }
                    else
                    {
                        body_factor = 1.1f;
                    }

                    if (f****d.story.traits.HasTrait(TraitDefOf.CreepyBreathing))
                    {
                        body_factor *= 0.9f;
                    }

                    if (f****d.story.traits.HasTrait(TraitDefOf.Beauty))
                    {
                        switch (f****d.story.traits.DegreeOfTrait(TraitDefOf.Beauty))
                        {
                        case 2:                                 // Beautiful
                            body_factor *= 1.25f;
                            break;

                        case 1:                                 // Pretty
                            body_factor *= 1.1f;
                            break;

                        case -1:                                 // Ugly
                            body_factor *= 0.8f;
                            break;

                        case -2:                                 // Staggeringly Ugly
                            body_factor *= 0.5f;
                            break;
                        }
                    }

                    if (RelationsUtility.IsDisfigured(f****d))
                    {
                        body_factor *= 0.8f;
                    }

                    // Nude target is more tempting.
                    if (!f****d.Dead && f****d.apparel.PsychologicallyNude && f****r.CanSee(f****d))
                    {
                        body_factor *= 1.1f;
                    }
                }
                else
                {
                    body_factor = 1.1f;
                }

                if (Quirk.Somnophile.IsSatisfiedBy(f****r, f****d))
                {
                    body_factor *= 1.25f;
                }

                if (Quirk.PregnancyFetish.IsSatisfiedBy(f****r, f****d))
                {
                    body_factor *= 1.25f;
                }

                if (Quirk.ImpregnationFetish.IsSatisfiedBy(f****r, f****d))
                {
                    body_factor *= 1.25f;
                }

                if (xxx.AlienFrameworkIsActive && !xxx.is_animal(f****r))
                {
                    if (xxx.is_xenophile(f****r))
                    {
                        if (f****r.def.defName == f****d.def.defName)
                        {
                            body_factor *= 0.5f;                             // Same species, xenophile less interested.
                        }
                    }
                    else if (xxx.is_xenophobe(f****r))
                    {
                        if (f****r.def.defName != f****d.def.defName)
                        {
                            body_factor *= 0.25f;                             // Different species, xenophobe less interested.
                        }
                    }
                }

                if (f****d.Dead && !xxx.is_necrophiliac(f****r))
                {
                    body_factor *= 0.5f;
                }
            }
            //Log.Message("would_fuck() - body_factor = " + body_factor.ToString());
            return(body_factor);
        }
Exemplo n.º 28
0
        internal static void _DoTend(Pawn doctor, Pawn patient, Medicine medicine)
        {
            if (!patient.health.HasHediffsNeedingTend(false))
            {
                return;
            }
            if (medicine != null && medicine.Destroyed)
            {
                Log.Warning("Tried to use destroyed medicine.");
                medicine = (Medicine)null;
            }
            float num1    = medicine == null ? 0.0f : medicine.def.GetStatValueAbstract(StatDefOf.MedicalPotency, (ThingDef)null);
            float quality = medicine == null ? 0.5f : num1;

            if (doctor != null)
            {
                quality *= doctor.GetStatValue(StatDefOf.BaseHealingQuality, true);
            }
            if (patient.InBed())
            {
                quality *= patient.CurrentBed().GetStatValue(StatDefOf.MedicalTreatmentQualityFactor, true);
            }
            if (patient.health.hediffSet.GetInjuriesTendable().Any <Hediff_Injury>())
            {
                float num2          = 0.0f;
                int   batchPosition = 0;
                foreach (Hediff_Injury hediffInjury in (IEnumerable <Hediff_Injury>)patient.health.hediffSet.GetInjuriesTendable().OrderByDescending <Hediff_Injury, float>((Func <Hediff_Injury, float>)(x => x.Severity)))
                {
                    float num3 = Mathf.Min(hediffInjury.Severity, 20f);
                    if ((double)num2 + (double)num3 <= 20.0)
                    {
                        num2 += num3;
                        hediffInjury.Tended(quality, batchPosition);
                        if (medicine != null)
                        {
                            ++batchPosition;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else
            {
                bleedingStumps.Clear();
                List <Hediff_MissingPart> partsCommonAncestors = patient.health.hediffSet.GetMissingPartsCommonAncestors();
                for (int index = 0; index < partsCommonAncestors.Count; ++index)
                {
                    if (partsCommonAncestors[index].IsFresh)
                    {
                        bleedingStumps.Add(partsCommonAncestors[index]);
                    }
                }
                if (bleedingStumps.Count > 0)
                {
                    bleedingStumps.RandomElement <Hediff_MissingPart>().IsFresh = false;
                    bleedingStumps.Clear();
                }
                else
                {
                    otherHediffs.Clear();
                    otherHediffs.AddRange(patient.health.hediffSet.GetTendableNonInjuryNonMissingPartHediffs());
                    Hediff result;
                    if (otherHediffs.TryRandomElement <Hediff>(out result))
                    {
                        HediffCompProperties hediffCompProperties = result.def.CompPropsFor(typeof(HediffComp_Tendable));
                        if (hediffCompProperties != null && hediffCompProperties.tendAllAtOnce)
                        {
                            int batchPosition = 0;
                            for (int index = 0; index < otherHediffs.Count; ++index)
                            {
                                if (otherHediffs[index].def == result.def)
                                {
                                    otherHediffs[index].Tended(quality, batchPosition);
                                    ++batchPosition;
                                }
                            }
                        }
                        else
                        {
                            result.Tended(quality, 0);
                        }
                    }
                    otherHediffs.Clear();
                }
            }
            if (doctor != null && patient.HostFaction == null && (patient.Faction != null && patient.Faction != doctor.Faction))
            {
                patient.Faction.AffectGoodwillWith(doctor.Faction, 0.3f);
            }
            if (doctor != null && doctor.RaceProps.Humanlike && (patient.RaceProps.Animal && RelationsUtility.TryDevelopBondRelation(doctor, patient, 0.01f)) && (doctor.Faction != null && doctor.Faction != patient.Faction))
            {
                InteractionWorker_RecruitAttempt.DoRecruit(doctor, patient, 1f, false);
            }
            patient.records.Increment(RecordDefOf.TimesTendedTo);
            if (doctor != null)
            {
                doctor.records.Increment(RecordDefOf.TimesTendedOther);
                doctor.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOfPsychology.DoctorBleedingHeart, patient);
            }
            if (medicine == null)
            {
                return;
            }
            if ((patient.Spawned || doctor != null && doctor.Spawned) && (double)num1 > 0.899999976158142)
            {
                SoundDef.Named("TechMedicineUsed").PlayOneShot((SoundInfo)patient.Position);
            }
            if (medicine.stackCount > 1)
            {
                --medicine.stackCount;
            }
            else
            {
                if (medicine.Destroyed)
                {
                    return;
                }
                medicine.Destroy(DestroyMode.Vanish);
            }
        }
Exemplo n.º 29
0
        public static int GetEnemiesInColony(this Pawn guest)
        {
            const int maxOpinion = -20;

            return(GetPawnsFromBase(guest.MapHeld).Count(p => RelationsUtility.PawnsKnowEachOther(guest, p) && guest.relations.OpinionOf(p) <= maxOpinion));
        }
Exemplo n.º 30
0
        internal static void _DoRecruit(Pawn recruiter, Pawn recruitee, float recruitChance, bool useAudiovisualEffects = true)
        {
            string text = recruitee.LabelIndefinite();

            if (recruitee.guest != null)
            {
                recruitee.guest.SetGuestStatus(null, false);
            }
            bool flag = recruitee.Name != null;

            if (recruitee.Faction != recruiter.Faction)
            {
                recruitee.SetFaction(recruiter.Faction, recruiter);
            }
            if (recruitee.RaceProps.Humanlike)
            {
                if (useAudiovisualEffects)
                {
                    Find.LetterStack.ReceiveLetter("LetterLabelMessageRecruitSuccess".Translate(), "MessageRecruitSuccess".Translate(new object[]
                    {
                        recruiter,
                        recruitee,
                        recruitChance.ToStringPercent()
                    }), LetterType.Good, recruitee, null);
                }
                TaleRecorder.RecordTale(TaleDefOf.Recruited, new object[]
                {
                    recruiter,
                    recruitee
                });
                recruiter.records.Increment(RecordDefOf.PrisonersRecruited);
                recruitee.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOf.RecruitedMe, recruiter);
                recruitee.needs.mood.thoughts.memories.RemoveMemoryThoughtsOfDef(ThoughtDefOf.RapportBuilt);
                List <Pawn> allFactionPawns = Find.Maps.SelectMany(m => from p in m.mapPawns.PawnsInFaction(recruiter.Faction)
                                                                   where p != recruitee && p.RaceProps.Humanlike
                                                                   select p).ToList <Pawn>();
                foreach (Pawn pawn in allFactionPawns)
                {
                    recruitee.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOfPsychology.CapturedMe, pawn);
                }
            }
            else
            {
                if (useAudiovisualEffects)
                {
                    if (!flag)
                    {
                        Messages.Message("MessageTameAndNameSuccess".Translate(new object[]
                        {
                            recruiter.LabelShort,
                            text,
                            recruitChance.ToStringPercent(),
                            recruitee.Name.ToStringFull
                        }).AdjustedFor(recruitee), recruitee, MessageSound.Benefit);
                    }
                    else
                    {
                        Messages.Message("MessageTameSuccess".Translate(new object[]
                        {
                            recruiter.LabelShort,
                            text,
                            recruitChance.ToStringPercent()
                        }), recruitee, MessageSound.Benefit);
                    }
                    MoteMaker.ThrowText((recruiter.DrawPos + recruitee.DrawPos) / 2f, recruiter.Map, "TextMote_TameSuccess".Translate(new object[]
                    {
                        recruitChance.ToStringPercent()
                    }), 8f);
                }
                recruiter.records.Increment(RecordDefOf.AnimalsTamed);
                RelationsUtility.TryDevelopBondRelation(recruiter, recruitee, 0.01f);
                float num = Mathf.Lerp(0.02f, 1f, recruitee.RaceProps.wildness);
                if (Rand.Value < num)
                {
                    TaleRecorder.RecordTale(TaleDefOf.TamedAnimal, new object[]
                    {
                        recruiter,
                        recruitee
                    });
                }
            }
            if (recruitee.caller != null)
            {
                recruitee.caller.DoCall();
            }
        }