Ejemplo n.º 1
0
        private static ThingDef GenerateAnimalGenome([NotNull] PawnKindDef mDef)
        {
            var tDef = new ThingDef
            {
                defName                 = GENOME_PREAMBLE + mDef.defName + "_Implicit",
                label                   = LABEL_TTAG.Translate(mDef.Named("MUTATION")),
                description             = GetGenomeDesc(mDef),
                resourceReadoutPriority = ResourceCountPriority.Middle,
                category                = ThingCategory.Item,
                thingClass              = typeof(ThingWithComps),
                thingCategories         = new List <ThingCategoryDef> {
                    PMThingCategoryDefOf.PM_MutationGenome
                },
                graphicData       = GenerateGenomeGraphicData(mDef),
                useHitPoints      = true,
                selectable        = true,
                thingSetMakerTags = new List <string> {
                    GENOME_SET_MAKER_TAG
                },
                altitudeLayer  = AltitudeLayer.Item,
                tickerType     = TickerType.Never,
                rotatable      = false,
                pathCost       = 15,
                drawGUIOverlay = true,
                modContentPack = mDef.modContentPack,
                tradeTags      = new List <string> {
                    GENOME_TRADER_TAGS
                }
            };

            SetGenomeStats(tDef, mDef);
            AddComps(tDef, mDef);

            return(tDef);
        }
Ejemplo n.º 2
0
        public static PawnKindDef DetermineKindDef(int generation)
        {
            PawnKindDef result = PawnKindDef.Named("ROMV_VampireKind");

            if (generation == 1)
            {
                result = PawnKindDef.Named("ROMV_FirstVampireKind");
            }
            else if (generation <= 6)
            {
                result = PawnKindDef.Named("ROMV_AncientVampireKind");
            }
            else if (generation <= 9)
            {
                result = PawnKindDef.Named("ROMV_GreaterVampireKind");
            }
            else if (generation <= 12)
            {
                result = PawnKindDef.Named("ROMV_VampireKind");
            }
            else if (generation <= 14)
            {
                result = PawnKindDef.Named("ROMV_LesserVampireKind");
            }
            else
            {
                result = PawnKindDef.Named("ROMV_ThinbloodVampireKind");
            }
            return(result);
        }
Ejemplo n.º 3
0
        public void BirthBaby()
        {
            //--Log.Message("[RJW]Hediff_InsectEgg::BirthBaby() - Egg of " + parentDef + " in " + pawn.ToString() + " birth!");
            PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDef.Named(parentDef), Faction.OfInsects, PawnGenerationContext.NonPlayer, pawn.Map.Tile, false, true, false, false, false, false, 0, false, true, true, false, false, false, false, null, null, null, null);

            ////--Log.Message("Hediff_GenericPregnancy::DoBirthSpawn( " + mother_name + ", " + father_name + ", " + chance_successful + " ) - spawning baby");
            Pawn baby = PawnGenerator.GeneratePawn(request);

            if (PawnUtility.TrySpawnHatchedOrBornPawn(baby, pawn))
            {
                if (pawn.RaceProps.IsFlesh)
                {
                    if (mother != null)
                    {
                        pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, mother);
                    }
                    if (father != null)
                    {
                        pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, father);
                    }
                }
            }
            else
            {
                Find.WorldPawns.PassToWorld(baby, PawnDiscardDecideMode.Discard);
            }

            if (this.Visible && baby != null)
            {
                Messages.Message("MessageGaveBirth".Translate(new object[] { this.pawn.LabelIndefinite() }).CapitalizeFirst(), baby, MessageTypeDefOf.NeutralEvent);
            }
            pawn.health.RemoveHediff(this);
        }
Ejemplo n.º 4
0
        public void SpawnDarkYoung(IncidentParms parms, IntVec3 vecparms)
        {
            int         iwCount   = 1;
            IntVec3     intVec    = vecparms;
            Map         map       = (Map)parms.target;
            PawnKindDef DarkYoung = PawnKindDef.Named("ROM_DarkYoung");

            if (parms.points <= 200f)
            {
                iwCount = Rand.RangeInclusive(1, 2);
            }
            else if (parms.points <= 400f)
            {
                iwCount = Rand.RangeInclusive(2, 3);
            }
            else if (parms.points <= 1400f)
            {
                iwCount = Rand.RangeInclusive(4, 5);
            }

            for (int i = 0; i < iwCount; i++)
            {
                IntVec3          loc          = CellFinder.RandomClosewalkCellNear(intVec, map, 10);
                Pawn             newThing     = PawnGenerator.GeneratePawn(DarkYoung, null);
                CosmicHorrorPawn newDarkYoung = newThing as CosmicHorrorPawn;
                GenSpawn.Spawn(newDarkYoung, loc, map);
            }
        }
