コード例 #1
0
        public override void Tick()
        {
            if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("HumanPregnancy")))
            {
                pawn.health.AddHediff(Hediff_HumanPregnancy.Create(pawn, null), pawn.RaceProps.body.AllParts.Find(x => x.def == BodyPartDefOf.Torso), null);
            }
            pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("HumanPregnancy")).Severity = 0.995f;

            pawn.health.RemoveHediff(this);
        }
コード例 #2
0
ファイル: Lovin_Override.cs プロジェクト: kyubix/RimWorld-Mod
        internal static void TryToImpregnate(Pawn initiator, Pawn partner)
        {
            // Lesbian/gay couples. Those cases should never result in pregnancy
            if (initiator.gender == partner.gender)
            {
                return;
            }

            Pawn male   = initiator.gender == Gender.Male? initiator: partner;
            Pawn female = initiator.gender == Gender.Female ? initiator : partner;

            // Only humans can be impregnated for now
            if (female.def.defName != "Human")
            {
                return;
            }

            BodyPartRecord torso         = female.RaceProps.body.AllParts.Find(x => x.def == BodyPartDefOf.Torso);
            HediffDef      contraceptive = HediffDef.Named("Contraceptive");

            // Make sure the woman is not pregnanct and not using a contraceptive
            if (female.health.hediffSet.HasHediff(HediffDefOf.Pregnant, torso) || female.health.hediffSet.HasHediff(contraceptive, null) || male.health.hediffSet.HasHediff(contraceptive, null))
            {
                return;
            }
            // Check the pawn's age to see how likely it is she can carry a fetus
            // 25 and below is guaranteed, 50 and above is impossible, 37.5 is 50% chance
            float preg_chance = Math.Max(1 - (Math.Max(female.ageTracker.AgeBiologicalYearsFloat - 25, 0) / 25), 0) * 0.33f;

            // For debug testing
            //float preg_chance = 1;
            if (preg_chance < Rand.Value)
            {
                if (Prefs.DevMode)
                {
                    Log.Message("Impregnation failed. Chance was " + preg_chance);
                }
                return;
            }
            if (Prefs.DevMode)
            {
                Log.Message("Impregnation succeeded. Chance was " + preg_chance);
            }
            // Spawn a bunch of hearts. Sharp eyed players may notice this means impregnation occurred.
            for (int i = 0; i <= 3; i++)
            {
                MoteMaker.ThrowMetaIcon(male.Position, male.MapHeld, ThingDefOf.Mote_Heart);
                MoteMaker.ThrowMetaIcon(female.Position, male.MapHeld, ThingDefOf.Mote_Heart);
            }

            // Do the actual impregnation. We apply it to the torso because Remove_Hediff in operations doesn't work on WholeBody (null body part)
            // for whatever reason.
            female.health.AddHediff(Hediff_HumanPregnancy.Create(female, male), torso);
        }
コード例 #3
0
 public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
 {
     if (pawn.health.hediffSet.HasHediff(HediffDef.Named("HumanPregnancy")))
     {
         Hediff_HumanPregnancy preggo = (Hediff_HumanPregnancy)pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("HumanPregnancy"));
         preggo.DiscoverPregnancy();
     }
     else
     {
         Messages.Message(billDoer.Name.ToStringShort + " has determined " + pawn.Name.ToStringShort + " is not pregnant.", MessageTypeDefOf.NeutralEvent);
     }
 }
コード例 #4
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            // We don't check if the surgery fails, because even if the surgery is a failure the fetus will still die

            if (billDoer != null)
            {
                TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[] {
                    billDoer,
                    pawn
                });
                //if (base.CheckSurgeryFail (billDoer, pawn, ingredients, part) == false) {
                if (base.CheckSurgeryFail(billDoer, pawn, ingredients, part, bill) == false)
                {
                    if (PawnUtility.ShouldSendNotificationAbout(pawn) || PawnUtility.ShouldSendNotificationAbout(billDoer))
                    {
                        string text;
                        if (!this.recipe.successfullyRemovedHediffMessage.NullOrEmpty())
                        {
                            text = string.Format(this.recipe.successfullyRemovedHediffMessage, billDoer.LabelShort, pawn.LabelShort);
                        }
                        else
                        {
                            text = "MessageSuccessfullyRemovedHediff".Translate(new object[] {
                                billDoer.LabelShort,
                                pawn.LabelShort,
                                this.recipe.removesHediff.label
                            });
                        }
                        Messages.Message(text, pawn, MessageTypeDefOf.TaskCompletion);
                    }
                }
            }

            Hediff_HumanPregnancy preggo = (Hediff_HumanPregnancy)pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("HumanPregnancy"));

            if (preggo.IsLateTerm())
            {
                // Give bad thoughts related to late abortions
                pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("LateTermAbortion"), null);
                if (preggo.GestationProgress >= 0.97f)
                {
                    Thought_Memory abortion_thought = pawn.needs.mood.thoughts.memories.OldestMemoryOfDef(ThoughtDef.Named("LateTermAbortion"));
                    if (abortion_thought == null)
                    {
                        Log.Error("ChildrenMod: Failed to add late term abortion thought!");
                    }
                    // Very late term abortion
                    abortion_thought.SetForcedStage(abortion_thought.CurStageIndex + 1);
                }

                // Give bad thoughts related to late abortions
                pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("LateTermAbortion"), null);
                if (preggo.GestationProgress >= 0.97f)
                {
                    Thought_Memory abortion_thought = pawn.needs.mood.thoughts.memories.OldestMemoryOfDef(ThoughtDef.Named("LateTermAbortion"));
                    // Very late term abortion
                    abortion_thought.SetForcedStage(abortion_thought.CurStageIndex + 1);
                }
                // Remove the fetus
                preggo.Miscarry(true);
            }
            else
            {
                pawn.health.RemoveHediff(preggo);
            }
        }