예제 #1
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            if (billDoer != null)
            {
                if (CheckSurgeryFailAndroid(billDoer, pawn, ingredients, part, bill))
                {
                    return;
                }

                TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);
            }

            pawn.health.AddHediff(recipe.addsHediff, part, null);
        }
예제 #2
0
 private static void AddCaravanExitTaleIfShould(Pawn pawn)
 {
     if (pawn.Spawned && pawn.IsFreeColonist)
     {
         if (pawn.Map.IsPlayerHome)
         {
             TaleRecorder.RecordTale(TaleDefOf.CaravanFormed, pawn);
         }
         else if (GenHostility.AnyHostileActiveThreatToPlayer(pawn.Map))
         {
             TaleRecorder.RecordTale(TaleDefOf.CaravanFled, pawn);
         }
     }
 }
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            HediffComp_Breast breast = pawn.GetBreastComp();

            if (billDoer != null && breast != null)
            {
                TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[]
                {
                    billDoer,
                    pawn
                });
                SurgeryResult(breast);
            }
        }
예제 #4
0
 public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
 {
     if (!CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
     {
         TaleRecorder.RecordTale(TaleDefOfPsychology.CuredAnxiety, new object[]
         {
             billDoer,
             pawn
         });
         Hediff anxiety = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOfPsychology.Anxiety);
         pawn.health.RemoveHediff(anxiety);
         return;
     }
 }
예제 #5
0
        /// <summary>
        /// change the given pawn to the hybrid race of the desired morph
        /// </summary>
        /// <param name="pawn">The pawn.</param>
        /// <param name="morph">the morph to change the pawn to</param>
        /// <param name="addMissingMutations">if true, any missing mutations will be applied to the pawn</param>
        /// <param name="displayNotifications">if set to <c>true</c> display race shit notifications.</param>
        /// <exception cref="ArgumentNullException">
        /// pawn
        /// or
        /// morph
        /// </exception>
        public static void ChangePawnToMorph([NotNull] Pawn pawn, [NotNull] MorphDef morph, bool addMissingMutations = true, bool displayNotifications = true)
        {
            if (pawn == null)
            {
                throw new ArgumentNullException(nameof(pawn));
            }
            if (morph == null)
            {
                throw new ArgumentNullException(nameof(morph));
            }
            if (morph.hybridRaceDef == null)
            {
                Log.Error($"tried to change pawn {pawn.Name.ToStringFull} to morph {morph.defName} but morph has no hybridRace!");
            }
            if (pawn.def != ThingDefOf.Human && !pawn.IsHybridRace())
            {
                return;
            }

            //apply mutations
            if (addMissingMutations)
            {
                SwapMutations(pawn, morph);
            }

            var hRace = morph.hybridRaceDef;

            MorphDef.TransformSettings tfSettings = morph.transformSettings;
            HandleGraphicsChanges(pawn, morph);
            ChangePawnRace(pawn, hRace, true);

            if (pawn.IsColonist)
            {
                PortraitsCache.SetDirty(pawn);
            }

            if (displayNotifications && (pawn.IsColonist || pawn.IsPrisonerOfColony))
            {
                SendHybridTfMessage(pawn, tfSettings);
            }



            if (tfSettings?.transformTale != null)
            {
                TaleRecorder.RecordTale(tfSettings.transformTale, pawn);
            }
            pawn.TryGainMemory(tfSettings?.transformationMemory ?? PMThoughtDefOf.DefaultMorphTfMemory);
        }