Ejemplo n.º 5
0
        public override void SpawnSetup()
        {
            base.SpawnSetup();
            Pawn pawn = PawnGenerator.GeneratePawn(PawnKindDef.Named("Rimba"), Faction.OfColony);

            GenSpawn.Spawn(pawn, this.Position);
        }
Ejemplo n.º 6
0
        public override void CompTick()
        {
            base.CompTick();
            Pawn pawn = this.parent as Pawn;

            if ((pawn.Map != null) && (pawn.needs.food.CurLevelPercentage < pawn.needs.food.PercentageThreshHungry) && (pawn.Awake() && AlphaAnimalsEvents_Settings.flagFrostmites))
            {
                if (stopdiggingcounter <= 0)
                {
                    PawnKindDef wildman = PawnKindDef.Named("WildMan");
                    Faction     faction = FactionUtility.DefaultFactionFrom(wildman.defaultFactionType);
                    Pawn        newPawn = PawnGenerator.GeneratePawn(wildman, faction);

                    Thing newcorpse = GenSpawn.Spawn(newPawn, pawn.Position, pawn.Map, WipeMode.Vanish);
                    newcorpse.Kill(null, null);
                    newcorpse.SetForbidden(true, false);
                    if (this.effecter == null)
                    {
                        this.effecter = EffecterDefOf.Mine.Spawn();
                    }
                    this.effecter.Trigger(pawn, newcorpse);


                    stopdiggingcounter = 40000;
                }
                stopdiggingcounter--;
            }
        }
