public static IEnumerable <CosmicHorrorPawn> SpawnHorrorsOfCountAt(PawnKindDef kindDef, IntVec3 at, Map map, int count, Faction fac = null, bool berserk = false, bool target = false) { List <CosmicHorrorPawn> pawns = new List <CosmicHorrorPawn>(); for (int i = 1; i <= count; i++) { if ((from cell in GenAdj.CellsAdjacent8Way(new TargetInfo(at, map)) where at.Walkable(map) && !at.Fogged(map) && at.InBounds(map) select cell).TryRandomElement(out at)) { CosmicHorrorPawn pawn = null; if (fac != Faction.OfPlayer) { //PawnGenerationRequest request = new PawnGenerationRequest(kindDef, fac, PawnGenerationContext.NonPlayer, map.Tile); //Pawn item = PawnGenerator.GeneratePawn(request); //list.Add(item); PawnGenerationRequest request = new PawnGenerationRequest(kindDef, fac, PawnGenerationContext.NonPlayer, map.Tile); pawn = (CosmicHorrorPawn)GenSpawn.Spawn(PawnGenerator.GeneratePawn(request), at, map); } else { pawn = (CosmicHorrorPawn)GenSpawn.Spawn(PawnGenerator.GeneratePawn(kindDef, fac), at, map); } pawns.Add(pawn); if (berserk) { pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk); } } } return(pawns.AsEnumerable <CosmicHorrorPawn>()); }
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); } }
protected override bool TryExecuteWorker(IncidentParms parms) { //Resolve parameters. ResolveSpawnCenter(parms); //Initialize variables. this.iwDef = MonsterDefOf.ROM_StarVampireSpawner; this.iwWarn = MonsterDefOf.Pawn_ROM_StarVampire_Warning; this.iwScout = null; //iwPawn as CosmicHorrorPawn; this.iwLoc = CellFinder.RandomClosewalkCellNear(parms.spawnCenter, (Map)parms.target, 8); //In-case there's something silly happening... if (this.iwFac == null) { this.iwFac = Find.FactionManager.FirstFactionOfDef(FactionDefOf.AncientsHostile); } //Normally, we would slow down time and play a message, but we won't. //Why do you ask? Simply put, this creates a far more tense situation of discovering the scout. //Find.TickManager.slower.SignalForceNormalSpeed(); //this.iwWarn.PlayOneShotOnCamera(); //Messages.Message("StarVampireIncidentMessage".Translate(), new RimWorld.Planet.GlobalTargetInfo(IntVec3.Invalid, (Map)parms.target), MessageTypeDefOf.SituationResolved); SpawnScout(parms); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { //Resolve parameters. ResolveSpawnCenter(parms); //Initialize variables. this.iwDef = MonsterDefOf.ROM_StarVampireSpawner; this.iwWarn = MonsterDefOf.Pawn_ROM_StarVampire_Warning; this.iwVampire = null; //iwPawn as CosmicHorrorPawn; this.iwLoc = CellFinder.RandomClosewalkCellNear(parms.spawnCenter, (Map)parms.target, 8); //In-case there's something silly happening... if (this.iwFac == null) { this.iwFac = Find.FactionManager.FirstFactionOfDef(FactionDefOf.SpacerHostile); } //Slow down time Find.TickManager.slower.SignalForceNormalSpeed(); //Play a sound. this.iwWarn.PlayOneShotOnCamera(); //Show the warning message. Messages.Message("StarVampireIncidentMessage".Translate(), new RimWorld.Planet.GlobalTargetInfo(IntVec3.Invalid, (Map)parms.target), MessageTypeDefOf.SituationResolved); //Spawn the Star Vampire. SpawnStarVampires(parms); return(true); }
protected override Job TryGiveJob(Pawn pawn) { //CosmicHorrorPawn pawnSelf = pawn as CosmicHorrorPawn; if (pawn.Downed) { return(null); } if (pawn.Dead) { return(null); } if (!pawn.Spawned) { return(null); } //if (!this.setStartTicks) //{ // this.startTicks = Find.TickManager.TicksGame + this.ticksUntilStartingAttack.RandomInRange; // this.setStartTicks = true; // return new Job(JobDefOf.WaitWander) { expiryInterval = 90 }; //} //if (Find.TickManager.TicksGame > (this.startTicks / 2) && this.showedMessage == false) //{ // this.showedMessage = true; // SoundDef warnSound = SoundDef.Named("Pawn_ROM_StarVampire_Warning"); // warnSound.PlayOneShotOnCamera(); // Messages.Message("StarVampireIncidentMessage2".Translate(), new RimWorld.Planet.GlobalTargetInfo(IntVec3.Invalid, pawn.Map), MessageTypeDefOf.SituationResolved); //} //if (Find.TickManager.TicksGame < this.startTicks) //{ // return new Job(JobDefOf.WaitWander) { expiryInterval = 90 }; //} if (Rand.Value < 0.5f) { return(new Job(JobDefOf.WaitCombat) { expiryInterval = 90 }); } if (!pawn.health.Downed && !pawn.health.Dead) { Predicate <Thing> validator = t => ((t != pawn) && t.Spawned) && (t is Building_Turret); CosmicHorrorPawn pawn2 = pawn as CosmicHorrorPawn; Thing targetA = GenClosest.ClosestThingReachable(pawn.Position, pawn.MapHeld, ThingRequest.ForGroup(ThingRequestGroup.BuildingArtificial), PathEndMode.ClosestTouch, TraverseParms.For(pawn2, Danger.Deadly, TraverseMode.PassDoors, true), 999f, validator, null); if (targetA != null) { //if (pawnSelf.canReveal()) { pawnSelf.Reveal(); } return(new Job(JobDefOf.AttackMelee, targetA) { //maxNumMeleeAttacks = 1, expiryInterval = Rand.Range(420, 900) }); } Predicate <Thing> predicate2 = delegate(Thing t) { if (t == pawn) { return(false); } Pawn pawn1 = t as Pawn; if ((pawn1 == null) || (!t.Spawned) || (pawn1.kindDef.ToString() == "ROM_StarVampire")) { return(false); } if (pawn1.RaceProps.Animal) { return(false); } return(true); }; Thing thing2 = GenClosest.ClosestThingReachable(pawn.Position, pawn.MapHeld, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.OnCell, TraverseParms.For(pawn2, Danger.Deadly, TraverseMode.PassDoors, false), notRaidingAttackRange, predicate2); Pawn pawnTarget = thing2 as Pawn; if (thing2 != null) { Thing thing3; using (PawnPath path = pawn.Map.pathFinder.FindPath(pawn.Position, thing2.Position, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassDoors, false), PathEndMode.OnCell)) { thing3 = path.FirstBlockingBuilding(out IntVec3 vec, pawn); } if (thing3 != null) { return(new Job(JobDefOf.AttackMelee, thing3) { //maxNumMeleeAttacks = 1, expiryInterval = Rand.Range(420, 900), locomotionUrgency = LocomotionUrgency.Sprint }); } if (thing2 != null) { if (pawnTarget.Dead) { //if (pawnSelf.canReveal()) { pawnSelf.Reveal(); } return(new Job(JobDefOf.Ingest, thing2) { //maxNumMeleeAttacks = 1, expiryInterval = Rand.Range(57420, 57900), locomotionUrgency = LocomotionUrgency.Sprint }); } //if (pawnSelf.canReveal()) { pawnSelf.Reveal(); } return(new Job(JobDefOf.PredatorHunt, thing2) { //maxNumMeleeAttacks = 1, expiryInterval = Rand.Range(57420, 57900), locomotionUrgency = LocomotionUrgency.Sprint, killIncappedTarget = true }); } } } //pawnSelf.Hide(); return(null); }