예제 #6
0
        public static void CheckDefeated(Settlement factionBase)
        {
            if (factionBase.Faction == Faction.OfPlayer)
            {
                return;
            }
            Map map = factionBase.Map;

            if (map == null || !SettlementDefeatUtility.IsDefeated(map, factionBase.Faction))
            {
                return;
            }
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("LetterFactionBaseDefeated".Translate(factionBase.Label, TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(60000)));
            if (!SettlementDefeatUtility.HasAnyOtherBase(factionBase))
            {
                factionBase.Faction.defeated = true;
                stringBuilder.AppendLine();
                stringBuilder.AppendLine();
                stringBuilder.Append("LetterFactionBaseDefeated_FactionDestroyed".Translate(factionBase.Faction.Name));
            }
            foreach (Faction current in Find.FactionManager.AllFactions)
            {
                if (!current.def.hidden && !current.IsPlayer && current != factionBase.Faction && current.HostileTo(factionBase.Faction))
                {
                    FactionRelationKind playerRelationKind = current.PlayerRelationKind;
                    if (current.TryAffectGoodwillWith(Faction.OfPlayer, 20, false, false, null, null))
                    {
                        stringBuilder.AppendLine();
                        stringBuilder.AppendLine();
                        stringBuilder.Append("RelationsWith".Translate(current.Name) + ": " + 20.ToStringWithSign());
                        current.TryAppendRelationKindChangedInfo(stringBuilder, playerRelationKind, current.PlayerRelationKind, null);
                    }
                }
            }
            Find.LetterStack.ReceiveLetter("LetterLabelFactionBaseDefeated".Translate(), stringBuilder.ToString(), LetterDefOf.PositiveEvent, new GlobalTargetInfo(factionBase.Tile), factionBase.Faction, null);
            DestroyedSettlement destroyedSettlement = (DestroyedSettlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.DestroyedSettlement);

            destroyedSettlement.Tile = factionBase.Tile;
            Find.WorldObjects.Add(destroyedSettlement);
            map.info.parent = destroyedSettlement;
            Find.WorldObjects.Remove(factionBase);
            destroyedSettlement.GetComponent <TimedForcedExit>().StartForceExitAndRemoveMapCountdown();
            TaleRecorder.RecordTale(TaleDefOf.CaravanAssaultSuccessful, new object[]
            {
                map.mapPawns.FreeColonists.RandomElement <Pawn>()
            });
        }
예제 #7
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            float learnfactor = 1f / recipe.surgerySuccessChanceFactor;
            //Let random bad events happen when hacking fails
            float combatPowerCapped = pawn.kindDef.combatPower <= 10000 ? pawn.kindDef.combatPower : 300;

            if (CheckHackingFail(pawn, billDoer, part))
            {
                learnfactor *= 0.5f;
                if (pawn.Dead)
                {
                    return;
                }
                //Re-add surgery bill
                if (!pawn.IsHacked())
                {
                    ((Building_HackingTable)pawn.CurrentBed()).TryAddPawnForModification(pawn, WTH_DefOf.WTH_HackMechanoid);
                }
                billDoer.skills.Learn(SkillDefOf.Crafting, combatPowerCapped * learnfactor, false);
                billDoer.skills.Learn(SkillDefOf.Intellectual, combatPowerCapped * learnfactor, false);
                return;
            }
            TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[]
            {
                billDoer,
                pawn
            });
            if (this.recipe.addsHediff != null)
            {
                pawn.health.AddHediff(this.recipe.addsHediff, part, null);
            }
            if (this.recipe.GetModExtension <DefModExtension_Recipe>() is DefModExtension_Recipe extension && extension.addsAdditionalHediff != null)
            {
                BodyPartRecord additionalHediffBodyPart = null;
                if (extension.additionalHediffBodyPart != null)
                {
                    additionalHediffBodyPart = pawn.health.hediffSet.GetNotMissingParts().FirstOrDefault((BodyPartRecord bpr) => bpr.def == extension.additionalHediffBodyPart);
                }
                pawn.health.AddHediff(extension.addsAdditionalHediff, additionalHediffBodyPart);
            }
            if (pawn.health.hediffSet.HasHediff(WTH_DefOf.WTH_RepairModule) && pawn.GetComp <CompRefuelable>() == null)
            {
                pawn.InitializeComps();
            }
            billDoer.skills.Learn(SkillDefOf.Crafting, combatPowerCapped * learnfactor, false);
            billDoer.skills.Learn(SkillDefOf.Intellectual, combatPowerCapped * learnfactor, false);

            PostSuccessfulApply(pawn, part, billDoer, ingredients, bill);
        }
        public override void SpawnSetup()
        {
            base.SpawnSetup();

            var     thingDef = (ThingSpawnPawnDef)def;
            var     newPawn  = (PawnConverted)PawnGenerator.GeneratePawn(thingDef.spawnPawnDef, Faction.OfColony);
            IntVec3 pos      = CellFinder.RandomClosewalkCellNear(Position, 2);

            newPawn.workTypes = thingDef.workTypes;
            GenSpawn.Spawn(newPawn, pos);

            TaleRecorder.RecordTale(TaleDef.Named("CreatedMechanoid"), new object[] { newPawn });

            Destroy();
        }
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients)
        {
            Debug("ApplyOnPawn");
            if (billDoer != null)
            {
                if (CheckSurgeryFail(billDoer, pawn, ingredients, pawn.ReproductiveOrgans()))
                {
                    return;
                }
                TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);
            }
            pawn.health.AddHediff(recipe.addsHediff, part, null);

            GiveThoughtsForPawnNeutered(pawn);
        }