Ejemplo n.º 7
0
        public override void Notify_PawnDied()
        {
            Map map = this.parent.pawn.Corpse.Map;

            if (map != null)
            {
                if (naturalDeath)
                {
                    PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDef.Named(Props.turnTo), null, PawnGenerationContext.NonPlayer, -1, false, true, false, false, true, false, 1f, false, true, true, false, false);
                    Pawn pawn = PawnGenerator.GeneratePawn(request);
                    PawnUtility.TrySpawnHatchedOrBornPawn(pawn, this.parent.pawn.Corpse);
                    pawn.Kill(null);
                    this.parent.pawn.Corpse.Destroy();
                }
                else
                {
                    Gender  oldGender             = this.parent.pawn.gender;
                    Faction faction               = Find.FactionManager.FirstFactionOfDef(FactionDefOf.AncientsHostile);
                    PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDef.Named(Props.turnTo), faction, PawnGenerationContext.NonPlayer, -1, false, true, false, false, true, false, 1f, false, true, true, false, false);
                    Pawn pawn = PawnGenerator.GeneratePawn(request);
                    PawnUtility.TrySpawnHatchedOrBornPawn(pawn, this.parent.pawn.Corpse);
                    pawn.gender = oldGender;
                    pawn.mindState.mentalStateHandler.TryStartMentalState(DefDatabase <MentalStateDef> .GetNamed("ManhunterPermanent", true), null, true, false, null, false);
                    for (int i = 0; i < 20; i++)
                    {
                        IntVec3 c;
                        CellFinder.TryFindRandomReachableCellNear(this.parent.pawn.Corpse.Position, map, 2, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out c);
                        FilthMaker.TryMakeFilth(c, this.parent.pawn.Corpse.Map, ThingDefOf.Filth_Blood);
                    }
                    SoundDefOf.Hive_Spawn.PlayOneShot(new TargetInfo(this.parent.pawn.Corpse.Position, map, false));
                    this.parent.pawn.Corpse.Destroy();
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     Does the find.
        /// </summary>
        /// <param name="worker">The worker.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        protected override void DoFind(Pawn worker)
        {
            if (_chosenAnimalToScan == null)
            {
                Log.Error($"calling DoFind on {parent.ThingID} which does not have a chosen animal!");
                return;
            }

            _scratchList.Clear();
            _scratchList.AddRange(_chosenAnimalToScan.GetAllMutationsFrom().Where(m => !DB.StoredMutations.Contains(m)));

            if (_scratchList.Count == 0)
            {
                Log.Warning("unable to find mutation to give!");
                _chosenAnimalToScan = null;
                return;
            }

            MutationDef mutation = _scratchList.RandomElement();

            DB.AddToDatabase(mutation);

            TaggedString msg = MUTATION_GATHERED_LABEL.Translate(mutation.Named("mutation"),
                                                                 _chosenAnimalToScan.Named("animal")
                                                                 );

            Messages.Message(msg, MessageTypeDefOf.PositiveEvent);
            if (_scratchList.Count - 1 == 0)
            {
                _chosenAnimalToScan = null;
            }
        }
        public void DoWindowContents(Rect inRect)
        {
            List <string>    keys = pawnSpawnStates.Keys.ToList().OrderByDescending(x => x).ToList();
            Listing_Standard ls   = new Listing_Standard();
            Rect             rect = new Rect(inRect.x, inRect.y, inRect.width, inRect.height);



            ls.Begin(rect);


            ls.Label("FF_AnimalSpawnMultiplier".Translate() + ": " + FFSpawnMultiplier, -1, "FF_AnimalSpawnMultiplierTooltip".Translate());
            FFSpawnMultiplier = (float)Math.Round(ls.Slider(FFSpawnMultiplier, 0.1f, 2f), 2);
            if (ls.Settings_Button("FF_Reset".Translate(), new Rect(0f, ls.CurHeight, 180f, 29f)))
            {
                FFSpawnMultiplier = FFSpawnMultiplierBase;
            }

            ls.Gap(40f);


            for (int num = keys.Count - 1; num >= 0; num--)
            {
                bool test = pawnSpawnStates[keys[num]];
                ls.CheckboxLabeled("FF_DisableAnimal".Translate(PawnKindDef.Named(keys[num]).LabelCap), ref test);
                pawnSpawnStates[keys[num]] = test;
            }



            ls.End();

            base.Write();
        }
        public override void CompTick()
        {
            base.CompTick();
            if (!TacticalMechanoids_Settings.MechanoidIsEnabled(Props.defToChangeFrom))
            {
                if (parent.Map != null)
                {
                    for (int i = 0; i < Props.numToSpawn; i++)
                    {
                        PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDef.Named(Props.defToChangeTo), Find.FactionManager.FirstFactionOfDef(FactionDefOf.Mechanoid), PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 1f, false, true, true, false, false);
                        Pawn pawn = PawnGenerator.GeneratePawn(request);
                        GenSpawn.Spawn(pawn, this.parent.Position, parent.Map, WipeMode.Vanish);

                        Lord lord = null;
                        if (this.parent is Pawn parentPawn)
                        {
                            lord = parentPawn.GetLord();
                        }
                        if (lord == null)
                        {
                            LordJob_DefendPoint lordJob = new LordJob_DefendPoint(pawn.Position, null, false, true);
                            lord = LordMaker.MakeNewLord(Faction.OfMechanoids, lordJob, Find.CurrentMap, null);
                        }
                        lord.AddPawn(pawn);
                    }


                    this.parent.Destroy();
                }
            }
        }
Ejemplo n.º 11
0
        // Token: 0x06000035 RID: 53 RVA: 0x00003CB0 File Offset: 0x00001EB0
        public virtual Pawn GetNewPawn(Gender gender = Gender.Female)
        {
            var modExtension = pawnCrafter.def.GetModExtension <PawnCrafterProperties>();
            var pawnKindDef  = modExtension == null?PawnKindDef.Named("Human") : modExtension.pawnKind;

            var pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(pawnKindDef, pawnCrafter.Faction,
                                                                            PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 1f, false, true, true,
                                                                            false, false, false, false, false, 0, 0, null, 1, null, null, null, null, null, null, null, gender));

            if (pawn.workSettings != null)
            {
                pawn.workSettings.Notify_DisabledWorkTypesChanged();
            }

            if (pawn.skills != null)
            {
                pawn.skills.Notify_SkillDisablesChanged();
            }

            if (!pawn.Dead && pawn.RaceProps.Humanlike)
            {
                pawn.needs.mood.thoughts.situational.Notify_SituationalThoughtsDirty();
            }

            return(pawn);
        }
Ejemplo n.º 12
0
        private Pawn GenAncestor()
        {
            PawnKindDef           pawnKindDef = PawnKindDef.Named("AncestorSpirit");
            PawnGenerationRequest request     = new PawnGenerationRequest(pawnKindDef, this.AncestorFaction);

            return(PawnGenerator.GeneratePawn(request));
        }
