public static void RemoveTrait( this TraitSet traits, TraitDef traitDef )
 {
     var trait = traits.GetTrait( traitDef );
     if( trait == null )
     {
         return;
     }
     traits.allTraits.Remove( trait );
 }
 public static Trait GetTrait( this TraitSet traits, TraitDef traitDef )
 {
     foreach( var trait in traits.allTraits )
     {
         if( trait.def == traitDef )
         {
             return trait;
         }
     }
     return null;
 }
示例#3
0
        private static void GiveRandomTraits(Pawn pawn, bool allowGay)
        {
            if (pawn.story == null)
            {
                return;
            }
            if (pawn.story.childhood.forcedTraits != null)
            {
                List <TraitEntry> forcedTraits = pawn.story.childhood.forcedTraits;
                for (int i = 0; i < forcedTraits.Count; i++)
                {
                    TraitEntry traitEntry = forcedTraits[i];
                    if (traitEntry.def == null)
                    {
                        Log.Error("Null forced trait def on " + pawn.story.childhood);
                    }
                    else if (!pawn.story.traits.HasTrait(traitEntry.def))
                    {
                        pawn.story.traits.GainTrait(new Trait(traitEntry.def, traitEntry.degree));
                    }
                }
            }
            if (pawn.story.adulthood.forcedTraits != null)
            {
                List <TraitEntry> forcedTraits2 = pawn.story.adulthood.forcedTraits;
                for (int j = 0; j < forcedTraits2.Count; j++)
                {
                    TraitEntry traitEntry2 = forcedTraits2[j];
                    if (traitEntry2.def == null)
                    {
                        Log.Error("Null forced trait def on " + pawn.story.adulthood);
                    }
                    else if (!pawn.story.traits.HasTrait(traitEntry2.def))
                    {
                        pawn.story.traits.GainTrait(new Trait(traitEntry2.def, traitEntry2.degree));
                    }
                }
            }
            int num = Rand.RangeInclusive(2, 3);

            if (allowGay && (LovePartnerRelationUtility.HasAnyLovePartnerOfTheSameGender(pawn) || LovePartnerRelationUtility.HasAnyExLovePartnerOfTheSameGender(pawn)))
            {
                Trait trait = new Trait(TraitDefOf.Gay, AlienPawnGenerator.RandomTraitDegree(TraitDefOf.Gay));
                pawn.story.traits.GainTrait(trait);
            }
            while (pawn.story.traits.allTraits.Count < num)
            {
                TraitDef newTraitDef = DefDatabase <TraitDef> .AllDefsListForReading.RandomElementByWeight((TraitDef tr) => tr.GetGenderSpecificCommonality(pawn));

                if (!pawn.story.traits.HasTrait(newTraitDef))
                {
                    if (newTraitDef == TraitDefOf.Gay)
                    {
                        if (!allowGay)
                        {
                            continue;
                        }
                        if (LovePartnerRelationUtility.HasAnyLovePartnerOfTheOppositeGender(pawn) || LovePartnerRelationUtility.HasAnyExLovePartnerOfTheOppositeGender(pawn))
                        {
                            continue;
                        }
                    }
                    if (!pawn.story.traits.allTraits.Any((Trait tr) => newTraitDef.ConflictsWith(tr)) && (newTraitDef.conflictingTraits == null || !newTraitDef.conflictingTraits.Any((TraitDef tr) => pawn.story.traits.HasTrait(tr))))
                    {
                        if (newTraitDef.requiredWorkTypes == null || !pawn.story.OneOfWorkTypesIsDisabled(newTraitDef.requiredWorkTypes))
                        {
                            if (!pawn.story.WorkTagIsDisabled(newTraitDef.requiredWorkTags))
                            {
                                int degree = AlienPawnGenerator.RandomTraitDegree(newTraitDef);
                                if (!pawn.story.childhood.DisallowsTrait(newTraitDef, degree) && !pawn.story.adulthood.DisallowsTrait(newTraitDef, degree))
                                {
                                    Trait trait2 = new Trait(newTraitDef, degree);
                                    if (pawn.mindState == null || pawn.mindState.mentalBreaker == null || pawn.mindState.mentalBreaker.BreakThresholdExtreme + trait2.OffsetOfStat(StatDefOf.MentalBreakThreshold) <= 40f)
                                    {
                                        pawn.story.traits.GainTrait(trait2);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#4
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            //--Log.Message("[RJW] JobDriver_BestialityForMale::MakeNewToils() called");
            //Rand.PopState();
            //Rand.PushState(RJW_Multiplayer.PredictableSeed());
            duration              = (int)(2500.0f * Rand.Range(0.50f, 0.90f));
            ticks_between_hearts  = Rand.RangeInclusive(70, 130);
            ticks_between_hits    = Rand.Range(xxx.config.min_ticks_between_hits, xxx.config.max_ticks_between_hits);
            ticks_between_thrusts = 100;

            if (xxx.is_bloodlust(pawn))
            {
                ticks_between_hits = (int)(ticks_between_hits * 0.75);
            }
            if (xxx.is_brawler(pawn))
            {
                ticks_between_hits = (int)(ticks_between_hits * 0.90);
            }

            //this.FailOn (() => (!animal.health.capacities.CanBeAwake) || (!comfort_prisoners.is_designated (animal)));
            // Fail if someone else reserves the prisoner before the pawn arrives or colonist can't reach animal
            this.FailOn(() => !pawn.CanReserveAndReach(animal, PathEndMode.Touch, Danger.Deadly));
            this.FailOn(() => animal.HostileTo(pawn));
            this.FailOnDespawnedNullOrForbidden(target_animal);
            this.FailOn(() => pawn.Drafted);
            yield return(Toils_Reserve.Reserve(target_animal, 1, 0));

            //Log.Message("[RJW] JobDriver_BestialityForMale::MakeNewToils() - moving towards animal");
            yield return(Toils_Goto.GotoThing(target_animal, PathEndMode.Touch));

            yield return(Toils_Interpersonal.WaitToBeAbleToInteract(pawn));

            yield return(Toils_Interpersonal.GotoInteractablePosition(target_animal));

            if (xxx.is_kind(pawn) ||
                (xxx.CTIsActive && xxx.has_traits(pawn) && pawn.story.traits.HasTrait(TraitDef.Named("RCT_AnimalLover"))))
            {
                yield return(TalkToAnimal(pawn, animal));

                yield return(TalkToAnimal(pawn, animal));
            }
            if (Rand.Chance(0.6f))
            {
                yield return(TalkToAnimal(pawn, animal));
            }
            yield return(Toils_Goto.GotoThing(target_animal, PathEndMode.OnCell));

            SexUtility.RapeAttemptAlert(pawn, animal);

            Toil rape = new Toil();

            rape.initAction = delegate
            {
                //--Log.Message("[RJW] JobDriver_BestialityForMale::MakeNewToils() - reserving animal");

                //--Log.Message("[RJW] JobDriver_BestialityForMale::MakeNewToils() - Setting animal job driver");
                if (!(animal.jobs.curDriver is JobDriver_GettinRaped dri))
                {
                    //wild animals may flee or attack
                    if (pawn.Faction != animal.Faction && animal.RaceProps.wildness > Rand.Range(0.22f, 1.0f) &&
                        !(pawn.TicksPerMoveCardinal < (animal.TicksPerMoveCardinal / 2) && !animal.Downed && xxx.is_not_dying(animal)))
                    {
                        animal.jobs.StopAll();                         // Wake up if sleeping.

                        float aggro = animal.kindDef.RaceProps.manhunterOnTameFailChance;
                        if (animal.kindDef.RaceProps.predator)
                        {
                            aggro += 0.2f;
                        }
                        else
                        {
                            aggro -= 0.1f;
                        }

                        if (Rand.Chance(aggro) && animal.CanSee(pawn))
                        {
                            animal.rotationTracker.FaceTarget(pawn);
                            LifeStageUtility.PlayNearestLifestageSound(animal, (ls) => ls.soundAngry, 1.4f);
                            MoteMaker.ThrowMetaIcon(animal.Position, animal.Map, ThingDefOf.Mote_IncapIcon);
                            MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_ColonistFleeing);                             //red '!'
                            animal.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter);
                            if (animal.kindDef.RaceProps.herdAnimal && Rand.Chance(0.2f))
                            {                             // 20% chance of turning the whole herd hostile...
                                List <Pawn> packmates = animal.Map.mapPawns.AllPawnsSpawned.Where(x =>
                                                                                                  x != animal && x.def == animal.def && x.Faction == animal.Faction &&
                                                                                                  x.Position.InHorDistOf(animal.Position, 24f) && x.CanSee(animal)).ToList();

                                foreach (Pawn packmate in packmates)
                                {
                                    packmate.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter);
                                }
                            }
                            Messages.Message(pawn.Name.ToStringShort + " is being attacked by " + xxx.get_pawnname(animal) + ".", pawn, MessageTypeDefOf.ThreatSmall);
                        }
                        else
                        {
                            MoteMaker.ThrowMetaIcon(animal.Position, animal.Map, ThingDefOf.Mote_ColonistFleeing);
                            LifeStageUtility.PlayNearestLifestageSound(animal, (ls) => ls.soundCall);
                            animal.mindState.StartFleeingBecauseOfPawnAction(pawn);
                            animal.mindState.mentalStateHandler.TryStartMentalState(DefDatabase <MentalStateDef> .GetNamed("PanicFlee"));
                        }
                        pawn.jobs.EndCurrentJob(JobCondition.Incompletable);
                    }
                    else
                    {
                        Job gettin_bred = new Job(xxx.gettin_bred, pawn, animal);
                        animal.jobs.StartJob(gettin_bred, JobCondition.InterruptForced, null, true);
                        (animal.jobs.curDriver as JobDriver_GettinRaped)?.increase_time(duration);
                    }
                }
示例#5
0
        public override void ResolveReferences()
        {
            base.ResolveReferences();


            if (!this.addToDatabase || BackstoryDatabase.allBackstories.ContainsKey(key: this.defName) || this.title.NullOrEmpty() || this.spawnCategories.NullOrEmpty())
            {
                return;
            }

            this.backstory = new Backstory
            {
                slot             = this.slot,
                shuffleable      = this.shuffleable,
                spawnCategories  = this.spawnCategories,
                forcedTraits     = this.forcedTraits.NullOrEmpty() ? null : this.forcedTraits.Where(predicate: trait => Rand.Range(min: 0, max: 100) < trait.chance).ToList().ConvertAll(converter: trait => new TraitEntry(def: TraitDef.Named(defName: trait.defName), degree: trait.degree)),
                disallowedTraits = this.disallowedTraits.NullOrEmpty() ? null : this.disallowedTraits.Where(predicate: trait => Rand.Range(min: 0, max: 100) < trait.chance).ToList().ConvertAll(converter: trait => new TraitEntry(def: TraitDef.Named(defName: trait.defName), degree: trait.degree)),
                workDisables     = this.workAllows.NullOrEmpty() ? this.workDisables.NullOrEmpty() ? WorkTags.None : ((Func <WorkTags>) delegate
                {
                    WorkTags wt = WorkTags.None;
                    this.workDisables.ForEach(action: tag => wt |= tag);
                    return(wt);
                })() : ((Func <WorkTags>) delegate
                {
                    WorkTags wt = WorkTags.None;
                    Enum.GetValues(enumType: typeof(WorkTags)).Cast <WorkTags>().Where(predicate: tag => !this.workAllows.Contains(item: tag)).ToList().ForEach(action: tag => wt |= tag);
                    return(wt);
                })(),
                identifier       = this.defName,
                requiredWorkTags = ((Func <WorkTags>) delegate
                {
                    WorkTags wt = WorkTags.None;
                    this.requiredWorkTags.ForEach(action: tag => wt |= tag);
                    return(wt);
                })()
            };

            Traverse.Create(root: this.backstory).Field(name: "bodyTypeGlobalResolved").SetValue(value: this.bodyTypeGlobal);
            Traverse.Create(root: this.backstory).Field(name: "bodyTypeFemaleResolved").SetValue(value: this.bodyTypeFemale);
            Traverse.Create(root: this.backstory).Field(name: "bodyTypeMaleResolved").SetValue(value: this.bodyTypeMale);
            Traverse.Create(root: this.backstory).Field(name: nameof(this.skillGains)).SetValue(value: this.skillGains.ToDictionary(keySelector: i => i.defName, elementSelector: i => i.amount));

            UpdateTranslateableFields(bs: this);

            this.backstory.ResolveReferences();
            this.backstory.PostLoad();

            this.backstory.identifier = this.defName;

            IEnumerable <string> errors;

            if (!(errors = this.backstory.ConfigErrors(ignoreNoSpawnCategories: false)).Any())
            {
                BackstoryDatabase.AddBackstory(bs: this.backstory);
            }
            else
            {
                Log.Error(text: this.defName + " has errors:\n" + string.Join(separator: "\n", value: errors.ToArray()));
            }
        }
示例#6
0
        public Pawn FromRealmPawn(RealmData realmData)
        {
            // This code is mainly a copy/paste of what happens in
            // PawnGenerator.DoGenerateNakedPawn()
            PawnKindDef kindDef = DefDatabase <PawnKindDef> .GetNamed(kindDefName);

            Pawn pawn = (Pawn)ThingMaker.MakeThing(kindDef.race);

            pawn.kindDef = kindDef;
            pawn.SetFactionDirect(Faction.OfPlayer);
            PawnComponentsUtility.CreateInitialComponents(pawn);
            pawn.gender = gender;

            // What is done in GenerateRandomAge()
            pawn.ageTracker.AgeBiologicalTicks    = ageBiologicalTicks;
            pawn.ageTracker.AgeChronologicalTicks = ageChronologicalTicks;

            // Ignored SetInitialLevels()
            // Ignored GenerateInitialHediffs()
            // Ignored GeneratePawnRelations()

            Pawn_StoryTracker story = pawn.story;

            story.melanin   = melanin;
            story.crownType = crownType;
            story.hairColor = new Color(hairColor[0], hairColor[1], hairColor[2], hairColor[3]);

            // What is done in GiveAppropriateBio()
            Name nameObj = pawn.Name;

            switch (name.Count())
            {
            case 1:
                nameObj = new NameSingle(name[0]);
                break;

            case 2:
                nameObj = new NameTriple(name[0], name[1], name[1]);
                break;

            case 3:
                nameObj = new NameTriple(name[0], name[1], name[2]);
                break;
            }
            pawn.Name = nameObj;

            if (!BackstoryDatabase.TryGetWithIdentifier(childhoodKey, out story.childhood))
            {
                throw new Exception(string.Format("Couldn't find backstory '{0}'", childhoodKey));
            }
            if (!BackstoryDatabase.TryGetWithIdentifier(adulthoodKey, out story.adulthood))
            {
                throw new Exception(string.Format("Couldn't find backstory '{0}'", adulthoodKey));
            }

            story.hairDef = DefDatabase <HairDef> .GetNamed(hairDefName);

            // Done in GiveRandomTraits()
            foreach (RealmTrait trait in traits)
            {
                TraitDef traitDef = DefDatabase <TraitDef> .GetNamed(trait.traitDefName);

                story.traits.GainTrait(new Trait(traitDef, trait.degree));
            }

            // We attribute the skills level
            foreach (RealmSkillRecord rec in skills.AsEnumerable())
            {
                SkillDef skillDef = DefDatabase <SkillDef> .AllDefs.First((def) => def.label == rec.skillDefLabel);

                SkillRecord skill = pawn.skills.GetSkill(skillDef);
                skill.Level   = rec.level;
                skill.passion = rec.passion;
            }

            pawn.workSettings.EnableAndInitialize();

            // Once we've generated a new solid pawn, we generate the gear of it
            // GenerateStartingApparelFor()
            Pawn_ApparelTracker apparelTracker = pawn.apparel;

            foreach (RealmThing realmThing in apparels)
            {
                Apparel apparel = (Apparel)realmData.FromRealmThing(realmThing);

                apparelTracker.Wear(apparel);
            }

            // TryGenerateWeaponFor()
            Pawn_EquipmentTracker equipmentTracker = pawn.equipment;

            foreach (RealmThing realmThing in equipments)
            {
                ThingWithComps thingWithComps = (ThingWithComps)realmData.FromRealmThing(realmThing);

                equipmentTracker.AddEquipment(thingWithComps);
            }

            // GenerateInventoryFor()
            Pawn_InventoryTracker inventoryTracker = pawn.inventory;

            foreach (RealmThing realmThing in inventory)
            {
                Thing thing = realmData.FromRealmThing(realmThing);

                inventoryTracker.innerContainer.TryAdd(thing);
            }

            return(pawn);
        }
示例#7
0
 public static bool hasTrait(Pawn pawn)
 {
     return(pawn.story.traits.HasTrait(TraitDef.Named("ProjectileInversion_Trait")));
 }
        internal void GrowUpTo(int stage, bool generated)
        {
            grown_to = stage;

            // Update the Colonist Bar
            PortraitsCache.SetDirty(pawn);
            pawn.Drawer.renderer.graphics.ResolveAllGraphics();

            // At the toddler stage. Now we can move and talk.
            if (stage == 1)
            {
                Severity = Math.Max(0.5f, Severity);
                //pawn.needs.food.
            }
            // Re-enable skills that were locked out from toddlers
            if (stage == 2)
            {
                if (!generated)
                {
                    pawn.story.childhood = BackstoryDatabase.allBackstories ["CustomBackstory_Rimchild"];
                    // Remove the hidden hediff stopping pawns from manipulating
                }
                if (pawn.health.hediffSet.HasHediff(HediffDef.Named("NoManipulationFlag")))
                {
                    pawn.health.hediffSet.hediffs.Remove(pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("NoManipulationFlag")));
                }
                Severity = Math.Max(0.75f, Severity);
            }
            // The child has grown to a teenager so we no longer need this effect
            if (stage == 3)
            {
                if (!generated && pawn.story.childhood.Title == "Child")
                {
                    pawn.story.childhood = BackstoryDatabase.allBackstories ["CustomBackstory_Rimchild"];
                }

                // Gain traits from life experiences
                if (pawn.story.traits.allTraits.Count < 3)
                {
                    List <Trait> life_traitpool = new List <Trait>();
                    // Try get cannibalism
                    if (pawn.needs.mood.thoughts.memories.Memories.Find(x => x.def == ThoughtDefOf.AteHumanlikeMeatAsIngredient) != null)
                    {
                        life_traitpool.Add(new Trait(TraitDefOf.Cannibal, 0, false));
                    }
                    // Try to get bloodlust
                    if (pawn.records.GetValue(RecordDefOf.KillsHumanlikes) > 0 || pawn.records.GetValue(RecordDefOf.AnimalsSlaughtered) >= 2)
                    {
                        life_traitpool.Add(new Trait(TraitDefOf.Bloodlust, 0, false));
                    }
                    // Try to get shooting accuracy
                    if (pawn.records.GetValue(RecordDefOf.ShotsFired) > 100)
                    {
                        life_traitpool.Add(new Trait(TraitDef.Named("ShootingAccuracy"), 1, false));
                    }
                    else if (pawn.records.GetValue(RecordDefOf.ShotsFired) > 100 && (int)pawn.records.GetValue(RecordDefOf.PawnsDowned) == 0)
                    {
                        life_traitpool.Add(new Trait(TraitDef.Named("ShootingAccuracy"), -1, false));
                    }
                    // Try to get brawler
                    else if (pawn.records.GetValue(RecordDefOf.ShotsFired) < 15 && pawn.records.GetValue(RecordDefOf.PawnsDowned) > 1)
                    {
                        life_traitpool.Add(new Trait(TraitDefOf.Brawler, 0, false));
                    }
                    // Try to get Green Thumb
                    if (pawn.records.GetValue(RecordDefOf.PlantsSown) > 100)
                    {
                        life_traitpool.Add(new Trait(TraitDefOf.GreenThumb, 0, false));
                    }
                    // Try to get Dislikes Men/Women
                    int male_rivals   = 0;
                    int female_rivals = 0;
                    foreach (Pawn colinist in Find.AnyPlayerHomeMap.mapPawns.AllPawnsSpawned)
                    {
                        if (pawn.relations.OpinionOf(colinist) <= -20)
                        {
                            if (colinist.gender == Gender.Male)
                            {
                                male_rivals++;
                            }
                            else
                            {
                                female_rivals++;
                            }
                        }
                    }
                    // Find which gender we hate
                    if (male_rivals > 3 || female_rivals > 3)
                    {
                        if (male_rivals > female_rivals)
                        {
                            life_traitpool.Add(new Trait(TraitDefOf.DislikesMen, 0, false));
                        }
                        else if (female_rivals > male_rivals)
                        {
                            life_traitpool.Add(new Trait(TraitDefOf.DislikesWomen, 0, false));
                        }
                    }
                    // Pyromaniac never put out any fires. Seems kinda stupid

                    /*if ((int)pawn.records.GetValue (RecordDefOf.FiresExtinguished) == 0) {
                     *      life_traitpool.Add (new Trait (TraitDefOf.Pyromaniac, 0, false));
                     * }*/
                    // Neurotic
                    if (pawn.records.GetValue(RecordDefOf.TimesInMentalState) > 6)
                    {
                        life_traitpool.Add(new Trait(TraitDef.Named("Neurotic"), 2, false));
                    }
                    else if (pawn.records.GetValue(RecordDefOf.TimesInMentalState) > 3)
                    {
                        life_traitpool.Add(new Trait(TraitDef.Named("Neurotic"), 1, false));
                    }

                    // Girls can turn gay during puberty
                    if (pawn.gender == Gender.Female && Rand.Value <= 0.08f && pawn.story.traits.allTraits.Count <= 3)
                    {
                        pawn.story.traits.GainTrait(new Trait(TraitDefOf.Gay, 0, true));
                    }

                    // Now let's try to add some life experience traits
                    if (life_traitpool.Count > 0)
                    {
                        int i = 3;
                        while (pawn.story.traits.allTraits.Count < 3 && i > 0)
                        {
                            Trait newtrait = life_traitpool.RandomElement();
                            if (pawn.story.traits.HasTrait(newtrait.def) == false)
                            {
                                pawn.story.traits.GainTrait(newtrait);
                            }
                            i--;
                        }
                    }
                }

                pawn.health.RemoveHediff(this);
            }
        }
示例#9
0
        public static bool isPsyker(this Pawn pawn, out int Level, out float Mult)
        {
            bool result = false;

            Mult  = 0f;
            Level = 0;

            if (pawn.RaceProps.Humanlike)
            {
                if (pawn.HasPsylink)
                {
                    Level  = pawn.psychicEntropy.Psylink.level;
                    result = true;
                }
                else
                if (pawn.health.hediffSet.hediffs.Any(x => x.GetType() == typeof(Hediff_Level)))
                {
                    Level  = (pawn.health.hediffSet.hediffs.First(x => x.GetType() == typeof(Hediff_Level)) as Hediff_Level).level;
                    result = true;
                }
                else
                if (pawn.story.traits.HasTrait(TraitDefOf.PsychicSensitivity))
                {
                    result = pawn.story.traits.DegreeOfTrait(TraitDefOf.PsychicSensitivity) > 0;
                    Level  = pawn.story.traits.DegreeOfTrait(TraitDefOf.PsychicSensitivity);
                }
                else
                {
                    TraitDef Corruptionpsyker = DefDatabase <TraitDef> .GetNamedSilentFail("Psyker");

                    if (Corruptionpsyker != null)
                    {
                        result = true;
                        pawn.story.traits.HasTrait(Corruptionpsyker);
                        Level = pawn.story.traits.DegreeOfTrait(Corruptionpsyker);
                    }
                }
                Mult = pawn.GetStatValue(StatDefOf.PsychicSensitivity) * (pawn.needs.mood.CurInstantLevelPercentage - pawn.health.hediffSet.PainTotal);
            }
            else
            {
                ToolUserPskyerDefExtension extension = null;
                if (pawn.def.HasModExtension <ToolUserPskyerDefExtension>())
                {
                    extension = pawn.def.GetModExtensionFast <ToolUserPskyerDefExtension>();
                }
                else
                if (pawn.kindDef.HasModExtension <ToolUserPskyerDefExtension>())
                {
                    extension = pawn.kindDef.GetModExtensionFast <ToolUserPskyerDefExtension>();
                }
                if (extension != null)
                {
                    result = true;
                    Level  = extension.Level;
                }
                if (pawn.needs != null && pawn.needs.mood != null)
                {
                    Mult = pawn.GetStatValue(StatDefOf.PsychicSensitivity) * (pawn.needs.mood.CurInstantLevelPercentage - pawn.health.hediffSet.PainTotal);
                }
                else
                {
                    Mult = pawn.GetStatValue(StatDefOf.PsychicSensitivity) * (1 - pawn.health.hediffSet.PainTotal);
                }
            }

            return(result);
        }
示例#10
0
 protected override ThoughtState CurrentSocialStateInternal(Pawn pawn, Pawn other)
 {
     if (pawn != null && other != null)
     {
         if (!other.RaceProps.Humanlike || other.Dead)
         {
             return(false);
         }
         if (!RelationsUtility.PawnsKnowEachOther(pawn, other))
         {
             return(false);
         }
         if (!other.story.traits.HasTrait(TorannMagicDefOf.Undead))
         {
             return(false);
         }
         if (pawn.story.traits.HasTrait(TorannMagicDefOf.Necromancer) || pawn.story.traits.HasTrait(TorannMagicDefOf.Lich) || pawn.story.traits.HasTrait(TraitDefOf.Psychopath) || pawn.story.traits.HasTrait(TraitDefOf.Bloodlust) || pawn.story.traits.HasTrait(TraitDef.Named("M*******t")))
         {
             return(false);
         }
     }
     return(true);
 }
示例#11
0
        public static ReanimatedPawn DoGenerateZombiePawnFromSource(Pawn sourcePawn, bool isBerserk = true,
                                                                    bool oathOfHastur = false)
        {
            var pawnKindDef   = PawnKindDef.Named("ReanimatedCorpse");
            var factionDirect = isBerserk
                ? Find.FactionManager.FirstFactionOfDef(FactionDefOf.AncientsHostile)
                : Faction.OfPlayer;
            var pawn = (ReanimatedPawn)ThingMaker.MakeThing(pawnKindDef.race);

            try
            {
                pawn.kindDef = pawnKindDef;
                pawn.SetFactionDirect(factionDirect);
                PawnComponentsUtility.CreateInitialComponents(pawn);
                pawn.gender = sourcePawn.gender;
                pawn.ageTracker.AgeBiologicalTicks    = sourcePawn.ageTracker.AgeBiologicalTicks;
                pawn.ageTracker.AgeChronologicalTicks = sourcePawn.ageTracker.AgeChronologicalTicks;
                pawn.workSettings = new Pawn_WorkSettings(pawn);
                if (pawn.workSettings != null && sourcePawn.Faction.IsPlayer)
                {
                    pawn.workSettings.EnableAndInitialize();
                }

                pawn.needs.SetInitialLevels();
                //Add hediffs?
                //Add relationships?
                if (pawn.RaceProps.Humanlike)
                {
                    pawn.story.melanin   = sourcePawn.story.melanin;
                    pawn.story.crownType = sourcePawn.story.crownType;
                    pawn.story.hairColor = sourcePawn.story.hairColor;
                    pawn.story.childhood = sourcePawn.story.childhood;
                    pawn.story.adulthood = sourcePawn.story.adulthood;
                    pawn.story.bodyType  = sourcePawn.story.bodyType;
                    pawn.story.hairDef   = sourcePawn.story.hairDef;
                    if (!oathOfHastur)
                    {
                        foreach (var current in sourcePawn.story.traits.allTraits)
                        {
                            pawn.story.traits.GainTrait(current);
                        }
                    }
                    else
                    {
                        pawn.story.traits.GainTrait(new Trait(TraitDef.Named("Cults_OathtakerHastur2"), 0, true));
                        pawn.story.traits.GainTrait(new Trait(TraitDefOf.Psychopath, 0, true));

                        SkillFixer(pawn, sourcePawn);
                        RelationshipFixer(pawn, sourcePawn);
                        AddedPartFixer(pawn, sourcePawn);
                    }

                    //pawn.story.GenerateSkillsFromBackstory();
                    var nameTriple = sourcePawn.Name as NameTriple;
                    if (!oathOfHastur)
                    {
                        pawn.Name = new NameTriple(nameTriple?.First,
                                                   string.Concat("* ", "Reanimated".Translate(), " ", nameTriple?.Nick, " *"),
                                                   nameTriple?.Last);
                    }
                    else
                    {
                        pawn.Name = nameTriple;
                    }
                }

                var headGraphicPath = sourcePawn.story.HeadGraphicPath;
                typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic)
                ?.SetValue(pawn.story, headGraphicPath);
                GenerateZombieApparelFromSource(pawn, sourcePawn);
                var con = new PawnGenerationRequest();
                PawnInventoryGenerator.GenerateInventoryFor(pawn, con);
                GiveZombieSkinEffect(pawn, sourcePawn as ReanimatedPawn, oathOfHastur);
                if (isBerserk)
                {
                    pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk);
                }

                //Log.Message(pawn.Name.ToStringShort);
                return(pawn);
            }
            catch (Exception e)
            {
                Utility.DebugReport(e.ToString());
            }

            return(null);
        }
示例#12
0
        private Pawn MakePawnWithRawXml(string xml)
        {
            try {
                XmlDocument document = new XmlDocument();
                document.LoadXml(xml);
                //Debug.Message("Pawn xml: {0}", xml);
                XmlNode root = document.FirstChild;

                string      pawnKind = root.SelectSingleNode("kind").InnerText;
                PawnKindDef kindDef  = PawnKindDef.Named(pawnKind);
                if (kindDef == null)
                {
                    kindDef = PawnKindDefOf.AncientSoldier;
                }

                Pawn p = PawnGenerator.GeneratePawn(kindDef, rp.faction);

                // ==== NAME AND AGE ====
                Name name      = null;
                var  nameNode  = root.SelectSingleNode("name");
                var  attrFirst = nameNode.Attributes.GetNamedItem("first");
                var  attrLast  = nameNode.Attributes.GetNamedItem("last");
                var  attrNick  = nameNode.Attributes.GetNamedItem("nick");
                if (attrFirst != null && attrLast != null)
                {
                    name = new NameTriple(attrFirst.Value, attrNick?.Value ?? "", attrLast.Value);
                }
                else
                {
                    name = new NameSingle(attrFirst?.Value ?? "Unknown");
                }
                p.Name = name;
                //Debug.Message("got name");

                string gender = root.SelectSingleNode("gender")?.InnerText;
                if (gender == "Male")
                {
                    p.gender = Gender.Male;
                }
                else if (gender == "Female")
                {
                    p.gender = Gender.Female;
                }

                string bioAgeString    = root.SelectSingleNode("biologicalAge")?.InnerText;
                string chronoAgeString = root.SelectSingleNode("chronologicalAge")?.InnerText;
                if (bioAgeString != null && chronoAgeString != null)
                {
                    long result = 0;
                    Int64.TryParse(bioAgeString, out result);
                    p.ageTracker.AgeBiologicalTicks = result;
                    Int64.TryParse(chronoAgeString, out result);
                    p.ageTracker.AgeChronologicalTicks = result + 3600000 * (-blueprint.dateShift); //+dateShift for dates, -dateShift for ages
                }
                //Debug.Message("got age");


                // ==== STORY AND APPEARANCE ====
                var storyNode = root.SelectSingleNode("saveable[@Class='Pawn_StoryTracker']");
                if (storyNode != null)
                {
                    Backstory bs           = null;
                    string    childhoodDef = storyNode.SelectSingleNode("childhood")?.InnerText;
                    if (BackstoryDatabase.TryGetWithIdentifier(childhoodDef, out bs))
                    {
                        p.story.childhood = bs;
                    }
                    string adulthoodDef = storyNode.SelectSingleNode("adulthood")?.InnerText;
                    if (BackstoryDatabase.TryGetWithIdentifier(adulthoodDef, out bs))
                    {
                        p.story.adulthood = bs;
                    }

                    string bodyTypeDefName = storyNode.SelectSingleNode("bodyType")?.InnerText;
                    if (bodyTypeDefName != null)
                    {
                        BodyTypeDef def = DefDatabase <BodyTypeDef> .GetNamedSilentFail(bodyTypeDefName);

                        if (def != null)
                        {
                            p.story.bodyType = def;
                        }

                        try {
                            string crownTypeName = storyNode.SelectSingleNode("crownType")?.InnerText;
                            p.story.crownType = (CrownType)Enum.Parse(typeof(CrownType), crownTypeName);
                        } catch (Exception) { }

                        string  hairDefName = storyNode.SelectSingleNode("hairDef")?.InnerText;
                        HairDef hairDef     = DefDatabase <HairDef> .GetNamedSilentFail(hairDefName);

                        if (hairDef != null)
                        {
                            p.story.hairDef = hairDef;
                        }

                        float melanin = 0;
                        if (float.TryParse(storyNode.SelectSingleNode("melanin")?.InnerText, out melanin))
                        {
                            p.story.melanin = melanin;
                        }

                        string hairColorString = storyNode.SelectSingleNode("hairColor")?.InnerText;
                        Color  hairColor       = (Color)ParseHelper.FromString(hairColorString, typeof(Color));
                        if (hairColor != null)
                        {
                            p.story.hairColor = hairColor;
                        }
                    }
                    XmlNodeList traitsList = storyNode.SelectNodes("traits/allTraits/li");
                    if (traitsList != null)
                    {
                        p.story.traits.allTraits.RemoveAll(_ => true);
                        foreach (XmlNode traitNode in traitsList)
                        {
                            string traitDefName = traitNode.SelectSingleNode("def")?.InnerText;
                            int    traitDegree  = 0;
                            int.TryParse(traitNode.SelectSingleNode("degree")?.InnerText, out traitDegree);

                            TraitDef traitDef = DefDatabase <TraitDef> .GetNamedSilentFail(traitDefName);

                            if (traitDef == null)
                            {
                                continue;
                            }

                            Trait t = new Trait(traitDef, traitDegree);
                            if (t == null)
                            {
                                continue;
                            }

                            p.story.traits.allTraits.Add(t);
                        }
                    }
                }

                // ==== SKILLS ====
                var skills = root.SelectSingleNode("saveable[@Class='Pawn_SkillTracker']");
                if (skills != null)
                {
                    XmlNodeList skillsList = storyNode.SelectNodes("skills/li");

                    foreach (XmlNode skillNode in skillsList)
                    {
                        string skillDefName = skillNode.SelectSingleNode("def")?.InnerText;
                        int    level        = 0;
                        int.TryParse(skillNode.SelectSingleNode("level")?.InnerText, out level);

                        float xp = 0;
                        float.TryParse(skillNode.SelectSingleNode("xpSinceLastLevel")?.InnerText, out xp);

                        SkillDef skillDef = DefDatabase <SkillDef> .GetNamedSilentFail(skillDefName);

                        if (skillDef == null)
                        {
                            continue;
                        }

                        SkillRecord skillRecord = p.skills.GetSkill(skillDef);
                        if (skillRecord == null)
                        {
                            skillRecord = new SkillRecord(p, skillDef);
                        }

                        skillRecord.Level            = level;
                        skillRecord.xpSinceLastLevel = xp;

                        try {
                            string passionTypeName = skillNode.SelectSingleNode("passion")?.InnerText;
                            if (passionTypeName != null)
                            {
                                skillRecord.passion = (Passion)Enum.Parse(typeof(Passion), passionTypeName);
                            }
                        } catch (Exception) { }
                    }
                }
                //Debug.Message("got traits and skills");

                // ==== HEALTH ====
                var healthNode = root.SelectSingleNode("saveable[@Class='Pawn_HealthTracker']");
                if (healthNode != null)
                {
                    XmlNode healthState = healthNode.SelectSingleNode("healthState");
                    if (healthState?.InnerText == "Dead")
                    {
                        p.health.SetDead();
                    }

                    XmlNodeList hediffsList = healthNode.SelectNodes("hediffSet/hediffs/li");
                    if (hediffsList != null)
                    {
                        Scribe.mode = LoadSaveMode.LoadingVars;
                        p.health?.hediffSet?.hediffs?.RemoveAll(_ => true);
                        //probably should pre-analyze hediffs prior to instantiating
                        foreach (XmlNode hediffNode in hediffsList)
                        {
                            var sourceNode = hediffNode.SelectSingleNode("source");
                            var source     = sourceNode?.InnerText;
                            //Debug.Message("Source is {0} in hediff {1}", source, hediffNode.OuterXml);
                            if (source != null)
                            {
                                ThingDef sourceThingDef = DefDatabase <ThingDef> .GetNamedSilentFail(source);

                                //Debug.Message("Found non-null source node: {0}. Def: {1}", sourceNode.OuterXml, sourceThingDef);
                                if (sourceThingDef == null)
                                {
                                    hediffNode.RemoveChild(sourceNode);
                                    //Debug.Message("def not found, removing node, result: {0}", hediffNode.OuterXml);
                                    //continue; //skip hediffs with unknown source
                                    //} else {
                                    //Debug.Message("def found: {0}", sourceThingDef);
                                }
                            }
                            try {
                                Hediff hediff = ScribeExtractor.SaveableFromNode <Hediff>(hediffNode, null);
                                if (hediff != null)
                                {
                                    if (hediff.source != null && hediff.Part != null)
                                    {
                                        p.health.AddHediff(hediff);
                                    }
                                }
                            } catch (Exception) {
                            }
                        }
                        Scribe.mode = LoadSaveMode.Inactive;
                    }
                }
                //Debug.Message("got health");

                // ==== APPAREL ====
                var apparelNode = root.SelectSingleNode("apparel");
                if (apparelNode != null)
                {
                    XmlNodeList apparelList = apparelNode.SelectNodes("item");
                    foreach (XmlNode item in apparelList)
                    {
                        string defName      = item.Attributes?.GetNamedItem("def")?.Value;
                        string stuffDefName = item.Attributes?.GetNamedItem("stuffDef")?.Value;

                        ThingDef stuffDef = null;
                        ThingDef thingDef = DefDatabase <ThingDef> .GetNamedSilentFail(defName);

                        if (stuffDefName != null)
                        {
                            stuffDef = DefDatabase <ThingDef> .GetNamedSilentFail(stuffDefName);
                        }

                        if (thingDef != null)
                        {
                            Apparel apparel = (Apparel)ThingMaker.MakeThing(thingDef, stuffDef);
                            apparel.HitPoints = Rand.Range(1, (int)(apparel.MaxHitPoints * 0.6));
                            if (apparel is Apparel)
                            {
                                p.apparel.Wear(apparel, false);
                            }
                        }
                    }
                }
                return(p);
            } catch (Exception e) {
                return(PawnGenerator.GeneratePawn(PawnKindDefOf.AncientSoldier, rp.faction));
            }
        }
示例#13
0
        public override void DefsLoaded()
        {
            if (ModIsActive)
            {
                /* Mod settings */

                toggleEmpathy        = Settings.GetHandle <bool>("EnableEmpathy", "EmpathyChangesTitle".Translate(), "EmpathyChangesTooltip".Translate(), true);
                toggleKinsey         = Settings.GetHandle <bool>("EnableSexuality", "SexualityChangesTitle".Translate(), "SexualityChangesTooltip".Translate(), true);
                kinseyMode           = Settings.GetHandle <KinseyMode>("KinseyMode", "KinseyModeTitle".Translate(), "KinseyModeTooltip".Translate(), KinseyMode.Realistic, null, "KinseyMode_");
                toggleIndividuality  = Settings.GetHandle <bool>("EnableIndividuality", "IndividualityTitle".Translate(), "IndividualityTooltip".Translate(), true);
                toggleElections      = Settings.GetHandle <bool>("EnableElections", "ElectionsTitle".Translate(), "ElectionsTooltip".Translate(), true);
                conversationDuration = Settings.GetHandle <float>("ConversationDuration", "DurationTitle".Translate(), "DurationTooltip".Translate(), 60f, (String s) => float.Parse(s) >= 15f && float.Parse(s) <= 180f);
                toggleDateLetters    = Settings.GetHandle <bool>("SendDateLetters", "SendDateLettersTitle".Translate(), "SendDateLettersTooltip".Translate(), true);
                toggleBenchmarking   = Settings.GetHandle <bool>("Benchmarking", "BenchmarkingTitle".Translate(), "BenchmarkingTooltip".Translate(), false);

                kinsey        = toggleKinsey.Value;
                notBabyMode   = toggleIndividuality.Value;
                elections     = toggleElections.Value;
                dateLetters   = toggleDateLetters.Value;
                benchmark     = toggleBenchmarking.Value;
                convoDuration = conversationDuration.Value;

                if (PsychologyBase.ActivateKinsey())
                {
                    mode = kinseyMode.Value;
                }

                /* Mod conflict detection */

                TraitDef bisexual = DefDatabase <TraitDef> .GetNamedSilentFail("Bisexual");

                TraitDef asexual = DefDatabase <TraitDef> .GetNamedSilentFail("Asexual");

                if (bisexual != null || asexual != null || !toggleKinsey)
                {
                    if (toggleKinsey)
                    {
                        Logger.Message("KinseyDisable".Translate());
                    }
                    kinsey = false;
                }

                /* Conditional vanilla Def edits */

                ThoughtDef knowGuestExecuted = AddNullifyingTraits("KnowGuestExecuted", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowGuestExecuted != null && toggleEmpathy)
                {
                    knowGuestExecuted = ModifyThoughtStages(knowGuestExecuted, new int[] { -1, -2, -4, -5 });
                }
                ThoughtDef knowColonistExecuted = AddNullifyingTraits("KnowColonistExecuted", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistExecuted != null && toggleEmpathy)
                {
                    knowColonistExecuted = ModifyThoughtStages(knowColonistExecuted, new int[] { -1, -2, -4, -5 });
                }
                ThoughtDef knowPrisonerDiedInnocent = AddNullifyingTraits("KnowPrisonerDiedInnocent", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowPrisonerDiedInnocent != null && toggleEmpathy)
                {
                    knowPrisonerDiedInnocent = ModifyThoughtStages(knowPrisonerDiedInnocent, new int[] { -4 });
                }
                ThoughtDef knowColonistDied = AddNullifyingTraits("KnowColonistDied", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistDied != null && toggleEmpathy)
                {
                    knowColonistDied = ModifyThoughtStages(knowColonistDied, new int[] { -2 });
                }
                ThoughtDef colonistAbandoned = AddNullifyingTraits("ColonistBanished", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (colonistAbandoned != null && toggleEmpathy)
                {
                    colonistAbandoned = ModifyThoughtStages(colonistAbandoned, new int[] { -2 });
                }
                ThoughtDef colonistAbandonedToDie = AddNullifyingTraits("ColonistBanishedToDie", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (colonistAbandonedToDie != null && toggleEmpathy)
                {
                    colonistAbandonedToDie = ModifyThoughtStages(colonistAbandonedToDie, new int[] { -4 });
                }
                ThoughtDef prisonerAbandonedToDie = AddNullifyingTraits("PrisonerBanishedToDie", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (prisonerAbandonedToDie != null && toggleEmpathy)
                {
                    prisonerAbandonedToDie = ModifyThoughtStages(prisonerAbandonedToDie, new int[] { -3 });
                }
                ThoughtDef knowPrisonerSold = AddNullifyingTraits("KnowPrisonerSold", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowPrisonerSold != null && toggleEmpathy)
                {
                    knowPrisonerSold = ModifyThoughtStages(knowPrisonerSold, new int[] { -4 });
                }
                ThoughtDef knowGuestOrganHarvested = AddNullifyingTraits("KnowGuestOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowGuestOrganHarvested != null && toggleEmpathy)
                {
                    knowGuestOrganHarvested = ModifyThoughtStages(knowGuestOrganHarvested, new int[] { -4 });
                }
                ThoughtDef knowColonistOrganHarvested = AddNullifyingTraits("KnowColonistOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistOrganHarvested != null && toggleEmpathy)
                {
                    knowColonistOrganHarvested = ModifyThoughtStages(knowColonistOrganHarvested, new int[] { -4 });
                }
                ThoughtDef beauty = AddNullifyingTraits("KnowColonistOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistOrganHarvested != null && toggleEmpathy)
                {
                    knowColonistOrganHarvested = ModifyThoughtStages(knowColonistOrganHarvested, new int[] { -4 });
                }

                /* ThingDef injection reworked by notfood */
                var zombieThinkTree = DefDatabase <ThinkTreeDef> .GetNamedSilentFail("Zombie");

                IEnumerable <ThingDef> things = (
                    from def in DefDatabase <ThingDef> .AllDefs
                    where typeof(Pawn).IsAssignableFrom(def.thingClass) &&
                    def.race?.intelligence == Intelligence.Humanlike &&
                    !def.defName.Contains("AIPawn") &&
                    (zombieThinkTree == null || def.race.thinkTreeMain != zombieThinkTree)
                    select def
                    );

                List <string> registered = new List <string>();
                foreach (ThingDef t in things)
                {
                    if (t.inspectorTabsResolved == null)
                    {
                        t.inspectorTabsResolved = new List <InspectTabBase>(1);
                    }
                    t.inspectorTabsResolved.Add(InspectTabManager.GetSharedInstance(typeof(ITab_Pawn_Psyche)));

                    if (t.recipes == null)
                    {
                        t.recipes = new List <RecipeDef>(6);
                    }
                    t.recipes.Add(RecipeDefOfPsychology.TreatPyromania);
                    t.recipes.Add(RecipeDefOfPsychology.TreatChemicalInterest);
                    t.recipes.Add(RecipeDefOfPsychology.TreatChemicalFascination);
                    t.recipes.Add(RecipeDefOfPsychology.TreatDepression);
                    t.recipes.Add(RecipeDefOfPsychology.TreatInsomnia);
                    t.recipes.Add(RecipeDefOfPsychology.CureAnxiety);

                    if (t.comps == null)
                    {
                        t.comps = new List <CompProperties>(1);
                    }
                    t.comps.Add(new CompProperties_Psychology());

                    if (!t.race.hediffGiverSets.NullOrEmpty())
                    {
                        if (t.race.hediffGiverSets.Contains(DefDatabase <HediffGiverSetDef> .GetNamed("OrganicStandard")))
                        {
                            t.race.hediffGiverSets.Add(DefDatabase <HediffGiverSetDef> .GetNamed("OrganicPsychology"));
                        }
                    }
                    registered.Add(t.defName);
                }
                if (Prefs.DevMode && Prefs.LogVerbose)
                {
                    Log.Message("Psychology :: Registered " + string.Join(", ", registered.ToArray()));
                }

                /*
                 * Now to enjoy the benefits of having made a popular mod!
                 * This will be our little secret.
                 */
                Traverse.Create(child).Field("bodyTypeMale").SetValue("Male");
                Traverse.Create(child).Field("bodyTypeFemale").SetValue("Female");
                child.slot = BackstorySlot.Childhood;
                child.SetTitle("Child soldier", "Child soldier");
                child.SetTitleShort("Scout", "Scout");
                child.baseDesc = "[PAWN_nameDef] was born into a dictatorial outlander society on a nearby rimworld. Their chief export was war, and [PAWN_pronoun] was conscripted at a young age into the military to serve as a scout due to [PAWN_possessive] runner's build. [PAWN_pronoun] learned how to use a gun, patch wounds on the battlefield, and communicate with [PAWN_possessive] squad. It was there [PAWN_pronoun] earned [PAWN_possessive] nickname.";
                Traverse.Create(child).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Shooting", 4);
                Traverse.Create(child).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Medicine", 2);
                Traverse.Create(child).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Social", 1);
                child.requiredWorkTags = WorkTags.Violent;
                child.shuffleable      = false;
                child.PostLoad();
                child.ResolveReferences();
                Backstory adultMale = new Backstory();
                Traverse.Create(adultMale).Field("bodyTypeMale").SetValue("Male");
                Traverse.Create(adultMale).Field("bodyTypeFemale").SetValue("Female");
                adultMale.slot = BackstorySlot.Adulthood;
                adultMale.SetTitle("Missing in action", "Missing in action");
                adultMale.SetTitleShort("Ex-P.O.W.", "Ex-P.O.W.");
                adultMale.baseDesc = "Eventually, [PAWN_pronoun] was captured on a mission by one of [PAWN_possessive] faction's many enemies. [PAWN_pronoun] was tortured for information, the techniques of which [PAWN_pronoun] never forgot. When they could get no more out of [PAWN_objective], [PAWN_pronoun] was sent to a prison camp, where [PAWN_pronoun] worked for years before staging an escape and fleeing into civilization.";
                Traverse.Create(adultMale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Crafting", 4);
                Traverse.Create(adultMale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Construction", 3);
                Traverse.Create(adultMale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Mining", 2);
                Traverse.Create(adultMale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Social", 1);
                adultMale.spawnCategories = new List <string>();
                adultMale.spawnCategories.AddRange(new string[] { "Civil", "Raider", "Slave", "Trader", "Traveler" });
                adultMale.shuffleable = false;
                adultMale.PostLoad();
                adultMale.ResolveReferences();
                Backstory adultFemale = new Backstory();
                Traverse.Create(adultFemale).Field("bodyTypeMale").SetValue("Male");
                Traverse.Create(adultFemale).Field("bodyTypeFemale").SetValue("Female");
                adultFemale.slot = BackstorySlot.Adulthood;
                adultFemale.SetTitle("Battlefield medic", "Battlefield medic");
                adultFemale.SetTitleShort("Medic", "Medic");
                adultFemale.baseDesc = "[PAWN_pronoun] continued to serve in the military, being promoted through the ranks as [PAWN_possessive] skill increased. [PAWN_pronoun] learned how to treat more serious wounds as [PAWN_possessive] role slowly transitioned from scout to medic, as well as how to make good use of army rations. [PAWN_pronoun] built good rapport with [PAWN_possessive] squad as a result.";
                Traverse.Create(adultFemale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Shooting", 4);
                Traverse.Create(adultFemale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Medicine", 3);
                Traverse.Create(adultFemale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Cooking", 2);
                Traverse.Create(adultFemale).Field("skillGains").GetValue <Dictionary <string, int> >().Add("Social", 1);
                adultFemale.spawnCategories = new List <string>();
                adultFemale.spawnCategories.AddRange(new string[] { "Civil", "Raider", "Slave", "Trader", "Traveler" });
                adultFemale.shuffleable = false;
                adultFemale.PostLoad();
                adultFemale.ResolveReferences();
                PawnBio male = new PawnBio();
                male.childhood = child;
                male.adulthood = adultMale;
                male.gender    = GenderPossibility.Male;
                male.name      = NameTriple.FromString("Jason 'Jackal' Tarai");
                male.PostLoad();
                SolidBioDatabase.allBios.Add(male);
                PawnBio female = new PawnBio();
                female.childhood = child;
                female.adulthood = adultFemale;
                female.gender    = GenderPossibility.Female;
                female.name      = NameTriple.FromString("Elizabeth 'Eagle' Tarai");
                female.PostLoad();
                SolidBioDatabase.allBios.Add(female);
                BackstoryDatabase.AddBackstory(child);
                BackstoryDatabase.AddBackstory(adultMale);
                BackstoryDatabase.AddBackstory(adultFemale);
            }
        }
示例#14
0
        private static void GenerateTraits(Pawn pawn, PawnGenerationRequest request)
        {
            if (pawn.story == null)
            {
                return;
            }
            if (pawn.story.childhood.forcedTraits != null)
            {
                List <TraitEntry> forcedTraits = pawn.story.childhood.forcedTraits;
                for (int i = 0; i < forcedTraits.Count; i++)
                {
                    TraitEntry traitEntry = forcedTraits[i];
                    if (traitEntry.def == null)
                    {
                        Log.Error("Null forced trait def on " + pawn.story.childhood);
                    }
                    else if (!pawn.story.traits.HasTrait(traitEntry.def))
                    {
                        pawn.story.traits.GainTrait(new Trait(traitEntry.def, traitEntry.degree, false));
                    }
                }
            }
            if (pawn.story.adulthood != null && pawn.story.adulthood.forcedTraits != null)
            {
                List <TraitEntry> forcedTraits2 = pawn.story.adulthood.forcedTraits;
                for (int j = 0; j < forcedTraits2.Count; j++)
                {
                    TraitEntry traitEntry2 = forcedTraits2[j];
                    if (traitEntry2.def == null)
                    {
                        Log.Error("Null forced trait def on " + pawn.story.adulthood);
                    }
                    else if (!pawn.story.traits.HasTrait(traitEntry2.def))
                    {
                        pawn.story.traits.GainTrait(new Trait(traitEntry2.def, traitEntry2.degree, false));
                    }
                }
            }
            int num = Rand.RangeInclusive(2, 3);

            if (request.AllowGay && (LovePartnerRelationUtility.HasAnyLovePartnerOfTheSameGender(pawn) || LovePartnerRelationUtility.HasAnyExLovePartnerOfTheSameGender(pawn)))
            {
                Trait trait = new Trait(TraitDefOf.Gay, PawnGenerator.RandomTraitDegree(TraitDefOf.Gay), false);
                pawn.story.traits.GainTrait(trait);
            }
            while (pawn.story.traits.allTraits.Count < num)
            {
                TraitDef newTraitDef = DefDatabase <TraitDef> .AllDefsListForReading.RandomElementByWeight((TraitDef tr) => tr.GetGenderSpecificCommonality(pawn));

                if (!pawn.story.traits.HasTrait(newTraitDef))
                {
                    if (newTraitDef == TraitDefOf.Gay)
                    {
                        if (!request.AllowGay)
                        {
                            continue;
                        }
                        if (LovePartnerRelationUtility.HasAnyLovePartnerOfTheOppositeGender(pawn) || LovePartnerRelationUtility.HasAnyExLovePartnerOfTheOppositeGender(pawn))
                        {
                            continue;
                        }
                    }
                    if (request.Faction == null || Faction.OfPlayerSilentFail == null || !request.Faction.HostileTo(Faction.OfPlayer) || newTraitDef.allowOnHostileSpawn)
                    {
                        if (!pawn.story.traits.allTraits.Any((Trait tr) => newTraitDef.ConflictsWith(tr)) && (newTraitDef.conflictingTraits == null || !newTraitDef.conflictingTraits.Any((TraitDef tr) => pawn.story.traits.HasTrait(tr))))
                        {
                            if (newTraitDef.requiredWorkTypes == null || !pawn.story.OneOfWorkTypesIsDisabled(newTraitDef.requiredWorkTypes))
                            {
                                if (!pawn.story.WorkTagIsDisabled(newTraitDef.requiredWorkTags))
                                {
                                    int degree = PawnGenerator.RandomTraitDegree(newTraitDef);
                                    if (!pawn.story.childhood.DisallowsTrait(newTraitDef, degree) && (pawn.story.adulthood == null || !pawn.story.adulthood.DisallowsTrait(newTraitDef, degree)))
                                    {
                                        Trait trait2 = new Trait(newTraitDef, degree, false);
                                        if (pawn.mindState != null && pawn.mindState.mentalBreaker != null)
                                        {
                                            float num2 = pawn.mindState.mentalBreaker.BreakThresholdExtreme;
                                            num2 += trait2.OffsetOfStat(StatDefOf.MentalBreakThreshold);
                                            num2 *= trait2.MultiplierOfStat(StatDefOf.MentalBreakThreshold);
                                            if (num2 > 0.4f)
                                            {
                                                continue;
                                            }
                                        }
                                        pawn.story.traits.GainTrait(trait2);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#15
0
        public static bool TryGetBackstory_DisallowedTrait(ThingDef thingDef, Pawn pawn, TraitDef td)
        {
            bool traitIsAllowed = true;

            //Log.Message("checking for alien races...");
            if (Validate.AlienHumanoidRaces.IsInitialized())
            {
                //Log.Message("initialized. Checking if " + thingDef.defName + " is an alien race...");
                ThingDef_AlienRace alienDef = thingDef as ThingDef_AlienRace;
                if (alienDef != null && alienDef.alienRace != null && alienDef.alienRace.raceRestriction != null && alienDef.alienRace.raceRestriction.traitList != null)
                {
                    if (alienDef.alienRace.raceRestriction.traitList.Contains(td))
                    {
                        traitIsAllowed = false;
                    }
                    //AlienTraitEntry ate = new AlienTraitEntry();
                    //ate.defName = (from def in DefDatabase<TraitDef>.AllDefs
                    //              where (def.defName == traitString)
                    //              select def).FirstOrDefault();
                    ////Log.Message("alien race. checking if " + traitString + " is allowed for backstory...");
                    //if (alienDef.alienRace.generalSettings != null && alienDef.alienRace.generalSettings. != null && alienDef.alienRace.generalSettings.disallowedTraits.)
                    //{
                    //    traitIsAllowed = false;
                    //}
                    if (pawn.story != null && pawn.story.AllBackstories != null)
                    {
                        foreach (Backstory bs in pawn.story.AllBackstories)
                        {
                            IEnumerable <BackstoryDef> enumerable = from def in DefDatabase <BackstoryDef> .AllDefs
                                                                    where (def.backstory == bs)
                                                                    select def;
                            foreach (BackstoryDef current in enumerable)
                            {
                                //Log.Message(current.LabelCap + " has disallowed traits: " + current.disallowedTraits.Count);
                                for (int i = 0; i < current.disallowedTraits.Count; i++)
                                {
                                    //Log.Message("" + current.disallowedTraits[i].defName);
                                    if (current.disallowedTraits[i].defName == td)
                                    {
                                        //Log.Message("trait is disallowed");
                                        traitIsAllowed = false;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //Log.Message("trait " + traitString + " is allowed: " + traitIsAllowed);
            return(traitIsAllowed);
        }
 public override void CompPostTick(ref float severityAdjustment)
 {
     base.CompPostTick(ref severityAdjustment);
     if (ticksSinceTraitGain >= ticksTillTraitGain)
     {
         //    if (Selected) Log.Message(string.Format("{0} Trait change on {1} Traits: {2}/{3}\n active: {4}, Originals: {5}/{6}, Added: {7}", this.parent.LabelCap, Pawn.LabelShortCap, CurTraitCount, MaxTraits, Active, OriRemaining, OriTraitCount, AddedTraitCount));
         if (MaxTraits >= CurTraitCount && Active)
         {
             SynthTraitEntry traitEntry = GenCollection.RandomElementByWeight(Props.traitsToGive, (x => x.chance));
             TraitDef        traitDef   = traitEntry.def;
             //    if (Selected) Log.Message(string.Format("{0} rolled {1}", Pawn, traitDef));
             Trait replacedtrait = null;
             if (CurTraitCount == MaxTraits)
             {
                 replacedtrait = OriRemaining > 0 ? OriTraitsRemaining.RandomElement() : AddedSpectrumTraits.FindAll(x => Props.traitsToGive.Any(y => y.def == x.def && ((y.degree > 0 && y.def.degreeDatas.Any(z => z.degree == x.Degree + 1)) || (y.degree < 0 && y.def.degreeDatas.Any(z => z.degree == x.Degree - 1))))).RandomElement();
                 if (replacedtrait == null && CurTraitCount == MaxTraits)
                 {
                     //    if (Selected) Log.Message(string.Format("{0} failed to find a trait to replace with {1}", Pawn, traitDef));
                     return;
                 }
                 //    if (Selected) Log.Message(string.Format("{0} replacing {1} with {2}", Pawn, replacedtrait, traitDef));
             }
             if (Pawn.story.traits.HasTrait(traitDef))// || (replacedtrait!=null && replacedtrait.def.degreeDatas.Count>1))
             {
                 Trait trait = Pawn.story.traits.GetTrait(traitDef);
                 //   if (Selected) Log.Message(string.Format("{0} already has {1}",Pawn, trait.LabelCap));
                 if (traitDef.degreeDatas.Count > 1)
                 {
                     string spectxt      = string.Format("{0} is a spectrum trait at Degree {1}", trait.LabelCap, trait.Degree);
                     int    targetDegree = trait.Degree;
                     bool   specinc      = traitEntry.degree > 0 && traitEntry.def.degreeDatas.Any(x => x.degree == trait.Degree + 1);
                     bool   specdec      = traitEntry.degree < 0 && traitEntry.def.degreeDatas.Any(x => x.degree == trait.Degree - 1);
                     if (specinc)
                     {
                         targetDegree = +traitEntry.degree;
                         spectxt      = spectxt + " " + string.Format("specinc:{0} target Degree {1}", specinc, targetDegree);
                     }
                     else if (specdec)
                     {
                         targetDegree = +traitEntry.degree;
                         spectxt      = spectxt + " " + string.Format("specdec:{0} target Degree {1}", specdec, targetDegree);
                     }
                     else
                     {
                         targetDegree = +traitEntry.degree;
                         spectxt      = spectxt + " " + string.Format("target Degree {2} is max", specinc, specdec, targetDegree);
                     }
                     //    if (Selected) Log.Message(spectxt);
                     if (trait.Degree == traitEntry.degree && traitEntry.degree != 0)
                     {
                         int degree = traitEntry.degree;
                         if (traitEntry.degree > 0 && traitEntry.def.degreeDatas.Any(x => x.degree == traitEntry.degree + 1))
                         {
                             replacedtrait = trait;
                             degree        = traitEntry.degree + 1;
                             trait         = new Trait(traitDef, degree);
                             Pawn.story.traits.allTraits.Remove(replacedtrait);
                             GainTrait(Pawn, trait);
                         }
                         if (traitEntry.degree < 0 && traitEntry.def.degreeDatas.Any(x => x.degree == traitEntry.degree - 1))
                         {
                             replacedtrait = trait;
                             degree        = traitEntry.degree - 1;
                             trait         = new Trait(traitDef, degree);
                             Pawn.story.traits.allTraits.Remove(replacedtrait);
                             GainTrait(Pawn, trait);
                         }
                     }
                 }
             }
             else
             {
                 foreach (var item in traitDef.conflictingTraits)
                 {
                     if (Pawn.story.traits.HasTrait(item))
                     {
                         Pawn.story.traits.allTraits.Remove(Pawn.story.traits.GetTrait(item));
                     }
                 }
                 if (CurTraitCount == MaxTraits || (replacedtrait != null && Pawn.story.traits.HasTrait(replacedtrait.def)))
                 {
                     Pawn.story.traits.allTraits.Remove(Pawn.story.traits.GetTrait(replacedtrait.def));
                 }
                 if (CurTraitCount < MaxTraits)
                 {
                     Trait trait = new Trait(traitDef, traitEntry.degree);
                     GainTrait(Pawn, trait);
                 }
             }
         }
         ticksSinceTraitGain = 0;
         ticksTillTraitGain  = Rand.Range(Props.TraitGainMinIntervalTicks, Props.TraitGainMaxIntervalTicks);
     }
     ticksSinceTraitGain++;
 }
示例#17
0
 public static void RemoveTrait(TraitSet traitSet, TraitDef targetTrait)
 {
     traitSet.allTraits.RemoveAll((trait) => trait.def == targetTrait);
 }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            const int partyParts  = 4;
            const int jobsPerPart = 3;
            const int maxTries    = 3;

            List <PartyJobType> partyJobsType = new List <PartyJobType>();
            List <Toil>         partyToils    = new List <Toil>();
            Building_Pyre       pyre          = this.TargetThingA as Building_Pyre;

            bool revelerIsPsychopath          = this.pawn.story.traits.HasTrait(TraitDef.Named("Psychopath"));
            bool revelerIsNudist              = this.pawn.story.traits.HasTrait(TraitDefOf.Nudist);
            bool revelerHasTriggerHappyTrait  = this.pawn.story.traits.DegreeOfTrait(TraitDef.Named("ShootingAccuracy")) == -1;
            int  revelerAlcoholAddictionLevel = this.pawn.story.traits.DegreeOfTrait(TraitDefOf.DrugDesire);

            // Psychopaths don't like having parties with others... 3:p
            if (revelerIsPsychopath)
            {
                partyToils.Add(Toils_Goto.GotoCell(pyreIndex, PathEndMode.ClosestTouch));
                Toil toil = new Toil()
                {
                    tickAction = () =>
                    {
                        this.pawn.Drawer.rotator.FaceCell(pyre.Position);
                    },
                    defaultDuration     = 300,
                    defaultCompleteMode = ToilCompleteMode.Delay
                };
                partyToils.Add(toil);
                pawn.needs.mood.thoughts.memories.TryGainMemoryThought(Util_CampfireParty.Thought_HadCampfirePartyPsychopaths);
                return(partyToils);
            }

            // Initialize party jobs type.
            for (int jobTypeIndex = 0; jobTypeIndex < partyParts * jobsPerPart; jobTypeIndex++)
            {
                partyJobsType.Add(PartyJobType.Undefined);
            }

            // If the colonist is a nudist, add a drop clothes job in 1st, 2nd or 3rd part.
            if (revelerIsNudist)
            {
                for (int tries = 0; tries < maxTries; tries++)
                {
                    int jobIndex = Rand.Range(jobsPerPart, 3 * jobsPerPart) + tries;
                    if (jobIndex >= partyParts * jobsPerPart)
                    {
                        jobIndex -= jobsPerPart;
                    }
                    if (partyJobsType[jobIndex] == PartyJobType.Undefined)
                    {
                        partyJobsType[jobIndex] = PartyJobType.DropClothes;
                        break;
                    }
                }
            }

            // If the colonist has the trigger-happy trait, add a shoot in the air job in 3nd or 4th part.
            if (revelerHasTriggerHappyTrait)
            {
                for (int tries = 0; tries < maxTries; tries++)
                {
                    int jobIndex = Rand.Range(2 * jobsPerPart, 4 * jobsPerPart) + tries;
                    if (jobIndex >= partyParts * jobsPerPart)
                    {
                        jobIndex -= jobsPerPart;
                    }
                    if (partyJobsType[jobIndex] == PartyJobType.Undefined)
                    {
                        partyJobsType[jobIndex] = PartyJobType.ShootUpInTheAir;
                        break;
                    }
                }
            }

            // Add a drink beer job for each level of addiction.
            if (revelerAlcoholAddictionLevel >= 0)
            {
                for (int beerIndex = 0; beerIndex < 2 * (revelerAlcoholAddictionLevel + 1); beerIndex++)
                {
                    for (int tries = 0; tries < maxTries; tries++)
                    {
                        int jobIndex = Rand.Range(0, partyParts * jobsPerPart) + tries;
                        if (jobIndex >= partyParts * jobsPerPart)
                        {
                            jobIndex -= jobsPerPart;
                        }
                        if (partyJobsType[jobIndex] == PartyJobType.Undefined)
                        {
                            partyJobsType[jobIndex] = PartyJobType.DrinkBeer;
                            break;
                        }
                    }
                }
            }

            // Convert all remaining undefined jobs into wander/play the guitar/dance jobs.
            for (int jobIndex = 0; jobIndex < partyParts * jobsPerPart; jobIndex++)
            {
                if (partyJobsType[jobIndex] == PartyJobType.Undefined)
                {
                    float jobSelector = Rand.Value;
                    if (jobSelector < 0.2f)
                    {
                        partyJobsType[jobIndex] = PartyJobType.PlayTheGuitar;
                    }
                    else if (jobSelector < 0.5f)
                    {
                        partyJobsType[jobIndex] = PartyJobType.Dance;
                    }
                    else
                    {
                        partyJobsType[jobIndex] = PartyJobType.WanderAroundPyre;
                    }
                }
            }
            // Debug: display generated jobs sequence.

            /*for (int jobIndex = 0; jobIndex < partyParts * jobsPerPart; jobIndex++)
             * {
             *  Log.Message("partyJobsType[" + jobIndex + "] = " + partyJobsType[jobIndex]);
             * }*/

            // Generate actual toils.
            if (this.pawn.jobs.jobQueue == null)
            {
                // This case will only happen for a pawn who has never queued jobs before.
                this.pawn.jobs.jobQueue = new JobQueue();
            }

            for (int jobIndex = 0; jobIndex < partyParts * jobsPerPart; jobIndex++)
            {
                switch (partyJobsType[jobIndex])
                {
                case PartyJobType.WanderAroundPyre:
                    this.pawn.jobs.jobQueue.EnqueueLast(new Job(Util_CampfireParty.Job_WanderAroundPyre, pyre));
                    break;

                case PartyJobType.PlayTheGuitar:
                    this.pawn.jobs.jobQueue.EnqueueLast(new Job(Util_CampfireParty.Job_PlayTheGuitar, pyre));
                    break;

                case PartyJobType.Dance:
                    this.pawn.jobs.jobQueue.EnqueueLast(new Job(Util_CampfireParty.Job_Dance, pyre));
                    break;

                case PartyJobType.DrinkBeer:
                    this.pawn.jobs.jobQueue.EnqueueLast(new Job(Util_CampfireParty.Job_IngestBeer, pyre));
                    break;

                case PartyJobType.DropClothes:
                    this.pawn.jobs.jobQueue.EnqueueLast(new Job(Util_CampfireParty.Job_DropClothes, pyre));
                    break;

                case PartyJobType.ShootUpInTheAir:
                    this.pawn.jobs.jobQueue.EnqueueLast(new Job(Util_CampfireParty.Job_ShootUpinTheAir, pyre));
                    break;
                }
                if ((jobIndex % jobsPerPart) == (jobsPerPart - 1))
                {
                    this.pawn.jobs.jobQueue.EnqueueLast(new Job(Util_CampfireParty.Job_UpdateThought));
                }
            }
            return(partyToils);
        }
示例#19
0
        public override void DefsLoaded()
        {
            if (ModIsActive)
            {
                toggleEmpathy       = Settings.GetHandle <bool>("EnableEmpathy", "EmpathyChangesTitle".Translate(), "EmpathyChangesTooltip".Translate(), true);
                toggleKinsey        = Settings.GetHandle <bool>("EnableSexuality", "SexualityChangesTitle".Translate(), "SexualityChangesTooltip".Translate(), true);
                kinseyMode          = Settings.GetHandle <KinseyMode>("KinseyMode", "KinseyModeTitle".Translate(), "KinseyModeTooltip".Translate(), KinseyMode.Realistic, null, "KinseyMode_");
                toggleSabotage      = Settings.GetHandle <bool>("EnableSabotage", "SabotageIncidentTitle".Translate(), "SabotageIncidentTooltip".Translate(), false);
                toggleIndividuality = Settings.GetHandle <bool>("EnableIndividuality", "IndividualityTitle".Translate(), "IndividualityTooltip".Translate(), true);

                sabotabby   = toggleSabotage.Value;
                notBabyMode = toggleIndividuality.Value;

                if (!detoursMedical)
                {
                    Logger.Warning("MedicalDetourDisable".Translate());
                }

                //Vanilla Defs will be edited at load to improve compatibility with other mods.
                AddConflictingTraits("Nudist", new TraitDef[] { TraitDefOfPsychology.Prude });
                AddConflictingTraits("Bloodlust", new TraitDef[] { TraitDefOfPsychology.BleedingHeart, TraitDefOfPsychology.Desensitized });
                AddConflictingTraits("Psychopath", new TraitDef[] { TraitDefOfPsychology.BleedingHeart, TraitDefOfPsychology.Desensitized, TraitDefOfPsychology.OpenMinded });
                AddConflictingTraits("Cannibal", new TraitDef[] { TraitDefOfPsychology.BleedingHeart, TraitDefOfPsychology.Gourmet });
                AddConflictingTraits("Ascetic", new TraitDef[] { TraitDefOfPsychology.Gourmet });
                AddConflictingTraits("Neurotic", new TraitDef[] { TraitDefOfPsychology.HeavySleeper });
                AddConflictingTraits("DislikesMen", new TraitDef[] { TraitDefOfPsychology.OpenMinded });
                AddConflictingTraits("DislikesWomen", new TraitDef[] { TraitDefOfPsychology.OpenMinded });
                AddConflictingTraits("Prosthophobe", new TraitDef[] { TraitDefOfPsychology.OpenMinded });

                TraitDef bisexual = DefDatabase <TraitDef> .GetNamedSilentFail("Bisexual");

                TraitDef asexual = DefDatabase <TraitDef> .GetNamedSilentFail("Asexual");

                if (bisexual != null || asexual != null || !toggleKinsey || !detoursSexual)
                {
                    if (toggleKinsey)
                    {
                        Logger.Message("KinseyDisable".Translate());
                        if (!detoursSexual)
                        {
                            Logger.Warning("KinseyDetourDisable".Translate());
                            TraitDefOfPsychology.Codependent.SetCommonality(0f);
                            TraitDefOfPsychology.Lecher.SetCommonality(0f);
                            TraitDefOfPsychology.OpenMinded.SetCommonality(0f);
                            TraitDefOfPsychology.Polygamous.SetCommonality(0f);
                        }
                    }
                    kinsey = false;
                }

                if (PsychologyBase.ActivateKinsey())
                {
                    mode = kinseyMode.Value;
                    TraitDef gay = TraitDef.Named("Gay");
                    if (gay != null)
                    {
                        gay.SetCommonality(0f);
                    }
                    foreach (ThingDef t in DefDatabase <ThingDef> .AllDefsListForReading)
                    {
                        if (t.thingClass == typeof(Pawn))
                        {
                            t.thingClass = typeof(PsychologyPawn);
                        }
                    }
                }

                AddNullifyingTraits("AteLavishMeal", new TraitDef[] { TraitDefOfPsychology.Gourmet });
                AddNullifyingTraits("AteFineMeal", new TraitDef[] { TraitDefOfPsychology.Gourmet });
                AddNullifyingTraits("AteAwfulMeal", new TraitDef[] { TraitDefOfPsychology.Gourmet });
                AddNullifyingTraits("AteRawFood", new TraitDef[] { TraitDefOfPsychology.Gourmet });
                AddNullifyingTraits("AteInsectMeatAsIngredient", new TraitDef[] { TraitDefOfPsychology.Gourmet });
                AddNullifyingTraits("AteInsectMeatDirect", new TraitDef[] { TraitDefOfPsychology.Gourmet });
                AddNullifyingTraits("AteRottenFood", new TraitDef[] { TraitDefOfPsychology.Gourmet });
                AddNullifyingTraits("SleepDisturbed", new TraitDef[] { TraitDefOfPsychology.HeavySleeper });
                AddNullifyingTraits("ObservedLayingCorpse", new TraitDef[] { TraitDefOfPsychology.Desensitized });
                AddNullifyingTraits("WitnessedDeathAlly", new TraitDef[] { TraitDefOfPsychology.BleedingHeart, TraitDefOfPsychology.Desensitized });
                AddNullifyingTraits("WitnessedDeathNonAlly", new TraitDef[] { TraitDefOfPsychology.BleedingHeart, TraitDefOfPsychology.Desensitized });
                AddNullifyingTraits("FeelingRandom", new TraitDef[] { TraitDefOfPsychology.Unstable });
                AddNullifyingTraits("ApparelDamaged", new TraitDef[] { TraitDefOfPsychology.Prude });
                AddNullifyingTraits("EnvironmentDark", new TraitDef[] { TraitDefOfPsychology.Photosensitive });
                AddNullifyingTraits("DeadMansApparel", new TraitDef[] { TraitDefOfPsychology.Desensitized });
                AddNullifyingTraits("Naked", new TraitDef[] { TraitDefOfPsychology.Prude });
                AddNullifyingTraits("ColonistLeftUnburied", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                AddNullifyingTraits("CheatedOnMe", new TraitDef[] { TraitDefOfPsychology.Polygamous });
                AddNullifyingTraits("Affair", new TraitDef[] { TraitDefOfPsychology.Polygamous });
                AddNullifyingTraits("Disfigured", new TraitDef[] { TraitDefOfPsychology.OpenMinded });
                AddNullifyingTraits("Pretty", new TraitDef[] { TraitDefOfPsychology.OpenMinded });
                AddNullifyingTraits("Ugly", new TraitDef[] { TraitDefOfPsychology.OpenMinded });
                AddNullifyingTraits("SleptOutside", new TraitDef[] { TraitDefOfPsychology.Outdoorsy });

                ThoughtDef knowGuestExecuted = AddNullifyingTraits("KnowGuestExecuted", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowGuestExecuted != null && toggleEmpathy)
                {
                    if (knowGuestExecuted.stages.Count >= 1) //We can't assume that other mods won't remove stages from this thought, so we'll try to avoid OutOfBounds exceptions.
                    {
                        knowGuestExecuted.stages[0].baseMoodEffect = -1;
                    }
                    if (knowGuestExecuted.stages.Count >= 2)
                    {
                        knowGuestExecuted.stages[1].baseMoodEffect = -2;
                    }
                    if (knowGuestExecuted.stages.Count >= 3)
                    {
                        knowGuestExecuted.stages[2].baseMoodEffect = -4;
                    }
                    if (knowGuestExecuted.stages.Count >= 4)
                    {
                        knowGuestExecuted.stages[3].baseMoodEffect = -5;
                    }
                }

                ThoughtDef knowColonistExecuted = AddNullifyingTraits("KnowColonistExecuted", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistExecuted != null && toggleEmpathy)
                {
                    if (knowColonistExecuted.stages.Count >= 1)
                    {
                        knowColonistExecuted.stages[0].baseMoodEffect = -1;
                    }
                    if (knowColonistExecuted.stages.Count >= 2)
                    {
                        knowColonistExecuted.stages[1].baseMoodEffect = -2;
                    }
                    if (knowColonistExecuted.stages.Count >= 3)
                    {
                        knowColonistExecuted.stages[2].baseMoodEffect = -4;
                    }
                    if (knowColonistExecuted.stages.Count >= 4)
                    {
                        knowColonistExecuted.stages[3].baseMoodEffect = -5;
                    }
                }

                ThoughtDef knowPrisonerDiedInnocent = AddNullifyingTraits("KnowPrisonerDiedInnocent", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowPrisonerDiedInnocent != null && toggleEmpathy)
                {
                    if (knowPrisonerDiedInnocent.stages.Count >= 1)
                    {
                        knowPrisonerDiedInnocent.stages[0].baseMoodEffect = -4;
                    }
                }

                ThoughtDef knowColonistDied = AddNullifyingTraits("KnowColonistDied", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistDied != null && toggleEmpathy)
                {
                    if (knowColonistDied.stages.Count >= 1)
                    {
                        knowColonistDied.stages[0].baseMoodEffect = -2;
                    }
                }

                ThoughtDef colonistAbandoned = AddNullifyingTraits("ColonistAbandoned", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (colonistAbandoned != null && toggleEmpathy)
                {
                    if (colonistAbandoned.stages.Count >= 1)
                    {
                        colonistAbandoned.stages[0].baseMoodEffect = -2;
                    }
                }

                ThoughtDef colonistAbandonedToDie = AddNullifyingTraits("ColonistAbandonedToDie", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (colonistAbandonedToDie != null && toggleEmpathy)
                {
                    if (colonistAbandonedToDie.stages.Count >= 1)
                    {
                        colonistAbandonedToDie.stages[0].baseMoodEffect = -4;
                    }
                }

                ThoughtDef prisonerAbandonedToDie = AddNullifyingTraits("PrisonerAbandonedToDie", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (prisonerAbandonedToDie != null && toggleEmpathy)
                {
                    if (prisonerAbandonedToDie.stages.Count >= 1)
                    {
                        prisonerAbandonedToDie.stages[0].baseMoodEffect = -3;
                    }
                }

                ThoughtDef knowPrisonerSold = AddNullifyingTraits("KnowPrisonerSold", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowPrisonerSold != null && toggleEmpathy)
                {
                    if (knowPrisonerSold.stages.Count >= 1)
                    {
                        knowPrisonerSold.stages[0].baseMoodEffect = -4;
                    }
                }

                ThoughtDef knowGuestOrganHarvested = AddNullifyingTraits("KnowGuestOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowGuestOrganHarvested != null && toggleEmpathy)
                {
                    if (knowGuestOrganHarvested.stages.Count >= 1)
                    {
                        knowGuestOrganHarvested.stages[0].baseMoodEffect = -4;
                    }
                }

                ThoughtDef knowColonistOrganHarvested = AddNullifyingTraits("KnowColonistOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistOrganHarvested != null && toggleEmpathy)
                {
                    if (knowColonistOrganHarvested.stages.Count >= 1)
                    {
                        knowColonistOrganHarvested.stages[0].baseMoodEffect = -4;
                    }
                }

                ReplaceThoughtWorker("CabinFever", typeof(ThoughtWorker_CabinFever));
                ReplaceThoughtWorker("Disfigured", typeof(ThoughtWorker_Disfigured));
                ReplaceThoughtWorker("Ugly", typeof(ThoughtWorker_Ugly));
                ReplaceThoughtWorker("AnnoyingVoice", typeof(ThoughtWorker_AnnoyingVoice));
                ReplaceThoughtWorker("CreepyBreathing", typeof(ThoughtWorker_CreepyBreathing));
                ReplaceThoughtWorker("Pretty", typeof(ThoughtWorker_Pretty));
                ReplaceIncidentWorker("RaidEnemy", typeof(IncidentWorker_RaidEnemy));

                // Credit to FluffierThanThou for the code.
                var livingRaces = DefDatabase <ThingDef>
                                  .AllDefsListForReading
                                  .Where(t => !t.race?.hediffGiverSets?.NullOrEmpty() ?? false);

                foreach (ThingDef alive in livingRaces)
                {
                    if (alive.race.hediffGiverSets.Contains(DefDatabase <HediffGiverSetDef> .GetNamed("OrganicStandard")))
                    {
                        alive.race.hediffGiverSets.Add(DefDatabase <HediffGiverSetDef> .GetNamed("OrganicPsychology"));
                        alive.recipes.Add(RecipeDefOfPsychology.TreatPyromania);
                    }
                }

                MentalBreakDef berserk = DefDatabase <MentalBreakDef> .GetNamed("Berserk");

                berserk.baseCommonality = 0f;
                MentalStateDef fireStartingSpree = DefDatabase <MentalStateDef> .GetNamed("FireStartingSpree");

                fireStartingSpree.workerClass = typeof(MentalStateWorker_FireStartingSpree);

                /*
                 * Now to enjoy the benefits of having made a popular mod!
                 * This will be our little secret.
                 */
                Backstory childMe = new Backstory();
                childMe.bodyTypeMale   = BodyType.Male;
                childMe.bodyTypeFemale = BodyType.Female;
                childMe.slot           = BackstorySlot.Childhood;
                childMe.SetTitle("Child soldier");
                childMe.SetTitleShort("Scout");
                childMe.baseDesc = "NAME was born into a dictatorial outlander society on a nearby rimworld. Their chief export was war, and HE was conscripted at a young age into the military to serve as a scout due to HIS runner's build. HECAP learned how to use a gun, patch wounds on the battlefield, and communicate with HIS squad. It was there HE earned HIS nickname.";
                childMe.skillGains.Add("Shooting", 4);
                childMe.skillGains.Add("Medicine", 2);
                childMe.skillGains.Add("Social", 1);
                childMe.requiredWorkTags = WorkTags.Violent;
                childMe.shuffleable      = false;
                childMe.PostLoad();
                childMe.ResolveReferences();
                //Disabled until I can be bothered to code it so they're actually siblings.

                /*Backstory adultMale = new Backstory();
                 * adultMale.bodyTypeMale = BodyType.Male;
                 * adultMale.bodyTypeFemale = BodyType.Female;
                 * adultMale.slot = BackstorySlot.Adulthood;
                 * adultMale.SetTitle("Missing in action");
                 * adultMale.SetTitleShort("P.O.W.");
                 * adultMale.baseDesc = "Eventually, HE was captured on a mission by one of his faction's many enemies. HECAP was tortured for information, the techniques of which HE never forgot. When they could get no more out of HIM, HE was sent to a prison camp, where HE worked for years before staging an escape and fleeing into civilization.";
                 * adultMale.skillGains.Add("Crafting", 4);
                 * adultMale.skillGains.Add("Construction", 3);
                 * adultMale.skillGains.Add("Mining", 2);
                 * adultMale.skillGains.Add("Social", 1);
                 * adultMale.spawnCategories = new List<string>();
                 * adultMale.spawnCategories.AddRange(new string[] { "Civil", "Raider", "Slave", "Trader", "Traveler" });
                 * adultMale.shuffleable = false;
                 * adultMale.PostLoad();
                 * adultMale.ResolveReferences();*/
                Backstory adultFemale = new Backstory();
                adultFemale.bodyTypeMale   = BodyType.Male;
                adultFemale.bodyTypeFemale = BodyType.Female;
                adultFemale.slot           = BackstorySlot.Adulthood;
                adultFemale.SetTitle("Battlefield medic");
                adultFemale.SetTitleShort("Medic");
                adultFemale.baseDesc = "HECAP continued to serve in the military, being promoted through the ranks as HIS skill increased. HECAP learned how to treat more serious wounds as HIS role slowly transitioned from scout to medic, as well as how to make good use of army rations. HECAP built good rapport with HIS squad as a result.";
                adultFemale.skillGains.Add("Shooting", 4);
                adultFemale.skillGains.Add("Medicine", 3);
                adultFemale.skillGains.Add("Cooking", 2);
                adultFemale.skillGains.Add("Social", 1);
                adultFemale.spawnCategories = new List <string>();
                adultFemale.spawnCategories.AddRange(new string[] { "Civil", "Raider", "Slave", "Trader", "Traveler" });
                adultFemale.shuffleable = false;
                adultFemale.PostLoad();
                adultFemale.ResolveReferences();

                /*PawnBio maleMe = new PawnBio();
                 * maleMe.childhood = childMe;
                 * maleMe.adulthood = adultMale;
                 * maleMe.gender = GenderPossibility.Male;
                 * maleMe.name = NameTriple.FromString("Nathan 'Jackal' Tarai");
                 * maleMe.PostLoad();
                 * SolidBioDatabase.allBios.Add(maleMe);*/
                PawnBio femaleMe = new PawnBio();
                femaleMe.childhood = childMe;
                femaleMe.adulthood = adultFemale;
                femaleMe.gender    = GenderPossibility.Female;
                femaleMe.name      = NameTriple.FromString("Elizabeth 'Eagle' Tarai");
                femaleMe.PostLoad();
                SolidBioDatabase.allBios.Add(femaleMe);
                BackstoryDatabase.AddBackstory(childMe);
                //BackstoryDatabase.AddBackstory(adultMale);
                BackstoryDatabase.AddBackstory(adultFemale);
            }
        }
示例#20
0
 public void ApplyTraitAdjustments(Pawn pawn, TraitDef traitDef)
 {
 }
示例#21
0
        public override void DefsLoaded()
        {
            if (ModIsActive)
            {
                /* Mod settings */

                toggleEmpathy       = Settings.GetHandle <bool>("EnableEmpathy", "EmpathyChangesTitle".Translate(), "EmpathyChangesTooltip".Translate(), true);
                toggleKinsey        = Settings.GetHandle <bool>("EnableSexuality", "SexualityChangesTitle".Translate(), "SexualityChangesTooltip".Translate(), true);
                kinseyMode          = Settings.GetHandle <KinseyMode>("KinseyMode", "KinseyModeTitle".Translate(), "KinseyModeTooltip".Translate(), KinseyMode.Realistic, null, "KinseyMode_");
                toggleIndividuality = Settings.GetHandle <bool>("EnableIndividuality", "IndividualityTitle".Translate(), "IndividualityTooltip".Translate(), true);
                toggleElections     = Settings.GetHandle <bool>("EnableElections", "ElectionsTitle".Translate(), "ElectionsTooltip".Translate(), true);

                notBabyMode = toggleIndividuality.Value;
                elections   = toggleElections.Value;

                if (PsychologyBase.ActivateKinsey())
                {
                    mode = kinseyMode.Value;
                }

                /* Mod conflict detection */

                TraitDef bisexual = DefDatabase <TraitDef> .GetNamedSilentFail("Bisexual");

                TraitDef asexual = DefDatabase <TraitDef> .GetNamedSilentFail("Asexual");

                if (bisexual != null || asexual != null || !toggleKinsey)
                {
                    if (toggleKinsey)
                    {
                        Logger.Message("KinseyDisable".Translate());
                    }
                    kinsey = false;
                }

                /* Conditional vanilla Def edits */

                ThoughtDef knowGuestExecuted = AddNullifyingTraits("KnowGuestExecuted", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowGuestExecuted != null && toggleEmpathy)
                {
                    knowGuestExecuted = ModifyThoughtStages(knowGuestExecuted, new int[] { -1, -2, -4, -5 });
                }
                ThoughtDef knowColonistExecuted = AddNullifyingTraits("KnowColonistExecuted", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistExecuted != null && toggleEmpathy)
                {
                    knowColonistExecuted = ModifyThoughtStages(knowColonistExecuted, new int[] { -1, -2, -4, -5 });
                }
                ThoughtDef knowPrisonerDiedInnocent = AddNullifyingTraits("KnowPrisonerDiedInnocent", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowPrisonerDiedInnocent != null && toggleEmpathy)
                {
                    knowPrisonerDiedInnocent = ModifyThoughtStages(knowPrisonerDiedInnocent, new int[] { -4 });
                }
                ThoughtDef knowColonistDied = AddNullifyingTraits("KnowColonistDied", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistDied != null && toggleEmpathy)
                {
                    knowColonistDied = ModifyThoughtStages(knowColonistDied, new int[] { -2 });
                }
                ThoughtDef colonistAbandoned = AddNullifyingTraits("ColonistAbandoned", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (colonistAbandoned != null && toggleEmpathy)
                {
                    colonistAbandoned = ModifyThoughtStages(colonistAbandoned, new int[] { -2 });
                }
                ThoughtDef colonistAbandonedToDie = AddNullifyingTraits("ColonistAbandonedToDie", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (colonistAbandonedToDie != null && toggleEmpathy)
                {
                    colonistAbandonedToDie = ModifyThoughtStages(colonistAbandonedToDie, new int[] { -4 });
                }
                ThoughtDef prisonerAbandonedToDie = AddNullifyingTraits("PrisonerAbandonedToDie", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (prisonerAbandonedToDie != null && toggleEmpathy)
                {
                    prisonerAbandonedToDie = ModifyThoughtStages(prisonerAbandonedToDie, new int[] { -3 });
                }
                ThoughtDef knowPrisonerSold = AddNullifyingTraits("KnowPrisonerSold", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowPrisonerSold != null && toggleEmpathy)
                {
                    knowPrisonerSold = ModifyThoughtStages(knowPrisonerSold, new int[] { -4 });
                }
                ThoughtDef knowGuestOrganHarvested = AddNullifyingTraits("KnowGuestOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowGuestOrganHarvested != null && toggleEmpathy)
                {
                    knowGuestOrganHarvested = ModifyThoughtStages(knowGuestOrganHarvested, new int[] { -4 });
                }
                ThoughtDef knowColonistOrganHarvested = AddNullifyingTraits("KnowColonistOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistOrganHarvested != null && toggleEmpathy)
                {
                    knowColonistOrganHarvested = ModifyThoughtStages(knowColonistOrganHarvested, new int[] { -4 });
                }
                ThoughtDef beauty = AddNullifyingTraits("KnowColonistOrganHarvested", new TraitDef[] { TraitDefOfPsychology.BleedingHeart });
                if (knowColonistOrganHarvested != null && toggleEmpathy)
                {
                    knowColonistOrganHarvested = ModifyThoughtStages(knowColonistOrganHarvested, new int[] { -4 });
                }


                IEnumerable <ThingDef> things = (from m in LoadedModManager.RunningMods
                                                 from def in m.AllDefs.OfType <ThingDef>()
                                                 where typeof(Pawn).IsAssignableFrom(def.thingClass)
                                                 select def);
                foreach (ThingDef t in things)
                {
                    if (t.race.intelligence == Intelligence.Humanlike && (DefDatabase <ThinkTreeDef> .GetNamedSilentFail("Zombie") == null || t.race.thinkTreeMain != DefDatabase <ThinkTreeDef> .GetNamedSilentFail("Zombie")))
                    {
                        t.thingClass = typeof(PsychologyPawn);
                        t.inspectorTabsResolved.Add(InspectTabManager.GetSharedInstance(typeof(ITab_Pawn_Psyche)));
                        t.recipes.Add(RecipeDefOfPsychology.TreatPyromania);
                        t.recipes.Add(RecipeDefOfPsychology.TreatChemicalInterest);
                        t.recipes.Add(RecipeDefOfPsychology.TreatChemicalFascination);
                        t.recipes.Add(RecipeDefOfPsychology.TreatDepression);
                        if (!t.race?.hediffGiverSets?.NullOrEmpty() ?? false)
                        {
                            if (t.race.hediffGiverSets.Contains(DefDatabase <HediffGiverSetDef> .GetNamed("OrganicStandard")))
                            {
                                t.race.hediffGiverSets.Add(DefDatabase <HediffGiverSetDef> .GetNamed("OrganicPsychology"));
                            }
                        }
                    }
                }

                /*
                 * Now to enjoy the benefits of having made a popular mod!
                 * This will be our little secret.
                 */
                Backstory childMe = new Backstory();
                childMe.bodyTypeMale   = BodyType.Male;
                childMe.bodyTypeFemale = BodyType.Female;
                childMe.slot           = BackstorySlot.Childhood;
                childMe.SetTitle("Child soldier");
                childMe.SetTitleShort("Scout");
                childMe.baseDesc = "NAME was born into a dictatorial outlander society on a nearby rimworld. Their chief export was war, and HE was conscripted at a young age into the military to serve as a scout due to HIS runner's build. HECAP learned how to use a gun, patch wounds on the battlefield, and communicate with HIS squad. It was there HE earned HIS nickname.";
                childMe.skillGains.Add("Shooting", 4);
                childMe.skillGains.Add("Medicine", 2);
                childMe.skillGains.Add("Social", 1);
                childMe.requiredWorkTags = WorkTags.Violent;
                childMe.shuffleable      = false;
                childMe.PostLoad();
                childMe.ResolveReferences();
                //Disabled until I can be bothered to code it so they're actually siblings.

                /*Backstory adultMale = new Backstory();
                 * adultMale.bodyTypeMale = BodyType.Male;
                 * adultMale.bodyTypeFemale = BodyType.Female;
                 * adultMale.slot = BackstorySlot.Adulthood;
                 * adultMale.SetTitle("Missing in action");
                 * adultMale.SetTitleShort("P.O.W.");
                 * adultMale.baseDesc = "Eventually, HE was captured on a mission by one of his faction's many enemies. HECAP was tortured for information, the techniques of which HE never forgot. When they could get no more out of HIM, HE was sent to a prison camp, where HE worked for years before staging an escape and fleeing into civilization.";
                 * adultMale.skillGains.Add("Crafting", 4);
                 * adultMale.skillGains.Add("Construction", 3);
                 * adultMale.skillGains.Add("Mining", 2);
                 * adultMale.skillGains.Add("Social", 1);
                 * adultMale.spawnCategories = new List<string>();
                 * adultMale.spawnCategories.AddRange(new string[] { "Civil", "Raider", "Slave", "Trader", "Traveler" });
                 * adultMale.shuffleable = false;
                 * adultMale.PostLoad();
                 * adultMale.ResolveReferences();*/
                Backstory adultFemale = new Backstory();
                adultFemale.bodyTypeMale   = BodyType.Male;
                adultFemale.bodyTypeFemale = BodyType.Female;
                adultFemale.slot           = BackstorySlot.Adulthood;
                adultFemale.SetTitle("Battlefield medic");
                adultFemale.SetTitleShort("Medic");
                adultFemale.baseDesc = "HECAP continued to serve in the military, being promoted through the ranks as HIS skill increased. HECAP learned how to treat more serious wounds as HIS role slowly transitioned from scout to medic, as well as how to make good use of army rations. HECAP built good rapport with HIS squad as a result.";
                adultFemale.skillGains.Add("Shooting", 4);
                adultFemale.skillGains.Add("Medicine", 3);
                adultFemale.skillGains.Add("Cooking", 2);
                adultFemale.skillGains.Add("Social", 1);
                adultFemale.spawnCategories = new List <string>();
                adultFemale.spawnCategories.AddRange(new string[] { "Civil", "Raider", "Slave", "Trader", "Traveler" });
                adultFemale.shuffleable = false;
                adultFemale.PostLoad();
                adultFemale.ResolveReferences();

                /*PawnBio maleMe = new PawnBio();
                 * maleMe.childhood = childMe;
                 * maleMe.adulthood = adultMale;
                 * maleMe.gender = GenderPossibility.Male;
                 * maleMe.name = NameTriple.FromString("Nathan 'Jackal' Tarai");
                 * maleMe.PostLoad();
                 * SolidBioDatabase.allBios.Add(maleMe);*/
                PawnBio femaleMe = new PawnBio();
                femaleMe.childhood = childMe;
                femaleMe.adulthood = adultFemale;
                femaleMe.gender    = GenderPossibility.Female;
                femaleMe.name      = NameTriple.FromString("Elizabeth 'Eagle' Tarai");
                femaleMe.PostLoad();
                SolidBioDatabase.allBios.Add(femaleMe);
                BackstoryDatabase.AddBackstory(childMe);
                //BackstoryDatabase.AddBackstory(adultMale);
                BackstoryDatabase.AddBackstory(adultFemale);
            }
        }
示例#22
0
            public static void Listener(ref Pawn ___pawn, ref Hediff hediff, BodyPartRecord part)
            {
                try
                {
                    //Si il sagit d'une VX0 alors passation du pawn en mode surrogate
                    if (hediff.def.defName == "ATPP_HediffVX0Chip" && (___pawn.Faction == Faction.OfPlayer || ___pawn.IsPrisoner))
                    {
                        CompAndroidState cas = ___pawn.TryGetComp <CompAndroidState>();
                        if (cas == null || cas.isSurrogate)
                        {
                            return;
                        }

                        if (___pawn.Faction.IsPlayer && !Utils.preventVX0Thought)
                        {
                            //Simulation mort surrogate organic
                            PawnDiedOrDownedThoughtsUtility.TryGiveThoughts(___pawn, null, PawnDiedOrDownedThoughtsKind.Died);

                            Pawn spouse = ___pawn.GetSpouse();
                            if (spouse != null && !spouse.Dead && spouse.needs.mood != null)
                            {
                                MemoryThoughtHandler memories = spouse.needs.mood.thoughts.memories;
                                memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried);
                                memories.RemoveMemoriesOfDef(ThoughtDefOf.HoneymoonPhase);
                            }
                            Traverse.Create(___pawn.relations).Method("AffectBondedAnimalsOnMyDeath").GetValue();

                            ___pawn.health.NotifyPlayerOfKilled(null, null, null);
                        }
                        else
                        {
                            //Si pas de la faction du player alors on va changer sa faction dans simuler de mort
                            if (!___pawn.Faction.IsPlayer)
                            {
                                ___pawn.SetFaction(Faction.OfPlayer, null);
                            }
                        }

                        cas.initAsSurrogate();

                        //SKills vierges
                        ___pawn.skills = new Pawn_SkillTracker(___pawn);
                        ___pawn.needs  = new Pawn_NeedsTracker(___pawn);

                        //Effacement des relations
                        ___pawn.relations = new Pawn_RelationsTracker(___pawn);

                        //TOuts les SX sont simple minded et ont aucuns autres traits
                        TraitDef td = DefDatabase <TraitDef> .GetNamed("SimpleMindedAndroid", false);

                        Trait t = null;
                        if (td != null)
                        {
                            t = new Trait(td);
                        }

                        ___pawn.story.traits.allTraits.Clear();
                        if (t != null)
                        {
                            ___pawn.story.traits.allTraits.Add(t);
                        }
                        Utils.notifTraitsChanged(___pawn);

                        if (!___pawn.IsAndroidTier())
                        {
                            //Reset du child et adulthood
                            if (!Settings.keepPuppetBackstory && ___pawn.story.childhood != null)
                            {
                                Backstory bs = null;

                                BackstoryDatabase.TryGetWithIdentifier("MercenaryRecruit", out bs);
                                if (bs != null)
                                {
                                    ___pawn.story.childhood = bs;
                                }
                            }

                            ___pawn.story.adulthood = null;
                        }


                        //Reset incapable of
                        Utils.ResetCachedIncapableOf(___pawn);

                        //Définition nouveau nom
                        ___pawn.Name = new NameTriple("", "S" + 0 + "-" + Utils.GCATPP.getNextSXID(0), "");
                        Utils.GCATPP.incNextSXID(0);

                        if (!Utils.preventVX0Thought)
                        {
                            //Ajout du thought de PUPPET
                            for (int i = 0; i < PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonistsAndPrisoners.Count; i++)
                            {
                                Pawn current = PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonistsAndPrisoners[i];
                                current.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(Utils.thoughtDefVX0Puppet, 0), null);
                            }
                        }

                        if (___pawn.IsPrisoner)
                        {
                            if (___pawn.guest != null)
                            {
                                ___pawn.guest.SetGuestStatus(Faction.OfPlayer, false);
                            }
                        }
                        if (___pawn.workSettings == null)
                        {
                            ___pawn.workSettings = new Pawn_WorkSettings(___pawn);
                            ___pawn.workSettings.EnableAndInitializeIfNotAlreadyInitialized();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Message("[ATPP] Pawn_HealthTracker.AddHediffPostfix " + ex.Message + " " + ex.StackTrace);
                }
            }
示例#23
0
 private static void RemoveTrait(Pawn pawn, TraitDef trait)
 {
     pawn.story.traits.allTraits.RemoveAll(t => t.def == trait);
 }
示例#24
0
 public static bool IsTraitDisabled([NotNull] TraitDef traitDef) => TraitDefs.Contains(traitDef.defName);
示例#25
0
        //[DebuggerHidden]
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(TargetIndex.A);
            this.FailOnDestroyedOrNull(TargetIndex.B);
            this.FailOnForbidden(TargetIndex.B);
            yield return(Toils_Reserve.Reserve(TargetIndex.A));

            yield return(Toils_Reserve.Reserve(TargetIndex.B));

            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.Touch));

            yield return(new Toil {
                initAction = delegate {
                    pawn.jobs.curJob.count = 1;
                }
            });

            yield return(Toils_Haul.StartCarryThing(TargetIndex.B));

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            yield return(Toils_General.WaitWith(TargetIndex.A, enslaveDuration, true));

            yield return(new Toil {
                initAction = delegate {
                    Thing slaveCollar = null;
                    pawn.carryTracker.TryDropCarriedThing(pawn.PositionHeld, ThingPlaceMode.Direct, out slaveCollar, null);
                    if (slaveCollar != null)
                    {
                        var collar = (Apparel)slaveCollar;
                        // Do enslave attempt
                        bool success = true;

                        if (!Victim.jobs.curDriver.asleep &&
                            !Victim.story.traits.HasTrait(TraitDef.Named("Wimp")) &&
                            !Victim.InMentalState &&
                            !Victim.Downed
                            )
                        {
                            if (Victim.story.traits.HasTrait(TraitDefOf.Nerves) &&
                                (Victim.story.traits.GetTrait(TraitDefOf.Nerves).Degree == -2 && Rand.Value > 0.66f) ||
                                Victim.needs.mood.CurInstantLevelPercentage < Rand.Range(0f, 0.33f)
                                )
                            {
                                success = false;
                            }
                        }
                        if (success)
                        {
                            Log.Message("Enslaved " + Victim.Name.ToStringShort);                             //Z- NameStringShort -> Name.ToStringShort
                            SlaveUtility.EnslavePawn(Victim, collar);
                            if (slaveCollar.Stuff.stuffProps.categories.Contains(StuffCategoryDefOf.Metallic) && !Victim.health.hediffSet.HasHediff(SS_HediffDefOf.SlaveMemory))
                            {
                                SlaveUtility.GetEnslavedHediff(Victim).TakeWillpowerHit(1.5f);
                            }
                            Messages.Message("EnslavedPrisonerSuccess".Translate(pawn.Name.ToStringShort, Victim.Name.ToStringShort), MessageTypeDefOf.PositiveEvent);                             //Z- NameStringShort -> Name.ToStringShort
                            AddEndCondition(() => JobCondition.Succeeded);
                        }
                        else
                        {
                            Victim.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk, "ReasonFailedEnslave".Translate(pawn.Name.ToStringShort, Victim.Name.ToStringShort));                             //Z- NameStringShort -> Name.ToStringShort
                            AddEndCondition(() => JobCondition.Incompletable);
                        }
                    }
                    else
                    {
                        AddEndCondition(() => JobCondition.Incompletable);
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });
        }
示例#26
0
 public static bool HasTrait(this Pawn pawn, TraitDef trait) => pawn?.story?.traits?.HasTrait(trait) ?? false;
示例#27
0
        public override void DoEffect(Pawn user)
        {
            if (parent.def != null && user.story.traits.HasTrait(TorannMagicDefOf.Gifted))
            {
                Trait giftedTrait = new Trait();
                if (parent.def.defName == "BookOfInnerFire" || parent.def.defName == "Torn_BookOfInnerFire")
                {
                    FixTrait(user, user.story.traits.allTraits);
                    user.story.traits.GainTrait(new Trait(TraitDef.Named("InnerFire"), 4, false));
                    if (parent.def.defName == "BookOfInnerFire")
                    {
                        HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f);
                    }
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "BookOfHeartOfFrost" || parent.def.defName == "Torn_BookOfHeartOfFrost")
                {
                    FixTrait(user, user.story.traits.allTraits);
                    user.story.traits.GainTrait(new Trait(TraitDef.Named("HeartOfFrost"), 4, false));
                    if (parent.def.defName == "BookOfHeartOfFrost")
                    {
                        HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f);
                    }
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "BookOfStormBorn" || parent.def.defName == "Torn_BookOfStormBorn")
                {
                    FixTrait(user, user.story.traits.allTraits);
                    user.story.traits.GainTrait(new Trait(TraitDef.Named("StormBorn"), 4, false));
                    if (parent.def.defName == "BookOfStormBorn")
                    {
                        HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f);
                    }
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "BookOfArcanist" || parent.def.defName == "Torn_BookOfArcanist")
                {
                    FixTrait(user, user.story.traits.allTraits);
                    user.story.traits.GainTrait(new Trait(TraitDef.Named("Arcanist"), 4, false));
                    if (parent.def.defName == "BookOfArcanist")
                    {
                        HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f);
                    }
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "BookOfValiant" || parent.def.defName == "Torn_BookOfValiant")
                {
                    FixTrait(user, user.story.traits.allTraits);
                    user.story.traits.GainTrait(new Trait(TraitDef.Named("Paladin"), 4, false));
                    if (parent.def.defName == "BookOfValiant")
                    {
                        HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f);
                    }
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "BookOfSummoner" || parent.def.defName == "Torn_BookOfSummoner")
                {
                    FixTrait(user, user.story.traits.allTraits);
                    user.story.traits.GainTrait(new Trait(TraitDef.Named("Summoner"), 4, false));
                    if (parent.def.defName == "BookOfSummoner")
                    {
                        HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f);
                    }
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "BookOfDruid" || parent.def.defName == "Torn_BookOfNature")
                {
                    FixTrait(user, user.story.traits.allTraits);
                    user.story.traits.GainTrait(new Trait(TraitDef.Named("Druid"), 4, false));
                    if (parent.def.defName == "BookOfDruid")
                    {
                        HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f);
                    }
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "BookOfNecromancer" || parent.def.defName == "Torn_BookOfUndead")
                {
                    FixTrait(user, user.story.traits.allTraits);
                    user.story.traits.GainTrait(new Trait(TraitDef.Named("Necromancer"), 4, false));
                    if (parent.def.defName == "BookOfNecromancer")
                    {
                        HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f);
                    }
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "BookOfPriest" || parent.def.defName == "Torn_BookOfPriest")
                {
                    FixTrait(user, user.story.traits.allTraits);
                    FixPriestSkills(user);
                    user.story.traits.GainTrait(new Trait(TraitDef.Named("Priest"), 4, false));
                    if (parent.def.defName == "BookOfPriest")
                    {
                        HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f);
                    }
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "BookOfBard" || parent.def.defName == "Torn_BookOfBard")
                {
                    if (!user.story.WorkTagIsDisabled(WorkTags.Social))
                    {
                        FixTrait(user, user.story.traits.allTraits);
                        FixBardSkills(user);
                        user.story.traits.GainTrait(new Trait(TraitDef.Named("TM_Bard"), 0, false));
                        if (parent.def.defName == "BookOfBard")
                        {
                            HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f);
                        }
                        this.parent.Destroy(DestroyMode.Vanish);
                    }
                    else
                    {
                        Messages.Message("TM_NotSocialCapable".Translate(new object[]
                        {
                            user.LabelShort
                        }), MessageTypeDefOf.RejectInput);
                    }
                }
                else if (parent.def.defName == "BookOfQuestion")
                {
                    FixTrait(user, user.story.traits.allTraits);
                    int rnd = Mathf.RoundToInt(Rand.Range(0, 10));
                    switch (rnd)
                    {
                    case 1:
                        user.story.traits.GainTrait(new Trait(TraitDef.Named("Necromancer"), 4, false));
                        break;

                    case 2:
                        user.story.traits.GainTrait(new Trait(TraitDef.Named("Druid"), 4, false));
                        break;

                    case 3:
                        user.story.traits.GainTrait(new Trait(TraitDef.Named("Summoner"), 4, false));
                        break;

                    case 4:
                        user.story.traits.GainTrait(new Trait(TraitDef.Named("InnerFire"), 4, false));
                        break;

                    case 5:
                        user.story.traits.GainTrait(new Trait(TraitDef.Named("HeartOfFrost"), 4, false));
                        break;

                    case 6:
                        user.story.traits.GainTrait(new Trait(TraitDef.Named("StormBorn"), 4, false));
                        break;

                    case 7:
                        user.story.traits.GainTrait(new Trait(TraitDef.Named("Arcanist"), 4, false));
                        break;

                    case 8:
                        user.story.traits.GainTrait(new Trait(TraitDef.Named("Priest"), 4, false));
                        break;

                    case 9:
                        user.story.traits.GainTrait(new Trait(TraitDef.Named("TM_Bard"), 0, false));
                        break;

                    case 10:
                        user.story.traits.GainTrait(new Trait(TraitDef.Named("Paladin"), 4, false));
                        break;
                    }
                    //HealthUtility.AdjustSeverity(user, TorannMagicDefOf.TM_Uncertainty, 0.2f);
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else
                {
                    Messages.Message("NotArcaneBook".Translate(), MessageTypeDefOf.RejectInput);
                }
            }
            else
            {
                Messages.Message("NotGiftedPawn".Translate(new object[]
                {
                    user.LabelShort
                }), MessageTypeDefOf.RejectInput);
            }
        }
        //
        // Methods
        //
        public void DoBirthSpawn(Pawn mother, Pawn father, float chance_successful = 1.0f)
        {
            if (mother == null)
            {
                Log.Error("No mother defined");
                return;
            }
            if (father == null)
            {
                Log.Warning("No father defined");
            }

            float birthing_quality = mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("GivingBirth")).TryGetComp <HediffComp_TendDuration> ().tendQuality;

            mother.health.AddHediff(HediffDef.Named("PostPregnancy"), null, null);
            mother.health.AddHediff(HediffDef.Named("Lactating"), ChildrenUtility.GetPawnBodyPart(pawn, "Torso"), null);

            int num = (mother.RaceProps.litterSizeCurve == null) ? 1 : Mathf.RoundToInt(Rand.ByCurve(mother.RaceProps.litterSizeCurve, 300));

            if (num < 1)
            {
                num = 1;
            }

            // Make sure the pawn looks like mommy and daddy
            float skin_whiteness = Rand.Range(0, 1);
            // Pool of "genetic traits" the baby can inherit
            List <Trait> traitpool = new List <Trait>();

            if (mother.RaceProps.Humanlike)
            {
                // Add mom's traits to the pool
                foreach (Trait momtrait in mother.story.traits.allTraits)
                {
                    traitpool.Add(momtrait);
                }
                if (father != null)
                {
                    // Add dad's traits to the pool
                    foreach (Trait dadtrait in father.story.traits.allTraits)
                    {
                        traitpool.Add(dadtrait);
                    }
                    // Blend skin colour between mom and dad
                    skin_whiteness = Rand.Range(mother.story.melanin, father.story.melanin);
                }
                else
                {
                    // If dad doesn't exist, just use mom's skin colour
                    skin_whiteness = mother.story.melanin;
                }

                // Clear out any traits that aren't genetic from the list
                if (traitpool.Count > 0)
                {
                    foreach (Trait trait in traitpool.ToArray())
                    {
                        bool is_genetic = false;
                        foreach (TraitDef gentrait in genetic_traits)
                        {
                            if (gentrait.defName == trait.def.defName)
                            {
                                is_genetic = true;
                            }
                        }
                        if (!is_genetic)
                        {
                            traitpool.Remove(trait);
                        }
                    }
                }
            }

            // Todo: Perhaps add a way to pass on the parent's body build
            // Best way to do it might be to represent thin/fat/normal/hulk
            // as a pair of two values, strength and weight
            // For example, if the mother has an average body type, she would
            // have a strength of .5f and a weight of .5f. A fat pawn would have
            // a strength of .5f and a weight of .75f. A thin pawn would have a
            // strength of .25f and a weight of .25f. A hulk pawn would have
            // strength of .75f and weight of .75f
            //List<float> strength_pool = new List<float>();
            //List<float> weight_pool = new List<float>();

            //// Get mother and fathers info here if possible

            //float avg_strength = strength_pool.Average();
            //float avg_weight = weight_pool.Average();

            // Surname passing
            string last_name = null;

            if (mother.RaceProps.Humanlike)
            {
                if (father == null)
                {
                    last_name = NameTriple.FromString(mother.Name.ToStringFull).Last;
                }
                else
                {
                    last_name = NameTriple.FromString(father.Name.ToStringFull).Last;
                }
                //Log.Message ("Debug: Newborn is born to the " + last_name + " family.");
            }

            //PawnGenerationRequest request = new PawnGenerationRequest (mother.kindDef, mother.Faction, PawnGenerationContext.NonPlayer, mother.Map, false, true, false, false, true, false, 1, false, true, true, null, 0, 0, null, skin_whiteness, last_name);
            PawnGenerationRequest request = new PawnGenerationRequest(mother.kindDef, mother.Faction, PawnGenerationContext.NonPlayer, mother.Map.Tile, false, true, false, false, false, false, 1, false, true, true, false, false, null, 0, 0, null, skin_whiteness, last_name);

            Pawn baby = null;

            for (int i = 0; i < num; i++)
            {
                baby = PawnGenerator.GeneratePawn(request);
                if (PawnUtility.TrySpawnHatchedOrBornPawn(baby, mother))
                {
                    if (baby.playerSettings != null && mother.playerSettings != null)
                    {
                        baby.playerSettings.AreaRestriction = mother.playerSettings.AreaRestriction;
                    }
                    if (baby.RaceProps.IsFlesh)
                    {
                        baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, mother);
                        if (father != null)
                        {
                            baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, father);
                        }
                    }

                    // Good until otherwise proven bad
                    bool successful_birth = true;
                    var  disabledBaby     = BackstoryDatabase.allBackstories ["CustomBackstory_NA_Childhood_Disabled"];
                    if (disabledBaby != null)
                    {
                        baby.story.childhood = disabledBaby;
                    }
                    else
                    {
                        Log.Error("Couldn't find the required Backstory: CustomBackstory_NA_Childhood_Disabled!");
                        baby.story.childhood = null;
                    }
                    baby.story.adulthood = null;
                    baby.workSettings.Disable(WorkTypeDefOf.Hunting);                      //hushes up the "has no ranged weapon" alert
                    // remove all traits
                    baby.story.traits.allTraits.Clear();

                    // Add some genetic traits
                    if (traitpool.Count > 0)
                    {
                        for (int j = 0; j != 2; j++)
                        {
                            Trait gentrait = traitpool.RandomElement();
                            if (!baby.story.traits.HasTrait(gentrait.def))
                            {
                                baby.story.traits.GainTrait(gentrait);
                            }
                        }
                    }
                    // Move the baby in front of the mother, rather than on top
                    if (mother.CurrentBed() != null)
                    {
                        baby.Position = baby.Position + new IntVec3(0, 0, 1).RotatedBy(mother.CurrentBed().Rotation);
                    }
                    // else {
                    //	 baby.Position = baby.Position + new IntVec3 (0, 0, 1).RotatedBy (mother.Rotation);
                    // }

                    // The baby died from bad chance of success
                    if (Rand.Value > chance_successful || chance_successful == 0)
                    {
                        successful_birth = false;
                    }

                    // Birth defects via drugs or alcohol
                    if (mother.health.hediffSet.HasHediff(HediffDef.Named("BirthDefectTracker")))
                    {
                        Hediff_BirthDefectTracker tracker = (Hediff_BirthDefectTracker)mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("BirthDefectTracker"));
                        // The baby died in utero from chemical affect
                        if (tracker.stillbirth)
                        {
                            successful_birth = false;
                        }
                        // The baby lived! So far, anyways
                        else
                        {
                            // Should the baby get fetal alcohol syndrome?
                            if (tracker.fetal_alcohol)
                            {
                                baby.health.AddHediff(HediffDef.Named("FetalAlcoholSyndrome"));
                            }
                            // If the mother got high while pregnant, crongrats retard
                            // now your baby is addicted to crack
                            if (tracker.drug_addictions.Count > 0)
                            {
                                foreach (HediffDef addiction in tracker.drug_addictions)
                                {
                                    baby.health.AddHediff(addiction, null, null);
                                }
                            }
                        }
                    }

                    // Inbred?
                    if (father != null && mother.relations.FamilyByBlood.Contains <Pawn> (father))
                    {
                        // 50% chance to get a birth defect from inbreeding
                        if (Rand.Range(0, 1) == 1)
                        {
                            GiveRandomBirthDefect(baby);
                            if (baby.health.hediffSet.HasHediff(HediffDef.Named("DefectStillborn")))
                            {
                                successful_birth = false;
                            }
                        }
                    }



                    // The baby was born! Yay!
                    if (successful_birth == true)
                    {
                        // Give father a happy memory if the birth was successful and he's not dead
                        if (father != null && !father.health.Dead)
                        {
                            // The father is happy the baby was born
                            father.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("PartnerGaveBirth"));
                        }

                        // Send a message that the baby was born
                        if (mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("HumanPregnancy")).Visible&& PawnUtility.ShouldSendNotificationAbout(mother))
                        {
                            //Messages.Message ("MessageGaveBirth".Translate (new object[] {mother.LabelIndefinite ()}).CapitalizeFirst (), mother, MessageSound.Benefit);
                            Find.LetterStack.ReceiveLetter("LabelGaveBirth".Translate(new object[] { baby.LabelIndefinite() }), "MessageHumanBirth".Translate(new object[] {
                                mother.LabelIndefinite(),
                                baby.Name.ToStringShort
                            }), LetterDefOf.Good, baby, null);
                        }

                        // Try to give PPD. If not, give "New baby" thought
                        float chance = 0.2f;
                        if (mother.story.traits.HasTrait(TraitDefOf.Psychopath))
                        {
                            chance -= 1;
                        }
                        if (mother.story.traits.HasTrait(TraitDef.Named("Nerves")))
                        {
                            chance -= 0.2f * mother.story.traits.GetTrait(TraitDef.Named("Nerves")).Degree;
                        }
                        else if (mother.story.traits.HasTrait(TraitDef.Named("NaturalMood")))
                        {
                            if (mother.story.traits.GetTrait(TraitDef.Named("NaturalMood")).Degree == 2)
                            {
                                chance -= 1;
                            }
                            if (mother.story.traits.GetTrait(TraitDef.Named("NaturalMood")).Degree == -2)
                            {
                                chance += 0.6f;
                            }
                            // For some reason this is broken

                            /*} else if (mother.story.traits.HasTrait (TraitDef.Named ("Neurotic"))) {
                             * if (mother.story.traits.GetTrait (TraitDef.Named ("Neurotic")).Degree == 1) {
                             *      chance += 0.2f;
                             * } else
                             *      chance += 0.4f;*/
                        }

                        // Because for whatever dumb reason the Math class doesn't have a Clamp method
                        if (chance < 0)
                        {
                            chance = 0;
                        }

                        if (chance > 1)
                        {
                            chance = 1;
                        }
                        Log.Message("Debugging: Chance of PPD is " + chance * 100 + "%");


                        // Try to give PPD
                        if (Rand.Value < chance)
                        {
                            mother.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("PostPartumDepression"), null);
                            bool verybad = false;
                            if (mother.story.traits.HasTrait(TraitDef.Named("NaturalMood")))
                            {
                                if (mother.story.traits.GetTrait(TraitDef.Named("NaturalMood")).Degree == -2)
                                {
                                    verybad = true;
                                }
                            }
                            else if (mother.story.traits.HasTrait(TraitDef.Named("Neurotic")))
                            {
                                if (mother.story.traits.GetTrait(TraitDef.Named("Neurotic")).Degree == 2)
                                {
                                    verybad = true;
                                }
                            }
                            // This pawn gets an exceptionally bad case of PPD
                            if (verybad)
                            {
                                foreach (Thought_Memory thought in mother.needs.mood.thoughts.memories.Memories)
                                {
                                    if (thought.def.defName == "PostPartumDepression")
                                    {
                                        thought.SetForcedStage(thought.CurStageIndex + 1);
                                    }
                                }
                            }
                        }
                        else
                        {
                            // If we didn't get PPD, then the pawn gets a mood buff
                            if (mother.health.hediffSet.HasHediff(HediffDef.Named("GaveBirthFlag")) == false)
                            {
                                mother.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("IGaveBirthFirstTime"));
                            }
                            else
                            {
                                mother.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("IGaveBirth"));
                            }
                        }
                    }
                    else
                    {
                        bool aborted = false;
                        if (chance_successful < 0f)
                        {
                            aborted = true;
                        }
                        if (baby != null)
                        {
                            Miscarry(baby, aborted);
                        }
                    }
                }
                else
                {
                    Find.WorldPawns.PassToWorld(baby, PawnDiscardDecideMode.Discard);
                }
            }
            // Post birth
            if (mother.Spawned)
            {
                // Spawn guck
                FilthMaker.MakeFilth(mother.Position, mother.Map, ThingDefOf.FilthAmnioticFluid, mother.LabelIndefinite(), 5);
                if (mother.caller != null)
                {
                    mother.caller.DoCall();
                }
                if (baby != null)
                {
                    if (baby.caller != null)
                    {
                        baby.caller.DoCall();
                    }
                }

                Log.Message("Birth quality = " + birthing_quality);
                // Possible tearing from pregnancy
                if (birthing_quality < 0.75f)
                {
                    if (birthing_quality < Rand.Value)
                    {
                        // Add a tear from giving birth
                        if (birthing_quality < Rand.Value)
                        {
                            mother.health.AddHediff(HediffDef.Named("PregnancyTearMajor"), ChildrenUtility.GetPawnBodyPart(mother, "Torso"), null);
                        }
                        else
                        {
                            mother.health.AddHediff(HediffDef.Named("PregnancyTear"), ChildrenUtility.GetPawnBodyPart(mother, "Torso"), null);
                        }
                    }
                }
            }
            pawn.health.RemoveHediff(pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("GivingBirth")));
            pawn.health.RemoveHediff(this);
        }
        protected override ThoughtState CurrentStateInternal(Pawn pawn)
        {
            if (!pawn.Spawned || !pawn.RaceProps.Humanlike)
            {
                return(false);
            }
            if (pawn.story.traits.HasTrait(TorannMagicDefOf.Undead) || pawn.story.traits.HasTrait(TorannMagicDefOf.Necromancer) || pawn.story.traits.HasTrait(TorannMagicDefOf.Lich) || pawn.story.traits.HasTrait(TraitDefOf.Psychopath) || pawn.story.traits.HasTrait(TraitDefOf.Bloodlust) || pawn.story.traits.HasTrait(TraitDef.Named("M*******t")))
            {
                return(false);
            }
            List <Pawn> mapPawns = pawn.Map.mapPawns.AllPawnsSpawned;

            for (int i = 0; i < mapPawns.Count; i++)
            {
                if (mapPawns[i].Spawned && mapPawns[i].RaceProps.Humanlike)
                {
                    if (mapPawns[i].story.traits.HasTrait(TorannMagicDefOf.Undead))
                    {
                        if (pawn.Position.InHorDistOf(mapPawns[i].Position, radius))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def         = this.def;
            int      raisedPawns = 0;

            Pawn pawn   = this.launcher as Pawn;
            Pawn victim = hitThing as Pawn;
            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();

            pwr = comp.MagicData.MagicPowerSkill_RaiseUndead.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_RaiseUndead_pwr");
            ver = comp.MagicData.MagicPowerSkill_RaiseUndead.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_RaiseUndead_ver");

            Thing corpseThing = null;

            IntVec3 curCell;
            IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(base.Position, this.def.projectile.explosionRadius, true);

            foreach (var cell in targets)
            {
                curCell = cell;

                TM_MoteMaker.ThrowPoisonMote(curCell.ToVector3Shifted(), map, .3f);
                if (curCell.InBounds(map))
                {
                    Corpse       corpse = null;
                    List <Thing> thingList;
                    thingList = curCell.GetThingList(map);
                    int z = 0;
                    while (z < thingList.Count)
                    {
                        corpseThing = thingList[z];
                        if (corpseThing != null)
                        {
                            bool validator = corpseThing is Corpse;
                            if (validator)
                            {
                                corpse = corpseThing as Corpse;
                                Pawn         undeadPawn   = corpse.InnerPawn;
                                CompRottable compRottable = corpse.GetComp <CompRottable>();
                                float        rotStage     = 0;
                                if (compRottable != null && compRottable.Stage == RotStage.Dessicated)
                                {
                                    rotStage = 1f;
                                }
                                if (compRottable != null)
                                {
                                    rotStage += compRottable.RotProgressPct;
                                }
                                bool flag_SL = false;
                                if (undeadPawn.def.defName == "SL_Runner" || undeadPawn.def.defName == "SL_Peon" || undeadPawn.def.defName == "SL_Archer" || undeadPawn.def.defName == "SL_Hero")
                                {
                                    PawnGenerationRequest pgr = new PawnGenerationRequest(PawnKindDef.Named("Tribesperson"), pawn.Faction, PawnGenerationContext.NonPlayer, -1, true, false, false, false, false, true, 0, false, false, false, false, false, false, false, false, 0, null, 0);
                                    Pawn newUndeadPawn        = PawnGenerator.GeneratePawn(pgr);
                                    GenSpawn.Spawn(newUndeadPawn, corpse.Position, corpse.Map, WipeMode.Vanish);
                                    corpse.Strip();
                                    corpse.Destroy(DestroyMode.Vanish);
                                    rotStage   = 1f;
                                    flag_SL    = true;
                                    undeadPawn = newUndeadPawn;
                                }
                                if (!undeadPawn.def.defName.Contains("ROM_") && undeadPawn.RaceProps.IsFlesh && (undeadPawn.Dead || flag_SL) && undeadPawn.def.thingClass.FullName != "TorannMagic.TMPawnSummoned")
                                {
                                    bool wasVampire = false;

                                    IEnumerable <ThingDef> enumerable = from hd in DefDatabase <HediffDef> .AllDefs
                                                                        where def.defName == "ROM_Vampirism"
                                                                        select def;
                                    if (enumerable.Count() > 0)
                                    {
                                        bool hasVampHediff = undeadPawn.health.hediffSet.HasHediff(HediffDef.Named("ROM_Vampirism")) || undeadPawn.health.hediffSet.HasHediff(HediffDef.Named("ROM_GhoulHediff"));
                                        if (hasVampHediff)
                                        {
                                            wasVampire = true;
                                        }
                                    }

                                    if (!wasVampire)
                                    {
                                        undeadPawn.SetFaction(pawn.Faction);
                                        if (undeadPawn.Dead)
                                        {
                                            ResurrectionUtility.Resurrect(undeadPawn);
                                        }
                                        raisedPawns++;
                                        comp.supportedUndead.Add(undeadPawn);
                                        if (undeadPawn.kindDef != null && undeadPawn.kindDef.RaceProps != null && undeadPawn.kindDef.RaceProps.Animal)
                                        {
                                            RemoveHediffsAddictionsAndPermanentInjuries(undeadPawn);
                                            HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, -4f);
                                            HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, .5f + ver.level);
                                            undeadPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_UndeadAnimalHD).TryGetComp <HediffComp_Undead>().linkedPawn = pawn;
                                            HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), -2f);
                                            HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), rotStage);

                                            if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Tameness).Accepted)
                                            {
                                                while (!undeadPawn.training.HasLearned(TrainableDefOf.Tameness))
                                                {
                                                    undeadPawn.training.Train(TrainableDefOf.Tameness, pawn);
                                                }
                                            }

                                            if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Obedience).Accepted)
                                            {
                                                while (!undeadPawn.training.HasLearned(TrainableDefOf.Obedience))
                                                {
                                                    undeadPawn.training.Train(TrainableDefOf.Obedience, pawn);
                                                }
                                            }

                                            if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Release).Accepted)
                                            {
                                                while (!undeadPawn.training.HasLearned(TrainableDefOf.Release))
                                                {
                                                    undeadPawn.training.Train(TrainableDefOf.Release, pawn);
                                                }
                                            }

                                            if (undeadPawn.training.CanAssignToTrain(TorannMagicDefOf.Haul).Accepted)
                                            {
                                                while (!undeadPawn.training.HasLearned(TorannMagicDefOf.Haul))
                                                {
                                                    undeadPawn.training.Train(TorannMagicDefOf.Haul, pawn);
                                                }
                                            }

                                            if (undeadPawn.training.CanAssignToTrain(TorannMagicDefOf.Rescue).Accepted)
                                            {
                                                while (!undeadPawn.training.HasLearned(TorannMagicDefOf.Rescue))
                                                {
                                                    undeadPawn.training.Train(TorannMagicDefOf.Rescue, pawn);
                                                }
                                            }
                                            undeadPawn.playerSettings.medCare = MedicalCareCategory.NoMeds;
                                            undeadPawn.def.tradeability       = Tradeability.None;
                                        }
                                        else if (undeadPawn.story != null && undeadPawn.story.traits != null && undeadPawn.needs != null && undeadPawn.playerSettings != null)
                                        {
                                            CompAbilityUserMagic compMagic = undeadPawn.GetComp <CompAbilityUserMagic>();
                                            if (compMagic != null && TM_Calc.IsMagicUser(undeadPawn)) //(compMagic.IsMagicUser && !undeadPawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) ||
                                            {
                                                compMagic.Initialize();
                                                compMagic.RemovePowers(true);
                                            }
                                            CompAbilityUserMight compMight = undeadPawn.GetComp <CompAbilityUserMight>();
                                            if (compMight != null && TM_Calc.IsMightUser(undeadPawn)) //compMight.IsMightUser ||
                                            {
                                                compMight.Initialize();
                                                compMight.RemovePowers(true);
                                            }
                                            RemoveHediffsAddictionsAndPermanentInjuries(undeadPawn);
                                            RemovePsylinkAbilities(undeadPawn);
                                            HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, -4f);
                                            HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, .5f + ver.level);
                                            undeadPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_UndeadHD).TryGetComp <HediffComp_Undead>().linkedPawn = pawn;
                                            HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), -2f);
                                            HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), rotStage);
                                            RedoSkills(undeadPawn, pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_LichHD")));
                                            if (undeadPawn.story.traits.HasTrait(TorannMagicDefOf.ChaosMage))
                                            {
                                                compMagic.RemovePawnAbility(TorannMagicDefOf.TM_ChaosTradition);
                                            }
                                            RemoveTraits(undeadPawn, undeadPawn.story.traits.allTraits);
                                            undeadPawn.story.traits.GainTrait(new Trait(TraitDef.Named("Undead"), 0, false));
                                            undeadPawn.story.traits.GainTrait(new Trait(TraitDef.Named("Psychopath"), 0, false));
                                            undeadPawn.needs.AddOrRemoveNeedsAsAppropriate();
                                            RemoveClassHediff(undeadPawn);
                                            if (undeadPawn.health.hediffSet.HasHediff(HediffDef.Named("DeathAcidifier")))
                                            {
                                                Hediff hd = undeadPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("DeathAcidifier"));
                                                undeadPawn.health.RemoveHediff(hd);
                                            }
                                            //Color undeadColor = new Color(.2f, .4f, 0);
                                            //undeadPawn.story.hairColor = undeadColor;
                                            //CompAbilityUserMagic undeadComp = undeadPawn.GetComp<CompAbilityUserMagic>();
                                            //if (undeadComp.IsMagicUser)
                                            //{
                                            //    undeadComp.ClearPowers();
                                            //}

                                            List <SkillRecord> skills = undeadPawn.skills.skills;
                                            for (int j = 0; j < skills.Count; j++)
                                            {
                                                skills[j].passion = Passion.None;
                                            }
                                            undeadPawn.playerSettings.hostilityResponse = HostilityResponseMode.Attack;
                                            undeadPawn.playerSettings.medCare           = MedicalCareCategory.NoMeds;
                                            for (int h = 0; h < 24; h++)
                                            {
                                                undeadPawn.timetable.SetAssignment(h, TimeAssignmentDefOf.Work);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Messages.Message("Vampiric powers have prevented undead reanimation of " + undeadPawn.LabelShort, MessageTypeDefOf.RejectInput);
                                    }
                                }
                            }
                            else if (corpseThing is Pawn)
                            {
                                Pawn undeadPawn = corpseThing as Pawn;
                                if (undeadPawn != pawn && !TM_Calc.IsNecromancer(undeadPawn) && TM_Calc.IsUndead(corpseThing as Pawn))
                                {
                                    RemoveHediffsAddictionsAndPermanentInjuries(undeadPawn);
                                    TM_MoteMaker.ThrowPoisonMote(curCell.ToVector3Shifted(), map, .6f);
                                }
                            }
                        }
                        z++;
                    }
                }
                if (raisedPawns > pwr.level + 1)
                {
                    break;
                }
            }
        }
 public static bool CanGetTrait(TraitDef trait, ThingDef race) =>
 !traitRestrictionDict.TryGetValue(key: trait, value: out List <ThingDef_AlienRace> races) &&
 !((race as ThingDef_AlienRace)?.alienRace.raceRestriction.onlyGetRaceRestrictedTraits ?? false) ||
 (races?.Contains(item: race as ThingDef_AlienRace) ?? false) ||
 traitWhiteDict.TryGetValue(key: trait, value: out races) && (races?.Contains(item: race as ThingDef_AlienRace) ?? false);
示例#32
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def         = this.def;
            int      raisedPawns = 0;

            Pawn pawn   = this.launcher as Pawn;
            Pawn victim = hitThing as Pawn;
            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();

            pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_RaiseUndead.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_RaiseUndead_pwr");
            ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_RaiseUndead.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_RaiseUndead_ver");

            Thing corpseThing = null;

            IntVec3 curCell;
            IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(base.Position, this.def.projectile.explosionRadius, true);

            for (int i = 0; i < targets.Count(); i++)
            {
                curCell = targets.ToArray <IntVec3>()[i];

                TM_MoteMaker.ThrowPoisonMote(curCell.ToVector3Shifted(), map, .3f);
                if (curCell.InBounds(map) && curCell.IsValid)
                {
                    Corpse       corpse = null;
                    List <Thing> thingList;
                    thingList = curCell.GetThingList(map);
                    int z = 0;
                    while (z < thingList.Count)
                    {
                        corpseThing = thingList[z];
                        if (corpseThing != null)
                        {
                            bool validator = corpseThing is Corpse;
                            if (validator)
                            {
                                corpse = corpseThing as Corpse;
                                Pawn undeadPawn    = corpse.InnerPawn;
                                Pawn newUndeadPawn = new Pawn();

                                if (undeadPawn.RaceProps.IsFlesh && undeadPawn.Dead && undeadPawn.def.thingClass.FullName != "TorannMagic.TMPawnSummoned")
                                {
                                    undeadPawn.SetFaction(pawn.Faction);
                                    ResurrectionUtility.Resurrect(undeadPawn);
                                    raisedPawns++;
                                    if (!undeadPawn.kindDef.RaceProps.Animal && undeadPawn.kindDef.RaceProps.Humanlike)
                                    {
                                        HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, -4f);
                                        HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, .5f + ver.level);
                                        RedoSkills(undeadPawn);
                                        RemoveTraits(undeadPawn, undeadPawn.story.traits.allTraits);
                                        undeadPawn.story.traits.GainTrait(new Trait(TraitDef.Named("Undead"), 0, false));
                                        undeadPawn.story.traits.GainTrait(new Trait(TraitDef.Named("Psychopath"), 0, false));
                                        undeadPawn.needs.AddOrRemoveNeedsAsAppropriate();
                                        Color undeadColor = new Color(.2f, .4f, 0);
                                        undeadPawn.story.hairColor = undeadColor;
                                        CompAbilityUserMagic undeadComp = undeadPawn.GetComp <CompAbilityUserMagic>();
                                        if (undeadComp.IsMagicUser)
                                        {
                                            undeadComp.ClearPowers();
                                        }

                                        List <SkillRecord> skills = undeadPawn.skills.skills;
                                        for (int j = 0; j < skills.Count; j++)
                                        {
                                            skills[j].passion = Passion.None;
                                        }
                                        undeadPawn.playerSettings.hostilityResponse = HostilityResponseMode.Attack;
                                        undeadPawn.playerSettings.medCare           = MedicalCareCategory.NoMeds;
                                        for (int h = 0; h < 24; h++)
                                        {
                                            undeadPawn.timetable.SetAssignment(h, TimeAssignmentDefOf.Work);
                                        }
                                    }
                                    if (undeadPawn.kindDef.RaceProps.Animal)
                                    {
                                        HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, -4f);
                                        HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, .5f + ver.level);

                                        if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Tameness).Accepted)
                                        {
                                            while (!undeadPawn.training.HasLearned(TrainableDefOf.Tameness))
                                            {
                                                undeadPawn.training.Train(TrainableDefOf.Tameness, pawn);
                                            }
                                        }

                                        if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Obedience).Accepted)
                                        {
                                            while (!undeadPawn.training.HasLearned(TrainableDefOf.Obedience))
                                            {
                                                undeadPawn.training.Train(TrainableDefOf.Obedience, pawn);
                                            }
                                        }

                                        if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Release).Accepted)
                                        {
                                            while (!undeadPawn.training.HasLearned(TrainableDefOf.Release))
                                            {
                                                undeadPawn.training.Train(TrainableDefOf.Release, pawn);
                                            }
                                        }

                                        if (undeadPawn.training.CanAssignToTrain(TorannMagicDefOf.Haul).Accepted)
                                        {
                                            while (!undeadPawn.training.HasLearned(TorannMagicDefOf.Haul))
                                            {
                                                undeadPawn.training.Train(TorannMagicDefOf.Haul, pawn);
                                            }
                                        }

                                        if (undeadPawn.training.CanAssignToTrain(TorannMagicDefOf.Rescue).Accepted)
                                        {
                                            while (!undeadPawn.training.HasLearned(TorannMagicDefOf.Rescue))
                                            {
                                                undeadPawn.training.Train(TorannMagicDefOf.Rescue, pawn);
                                            }
                                        }
                                        undeadPawn.playerSettings.medCare = MedicalCareCategory.NoMeds;
                                        undeadPawn.def.tradeability       = Tradeability.None;
                                    }
                                }
                            }
                        }
                        z++;
                    }
                }
                if (raisedPawns > pwr.level + 1)
                {
                    i = targets.Count();
                }
            }
        }
示例#33
0
        private static Boolean Contains(Pawn pPawnSel, List<TraitDef> lTraitDef)
        {

            TraitDef[] tArray = new TraitDef[lTraitDef.Count];

            lTraitDef.CopyTo(tArray, 0);

            for (var i = 0; i < tArray.Length; i++)
            {
                if (pPawnSel.story.traits.HasTrait(tArray[i]))
                {
                    return true;
                }
            }


            return false;

        }