예제 #10
0
 private static void Prefix(Pawn ___pawn, DamageInfo?dinfo, Hediff hediff)
 {
     if (InCombat(___pawn))
     {
         if (Rand.Chance(0.1f))
         {
             TaleRecorder.RecordTale(VSIE_DefOf.VSIE_WasBadlyInjured, ___pawn);
         }
     }
     if (dinfo.HasValue)
     {
         Pawn_Kill_Patch.TryRecordSavedMeFromRaiders(___pawn, dinfo);
         Pawn_Kill_Patch.TryRecordMeleeAspiration(dinfo);
     }
 }
예제 #11
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients,
                                         Bill bill)
        {
            if (billDoer == null)
            {
                return;
            }

            if (!CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
            {
                TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);

                var hediff = pawn?.health?.hediffSet?.GetHediffs <Hediff>()
                             ?.Where(x => x.def == PS_DefOf.PS_HediffDefs_BotchedLaryngoplasty).FirstOrDefault();
                if (hediff != null)
                {
                    pawn.health.RemoveHediff(hediff);
                }
                else if (pawn != null && pawn.story.traits.allTraits.Any(x => x.def == TraitDefOf.AnnoyingVoice))
                {
                    PS_TraitChanger.Remove(pawn, new Trait(TraitDefOf.AnnoyingVoice));
                }
                else if (pawn != null && pawn.story.traits.allTraits.Any(x => x.def == TraitDefOf.CreepyBreathing))
                {
                    PS_TraitChanger.Remove(pawn, new Trait(TraitDefOf.CreepyBreathing));
                }

                Messages.Message(
                    string.Format("PS_Messages_SurgeryResult_Success".Translate(), billDoer.LabelShort,
                                  pawn?.LabelShort, "PS_Messages_Surgery_Laryngoplasty".Translate()), new LookTargets(pawn),
                    MessageTypeDefOf.TaskCompletion);
            }
            else
            {
                var hasHediff = pawn?.health?.hediffSet?.GetHediffs <Hediff>()
                                ?.Where(x => x.def == PS_DefOf.PS_HediffDefs_BotchedLaryngoplasty).Any() ?? false;
                if (!hasHediff)
                {
                    var hediff = HediffMaker.MakeHediff(PS_DefOf.PS_HediffDefs_BotchedLaryngoplasty, pawn, part);
                    pawn?.health?.AddHediff(hediff);
                }

                Messages.Message(
                    string.Format("PS_Messages_SurgeryResult_Botched".Translate(), billDoer.LabelShort,
                                  pawn?.LabelShort, "PS_Messages_Surgery_Laryngoplasty".Translate()), new LookTargets(pawn),
                    MessageTypeDefOf.NegativeHealthEvent);
            }
        }