Ejemplo n.º 13
0
        public void DoWindowContents(Rect inRect)
        {
            List <string>    keys  = pawnSpawnStates.Keys.ToList().OrderByDescending(x => x).ToList();
            Listing_Standard ls    = new Listing_Standard();
            Rect             rect  = new Rect(inRect.x, inRect.y, inRect.width, inRect.height);
            Rect             rect2 = new Rect(0f, 0f, inRect.width - 30f, ((keys.Count / 2) + 2) * 24);

            Widgets.BeginScrollView(rect, ref scrollPosition, rect2, true);
            ls.ColumnWidth = rect2.width / 2.2f;
            ls.Begin(rect2);
            ls.CheckboxLabeled("allowVanillaAnimals".Translate(), ref flagVanillaAnimals, null);
            for (int num = keys.Count - 1; num >= 0; num--)
            {
                if (num == keys.Count / 2)
                {
                    ls.NewColumn();
                }
                bool test = pawnSpawnStates[keys[num]];
                if (DefDatabase <PawnKindDef> .GetNamedSilentFail(keys[num]) == null)
                {
                    pawnSpawnStates.Remove(keys[num]);
                }
                else
                {
                    ls.CheckboxLabeled("AA_DisableAnimal".Translate(PawnKindDef.Named(keys[num]).LabelCap), ref test);
                    pawnSpawnStates[keys[num]] = test;
                }
            }

            ls.End();
            Widgets.EndScrollView();
            base.Write();
        }
Ejemplo n.º 14
0
        public override void CompTick()
        {
            base.CompTick();
            if (!AlphaAnimalsEvents_Mod.settings.flagAlphaMechanoidsSappers)
            {
                if (parent.Map != null)
                {
                    PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDef.Named(Props.defToChangeTo), Find.FactionManager.FirstFactionOfDef(FactionDefOf.Mechanoid), PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 1f, false, true, true, false, false);
                    Pawn pawn = PawnGenerator.GeneratePawn(request);
                    GenSpawn.Spawn(pawn, this.parent.Position, parent.Map, WipeMode.Vanish);

                    Lord lord = null;
                    if (pawn.Map.mapPawns.SpawnedPawnsInFaction(Faction.OfMechanoids).Any((Pawn p) => p != pawn))
                    {
                        lord = ((Pawn)GenClosest.ClosestThing_Global(pawn.Position, pawn.Map.mapPawns.SpawnedPawnsInFaction(Faction.OfMechanoids), 99999f, (Thing p) => p != pawn && ((Pawn)p).GetLord() != null, null)).GetLord();
                    }
                    if (lord == null)
                    {
                        LordJob_DefendPoint lordJob = new LordJob_DefendPoint(pawn.Position, null, false, true);
                        lord = LordMaker.MakeNewLord(Faction.OfMechanoids, lordJob, Find.CurrentMap, null);
                    }
                    lord.AddPawn(pawn);


                    this.parent.Destroy();
                }
            }
        }
        public static AIPawn GenerateAIPawn(string kindDefName, Faction faction, Map map, Gender gender = Gender.Female)
        {
            //return GeneratePawn(PawnKindDef.Named(kindDefName), faction, map, gender);
            PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDef.Named(kindDefName), faction, PawnGenerationContext.NonPlayer, -1, true, true, false, false, false, false, 0f, false, false, true, false, false, false, false, false, 0f, 0f, null, 0f, null, null, null, null, null, 0f, 0f, gender, 0.1f, null, null, null);;

            return(GenerateAIPawn(ref request, map));
        }
        public void SpawnSkeletonMinions(IntVec3 center, int radius, Faction faction)
        {
            IntVec3 curCell;
            Map     map = this.SingleMap;
            IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(center, radius, true);

            foreach (var cell in targets)
            {
                curCell = cell;
                if (curCell.InBounds(map) && curCell.IsValid && curCell.Walkable(map))
                {
                    SpawnThings skeleton = new SpawnThings();
                    if (Rand.Chance(geChance))
                    {
                        skeleton.def     = TorannMagicDefOf.TM_GiantSkeletonR;
                        skeleton.kindDef = PawnKindDef.Named("TM_GiantSkeleton");
                    }
                    else if (Rand.Chance(leChance))
                    {
                        skeleton.def     = TorannMagicDefOf.TM_SkeletonR;
                        skeleton.kindDef = PawnKindDef.Named("TM_Skeleton");
                    }
                    else
                    {
                        skeleton = null;
                    }

                    if (skeleton != null)
                    {
                        TM_Action.SingleSpawnLoop(null, skeleton, curCell, map, 0, false, false, faction);
                    }
                }
            }
        }
