public static void DoRecruit(Pawn recruiter, Pawn recruitee, float recruitChance, bool useAudiovisualEffects = true)
        {
            string text;
            string text2;

            InteractionWorker_RecruitAttempt.DoRecruit(recruiter, recruitee, recruitChance, out text, out text2, useAudiovisualEffects, true);
        }
Ejemplo n.º 2
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.", false);
                medicine = null;
            }
            float quality = TendUtility.CalculateBaseTendQuality(doctor, patient, (medicine == null) ? null : medicine.def);

            TendUtility.GetOptimalHediffsToTendWithSingleTreatment(patient, medicine != null, TendUtility.tmpHediffsToTend, null);
            for (int i = 0; i < TendUtility.tmpHediffsToTend.Count; i++)
            {
                TendUtility.tmpHediffsToTend[i].Tended(quality, 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 && 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);
            }
            if (doctor == patient && !doctor.Dead)
            {
                doctor.mindState.Notify_SelfTended();
            }
            if (medicine != null)
            {
                if ((patient.Spawned || (doctor != null && doctor.Spawned)) && medicine != null && medicine.GetStatValue(StatDefOf.MedicalPotency, true) > ThingDefOf.MedicineIndustrial.GetStatValueAbstract(StatDefOf.MedicalPotency, null))
                {
                    SoundDefOf.TechMedicineUsed.PlayOneShot(new TargetInfo(patient.Position, patient.Map, false));
                }
                if (medicine.stackCount > 1)
                {
                    medicine.stackCount--;
                }
                else if (!medicine.Destroyed)
                {
                    medicine.Destroy(DestroyMode.Vanish);
                }
            }
        }
 public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks)
 {
     if (!recipient.mindState.CheckStartMentalStateBecauseRecruitAttempted(initiator))
     {
         bool  flag = initiator.InspirationDef == InspirationDefOf.InspiredRecruitment && recipient.RaceProps.Humanlike;
         float num  = 1f;
         if (flag || DebugSettings.instantRecruit)
         {
             num = 1f;
         }
         else
         {
             num *= ((!recipient.NonHumanlikeOrWildMan()) ? initiator.GetStatValue(StatDefOf.RecruitPrisonerChance, true) : initiator.GetStatValue(StatDefOf.TameAnimalChance, true));
             float num2 = (float)((!recipient.IsWildMan()) ? ((!recipient.RaceProps.Humanlike) ? InteractionWorker_RecruitAttempt.RecruitChanceFactorCurve_Wildness.Evaluate(recipient.RaceProps.wildness) : (1.0 - recipient.RecruitDifficulty(initiator.Faction, true))) : 0.25);
             num *= num2;
             if (!recipient.NonHumanlikeOrWildMan())
             {
                 float x = (float)recipient.relations.OpinionOf(initiator);
                 num *= InteractionWorker_RecruitAttempt.RecruitChanceFactorCurve_Opinion.Evaluate(x);
                 if (recipient.needs.mood != null)
                 {
                     float curLevel = recipient.needs.mood.CurLevel;
                     num *= InteractionWorker_RecruitAttempt.RecruitChanceFactorCurve_Mood.Evaluate(curLevel);
                 }
             }
             if (initiator.relations.DirectRelationExists(PawnRelationDefOf.Bond, recipient))
             {
                 num = (float)(num * 4.0);
             }
             num = Mathf.Clamp(num, 0.005f, 1f);
         }
         if (Rand.Chance(num))
         {
             InteractionWorker_RecruitAttempt.DoRecruit(initiator, recipient, num, true);
             extraSentencePacks.Add(RulePackDefOf.Sentence_RecruitAttemptAccepted);
             if (flag)
             {
                 initiator.mindState.inspirationHandler.EndInspiration(InspirationDefOf.InspiredRecruitment);
             }
         }
         else
         {
             string text = (!recipient.NonHumanlikeOrWildMan()) ? "TextMote_RecruitFail".Translate(num.ToStringPercent()) : "TextMote_TameFail".Translate(num.ToStringPercent());
             MoteMaker.ThrowText((initiator.DrawPos + recipient.DrawPos) / 2f, initiator.Map, text, 8f);
             extraSentencePacks.Add(RulePackDefOf.Sentence_RecruitAttemptRejected);
         }
     }
 }