예제 #12
0
        private static void RecruitingSuccess(Pawn guest)
        {
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDef.Named("RecruitGuest"), KnowledgeAmount.Total);

            Find.LetterStack.ReceiveLetter(labelRecruitSuccess, String.Format(txtRecruitSuccess, guest), LetterType.Good, guest);

            if (guest.Faction != Faction.OfPlayer)
            {
                if (guest.Faction != null)
                {
                    guest.Faction.AffectGoodwillWith(Faction.OfPlayer, -guest.RecruitPenalty());
                    if (guest.RecruitPenalty() >= 1)
                    {
                        //Log.Message("txtRecruitFactionAnger");
                        string message;
                        if (guest.Faction.leader != null)
                        {
                            message = String.Format(txtRecruitFactionAnger, guest.Faction.leader.Name, guest.Faction.Name, guest.NameStringShort, (-guest.RecruitPenalty()).ToStringByStyle(ToStringStyle.Integer, ToStringNumberSense.Offset));
                            Find.LetterStack.ReceiveLetter(labelRecruitFactionChiefAnger, message, LetterType.BadNonUrgent);
                        }
                        else
                        {
                            message = String.Format(txtRecruitFactionAngerLeaderless, guest.Faction.Name, guest.NameStringShort, (-guest.RecruitPenalty()).ToStringByStyle(ToStringStyle.Integer, ToStringNumberSense.Offset));
                            Find.LetterStack.ReceiveLetter(labelRecruitFactionAnger, message, LetterType.BadNonUrgent);
                        }
                    }
                    else if (guest.RecruitPenalty() <= -1)
                    {
                        //Log.Message("txtRecruitFactionPlease");
                        string message;
                        if (guest.Faction.leader != null)
                        {
                            message = String.Format(txtRecruitFactionPlease, guest.Faction.leader.Name, guest.Faction.Name, guest.NameStringShort, (-guest.RecruitPenalty()).ToStringByStyle(ToStringStyle.Integer, ToStringNumberSense.Offset));
                            Find.LetterStack.ReceiveLetter(labelRecruitFactionChiefPlease, message, LetterType.Good);
                        }
                        else
                        {
                            message = String.Format(txtRecruitFactionPleaseLeaderless, guest.Faction.Name, guest.NameStringShort, (-guest.RecruitPenalty()).ToStringByStyle(ToStringStyle.Integer, ToStringNumberSense.Offset));
                            Find.LetterStack.ReceiveLetter(labelRecruitFactionPlease, message, LetterType.Good);
                        }
                    }
                }
                guest.Adopt();
            }
            var taleParams = new object[] { guest.MapHeld.mapPawns.FreeColonistsSpawned.RandomElement(), guest };

            TaleRecorder.RecordTale(TaleDef.Named("Recruited"), taleParams);
        }
예제 #13
0
        public static void DoBirthSpawn(Pawn mother, Pawn father)
        {
            int num = (mother.RaceProps.litterSizeCurve == null) ? 1 : Mathf.RoundToInt(Rand.ByCurve(mother.RaceProps.litterSizeCurve, 300));

            if (num < 1)
            {
                num = 1;
            }
            PawnGenerationRequest request = new PawnGenerationRequest(mother.kindDef, mother.Faction, PawnGenerationContext.NonPlayer, -1, false, true, false, false, true, false, 1f, false, true, true, false, false, false, false, null, null, null, null, null, null, null);
            Pawn pawn = null;

            for (int i = 0; i < num; i++)
            {
                pawn = PawnGenerator.GeneratePawn(request);
                if (PawnUtility.TrySpawnHatchedOrBornPawn(pawn, mother))
                {
                    if (pawn.playerSettings != null && mother.playerSettings != null)
                    {
                        pawn.playerSettings.AreaRestriction = mother.playerSettings.AreaRestriction;
                    }
                    if (pawn.RaceProps.IsFlesh)
                    {
                        pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, mother);
                        if (father != null)
                        {
                            pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, father);
                        }
                    }
                }
                else
                {
                    Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard);
                }
                TaleRecorder.RecordTale(TaleDefOf.GaveBirth, mother, pawn);
            }
            if (mother.Spawned)
            {
                FilthMaker.MakeFilth(mother.Position, mother.Map, ThingDefOf.FilthAmnioticFluid, mother.LabelIndefinite(), 5);
                if (mother.caller != null)
                {
                    mother.caller.DoCall();
                }
                if (pawn.caller != null)
                {
                    pawn.caller.DoCall();
                }
            }
        }
