private IEnumerable <Pawn> GenerateWanderingCaravans(PawnKindDef def) { int wanderingCaravansCount = def.RaceProps.wildness != 0 ? def.wildGroupSize.RandomInRange : Rand.Range(3, 9); for (int i = 0; i < wanderingCaravansCount; i++) { yield return(WanderingCaravansUtility.GenerateWanderingCaravan(def)); } }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; if (!this.TryResolveParms(parms, out PawnKindDef chasedCaravanDef)) { return(false); } DiaNode descDiaNode = new DiaNode($"A group of {parms.faction.def.pawnsPlural} from {parms.faction.Name} can be seen in the distance, and are chasing down a " + $"trade caravan carrying a potentially valuable inventory.\n\nYou can either defend the caravan from the {parms.faction.def.pawnsPlural} and obtain its " + $"inventory or let them have it.\n\nBe warned - if you accept, you'll have to fight off the {parms.faction.def.pawnsPlural} on its tail."); descDiaNode.options.Add(new DiaOption("Defend the caravan") { action = delegate { Pawn chasedCaravan = WanderingCaravansUtility.GenerateWanderingCaravan(chasedCaravanDef); chasedCaravan.SetFaction(Faction.OfPlayer); GenSpawn.Spawn(chasedCaravan, parms.spawnCenter, map); CameraJumper.TryJump(chasedCaravan); IncidentParms incidentParams = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map); incidentParams.forced = true; incidentParams.faction = parms.faction; incidentParams.raidStrategy = RaidStrategyDefOf.ImmediateAttack; incidentParams.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn; incidentParams.spawnCenter = parms.spawnCenter; incidentParams.points = parms.points; Find.Storyteller.incidentQueue.Add(new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, incidentParams), Find.TickManager.TicksGame + new IntRange(1000, 2500).RandomInRange)); }, resolveTree = true }); DiaNode rejectDiaNode = new DiaNode("The hunters have almost caught up to the caravan and will be able to obtain its potentially valuable items."); rejectDiaNode.options.Add(new DiaOption("OK") { resolveTree = true }); descDiaNode.options.Add(new DiaOption($"Let the {parms.faction.def.pawnsPlural} have it") { link = rejectDiaNode }); Find.WindowStack.Add(new Dialog_NodeTree(descDiaNode, true, true, "Wandering caravan chased to " + map.info.parent.Label)); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; if (!this.TryResolveParms(parms, out PawnKindDef chasedCaravanDef)) { return(false); } DiaNode descDiaNode = new DiaNode($"WanderingCaravan.CaravanChased_OptionText".Translate(parms.faction.def.pawnsPlural, parms.faction.Name)); descDiaNode.options.Add(new DiaOption("WanderingCaravan.CaravanChased_OptionDefend".Translate()) { action = delegate { Pawn chasedCaravan = WanderingCaravansUtility.GenerateWanderingCaravan(chasedCaravanDef); chasedCaravan.SetFaction(Faction.OfPlayer); GenSpawn.Spawn(chasedCaravan, parms.spawnCenter, map); CameraJumper.TryJump(chasedCaravan); IncidentParms incidentParams = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map); incidentParams.forced = true; incidentParams.faction = parms.faction; incidentParams.raidStrategy = RaidStrategyDefOf.ImmediateAttack; incidentParams.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn; incidentParams.spawnCenter = parms.spawnCenter; incidentParams.points = parms.points; Find.Storyteller.incidentQueue.Add(new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, incidentParams), Find.TickManager.TicksGame + new IntRange(1000, 2500).RandomInRange)); }, resolveTree = true }); DiaNode rejectDiaNode = new DiaNode("WanderingCaravan.CaravanChased_Rejected".Translate(parms.faction.def.pawnsPlural)); rejectDiaNode.options.Add(new DiaOption("OK") { resolveTree = true }); descDiaNode.options.Add(new DiaOption($"WanderingCaravan.CaravanChased_OptionReject".Translate(parms.faction.def.pawnsPlural)) { link = rejectDiaNode }); Find.WindowStack.Add(new Dialog_NodeTree(descDiaNode, true, true, "WanderingCaravan.CaravanChased_OptionTitle".Translate(map.info.parent.Label))); return(true); }