Ejemplo n.º 17
0
        public void Hatch()
        {
            if (this.parent.Map.IsPlayerHome)
            {
                FilthMaker.MakeFilth(this.parent.Position, this.parent.Map, ThingDefOf.Filth_AmnioticFluid, 1);


                for (int i = 0; i < this.parent.stackCount; i++)
                {
                    if (rand.NextDouble() < 0.9)
                    {
                        request = new PawnGenerationRequest(this.Props.hatcherPawn, Faction.OfPlayer, PawnGenerationContext.NonPlayer, -1, false, true, false, false, true, false, 1f, false, true, true, false, false);
                    }
                    else
                    {
                        request   = new PawnGenerationRequest(PawnKindDef.Named("GR_AberrantFleshbeast"), null, PawnGenerationContext.NonPlayer, -1, false, true, false, false, true, false, 1f, false, true, true, false, false);
                        WasMutant = true;
                    }
                    Pawn pawn = PawnGenerator.GeneratePawn(request);
                    if (PawnUtility.TrySpawnHatchedOrBornPawn(pawn, this.parent))
                    {
                        if (pawn != null)
                        {
                            if (this.hatcheeParent != null)
                            {
                                if (pawn.playerSettings != null && this.hatcheeParent.playerSettings != null && this.hatcheeParent.Faction == this.hatcheeFaction)
                                {
                                    pawn.playerSettings.AreaRestriction = this.hatcheeParent.playerSettings.AreaRestriction;
                                }
                                if (pawn.RaceProps.IsFlesh)
                                {
                                    pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, this.hatcheeParent);
                                }
                            }
                            if (this.otherParent != null && (this.hatcheeParent == null || this.hatcheeParent.gender != this.otherParent.gender) && pawn.RaceProps.IsFlesh)
                            {
                                pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, this.otherParent);
                            }
                            if (WasMutant)
                            {
                                Messages.Message("GR_ANewCreatureWasBornMutant".Translate(), pawn, MessageTypeDefOf.NegativeEvent);
                            }
                            else
                            {
                                Messages.Message("GR_ANewCreatureWasBorn".Translate(), pawn, MessageTypeDefOf.PositiveEvent);
                            }
                        }
                        if (this.parent.Spawned)
                        {
                            FilthMaker.MakeFilth(this.parent.Position, this.parent.Map, ThingDefOf.Filth_AmnioticFluid, 1);
                        }
                    }
                    else
                    {
                        Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard);
                    }
                }
                this.parent.Destroy(DestroyMode.Vanish);
            }
        }
Ejemplo n.º 18
0
 public override void PostApplyDamage(DamageInfo dinfo, float totalDamageDealt)
 {
     if (base.Dead)
     {
         Log.Message("QUEEN DEAD");
         AlienInfectionHediff hediff = (AlienInfectionHediff)HediffMaker.MakeHediff
                                           (PurpleIvyDefOf.PI_AlienInfection, this);
         hediff.instigator = PawnKindDef.Named("Genny_ParasiteOmega");
         var range = new IntRange(30, 50);
         hediff.maxNumberOfCreatures = range.RandomInRange;
         hediff.ageTicks             = new IntRange(40000, 50000).RandomInRange;
         this.health.AddHediff(hediff);
         var corpse = (Corpse)this.ParentHolder;
         PurpleIvyUtils.SpawnNests(this);
     }
     else if (!(dinfo.Instigator is MeteorIncoming))
     {
         var hediff = this.health.hediffSet.hediffs
                      .FirstOrDefault((Hediff h) => h.def == PurpleIvyDefOf.PI_CrashlandedDowned);
         if (hediff != null)
         {
             this.health.hediffSet.hediffs.Remove(hediff);
             RestUtility.Awake(this);
         }
     }
     base.PostApplyDamage(dinfo, totalDamageDealt);
 }