예제 #14
0
        public void StartPlaying(Pawn musician, Thing instrument, Thing venue, bool isWork)
        {
            var venueHash = venue.GetHashCode();

            foreach (var otherVenueHash in Performances.Keys)
            {
                if (!RadiusAndRoomCheck(Performances[otherVenueHash].Venue, venue))
                {
                    continue;
                }

                venueHash = otherVenueHash;
                break;
            }

            if (!Performances.ContainsKey(venueHash))
            {
                Performances[venueHash] = new Performance(venue);
            }

            var musicianHash = musician.GetHashCode();

            if (Performances[venueHash].Performers.ContainsKey(musicianHash))
            {
                return;
            }

            Performances[venueHash].Performers[musicianHash] =
                new Performer {
                Musician = musician, Instrument = instrument
            };
            Performances[venueHash].CalculateQuality();

            if (Performances[venueHash].Quality >= 2f)
            {
                TaleRecorder.RecordTale(TaleDef.Named("PlayedMusic"), musician, instrument.def);
            }

            if (isWork)
            {
                WorkPerformanceTimestamps[musician.GetHashCode()] = Find.TickManager.TicksGame;
            }

#if DEBUG
            Verse.Log.Message(string.Format("Musicians: {0}", string.Join(", ", Performances[venueHash].Performers.Select(x => LogMusician(x.Value.Musician, x.Value.Instrument)).ToArray())));
            Verse.Log.Message(string.Format("Quality: {0}", Performances[venueHash].Quality));
#endif
        }
예제 #15
0
        // Token: 0x0600000B RID: 11 RVA: 0x000029EC File Offset: 0x00000BEC
        private Toil StartCollectCorpseToil()
        {
            var toil = new Toil();

            toil.initAction = delegate
            {
                if (Victim == null)
                {
                    toil.actor.jobs.EndCurrentJob(JobCondition.Incompletable);
                }
                else
                {
                    TaleRecorder.RecordTale(TaleDefOf.Hunted, pawn, Victim);
                    var corpse = Victim.Corpse;
                    if (corpse == null || !pawn.CanReserveAndReach(corpse, PathEndMode.ClosestTouch, Danger.Deadly))
                    {
                        pawn.jobs.EndCurrentJob(JobCondition.Incompletable);
                    }
                    else
                    {
                        corpse.SetForbidden(false);
                        if (corpse.InnerPawn.RaceProps.deathActionWorkerClass != null &&
                            !Hunting_Loader.settings.shouldCollectExplodables)
                        {
                            pawn.jobs.EndCurrentJob(JobCondition.Incompletable);
                        }
                        else
                        {
                            if (StoreUtility.TryFindBestBetterStoreCellFor(corpse, pawn, Map, StoragePriority.Unstored,
                                                                           pawn.Faction, out var c))
                            {
                                pawn.Reserve(corpse, job);
                                pawn.Reserve(c, job);
                                job.SetTarget(TargetIndex.B, c);
                                job.SetTarget(TargetIndex.A, corpse);
                                job.count    = 1;
                                job.haulMode = HaulMode.ToCellStorage;
                            }
                            else
                            {
                                pawn.jobs.EndCurrentJob(JobCondition.Succeeded);
                            }
                        }
                    }
                }
            };
            return(toil);
        }
예제 #16
0
 public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients)
 {
     if (billDoer != null)
     {
         if (base.CheckSurgeryFail(billDoer, pawn, ingredients, part))
         {
             return;
         }
         TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[]
         {
             billDoer,
             pawn
         });
     }
     TendUtility.DoTend(billDoer, pawn, ingredients[0] as Medicine);
 }
예제 #17
0
 public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
 {
     if (billDoer != null)
     {
         //if (base.CheckSurgeryFail(billDoer, pawn, ingredients, part))
         //{
         //    return;
         //}
         TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[]
         {
             billDoer,
             pawn
         });
         pawn.health.hediffSet.hediffs.RemoveAll(x => x.def == HediffDefOf.BloodLoss);
     }
 }
예제 #18
0
        private void DoMutationAddedEffects(Pawn pawn)
        {
            IntermittentMagicSprayer.ThrowMagicPuffDown(pawn.Position.ToVector3(), pawn.MapHeld);
            var mDef  = hediff as MutationDef;
            var mTale = tale ?? mDef?.mutationTale;
            var mMem  = memory ?? mDef?.mutationMemory;

            if (mTale != null)
            {
                TaleRecorder.RecordTale(mTale, pawn);
            }
            if (mMem != null)
            {
                TryAddMemory(pawn, mMem);
            }
        }