Ejemplo n.º 4
0
 public static void DoTend(Pawn doctor, Pawn patient, Medicine medicine)
 {
     if (patient.health.HasHediffsNeedingTend(false))
     {
         if (medicine != null && medicine.Destroyed)
         {
             Log.Warning("Tried to use destroyed medicine.");
             medicine = null;
         }
         float num  = (float)((medicine == null) ? 0.30000001192092896 : medicine.def.GetStatValueAbstract(StatDefOf.MedicalPotency, null));
         float num2 = (float)((doctor == null) ? 0.75 : doctor.GetStatValue(StatDefOf.MedicalTendQuality, true));
         num2 *= num;
         Building_Bed building_Bed = patient.CurrentBed();
         if (building_Bed != null)
         {
             num2 += building_Bed.GetStatValue(StatDefOf.MedicalTendQualityOffset, true);
         }
         if (doctor == patient)
         {
             num2 = (float)(num2 * 0.699999988079071);
         }
         num2 = Mathf.Clamp01(num2);
         TendUtility.GetOptimalHediffsToTendWithSingleTreatment(patient, medicine != null, TendUtility.tmpHediffsToTend, null);
         for (int i = 0; i < TendUtility.tmpHediffsToTend.Count; i++)
         {
             TendUtility.tmpHediffsToTend[i].Tended(num2, i);
         }
         if (doctor != null && doctor.Faction != null && patient.HostFaction == null && patient.Faction != null && patient.Faction != doctor.Faction)
         {
             patient.Faction.AffectGoodwillWith(doctor.Faction, 0.3f);
         }
         if (doctor != null && doctor.IsColonistPlayerControlled)
         {
             patient.records.AccumulateStoryEvent(StoryEventDefOf.TendedByPlayer);
         }
         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);
         }
         if (medicine != null)
         {
             if ((patient.Spawned || (doctor != null && doctor.Spawned)) && num > ThingDefOf.Medicine.GetStatValueAbstract(StatDefOf.MedicalPotency, null))
             {
                 SoundDefOf.TechMedicineUsed.PlayOneShot(new TargetInfo(patient.Position, patient.Map, false));
             }
             if (medicine.stackCount > 1)
             {
                 medicine.stackCount--;
             }
             else if (!medicine.Destroyed)
             {
                 medicine.Destroy(DestroyMode.Vanish);
             }
         }
     }
 }
        public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef)
        {
            letterText  = null;
            letterLabel = null;
            letterDef   = null;
            if (recipient.mindState.CheckStartMentalStateBecauseRecruitAttempted(initiator))
            {
                return;
            }
            bool  flag  = recipient.AnimalOrWildMan() && !recipient.IsPrisoner;
            float x     = (float)((recipient.relations == null) ? 0 : recipient.relations.OpinionOf(initiator));
            bool  flag2 = initiator.InspirationDef == InspirationDefOf.Inspired_Recruitment && !flag && recipient.guest.interactionMode != PrisonerInteractionModeDefOf.ReduceResistance;

            if (!flag && recipient.guest.resistance > 0f && !flag2)
            {
                float num = 1f;
                num *= initiator.GetStatValue(StatDefOf.NegotiationAbility, true);
                num *= InteractionWorker_RecruitAttempt.ResistanceImpactFactorCurve_Mood.Evaluate(recipient.needs.mood.CurLevelPercentage);
                num *= InteractionWorker_RecruitAttempt.ResistanceImpactFactorCurve_Opinion.Evaluate(x);
                num  = Mathf.Min(num, recipient.guest.resistance);
                float resistance = recipient.guest.resistance;
                recipient.guest.resistance = Mathf.Max(0f, recipient.guest.resistance - num);
                string text = "TextMote_ResistanceReduced".Translate(new object[]
                {
                    resistance.ToString("F1"),
                    recipient.guest.resistance.ToString("F1")
                });
                if (recipient.needs.mood != null && recipient.needs.mood.CurLevelPercentage < 0.4f)
                {
                    text = text + "\n(" + "lowMood".Translate() + ")";
                }
                if (recipient.relations != null && (float)recipient.relations.OpinionOf(initiator) < -0.01f)
                {
                    text = text + "\n(" + "lowOpinion".Translate() + ")";
                }
                MoteMaker.ThrowText((initiator.DrawPos + recipient.DrawPos) / 2f, initiator.Map, text, 8f);
                if (recipient.guest.resistance == 0f)
                {
                    string text2 = "MessagePrisonerResistanceBroken".Translate(new object[]
                    {
                        recipient.LabelShort,
                        initiator.LabelShort
                    });
                    if (recipient.guest.interactionMode == PrisonerInteractionModeDefOf.AttemptRecruit)
                    {
                        text2 = text2 + " " + "MessagePrisonerResistanceBroken_RecruitAttempsWillBegin".Translate();
                    }
                    Messages.Message(text2, recipient, MessageTypeDefOf.PositiveEvent, true);
                }
            }
            else
            {
                float num2;
                if (flag)
                {
                    num2 = initiator.GetStatValue(StatDefOf.TameAnimalChance, true);
                    float x2 = (!recipient.IsWildMan()) ? recipient.RaceProps.wildness : 0.2f;
                    num2 *= InteractionWorker_RecruitAttempt.TameChanceFactorCurve_Wildness.Evaluate(x2);
                    if (initiator.relations.DirectRelationExists(PawnRelationDefOf.Bond, recipient))
                    {
                        num2 *= 4f;
                    }
                }
                else if (flag2 || DebugSettings.instantRecruit)
                {
                    num2 = 1f;
                }
                else
                {
                    num2 = initiator.GetStatValue(StatDefOf.NegotiationAbility, true) * 0.5f;
                    float x3 = recipient.RecruitDifficulty(initiator.Faction);
                    num2 *= InteractionWorker_RecruitAttempt.RecruitChanceFactorCurve_RecruitDifficulty.Evaluate(x3);
                    num2 *= InteractionWorker_RecruitAttempt.RecruitChanceFactorCurve_Opinion.Evaluate(x);
                    if (recipient.needs.mood != null)
                    {
                        float curLevel = recipient.needs.mood.CurLevel;
                        num2 *= InteractionWorker_RecruitAttempt.RecruitChanceFactorCurve_Mood.Evaluate(curLevel);
                    }
                }
                if (Rand.Chance(num2))
                {
                    InteractionWorker_RecruitAttempt.DoRecruit(initiator, recipient, num2, true);
                    if (flag2)
                    {
                        initiator.mindState.inspirationHandler.EndInspiration(InspirationDefOf.Inspired_Recruitment);
                    }
                    extraSentencePacks.Add(RulePackDefOf.Sentence_RecruitAttemptAccepted);
                }
                else
                {
                    string text3 = (!flag) ? "TextMote_RecruitFail".Translate(new object[]
                    {
                        num2.ToStringPercent()
                    }) : "TextMote_TameFail".Translate(new object[]
                    {
                        num2.ToStringPercent()
                    });
                    if (!flag)
                    {
                        if (recipient.needs.mood != null && recipient.needs.mood.CurLevelPercentage < 0.4f)
                        {
                            text3 = text3 + "\n(" + "lowMood".Translate() + ")";
                        }
                        if (recipient.relations != null && (float)recipient.relations.OpinionOf(initiator) < -0.01f)
                        {
                            text3 = text3 + "\n(" + "lowOpinion".Translate() + ")";
                        }
                    }
                    MoteMaker.ThrowText((initiator.DrawPos + recipient.DrawPos) / 2f, initiator.Map, text3, 8f);
                    extraSentencePacks.Add(RulePackDefOf.Sentence_RecruitAttemptRejected);
                }
            }
        }