private void GenerateAndSpawnPawns(Faction faction, IncidentParms parms, IntVec3 spot) { Map map = (Map)parms.target; LordJob lordJob = new LordJob_AssaultColony(faction, canKidnap: true, canTimeoutOrFlee: false, true); Lord lord = LordMaker.MakeNewLord(faction, lordJob, map); PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms { faction = faction, points = Mathf.Clamp(parms.points / 2, 0, parms.points), generateFightersOnly = true, groupKind = PawnGroupKindDefOf.Combat, raidStrategy = RaidStrategyDefOf.ImmediateAttack, forceOneIncap = true }; IEnumerable <Pawn> pawns = PawnGroupMakerUtility.GeneratePawns(pawnGroupMakerParms); foreach (var pawn in pawns) { IntVec3 loc = CellFinder.RandomSpawnCellForPawnNear(spot, map); GenSpawn.Spawn(pawn, loc, map, Rot4.Random); lord.AddPawn(pawn); } }
public static IEnumerable <Pawn> MountAnimals(PawnGroupMakerParms groupParms, bool warnOnZeroResults, IncidentParms parms) { List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(groupParms, true).ToList(); if (list.Count == 0) { return(list); } parms.raidArrivalMode.Worker.Arrive(list, parms); if (!(parms.raidArrivalMode == null || parms.raidArrivalMode == PawnsArrivalModeDefOf.EdgeWalkIn) || (parms.raidStrategy != null && parms.raidStrategy.workerClass == typeof(RaidStrategyWorker_Siege))) { return(list); } NPCMountUtility.generateMounts(ref list, parms, Base.inBiomeWeight, Base.outBiomeWeight, Base.nonWildWeight, Base.enemyMountChance, Base.enemyMountChanceTribal); foreach (Pawn pawn in list) { if (pawn.equipment == null) { pawn.equipment = new Pawn_EquipmentTracker(pawn); } } foreach (Pawn pawn in list)//Moved this code here so we can check if the pawn actually has apparel. { if (pawn.apparel != null && pawn.apparel.WornApparel != null && pawn.apparel.WornApparel.Any((Apparel ap) => ap is ShieldBelt)) { LessonAutoActivator.TeachOpportunity(ConceptDefOf.ShieldBelts, OpportunityType.Critical); break; } } return(list); }
private void GeneratePawns(Map map, float points) { PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms { faction = Faction, points = points, generateFightersOnly = true, groupKind = PawnGroupKindDefOf.Combat, raidStrategy = RaidStrategyDefOf.ImmediateAttack, forceOneIncap = true }; var pawns = PawnGroupMakerUtility.GeneratePawns(pawnGroupMakerParms).ToList(); foreach (var pawn in pawns) { if (CellFinder.TryFindRandomCellNear(map.Center, map, 15, (IntVec3 x) => x.Standable(map) && !x.Fogged(map), out IntVec3 loc)) { GenSpawn.Spawn(pawn, loc, map, Rot4.Random); } } LordJob_AssaultColony lordJob_AssaultColony = new LordJob_AssaultColony(Faction); Lord lord = LordMaker.MakeNewLord(Faction, lordJob_AssaultColony, map, pawns); }
private void Outcome_Disaster(Caravan caravan) { LongEventHandler.QueueLongEvent(delegate() { FactionRelationKind playerRelationKind = this.Faction.PlayerRelationKind; int randomInRange = DiplomacyTuning.Goodwill_PeaceTalksDisasterRange.RandomInRange; this.Faction.TryAffectGoodwillWith(Faction.OfPlayer, randomInRange, false, false, null, null); this.Faction.TrySetRelationKind(Faction.OfPlayer, FactionRelationKind.Hostile, false, null, null); IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, caravan); incidentParms.faction = this.Faction; PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, incidentParms, true); defaultPawnGroupMakerParms.generateFightersOnly = true; List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms, true).ToList <Pawn>(); Map map = CaravanIncidentUtility.SetupCaravanAttackMap(caravan, list, false); if (list.Any <Pawn>()) { LordMaker.MakeNewLord(incidentParms.faction, new LordJob_AssaultColony(this.Faction, true, true, false, false, true), map, list); } Find.TickManager.Notify_GeneratedPotentiallyHostileMap(); GlobalTargetInfo target = (!list.Any <Pawn>()) ? GlobalTargetInfo.Invalid : new GlobalTargetInfo(list[0].Position, map, false); string label = "LetterLabelPeaceTalks_Disaster".Translate(); string letterText = this.GetLetterText("LetterPeaceTalks_Disaster".Translate(new object[] { this.Faction.def.pawnsPlural.CapitalizeFirst(), this.Faction.Name, Mathf.RoundToInt((float)randomInRange) }), caravan, playerRelationKind); PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref label, ref letterText, "LetterRelatedPawnsGroupGeneric".Translate(new object[] { Faction.OfPlayer.def.pawnsPlural }), true, true); Find.LetterStack.ReceiveLetter(label, letterText, LetterDefOf.ThreatBig, target, this.Faction, null); }, "GeneratingMapForNewEncounter", false, null); }
public static List <Pawn> GenerateRaidPawns(IncidentParms parms) { if (PES_Settings.DebugModeOn) { Log.Message("-=PS=- GenerateRaidPawns Start", false); } if (parms != null && parms.questTag != null) //Lt. Bob - "Temporary" bypass fix? for Quest handling { Log.Message("-=PS=- GenerateRaidPawns - questTag!=Null == " + parms.questTag); } IsIntercepting_PawnGeneration = GeneratorPatchFlag.Generate; PawnGroupKindDef combat = PawnGroupKindDefOf.Combat; parms.points = IncidentWorker_Raid.AdjustedRaidPoints(parms.points, parms.raidArrivalMode, parms.raidStrategy, parms.faction, combat); PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(combat, parms, false); List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms, true).ToList <Pawn>(); if (list.Count == 0) { Log.Error("Got no pawns spawning raid from parms " + parms, false); } return(list); }
protected void TreasureWithHumanAmbush(Caravan caravan) { List <Thing> rewardList = GenerateReward(); for (int i = 0; i < rewardList.Count; i++) { caravan.AddPawnOrItem(rewardList[i], true); } LongEventHandler.QueueLongEvent(delegate { IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, caravan); //make sure a minimum point threshold is hit if (incidentParms.points < MinimumPointThreshold) { incidentParms.points = MinimumPointThreshold + 100f; } incidentParms.faction = Find.FactionManager.RandomEnemyFaction(); PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, incidentParms, true); defaultPawnGroupMakerParms.generateFightersOnly = true; List <Pawn> pawnList = PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms, true).ToList <Pawn>(); Map map = CaravanIncidentUtility.SetupCaravanAttackMap(caravan, pawnList, false); if (pawnList.Any <Pawn>()) { LordMaker.MakeNewLord(incidentParms.faction, new LordJob_AssaultColony(incidentParms.faction, true, true, false, false, true), map, pawnList); } Find.TickManager.CurTimeSpeed = TimeSpeed.Paused; GlobalTargetInfo lookTarget = (!pawnList.Any <Pawn>()) ? GlobalTargetInfo.Invalid : new GlobalTargetInfo(pawnList[0].Position, map, false); Find.LetterStack.ReceiveLetter("LetterLabelTreasureAmbushLGE".Translate(), "LetterTreasureAmbushLGE".Translate(GenThing.GetMarketValue(rewardList).ToStringMoney(null), GenLabel.ThingsLabel(rewardList, string.Empty)), LetterDefOf.ThreatBig, lookTarget, null); }, "GeneratingMapForNewEncounter", false, null); }
public override void Generate(Map map, GenStepParams parms) { IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatSmall, map); incidentParms.faction = parms.sitePart.site.Faction; if (incidentParms.faction == null) { incidentParms.faction = Faction.OfMechanoids; } incidentParms.points = parms.sitePart.parms.threatPoints; List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, incidentParms, false), true).ToList <Pawn>(); if (list.Count > 0) { foreach (Pawn pawn in list) { IntVec3 result = new IntVec3(); CellFinder.TryFindRandomCellNear(map.Center, map, 10, c => c.Walkable(map), out result); GenSpawn.Spawn(pawn, result, map); } } MapGenerator.SetVar <CellRect>("RectOfInterest", CellRect.CenteredOn(map.Center, 1, 1)); LordMaker.MakeNewLord(incidentParms.faction, new LordJob_DefendBase(incidentParms.faction, map.Center), map, list); }
protected virtual IEnumerable <Pawn> GenerateNewPawns(IncidentParms parms, int preferredAmount) { int i = 0; while (i < preferredAmount) { var newPawns = PawnGroupMakerUtility.GeneratePawns(IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDef, parms, true), false).ToArray(); Log.Message($"Created {newPawns.Length} new pawns for {parms.faction.Name}."); foreach (var pawn in newPawns) { Find.World.worldPawns.PassToWorld(pawn); } foreach (var pawn in newPawns.RandomlyUsingTitleAsChance()) { yield return(pawn); i++; if (i >= preferredAmount) { yield break; } } // To avoid infinite loop if (!newPawns.Any()) { i++; } } }
public override void Generate(Map map, GenStepParams parms) { IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatSmall, map); incidentParms.faction = Find.FactionManager.AllFactionsListForReading.FindAll(f => (f.def == VFEV_DefOf.VFEV_VikingsClan || f.def == VFEV_DefOf.VFEV_VikingsSlaver) && f.HostileTo(Faction.OfPlayer))?.RandomElement(); /*parms.sitePart.site.Faction;*/ if (incidentParms.faction == null) { incidentParms.faction = Faction.OfMechanoids; } incidentParms.points = Mathf.Max(incidentParms.points * 0.5f, incidentParms.faction.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat)); List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, incidentParms, false), true).ToList(); if (list.Count > 0) { foreach (Pawn pawn in list) { IntVec3 result = new IntVec3(); CellFinder.TryFindRandomCellNear(map.Center, map, 10, c => c.Walkable(map), out result); GenSpawn.Spawn(pawn, result, map); } } MapGenerator.SetVar("RectOfInterest", CellRect.CenteredOn(map.Center, 1, 1)); if (incidentParms.faction == Faction.OfMechanoids) { LordMaker.MakeNewLord(incidentParms.faction, new LordJob_DefendPoint(map.Center, 10, addFleeToil: false), map, list); } else { LordMaker.MakeNewLord(incidentParms.faction, new LordJob_DefendBase(incidentParms.faction, map.Center), map, list); } }
private void GeneratePawns(Map map, float points) { PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms { faction = Faction, points = points, generateFightersOnly = true, groupKind = PawnGroupKindDefOf.Combat, raidStrategy = RaidStrategyDefOf.ImmediateAttack, forceOneIncap = true }; var pawns = PawnGroupMakerUtility.GeneratePawns(pawnGroupMakerParms).ToList(); GenerateItems(); foreach (var carrier in GenerateCarriers()) { pawns.Add(carrier); } IncidentParms parms = new IncidentParms { target = map, spawnCenter = CellFinder.RandomClosewalkCellNear(map.Center, map, 15, x => x.Walkable(map) && !x.Fogged(map)) }; foreach (var pawn in pawns) { IntVec3 loc = CellFinder.RandomClosewalkCellNear(parms.spawnCenter, map, 8); GenSpawn.Spawn(pawn, loc, map, parms.spawnRotation); } LordJob_DefendBase lordJob = new LordJob_DefendBase(Faction, parms.spawnCenter); Lord lord = LordMaker.MakeNewLord(Faction, lordJob, map, pawns); }
private void Outcome_Disaster(Caravan caravan) { LongEventHandler.QueueLongEvent(delegate { FactionRelationKind playerRelationKind = base.Faction.PlayerRelationKind; int randomInRange = DiplomacyTuning.Goodwill_PeaceTalksDisasterRange.RandomInRange; base.Faction.TryAffectGoodwillWith(Faction.OfPlayer, randomInRange, canSendMessage: false, canSendHostilityLetter: false); base.Faction.TrySetRelationKind(Faction.OfPlayer, FactionRelationKind.Hostile, canSendLetter: false); IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, caravan); incidentParms.faction = base.Faction; PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, incidentParms, ensureCanGenerateAtLeastOnePawn: true); defaultPawnGroupMakerParms.generateFightersOnly = true; List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms).ToList(); Map map = CaravanIncidentUtility.SetupCaravanAttackMap(caravan, list, sendLetterIfRelatedPawns: false); if (list.Any()) { LordMaker.MakeNewLord(incidentParms.faction, new LordJob_AssaultColony(base.Faction), map, list); } Find.TickManager.Notify_GeneratedPotentiallyHostileMap(); GlobalTargetInfo target = (list.Any() ? new GlobalTargetInfo(list[0].Position, map) : GlobalTargetInfo.Invalid); TaggedString letterLabel = "LetterLabelPeaceTalks_Disaster".Translate(); TaggedString letterText = GetLetterText("LetterPeaceTalks_Disaster".Translate(base.Faction.def.pawnsPlural.CapitalizeFirst(), base.Faction.NameColored, Mathf.RoundToInt(randomInRange)), caravan, playerRelationKind); PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref letterLabel, ref letterText, "LetterRelatedPawnsGroupGeneric".Translate(Faction.OfPlayer.def.pawnsPlural), informEvenIfSeenBefore: true); Find.LetterStack.ReceiveLetter(letterLabel, letterText, LetterDefOf.ThreatBig, target, base.Faction); }, "GeneratingMapForNewEncounter", doAsynchronously: false, null); }
private void CaravanDelivery() { PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms { faction = SignedFaction.Faction, groupKind = PawnGroupKindDefOf.Trader, points = Rand.Range(300, 1000), tile = Settlement.Tile }; Caravan = CaravanAIMaker.MakeCaravan(PawnGroupMakerUtility.GeneratePawns(pawnGroupMakerParms), SignedFaction.Faction, Settlement.Tile, true, CaravanAIMaker.GetCaravanColor(SignedFaction.Faction, Faction.OfPlayer), true, true); TryGetRandomPawnGroupMaker(pawnGroupMakerParms, out PawnGroupMaker maker); foreach (var p in Caravan.PawnsListForReading) { p.inventory.innerContainer.Clear(); } GenerateCarriers(pawnGroupMakerParms, maker, Items, Caravan); Items.ForEach(item => { if (item is Pawn p) { Find.WorldPawns.PassToWorld(p); Caravan.AddPawn(p, false); } }); Items.Clear(); Caravan.pather.StartPath(DestinationMap.Tile, new CaravanArrivalAction_AIEnterCaravan(DestinationMap.Parent)); Find.LetterStack.ReceiveLetter("TradeSchedulingAgreementComp_CaravanFormedTitle".Translate(), "TradeSchedulingAgreementComp_CaravanFormedDesc".Translate(), LetterDefOf.PositiveEvent, new LookTargets(Caravan)); }
private void SpawnCaravan() { PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms { faction = faction, groupKind = PawnGroupKindDefOf.Combat, points = Rand.Range(200, 500), }; List <Pawn> pawns = PawnGroupMakerUtility.GeneratePawns(pawnGroupMakerParms).ToList(); if (CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => !c.Roofed(map) && c.Walkable(map) && c.Standable(map), map, 0f, out IntVec3 pos)) { foreach (var pawn in pawns) { GenSpawn.Spawn(pawn, pos, map); } } Pawn p = pawns.RandomElement(); foreach (var item in ContainedItems) { p.inventory.innerContainer.TryAdd(item); } Find.LetterStack.ReceiveLetter("AssistCaravan_GifterArrivedTitle".Translate(), "AssistCaravan_GifterArrived".Translate(), LetterDefOf.PositiveEvent, new LookTargets(pawns[0])); RCellFinder.TryFindRandomSpotJustOutsideColony(pawns[0], out IntVec3 result); LordJob_CaravanBringItems lordJob = new LordJob_CaravanBringItems(result, p); Lord lord = LordMaker.MakeNewLord(faction, lordJob, map, pawns); QuestsManager.Communications.RemoveComponent(this); }
private void Outcome_Disaster(Caravan caravan) { LongEventHandler.QueueLongEvent(delegate { int randomInRange = WorldObject_ResearchRequestLGE.DisasterFactionRelationOffset.RandomInRange; this.Faction.TryAffectGoodwillWith(Faction.OfPlayer, randomInRange, false, false, null, null); if (!this.Faction.HostileTo(Faction.OfPlayer)) { this.Faction.TrySetRelationKind(Faction.OfPlayer, FactionRelationKind.Hostile, false, null, null); } IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, caravan); incidentParms.faction = this.Faction; PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, incidentParms, true); defaultPawnGroupMakerParms.generateFightersOnly = true; List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms, true).ToList <Pawn>(); Map map = CaravanIncidentUtility.SetupCaravanAttackMap(caravan, list, false); if (list.Any <Pawn>()) { LordMaker.MakeNewLord(incidentParms.faction, new LordJob_AssaultColony(this.Faction, true, true, false, false, true), map, list); } Find.TickManager.CurTimeSpeed = TimeSpeed.Paused; GlobalTargetInfo lookTarget = (!list.Any <Pawn>()) ? GlobalTargetInfo.Invalid : new GlobalTargetInfo(list[0].Position, map, false); Find.LetterStack.ReceiveLetter("LetterLabelResearchRequest_DisasterLGE".Translate(), this.GetLetterText("LetterResearchRequest_DisasterLGE".Translate(this.Faction.def.pawnsPlural.CapitalizeFirst(), this.Faction.Name, Mathf.RoundToInt(randomInRange)), caravan), LetterDefOf.ThreatBig, lookTarget, null); }, "GeneratingMapForNewEncounter", false, null); }
private IEnumerable <Pawn> GeneratePawns(Map map, Faction faction, GenStepParams parms) { float p; if (parms.sitePart?.parms != null && parms.sitePart.parms.threatPoints >= defaultPointsRange.min && parms.sitePart.parms.threatPoints <= defaultPointsRange.max) { p = parms.sitePart.parms.threatPoints; KLog.Message($"Using sitePart parms threat points: {p}"); } else { p = defaultPointsRange.RandomInRange; KLog.Message($"Using in-range threat points: {p}. Choosen from {defaultPointsRange}"); } p = Math.Max(p, 150) * pointMultiplier; KLog.Message($"Final threat points: {p}"); return(PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms { groupKind = PawnGroupKindDefOf.Combat, tile = map.Tile, faction = faction, points = p }, true)); }
public void SendRaid() { if (!TryFindSpawnSpot(Map, out IntVec3 spawnSpot)) { return; } PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms { faction = Faction, points = Rand.Range(1800, 2400), generateFightersOnly = true, groupKind = PawnGroupKindDefOf.Combat, raidStrategy = RaidStrategyDefOf.ImmediateAttack }; LordJob lordJob = new LordJob_AssaultColony(Faction, canKidnap: false, canTimeoutOrFlee: false, canSteal: false); Lord lord = LordMaker.MakeNewLord(Faction, lordJob, Map); lord.numPawnsLostViolently = int.MaxValue; IEnumerable <Pawn> pawns = PawnGroupMakerUtility.GeneratePawns(pawnGroupMakerParms); foreach (var p in pawns) { GenSpawn.Spawn(p, spawnSpot, Map); lord.AddPawn(p); } Find.LetterStack.ReceiveLetter("DoomsdayContrAttackTitle".Translate(), "DoomsdayContrAttack".Translate(), LetterDefOf.ThreatBig); RaidSent = true; }
public override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; List <TargetInfo> list = new List <TargetInfo>(); ThingDef shipPartDef = def.mechClusterBuilding; IntVec3 intVec = FindDropPodLocation(map, (IntVec3 spot) => CanPlaceAt(spot)); if (intVec == IntVec3.Invalid) { return(false); } float points = Mathf.Max(parms.points * 0.9f, 300f); Thing thing = ThingMaker.MakeThing(shipPartDef); Building building_CrashedShipPart = (Building)thing; CompPawnSpawnerOnDamaged damaged = building_CrashedShipPart.TryGetCompFast <CompPawnSpawnerOnDamaged>(); thing.SetFaction(faction, null); List <Pawn> list2 = PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms { groupKind = PawnGroupKindDefOf.Combat, tile = map.Tile, faction = faction, points = points }).ToList(); LordMaker.MakeNewLord(faction, new LordJob_SleepThenMechanoidsDefend(new List <Thing> { thing }, faction, 28f, intVec, canAssaultColony: false, isMechCluster: false), map, list2); DropPodUtility.DropThingsNear(intVec, map, list2.Cast <Thing>()); foreach (Pawn item in list2) { item.TryGetCompFast <CompCanBeDormant>()?.ToSleep(); } list.AddRange(list2.Select((Pawn p) => new TargetInfo(p))); GenSpawn.Spawn(SkyfallerMaker.MakeSkyfaller(ThingDefOf.CrashedShipPartIncoming, thing), intVec, map); list.Add(new TargetInfo(intVec, map)); SendStandardLetter(parms, list); return(true); bool CanPlaceAt(IntVec3 loc) { CellRect cellRect = GenAdj.OccupiedRect(loc, Rot4.North, shipPartDef.Size); if (loc.Fogged(map) || !cellRect.InBounds(map)) { return(false); } foreach (IntVec3 item2 in cellRect) { RoofDef roof = item2.GetRoof(map); if (roof != null && roof.isNatural) { return(false); } } return(GenConstruct.CanBuildOnTerrain(shipPartDef, loc, map, Rot4.North)); } }
protected virtual IEnumerable <Pawn> SpawnPawns(PawnGroupMakerParms pawnGroupMakerParms, IntVec3 spawnCenter, Map map) { foreach (Pawn retrieverPawn in PawnGroupMakerUtility.GeneratePawns(pawnGroupMakerParms)) { GenSpawn.Spawn(retrieverPawn, CellFinder.RandomClosewalkCellNear(spawnCenter, map, 5), map); yield return(retrieverPawn); } }
protected override List <Pawn> GeneratePawns(IncidentParms parms) { PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, parms); defaultPawnGroupMakerParms.generateFightersOnly = true; defaultPawnGroupMakerParms.dontUseSingleUseRocketLaunchers = true; return(PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms).ToList()); }
protected override bool TryExecuteWorker(IncidentParms parms) { parms.raidStrategy.Worker.TryGenerateThreats(parms); if (!parms.raidArrivalMode.Worker.TryResolveRaidSpawnCenter(parms)) { return(false); } float points = parms.points; List <Pawn> list = parms.raidStrategy.Worker.SpawnThreats(parms); if (list == null) { list = PawnGroupMakerUtility.GeneratePawns(IncidentParmsUtility.GetDefaultPawnGroupMakerParms(combat, parms)).ToList(); if (list.Count == 0) { Log.Error("Got no pawns spawning raid from parms " + parms); return(false); } parms.raidArrivalMode.Worker.Arrive(list, parms); } GenerateRaidLoot(parms, points, list); TaggedString letterLabel = GetLetterLabel(parms); TaggedString letterText = GetLetterText(parms, list); PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref letterLabel, ref letterText, GetRelatedPawnsInfoLetterText(parms), true); List <TargetInfo> list2 = new List <TargetInfo>(); if (parms.pawnGroups != null) { List <List <Pawn> > list3 = IncidentParmsUtility.SplitIntoGroups(list, parms.pawnGroups); List <Pawn> list4 = list3.MaxBy((List <Pawn> x) => x.Count); if (list4.Any()) { list2.Add(list4[0]); } for (int i = 0; i < list3.Count; i++) { if (list3[i] != list4 && list3[i].Any()) { list2.Add(list3[i][0]); } } } else if (list.Any()) { foreach (Pawn item in list) { list2.Add(item); } } SendRimWarLetter(letterLabel, letterText, GetLetterDef(), parms, list2); parms.raidStrategy.Worker.MakeLords(parms, list); Find.TickManager.slower.SignalForceNormalSpeedShort(); Find.StoryWatcher.statsRecord.numRaidsEnemy++; return(true); }
public static List <Pawn> GenerateNeutralPawns(PawnGroupKindDef pawnGroupKind, IncidentParms parms) { IsIntercepting_PawnGeneration = GeneratorPatchFlag.Generate; PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(pawnGroupKind, parms, true); List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms, false).ToList <Pawn>(); return(list); }
public override void Generate(Map map, GenStepParams parms) { var s = new Stencil(map); s = s.Bound(s.MinX, s.MaxZ - Mathf.RoundToInt(map.Size.x * HeightRatio), s.MaxX, s.MaxZ) .Center(); // Clear area s.Expand(0, 3, 0, 0).ClearThingsInBounds(); // Courtyard floor s.FillTerrain(BaseGenUtility.RandomHightechFloorDef()); // Outer floor s.Bound(0, s.MinZ - 1, 0, s.MinZ - 8).SetTerrain(GenCity.RandomFloor(map)); // Outer barricade s.Fill(s.MinX, s.MinZ - 7, s.MaxX, s.MinZ - 7, ThingDefOf.Barricade, GenCity.RandomStuff(ThingDefOf.Barricade, map), IsValidBarricadeTile); // Outer wall var wallStuff = BaseGenUtility.RandomHightechWallStuff(); var doorX = s.MinX + map.Size.x / 2; s.Fill(s.MinX, s.MinZ - 3, doorX - 1, s.MinZ, ThingDefOf.Wall, wallStuff); s.Fill(doorX + 1, s.MinZ - 3, s.MaxX, s.MinZ, ThingDefOf.Wall, wallStuff); s.Bound(doorX, s.MinZ - 3, doorX, s.MinZ) .Fill(ThingDefOf.Door, wallStuff); // Inner keep s = s.Expand(-marginRange.RandomInRange, -marginRange.RandomInRange, -marginRange.RandomInRange, -marginRange.RandomInRange); var genStep = (GenStep_Buildings)buildingGenStepDef.genStep; genStep.GenerateRect(s); // Mechanoids var mechs = PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms { groupKind = PawnGroupKindDefOf.Combat, tile = map.Tile, faction = Faction.OfMechanoids, points = 5000, }).ToList(); foreach (var mech in mechs) { var pos = s.Expand(-10).MoveRand().pos; GenSpawn.Spawn(mech, GenCity.FindPawnSpot(pos, map), map); mech.SetFactionDirect(map.ParentFaction); mech.Name = new NameSingle(mechanoidNames[Rand.Range(0, mechanoidNames.Count)] + " #" + Rand.RangeInclusive(10, 40)); var lord = LordMaker.MakeNewLord(map.ParentFaction, new LordJob_LiveInCitadel(pos), map); lord.AddPawn(mech); } //TODO throne room }
public static bool Prefix(ref List <Pawn> __result, Faction faction) { __result = PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms { tile = Find.AnyPlayerHomeMap.Tile, groupKind = PawnGroupKindDefOf.Trader, faction = faction, points = TraderCaravanUtility.GenerateGuardPoints(), dontUseSingleUseRocketLaunchers = true }).ToList(); return(false); }
protected new List <Pawn> SpawnPawns(IncidentParms parms) { Map map = (Map)parms.target; var list = PawnGroupMakerUtility.GeneratePawns(IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDef, parms, true), false) .Take(Settings.maxGuestGroupSize) // Added .ToList(); foreach (Pawn newThing in list) { GenSpawn.Spawn(newThing, CellFinder.RandomClosewalkCellNear(parms.spawnCenter, map, 5), map); } return(list); }
public static bool Prefix(ref List <Pawn> __result, IncidentWorker_NeutralGroup __instance, IncidentParms parms) { Map map = (Map)parms.target; List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(IncidentParmsUtility.GetDefaultPawnGroupMakerParms((PawnGroupKindDef)PawnGroupKindDefInfo.Invoke(__instance, new object[] { }), parms, ensureCanGenerateAtLeastOnePawn: true), warnOnZeroResults: false).ToList(); foreach (Pawn item in list) { IntVec3 loc = CellFinderExtended.RandomClosewalkCellNear(parms.spawnCenter, map, item.kindDef, 5); GenSpawn.Spawn(item, loc, map); } __result = list; return(false); }
private IEnumerable <Pawn> GeneratePawns(GenStepParams parms, Map map, Faction faction) { float points = (parms.sitePart == null) ? defaultPointsRange.RandomInRange : parms.sitePart.parms.threatPoints; PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms(); pawnGroupMakerParms.groupKind = PawnGroupKindDefOf.Combat; pawnGroupMakerParms.tile = map.Tile; pawnGroupMakerParms.faction = faction; pawnGroupMakerParms.points = points; if (parms.sitePart != null) { pawnGroupMakerParms.seed = SeedPart; } return(PawnGroupMakerUtility.GeneratePawns(pawnGroupMakerParms, true)); }
private void SpawnGroup(int points, CellRect locationRect, Faction faction, Map map) { PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms(); pawnGroupMakerParms.groupKind = PawnGroupKindDefOf.Combat; pawnGroupMakerParms.tile = map.Tile; pawnGroupMakerParms.points = points; pawnGroupMakerParms.faction = faction; pawnGroupMakerParms.generateFightersOnly = false; pawnGroupMakerParms.forceOneIncap = false; pawnGroupMakerParms.seed = Rand.Int; List <Pawn> pawns = PawnGroupMakerUtility.GeneratePawns(pawnGroupMakerParms).ToList(); CellRect rect = locationRect; if (pawns == null) { Debug.Warning("Pawns list is null"); } else { Debug.Log("Pawns list contains {0} records", pawns.Count); } foreach (Pawn p in pawns) { bool result = CellFinder.TryFindRandomCellInsideWith(locationRect, (IntVec3 x) => x.Standable(map), out IntVec3 location); if (result) { GenSpawn.Spawn(p, location, map, Rot4.Random); } else { Debug.Warning("Can't find location!"); } } LordJob lordJob = null; lordJob = new LordJob_DefendBase(faction, rect.CenterCell); if (lordJob != null) { LordMaker.MakeNewLord(faction, lordJob, map, pawns); } }
private List <Pawn> SpawnRaid(IncidentParms parms, out List <TargetInfo> targetInfos) { PawnGroupKindDef combat = PawnGroupKindDefOf.Combat; parms.raidStrategy.Worker.TryGenerateThreats(parms); List <Pawn> list = parms.raidStrategy.Worker.SpawnThreats(parms); if (list == null) { list = PawnGroupMakerUtility.GeneratePawns(IncidentParmsUtility.GetDefaultPawnGroupMakerParms(combat, parms)).ToList(); if (list.Count == 0) { Log.Error("Got no pawns spawning raid from parms " + parms); targetInfos = null; return(list); } parms.raidArrivalMode.Worker.Arrive(list, parms); } List <TargetInfo> list2 = new List <TargetInfo>(); if (parms.pawnGroups != null) { List <List <Pawn> > list3 = IncidentParmsUtility.SplitIntoGroups(list, parms.pawnGroups); List <Pawn> list4 = list3.MaxBy((List <Pawn> x) => x.Count); if (list4.Any()) { list2.Add(list4[0]); } for (int i = 0; i < list3.Count; i++) { if (list3[i] != list4 && list3[i].Any()) { list2.Add(list3[i][0]); } } } else if (list.Any()) { foreach (Pawn item in list) { list2.Add(item); } } parms.raidStrategy.Worker.MakeLords(parms, list); targetInfos = list2; return(list); }
/// <summary> /// Tries to execute the worker. /// </summary> /// <param name="parms">The parms.</param> /// <returns></returns> protected override bool TryExecuteWorker(IncidentParms parms) { var map = (Map)parms.target; var targetInfoList = new List <TargetInfo>(); ThingDef shipPartDef = def.mechClusterBuilding; IntVec3 dropPodLocation = MechClusterUtility.FindDropPodLocation(map, spot => { if (!spot.Fogged(map) && GenConstruct.CanBuildOnTerrain(shipPartDef, spot, map, Rot4.North)) { return(GenConstruct.CanBuildOnTerrain(shipPartDef, new IntVec3(spot.x - Mathf.CeilToInt(shipPartDef.size.x / 2f), spot.y, spot.z), map, Rot4.North)); } return(false); }); if (dropPodLocation == IntVec3.Invalid) { return(false); } float num = Mathf.Max(parms.points * 0.9f, 300f); var genParams = new PawnGroupMakerParms { groupKind = PawnGroupKindDefOf.Combat, tile = map.Tile, faction = Faction.OfMechanoids, points = num }; List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(genParams) .ToList(); Thing innerThing = ThingMaker.MakeThing(shipPartDef); innerThing.SetFaction(Faction.OfMechanoids); LordMaker.MakeNewLord(Faction.OfMechanoids, new LordJob_SleepThenMechanoidsDefend(new List <Thing> { innerThing }, Faction.OfMechanoids, 28f, dropPodLocation, false, false), map, list); DropPodUtility.DropThingsNear(dropPodLocation, map, list); foreach (Thing thing in list) { thing.TryGetComp <CompCanBeDormant>()?.ToSleep(); } targetInfoList.AddRange(list.Select(p => new TargetInfo(p))); GenSpawn.Spawn(SkyfallerMaker.MakeSkyfaller(PMThingDefOf.CrashedMutagenicShipPartIncoming, innerThing), dropPodLocation, map); targetInfoList.Add(new TargetInfo(dropPodLocation, map)); SendStandardLetter(parms, targetInfoList, Array.Empty <NamedArgument>()); return(true); }
private static void Outcome_TalksSabotageDisaster(Faction favouredFaction, Faction burdenedFaction, Pawn pawn, IIncidentTarget incidentTarget) { favouredFaction.TryAffectGoodwillWith(other: pawn.Faction, goodwillChange: -FactionInteractionDiplomacyTuningsBlatantlyCopiedFromPeaceTalks .GoodWill_FactionWarPeaceTalks_ImpactHuge.RandomInRange); favouredFaction.TrySetRelationKind(other: pawn.Faction, kind: FactionRelationKind.Hostile, canSendLetter: false, reason: null, lookTarget: null); burdenedFaction.TryAffectGoodwillWith(other: pawn.Faction, goodwillChange: -FactionInteractionDiplomacyTuningsBlatantlyCopiedFromPeaceTalks .GoodWill_FactionWarPeaceTalks_ImpactHuge.RandomInRange); burdenedFaction.TrySetRelationKind(other: pawn.Faction, kind: FactionRelationKind.Hostile, canSendLetter: false, reason: null, lookTarget: null); Find.World.GetComponent <WorldComponent_MFI_FactionWar>().StartWar(factionOne: favouredFaction, factionInstigator: burdenedFaction, selfResolved: favouredFaction.leader == pawn); LongEventHandler.QueueLongEvent(action: delegate { IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(incCat: IncidentCategoryDefOf.ThreatBig, target: incidentTarget); incidentParms.faction = favouredFaction; PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(groupKind: PawnGroupKindDefOf.Combat, parms: incidentParms, ensureCanGenerateAtLeastOnePawn: true); defaultPawnGroupMakerParms.generateFightersOnly = true; List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(parms: defaultPawnGroupMakerParms).ToList(); IncidentParms burdenedFactionIncidentParms = incidentParms; burdenedFactionIncidentParms.faction = burdenedFaction; PawnGroupMakerParms burdenedFactionPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(groupKind: PawnGroupKindDefOf.Combat, parms: incidentParms, ensureCanGenerateAtLeastOnePawn: true); burdenedFactionPawnGroupMakerParms.generateFightersOnly = true; List <Pawn> burdenedFactionWarriors = PawnGroupMakerUtility.GeneratePawns(parms: burdenedFactionPawnGroupMakerParms).ToList(); List <Pawn> combinedList = new List <Pawn>(); combinedList.AddRange(collection: list); combinedList.AddRange(collection: burdenedFactionWarriors); Map map = CaravanIncidentUtility.SetupCaravanAttackMap(caravan: incidentTarget as Caravan, enemies: combinedList, sendLetterIfRelatedPawns: true); if (list.Any()) { LordMaker.MakeNewLord(faction: incidentParms.faction, lordJob: new LordJob_AssaultColony(assaulterFaction: favouredFaction), map: map, startingPawns: list); } if (burdenedFactionWarriors.Any()) { LordMaker.MakeNewLord(faction: burdenedFactionIncidentParms.faction, lordJob: new LordJob_AssaultColony(assaulterFaction: burdenedFaction), map: map, startingPawns: burdenedFactionWarriors); } Find.TickManager.Notify_GeneratedPotentiallyHostileMap(); }, textKey: "GeneratingMapForNewEncounter", doAsynchronously: false, exceptionHandler: null); }