예제 #19
0
 public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
 {
     if (billDoer != null)
     {
         if (base.CheckSurgeryFailAndroid(billDoer, pawn, ingredients, part, bill))
         {
             return;
         }
         TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[]
         {
             billDoer,
             pawn
         });
         MedicalRecipesUtility.RestorePartAndSpawnAllPreviousParts(pawn, part, billDoer.Position, billDoer.Map);
     }
 }
        private static void Postfix(ref IEnumerable <Toil> __result)
        {
            List <Toil> toils = __result.ToList();
            var         toil  = new Toil();

            toil.initAction = delegate()
            {
                var actor = toil.actor;
                if (Rand.Chance(0.1f))
                {
                    TaleRecorder.RecordTale(VSIE_DefOf.VSIE_ExposedCorpseOfMyFriend, (actor.CurJob.GetTarget(TargetIndex.A).Thing as Corpse).InnerPawn, actor);
                }
            };
            toils.Add(toil);
            __result = toils;
        }
 public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
 {
     if (billDoer != null)
     {
         if (base.CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
         {
             return;
         }
         TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[]
         {
             billDoer,
             pawn
         });
         pawn.health.RestorePart(part, null, true);
     }
 }
예제 #22
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients,
                                         Bill bill)
        {
            if (billDoer == null)
            {
                return;
            }

            if (!CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
            {
                TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);

                var trait = pawn?.story?.traits?.allTraits?.Where(x => x.def.defName == "Immunity")
                            .FirstOrDefault();
                if (trait != null && trait.Degree == -1)
                {
                    PS_TraitChanger.Remove(pawn, new Trait(DefDatabase <TraitDef> .GetNamed("Immunity"), -1));
                }
                else if (trait == null)
                {
                    PS_TraitChanger.AddTrait(pawn, new Trait(DefDatabase <TraitDef> .GetNamed("Immunity"), 1));
                }

                Messages.Message(
                    string.Format("PS_Messages_SurgeryResult_Success".Translate(), billDoer.LabelShort,
                                  pawn?.LabelShort, "PS_Messages_Surgery_ImmunityBoost".Translate()), new LookTargets(pawn),
                    MessageTypeDefOf.TaskCompletion);
            }
            else
            {
                var trait = pawn?.story?.traits?.allTraits?.Where(x => x.def.defName == "Immunity")
                            .FirstOrDefault();
                if (trait != null && trait.Degree == 1)
                {
                    PS_TraitChanger.Remove(pawn, new Trait(DefDatabase <TraitDef> .GetNamed("Immunity"), 1));
                }
                else if (trait == null)
                {
                    PS_TraitChanger.AddTrait(pawn, new Trait(DefDatabase <TraitDef> .GetNamed("Immunity"), -1));
                }

                Messages.Message(
                    string.Format("PS_Messages_SurgeryResult_Botched".Translate(), billDoer.LabelShort,
                                  pawn?.LabelShort, "PS_Messages_Surgery_ImmunityBoost".Translate()), new LookTargets(pawn),
                    MessageTypeDefOf.NegativeHealthEvent);
            }
        }