Ejemplo n.º 19
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map         map         = (Map)parms.target;
            PawnKindDef pawnKindDef = PawnKindDef.Named("AA_ArcticLion");
            IntVec3     intVec;

            if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal))
            {
                return(false);
            }
            List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals(pawnKindDef, map.Tile, 300);
            Rot4        rot  = Rot4.FromAngleFlat((map.Center - intVec).AngleFlat);

            for (int i = 0; i < list.Count; i++)
            {
                Pawn    pawn = list[i];
                IntVec3 loc  = CellFinder.RandomClosewalkCellNear(intVec, map, 10, null);
                GenSpawn.Spawn(pawn, loc, map, rot, WipeMode.Vanish, false);
                pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, false, false, null, false);
                pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + Rand.Range(60000, 120000);
                pawn.health.AddHediff(HediffDef.Named("AA_InvisibleArcticLion"));
            }
            Find.LetterStack.ReceiveLetter("LetterLabelManhuntingArcticLion".Translate(), "ManhuntingArcticLion".Translate(), LetterDefOf.ThreatBig, null, null, null);
            Find.TickManager.slower.SignalForceNormalSpeedShort();

            return(true);
        }
        private bool TrySpawnPawn(out Pawn pawn, Map map)
        {
            var kindDef = (Cthulhu.Utility.IsCosmicHorrorsLoaded() ? PawnKindDef.Named("ROM_DarkYoung") : PawnKindDefOf.Megaspider);

            pawn = PawnGenerator.GeneratePawn(kindDef, base.Faction);
            try
            {
                IntVec3 pos = base.Position;
                for (int i = 0; i < 3; i++)
                {
                    pos += GenAdj.CardinalDirections[2];
                }
                GenSpawn.Spawn(pawn, CellFinder.RandomClosewalkCellNear(pos, map, 1), map); //
                this.spawnedPawns.Add(pawn);
                if (this.Faction != Faction.OfPlayer)
                {
                    if (lord == null)
                    {
                        lord = this.CreateNewLord();
                    }
                    lord.AddPawn(pawn);
                }

                Messages.Message("Cults_NewDarkYoung".Translate(), pawn, MessageTypeDefOf.PositiveEvent);
                return(true);
            }
            catch
            {
                return(true);
            }
        }
Ejemplo n.º 21
0
        private bool TrySpawnPawn(out Pawn pawn)
        {
            var list = new List <PawnKindDef> {
                PawnKindDef.Named("Terrorworm"), PawnKindDef.Named("Visceral")
            };
            var curPoints = SpawnedPawnsPoints;
            var source    = from x in list where curPoints + x.combatPower <= 500f select x;

            if (!source.TryRandomElement(out var kindDef))
            {
                pawn = null;
                return(false);
            }

            pawn = PawnGenerator.GeneratePawn(kindDef, Faction);
            PawnUtility.TrySpawnHatchedOrBornPawn(pawn, this);

            // GenSpawn.Spawn(pawn, CellFinder.RandomClosewalkCellNear(base.Position, base.Map, 4, null), base.Map);
            spawnedPawns.Add(pawn);
            var lord = Lord;

            if (lord == null)
            {
                lord = CreateNewLord();
            }

            lord.AddPawn(pawn);
            return(true);
        }
Ejemplo n.º 22
0
        private bool TrySpawnPawn(out Pawn pawn)
        {
            List <PawnKindDef> list = new List <PawnKindDef>();

            list.Add(PawnKindDef.Named("Terrorworm"));
            list.Add(PawnKindDef.Named("Visceral"));
            float curPoints = this.SpawnedPawnsPoints;
            IEnumerable <PawnKindDef> source =
                from x in list
                where curPoints + x.combatPower <= 500f
                select x;
            PawnKindDef kindDef;

            if (!source.TryRandomElement(out kindDef))
            {
                pawn = null;
                return(false);
            }
            pawn = PawnGenerator.GeneratePawn(kindDef, this.Faction);
            PawnUtility.TrySpawnHatchedOrBornPawn(pawn, this);
            //GenSpawn.Spawn(pawn, CellFinder.RandomClosewalkCellNear(base.Position, base.Map, 4, null), base.Map);
            this.spawnedPawns.Add(pawn);
            Lord lord = this.Lord;

            if (lord == null)
            {
                lord = this.CreateNewLord();
            }
            lord.AddPawn(pawn);
            return(true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map         map         = (Map)parms.target;
            PawnKindDef pawnKindDef = PawnKindDef.Named("AA_FeraliskClutchMother");
            IntVec3     intVec;

            if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal))
            {
                return(false);
            }

            Rot4 rot = Rot4.FromAngleFlat((map.Center - intVec).AngleFlat);

            IntVec3 loc2     = CellFinder.RandomClosewalkCellNear(intVec, map, 1, null);
            Pawn    newThing = PawnGenerator.GeneratePawn(pawnKindDef, null);

            newThing.gender = Gender.Female;
            GenSpawn.Spawn(newThing, loc2, map, WipeMode.Vanish);



            Find.LetterStack.ReceiveLetter("LetterLabelFeraliskClutchMother".Translate(), "FeraliskClutchMother".Translate(), LetterDefOf.ThreatBig, newThing, null, null);



            return(true);
        }
