public override bool SubstituionWorkerExecution() { Map map = (Map)parms.target; Rot4 rot = Rot4.FromAngleFlat((map.Center - intVec).AngleFlat); for (int i = 0; i < pawnList.Count; i++) { Pawn newThing = pawnList[i]; IntVec3 loc = CellFinder.RandomClosewalkCellNear(intVec, map, 10, null); GenSpawn.Spawn(newThing, loc, map, rot, WipeMode.Vanish, false); } LordMaker.MakeNewLord(null, new LordJob_ExitMapNear(near, LocomotionUrgency.Walk, 12f, false, false), map, pawnList); IncidentDef def = incidentDef; string text = string.Format(def.letterText, AnimalType.GetLabelPlural(-1)).CapitalizeFirst(); string label = string.Format(def.letterLabel, AnimalType.GetLabelPlural(-1).CapitalizeFirst()); Find.LetterStack.ReceiveLetter(label, text, def.letterDef, pawnList[0], null, null); return(true); }
public override bool IsPossible() { worker = new RimWorld.IncidentWorker_MakeGameCondition(); worker.def = IncidentDef.Named("Flashstorm"); parms = new IncidentParms(); List <Map> allMaps = Current.Game.Maps; foreach (Map map in allMaps) { parms.target = map; if (worker.CanFireNow(parms)) { return(true); } } return(false); }
protected override void OpenBox(Pawn usedBy) { Map map = usedBy.Map; Rand.PushState(parent.HashOffset()); bool hostileActivity = GenHostility.AnyHostileActiveThreatToPlayer(map); KeyValuePair <List <IncidentCategoryDef>, IncidentGroupData> selectedGroup = incidentGroups.RandomElementByWeight(kvp => kvp.Value.chance); while (hostileActivity && selectedGroup.Key.Contains(IncidentCategoryDefOf.FactionArrival)) { selectedGroup = incidentGroups.RandomElementByWeight(kvp => kvp.Value.chance); } int count = Rand.RangeInclusive(selectedGroup.Value.countMin, Rand.RangeInclusive(selectedGroup.Value.countStep, selectedGroup.Value.countMax)); for (int i = 0; i < count; i++) { List <IncidentDef> validIncidents = new List <IncidentDef>(); foreach (IncidentDef incident in from def in DefDatabase <IncidentDef> .AllDefs where selectedGroup.Key.Contains(def.category) && def.TargetAllowed(map) select def) { IncidentParms parms = StorytellerUtility.DefaultParmsNow(incident.category, map); if (incident.Worker.CanFireNow(parms, false)) { validIncidents.Add(incident); } } IncidentDef selectedIncident = validIncidents.RandomElementByWeight(new Func <IncidentDef, float>(IncidentChanceFinal)); if (selectedIncident != null) { IncidentParms parms = StorytellerUtility.DefaultParmsNow(selectedIncident.category, map); if (selectedIncident.pointsScaleable) { StorytellerComp storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain); if (storytellerComp != null) { parms = storytellerComp.GenerateParms(selectedIncident.category, parms.target); } } selectedIncident.Worker.TryExecute(parms); } } Rand.PopState(); }
public override bool IsPossible() { worker = new RimWorld.IncidentWorker_Aurora(); worker.def = IncidentDef.Named("Aurora"); parms = new IncidentParms(); List <Map> allMaps = Current.Game.Maps; allMaps.Shuffle(); foreach (Map map in allMaps) { parms.target = map; if (worker.CanFireNow(parms)) { return(true); } } return(false); }
private static bool TryStartPeaceTalks(Faction faction) { int tile; if (!JecsToolsFactionDialogMaker.TryFindTile(out tile)) { return(false); } PeaceTalks peaceTalks = (PeaceTalks)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.PeaceTalks); peaceTalks.Tile = tile; peaceTalks.SetFaction(faction); peaceTalks.GetComponent <TimeoutComp>().StartTimeout(900000); Find.WorldObjects.Add(peaceTalks); var def = IncidentDef.Named("QuestPeaceTalks"); string text = string.Format(def.letterText.AdjustedFor(faction.leader), faction.def.leaderTitle, faction.Name, 15).CapitalizeFirst(); Find.LetterStack.ReceiveLetter(def.letterLabel, text, def.letterDef, peaceTalks, null); return(true); }
public override bool IsPossible() { PawnKindDef animalKind = PawnKindDef.Named("YorkshireTerrier"); int num = AnimalsCount.RandomInRange; num = Mathf.Max(num, Mathf.CeilToInt(4f / animalKind.RaceProps.baseBodySize)); worker = new IncidentWorker_SpecificAnimalsWanderIn(null, animalKind, true, num, false, true); worker.def = IncidentDef.Named("FarmAnimalsWanderIn"); Map map = Helper.AnyPlayerMap; if (map != null) { parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.Misc, map); return(worker.CanFireNow(parms)); } return(false); }
public override bool IsPossible() { worker = new RimWorld.IncidentWorker_SelfTame(); worker.def = IncidentDef.Named("SelfTame"); Map map = Helper.AnyPlayerMap; if (map != null) { parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.Misc, map); bool canFire = worker.CanFireNow(parms); Helper.Log("Can fire " + canFire); return(canFire); } return(false); }
/// <summary>called when the settings are changed</summary> public static void NotifySettingsChanged() { PawnmorpherSettings settings = LoadedModManager.GetMod <PawnmorpherMod>().GetSettings <PawnmorpherSettings>(); IncidentDef mutagenIncident = IncidentDef.Named("MutagenicShipPartCrash"); if (!settings.enableMutagenShipPart) { mutagenIncident.baseChance = 0.0f; } else { mutagenIncident.baseChance = 2.0f; } if (!settings.enableFallout) { PMIncidentDefOf.MutagenicFallout.baseChance = 0; } }
public void RollTableOfFun(Map map) { FunSpell result = GenCollection.RandomElementByWeight <FunSpell>(TableOfFun, GetWeight); if (result.defName == "Cults_SpellDoubleTheFun") { Cthulhu.Utility.DebugReport("Double The Fun!"); DoubleTheFun(map); return; } IncidentDef temp = DefDatabase <IncidentDef> .GetNamed(result.defName); if (temp != null) { map.GetComponent <MapComponent_SacrificeTracker>().lastSideEffect = temp; CultUtility.CastSpell(temp, map); return; } Cthulhu.Utility.DebugReport("Failed to utilize " + temp.ToString()); }
public static bool Intercept_SkyFaller <T>(IncidentDef incidentDef, IncidentParms parms, bool needHoaxing = false, bool checkHostileFaction = false) where T : InterceptedIncident_SkyFaller, new() { if (checkHostileFaction && parms.faction.PlayerRelationKind != FactionRelationKind.Hostile) { return(false); } InterceptedIncident_SkyFaller incident = new T(); incident.incidentDef = incidentDef; incident.parms = parms; if (incident.FallerType == SkyFallerType.Big && !PESDefOf.PES_SkyIDL.IsFinished) { return(false); } if (incident.FallerType == SkyFallerType.Small && !PESDefOf.PES_SkyIDS.IsFinished) { return(false); } if (!incident.PreCalculateDroppingSpot()) { return(false); } int totDuration = incident.FallerType == SkyFallerType.Big ? PES_Settings.LargeSkyFallerDuration : PES_Settings.SmallSkyFallerDuration; int decTime = incident.FallerType == SkyFallerType.Big ? PES_Settings.LargeSkyFallerIdentificationTime : PES_Settings.SmallSkyFallerIdentificationTime; if (!IncidentCaravanUtility.AddSimpleIncidentCaravan(incident, totDuration, decTime)) { Log.Error("Fail to create Incident Caravan"); return(false); } if (needHoaxing) { IsHoaxingStoryTeller = true; } if (PES_Settings.DebugModeOn) { Messages.Message("PES_Debug: Successfully intercepted a skyfaller Incident", MessageTypeDefOf.NeutralEvent); } return(true); }
/// <summary> /// Lt.Bob - Unifies debug information to central command (__instance) /// </summary> /// <param name="parms"></param> /// <param name="IncDef"></param> public static void DebugParms(IncidentParms parms, IncidentDef IncDef = null) { Log.Message(" PS=- parms= " + parms.ToString(), false); if (parms.quest != null) { Log.Message(" PS=- parms.quest= " + parms.quest.ToString(), false); Log.Message(" PS=- parms.quest.PartsListForReading= " + parms.quest.PartsListForReading, false); } else { Log.Message(" PS=- parms.quest= NULL", false); } if (parms.questTag != null) { Log.Message(" PS=- parms.questTag= " + parms.questTag.ToString(), false); } else { Log.Message(" PS=- parms.questTag= NULL", false); } if (parms.questScriptDef != null) { Log.Message(" PS=- parms.questScriptDef= " + parms.questScriptDef.ToString(), false); } else { Log.Message(" PS=- parms.questScriptDef= NULL", false); } if (IncDef == null) { Log.Message(" PS=- IncidentDef= NULL", false); return; } Log.Message(" PS=- IncidentDef= " + IncDef.ToString(), false); if (IncDef.defName != null) { Log.Message(" PS=- IncidentDef.defName= " + IncDef.defName, false); return; } Log.Message(" PS=- IncidentDef.defName= NULL", false); }
public override void GameComponentTick() { int currentTick = this.game.tickManager.TicksAbs; TickEvent nextEvent = events.FirstOrDefault(); if (nextEvent != null && nextEvent.tick <= currentTick) { Utils.LogDebug($"Firing scheduled {nextEvent.e.incidentName} event!"); // Remove from list events.Remove(nextEvent); int nextEventTick = nextEvent.e.GetNextEventTick(currentTick); IncidentDef incident = nextEvent.e.GetIncident(); if (incident != null) { IEnumerable <IIncidentTarget> targets = nextEvent.e.incidentTarget.GetCurrentTarget(nextEvent.e); if (targets.Count() > 0) { nextEvent.e.targetSelector.RunOn(targets, (target) => this.nextEvents.Add(new NextEvent(incident, target))); } else { Utils.LogDebugWarning($"Event found 0 targets"); } } else { Utils.LogWarning($"Could not fire event, since it could not find an IncidentDef"); } Utils.LogDebug($"Next event will happen on {GenDate.HourOfDay(nextEventTick, 0)}h, {GenDate.DateFullStringAt(nextEventTick, Vector2.zero)}"); //Utils.LogDebug($"Hours until: {(nextEventTick - currentTick) / GenDate.TicksPerHour}"); TickEvent.AddToList(events, nextEventTick, nextEvent.e); } if (nextEvents.Count > 0) { nextEvents.First().Execute(); nextEvents.RemoveAt(0); } //Current.Game.storyteller.TryFire() base.GameComponentTick(); }
private static IncidentDef TryIdentifyType(IncidentParms parms, IncidentDef incidentDef, float spottingPower) { if (!ResearchProjectDefOf.MotionScanner.IsFinished) { return(null); } float multiplier = .1f; if (ResearchProjectDefOf.AdvancedScoutingTehniques.IsFinished && (parms.target as Map).listerBuildings.ColonistsHaveBuildingWithPowerOn(ThingDefOf.SatelliteController)) { multiplier = 1f; } if (spottingPower * multiplier < new IntRange(0, 100).RandomInRange) { return(null); } return(incidentDef); }
public override void Execute(int amount, string boughtBy) { Map currentMap = Find.CurrentMap; IncidentParms parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.AllyAssistance, currentMap); parms.forced = true; //parms.raidArrivalMode = PawnsArrivalModeDefOf.CenterDrop; //parms.raidStrategy = RaidStrategyDefOf.ImmediateAttackFriendly; parms.raidArrivalModeForQuickMilitaryAid = true; parms.points = DiplomacyTuning.RequestedMilitaryAidPointsRange.RandomInRange; parms.faction = Find.FactionManager.RandomAlliedFaction(); var raidWorker = new IncidentWorker_RaidFriendly(); raidWorker.def = IncidentDef.Named("RaidFriendly"); raidWorker.TryExecute(parms); AlertManager.NormalEventNotification("Your viewers have sent help from "); }
static void Prefix(bool earlyTryMode) { if (!earlyTryMode) { return; } var backupIncidentDefOfTypes = new List <Type> { typeof(BackupVanillaIncidentDefOf) }; if (!(ModAssemblies.MoreFactionInteraction is null)) { backupIncidentDefOfTypes.Add(typeof(BackupMoreFactionInteractionIncidentDefOf)); } foreach (var backupIncidentDefOfType in backupIncidentDefOfTypes) { foreach (var backupIncidentDefOfField in backupIncidentDefOfType.GetFields(BindingFlags.Static | BindingFlags.Public)) { var defName = backupIncidentDefOfField.Name; var origDef = DefDatabase <IncidentDef> .GetNamed(defName); // Need to non-shallow copy the def, since some mods (such as LotR Third Age) also mutate incidents that they remove. // Also, not using AccessTools.MakeDeepCopy since it deep copies too far (such as deep copying Type fields), // to the point of somehow causing a crash. // For our purposes, we'll just shallow copy fields and single-depth copy non-array lists. var copiedDef = new IncidentDef(); foreach (var field in fieldofs_IncidentDef) { var value = field.GetValue(origDef); if (value is IList list && value.GetType() is var listType && !listType.IsArray) { var copiedList = (IList)Activator.CreateInstance(listType); foreach (var item in list) { copiedList.Add(item); } field.SetValue(copiedDef, copiedList); }
public override void TickRare() { if (Spawned) { ticksLeft--; if (!triggered) { if (ticksLeft < 0) { ticksLeft = (int)Math.Abs(Rand.Gaussian(0, referenceTimeoutAfterTriggered)); triggered = true; Debug.Log("Battle", "Auto triggered raid at {0}, {1} of value {2} after {3} long ticks (approximately max speed seconds)", base.Position.x, base.Position.z, value, ticksLeft); } List <Thing> searchSet = PawnsFinder.AllMaps_FreeColonistsSpawned.ToList().ConvertAll(pawn => (Thing)pawn); Thing thing = GenClosest.ClosestThing_Global(base.Position, searchSet, 10.0f); if (thing != null) { ticksLeft = (int)Math.Abs(Rand.Gaussian(0, 200)); triggered = true; Debug.Log("Battle", "Triggered raid at {0}, {1} of value {2} after {3} long ticks (approximately max speed seconds)", base.Position.x, base.Position.z, value, ticksLeft); } } else { if (ticksLeft < 0) { IncidentDef incidentDef = IncidentDefOf.RaidEnemy; IncidentParms parms = new IncidentParms { faction = faction, points = value, target = base.Map }; incidentDef.Worker.TryExecute(parms); Destroy(); } } } }
public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false) { this.separateChannel = separateChannel; this.Viewer = viewer; string[] command = message.Split(' '); GameComponentPawns gameComponent = Current.Game.GetComponent <GameComponentPawns>(); if (gameComponent.HasUserBeenNamed(viewer.username)) { Toolkit.client.SendMessage($"@{viewer.username} you are in the colony and not in need of rescuing.", separateChannel); return(false); } worker = new IncidentWorker_QuestViewerRescue(viewer); worker.def = IncidentDef.Named("QuestViewerRescue"); parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.Misc, Helper.AnyPlayerMap); return(true); }
public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false) { this.separateChannel = separateChannel; this.Viewer = viewer; string[] command = message.Split(' '); GameComponentPawns gameComponent = Current.Game.GetComponent <GameComponentPawns>(); if (gameComponent.HasUserBeenNamed(viewer.username)) { TwitchWrapper.SendChatMessage($"@{viewer.username} you are in the colony and cannot visit."); return(false); } worker = new IncidentWorker_VisitColony(viewer); worker.def = IncidentDef.Named("VisitColony"); parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.Misc, Helper.AnyPlayerMap); 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 = StorytellerUtility.DefaultParmsNow(worker.def.category, target); parms.faction = Find.FactionManager.OfInsects; worker = new IncidentWorker_Infestation(); worker.def = IncidentDef.Named("Infestation"); return(worker.CanFireNow(parms)); }
public override bool IsPossible() { var innterType = typeof(IncidentWorker).Assembly.GetTypes() .Where(s => s.Name == "IncidentWorker_PsychicEmanatorShipPartCrash").First(); var innerObject = Activator.CreateInstance(innterType); worker = innerObject as IncidentWorker; worker.def = IncidentDef.Named("PsychicEmanatorShipPartCrash"); Map map = Helper.AnyPlayerMap; if (map != null) { parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.Misc, map); return(worker.CanFireNow(parms)); } return(false); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; if (!TryResolveParms(parms)) { return(false); } if (parms.faction.HostileTo(Faction.OfPlayer)) { return(false); } List <Pawn> list = SpawnPawns(parms); if (list.Count == 0) { return(false); } for (int i = 0; i < list.Count; i++) { if (list[i].needs != null && list[i].needs.food != null) { list[i].needs.food.CurLevel = list[i].needs.food.MaxLevel; } } IntVec3 chillSpot; IncidentDef arrival = ItemRequestsDefOf.RequestCaravanArrival; Find.LetterStack.ReceiveLetter(arrival.letterLabel, arrival.letterText, arrival.letterDef, list[0], parms.faction); RCellFinder.TryFindRandomSpotJustOutsideColony(list[0], out chillSpot); LordJob_FulfillItemRequest lordJob = new LordJob_FulfillItemRequest(parms.faction, chillSpot); LordMaker.MakeNewLord(parms.faction, lordJob, map, list); return(true); }
public void SororitasTick() { if (!AdeptusSororitas.HostileTo(Faction.OfPlayer) && FactionCanHelp && Rand.Range(0, 100) < 10) { foreach (Lord current in Find.LordManager.lords) { if (current.CurLordToil is LordToil_AssaultColony && current.faction != AdeptusSororitas && current.faction != ImperialGuard) { IncidentParms parms = new IncidentParms(); parms.faction = AdeptusSororitas; parms.points = 1000; parms.raidArrivalMode = PawnsArriveMode.CenterDrop; parms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; IncidentDef relief = new IncidentDef(); relief.workerClass = typeof(IncidentWorker_RaidFriendly); relief.Worker.TryExecute(parms); this.FactionCanHelp = false; break; } } } }
private static IncidentDef IncomingIncidentDef(Faction faction) { switch (Rand.RangeInclusive(min: 0, max: 50)) { //kinda dirty hack that also means if you set the modifier to 2 you get fewer of the other quests. Oh well. case int n when n <= 6 * MoreFactionInteraction_Settings.pirateBaseUpgraderModifier: return(MFI_DefOf.MFI_QuestSpreadingPirateCamp); case int n when n <= 8: return(IncidentDef.Named("Quest_BanditCamp")); case int n when n <= 9: return(MFI_DefOf.MFI_DiplomaticMarriage); case int n when n <= 19: return(faction.leader != null ? MFI_DefOf.MFI_ReverseTradeRequest : IncomingIncidentDef(faction)); case int n when n <= 25: return(MFI_DefOf.MFI_BumperCropRequest); case int n when n <= 29: return(faction.leader != null ? MFI_DefOf.MFI_HuntersLodge : IncomingIncidentDef(faction)); case int n when n <= 31: return(IncidentDef.Named("MFI_MysticalShaman")); case int n when n <= 35: return(faction.leader != null?IncidentDef.Named("Quest_ItemStash") : IncomingIncidentDef(faction)); case int n when n <= 40: return(IncidentDefOf.Quest_TradeRequest); case int n when n <= 50: return(IncidentDefOf.TraderCaravanArrival); default: return(IncidentDefOf.TraderCaravanArrival); } }
/// <summary> /// This is taken and adapted from IncidentWorker_RefugeeChased /// </summary> /// <param name="parms"></param> /// <returns></returns> private bool TryExecuteRaid() { Faction faction; if (!( from f in Find.FactionManager.AllFactions where (f.def.hidden ? false : f.HostileTo(Faction.OfPlayer)) select f).TryRandomElement <Faction>(out faction)) { return(false); } IncidentParms pursuerAttackParms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentCategory.ThreatBig); pursuerAttackParms.forced = true; pursuerAttackParms.faction = faction; //immediateAttack.raidStrategy = RaidStrategyDefOf.ImmediateAttack; ResolveRaidStrategy_NoSiege(ref pursuerAttackParms); pursuerAttackParms.raidArrivalMode = PawnsArriveMode.EdgeWalkIn; pursuerAttackParms.spawnCenter = ExitMapCell; if (pursuerAttackParms.points < IncidentPoints) { pursuerAttackParms.points = IncidentPoints; } if (pursuerAttackParms.points <= 0) { pursuerAttackParms.points = Rand.RangeInclusive(40, 140); } pursuerAttackParms.points *= pointMultiplier; int occurTick = Find.TickManager.TicksGame + Rand.RangeInclusive(def.enemySpawnTimeMin, def.enemySpawnTimeMax); Find.Storyteller.incidentQueue.Add(IncidentDef.Named("RaidEnemy"), occurTick, pursuerAttackParms); return(true); }
public override bool IsPossible() { PawnKindDef animalKind = PawnKindDef.Named("YorkshireTerrier"); int num = AnimalsCount.RandomInRange; num = Mathf.Max(num, Mathf.CeilToInt(4f / animalKind.RaceProps.baseBodySize)); worker = new IncidentWorker_SpecificAnimalsWanderIn(null, animalKind, true, num, false, true); worker.def = IncidentDef.Named("FarmAnimalsWanderIn"); parms = new IncidentParms(); List <Map> allMaps = Current.Game.Maps; foreach (Map map in allMaps) { parms.target = map; if (worker.CanFireNow(parms)) { return(true); } } return(false); }
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 static bool CreateIncidentCaraven_HumanNeutral <T>(IncidentDef incidentDef, IncidentParms parms) where T : InterceptedIncident, new() { InterceptedIncident incident = new T(); incident.incidentDef = incidentDef; incident.parms = parms; if (!incident.ManualDeterminParams()) { return(false); } if (!IncidentCaravanUtility.AddNewIncidentCaravan(incident)) { Log.Error("Fail to create Incident Caravan"); return(false); } IsHoaxingStoryTeller = true; if (PES_Settings.DebugModeOn) { Messages.Message("PES_Debug: Successfully intercepted a neutral Incident", MessageTypeDefOf.NeutralEvent); } //IsIntercepting_PawnGeneration = GeneratorPatchFlag.ReturnZero; return(true); }
public static bool CreateIncidentCaravan_Animal <T>(IncidentDef incidentDef, IncidentParms parms) where T : InterceptedIncident, new() { InterceptedIncident incident = new T(); incident.incidentDef = incidentDef; incident.parms = parms; if (!incident.ManualDeterminParams()) { return(false); } if (!IncidentCaravanUtility.AddNewIncidentCaravan(incident)) { Log.Error("Fail to create Incident Caravan"); return(false); } //Hoxing Should be done in the patch //IsHoaxingStoryTeller = true; if (PES_Settings.DebugModeOn) { Messages.Message("PES_Debug: Successfully intercepted an animal Incident", MessageTypeDefOf.NeutralEvent); } return(true); }
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 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; } } } }