// Token: 0x06000087 RID: 135 RVA: 0x00005106 File Offset: 0x00003306 protected override IEnumerable <Toil> MakeNewToils() { Toil toil = new Toil { initAction = delegate() { this.ticksLeft = Rand.Range(300, 900); int num = 0; IntVec3 c; do { c = this.pawn.Position + GenAdj.AdjacentCellsAndInside[Rand.Range(0, 9)]; num++; if (num > 12) { goto IL_6B; } }while (!c.InBounds(this.pawn.Map) || !c.Standable(this.pawn.Map)); goto IL_77; IL_6B: c = this.pawn.Position; IL_77: this.job.targetA = c; this.pawn.pather.StopDead(); }, tickAction = delegate() { if (this.ticksLeft % 150 == 149) { FilthMaker.TryMakeFilth(this.job.targetA.Cell, base.Map, ThingDefOf.Filth_BlueVomit, this.pawn.LabelIndefinite(), 1); if (this.pawn.needs.food.CurLevelPercentage > 0.1f) { this.pawn.needs.food.CurLevel -= this.pawn.needs.food.MaxLevel * 0.04f; } } this.ticksLeft--; if (this.ticksLeft <= 0) { base.ReadyForNextToil(); TaleRecorder.RecordTale(TaleDefOf.Vomited, new object[] { this.pawn }); } }, defaultCompleteMode = ToilCompleteMode.Never }; toil.WithEffect(EffecterDefOf.Blue_Vomit, TargetIndex.A); toil.PlaySustainerOrSound(() => SoundDefOf.Vomit); yield return(toil); yield break; }
public static void ApplyTaleDef(string defName, Pawn pawn) { TaleDef taleToAdd = TaleDef.Named(defName); if ((pawn.IsColonist || pawn.HostFaction == Faction.OfPlayer) && taleToAdd != null) { TaleRecorder.RecordTale(taleToAdd, new object[] { pawn, }); } }
public static void TryRecordSavedMeFromRaiders(Pawn assaulter, DamageInfo?dinfo) { Pawn target = assaulter.mindState.enemyTarget as Pawn; if (target != null && target?.mindState?.meleeThreat == assaulter && dinfo.Value.Instigator != null && dinfo.Value.Instigator is Pawn saviour && target != saviour) { if (Rand.Chance(0.1f)) { TaleRecorder.RecordTale(VSIE_DefOf.VSIE_SavedMeFromRaiders, target, saviour, assaulter); } } }
private void CheckWonBattle() { if (!wonBattle && !GenHostility.AnyHostileActiveThreatToPlayer(base.Map)) { TimedDetectionRaids component = GetComponent <TimedDetectionRaids>(); component.SetNotifiedSilently(); string detectionCountdownTimeLeftString = component.DetectionCountdownTimeLeftString; Find.LetterStack.ReceiveLetter("LetterLabelCaravansBattlefieldVictory".Translate(), "LetterCaravansBattlefieldVictory".Translate(detectionCountdownTimeLeftString), LetterDefOf.PositiveEvent, this); TaleRecorder.RecordTale(TaleDefOf.CaravanAmbushDefeated, base.Map.mapPawns.FreeColonists.RandomElement()); wonBattle = true; } }
private void CheckStartForceExitAndRemoveMapCountdown() { if (!this.startedCountdown && !GenHostility.AnyHostileActiveThreatToPlayer(base.Map)) { this.startedCountdown = true; int num = Mathf.RoundToInt((float)(this.core.forceExitAndRemoveMapCountdownDurationDays * 60000.0)); string text = (!this.anyEnemiesInitially) ? "MessageSiteCountdownBecauseNoEnemiesInitially".Translate(TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(num)) : "MessageSiteCountdownBecauseNoMoreEnemies".Translate(TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(num)); Messages.Message(text, this, MessageTypeDefOf.PositiveEvent); base.GetComponent <TimedForcedExit>().StartForceExitAndRemoveMapCountdown(num); TaleRecorder.RecordTale(TaleDefOf.CaravanAssaultSuccessful, base.Map.mapPawns.FreeColonists.RandomElement()); } }
private static void Prefix(Pawn victim) { if (victim != null && victim == Recipe_Patch._pawn) { if (Rand.Chance(0.1f)) { TaleRecorder.RecordTale(VSIE_DefOf.VSIE_RemovedPrisonersOrgans, Recipe_Patch._billDoer); } Recipe_Patch._pawn = null; Recipe_Patch._billDoer = null; } }
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, billDoer, pawn); this.ChangeBioAge(pawn); } }
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, new object[] { 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(); } } }
private void TradeButtonPressed() { Close(); var fulfilledFullRequest = true; var totalRequestedValue = deal.TotalRequestedValue; var lord = traderPawn.GetLord(); if (playerPawn.Map.resourceCounter.Silver < totalRequestedValue) { Messages.Message("IR.FulfillItemRequestWindow.NotEnoughSilverMessage".Translate(), MessageTypeDefOf.NegativeEvent); lord.ReceiveMemo(LordJob_FulfillItemRequest.MemoOnUnfulfilled); } else { if (traderPawn == null) { Log.Error("Trader pawn unable to be cast to ITrader!"); return; } foreach (var requested in requestedItems) { if (requested.removed) { fulfilledFullRequest = false; } else { SpawnItem(requested); } } if (fulfilledFullRequest) { traderFaction.Notify_PlayerTraded(totalRequestedValue, playerPawn); TaleRecorder.RecordTale(TaleDefOf.TradedWith, playerPawn, traderPawn); lord.ReceiveMemo(LordJob_FulfillItemRequest.MemoOnFulfilled); } else { lord.ReceiveMemo(DetermineUnfulfilledValue()); } UpdateColonyCurrency(Mathf.RoundToInt(totalRequestedValue)); } Find.World.GetComponent <RequestSession>().CloseOpenDealWith(traderFaction); }
public void ShipUnload(bool wasDestroyed = false, bool dropPawns = true, bool dropitems = false) { List <Thing> allCargo = new List <Thing>(); allCargo.AddRange(this.GetDirectlyHeldThings()); for (int i = 0; i < allCargo.Count; i++) { Thing thing = allCargo[i]; Thing thing2; if (wasDestroyed && Rand.Range(0, 1f) < 0.3f) { thing.Destroy(DestroyMode.KillFinalize); } else { Pawn pawn1 = thing as Pawn; if (pawn1 != null && dropPawns && !pawn1.IsPrisoner && pawn1.def.race.Humanlike || (dropitems && thing.GetType() != typeof(Pawn))) { if (this.GetDirectlyHeldThings().TryDrop(thing, base.Position, this.Map, ThingPlaceMode.Near, out thing2, delegate(Thing placedThing, int count) { if (Find.TickManager.TicksGame < 1200 && TutorSystem.TutorialMode && placedThing.def.category == ThingCategory.Item) { Find.TutorialState.AddStartingItem(placedThing); } })) { Pawn pawn2 = thing2 as Pawn; if (pawn2 != null) { if (pawn2.RaceProps.Humanlike) { TaleRecorder.RecordTale(TaleDefOf.LandedInPod, new object[] { pawn2 }); } if (pawn2.IsColonist && pawn2.Spawned && !base.Map.IsPlayerHome) { pawn2.drafter.Drafted = true; } } } } else if (dropitems && thing.GetType() != typeof(Pawn)) { this.GetDirectlyHeldThings().TryDrop(thing, ThingPlaceMode.Near, out thing); } } } SoundDef.Named("DropPodOpen").PlayOneShot(new TargetInfo(base.Position, base.Map, false)); }
// Token: 0x0600264B RID: 9803 RVA: 0x00123038 File Offset: 0x00121438 public override void AttachTo(Thing parent) { base.AttachTo(parent); Pawn pawn = parent as Pawn; if (pawn != null) { TaleRecorder.RecordTale(TaleDefOf.WasOnFire, new object[] { pawn }); } }
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill) { TaleRecorder.RecordTale(TaleDefOf.DidSurgery, (object)billDoer, (object)pawn); var missingParts = BodyPartRecordsMissing(pawn); foreach (var record in missingParts) { MedicalRecipesUtility.RestorePartAndSpawnAllPreviousParts(pawn, record, billDoer.Position, billDoer.Map); } }
private static void Postfix(LordJob_Joinable_MarriageCeremony __instance) { List <Pawn> attendedWedding = new List <Pawn>(); List <Pawn> ownedPawns = __instance.lord.ownedPawns; for (int i = 0; i < ownedPawns.Count; i++) { if (__instance.firstPawn.Position.InHorDistOf(ownedPawns[i].Position, 18f) || __instance.secondPawn.Position.InHorDistOf(ownedPawns[i].Position, 18f)) { attendedWedding.Add(ownedPawns[i]); } } foreach (var pawn in attendedWedding) { if (pawn != __instance.firstPawn) { if (Rand.Chance(0.1f)) { TaleRecorder.RecordTale(VSIE_DefOf.VSIE_AttendedMyWedding, __instance.firstPawn, pawn); } } else if (pawn != __instance.secondPawn) { if (Rand.Chance(0.1f)) { TaleRecorder.RecordTale(VSIE_DefOf.VSIE_AttendedMyWedding, __instance.secondPawn, pawn); } } } foreach (var pawn in __instance.lord.Map.mapPawns.AllPawns.Where(x => x.IsColonist)) { if (!attendedWedding.Contains(pawn)) { if (attendedWedding.Contains(__instance.firstPawn)) { if (Rand.Chance(0.1f)) { TaleRecorder.RecordTale(VSIE_DefOf.VSIE_DidNotAttendWedding, __instance.firstPawn, pawn); } } if (attendedWedding.Contains(__instance.secondPawn)) { if (Rand.Chance(0.1f)) { TaleRecorder.RecordTale(VSIE_DefOf.VSIE_DidNotAttendWedding, __instance.secondPawn, pawn); } } } } }
// Token: 0x06000C80 RID: 3200 RVA: 0x0003DF08 File Offset: 0x0003C108 internal static void _Interacted(this InteractionWorker_RomanceAttempt _this, Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks) { if (Rand.Value < _SuccessChance(_this, initiator, recipient)) { List <Pawn> list; _BreakLoverAndFianceRelations(_this, initiator, out list); List <Pawn> list2; _BreakLoverAndFianceRelations(_this, recipient, out list2); for (int i = 0; i < list.Count; i++) { _TryAddCheaterThought(_this, list[i], initiator); } for (int j = 0; j < list2.Count; j++) { _TryAddCheaterThought(_this, list2[j], recipient); } initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.ExLover, recipient); initiator.relations.AddDirectRelation(PawnRelationDefOf.Lover, recipient); TaleRecorder.RecordTale(TaleDefOf.BecameLover, new object[] { initiator, recipient }); initiator.needs.mood.thoughts.memories.RemoveSocialMemoryThoughts(ThoughtDefOf.BrokeUpWithMe, recipient); recipient.needs.mood.thoughts.memories.RemoveSocialMemoryThoughts(ThoughtDefOf.BrokeUpWithMe, initiator); initiator.needs.mood.thoughts.memories.RemoveSocialMemoryThoughts(ThoughtDefOfPsychology.BrokeUpWithMeCodependent, recipient); recipient.needs.mood.thoughts.memories.RemoveSocialMemoryThoughts(ThoughtDefOfPsychology.BrokeUpWithMeCodependent, initiator); initiator.needs.mood.thoughts.memories.RemoveSocialMemoryThoughts(ThoughtDefOf.FailedRomanceAttemptOnMe, recipient); recipient.needs.mood.thoughts.memories.RemoveSocialMemoryThoughts(ThoughtDefOf.FailedRomanceAttemptOnMe, initiator); if (initiator.IsColonist || recipient.IsColonist) { var _SendNewLoversLetter = typeof(InteractionWorker_RomanceAttempt).GetMethod("SendNewLoversLetter", BindingFlags.Instance | BindingFlags.NonPublic); if (_SendNewLoversLetter != null) { _SendNewLoversLetter.Invoke(_this, new object[] { initiator, recipient, list, list2 }); } else { Log.ErrorOnce("Unable to reflect InteractionWorker_RomanceAttempt.SendNewLoversLetter!", 305432421); } } extraSentencePacks.Add(RulePackDefOf.Sentence_RomanceAttemptAccepted); LovePartnerRelationUtility.TryToShareBed(initiator, recipient); } else { initiator.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOf.RebuffedMyRomanceAttempt, recipient); recipient.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOf.FailedRomanceAttemptOnMe, initiator); extraSentencePacks.Add(RulePackDefOf.Sentence_RomanceAttemptRejected); } }
/*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 (!pawn.abilities.abilities.NullOrEmpty()) { List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (Ability ability in pawn.abilities.abilities) { //compNeurotrainer.ability = ability.def; string thingDefName = ThingDefGenerator_Neurotrainer.PsytrainerDefPrefix + "_" + ability.def.defName; ThingDef thingDef = DefDatabase <ThingDef> .AllDefsListForReading.Find(x => x.defName.Equals(thingDefName)); if (thingDef != null) { list.Add(new DebugMenuOption(ability.def.LabelCap, DebugMenuOptionMode.Action, delegate() { /*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.HomeFaction, -70); //base.ReportViolation(pawn, billDoer, pawn.FactionOrExtraMiniOrHomeFaction, -70, "PolarisGoodwillChangedReason_ExtractedAbility".Translate(pawn.NameShortColored)); } })); } } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); } else { Messages.Message("PolarisExtractAbilityFailed".Translate(pawn.NameShortColored), pawn, MessageTypeDefOf.NeutralEvent, true); } }
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); }
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); } }
public static void CheckDefeated(Settlement factionBase) { if (factionBase.Faction == Faction.OfPlayer) { return; } Map map = factionBase.Map; if (map == null || !IsDefeated(map, factionBase.Faction)) { return; } DestroyedSettlement destroyedSettlement = (DestroyedSettlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.DestroyedSettlement); destroyedSettlement.Tile = factionBase.Tile; destroyedSettlement.SetFaction(factionBase.Faction); Find.WorldObjects.Add(destroyedSettlement); TimedDetectionRaids component = destroyedSettlement.GetComponent <TimedDetectionRaids>(); component.CopyFrom(factionBase.GetComponent <TimedDetectionRaids>()); component.SetNotifiedSilently(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("LetterFactionBaseDefeated".Translate(factionBase.Label, component.DetectionCountdownTimeLeftString)); if (!HasAnyOtherBase(factionBase)) { factionBase.Faction.defeated = true; stringBuilder.AppendLine(); stringBuilder.AppendLine(); stringBuilder.Append("LetterFactionBaseDefeated_FactionDestroyed".Translate(factionBase.Faction.Name)); } foreach (Faction allFaction in Find.FactionManager.AllFactions) { if (!allFaction.Hidden && !allFaction.IsPlayer && allFaction != factionBase.Faction && allFaction.HostileTo(factionBase.Faction)) { FactionRelationKind playerRelationKind = allFaction.PlayerRelationKind; if (allFaction.TryAffectGoodwillWith(Faction.OfPlayer, 20, canSendMessage: false, canSendHostilityLetter: false)) { stringBuilder.AppendLine(); stringBuilder.AppendLine(); stringBuilder.Append("RelationsWith".Translate(allFaction.Name) + ": " + 20.ToStringWithSign()); allFaction.TryAppendRelationKindChangedInfo(stringBuilder, playerRelationKind, allFaction.PlayerRelationKind); } } } Find.LetterStack.ReceiveLetter("LetterLabelFactionBaseDefeated".Translate(), stringBuilder.ToString(), LetterDefOf.PositiveEvent, new GlobalTargetInfo(factionBase.Tile), factionBase.Faction); map.info.parent = destroyedSettlement; factionBase.Destroy(); TaleRecorder.RecordTale(TaleDefOf.CaravanAssaultSuccessful, map.mapPawns.FreeColonists.RandomElement()); }
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; } }
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>() }); }
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); }
/// <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); }
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); }
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); } }
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 }
// 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); }
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); }
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); } }