protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; IntVec3 intVec; if (!this.TryFindEntryCell(map, out intVec)) { return(false); } PawnKindDef thrumbo = ThrumboDefOf.BlondThrumboPawn; float num = StorytellerUtility.DefaultThreatPointsNow(map); int num2 = GenMath.RoundRandom(num / thrumbo.combatPower); int max = Rand.RangeInclusive(2, 16); num2 = Mathf.Clamp(num2, 1, max); int num3 = Rand.RangeInclusive(90000, 150000); IntVec3 invalid = IntVec3.Invalid; if (!RCellFinder.TryFindRandomCellOutsideColonyNearTheCenterOfTheMap(intVec, map, 10f, out invalid)) { invalid = IntVec3.Invalid; } Pawn pawn = null; for (int i = 0; i < num2; i++) { IntVec3 loc = CellFinder.RandomClosewalkCellNear(intVec, map, 10, null); pawn = PawnGenerator.GeneratePawn(thrumbo, null); GenSpawn.Spawn(pawn, loc, map, Rot4.Random, WipeMode.Vanish, false); pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + num3; if (invalid.IsValid) { pawn.mindState.forcedGotoPosition = CellFinder.RandomClosewalkCellNear(invalid, map, 10, null); } } Find.LetterStack.ReceiveLetter("LetterLabelGingerThrumboPasses".Translate(thrumbo.label).CapitalizeFirst(), "LetterGingerThrumboPassesDesc".Translate(thrumbo.label), LetterDefOf.PositiveEvent, pawn, null, null); return(true); }
public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false) { this.separateChannel = separateChannel; this.Viewer = viewer; string[] command = message.Split(' '); if (command.Length < 3) { Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel); return(false); } if (!VariablesHelpers.PointsWagerIsValid( command[2], viewer, ref pointsWager, ref storeIncident, separateChannel )) { return(false); } target = Current.Game.AnyPlayerHomeMap; if (target == null) { return(false); } parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.RaidBeacon, target); parms.points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, parms.points); parms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; parms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn; worker = new Incidents.IncidentWorker_RaidEnemy(); worker.def = IncidentDefOf.RaidEnemy; return(worker.CanFireNow(parms)); }
public override bool ManualDeterminParams() { Map map = (Map)parms.target; if (!this.TryFindEntryCell(map, out intVec)) { return(false); } AnimalType = PawnKindDefOf.Thrumbo; float num = StorytellerUtility.DefaultThreatPointsNow(map); AnimalNum = GenMath.RoundRandom(num / AnimalType.combatPower); int max = Rand.RangeInclusive(2, 4); AnimalNum = Mathf.Clamp(AnimalNum, 1, max); invalid = IntVec3.Invalid; if (!RCellFinder.TryFindRandomCellOutsideColonyNearTheCenterOfTheMap(intVec, map, 10f, out invalid)) { invalid = IntVec3.Invalid; } lookTargets = new TargetInfo(intVec, map, false); return(true); }
private void Finished() { List <Pawn> ownedPawns = this.lord.ownedPawns; int num = 0; for (int i = 0; i < ownedPawns.Count; i++) { if (GatheringsUtility.InGatheringArea(ownedPawns[i].Position, this.spot, base.Map)) { ownedPawns[i].needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("AttendedElection"), null); num++; } } if (num != 0) { IncidentParms parms = StorytellerUtility.DefaultParmsNow(IncidentDef.Named("SetLeadership").category, this.Map); IncidentDef.Named("SetLeadership").Worker.TryExecute(parms); } else { Messages.Message("ElectionNoAttendees".Translate(), MessageTypeDefOf.RejectInput); } }
public void TryFireFlareRaid(Map map) { //int ticksGame = Find.TickManager.TicksGame; //if (GlobalLastFireTick > 0 && (ticksGame - GlobalLastFireTick) / 60000f < FlareRaidDef.minRefireDays) //{ // return false; //} if (!Rand.Chance(SolarRaid_IncidentWorker.ChanceForFlareRaid(map))) { return; } IncidentParms newParms = StorytellerUtility.DefaultParmsNow(FlareRaidDef.category, map); if (!FlareRaidDef.Worker.CanFireNow(newParms)) { return; } Find.Storyteller.TryFire(new FiringIncident(FlareRaidDef, null, newParms)); }
public override bool IsPossible() { ToolkitPatchLogger.Log(incidentDef.defName, "Checking if possible.."); worker = GetWorker(); worker.def = incidentDef; if (target != null) { parms = StorytellerUtility.DefaultParmsNow(incidentCategoryDef, target); parms.forced = shouldForceFire; bool success = worker.CanFireNow(parms); if (!success) { WorkerCanFireCheck.CheckDefaultFireNowConditions(worker, parms, incidentDef); } ToolkitPatchLogger.Log(incidentDef.defName, $"Can fire with params '{parms.ToString()}' on worker {worker.ToString()}? {success}"); return(success); } ToolkitPatchLogger.ErrorLog(incidentDef.defName, $"Failed to get target. Cannot fire"); return(false); }
private void Finished() { List <Pawn> ownedPawns = this.lord.ownedPawns; int num = 0; for (int i = 0; i < ownedPawns.Count; i++) { if (PartyUtility.InPartyArea(ownedPawns[i].Position, this.spot, base.Map)) { ownedPawns[i].needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("AttendedElection"), null); num++; } } if (num != 0) { IncidentParms parms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentDef.Named("LeaderElection").category, this.Map); IncidentDef.Named("LeaderElection").Worker.TryExecute(parms); } else { Messages.Message("ElectionNoAttendees".Translate(), MessageSound.Negative); } }
public override void WorldComponentTick() { base.WorldComponentTick(); if (Find.AnyPlayerHomeMap == null) { return; } if (Find.TickManager.TicksGame >= occuringTick) { IncidentParms parms = StorytellerUtility.DefaultParmsNow(incident.category, Find.Maps.Where(x => x.IsPlayerHome).RandomElement()); if (incident.Worker.TryExecute(parms)) { occuringTick += IntervalTicks; } else { occuringTick += GenDate.TicksPerDay; } } }
public override void PostMapGenerate() { if (!active) { return; } MapParent map = (MapParent)parent; // Balance List <PawnKindDef> kindDefs = new List <PawnKindDef> { DefDatabase <PawnKindDef> .GetNamed("Mercenary_Elite"), DefDatabase <PawnKindDef> .GetNamed("Town_Guard"), DefDatabase <PawnKindDef> .GetNamed("Grenadier_Destructive") }; Lord lord = LordMaker.MakeNewLord(ally, new LordJob_AssaultColony(ally, false), map.Map); if (!RCellFinder.TryFindRandomPawnEntryCell(out IntVec3 vec3, map.Map, 0.2f)) { return; } Utilities.GenerateFighter(Mathf.Clamp(StorytellerUtility.DefaultThreatPointsNow(Find.AnyPlayerHomeMap), 400, 1500), lord, kindDefs, map.Map, ally, vec3); }
public override bool IsPossible() { ToolkitPatchLogger.Log(incidentDef.defName, "Checking if possible.."); worker = GetWorker(); worker.def = incidentDef; float points = StorytellerUtility.DefaultThreatPointsNow(target); parms = StorytellerUtility.DefaultParmsNow(category, target); parms.forced = shouldForceFire; parms.points = points; bool success = worker.CanFireNow(parms); if (!success) { WorkerCanFireCheck.CheckDefaultFireNowConditions(worker, parms, incidentDef); } ToolkitPatchLogger.Log(incidentDef.defName, $"Can fire with params '{parms.ToString()}' on worker {worker.ToString()}? {success}"); return(success); }
public static void Postfix(IncidentWorker_RaidEnemy __instance, ref IncidentParms parms, bool __result) { if (__result) { if (parms.faction.def == XenomorphDefOf.RRY_Xenomorph && parms.raidStrategy != XenomorphDefOf.RRY_PowerCut) { Map map = (Map)parms.target; if (map.listerBuildings.allBuildingsColonist.Any(x => x.TryGetComp <CompPowerPlant>() != null)) { Rand.PushState(); int @int = Rand.Int; bool chance = Rand.ChanceSeeded(0.1f, @int); Rand.PopState(); if (AvP_IncidentWorker_RaidEnemy_TryExecute_PowerCut_Patch.TryFindSpawnSpot(map, out IntVec3 intVec) && chance) { IncidentParms raidParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map); raidParms.forced = true; raidParms.faction = parms.faction; raidParms.raidStrategy = XenomorphDefOf.RRY_PowerCut; raidParms.raidArrivalMode = XenomorphDefOf.RRY_DropThroughRoofNearPower; raidParms.spawnCenter = intVec; raidParms.generateFightersOnly = true; Rand.PushState(); raidParms.points = Mathf.Max((raidParms.points / 5) * AvP_IncidentWorker_RaidEnemy_TryExecute_PowerCut_Patch.RaidPointsFactorRange.RandomInRange, 500f); Rand.PopState(); raidParms.pawnGroupMakerSeed = new int?(@int); PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, raidParms, true); defaultPawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(defaultPawnGroupMakerParms.points, XenomorphDefOf.RRY_DropThroughRoofNearPower, XenomorphDefOf.RRY_PowerCut, defaultPawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat); IEnumerable <PawnKindDef> pawnKinds = PawnGroupMakerUtility.GeneratePawnKindsExample(defaultPawnGroupMakerParms); QueuedIncident qi = new QueuedIncident(new FiringIncident(XenomorphDefOf.RRY_PowerCut_Xenomorph, null, raidParms), Find.TickManager.TicksGame + AvP_IncidentWorker_RaidEnemy_TryExecute_PowerCut_Patch.RaidDelay.RandomInRange, 0); Find.Storyteller.incidentQueue.Add(qi); } } } } }
public override void MapComponentTick() { base.MapComponentTick(); //We don't need to run all that often if (Find.TickManager.TicksGame % 531 == 0 && GenDate.DaysPassed > 8) { CleanIncidentQueue(null); foreach (KeyValuePair <Faction, int> kvp in NextFactionInteraction) { if (Find.TickManager.TicksGame >= kvp.Value) { Faction faction = kvp.Key; IncidentDef incident = IncomingIncidentDef(faction) ?? IncomingIncidentDef(faction); // "try again" null-check. IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(incCat: incident.category, target: map); incidentParms.faction = faction; //forced, because half the time game doesn't feel like firing events. incidentParms.forced = true; //trigger incident somewhere between half a day and 3 days from now Find.Storyteller.incidentQueue.Add(def: incident, fireTick: Find.TickManager.TicksGame + Rand.Range(min: GenDate.TicksPerDay / 2, max: GenDate.TicksPerDay * 3), parms: incidentParms, retryDurationTicks: 2500); NextFactionInteraction[key : faction] = Find.TickManager.TicksGame + (int)(FactionInteractionTimeSeperator.TimeBetweenInteraction.Evaluate(faction.PlayerGoodwill) * MoreFactionInteraction_Settings.timeModifierBetweenFactionInteraction); //kids, you shouldn't change values you iterate over. break; } } } }
protected virtual void ReinforcementsArrived() { if (!CellFinder.TryFindRandomEdgeCellWith((IntVec3 x) => x.Standable(Map) && Map.reachability.CanReachColony(x), Map, CellFinder.EdgeRoadChance_Hostile, out IntVec3 edgeCell)) { return; } IncidentParms parms = new IncidentParms() { target = Map, points = StorytellerUtility.DefaultThreatPointsNow(Find.CurrentMap), faction = reinforcementsFrom.Faction }; PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, parms, false); defaultPawnGroupMakerParms.generateFightersOnly = true; defaultPawnGroupMakerParms.dontUseSingleUseRocketLaunchers = true; List <Pawn> enemies = PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms, true).ToList(); for (int i = 0; i < enemies.Count; i++) { IntVec3 loc = CellFinder.RandomSpawnCellForPawnNear(edgeCell, Map, 4); GenSpawn.Spawn(enemies[i], loc, Map, Rot4.Random, WipeMode.Vanish, false); } LordJob lordJob = CreateLordJob(enemies, parms); if (lordJob != null) { LordMaker.MakeNewLord(parms.faction, lordJob, Map, enemies); } var letter = LetterMaker.MakeLetter("ReinforcementsArrivedLabel".Translate(), "ReinforcementsArrived".Translate(reinforcementsFrom.Label), LetterDefOf.ThreatBig, reinforcementsFrom.Faction); Find.LetterStack.ReceiveLetter(letter); ticksTillReinforcements = Mathf.RoundToInt(pathToSite.TotalCost * scaleFactor.RandomInRange); }
protected override bool TryExecuteWorker(IncidentParms parms) { if (!settings.Active) { return(false); } if (!TryGetTwoFactions(out Faction faction1, out Faction faction2)) { return(false); } Map map = (Map)parms.target; parms.points = StorytellerUtility.DefaultThreatPointsNow(parms.target); IntVec3 existingMapEdgeCell1 = IntVec3.Invalid; IntVec3 existingMapEdgeCell2 = IntVec3.Invalid; if (!TryFindEntryCell(map, out existingMapEdgeCell1)) { return(false); } if (!TryFindEntryCell(map, out existingMapEdgeCell2)) { return(false); } GenerateAndSpawnPawns(faction1, parms, existingMapEdgeCell1); GenerateAndSpawnPawns(faction2, parms, existingMapEdgeCell2); SendStandardLetter(parms, null); return(true); }
public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false) { this.separateChannel = separateChannel; this.viewer = viewer; string[] command = message.Split(' '); if (command.Length < 3) { VariablesHelpers.ViewerDidWrongSyntax(viewer.username, storeIncident.syntax, separateChannel); return(false); } if (!VariablesHelpers.PointsWagerIsValid( command[2], viewer, ref pointsWager, ref storeIncident, separateChannel )) { return(false); } target = Current.Game.AnyPlayerHomeMap; if (target == null) { return(false); } parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.RaidBeacon, target); parms.points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, parms.points); worker = new IncidentWorker_ManhunterPack(); worker.def = IncidentDefOf.RaidEnemy; return(worker.CanFireNow(parms)); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; if (!TryFindEntryCell(map, out var cell)) { return(false); } PawnKindDef AnimaThrumbo = PawnKindDef.Named("AnimaThrumbo"); int value = GenMath.RoundRandom(StorytellerUtility.DefaultThreatPointsNow(map) / AnimaThrumbo.combatPower); int max = Rand.RangeInclusive(3, 6); value = Mathf.Clamp(value, 2, max); int num = Rand.RangeInclusive(90000, 150000); IntVec3 result = IntVec3.Invalid; if (!RCellFinder.TryFindRandomCellOutsideColonyNearTheCenterOfTheMap(cell, map, 10f, out result)) { result = IntVec3.Invalid; } Pawn pawn = null; for (int i = 0; i < value; i++) { IntVec3 loc = CellFinder.RandomClosewalkCellNear(cell, map, 10); pawn = PawnGenerator.GeneratePawn(AnimaThrumbo); GenSpawn.Spawn(pawn, loc, map, Rot4.Random); pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + num; if (result.IsValid) { pawn.mindState.forcedGotoPosition = CellFinder.RandomClosewalkCellNear(result, map, 10); } } SendStandardLetter("LetterLabelThrumboPasses".Translate(AnimaThrumbo.label).CapitalizeFirst(), "LetterThrumboPasses".Translate(AnimaThrumbo.label), LetterDefOf.PositiveEvent, parms, pawn); return(true); }
protected void CaravanAmbushHumansNoTreasure(Caravan caravan) { 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; } incidentParms.faction = Find.FactionManager.RandomEnemyFaction(); 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(incidentParms.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("LetterLabelIMAmbushLGE".Translate(), "LetterIMAmbushLGE".Translate(), LetterDefOf.ThreatBig, lookTarget, null); }, "GeneratingMapForNewEncounter", false, null); }
private static DiaOption CreateAcceptOption(Pawn refugee, IntVec3 spawnSpot, Map map, Faction enemyFac) { DiaOption diaOption = new DiaOption("RefugeeChasedInitial_Accept".Translate()); diaOption.action = delegate { GenSpawn.Spawn(refugee, spawnSpot, map); refugee.SetFaction(Faction.OfPlayer, null); Find.CameraDriver.JumpToVisibleMapLoc(spawnSpot); IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentCategory.ThreatBig, map); incidentParms.forced = true; incidentParms.faction = enemyFac; incidentParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; incidentParms.raidArrivalMode = PawnsArriveMode.EdgeWalkIn; incidentParms.spawnCenter = spawnSpot; incidentParms.points *= 1.35f; IntRange raidDelay = (IntRange)typeof(IncidentWorker_RefugeeChased).GetField("RaidDelay", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null); QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, incidentParms), Find.TickManager.TicksGame + raidDelay.RandomInRange); Find.Storyteller.incidentQueue.Add(qi); }; diaOption.resolveTree = true; return(diaOption); }
public override bool TryExecuteEvent() { List <IncidentDef> incidents = DefDatabase <IncidentDef> .AllDefsListForReading.ToList(); Rand.PushState(); incidents.Shuffle(); Rand.PopState(); IIncidentTarget target = WorldRendererUtility.WorldRenderedNow ? (Find.WorldSelector.SingleSelectedObject as IIncidentTarget) : null; if (target is null) { target = Find.CurrentMap; } if (target is null) { Messages.Message("FailedTargetFinder".Translate(), MessageTypeDefOf.RejectInput); return(false); } foreach (IncidentDef incident in incidents) { try { var parms = StorytellerUtility.DefaultParmsNow(incident.category, target); if (incident.Worker.CanFireNow(parms) && incident.Worker.TryExecute(parms)) { return(true); } } catch { } } Messages.Message("FailedRewardEvent".Translate(defName), MessageTypeDefOf.RejectInput); return(false); }
protected override void Generate(ThingSetMakerParams parms, List <Thing> outThings) { IntRange?countRange = parms.countRange; int randomInRange = ((countRange == null) ? ThingSetMaker_SpecialMeteorite.MineablesCountRange : countRange.Value).RandomInRange; ThingDef def = this.FindRandomMineableDef(); for (int i = 0; i < randomInRange; i++) { Building building = (Building)ThingMaker.MakeThing(def, null); building.canChangeTerrainOnDestroyed = false; outThings.Add(building); } PawnKindDef skyeel = PawnKindDef.Named("AA_Skyeel"); Map mapPlayerHome = null; List <Map> maps = Find.Maps; for (int i = 0; i < maps.Count; i++) { if (maps[i].IsPlayerHome) { mapPlayerHome = maps[i]; } } float num = StorytellerUtility.DefaultThreatPointsNow(mapPlayerHome); int num2 = GenMath.RoundRandom(num / skyeel.combatPower); int max = Rand.RangeInclusive(5, 20); num2 = Mathf.Clamp(num2, 4, max); for (int i = 0; i < num2; i++) { Pawn pawn = PawnGenerator.GeneratePawn(skyeel, null); outThings.Add(pawn); } }
public void QueueFactionArrival(Faction faction, Map map) { //TODO: check if it works IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.FactionArrival, map); incidentParms.forced = true; IntVec3 spawnCenter; if (RCellFinder.TryFindRandomPawnEntryCell(out spawnCenter, map, 0f, false, (IntVec3 v) => v.Standable(map))) { incidentParms.spawnCenter = spawnCenter; } IntVec3 spawnCenter2; if (CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => map.reachability.CanReachColony(c), map, CellFinder.EdgeRoadChance_Neutral, out spawnCenter2)) { incidentParms.faction = faction; incidentParms.spawnCenter = spawnCenter2; incidentParms.points *= 4f; incidentParms.points = Math.Max(incidentParms.points, 250f); QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.TravelerGroup, null, incidentParms), Find.TickManager.TicksGame + Rand.RangeInclusive(5000, 15000)); Find.Storyteller.incidentQueue.Add(qi); } }
public void UnlockQuest(Pawn pawn) { if (this.questToUnlock != null) { Slate slate = new Slate(); slate.Set("points", StorytellerUtility.DefaultThreatPointsNow(pawn.Map)); if (this.questToUnlock == QuestScriptDefOf.LongRangeMineralScannerLump) { slate.Set("targetMineable", ThingDefOf.MineableGold); slate.Set("worker", PawnsFinder.AllMaps_FreeColonists.FirstOrDefault()); } Quest quest = QuestGen.Generate(this.questToUnlock, slate); Find.SignalManager.RegisterReceiver(quest); List <QuestPart> partsListForReading = quest.PartsListForReading; for (int i = 0; i < partsListForReading.Count; i++) { partsListForReading[i].PostQuestAdded(); } quest.Initiate(); this.used = true; Find.LetterStack.ReceiveLetter("VBE.LocationsOpened".Translate(), "VBE.LocationsOpenedDesc".Translate(), LetterDefOf.NeutralEvent, quest.QuestLookTargets.Where(t => t.IsWorldTarget || t.IsMapTarget).FirstOrDefault()); } }
private void Outcome_Disaster(Caravan caravan) { Faction.TryAffectGoodwillWith(Faction.OfPlayer, -40); bool chance = Rand.Chance(0.5f); Settlement s = chance ? Set1 : Set2; Settlement turncoat = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement); turncoat.SetFaction(Find.FactionManager.AllFactionsVisible.Where(f => !f.IsPlayer && f.HostileTo(Faction.OfPlayer)).RandomElementWithFallback(null)); turncoat.Tile = s.Tile; turncoat.Name = s.Name; if (turncoat.Faction == null) { Outcome_Fail(caravan); return; } Settlement friendly = chance ? Set2 : Set1; Find.WorldObjects.Remove(s); Find.WorldObjects.Remove(chance ? Set2 : Set1); Find.WorldObjects.Add(turncoat); Site ambush = SiteMaker.MakeSite(SiteCoreDefOf.Nothing, SitePartDefOf.AmbushEdge, Tile, turncoat.Faction, true, StorytellerUtility.DefaultSiteThreatPointsNow()); Find.LetterStack.ReceiveLetter("LetterLabelDisputeDisaster".Translate(), "DisputeDisaster".Translate(turncoat, turncoat.Faction, friendly) , LetterDefOf.ThreatBig, turncoat, null, "Disaster"); LongEventHandler.QueueLongEvent(new Action(() => { MapGenerator.GenerateMap(new IntVec3(110, 1, 110), ambush, MapGeneratorDefOf.Encounter); List <PawnKindDef> kindDefs = new List <PawnKindDef>(); for (int i = 0; i < 2; i++) { kindDefs.Clear(); Lord lord = LordMaker.MakeNewLord(i == 0 ? turncoat.Faction : Faction, new LordJob_AssaultColony(i == 0 ? turncoat.Faction : Faction), ambush.Map); kindDefs = Utilities.GeneratePawnKindDef(45, i == 0 ? turncoat.Faction : Faction); // Balance IntVec3 vec = CellFinder.RandomClosewalkCellNear(new IntVec3(ambush.Map.Center.x - 30 + (i * 60), ambush.Map.Center.y, ambush.Map.Center.z), ambush.Map, 10); Utilities.GenerateFighter(StorytellerUtility.DefaultSiteThreatPointsNow() + 300, lord, kindDefs, ambush.Map, i == 0 ? turncoat.Faction : Faction, vec); } CaravanEnterMapUtility.Enter(caravan, ambush.Map, CaravanEnterMode.Center, CaravanDropInventoryMode.DoNotDrop, true); }), "GeneratingMapForNewEncounter", false, null); Utilities.FactionsWar().GetByFaction(turncoat.Faction).resources += FE_WorldComp_FactionsWar.SETTLEMENT_RESOURCE_VALUE * 2; Utilities.FactionsWar().GetByFaction(friendly.Faction).resources -= FE_WorldComp_FactionsWar.SETTLEMENT_RESOURCE_VALUE * 2; Find.WorldObjects.Remove(this); }
private void Outcome_Backfire(Caravan caravan) { Faction.TryAffectGoodwillWith(Faction.OfPlayer, -25); Settlement turncoat, friendly; bool chance = Rand.Chance(0.5f); Settlement s = chance ? Set1 : Set2; turncoat = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement); turncoat.SetFaction(Find.FactionManager.AllFactionsVisible.Where(f => !f.IsPlayer && f.HostileTo(Faction.OfPlayer)).RandomElementWithFallback(null)); turncoat.Tile = s.Tile; turncoat.Name = s.Name; if (turncoat.Faction == null) { Outcome_Fail(caravan); return; } Thing silver = ThingMaker.MakeThing(ThingDefOf.Silver); silver.stackCount = (int)FE_IncidentWorker_Jointraid.SilverBonusRewardCurve.Evaluate(Set2.Faction.PlayerGoodwill); List <Thing> rewards = ThingSetMakerDefOf.Reward_StandardByDropPod.root.Generate(new ThingSetMakerParams() { totalMarketValueRange = new FloatRange?(SiteTuning.BanditCampQuestRewardMarketValueRange * SiteTuning.QuestRewardMarketValueThreatPointsFactor.Evaluate(StorytellerUtility.DefaultSiteThreatPointsNow())) }); friendly = chance ? Set2 : Set1; turncoat.GetComponent <WorldComp_JointRaid>().StartComp(new IntRange(Global.DayInTicks * 15, Global.DayInTicks * 25).RandomInRange, friendly.Faction, rewards, silver); Find.WorldObjects.Remove(s); Find.WorldObjects.Add(turncoat); Utilities.FactionsWar().GetByFaction(turncoat.Faction).resources += FE_WorldComp_FactionsWar.SETTLEMENT_RESOURCE_VALUE * 2; Utilities.FactionsWar().GetByFaction(friendly.Faction).resources -= FE_WorldComp_FactionsWar.SETTLEMENT_RESOURCE_VALUE * 2; Find.LetterStack.ReceiveLetter("LetterLabelDisputeBackfire".Translate(), "DisputeBackfire".Translate(turncoat, turncoat.Faction, friendly) , LetterDefOf.ThreatBig, turncoat, Faction, null); Find.WorldObjects.Remove(this); }
protected override void ResolveRaidPoints(IncidentParms parms) { parms.points = StorytellerUtility.DefaultThreatPointsNow(parms.target); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; if (!TryFindSpawnSpot(map, out IntVec3 spawnSpot)) { return(false); } if (!TryFindEnemyFaction(out Faction enemyFac)) { return(false); } int @int = Rand.Int; IncidentParms raidParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map); raidParms.forced = true; raidParms.faction = enemyFac; raidParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; raidParms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn; raidParms.spawnCenter = spawnSpot; raidParms.points = Mathf.Max(raidParms.points * RaidPointsFactorRange.RandomInRange, enemyFac.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat)); raidParms.pawnGroupMakerSeed = @int; PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, raidParms); defaultPawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(defaultPawnGroupMakerParms.points, raidParms.raidArrivalMode, raidParms.raidStrategy, defaultPawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat); IEnumerable <PawnKindDef> pawnKinds = PawnGroupMakerUtility.GeneratePawnKindsExample(defaultPawnGroupMakerParms); PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDefOf.SpaceRefugee, null, PawnGenerationContext.NonPlayer, -1, forceGenerateNewPawn: false, newborn: false, allowDead: false, allowDowned: false, canGeneratePawnRelations: true, mustBeCapableOfViolence: false, colonistRelationChanceFactor: 20f); Pawn refugee = PawnGenerator.GeneratePawn(request); refugee.relations.everSeenByPlayer = true; string text = "RefugeeChasedInitial".Translate(refugee.Name.ToStringFull, refugee.story.Title, enemyFac.def.pawnsPlural, enemyFac.Name, refugee.ageTracker.AgeBiologicalYears, PawnUtility.PawnKindsToCommaList(pawnKinds, useAnd: true), refugee.Named("PAWN")); text = text.AdjustedFor(refugee); TaggedString temp = new TaggedString(text); PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref temp, refugee); DiaNode diaNode = new DiaNode(text); DiaOption diaOption = new DiaOption("RefugeeChasedInitial_Accept".Translate()); diaOption.action = delegate { GenSpawn.Spawn(refugee, spawnSpot, map); refugee.SetFaction(Faction.OfPlayer); CameraJumper.TryJump(refugee); QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, raidParms), Find.TickManager.TicksGame + RaidDelay.RandomInRange); Find.Storyteller.incidentQueue.Add(qi); }; diaOption.resolveTree = true; diaNode.options.Add(diaOption); string text2 = "RefugeeChasedRejected".Translate(refugee.LabelShort, refugee); DiaNode diaNode2 = new DiaNode(text2); DiaOption diaOption2 = new DiaOption("OK".Translate()); diaOption2.resolveTree = true; diaNode2.options.Add(diaOption2); DiaOption diaOption3 = new DiaOption("RefugeeChasedInitial_Reject".Translate()); diaOption3.action = delegate { Find.WorldPawns.PassToWorld(refugee); }; diaOption3.link = diaNode2; diaNode.options.Add(diaOption3); string title = "RefugeeChasedTitle".Translate(map.Parent.Label); Find.WindowStack.Add(new Dialog_NodeTreeWithFactionInfo(diaNode, enemyFac, delayInteractivity: true, radioMode: true, title: title)); Find.Archive.Add(new ArchivedDialog(diaNode.text, title, enemyFac)); return(true); }
public override void Tick() { base.Tick(); if (progress >= 0) { progress += 1f / this.duration; if (unSpentFuse == null && !oneRaidPerProgress) { mechRaidProgress++; if (mechRaidProgress > mechRaidInterval) { if (Find.FactionManager.FirstFactionOfDef(FactionDefOf.Mechanoid) != null) { IncidentParms parms = new IncidentParms(); parms.target = this.Map; parms.faction = Faction.OfMechanoids; parms.points = StorytellerUtility.DefaultThreatPointsNow(parms.target) * 2.5f; parms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; parms.raidArrivalMode = PawnsArrivalModeDefOf.CenterDrop; IncidentDef def = IncidentDefOf.RaidEnemy; def.Worker.TryExecute(parms); oneRaidPerProgress = true; } mechRaidProgress = 0; } } if (progress >= 1) { progress = -1f; this.Map.mapDrawer.MapMeshDirty(this.Position, MapMeshFlag.Things | MapMeshFlag.Buildings); Pawn innerPawn = this.innerContainer?.FirstOrFallback() as Pawn; PawnKindDef kindDef = innerPawn?.kindDef.GetModExtension <DefExtension_Paragon>()?.mechToConvertTo; Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(kindDef, Faction.OfPlayer, fixedBiologicalAge: 1, fixedChronologicalAge: 1, newborn: false, forceGenerateNewPawn: true)); IntVec3 near = CellFinder.StandableCellNear(this.Position, this.Map, 5f); GenSpawn.Spawn(pawn, near, this.Map); pawn.health.AddHediff(InternalDefOf.GR_RecentlyHatched); pawn.health.AddHediff(InternalDefOf.GR_AnimalControlHediff); if (innerPawn.Name != null && !innerPawn.Name.ToString().UncapitalizeFirst().Contains(innerPawn.def.label)) { pawn.Name = innerPawn.Name; } if (innerPawn.training != null) { pawn.training = innerPawn.training; } if (innerPawn.relations != null) { pawn.relations = innerPawn.relations; } if (innerPawn.playerSettings != null && innerPawn.playerSettings.AreaRestriction != null) { pawn.playerSettings.AreaRestriction = innerPawn.playerSettings.AreaRestriction; } QualityCategory quality = innerPawn.TryGetComp <CompHybrid>()?.quality ?? QualityCategory.Normal; CompHybrid comp = pawn.TryGetComp <CompHybrid>(); if (comp != null) { comp.quality = quality; } if (unSpentFuse != null) { unSpentFuse.active = false; GenExplosion.DoExplosion(unSpentFuse.Position, this.Map, 2.9f, DamageDefOf.Flame, this, -1, -1, null, null, null, null, null, 0f, 1, false, null, 0f, 1); } this.DestroyContents(); } } }
public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target) { if (VoteHandler.voteActive) { yield break; } float acceptFraction = 1f; if (this.Props.acceptFractionByDaysPassedCurve != null) { acceptFraction *= this.Props.acceptFractionByDaysPassedCurve.Evaluate(GenDate.DaysPassedFloat); } if (this.Props.acceptPercentFactorPerThreatPointsCurve != null) { acceptFraction *= this.Props.acceptPercentFactorPerThreatPointsCurve.Evaluate(StorytellerUtility.DefaultThreatPointsNow(target)); } int incCount = IncidentCycleUtility.IncidentCountThisInterval(target, Find.Storyteller.storytellerComps.IndexOf(this), this.Props.minDaysPassed, this.Props.onDays, this.Props.offDays, this.Props.minSpacingDays, this.Props.numIncidentsRange.min, this.Props.numIncidentsRange.max, acceptFraction); for (int i = 0; i < incCount; i++) { Helper.Log("Trying to gen OFC Inc"); FiringIncident fi = this.GenerateIncident(target); if (fi != null) { yield return(fi); } } yield break; }
public static void QuestDefs() { Slate slate = new Slate(); slate.Set("points", StorytellerUtility.DefaultThreatPointsNow(Find.World)); DebugTables.MakeTablesDialog(from x in DefDatabase <QuestScriptDef> .AllDefs orderby x.IsRootRandomSelected descending, x.IsRootDecree descending select x, new TableDataGetter <QuestScriptDef>("defName", (QuestScriptDef d) => d.defName), new TableDataGetter <QuestScriptDef>("points\nmin", (QuestScriptDef d) => (!(d.rootMinPoints > 0f)) ? "" : d.rootMinPoints.ToString()), new TableDataGetter <QuestScriptDef>("progress\nmin", (QuestScriptDef d) => (!(d.rootMinProgressScore > 0f)) ? "" : d.rootMinProgressScore.ToString()), new TableDataGetter <QuestScriptDef>("increases\npop", (QuestScriptDef d) => d.rootIncreasesPopulation.ToStringCheckBlank()), new TableDataGetter <QuestScriptDef>("root\nweight", (QuestScriptDef d) => (!(d.rootSelectionWeight > 0f)) ? "" : d.rootSelectionWeight.ToString()), new TableDataGetter <QuestScriptDef>("decree\nweight", (QuestScriptDef d) => (!(d.decreeSelectionWeight > 0f)) ? "" : d.decreeSelectionWeight.ToString()), new TableDataGetter <QuestScriptDef>("decree\ntags", (QuestScriptDef d) => d.decreeTags.ToCommaList()), new TableDataGetter <QuestScriptDef>("auto\naccept", (QuestScriptDef d) => d.autoAccept.ToStringCheckBlank()), new TableDataGetter <QuestScriptDef>("expiry\ndays", (QuestScriptDef d) => (!(d.expireDaysRange.TrueMax > 0f)) ? "" : d.expireDaysRange.ToString()), new TableDataGetter <QuestScriptDef>("CanRun\nnow", (QuestScriptDef d) => d.CanRun(slate).ToStringCheckBlank()), new TableDataGetter <QuestScriptDef>("canGiveRoyalFavor", (QuestScriptDef d) => d.canGiveRoyalFavor.ToStringCheckBlank()), new TableDataGetter <QuestScriptDef>("possible rewards", delegate(QuestScriptDef d) { RewardsGeneratorParams?rewardsParams = null; bool multiple = false; slate.Set <Action <QuestNode, Slate> >("testRunCallback", delegate(QuestNode node, Slate curSlate) { QuestNode_GiveRewards questNode_GiveRewards = node as QuestNode_GiveRewards; if (questNode_GiveRewards != null) { if (rewardsParams.HasValue) { multiple = true; } else { rewardsParams = questNode_GiveRewards.parms.GetValue(curSlate); } } }); bool flag = d.CanRun(slate); slate.Remove("testRunCallback"); if (multiple) { return("complex"); } if (rewardsParams.HasValue) { StringBuilder stringBuilder = new StringBuilder(); if (rewardsParams.Value.allowGoodwill) { stringBuilder.AppendWithComma("goodwill"); } if (rewardsParams.Value.allowRoyalFavor) { stringBuilder.AppendWithComma("favor"); } return(stringBuilder.ToString()); } return((!flag) ? "unknown" : ""); }), new TableDataGetter <QuestScriptDef>("weight histogram", delegate(QuestScriptDef d) { string text = ""; for (float num = 0f; num < d.rootSelectionWeight; num += 0.05f) { text += "*"; if (num > 3f) { text += "*"; break; } } return(text); })); }
public override void PostMapGenerate(Map map) { IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(incCat: IncidentCategoryDefOf.Misc, target: map); incidentParms.forced = true; }