public override void PostMapGenerate(Map map) { base.PostMapGenerate(map); this.MakeMuffalo(map); this.QueueArrivals(map); if (Rand.Chance(0.05f)) { IEnumerable <Pawn> source = from p in map.mapPawns.FreeColonistsSpawned where p.story.traits.HasTrait(TraitDef.Named("PsychicSensitivity")) select p; if (source.Count <Pawn>() > 0) { Pawn pawn = source.RandomElement <Pawn>(); Find.LetterStack.ReceiveLetter("RD_ManhunterDanger".Translate(), "RD_MalevolentPsychicDesc".Translate(pawn.Named("PAWN")) //"{0} believes that a malevolent psychic energy is massing, and that this peaceful herd of muffalo are on the brink of a mass insanity." , LetterDefOf.ThreatSmall, null); } //TODO: check if it works IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.FactionArrival, map); incidentParms.forced = true; incidentParms.points = 100f; QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDef.Named("RD_MuffaloMassInsanity"), null, incidentParms), Find.TickManager.TicksGame + Rand.RangeInclusive(10000, 45000)); Find.Storyteller.incidentQueue.Add(qi); } }
protected override bool TryExecuteWorker(IncidentParms parms) { var map = (Map)parms.target; var sacrificeTracker = map.GetComponent <MapComponent_SacrificeTracker>(); if (sacrificeTracker == null) { return(Utility.ResultFalseWithReport(new StringBuilder("Missing map component."))); } if (sacrificeTracker.unspeakableOathPawns == null) { sacrificeTracker.unspeakableOathPawns = new List <Pawn>(); } if (!Utility.IsActorAvailable(executioner(map))) { Messages.Message("Executioner is unavailable.", MessageTypeDefOf.RejectInput); return(false); } executioner(map).story.traits.GainTrait(new Trait(TraitDef.Named("Cults_OathtakerHastur"))); sacrificeTracker.unspeakableOathPawns.Add(executioner(map)); return(true); }
// Token: 0x0600000C RID: 12 RVA: 0x00002610 File Offset: 0x00000810 public static void Postfix(SkillRecord __instance) { var traverse = Traverse.Create(__instance); var value = traverse.Field("pawn").GetValue <Pawn>(); if (API.hasTrait(value)) { return; } if (!__instance.def.Equals(SkillDefOf.Melee)) { return; } if (__instance.levelInt != 20) { return; } value.story.traits.GainTrait(new Trait(TraitDef.Named("ProjectileInversion_Trait"))); var isColonist = value.IsColonist; if (isColonist) { Messages.Message( "YourPawnGainProjectileInversionTraitMsg".Translate(value.Label, TraitDef.Named("ProjectileInversion_Trait").degreeDatas.RandomElement().label.Translate()), value, MessageTypeDefOf.PositiveEvent); } }
public void TakeWillpowerHit(float severity) { if (pawn.story.traits.HasTrait(TraitDef.Named("Wimp"))) { severity *= 2; } if (pawn.story.traits.HasTrait(TraitDefOf.Nerves)) { int nerveDegree = pawn.story.traits.GetTrait(TraitDefOf.Nerves).Degree; if (nerveDegree > 0) { severity /= nerveDegree; } else if (nerveDegree < 0) { severity *= -nerveDegree; } } if (severity > 0) { severity *= SimpleSlavery.WillpowerFallRate; } willpower -= severity * 0.05f; if (willpower < 0) { willpower = 0; } //Log.Message ("DEBUG: Slave " + pawn.NameStringShort + " Willpower = " + willpower); }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Reserve.Reserve(TargetIndex.A, 4, 0, null)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); Toil t2 = Toils_General.Wait(6000); t2.AddFailCondition(() => this.Building.GetComp <CompWeatherSat>() == null); t2 = t2.WithEffect(EffecterDefOf.Research, TargetIndex.A); t2.tickAction = delegate() { float num = 0.0002f; num *= 1f + 0.5f * (float)base.GetActor().story.traits.DegreeOfTrait(TraitDef.Named("PsychicSensitivity")); CompWeatherSat comp = this.Building.GetComp <CompWeatherSat>(); if (comp != null) { comp.mana += num; if (comp.mana < 0f) { comp.mana = 0f; } if (comp.mana > 100f) { comp.mana = 100f; } } }; yield return(t2); yield return(Toils_Reserve.Release(TargetIndex.A)); yield break; }
public static Pawn FindBestPsychic(IEnumerable <IntVec3> within, Map map) { Pawn pawn = null; foreach (IntVec3 c in within) { foreach (Thing thing in c.GetThingList(map)) { if (thing.def.category == ThingCategory.Pawn && thing.def.race.intelligence == Intelligence.Humanlike) { Pawn pawn2 = thing as Pawn; int num = pawn2.story.traits.DegreeOfTrait(TraitDef.Named("PsychicSensitivity")); if (num > 0) { if (pawn == null) { pawn = pawn2; } else if (pawn.story.traits.DegreeOfTrait(TraitDef.Named("PsychicSensitivity")) < num) { pawn = pawn2; } } } } } return(pawn); }
public static void RandomlyDamagePawn(Pawn pawn, int injuriesNumber, int damageAmount) { if (pawn.story.traits.HasTrait(TraitDef.Named("Wimp"))) { // Do not hurt wimp pawns as they could be spawned as dead and break the lord behavior. return; } HediffSet hediffSet = pawn.health.hediffSet; int injuriesIndex = 0; while ((pawn.Dead == false) && (injuriesIndex < injuriesNumber) && HittablePartsViolence(hediffSet).Any <BodyPartRecord>()) { injuriesIndex++; BodyPartRecord bodyPartRecord = HittablePartsViolence(hediffSet).RandomElementByWeight((BodyPartRecord x) => x.coverageAbs); DamageDef def; if (bodyPartRecord.depth == BodyPartDepth.Outside) { def = HealthUtility.RandomViolenceDamageType(); } else { def = DamageDefOf.Blunt; } BodyPartRecord forceHitPart = bodyPartRecord; DamageInfo dinfo = new DamageInfo(def, damageAmount, 0f, -1f, null, forceHitPart, null, DamageInfo.SourceCategory.ThingOrUnknown); pawn.TakeDamage(dinfo); } }
protected override bool TryCastShot() { Map map = base.CasterPawn.Map; Pawn pawn = base.CasterPawn; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); List <Trait> traits = pawn.story.traits.allTraits; for (int i = 0; i < traits.Count; i++) { if (traits[i].def.defName == "Necromancer") { FixTrait(pawn, pawn.story.traits.allTraits); AdjustPlayerSettings(pawn); pawn.story.traits.GainTrait(new Trait(TraitDef.Named("Lich"), 4, false)); HealthUtility.AdjustSeverity(pawn, HediffDef.Named("TM_LichHD"), .5f); for (int h = 0; h < 24; h++) { pawn.timetable.SetAssignment(h, TimeAssignmentDefOf.Work); } pawn.needs.AddOrRemoveNeedsAsAppropriate(); comp.AddPawnAbility(TorannMagicDefOf.TM_DeathBolt, false); comp.spell_Flight = true; comp.InitializeSpell(); TM_MoteMaker.ThrowScreamMote(pawn.Position.ToVector3(), pawn.Map, 2f, 216, 255, 0); } else { //Log.Message("Necromancer trait not found."); } } this.burstShotsLeft = 0; return(false); }
protected override bool TryCastShot() { Map map = base.CasterPawn.Map; Pawn pawn = base.CasterPawn; CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); MightPowerSkill pwr = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_SniperFocus.FirstOrDefault((MightPowerSkill x) => x.label == "TM_SniperFocus_pwr"); List <Trait> traits = this.CasterPawn.story.traits.allTraits; for (int i = 0; i < traits.Count; i++) { if (traits[i].def.defName == "TM_Sniper") { if (traits[i].Degree < pwr.level) { traits.Remove(traits[i]); this.CasterPawn.story.traits.GainTrait(new Trait(TraitDef.Named("TM_Sniper"), pwr.level, false)); MoteMaker.ThrowHeatGlow(base.CasterPawn.Position, map, 2); } } } this.burstShotsLeft = 0; return(false); }
public void Scan(Corpse c) { if (this.Emitter.TryAcceptThing(c, true)) { c.InnerPawn.story.traits.GainTrait(new Trait(TraitDef.Named("RD_Holographic"), 0, false)); } }
public void HasturResurrection() { Pawn sourceCorpse = toBeResurrected.RandomElement(); toBeResurrected.Remove(sourceCorpse); IntVec3 spawnLoc = IntVec3.Invalid; if (sourceCorpse.Corpse != null) { //Use B18's Resurrect Feature ResurrectionUtility.Resurrect(sourceCorpse); //Remove everything that conflicts with Psychopathic behavior sourceCorpse.story.traits.allTraits.RemoveAll( x => (x.def.conflictingTraits is List <TraitDef> conflicts && !conflicts.NullOrEmpty() && conflicts.Contains(TraitDefOf.Psychopath)) || x.def.defName == "Cults_OathtakerHastur"); //Remove a random trait and add Psychopath if (sourceCorpse.story.traits.allTraits is List <Trait> allTraits && allTraits.Count > 1 && allTraits.FirstOrDefault(x => x.def == TraitDefOf.Psychopath) == null) { sourceCorpse.story.traits.allTraits.RemoveLast(); sourceCorpse.story.traits.GainTrait(new Trait(TraitDefOf.Psychopath, 0, true)); } //Adds the "Reanimated" trait sourceCorpse.story.traits.GainTrait(new Trait(TraitDef.Named("Cults_OathtakerHastur2"), 0, true)); //Message to the player #pragma warning disable CS0618 // Type or member is obsolete Messages.Message("ReanimatedOath".Translate(sourceCorpse.Name), MessageTypeDefOf.PositiveEvent); #pragma warning restore CS0618 // Type or member is obsolete } }
protected override ThoughtState CurrentSocialStateInternal(Pawn p, Pawn other) { if (!p.RaceProps.Humanlike) { return(false); } if (!p.story.traits.HasTrait(TraitDef.Named("BodyModificationEnthusiast"))) { return(false); } if (!RelationsUtility.PawnsKnowEachOther(p, other)) { return(false); } if (other.def != p.def) { return(false); } int num = Internal.countBodyMods(other.health.hediffSet); if (num > 0) { return(ThoughtState.ActiveAtStage(num - 1)); } return(false); }
public static bool IsMage(this Pawn pawn) { if (pawn?.story?.traits?.HasTrait(TraitDef.Named("LotRW_MagicAttuned")) ?? false) { return(true); } return(false); }
public static bool IsIstari(this Pawn pawn) { if (pawn?.story?.traits?.HasTrait(TraitDef.Named("LotRW_Istari")) ?? false) { return(true); } return(false); }
public void ChangeTraitDegreeIfConditionReached(float timesInMentalState) { if (pawn.story.traits.DegreeOfTrait(TraitDef.Named("Nerves")) == -1) { pawn.story.traits.allTraits.Remove(new Trait(TraitDefOf.Nerves, -1, false)); pawn.story.traits.GainTrait(new Trait(TraitDefOf.Nerves, -2, false)); } }
public static void ReplaceTraitInnocent(ref Pawn pawn) { List <Trait> traitpool = new List <Trait>(); Pawn mother = pawn.GetMother(); Pawn father = pawn.GetFather(); if (mother != null && mother.RaceProps.Humanlike) { foreach (Trait momtrait in mother.story.traits.allTraits) { traitpool.Add(momtrait); } } if (father != null && mother.RaceProps.Humanlike) { foreach (Trait fatrait in father.story.traits.allTraits) { traitpool.Add(fatrait); } } traitpool.Add(new Trait(TraitDef.Named("Kind"))); traitpool.Add(new Trait(TraitDef.Named("Bloodlust"))); traitpool.Add(new Trait(TraitDef.Named("Psychopath"))); traitpool.Add(new Trait(TraitDef.Named("Nimble"))); traitpool.Add(new Trait(TraitDef.Named("FastLearner"))); traitpool.Add(new Trait(TraitDef.Named("Tough"))); traitpool.Add(new Trait(TraitDef.Named("ShootingAccuracy"), 1)); traitpool.Add(new Trait(TraitDef.Named("ShootingAccuracy"), -1)); List <Trait> hadtrait = new List <Trait>(); int trait_count_before = pawn.story.traits.allTraits.Count; foreach (Trait intrait in pawn.story.traits.allTraits) { if (intrait.def != TraitDef_BnC.Innocent) { hadtrait.Add(intrait); } } pawn.story.traits.allTraits.RemoveRange(0, (pawn.story.traits.allTraits.Count)); foreach (Trait intoit in hadtrait) { pawn.story.traits.GainTrait(intoit); } int r; do { r = new Random().Next(0, traitpool.Count); Trait trait = traitpool[r]; if (trait != null && !pawn.story.traits.HasTrait(trait.def) && !pawn.story.traits.allTraits.Any(x => x.def.ConflictsWith(trait))) { pawn.story.traits.GainTrait(trait); } } while (pawn.story.traits.allTraits.Count < trait_count_before); }
// Token: 0x06001F46 RID: 8006 RVA: 0x000F2028 File Offset: 0x000F0428 private void Outcome_Success(Caravan caravan) { caravan.pawns[0].story.traits.GainTrait(new Trait(TraitDef.Named("Warframe_Trait"))); Find.LetterStack.ReceiveLetter("LetterLabelVoidSon_Success".Translate(), GetLetterText( "LetterVoidSon_Success".Translate(caravan.pawns[0].LabelCap)), LetterDefOf.PositiveEvent, caravan, Faction); }
private static float BedValue(Building_GuestBed bed, Pawn guest, int money) { StaticBedValue(bed, out var room, out var quality, out var impressiveness, out var roomType, out var comfort); var fee = RoundToInt(money > 0 ? 250 * (bed.rentalFee / money) : 0); // 0 - 250 // Royalty requires single bed? var royalExpectations = GetRoyalExpectations(bed, guest, room, out var title); // Shared int otherPawnOpinion = OtherPawnOpinion(bed, guest); // -150 - 0 // Temperature var temperature = GetTemperatureScore(guest, room, bed); // -200 - 0 // Traits if (guest.story.traits.HasTrait(TraitDefOf.Greedy)) { fee *= 3; impressiveness -= 50; } if (guest.story.traits.HasTrait(TraitDefOf.Kind)) { fee /= 2; } if (guest.story.traits.HasTrait(TraitDefOf.Ascetic)) { impressiveness *= -1; roomType = 75; // We don't care, so always max comfort = 100; // We don't care, so always max } if (guest.story.traits.HasTrait(TraitDef.Named("Jealous"))) { fee /= 4; impressiveness -= 50; impressiveness *= 4; } // Tired int distance = 0; if (guest.IsTired()) { distance = (int)bed.Position.DistanceTo(guest.Position); //Log.Message($"{guest.LabelShort} is tired. {bed.LabelCap} is {distance} units far away."); } var score = impressiveness + quality + comfort + roomType + temperature + otherPawnOpinion + royalExpectations - distance; var value = CeilToInt(scoreFactor * score - fee); //Log.Message($"For {guest.LabelShort} {bed.Label} at {bed.Position} has a score of {score} and value of {value}:\n" // + $"impressiveness = {impressiveness}, quality = {quality}, fee = {fee}, roomType = {roomType}, opinion = {otherPawnOpinion}, temperature = {temperature}, distance = {distance}"); return(value); }
public void HasturResurrection() { if (toBeResurrected?.FirstOrDefault() == null) { ticksUntilResurrection = -999; return; } var sourceCorpse = toBeResurrected.RandomElement(); toBeResurrected.Remove(sourceCorpse); var unused = IntVec3.Invalid; if (sourceCorpse.Corpse == null) { return; } try { if (sourceCorpse?.Corpse?.holdingOwner is ThingOwner owner) { Thing lastThing = null; owner.TryDrop(sourceCorpse.Corpse, ThingPlaceMode.Near, out lastThing); } } catch { } //Use B18's Resurrect Feature ResurrectionUtility.Resurrect(sourceCorpse); //Remove everything that conflicts with Psychopathic behavior sourceCorpse.story.traits.allTraits.RemoveAll( x => x.def.conflictingTraits is List <TraitDef> conflicts && !conflicts.NullOrEmpty() && conflicts.Contains(TraitDefOf.Psychopath) || x.def.defName == "Cults_OathtakerHastur"); //Remove a random trait and add Psychopath if (sourceCorpse.story.traits.allTraits is List <Trait> { Count : > 1 } allTraits&& allTraits.FirstOrDefault(x => x.def == TraitDefOf.Psychopath) == null) { sourceCorpse.story.traits.allTraits.RemoveLast(); sourceCorpse.story.traits.GainTrait(new Trait(TraitDefOf.Psychopath, 0, true)); } //Adds the "Reanimated" trait sourceCorpse.story.traits.GainTrait(new Trait(TraitDef.Named("Cults_OathtakerHastur2"), 0, true)); //Message to the player #pragma warning disable CS0618 // Type or member is obsolete Messages.Message("ReanimatedOath".Translate(sourceCorpse.Name), MessageTypeDefOf.PositiveEvent); #pragma warning restore CS0618 // Type or member is obsolete }
public void GenerateTraits() { if (Rand.Chance(0.95f)) { pawn.story.traits.GainTrait(new Trait(TraitDef.Named("Abrasive"))); } if (Rand.Chance(0.4f)) { pawn.story.traits.GainTrait(new Trait(TraitDef.Named("FearsFire"))); } GiveTraitWithChance("Brawler"); GiveTraitWithChance("Bloodlust"); GiveTraitWithChance("CreepyBreathing"); GiveTraitWithChance("FastLearner"); GiveTraitWithChance("Ascetic"); GiveTraitWithChance("Gay"); GiveTraitWithChance("GreenThumb"); GiveTraitWithChance("NaturalMood"); GiveTraitWithChance("Nudist"); GiveTraitWithChance("PsychicSensitivity"); GiveTraitWithChance("Psychopath"); GiveTraitWithChance("TooSmart"); GiveTraitWithChance("Nimble"); GiveTraitWithChance("Pyromaniac"); GiveTraitWithChance("SuperImmune"); GiveTraitWithChance("FastLearner"); GiveTraitWithChance("M*******t"); GiveTraitWithChance("NightOwl"); GiveTraitWithChance("Wimp"); GiveTraitWithChanceInRange("SpeedOffset", -1, 2); GiveTraitWithChanceInRange("DrugDesire", -1, 2); GiveTraitWithChanceInRange("NaturalMood", -2, 2); GiveTraitWithChanceInRange("Nerves", -2, 2); GiveTraitWithChanceInRange("Neurotic", -2, 2); GiveTraitWithChanceInRange("Industriousness", -2, 2); GiveTraitWithChanceInRange("PsychicSensitivity", -2, 2); GiveTraitWithChanceInRange("Beauty", 1, 2); //GiveTraitWithChanceInRange("ShootingAccuracy", -1, 1); if (pawn.story.traits.HasTrait(TraitDefOf.Abrasive)) { if (Rand.Chance(0.25f)) { pawn.story.traits.GainTrait(new Trait(TraitDefOf.Kind, 0, false)); } if (pawn.story.traits.allTraits.Count >= 3) { return; } } GiveTraitWithChanceIfNull("DislikesWomen", "DislikesMen"); GiveTraitWithChanceIfNull("DislikesMen", "DislikesWomen"); }
public void GiveTraitWithChance(string traitName) { if (pawn.story.traits.allTraits.Count >= 3) { return; } if (Rand.Chance(chance)) { pawn.story.traits.GainTrait(new Trait(TraitDef.Named(traitName))); } }
public void SetUpPawn() { if (this.pawn.Spawned) { this.pawn.DeSpawn(); } this.pawn.health.Reset(); this.pawn.story.traits.GainTrait(new Trait(TraitDef.Named("RD_Holographic"), 0, false)); GenSpawn.Spawn(this.pawn, this.parent.Position, this.parent.Map); this.MakeValidAllowedZone(); }
public override void CompPostTick(ref float severityAdjustment) { base.CompPostTick(ref severityAdjustment); if (base.Pawn.IsHashIntervalTick(SeverityUpdateInterval)) { float num = this.SeverityChangePerDay(); num *= 0.00333333341f; if (xxx.has_traits(Pawn)) { if (xxx.RoMIsActive) { if (Pawn.story.traits.HasTrait(TraitDef.Named("Succubus"))) { num *= 4.0f; } } if (Pawn.story.traits.HasTrait(TraitDefOf.Tough)) { num *= 2.0f; } if (Pawn.story.traits.HasTrait(TraitDefOf.Tough)) { num *= 2.0f; } if (Pawn.story.traits.HasTrait(TraitDef.Named("Wimp"))) { num *= 0.5f; } if (Pawn.story.traits.HasTrait(TraitDefOf.Nerves)) { int td = Pawn.story.traits.DegreeOfTrait(TraitDefOf.Nerves); switch (td) { case -2: num *= 2.0f; break; case -1: num *= 1.5f; break; case 1: num *= 0.5f; break; case 2: num *= 0.25f; break; } } } severityAdjustment += num; } }
protected override ThoughtState CurrentStateInternal(Pawn p) { Pawn pawn = p; if (pawn.story.traits.HasTrait(TraitDef.Named("Kind")) && pawn.Map.mapPawns.FreeColonistsAndPrisonersSpawned.ToList().Find( x => SlaveUtility.IsPawnColonySlave(x) && x.Faction == pawn.Faction) != null) { return(ThoughtState.ActiveDefault); } return(ThoughtState.Inactive); }
protected override void DoAnyFurtherActions(Pawn activatedBy, Map map, Thing trigger) { this.bestPsychic = PawnTalentUtility.FindBestPsychic(base.GetEffectArea(activatedBy.Position), map); if (this.bestPsychic != null) { if (this.bestPsychic.story.traits.DegreeOfTrait(TraitDef.Named("PsychicSensitivity")) != 2) { Hediff hediff = HediffMaker.MakeHediff(HediffDefOf.PsychicShock, this.bestPsychic, null); this.bestPsychic.health.AddHediff(hediff, null, null); } } else { List <Pawn> list = new List <Pawn>(); foreach (IntVec3 c in base.GetEffectArea(activatedBy.Position)) { foreach (Thing thing in c.GetThingList(map)) { if (thing.def.category == ThingCategory.Pawn && thing.def.race.intelligence == Intelligence.Humanlike) { Pawn pawn = thing as Pawn; int num = pawn.story.traits.DegreeOfTrait(TraitDef.Named("PsychicSensitivity")); if (num >= 0) { list.Add(pawn); } } } } foreach (Pawn pawn2 in list) { float value = Rand.Value; if ((double)value < 0.25) { pawn2.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk, null, true, false, null); } else if ((double)value < 0.85) { Hediff hediff2 = HediffMaker.MakeHediff(HediffDefOf.PsychicShock, pawn2, null); pawn2.health.AddHediff(hediff2, null, null); } } } ActionTrigger actionTrigger = trigger as ActionTrigger; if (actionTrigger != null) { IEnumerable <IntVec3> cells = actionTrigger.Cells; IntVec3 center = cells.RandomElement <IntVec3>(); //TODO: check if it works GenExplosion.DoExplosion(center, map, 2f, DamageDefOf.Flame, null, -1, -1f, null, null, null, null, ThingDefOf.ChunkSlagSteel, 0.4f, 1, true, null, 0f, 1); } }
public static void doElect(Pawn pawn, Hediff hediff, bool forced = false) { hediff.Severity = 0.1f; pawn.health.AddHediff(hediff, null, null); pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("ElectedLeader")); StringBuilder stringBuilder = new StringBuilder(); if (forced) { stringBuilder.AppendLine("LeaderChosen".Translate(new object[] { pawn.Name.ToStringFull, hediff.LabelBase })); } else { stringBuilder.AppendLine("LeaderElected".Translate(new object[] { pawn.Name.ToStringFull, hediff.LabelBase })); } if (Prefs.DevMode) { stringBuilder.AppendLine(""); stringBuilder.AppendLine("--DEBUG-DEV---"); stringBuilder.AppendLine("Botanist Score: " + getBotanistScore(pawn)); stringBuilder.AppendLine("Warrior Score: " + getWarriorScore(pawn)); stringBuilder.AppendLine("Carpenter Score: " + getCarpenterScore(pawn)); stringBuilder.AppendLine("Scientist Score: " + getScientistScore(pawn)); } if (Utility.getGov() != null) { Find.LetterStack.ReceiveLetter("NewLeaderLetterTitle".Translate(new object[] { Utility.getGov().nameMale }), stringBuilder.ToString(), LetterDefOf.Good, pawn, null); } else { Find.LetterStack.ReceiveLetter("New Leader", stringBuilder.ToString(), LetterDefOf.Good, pawn, null); } foreach (Pawn p in getAllColonists()) { if (p != pawn) { int num2 = p.relations.OpinionOf(pawn); if (num2 <= -20) { p.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("RivalLeader"), null); } if (p.story.traits.HasTrait(TraitDef.Named("Jealous")) && TeachingUtility.leaderH(p) == null) { p.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("ElectedLeaderJealous"), null); } } } }
private bool CanFindPsychic(Map map, out Pawn pawn) { pawn = null; foreach (Pawn pawn2 in map.mapPawns.FreeColonists) { if (pawn2.story.traits.HasTrait(TraitDef.Named("PsychicSensitivity"))) { pawn = pawn2; return(true); } } return(false); }
public void GiveTraitWithChanceIfNull(string nullTrait, string traitToGive) { if (pawn.story.traits.allTraits.Count >= 3) { return; } if (!pawn.story.traits.HasTrait(TraitDef.Named(nullTrait))) { if (Rand.Chance(chance)) { pawn.story.traits.GainTrait(new Trait(TraitDef.Named(traitToGive))); } } }
public static bool SatisfiesSapiosexual(Pawn partner) { if (!xxx.has_traits(partner)) { return(false); } return(partner.story.traits.HasTrait(TraitDefOf.TooSmart) || (xxx.CTIsActive && partner.story.traits.HasTrait(TraitDef.Named("RCT_Savant"))) || (xxx.IndividualityIsActive && partner.story.traits.HasTrait(xxx.SYR_CreativeThinker)) || (xxx.CTIsActive && partner.story.traits.HasTrait(TraitDef.Named("RCT_Inventor"))) || partner.story.traits.HasTrait(TraitDefOf.GreatMemory) || partner.story.traits.HasTrait(TraitDefOf.Transhumanist) || partner.skills.GetSkill(SkillDefOf.Intellectual).levelInt >= 15); }
static void ReRollRaceTraits(Pawn pawn, ThingDef_AlienRace newRace) { var traitSet = pawn.story?.traits; if (traitSet == null) { return; } var allAlienTraits = newRace.alienRace.generalSettings?.forcedRaceTraitEntries; if (allAlienTraits == null || allAlienTraits.Count == 0) { return; } //removing traits not supported right now, Rimworld doesn't like it when you remove traits var traitsToAdd = allAlienTraits; foreach (AlienTraitEntry alienTraitEntry in traitsToAdd) { var def = TraitDef.Named(alienTraitEntry.defName); if (traitSet.HasTrait(def)) { continue; //don't add traits that are already added } var add = (Rand.RangeInclusive(0, 100) <= alienTraitEntry.chance); if (add && pawn.gender == Gender.Male && alienTraitEntry.commonalityMale > 0) { add = Rand.RangeInclusive(0, 100) <= alienTraitEntry.commonalityMale; } else if (add && pawn.gender == Gender.Female && alienTraitEntry.commonalityFemale > 0) //only check gender chance if the add roll has passed { //this is consistent with how the alien race framework handles it add = Rand.RangeInclusive(0, 100) <= alienTraitEntry.commonalityMale; } if (add) { var degree = def.degreeDatas[alienTraitEntry.degree]; traitSet.GainTrait(new Trait(def, alienTraitEntry.degree, true)); if (degree.skillGains != null) { UpdateSkillsPostAdd(pawn, degree.skillGains); //need to update the skills manually } } } }