Ejemplo n.º 24
0
 public Window_CraftWarframe(Building_WarframeCrafter WFCraft)
 {
     this.WFCraft    = WFCraft;
     nowWarframeKind = PawnKindDef.Named("Warframe_Excalibur");
     newWF           = getNewWF();
     RefreshCosts();
 }
Ejemplo n.º 25
0
        /// <summary>
        /// This is called seperately when the Mod-Thread is done.
        /// It is needed to be seperately from SpawnSetup, so that the graphics can be found
        /// </summary>
        private void SpawnSetup_Part2()
        {
            UI_Activate = ContentFinder <Texture2D> .Get(UI_ActivatePath, true);

            resourceDefs = new List <ThingDef>()
            {
                ThingDef.Named("Steel"),
                ThingDef.Named("Silver"),
                ThingDef.Named("Gold"),
                ThingDef.Named("Plasteel"),
                ThingDef.Named("Uranium"),
                ThingDef.Named("Jade"),
                ThingDef.Named("Synthread"),
                ThingDef.Named("Hyperweave"),
                ThingDef.Named("MedicineUltratech")
            };

            pawnKindDefs = new List <PawnKindDef>()
            {
                PawnKindDef.Named("Mercenary_Gunner"),
                PawnKindDef.Named("Mercenary_Sniper"),
                PawnKindDef.Named("Grenadier_Destructive"),
                PawnKindDef.Named("Mercenary_Slasher"),
                PawnKindDef.Named("Mercenary_Heavy"),
                PawnKindDef.Named("Drifter"),
                PawnKindDef.Named("Scavenger"),
                PawnKindDef.Named("Pirate"),
                PawnKindDef.Named("Thrasher"),
                //PawnKindDef.Named("AncientSoldier")
            };
        }
        public PawnKindDef GetValidAnimalFor([NotNull] Pawn target)
        {
            if (Props.checkForMorphFirst)
            {
                var morph = target.def.GetMorphOfRace();
                if (morph != null)
                {
                    try
                    {
                        return(DefDatabase <PawnKindDef> .AllDefs.First(pk => pk.race == morph.race));
                    }
                    catch (Exception e)
                    {
                        Log.Error($"caught {e.GetType().Name} while getting animal for morph {morph.defName}!\n{e}");
                        return(PawnKindDef.Named("Wolf_Timber"));
                    }
                }
            }


            _scratchList.Clear();
            _scratchList.AddRange(DefDatabase <PawnKindDef> .AllDefs.Where(pk => pk.race != null && IsValidAnimal(pk.race)));

            if (_scratchList.Count == 0)
            {
                Log.Error($"unable to find a valid animal for {target.Label} using \n{Props}\nreturning fallback pawn kind");
                return(PawnKindDef.Named("Wolf_Timber"));
            }

            return(_scratchList.RandomElement());
        }
Ejemplo n.º 27
0
        private void SetVars(Slate slate)
        {
            var option = options.GetValue(slate).RandomElementByWeight(x => x.weight);

            var asker = pawn.GetValue(slate); // yayo

            PawnKindDef var;

            if (option.kindDef != null)
            {
                var = option.kindDef;
                // yayo

                if (var.defName == "SpaceRefugee_Clothed" && asker?.Faction != null &&
                    asker.Faction.def != FactionDefOf.Empire)
                {
                    var = PawnKindDef.Named($"SpaceRefugee_Clothed_{asker.Faction.def.defName}");
                }

                //
            }
            else if (option.anyAnimal)
            {
                var = (from x in DefDatabase <PawnKindDef> .AllDefs
                       where x.RaceProps.Animal && (option.onlyAllowedFleshType == null ||
                                                    x.RaceProps.FleshType == option.onlyAllowedFleshType)
                       select x).RandomElement();
            }
            else
            {
                var = null;
            }

            slate.Set(storeAs.GetValue(slate), var);
        }