예제 #23
0
        /*public override void ConsumeIngredient(Thing ingredient, RecipeDef recipe, Map map)
         * {
         * }*/

        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            bool flag = this.IsViolationOnPawn(pawn, part, Faction.OfPlayer);

            if (billDoer != null)
            {
                if (base.CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
                {
                    return;
                }
                TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[]
                {
                    billDoer,
                    pawn
                });
            }
            CompNeurotrainer compNeurotrainer = ingredients[0].TryGetComp <CompNeurotrainer>();

            if (compNeurotrainer != null && !pawn.abilities.abilities.NullOrEmpty())
            {
                List <DebugMenuOption> list = new List <DebugMenuOption>();
                foreach (Ability ability in pawn.abilities.abilities)
                {
                    list.Add(new DebugMenuOption(ability.def.LabelCap, DebugMenuOptionMode.Action, delegate()
                    {
                        compNeurotrainer.ability = ability.def;
                        string thingDefName      = NeurotrainerDefGenerator.PsytrainerDefPrefix + "_" + ability.def.defName;
                        ThingDef thingDef        = DefDatabase <ThingDef> .AllDefsListForReading.Find(x => x.defName.Equals(thingDefName));
                        //Thing thing = ThingMaker.MakeThing(thingDef, null);
                        //GenPlace.TryPlaceThing(thing, pawn.Position, billDoer.Map, ThingPlaceMode.Near);
                        GenSpawn.Spawn(thingDef, pawn.Position, pawn.Map, WipeMode.Vanish);
                        string abilityName = ability.def.LabelCap;
                        pawn.abilities.abilities.Remove(ability);
                        Messages.Message("PolarisExtractAbilitySuccessfully".Translate(pawn.NameShortColored, abilityName), pawn, MessageTypeDefOf.NeutralEvent, true);
                        if (flag)
                        {
                            base.ReportViolation(pawn, billDoer, pawn.FactionOrExtraHomeFaction, -70, "PolarisGoodwillChangedReason_ExtractedAbility".Translate(pawn.NameShortColored));
                        }
                    }));
                }
                Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
            }
            else
            {
                Messages.Message("PolarisExtractAbilityFailed".Translate(pawn.NameShortColored), pawn, MessageTypeDefOf.NeutralEvent, true);
            }
        }
 private static void Prefix(Pawn __instance, Faction newFaction, Pawn recruiter = null)
 {
     if (newFaction != __instance.Faction && __instance.Faction.HostileTo(newFaction))
     {
         if (Rand.Chance(0.1f))
         {
             TaleRecorder.RecordTale(VSIE_DefOf.VSIE_WasPreviouslyOurEnemy, __instance);
         }
     }
     if (__instance.IsWildMan() && recruiter != null)
     {
         if (Rand.Chance(0.1f))
         {
             TaleRecorder.RecordTale(VSIE_DefOf.VSIE_TamedMe, __instance, recruiter);
         }
     }
 }
        private static void Postfix(ref IEnumerable <Toil> __result)
        {
            List <Toil> toils = __result.ToList();
            var         toil  = new Toil();

            toil.initAction = delegate()
            {
                if (Rand.Chance(0.1f))
                {
                    var actor       = toil.actor;
                    var resurrected = (actor.CurJob.targetA.Thing as Corpse).InnerPawn;
                    TaleRecorder.RecordTale(VSIE_DefOf.VSIE_ResurrectedMe, resurrected, actor);
                }
            };
            toils.Insert(toils.Count - 1, toil);
            __result = toils;
        }
