public static void CauseMechanoidRaid(Pawn pawn, BodyPartRecord part, RecipeDef recipe, float points = 1.25f, int minTicks = 2000, int maxTicks = 4000) { IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, pawn.Map); IntVec3 spawnSpot; if (!CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => pawn.Map.reachability.CanReachColony(c), pawn.Map, CellFinder.EdgeRoadChance_Neutral, out spawnSpot)) { Nothing(pawn, null, recipe); return; } incidentParms.forced = true; incidentParms.faction = Faction.OfMechanoids; incidentParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; incidentParms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn; incidentParms.spawnCenter = spawnSpot; incidentParms.points *= points; int delay = new IntRange(minTicks, maxTicks).RandomInRange; QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, incidentParms), Find.TickManager.TicksGame + delay); Find.Storyteller.incidentQueue.Add(qi); Base.Instance.GetExtendedDataStorage().lastEmergencySignalTick = Find.TickManager.TicksGame; Base.Instance.GetExtendedDataStorage().lastEmergencySignalDelay = delay; }
public override void PostMapGenerate(Map map) { 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; } Faction faction; if ((from f in Find.FactionManager.AllFactions where !f.def.hidden && f.HostileTo(Faction.OfPlayer) select f).TryRandomElement(out faction)) { IntVec3 spawnCenter2; if (CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => map.reachability.CanReachColony(c), map, CellFinder.EdgeRoadChance_Neutral, out spawnCenter2)) { incidentParms.faction = faction; incidentParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; incidentParms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn; incidentParms.spawnCenter = spawnCenter2; incidentParms.points *= 20f; incidentParms.points = Math.Max(incidentParms.points, 250f); QueuedIncident qi = new QueuedIncident(new FiringIncident(ThingDefOfReconAndDiscovery.RD_RaidEnemyQuest, null, incidentParms), Find.TickManager.TicksGame + Rand.RangeInclusive(5000, 15000)); Find.Storyteller.incidentQueue.Add(qi); } } }
public override void PostMapGenerate(Map map) { base.PostMapGenerate(map); this.MakeMuffalo(map); this.QueueArrivals(map); if (Rand.Chance(0.05f)) { IEnumerable <Pawn> source = from p in map.mapPawns.FreeColonistsSpawned where p.story.traits.HasTrait(TraitDef.Named("PsychicSensitivity")) select p; if (source.Count <Pawn>() > 0) { Pawn pawn = source.RandomElement <Pawn>(); Find.LetterStack.ReceiveLetter("RD_ManhunterDanger".Translate(), "RD_MalevolentPsychicDesc".Translate(pawn.Named("PAWN")) //"{0} believes that a malevolent psychic energy is massing, and that this peaceful herd of muffalo are on the brink of a mass insanity." , LetterDefOf.ThreatSmall, null); } //TODO: check if it works IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.FactionArrival, map); incidentParms.forced = true; incidentParms.points = 100f; QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDef.Named("RD_MuffaloMassInsanity"), null, incidentParms), Find.TickManager.TicksGame + Rand.RangeInclusive(10000, 45000)); Find.Storyteller.incidentQueue.Add(qi); } }
public override void PostMapGenerate(Map map) { IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(incCat: IncidentCategoryDefOf.Misc, target: map); QueuedIncident queuedIncident = new QueuedIncident(firingInc: new FiringIncident(def: DefDatabase <IncidentDef> .GetNamed(defName: "MFI_HerdMigration_Ambush"), source: null, parms: incidentParms), fireTick: Find.TickManager.TicksGame + Rand.RangeInclusive(min: GenDate.TicksPerDay / 2, max: GenDate.TicksPerDay)); Find.Storyteller.incidentQueue.Add(qi: queuedIncident); }
public static void Recache() { BulletinCache.Clear(); foreach (var x in IncidentCaravanUtility.IncidentCaravans) { if (x.detected) { BulletinCache.Add(Bulletin.Create(x)); } } //----- This code is to help player remove some corrupted information in the save caused by bugs in the last version QueuedIncident toremove = null; foreach (QueuedIncident qi in Find.Storyteller.incidentQueue) { if (qi.FiringIncident.def == IncidentDefOf.SolarFlare) { toremove = qi; break; } } if (toremove != null) { List <QueuedIncident> tmpQue = typeof(IncidentQueue).GetField("queuedIncidents", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(Find.Storyteller.incidentQueue) as List <QueuedIncident>; if (tmpQue != null) { tmpQue.Remove(toremove); } } //------- BulletinCache.Sort(); int danger = 0, neutral = 0, uid = 0; foreach (var x in BulletinCache) { if (x.bulletinIntelLevel == Interceptor.IncidentIntelLevel.Danger) { ++danger; } else if (x.bulletinIntelLevel == Interceptor.IncidentIntelLevel.Neutral) { ++neutral; } else { ++uid; } } if (danger > Instance.dangerNum) { OpenIt(); } Instance.dangerNum = danger; Instance.neutralNum = neutral; Instance.uidNum = uid; ReCalulateSize(); }
public void QueueIncident(FiringIncident incident, float afterDays) { var qi = new QueuedIncident(incident, (int)(Find.TickManager.TicksGame + GenDate.TicksPerDay * afterDays)); incidentQueue.Add(qi); //Log.Message("Queued Hospitality incident after " + afterDays + " days. Queue has now " + incidentQueue.Count + " items."); }
// Token: 0x06000010 RID: 16 RVA: 0x00002528 File Offset: 0x00000728 private void CallInSubscriptions(int originTile) { IncrementGoodwill(); var num = seasonScore * serviceRegularity * 75f; if (num >= 50f) { var list = (from settlement in Find.WorldObjects.SettlementBases where settlement.Faction != Faction.OfPlayer && settlement.Faction.def.CanEverBeNonHostile && (float)settlement.Faction.PlayerGoodwill > 0f && Find.WorldGrid.ApproxDistanceInTiles(originTile, settlement.Tile) < 36f && Find.WorldReachability.CanReach(originTile, settlement.Tile) select settlement).ToList <Settlement>(); if (!list.NullOrEmpty <Settlement>()) { foreach (Settlement settlementBase in list) { var incidentParms = new IncidentParms { faction = settlementBase.Faction, points = num, spawnCenter = Position, target = Map }; var qi = new QueuedIncident(new FiringIncident(ThingDefOf_RazzleDazzle.RAZSubscription, null, incidentParms), Find.TickManager.TicksGame + Rand.RangeInclusive(6000, 120000), 0); Find.Storyteller.incidentQueue.Add(qi); } } } }
// Token: 0x06000014 RID: 20 RVA: 0x000023D8 File Offset: 0x000005D8 public override void PawnDied(Corpse corpse) { bool flag = corpse.InnerPawn.ageTracker.CurLifeStageIndex == 0; int num; if (flag) { num = 100; } else { bool flag2 = corpse.InnerPawn.ageTracker.CurLifeStageIndex == 1; if (flag2) { num = 75; } else { num = 50; } } int num2 = Rand.Range(60, 600); StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, corpse.Map); IncidentParms parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, corpse.Map); QueuedIncident qi = new QueuedIncident(new FiringIncident(CrazyRabbitIncidentDefOf.CrazyRabbitIncident, null, parms), Find.TickManager.TicksGame + num2, 0); bool flag3 = GenDate.DaysPassed >= 90 && Rand.Range(1, 10) == 1; if (flag3) { Log.Message("Bunny died. Nature will take revenge. Secret incident triggered (" + num + ")", false); Find.Storyteller.incidentQueue.Add(qi); } }
private void TriggerFindStargate() { IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, Find.World); incidentParms.forced = true; QueuedIncident qi = new QueuedIncident(new FiringIncident(ThingDefOfReconAndDiscovery.RD_DiscoveredStargate, null, incidentParms), Find.TickManager.TicksGame + 100); Find.Storyteller.incidentQueue.Add(qi); }
private static IDelayHolder DelayRaid(IncidentParms parms, IncidentDef incidentDef) { var delay = CalculateDelay(parms); var qi = new QueuedIncident(new FiringIncident(incidentDef, null, parms), delay.GetGlobalDelay()); Find.Storyteller.incidentQueue.Add(qi); return(delay); }
public override void PostMapGenerate(Map map) { IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(incCat: IncidentCategoryDefOf.Misc, target: map); incidentParms.forced = true; //this part is forced to bypass CanFireNowSub, to solve issue with scenario-added incident. QueuedIncident queuedIncident = new QueuedIncident(firingInc: new FiringIncident(def: DefDatabase <IncidentDef> .GetNamed(defName: "MFI_HerdMigration_Ambush"), source: null, parms: incidentParms), fireTick: Find.TickManager.TicksGame + Rand.RangeInclusive(min: GenDate.TicksPerDay / 2, max: GenDate.TicksPerDay)); Find.Storyteller.incidentQueue.Add(qi: queuedIncident); }
public void Try2InitiateRaid() { Map map = parent.Map; if (map == null) { return; } Faction faction; if (!TryFindEnemyFaction(out faction)) { return; } //IntVec3 spawnSpot; //if (!TryFindSpawnSpot(map, out spawnSpot)) // return; IncidentParms raidParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map); raidParms.forced = true; raidParms.faction = faction; raidParms.raidStrategy = null; raidParms.raidArrivalMode = null; //raidParms.spawnCenter = spawnSpot; raidParms.points = Mathf.Max(raidParms.points * (EndGame_ModSettings.raidPointsFactorRangePercent.RandomInRange / 100f), faction.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat)); //raidParms.points = 20000.0f; // DEBUG raidParms.pawnGroupMakerSeed = Rand.Int; // Between day 0 and 7 --> Reduced danger : reduced raid points if (IsDangerLow) { raidParms.points = (float)(raidParms.points * EndGame_ModSettings.dangerLowRaidPointFactor); } // Between day 7 and 24 --> Medium danger : average raid points if (!IsDangerLow && !IsDangerHigh) { raidParms.points = (float)(raidParms.points * EndGame_ModSettings.dangerMidRaidPointFactor); } // Between day 24 and max --> Increased danger : increased raid points if (IsDangerHigh) { raidParms.points = (float)(raidParms.points * EndGame_ModSettings.dangerHighRaidPointFactor); } QueuedIncident qi = new QueuedIncident(new FiringIncident(GetPossibleIncidentDefs.RandomElement(), null, raidParms), Find.TickManager.TicksGame + 10, 0); Find.Storyteller.incidentQueue.Add(qi); }
public override void PostMapGenerate(Map map) { var incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.Misc, map); incidentParms.forced = true; //this part is forced to bypass CanFireNowSub, to solve issue with scenario-added incident. var queuedIncident = new QueuedIncident( new FiringIncident(DefDatabase <IncidentDef> .GetNamed("MFI_HerdMigration_Ambush"), null, incidentParms), Find.TickManager.TicksGame + Rand.RangeInclusive(GenDate.TicksPerDay / 2, GenDate.TicksPerDay)); Find.Storyteller.incidentQueue.Add(queuedIncident); }
public override void PostMapGenerate(Map map) { IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, (IncidentCategory)3, map); incidentParms.forced = true; IntVec3 spawnCenter; if (RCellFinder.TryFindRandomPawnEntryCell(out spawnCenter, map, 0f, (IntVec3 v) => GenGrid.Standable(v, map))) { incidentParms.spawnCenter = spawnCenter; } Faction faction; if (GenCollection.TryRandomElement <Faction>(from f in Find.FactionManager.AllFactions where !f.def.hidden && FactionUtility.HostileTo(f, Faction.OfPlayer) select f, out faction)) { IntVec3 spawnCenter2; if (CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => map.reachability.CanReachColony(c), map, 0f, out spawnCenter2)) { incidentParms.faction = Faction.OfMechanoids; incidentParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; incidentParms.generateFightersOnly = true; incidentParms.raidNeverFleeIndividual = true; incidentParms.raidArrivalMode = PawnsArriveMode.CenterDrop; incidentParms.spawnCenter = spawnCenter2; incidentParms.points *= 20f; incidentParms.points = Math.Max(incidentParms.points, 250f); QueuedIncident queuedIncident = new QueuedIncident(new FiringIncident(TorannMagicDefOf.ArcaneEnemyRaid, null, incidentParms), Find.TickManager.TicksGame + Rand.RangeInclusive(500, 5000)); Find.Storyteller.incidentQueue.Add(queuedIncident); System.Random random = new System.Random(); int rnd = GenMath.RoundRandom(random.Next(0, 10)); if (rnd < 5) { incidentParms.points = Math.Max(incidentParms.points * 2, 500f); queuedIncident = new QueuedIncident(new FiringIncident(TorannMagicDefOf.ArcaneEnemyRaid, null, incidentParms), Find.TickManager.TicksGame + Rand.RangeInclusive(2000, 3000)); Find.Storyteller.incidentQueue.Add(queuedIncident); } if (rnd < 3) { if (GenCollection.TryRandomElement <Faction>(from f in Find.FactionManager.AllFactions where !f.def.hidden && FactionUtility.HostileTo(f, Faction.OfPlayer) select f, out faction)) { incidentParms.faction = faction; incidentParms.points = Math.Max(250f, 500f); queuedIncident = new QueuedIncident(new FiringIncident(TorannMagicDefOf.ArcaneEnemyRaid, null, incidentParms), Find.TickManager.TicksGame + Rand.RangeInclusive(5000, 10000)); Find.Storyteller.incidentQueue.Add(queuedIncident); } } } } }
public static void PlanNewVisit(IIncidentTarget map, float afterDays, Faction faction = null) { IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentCategory.AllyArrival, map); if (faction != null) { incidentParms.faction = faction; } var incident = new FiringIncident(IncidentDefOf.VisitorGroup, null, incidentParms); QueuedIncident qi = new QueuedIncident(incident, (int)(Find.TickManager.TicksGame + GenDate.TicksPerDay * afterDays)); Find.Storyteller.incidentQueue.Add(qi); }
public static bool IncidentIsQueued(IncidentParms parms, IncidentDef incidentDef) { IEnumerator qIncidents = Find.Storyteller.incidentQueue.GetEnumerator(); while (qIncidents.MoveNext()) { QueuedIncident qi = (QueuedIncident)qIncidents.Current; if (qi.FiringIncident.parms == parms && qi.FiringIncident.def == incidentDef) { return(true); } } return(false); }
public static void Prefix(ref IncidentParms parms) { if (parms.target is Map && (parms.target as Map).IsPlayerHome) { if (parms.faction != null && (parms.faction.def.defName.Contains("MuvLuv_BETA"))) { if ((parms.target is Map map)) { if (Rand.Chance(0.25f)) { int strikedelay = Find.TickManager.TicksGame + IncidentWorker_RaidEnemy_TryExecuteWorker_BETA_Patch.RaidDelay.RandomInRange; // parms.points = parms.points / 2; float hivepoints = parms.points; if (Rand.Chance(0.25f)) { int @int = Rand.Int; IncidentParms raidParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map); raidParms.forced = true; raidParms.faction = parms.faction; raidParms.points = hivepoints; raidParms.pawnGroupMakerSeed = new int?(@int); IncidentDef incidentDef1 = IncidentDefOf.BETAInfestationInterior; IncidentDef incidentDef2 = IncidentDefOf.BETAInfestationExterior; QueuedIncident qi1 = new QueuedIncident(new FiringIncident(incidentDef1, null, raidParms), strikedelay, 0); strikedelay += 60; QueuedIncident qi2 = new QueuedIncident(new FiringIncident(incidentDef2, null, raidParms), strikedelay, 0); Find.Storyteller.incidentQueue.Add(qi1); Find.Storyteller.incidentQueue.Add(qi2); } else { IncidentDef incidentDef = Rand.Chance(0.5f) ? IncidentDefOf.BETAInfestationInterior : IncidentDefOf.BETAInfestationExterior; int @int = Rand.Int; IncidentParms raidParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map); raidParms.forced = true; raidParms.faction = parms.faction; raidParms.points = hivepoints; raidParms.pawnGroupMakerSeed = new int?(@int); QueuedIncident qi = new QueuedIncident(new FiringIncident(incidentDef, null, raidParms), strikedelay, 0); Find.Storyteller.incidentQueue.Add(qi); } } } } } }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch)); Toil tFuel = new Toil(); tFuel.defaultCompleteMode = ToilCompleteMode.Instant; tFuel.AddFailCondition(() => this.Casket.GetComp <CompRefuelable>().Fuel < 50f); tFuel.AddFailCondition(() => !this.Casket.GetComp <CompPowerTrader>().PowerOn); tFuel.initAction = delegate() { this.Casket.GetComp <CompRefuelable>().ConsumeFuel(25f); }; yield return(tFuel); Toil t2 = Toils_General.Wait(6000); t2.AddFailCondition(() => !this.Casket.GetComp <CompPowerTrader>().PowerOn); t2.initAction = delegate() { this.Casket.Map.weatherManager.TransitionTo(WeatherDef.Named("RainyThunderstorm")); }; t2 = t2.WithProgressBar(TargetIndex.A, () => (6000f - (float)this.ticksLeftThisToil) / 6000f, false, -0.5f); yield return(t2); yield return(new Toil { defaultCompleteMode = ToilCompleteMode.Instant, initAction = delegate() { GenExplosion.DoExplosion(this.Casket.Position, this.Casket.Map, 50f, DamageDefOf.EMP, this.Casket, -1, -1f, SoundDefOf.EnergyShield_Broken, null, null, null, null, 0f, 1, false, null, 0f, 1); this.Casket.GetComp <CompOsiris>().HealContained(); this.Casket.Map.weatherManager.TransitionTo(WeatherDef.Named("Rain")); IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.FactionArrival, this.Casket.Map); incidentParms.forced = true; incidentParms.target = this.Casket.Map; QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDef.Named("ShortCircuit"), null, incidentParms), Find.TickManager.TicksGame + 1); Find.Storyteller.incidentQueue.Add(qi); } }); yield return(Toils_Reserve.Release(TargetIndex.A)); yield break; }
public QueuedIncident GetNextVisit(Faction faction) { QueuedIncident nearest = null; // Find earliest foreach (QueuedIncident incident in incidentQueue) { if (incident.FiringIncident.parms.faction == faction) { if (nearest == null || incident.FireTick < nearest.FireTick) { nearest = incident; } } } return(nearest); }
private 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.JumpTo(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; QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, incidentParms), Find.TickManager.TicksGame + IncidentWorker_RefugeeChased.RaidDelay.RandomInRange); Find.Storyteller.incidentQueue.Add(qi); }; diaOption.resolveTree = true; return(diaOption); }
private static void CauseMechanoidRaid(Pawn pawn, BodyPartRecord part) { IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, pawn.Map); IntVec3 spawnSpot; if (!CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => pawn.Map.reachability.CanReachColony(c), pawn.Map, CellFinder.EdgeRoadChance_Neutral, out spawnSpot)) { Nothing(pawn, null); return; } incidentParms.forced = true; incidentParms.faction = Faction.OfMechanoids; incidentParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; incidentParms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn; incidentParms.spawnCenter = spawnSpot; incidentParms.points *= 1.35f; QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, incidentParms), Find.TickManager.TicksGame + new IntRange(1000, 2500).RandomInRange); Find.Storyteller.incidentQueue.Add(qi); Find.LetterStack.ReceiveLetter("WTH_Letter_CausedMechanoidRaid_Label".Translate(), "WTH_Letter_CausedMechanoidRaid_Description".Translate(), LetterDefOf.ThreatBig, pawn); }
private void QueueEvent(RaidStrategyDef strat, IntRange delay) { Map map = Find.AnyPlayerHomeMap; IntVec3 spawnSpot; if (!CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => map.reachability.CanReachColony(c), map, CellFinder.EdgeRoadChance_Neutral, out spawnSpot)) { return; } IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map); incidentParms.forced = true; incidentParms.faction = Find.FactionManager.RandomEnemyFaction(); incidentParms.points = Challenge_NColonists.AllColonists.Count() * 100f; incidentParms.raidStrategy = strat; incidentParms.raidNeverFleeIndividual = true; int when = Find.TickManager.TicksGame + delay.RandomInRange; QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, incidentParms), when); Find.Storyteller.incidentQueue.Add(qi); }
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 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); } }
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 bool TryExecute(IncidentParms parms) { Map map = (Map)parms.target; IntVec3 spawnSpot; int durationDays = Mathf.RoundToInt(this.def.durationDays.RandomInRange); if (Prefs.DevMode) { Log.Message("[Carnivale] Calculating spawn centre:"); } if (!CarnCellFinder.BestCarnivalSpawnSpot(map, out spawnSpot)) { if (Prefs.DevMode) { Log.Warning("[Carnivale] Tried to execute incident CarnivalApproaches, failed to find reachable spawn spot."); } return(false); } if (!FindCarnivalFaction(out parms.faction)) { if (Prefs.DevMode) { Log.Warning("[Carnivale] Tried to execute incident CarnivalApproaches, failed to find valid faction."); } return(false); } // Calculate fe int feePerColonist = CarnUtils.CalculateFeePerColonist(parms.points); // Main dialog node string title = "CarnivalApproachesTitle".Translate(parms.faction.Name); DiaNode initialNode = new DiaNode("CarnivalApproachesInitial".Translate(new object[] { parms.faction.Name, durationDays, feePerColonist + " " + ThingDefOf.Silver.label, map.info.parent.Label == "Colony" ? "your colony" : map.info.parent.Label })); // Accept button DiaOption acceptOption = new DiaOption("CarnivalApproachesAccept".Translate()); acceptOption.action = delegate { // Do accept action parms.faction.AffectGoodwillWith(Faction.OfPlayer, acceptanceBonus); IncidentParms arrivalParms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentCategory.AllyArrival, map); //arrivalParms.forced = true; // forcing not necessary arrivalParms.faction = parms.faction; arrivalParms.spawnCenter = spawnSpot; arrivalParms.points = parms.points; // Do this? // This is so it can be determined that the spawnpoint was precomputed. Rot4 sneakyValueForSpawnpointResolved = Rot4.East; arrivalParms.spawnRotation = sneakyValueForSpawnpointResolved; // This is super cheaty, but there is no other field to pass this to. arrivalParms.raidPodOpenDelay = durationDays; // End cheaty. // Assign fee per colonist to CarnivalInfo CarnUtils.Info.feePerColonist = -feePerColonist; QueuedIncident qi = new QueuedIncident(new FiringIncident(_DefOf.CarnivalArrives, null, arrivalParms), Find.TickManager.TicksGame + GenDate.TicksPerDay); Find.Storyteller.incidentQueue.Add(qi); }; initialNode.options.Add(acceptOption); // Accept thank you message DiaNode acceptedMessage = new DiaNode("CarnivalApproachesAcceptMessage".Translate(new object[] { parms.faction.leader.Name.ToStringFull })); DiaOption ok = new DiaOption("OK".Translate()); ok.resolveTree = true; acceptedMessage.options.Add(ok); acceptOption.link = acceptedMessage; // Reject button DiaOption rejectOption = new DiaOption("CarnivalApproachesReject".Translate()); rejectOption.action = delegate { // Do reject action parms.faction.AffectGoodwillWith(Faction.OfPlayer, rejectionPenalty); }; initialNode.options.Add(rejectOption); // Reject f**k you message (TODO: randomise response) DiaNode rejectedMessage = new DiaNode("CarnivalApproachesRejectMessage".Translate(new object[] { parms.faction.leader.Name.ToStringShort })); DiaOption hangup = new DiaOption("HangUp".Translate()); hangup.resolveTree = true; rejectedMessage.options.Add(hangup); rejectOption.link = rejectedMessage; // Draw dialog Find.WindowStack.Add(new Dialog_NodeTree(initialNode, true, true, title)); return(true); }
public override bool TryExecute(IncidentParms parms) { Map map = (Map)parms.target; IntVec3 spawnSpot; if (!CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => map.reachability.CanReachColony(c), map, out spawnSpot)) { return(false); } Faction faction = Find.FactionManager.FirstFactionOfDef(FactionDefOf.Spacer); PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDefOf.SpaceRefugee, faction, PawnGenerationContext.NonPlayer, null, false, false, false, false, true, false, 20f, false, true, true, null, null, null, null, null, null); Pawn refugee = PawnGenerator.GeneratePawn(request); refugee.relations.everSeenByPlayer = true; Faction enemyFac; if (!(from f in Find.FactionManager.AllFactions where !f.def.hidden && f.HostileTo(Faction.OfPlayer) select f).TryRandomElement(out enemyFac)) { return(false); } string text = "RefugeeChasedInitial".Translate(new object[] { refugee.Name.ToStringFull, refugee.story.Title.ToLower(), enemyFac.def.pawnsPlural, enemyFac.Name, refugee.ageTracker.AgeBiologicalYears }); text = text.AdjustedFor(refugee); PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, 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, null); Find.CameraDriver.JumpTo(spawnSpot); IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategory.ThreatBig, map); incidentParms.forced = true; incidentParms.faction = enemyFac; incidentParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; incidentParms.raidArrivalMode = PawnsArriveMode.EdgeWalkIn; incidentParms.spawnCenter = spawnSpot; incidentParms.points *= 1.35f; QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, incidentParms), Find.TickManager.TicksGame + IncidentWorker_RefugeeChased.RaidDelay.RandomInRange); Find.Storyteller.incidentQueue.Add(qi); }; diaOption.resolveTree = true; diaNode.options.Add(diaOption); string text2 = "RefugeeChasedRejected".Translate(new object[] { refugee.Name.ToStringShort }); 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, PawnDiscardDecideMode.Decide); }; diaOption3.link = diaNode2; diaNode.options.Add(diaOption3); Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, true)); return(true); }
/// <summary> /// If no visitor group is available, make your own and afterwards reexecute this incident /// </summary> /// <param name="parms"></param> /// <returns></returns> private bool TryExecuteVisitorsAndRestartSelf(IncidentParms parms) { Map map = (Map)parms.target; IEnumerable <Faction> factions = Find.FactionManager.AllFactionsListForReading.Where(fac => fac != Faction.OfPlayer && !fac.HostileTo(Faction.OfPlayer)); // && // (float)GenDate.DaysPassed >= fac.def.earliestRaidDays ); Faction faction = null; if (factions != null) { faction = factions.RandomElement(); } else { //Log.Warning("IncidentWorker_RumorOf: Tried to create visitor group with null faction. Only possible, if there aren't anymore friendly factions available!"); return(true); // This will be handled as if it was successful.. ??? } //Log.Error("OutdoorTemp:" + GenTemperature.OutdoorTemp.ToString() + " / SeasonalTemp:" + GenTemperature.SeasonalTemp.ToString() + " Faction:" + faction.def.defName); IntVec3 visitorSpawnCell = IntVec3.Invalid; CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => c.Standable(map) && map.reachability.CanReachColony(c), map, out visitorSpawnCell); IncidentParms VisitorParms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentCategory.Misc, map); VisitorParms.forced = true; VisitorParms.faction = faction; VisitorParms.points = (float)Rand.Range(40, 140); VisitorParms.spawnCenter = visitorSpawnCell; VisitorParms.raidArrivalMode = PawnsArriveMode.EdgeWalkIn; // Execute Visitor Group int occurTick = Find.TickManager.TicksGame + 60; int occurTick2 = Find.TickManager.TicksGame + Rand.RangeInclusive(6500, 10000); QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.VisitorGroup, null, VisitorParms), occurTick); //Log.Error("CanFireNow: " + qi.FiringIncident.def.Worker.CanFireNow().ToString()); if (qi.FiringIncident.def.Worker.CanFireNow(map)) { Find.Storyteller.incidentQueue.Add(qi); } else { VisitorParms.points /= 2; QueuedIncident qi_temp = new QueuedIncident(new FiringIncident(IncidentDef.Named("TraderCaravanArrival"), null, VisitorParms), occurTick); Find.Storyteller.incidentQueue.Add(qi_temp); } // Re-Execute Self parms.forced = true; QueuedIncident qi2 = new QueuedIncident(new FiringIncident(IncidentDef.Named(this.def.defName), null, parms), occurTick2); Find.Storyteller.incidentQueue.Add(qi2); return(true); }
public override bool TryExecute(IncidentParms parms) { IntVec3 spawnSpot; if (!CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => c.CanReachColony(), out spawnSpot)) { return(false); } Faction faction = Find.FactionManager.FirstFactionOfDef(FactionDefOf.Spacer); PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDefOf.SpaceRefugee, faction, PawnGenerationContext.NonPlayer, false, false, false, false, true, false, RelationWithColonistWeight, false, true, true, null, null, null, null, null); Pawn refugee = PawnGenerator.GeneratePawn(request); refugee.relations.everSeenByPlayer = true; Faction enemyFac; if (!(from f in Find.FactionManager.AllFactions where !f.def.hidden && f.HostileTo(Faction.OfPlayer) select f).TryRandomElement(out enemyFac)) { return(false); } string text = "RefugeeChasedInitial".Translate(new object[] { refugee.Name.ToStringFull, refugee.story.adulthood.title.ToLower(), enemyFac.def.pawnsPlural, enemyFac.Name, refugee.ageTracker.AgeBiologicalYears }); text = text.AdjustedFor(refugee); PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, refugee); DiaNode diaNode = new DiaNode(text); DiaOption diaOption = new DiaOption("RefugeeChasedInitial_Accept".Translate()); diaOption.action = delegate { GenSpawn.Spawn(refugee, spawnSpot); refugee.SetFaction(Faction.OfPlayer); // Refugee stole vehicle? float value = Rand.Value; if (enemyFac.def.techLevel >= TechLevel.Industrial && value >= 0.33f) { CellFinder.RandomClosewalkCellNear(spawnSpot, 5); Thing thing; if (value >= 0.8f) { thing = ThingMaker.MakeThing(ThingDef.Named("VehicleCombatATV")); } else { thing = ThingMaker.MakeThing(ThingDef.Named("VehicleATV")); } GenSpawn.Spawn(thing, spawnSpot); Thing fuel = ThingMaker.MakeThing(thing.TryGetComp <CompRefuelable>().Props.fuelFilter.AllowedThingDefs.FirstOrDefault()); fuel.stackCount += Mathf.FloorToInt(5 + Rand.Value * 15f); thing.TryGetComp <CompRefuelable>().Refuel(fuel); int num2 = Mathf.FloorToInt(Rand.Value * 0.3f * thing.MaxHitPoints); thing.TakeDamage(new DamageInfo(DamageDefOf.Bullet, num2, null, null)); thing.SetFaction(Faction.OfPlayer); Job job = new Job(HaulJobDefOf.Mount); Find.Reservations.ReleaseAllForTarget(thing); job.targetA = thing; refugee.jobs.StartJob(job, JobCondition.InterruptForced); SoundInfo info = SoundInfo.InWorld(thing); thing.TryGetComp <CompMountable>().sustainerAmbient = thing.TryGetComp <CompVehicle>().compProps.soundAmbient.TrySpawnSustainer(info); } Find.CameraDriver.JumpTo(spawnSpot); IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentCategory.ThreatBig); incidentParms.forced = true; incidentParms.faction = enemyFac; incidentParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; incidentParms.raidArrivalMode = PawnsArriveMode.EdgeWalkIn; incidentParms.spawnCenter = spawnSpot; incidentParms.points *= RaidPointsFactor; QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, incidentParms), Find.TickManager.TicksGame + RaidDelay.RandomInRange); Find.Storyteller.incidentQueue.Add(qi); }; diaOption.resolveTree = true; diaNode.options.Add(diaOption); string text2 = "RefugeeChasedRejected".Translate(new object[] { refugee.NameStringShort }); 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); Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, true)); return(true); }
public static bool Replacement(IncidentParms parms, ref bool __result) { Map map = (Map)parms.target; IntVec3 spawnSpot; if (!CellFinder.TryFindRandomEdgeCellWith(c => map.reachability.CanReachColony(c), map, CellFinder.EdgeRoadChance_Neutral, out spawnSpot)) { __result = false; return(false); } #region CHANGED Pawn refugee = Rand.Value < 0.7f ? GenericUtility.GetAnyRelatedWorldPawn(_selector, 100) : null; if (refugee == null) { // Just ANYONE Find.WorldPawns.AllPawnsAlive.Where(_selector).TryRandomElement(out refugee); } if (refugee == null) { __result = false; return(false); } #endregion refugee.relations.everSeenByPlayer = true; Faction enemyFac; if (!(from f in Find.FactionManager.AllFactions where !f.def.hidden && f.HostileTo(Faction.OfPlayer) select f).TryRandomElement(out enemyFac)) { __result = false; return(false); } string text = "RefugeeChasedInitial".Translate(new object[] { refugee.Name.ToStringFull, refugee.story.Title.ToLower(), enemyFac.def.pawnsPlural, enemyFac.Name, refugee.ageTracker.AgeBiologicalYears }); text = text.AdjustedFor(refugee); PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, 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, null); CameraJumper.TryJump(refugee); 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 *= RaidPointsFactor; QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, incidentParms), Find.TickManager.TicksGame + RaidDelay.RandomInRange); Find.Storyteller.incidentQueue.Add(qi); }; diaOption.resolveTree = true; diaNode.options.Add(diaOption); string text2 = "RefugeeChasedRejected".Translate(new object[] { refugee.NameStringShort }); 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 { #region CHANGED HealthUtility.DamageUntilDead(refugee); //Log.Message(refugee.Name + " dead? " + refugee.Dead); //Find.WorldPawns.PassToWorld(refugee,PawnDiscardDecideMode.Discard); #endregion }; diaOption3.link = diaNode2; diaNode.options.Add(diaOption3); string title = "RefugeeChasedTitle".Translate(new object[] { map.info.parent.Label }); Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, true, title)); __result = true; return(false); }