Ejemplo n.º 28
0
        public override void Resolve(ResolveParams rp)
        {
            var kindStr = "RE_GKind";

            BaseGen.symbolStack.Push("indoorLighting", rp);
            if (Rand.Value < 0.05f)
            {
                BaseGen.symbolStack.Push("randomlyPlaceMealsOnTables", rp);
                BaseGen.symbolStack.Push("placeChairsNearTables", rp);
                int num = Mathf.Max(GenMath.RoundRandom((float)rp.rect.Area / 20f), 1);
                for (int i = 0; i < num; i++)
                {
                    ResolveParams resolveParams = rp;
                    resolveParams.singleThingDef = ThingDefOf.Table2x2c;
                    BaseGen.symbolStack.Push("thing", resolveParams);
                }
            }
            else
            {
                var map = BaseGen.globalSettings.map;
                MiscUtility.SpawnHerbsAtRect(rp.rect, map, 4, 6);
            }
            var monsterParams = rp;

            monsterParams.rect = rp.rect;
            monsterParams.pawnGroupMakerParams = null;
            monsterParams.singlePawnKindDef    = PawnKindDef.Named(kindStr);
            Lord singlePawnLord = LordMaker.MakeNewLord(monsterParams.faction, new LordJob_DefendPoint(monsterParams.rect.CenterCell), BaseGen.globalSettings.map);

            monsterParams.singlePawnLord = singlePawnLord;
            BaseGen.symbolStack.Push("pawn", monsterParams);
        }
        public override void CompTickRare()
        {
            base.CompTickRare();
            metamorphosisTick++;
            if (metamorphosisTick > rareTicksInAYear * Props.timeInYears)
            {
                Faction faction = this.parent.Faction;



                PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDef.Named(Props.pawnToTurnInto), faction, PawnGenerationContext.NonPlayer, -1, false, true, false, false, true, false, 1f, false, true, true, false, false);
                Pawn pawn = PawnGenerator.GeneratePawn(request);
                GenSpawn.Spawn(pawn, CellFinder.RandomClosewalkCellNear(parent.Position, parent.Map, 3, null), parent.Map, WipeMode.Vanish);



                for (int i = 0; i < 20; i++)
                {
                    IntVec3 c;
                    CellFinder.TryFindRandomReachableCellNear(this.parent.Position, this.parent.Map, 2, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out c);
                    FilthMaker.TryMakeFilth(c, this.parent.Map, ThingDefOf.Filth_AmnioticFluid);
                }


                SoundDefOf.Hive_Spawn.PlayOneShot(new TargetInfo(this.parent.Position, this.parent.Map, false));
                this.parent.Destroy();
            }
        }
Ejemplo n.º 30
0
        public override void PawnDied(Corpse corpse)
        {
            //GenExplosion.DoExplosion(corpse.Position, corpse.Map, 2.9f, DamageDefOf.Stun, corpse.InnerPawn, -1, -1, null, null, null, null, ThingDef.Named("Gas_Smoke"), .7f, 1, false, null, 0f, 1);

            Faction newFaction = corpse.InnerPawn.Faction;


            if (corpse.def.defName == "Corpse_AA_FissionMouse")
            {
                PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDef.Named("AA_FissionMouseSecond"), newFaction, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 1f, false, true, true, false, false);
                Pawn pawn  = PawnGenerator.GeneratePawn(request);
                Pawn pawn2 = PawnGenerator.GeneratePawn(request);
                Pawn pawn3 = PawnGenerator.GeneratePawn(request);
                PawnUtility.TrySpawnHatchedOrBornPawn(pawn, corpse.InnerPawn);
                PawnUtility.TrySpawnHatchedOrBornPawn(pawn2, corpse.InnerPawn);
                PawnUtility.TrySpawnHatchedOrBornPawn(pawn3, corpse.InnerPawn);
            }
            else if (corpse.def.defName == "Corpse_AA_FissionMouseSecond")
            {
                PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDef.Named("AA_FissionMouseThird"), newFaction, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 1f, false, true, true, false, false);
                Pawn pawn  = PawnGenerator.GeneratePawn(request);
                Pawn pawn2 = PawnGenerator.GeneratePawn(request);
                Pawn pawn3 = PawnGenerator.GeneratePawn(request);
                PawnUtility.TrySpawnHatchedOrBornPawn(pawn, corpse.InnerPawn);
                PawnUtility.TrySpawnHatchedOrBornPawn(pawn2, corpse.InnerPawn);
                PawnUtility.TrySpawnHatchedOrBornPawn(pawn3, corpse.InnerPawn);
            }
        }