예제 #26
0
        private static void RecruitingSuccess(Pawn guest, int recruitPenalty)
        {
            if (guest.Faction != Faction.OfPlayer)
            {
                if (guest.Faction != null)
                {
                    guest.Faction.TryAffectGoodwillWith(Faction.OfPlayer, -recruitPenalty, false, true, null, guest);
                    if (recruitPenalty >= 1)
                    {
                        // TODO: Use Translate instead of Format
                        string message;
                        if (guest.Faction.leader != null)
                        {
                            message = Format(txtRecruitFactionAnger, guest.Faction.leader.Name, guest.Faction.Name, guest.Name.ToStringShort, GenText.ToStringByStyle(-recruitPenalty, ToStringStyle.Integer, ToStringNumberSense.Offset));
                            Find.LetterStack.ReceiveLetter(labelRecruitFactionChiefAnger, message, LetterDefOf.NegativeEvent, GlobalTargetInfo.Invalid, guest.Faction);
                        }
                        else
                        {
                            message = Format(txtRecruitFactionAngerLeaderless, guest.Faction.Name, guest.Name.ToStringShort, GenText.ToStringByStyle(-recruitPenalty, ToStringStyle.Integer, ToStringNumberSense.Offset));
                            Find.LetterStack.ReceiveLetter(labelRecruitFactionAnger, message, LetterDefOf.NegativeEvent, GlobalTargetInfo.Invalid, guest.Faction);
                        }
                    }
                    else if (recruitPenalty <= -1)
                    {
                        // TODO: Use Translate instead of Format
                        string message;
                        if (guest.Faction.leader != null)
                        {
                            message = Format(txtRecruitFactionPlease, guest.Faction.leader.Name, guest.Faction.Name, guest.Name.ToStringShort, GenText.ToStringByStyle(-recruitPenalty, ToStringStyle.Integer, ToStringNumberSense.Offset));
                            Find.LetterStack.ReceiveLetter(labelRecruitFactionChiefPlease, message, LetterDefOf.PositiveEvent, GlobalTargetInfo.Invalid, guest.Faction);
                        }
                        else
                        {
                            message = Format(txtRecruitFactionPleaseLeaderless, guest.Faction.Name, guest.Name.ToStringShort, GenText.ToStringByStyle(-recruitPenalty, ToStringStyle.Integer, ToStringNumberSense.Offset));
                            Find.LetterStack.ReceiveLetter(labelRecruitFactionPlease, message, LetterDefOf.PositiveEvent, GlobalTargetInfo.Invalid, guest.Faction);
                        }
                    }
                }

                guest.Adopt();
            }

            var taleParams = new object[] { guest.MapHeld.mapPawns.FreeColonistsSpawned.RandomElement(), guest };

            TaleRecorder.RecordTale(TaleDef.Named("Recruited"), taleParams);
        }
        private void ActionFight(Caravan caravan, List <Pawn> attackers)
        {
            Faction enemyFaction = attackers[0].Faction;

            TaleRecorder.RecordTale(TaleDefOf.CaravanAmbushedByHumanlike, caravan.RandomOwner());
            LongEventHandler.QueueLongEvent(delegate
            {
                Map map = CaravanIncidentUtility.SetupCaravanAttackMap(caravan, attackers, sendLetterIfRelatedPawns: true);
                LordJob_AssaultColony lordJob_AssaultColony = new LordJob_AssaultColony(enemyFaction, canKidnap: true, canTimeoutOrFlee: false);
                if (lordJob_AssaultColony != null)
                {
                    LordMaker.MakeNewLord(enemyFaction, lordJob_AssaultColony, map, attackers);
                }
                Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
                CameraJumper.TryJump(attackers[0]);
            }, "GeneratingMapForNewEncounter", false, null);
        }
 private static void RecordTale(Pawn worker, Corpse corpse)
 {
     if (worker.IsColonist)
     {
         TaleDef tale;
         if (corpse.InnerPawn.IsColonist)
         {
             if (worker.skills.GetSkill(SkillDefOf.Medicine).passion == Passion.None)
             {
                 tale = DissectionDefOf.DissectedColonistWithoutPassionTale;
             }
             else
             {
                 tale = DissectionDefOf.DissectedColonistWithPassionTale;
             }
         }
         else if ((corpse.InnerPawn.Faction != null && corpse.InnerPawn.Faction.PlayerRelationKind == FactionRelationKind.Hostile) ||
                  (corpse.InnerPawn.guilt != null && corpse.InnerPawn.guilt.IsGuilty))
         {
             if (worker.skills.GetSkill(SkillDefOf.Medicine).passion == Passion.None)
             {
                 tale = DissectionDefOf.DissectedEnemyWithoutPassionTale;
             }
             else
             {
                 tale = DissectionDefOf.DissectedEnemyWithPassionTale;
             }
         }
         else
         {
             if (worker.skills.GetSkill(SkillDefOf.Medicine).passion == Passion.None)
             {
                 tale = DissectionDefOf.DissectedStrangerWithoutPassionTale;
             }
             else
             {
                 tale = DissectionDefOf.DissectedStrangerWithPassionTale;
             }
         }
         TaleRecorder.RecordTale(tale, new object[]
         {
             worker,
             corpse.InnerPawn
         });
     }
 }
 internal static void _ApplyOnPawn(this Recipe_InstallImplant r, Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients)
 {
     if (billDoer != null)
     {
         if (_Recipe_MedicalOperation._CheckSurgeryFail(r, billDoer, pawn, ingredients))
         {
             return;
         }
         TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[]
         {
             billDoer,
             pawn
         });
         billDoer.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOfPsychology.ReplacedPartBleedingHeart, pawn);
     }
     pawn.health.AddHediff(r.recipe.addsHediff, part, null);
 }
예제 #30
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            if (billDoer != null)
            {
                if (!PawnHelper.isHaveHediff(pawn, HediffDefOf.LifeStages_Youth) && CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
                {
                    return;
                }
                TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);
            }

            PawnHelper.ResolveTransgender(pawn);

            pawn.gender = newGender(pawn);

            resolveSexOrgans(pawn);
        }