protected override void RunInt() { Slate slate = QuestGen.slate; Map map = slate.Get <Map>("map"); QuestPart_ThreatsGenerator questPart_ThreatsGenerator = new QuestPart_ThreatsGenerator(); questPart_ThreatsGenerator.threatStartTicks = threatStartTicks.GetValue(slate); questPart_ThreatsGenerator.inSignalEnable = (QuestGenUtility.HardcodedSignalWithQuestID(inSignalEnable.GetValue(slate)) ?? slate.Get <string>("inSignal")); questPart_ThreatsGenerator.inSignalDisable = QuestGenUtility.HardcodedSignalWithQuestID(inSignalDisable.GetValue(slate)); ThreatsGeneratorParams value = parms.GetValue(slate); value.faction = (faction.GetValue(slate) ?? value.faction); questPart_ThreatsGenerator.parms = value; questPart_ThreatsGenerator.mapParent = map.Parent; QuestGen.quest.AddPart(questPart_ThreatsGenerator); if (!storeThreatExampleAs.GetValue(slate).NullOrEmpty()) { PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms(); pawnGroupMakerParms.groupKind = PawnGroupKindDefOf.Combat; pawnGroupMakerParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; pawnGroupMakerParms.faction = (value.faction ?? (from x in Find.FactionManager.GetFactions(allowHidden: false, allowDefeated: false, allowNonHumanlike: true, TechLevel.Industrial) where x.HostileTo(Faction.OfPlayer) select x).RandomElement()); float num = value.threatPoints ?? (StorytellerUtility.DefaultThreatPointsNow(map) * value.currentThreatPointsFactor); if (value.minThreatPoints.HasValue) { num = Mathf.Max(num, value.minThreatPoints.Value); } pawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(num, PawnsArrivalModeDefOf.EdgeWalkIn, RaidStrategyDefOf.ImmediateAttack, pawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat); IEnumerable <PawnKindDef> pawnKinds = PawnGroupMakerUtility.GeneratePawnKindsExample(pawnGroupMakerParms); slate.Set(storeThreatExampleAs.GetValue(slate), PawnUtility.PawnKindsToLineList(pawnKinds, " - ")); } }
protected override void RunInt() { Slate slate = QuestGen.slate; Map target = QuestGen.slate.Get <Map>("map"); float a = QuestGen.slate.Get("points", 0f); Faction faction = QuestGen.slate.Get <Faction>("enemyFaction"); QuestPart_Incident questPart_Incident = new QuestPart_Incident(); questPart_Incident.debugLabel = "raid"; questPart_Incident.incident = IncidentDefOf.RaidEnemy; IncidentParms incidentParms = new IncidentParms(); incidentParms.forced = true; incidentParms.target = target; incidentParms.points = Mathf.Max(a, faction.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat)); incidentParms.faction = faction; incidentParms.pawnGroupMakerSeed = Rand.Int; incidentParms.inSignalEnd = QuestGenUtility.HardcodedSignalWithQuestID(inSignalLeave.GetValue(slate)); incidentParms.questTag = QuestGenUtility.HardcodedTargetQuestTagWithQuestID(tag.GetValue(slate)); if (!customLetterLabel.GetValue(slate).NullOrEmpty() || customLetterLabelRules.GetValue(slate) != null) { QuestGen.AddTextRequest("root", delegate(string x) { incidentParms.customLetterLabel = x; }, QuestGenUtility.MergeRules(customLetterLabelRules.GetValue(slate), customLetterLabel.GetValue(slate), "root")); } if (!customLetterText.GetValue(slate).NullOrEmpty() || customLetterTextRules.GetValue(slate) != null) { QuestGen.AddTextRequest("root", delegate(string x) { incidentParms.customLetterText = x; }, QuestGenUtility.MergeRules(customLetterTextRules.GetValue(slate), customLetterText.GetValue(slate), "root")); } IncidentWorker_Raid obj = (IncidentWorker_Raid)questPart_Incident.incident.Worker; obj.ResolveRaidStrategy(incidentParms, PawnGroupKindDefOf.Combat); obj.ResolveRaidArriveMode(incidentParms); if (incidentParms.raidArrivalMode.walkIn) { incidentParms.spawnCenter = walkInSpot.GetValue(slate) ?? QuestGen.slate.Get <IntVec3?>("walkInSpot") ?? IntVec3.Invalid; } PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, incidentParms); defaultPawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(defaultPawnGroupMakerParms.points, incidentParms.raidArrivalMode, incidentParms.raidStrategy, defaultPawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat); IEnumerable <PawnKindDef> pawnKinds = PawnGroupMakerUtility.GeneratePawnKindsExample(defaultPawnGroupMakerParms); questPart_Incident.SetIncidentParmsAndRemoveTarget(incidentParms); questPart_Incident.inSignal = QuestGenUtility.HardcodedSignalWithQuestID(inSignal.GetValue(slate)) ?? QuestGen.slate.Get <string>("inSignal"); QuestGen.quest.AddPart(questPart_Incident); QuestGen.AddQuestDescriptionRules(new List <Rule> { new Rule_String("raidPawnKinds", PawnUtility.PawnKindsToLineList(pawnKinds, " - ", ColoredText.ThreatColor)), new Rule_String("raidArrivalModeInfo", incidentParms.raidArrivalMode.textWillArrive.Formatted(faction)) }); }
public static void Raid(this Quest quest, Map map, float points, Faction faction, string inSignalLeave = null, string customLetterLabel = null, string customLetterText = null, RulePack customLetterLabelRules = null, RulePack customLetterTextRules = null, IntVec3?walkInSpot = null, string tag = null, string inSignal = null, string rootSymbol = "root", PawnsArrivalModeDef raidArrivalMode = null) { QuestPart_Incident questPart_Incident = new QuestPart_Incident(); questPart_Incident.debugLabel = "raid"; questPart_Incident.incident = IncidentDefOf.RaidEnemy; IncidentParms incidentParms = new IncidentParms(); incidentParms.forced = true; incidentParms.target = map; incidentParms.points = Mathf.Max(points, faction.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat)); incidentParms.faction = faction; incidentParms.pawnGroupMakerSeed = Rand.Int; incidentParms.inSignalEnd = inSignalLeave; incidentParms.questTag = QuestGenUtility.HardcodedTargetQuestTagWithQuestID(tag); incidentParms.raidArrivalMode = raidArrivalMode; if (!customLetterLabel.NullOrEmpty() || customLetterLabelRules != null) { QuestGen.AddTextRequest(rootSymbol, delegate(string x) { incidentParms.customLetterLabel = x; }, QuestGenUtility.MergeRules(customLetterLabelRules, customLetterLabel, rootSymbol)); } if (!customLetterText.NullOrEmpty() || customLetterTextRules != null) { QuestGen.AddTextRequest(rootSymbol, delegate(string x) { incidentParms.customLetterText = x; }, QuestGenUtility.MergeRules(customLetterTextRules, customLetterText, rootSymbol)); } IncidentWorker_Raid obj = (IncidentWorker_Raid)questPart_Incident.incident.Worker; obj.ResolveRaidStrategy(incidentParms, PawnGroupKindDefOf.Combat); obj.ResolveRaidArriveMode(incidentParms); if (incidentParms.raidArrivalMode.walkIn) { incidentParms.spawnCenter = walkInSpot ?? QuestGen.slate.Get <IntVec3?>("walkInSpot") ?? IntVec3.Invalid; } PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, incidentParms); defaultPawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(defaultPawnGroupMakerParms.points, incidentParms.raidArrivalMode, incidentParms.raidStrategy, defaultPawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat); IEnumerable <PawnKindDef> pawnKinds = PawnGroupMakerUtility.GeneratePawnKindsExample(defaultPawnGroupMakerParms); questPart_Incident.SetIncidentParmsAndRemoveTarget(incidentParms); questPart_Incident.inSignal = inSignal ?? QuestGen.slate.Get <string>("inSignal"); QuestGen.quest.AddPart(questPart_Incident); QuestGen.AddQuestDescriptionRules(new List <Rule> { new Rule_String("raidPawnKinds", PawnUtility.PawnKindsToLineList(pawnKinds, " - ", ColoredText.ThreatColor)), new Rule_String("raidArrivalModeInfo", incidentParms.raidArrivalMode.textWillArrive.Formatted(faction)) }); }
protected override void RunInt() { Slate slate = QuestGen.slate; slate.Get <Map>("map"); PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms(); pawnGroupMakerParms.groupKind = PawnGroupKindDefOf.Combat; pawnGroupMakerParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; pawnGroupMakerParms.faction = faction.GetValue(slate) ?? (from x in Find.FactionManager.GetFactions_NewTemp(allowHidden: false, allowDefeated: false, allowNonHumanlike: true, TechLevel.Industrial) where x.HostileTo(Faction.OfPlayer) select x).RandomElement(); pawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(points.GetValue(slate), PawnsArrivalModeDefOf.EdgeWalkIn, RaidStrategyDefOf.ImmediateAttack, pawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat); IEnumerable <PawnKindDef> pawnKinds = PawnGroupMakerUtility.GeneratePawnKindsExample(pawnGroupMakerParms); slate.Set(storeAs.GetValue(slate), PawnUtility.PawnKindsToLineList(pawnKinds, " - ", ColoredText.ThreatColor)); }
protected override void RunInt() { Slate slate = QuestGen.slate; QuestPart_MechCluster questPart_MechCluster = new QuestPart_MechCluster(); questPart_MechCluster.inSignal = QuestGenUtility.HardcodedSignalWithQuestID(inSignal.GetValue(slate)) ?? QuestGen.slate.Get <string>("inSignal"); questPart_MechCluster.tag = QuestGenUtility.HardcodedTargetQuestTagWithQuestID(tag.GetValue(slate)); questPart_MechCluster.mapParent = slate.Get <Map>("map").Parent; questPart_MechCluster.sketch = GenerateSketch(slate); QuestGen.quest.AddPart(questPart_MechCluster); string text = ""; if (questPart_MechCluster.sketch.pawns != null) { text += PawnUtility.PawnKindsToLineList(questPart_MechCluster.sketch.pawns.Select((MechClusterSketch.Mech m) => m.kindDef), " - ", ColoredText.ThreatColor); } string[] array = (from t in questPart_MechCluster.sketch.buildingsSketch.Things where GenHostility.IsDefMechClusterThreat(t.def) group t by t.def.label).Select(delegate(IGrouping <string, SketchThing> grp) { int num = grp.Count(); return(num + " " + ((num > 1) ? Find.ActiveLanguageWorker.Pluralize(grp.Key, num) : grp.Key)); }).ToArray(); if (array.Any()) { if (text != "") { text += "\n"; } text += array.ToLineList(ColoredText.ThreatColor, " - "); } if (text != "") { QuestGen.AddQuestDescriptionRules(new List <Rule> { new Rule_String("allThreats", text) }); } }
protected override bool TryExecuteWorker(IncidentParms parms) { //if(this.wo != null) //{ // this.wo.interactable = false; //} if (parms.target is Map) { return(IncidentDefOf.TravelerGroup.Worker.TryExecute(parms)); } Caravan caravan = (Caravan)parms.target; Faction faction = parms.faction; bool factionCanTrade = WorldUtility.FactionCanTrade(parms.faction); //if (parms.faction != null && factionCanTrade) //{ // faction = parms.faction; //} //else //{ // return false; //} List <Pawn> list = GenerateCaravanPawns(faction, wo.RimWarPoints); if (!list.Any()) { Log.Error("IncidentWorker_CaravanMeeting could not generate any pawns."); return(false); } Caravan metCaravan = CaravanMaker.MakeCaravan(list, faction, -1, addToWorldPawnsIfNotAlready: false); bool hostileToPlayer = faction.HostileTo(Faction.OfPlayer); CameraJumper.TryJumpAndSelect(caravan); DiaNode diaNode = new DiaNode((string)"CaravanMeeting".Translate(caravan.Name, faction.Name, PawnUtility.PawnKindsToLineList(from x in metCaravan.PawnsListForReading select x.kindDef, " - ")).CapitalizeFirst()); Pawn bestPlayerNegotiator = BestCaravanPawnUtility.FindBestNegotiator(caravan, faction, metCaravan.TraderKind); if (metCaravan.CanTradeNow) { DiaOption diaOption = new DiaOption("CaravanMeeting_Trade".Translate()); diaOption.action = delegate { Find.WindowStack.Add(new Dialog_Trade(bestPlayerNegotiator, metCaravan)); PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(metCaravan.Goods.OfType <Pawn>(), "LetterRelatedPawnsTradingWithOtherCaravan".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent); }; if (bestPlayerNegotiator == null) { if (metCaravan.TraderKind.permitRequiredForTrading != null && !caravan.pawns.Any(delegate(Pawn p) { if (p.royalty != null) { return(p.royalty.HasPermit(metCaravan.TraderKind.permitRequiredForTrading, faction)); } return(false); })) { RoyalTitleDef royalTitleDef = faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.First(delegate(RoyalTitleDef t) { if (t.permits != null) { return(t.permits.Contains(metCaravan.TraderKind.permitRequiredForTrading)); } return(false); }); diaOption.Disable("CaravanMeeting_NoPermit".Translate(royalTitleDef.GetLabelForBothGenders(), faction).Resolve()); } else if (hostileToPlayer) { diaOption.Disable("RW_CaravanMeeting_TradeUnwilling".Translate(faction.Name)); } else { diaOption.Disable("CaravanMeeting_TradeIncapable".Translate()); } } else if (!factionCanTrade) { diaOption.Disable("RW_CaravanMeeting_FactionIncapableOfTrade".Translate()); } diaNode.options.Add(diaOption); } DiaOption diaOption2 = new DiaOption("CaravanMeeting_Attack".Translate()); diaOption2.action = delegate { LongEventHandler.QueueLongEvent(delegate { Pawn t2 = caravan.PawnsListForReading[0]; faction.TrySetRelationKind(Faction.OfPlayer, FactionRelationKind.Hostile, true, "GoodwillChangedReason_AttackedCaravan".Translate(), t2); Map map = CaravanIncidentUtility.GetOrGenerateMapForIncident(caravan, new IntVec3(100, 1, 100), WorldObjectDefOf.AttackedNonPlayerCaravan); map.Parent.SetFaction(faction); MultipleCaravansCellFinder.FindStartingCellsFor2Groups(map, out IntVec3 playerSpot, out IntVec3 enemySpot); CaravanEnterMapUtility.Enter(caravan, map, (Pawn p) => CellFinder.RandomClosewalkCellNear(playerSpot, map, 12), CaravanDropInventoryMode.DoNotDrop, draftColonists: true); List <Pawn> list2 = metCaravan.PawnsListForReading.ToList(); CaravanEnterMapUtility.Enter(metCaravan, map, (Pawn p) => CellFinder.RandomClosewalkCellNear(enemySpot, map, 12)); LordMaker.MakeNewLord(faction, new LordJob_DefendAttackedTraderCaravan(list2[0].Position), map, list2); Find.TickManager.Notify_GeneratedPotentiallyHostileMap(); CameraJumper.TryJumpAndSelect(t2); PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(list2, "LetterRelatedPawnsGroupGeneric".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent, informEvenIfSeenBefore: true); wo.Destroy(); }, "GeneratingMapForNewEncounter", false, null);