protected override void RunInt() { Slate slate = QuestGen.slate; Map map = slate.Get <Map>("map"); QuestPart_ThreatsGenerator questPart_ThreatsGenerator = new QuestPart_ThreatsGenerator(); questPart_ThreatsGenerator.threatStartTicks = threatStartTicks.GetValue(slate); questPart_ThreatsGenerator.inSignalEnable = (QuestGenUtility.HardcodedSignalWithQuestID(inSignalEnable.GetValue(slate)) ?? slate.Get <string>("inSignal")); questPart_ThreatsGenerator.inSignalDisable = QuestGenUtility.HardcodedSignalWithQuestID(inSignalDisable.GetValue(slate)); ThreatsGeneratorParams value = parms.GetValue(slate); value.faction = (faction.GetValue(slate) ?? value.faction); questPart_ThreatsGenerator.parms = value; questPart_ThreatsGenerator.mapParent = map.Parent; QuestGen.quest.AddPart(questPart_ThreatsGenerator); if (!storeThreatExampleAs.GetValue(slate).NullOrEmpty()) { PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms(); pawnGroupMakerParms.groupKind = PawnGroupKindDefOf.Combat; pawnGroupMakerParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; pawnGroupMakerParms.faction = (value.faction ?? (from x in Find.FactionManager.GetFactions(allowHidden: false, allowDefeated: false, allowNonHumanlike: true, TechLevel.Industrial) where x.HostileTo(Faction.OfPlayer) select x).RandomElement()); float num = value.threatPoints ?? (StorytellerUtility.DefaultThreatPointsNow(map) * value.currentThreatPointsFactor); if (value.minThreatPoints.HasValue) { num = Mathf.Max(num, value.minThreatPoints.Value); } pawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(num, PawnsArrivalModeDefOf.EdgeWalkIn, RaidStrategyDefOf.ImmediateAttack, pawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat); IEnumerable <PawnKindDef> pawnKinds = PawnGroupMakerUtility.GeneratePawnKindsExample(pawnGroupMakerParms); slate.Set(storeThreatExampleAs.GetValue(slate), PawnUtility.PawnKindsToLineList(pawnKinds, " - ")); } }
public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target) { DebugLogger.Log("Make interval incidents"); yield return(new FiringIncident(IncidentDefOf.RaidEnemy, this, new IncidentParms { target = target, points = StorytellerUtility.DefaultThreatPointsNow(target) })); }
public override void Arrived(List <ActiveArtilleryStrike> artilleryStrikes, int tile) { if (Find.WorldObjects.WorldObjectAt(tile, RimWorld.WorldObjectDefOf.PeaceTalks) is PeaceTalks peaceTalks) { if (artilleryStrikes.Any(s => s.shellDef.projectile.damageDef.harmsHealth)) { var faction = peaceTalks.Faction; faction.TryAffectGoodwillWith(Faction.OfPlayer, -99999, reason: DefDatabase <HistoryEventDef> .GetNamed("VFES_ArtilleryStrike"), lookTarget: peaceTalks); // 50% chance of causing a raid if (Rand.Bool) { var parms = new IncidentParms { target = sourceMap, points = StorytellerUtility.DefaultThreatPointsNow(sourceMap), faction = faction, generateFightersOnly = true, forced = true }; Find.Storyteller.incidentQueue.Add(IncidentDefOf.RaidEnemy, Find.TickManager.TicksGame + RaidIntervalRange.RandomInRange, parms); } Find.QuestManager.QuestsListForReading.Where(q => q.QuestLookTargets.Contains(peaceTalks)).ToList().ForEach(q => q.End(QuestEndOutcome.Fail)); Find.LetterStack.ReceiveLetter("VFESecurity.ArtilleryStrikeProvokedGeneric_Letter".Translate(peaceTalks.def.label), "VFESecurity.ArtilleryStrikePeaceTalks_LetterText".Translate(faction.Name), LetterDefOf.NegativeEvent); Find.WorldObjects.Remove(peaceTalks); if (ArtilleryComp != null) { ArtilleryComp.ResetForcedTarget(); } } } }
public static void Prefix(Transition __instance, Lord lord) { var options = Find.Storyteller.def.GetModExtension <StorytellerDefExtension>(); if (options != null && options.storytellerThreat != null) { if (__instance.canMoveToSameState || __instance.target != lord.CurLordToil) { for (int i = 0; i < __instance.preActions.Count; i++) { if (__instance.preActions[i] is TransitionAction_Message transitionAction) { if (transitionAction.message == "MessageRaidersGivenUpLeaving".Translate(lord.faction.def.pawnsPlural.CapitalizeFirst(), lord.faction.Name) || transitionAction.message == "MessageFightersFleeing".Translate(lord.faction.def.pawnsPlural.CapitalizeFirst(), lord.faction.Name)) { var gameComp = Current.Game.GetComponent <StorytellerWatcher>(); //Log.Message("gameComp.raidGroups: " + gameComp.raidGroups.Count); //Log.Message("gameComp.reinforcementGroups: " + gameComp.reinforcementGroups.Count); for (int j = gameComp.raidGroups.Count - 1; j >= 0; j--) { if (gameComp.raidGroups[j].lords.Contains(lord) && gameComp.raidGroups[j].lords.Count > 1) { gameComp.raidGroups[j].lords.Remove(lord); return; } } var raidGroup = gameComp.raidGroups.Where(x => x.lords.Contains(lord)).FirstOrDefault(); if (raidGroup != null) { if (__instance.Map.IsPlayerHome && lord.faction.HostileTo(Faction.OfPlayer)) { IncidentParms parms = new IncidentParms { target = lord.Map, forced = true, points = StorytellerUtility.DefaultThreatPointsNow(lord.Map) }; var incidentDef = DefDatabase <IncidentDef> .GetNamed(options.storytellerThreat.goodIncidents.RandomElement()); if (incidentDef != null) { //Log.Message("Success: " + incidentDef, true); ; Find.Storyteller.incidentQueue.Add(incidentDef, Find.TickManager.TicksGame + new IntRange(6000, 12000).RandomInRange, parms); } } gameComp.raidGroups.Remove(raidGroup); } var reinforcementGroup = gameComp.reinforcementGroups.Where(x => x.lords.Contains(lord)).FirstOrDefault(); if (reinforcementGroup != null) { gameComp.reinforcementGroups.Remove(raidGroup); } } } } } } }
public static void Prefix(Pawn __instance, DamageInfo?dinfo, Hediff exactCulprit = null) { try { var options = Find.Storyteller.def.GetModExtension <StorytellerDefExtension>(); if (options != null && options.storytellerThreat != null && __instance.IsColonist && __instance.FactionOrExtraMiniOrHomeFaction == Faction.OfPlayer) { if (ShouldTriggerReinforcements(__instance, dinfo, out Faction enemyFaction)) { IncidentParms parms = new IncidentParms { target = __instance.Map, faction = enemyFaction, forced = true, raidStrategy = RaidStrategyDefOf.ImmediateAttack, points = StorytellerUtility.DefaultThreatPointsNow(__instance.Map) / 4f }; //Log.Message("Colonist died! Reinforcements will arrive"); var incidentDef = DefDatabase <IncidentDef> .GetNamed("VSE_Reinforcements"); Find.Storyteller.incidentQueue.Add(incidentDef, Find.TickManager.TicksGame + new IntRange(300, 600).RandomInRange, parms); } } } catch (Exception ex) { //Log.Error("Error: " + ex, true); }; }
protected override bool TryExecuteWorker(IncidentParms parms) { int j = 0; Map map = (Map)parms.target; float points = StorytellerUtility.DefaultThreatPointsNow(map); if (points > 2000) { points = 2000; } for (int i = 0; i < 1 + (points / 200); i++) { if (TryFindRandomAnimal(map, out Pawn animal)) { j++; IncidentWorker_AnimalInsanityMass.DriveInsane(animal); } if (Rand.Range(0, 7) == 0) { break; } } if (j == 0) { return(false); } Find.LetterStack.ReceiveLetter("LetterLabelColoniesAnimalRampage".Translate().CapitalizeFirst(), "LetterColoniesAnimalRampage".Translate(), LetterDefOf.ThreatSmall); Find.TickManager.slower.SignalForceNormalSpeedShort(); return(true); }
public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target) { //Settings.DebugString("== Enter StorytellerComp_OmenOnOffCycle.MakeIntervalIncidents =="); var num = 1f; if (Props.acceptFractionByDaysPassedCurve != null) { num *= Props.acceptFractionByDaysPassedCurve.Evaluate(GenDate.DaysPassedFloat); } if (Props.acceptPercentFactorPerThreatPointsCurve != null) { num *= Props.acceptPercentFactorPerThreatPointsCurve.Evaluate( StorytellerUtility.DefaultThreatPointsNow(target)); } var incCount = IncidentCycleUtility.IncidentCountThisInterval(target, Find.Storyteller.storytellerComps.IndexOf(this), Props.minDaysPassed, Props.onDays, Props.offDays, Props.minSpacingDays, Props.numIncidentsRange.min, Props.numIncidentsRange.max, num); //Settings.DebugString($"Accept Fraction: {num} + Incident Count: {incCount}"); for (var i = 0; i < incCount; i++) { var firingIncident = GenerateIncident(target); if (firingIncident != null) { Settings.DebugString($"Make Incident: {firingIncident.def.defName}"); yield return(firingIncident); } } //Settings.DebugString("== Exit StorytellerComp_OmenOnOffCycle.MakeIntervalIncidents =="); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; IntVec3 intVec; if (!this.TryFindEntryCell(map, out intVec)) { return(false); } PawnKindDef husk = PawnKindDef.Named("AA_FungalHusk"); float num = StorytellerUtility.DefaultThreatPointsNow(map); int num2 = GenMath.RoundRandom(num / husk.combatPower); int max = Rand.RangeInclusive(2, 10); num2 = Mathf.Clamp(num2, 1, max); Pawn pawn = null; for (int i = 0; i < num2; i++) { IntVec3 loc = CellFinder.RandomClosewalkCellNear(intVec, map, 10, null); pawn = PawnGenerator.GeneratePawn(husk, null); GenSpawn.Spawn(pawn, loc, map, Rot4.Random, WipeMode.Vanish, false); pawn.mindState.mentalStateHandler.TryStartMentalState(DefDatabase <MentalStateDef> .GetNamed("ManhunterPermanent", true), null, true, false, null, false); } Find.LetterStack.ReceiveLetter("AA_LetterLabelFungalHusk".Translate(husk.label.CapitalizeFirst()), "AA_LetterFungalHusk".Translate(husk.label), LetterDefOf.NegativeEvent, pawn, null, null); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { if (!settings.Active) { return(false); } Map map = (Map)parms.target; if (!ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(parms.points, map.Tile, out PawnKindDef animalKind)) { return(false); } if (!FindHomeAreaCell(map, out IntVec3 result)) { return(false); } parms.points = StorytellerUtility.DefaultThreatPointsNow(parms.target); animals = GetAnimals(animalKind, map, parms.points); DropPodUtilityPlus.DropThingsNear(result, map, animals, callback: DriveInsane); SendStandardLetter(parms, null); return(true); }
public override void CompTick() { MapParent mapParent = (MapParent)parent; if (mapParent.HasMap) { if (ticksLeftTillNotifyPlayer > 0 && --ticksLeftTillNotifyPlayer == 0) { NotifyPlayer(); } if (ticksLeftToSendRaid > 0) { ticksLeftToSendRaid--; if (ticksLeftToSendRaid == 0) { IncidentParms incidentParms = new IncidentParms(); incidentParms.target = mapParent.Map; incidentParms.points = StorytellerUtility.DefaultThreatPointsNow(incidentParms.target) * 2.5f; incidentParms.faction = RaidFaction; IncidentDefOf.RaidEnemy.Worker.TryExecute(incidentParms); ticksLeftToSendRaid = (int)(Rand.Range(18f, 24f) * 2500f); Messages.Message("MessageCaravanDetectedRaidArrived".Translate(incidentParms.faction.def.pawnsPlural, incidentParms.faction, ticksLeftToSendRaid.ToStringTicksToDays()), MessageTypeDefOf.ThreatBig); } } } else { ResetCountdown(); } }
protected override void ResolveRaidPoints(IncidentParms parms) { if (parms.points <= 0f) { parms.points = StorytellerUtility.DefaultThreatPointsNow(parms.target); } }
protected override bool TryExecuteWorker(IncidentParms parms) { int j = 0; Map map = (Map)parms.target; float points = StorytellerUtility.DefaultThreatPointsNow(map); if (points > 2000) { points = 2000; } for (int i = 0; i < 3 + (points / 100); i++) { j++; IntVec3 loc = CellFinder.RandomCell(map); GenSpawn.Spawn(ThingDefOf.MeteoriteIncoming, loc, map); } if (TryFindRandomAnimal(map, out Pawn animal)) { j++; IntVec3 loc = animal.InteractionCell; GenSpawn.Spawn(ThingDefOf.MeteoriteIncoming, loc, map); } if (j == 0) { return(false); } Find.LetterStack.ReceiveLetter("LetterLabelMeterLight".Translate().CapitalizeFirst(), "LetterMeterLight".Translate(), LetterDefOf.ThreatSmall); Find.TickManager.slower.SignalForceNormalSpeedShort(); return(true); }
protected override void ResolveRaidPoints(IncidentParms parms) { if (parms.points <= 0f) { Log.Error("RaidEnemy is resolving raid points. They should always be set before initiating the incident.", false); parms.points = StorytellerUtility.DefaultThreatPointsNow(parms.target); } }
public override void DoAction() { Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(this.questDef, StorytellerUtility .DefaultThreatPointsNow(this.window.initiator.Map)); Find.LetterStack.ReceiveLetter(quest.name, quest.description, LetterDefOf.PositiveEvent, null, null, quest, null, null); }
public override bool IsPossible() { worker = new IncidentWorker_DrunkMuffalos(); worker.def = IncidentDef.Named("DrunkMuffalos"); parms = new IncidentParms(); parms.target = Current.Game.RandomPlayerHomeMap; parms.points = StorytellerUtility.DefaultThreatPointsNow(parms.target); return(worker.CanFireNow(parms)); }
private List <Thing> GenerateRewards(Faction alliedFaction, IncidentParms parms) { int totalMarketValue = (int)Mathf.Clamp(StorytellerUtility.DefaultThreatPointsNow(parms.target) * 10, 1000, 3000); List <Thing> list = new List <Thing>(); ItemCollectionGenerator_Internal_Arcane itc_ia = new ItemCollectionGenerator_Internal_Arcane(); return(itc_ia.Generate(totalMarketValue, list)); //return ItemCollectionGeneratorDefOf.BanditCampQuestRewards.Worker.Generate(parms); }
public static bool Do() { var root = DefDatabase <QuestScriptDef> .GetNamed("Reunion_DownedRefugee"); var points = StorytellerUtility.DefaultThreatPointsNow(Current.Game.AnyPlayerHomeMap); QuestUtility.SendLetterQuestAvailable(QuestUtility.GenerateQuestAndMakeAvailable(root, points)); return(true); }
protected void ResolveRaidPoints(IncidentParms parms) { float factor = ZombiefiedMod.ZombieRaidAmountMultiplier; parms.points = StorytellerUtility.DefaultThreatPointsNow(parms.target) * PointsFactor * factor; if (parms.points > 3777f * ZombiefiedMod.ZombieRaidAmountMultiplier) { parms.points = 3777f * ZombiefiedMod.ZombieRaidAmountMultiplier; } }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; IntVec3 intVec; if (!this.TryFindEntryCell(map, out intVec)) { return(false); } PawnKindDef aerofleet = PawnKindDef.Named("AA_Aerofleet"); PawnKindDef aerofleetcolossal = PawnKindDef.Named("AA_ColossalAerofleet"); float num = StorytellerUtility.DefaultThreatPointsNow(map); int num2 = GenMath.RoundRandom(num / aerofleetcolossal.combatPower); int num2smaller = GenMath.RoundRandom(num / aerofleet.combatPower); int max = Rand.RangeInclusive(2, 4); int maxsmaller = Rand.RangeInclusive(10, 25); num2 = Mathf.Clamp(num2, 1, max); num2smaller = Mathf.Clamp(num2smaller, 1, maxsmaller); 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(aerofleetcolossal, 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); } } for (int i = 0; i < num2smaller; i++) { IntVec3 loc = CellFinder.RandomClosewalkCellNear(intVec, map, 10, null); pawn = PawnGenerator.GeneratePawn(aerofleet, 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("LetterLabelColossalAerofleetPasses".Translate(aerofleetcolossal.label.CapitalizeFirst()), "LetterColossalAerofleetPasses".Translate(aerofleetcolossal.label), LetterDefOf.PositiveEvent, pawn, null, null); return(true); }
public void SendGssRaid(Map map, bool force = false) { float passedDays = (lastRaidTicks - Find.TickManager.TicksGame) / 60000f; if (force || passedDays <= 0) { lastRaidTicks = Find.TickManager.TicksGame + 60000; GssRaids.SendRaid(map, Mathf.Max(300, StorytellerUtility.DefaultThreatPointsNow(map))); } }
public static void SendRaid(Faction faction, float multiplier, int ticksToSend) { IncidentParms incidentParms = new IncidentParms(); incidentParms.target = Find.AnyPlayerHomeMap; incidentParms.faction = faction; incidentParms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn; incidentParms.points = StorytellerUtility.DefaultThreatPointsNow(incidentParms.target) * multiplier; incidentParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; Find.Storyteller.incidentQueue.Add(IncidentDefOf.RaidEnemy, Find.TickManager.TicksGame + ticksToSend, incidentParms); }
static void GenerateIntelQuest(Faction faction, string name, int goodwill) { Slate slate = new Slate(); slate.Set("points", StorytellerUtility.DefaultThreatPointsNow(Find.World)); slate.Set("asker", faction.leader); Quest newQuest = QuestUtility.GenerateQuestAndMakeAvailable(DefDatabase <QuestScriptDef> .GetNamed(name), slate); QuestUtility.SendLetterQuestAvailable(newQuest); faction.lastTraderRequestTick = Find.TickManager.TicksGame; faction.TryAffectGoodwillWith(Faction.OfPlayer, -goodwill, canSendMessage: false, canSendHostilityLetter: true, "GoodwillChangedReason_RequestedIntel".Translate()); }
public override void OnReceived(EmailMessage message, EmailBox box) { IncidentParms incidentParms = new IncidentParms(); incidentParms.target = Find.AnyPlayerHomeMap; incidentParms.faction = message.Faction; incidentParms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn; incidentParms.points = StorytellerUtility.DefaultThreatPointsNow(incidentParms.target); incidentParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; Find.Storyteller.incidentQueue.Add(IncidentDefOf.RaidEnemy, Find.TickManager.TicksGame + TicksToSend, incidentParms); }
public override bool IsPossible() { worker = new IncidentWorker_GiveQuest(); worker.def = IncidentDef.Named("GiveQuest_Settlers_Wanted"); worker.def.questScriptDef = DefDatabase <QuestScriptDef> .GetNamed("Settlers_Wanted"); parms = new IncidentParms(); parms.questScriptDef = DefDatabase <QuestScriptDef> .GetNamed("Settlers_Wanted"); parms.points = StorytellerUtility.DefaultThreatPointsNow(Current.Game.RandomPlayerHomeMap); parms.forced = true; return(worker.CanFireNow(parms)); }
public override void Resolve(ResolveParams rp) { //Random chance for Danger if (Rand.Chance(0.9f)) { if (rp.disableHives == false) //Meaning they should be active { ResolveParams resolveParamsDanger = rp; resolveParamsDanger.hivesCount = Rand.RangeInclusive(1, 2); resolveParamsDanger.rect = rp.rect.ContractedBy(1); if (StorytellerUtility.DefaultThreatPointsNow(Find.World) > 4000f) { resolveParamsDanger.hivesCount = Rand.RangeInclusive(2, 3); } BaseGen.symbolStack.Push("hives", resolveParamsDanger); } else { //MechanoidsSpawn ResolveParams resolveParamsDanger = rp; resolveParamsDanger.mechanoidsCount = Rand.RangeInclusive(3, 5); resolveParamsDanger.rect = rp.rect.ContractedBy(1); if (StorytellerUtility.DefaultThreatPointsNow(Find.World) > 4000f) { resolveParamsDanger.mechanoidsCount = Rand.RangeInclusive(5, 7); } BaseGen.symbolStack.Push("randomMechanoidGroup", resolveParamsDanger); } } //Put in a storage container ResolveParams resolveParamsAncientStorage = rp; resolveParamsAncientStorage.rect = new CellRect(rp.rect.minX + 3, rp.rect.minZ + 3, rp.rect.Width - 6, rp.rect.Height - 5); //Reward Loot resolveParamsAncientStorage.stockpileConcreteContents = RewardGeneratorUtilityLGE.GenerateStorageBoxReward(); BaseGen.symbolStack.Push("storageBoxLGE", resolveParamsAncientStorage); ResolveParams resolveParamsCryoCaskets = rp; resolveParamsCryoCaskets.rect = rp.rect.ContractedBy(1); //We could steal from the SymbolResolver_Interior_AncientTemple here and include rewards and/or dangers BaseGen.symbolStack.Push("ancientShrinesGroup", resolveParamsCryoCaskets); //spawn empty room BaseGen.symbolStack.Push("emptyRoom", rp); //Clear out the entire rect (including roofs) rp.clearRoof = true; BaseGen.symbolStack.Push("clear", rp); }
private void SendCancelOrderRaid() { IncidentParms incidentParms = new IncidentParms(); incidentParms.target = Find.AnyPlayerHomeMap; incidentParms.faction = Find.FactionManager.RandomEnemyFaction(); incidentParms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn; incidentParms.points = StorytellerUtility.DefaultThreatPointsNow(incidentParms.target) * raidMultiplier; incidentParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; Find.Storyteller.incidentQueue.Add(IncidentDefOf.RaidEnemy, Find.TickManager.TicksGame + Rand.Range(2, 3) * 60000, incidentParms); raidMultiplier += 0.4f; }
public static bool RaidPossible(float points, PawnsArrivalModeDef arrival, RaidStrategyDef strategy = null, Faction faction = null) { var raidEnemy = new IncidentWorker_RaidEnemy(); raidEnemy.def = IncidentDefOf.RaidEnemy; return(raidEnemy.CanFireNow(new IncidentParms { target = Helper.AnyPlayerMap, points = Math.Max(StorytellerUtility.DefaultThreatPointsNow(Helper.AnyPlayerMap), points), raidArrivalMode = arrival, raidStrategy = strategy == null ? RaidStrategyDefOf.ImmediateAttack : strategy, faction = faction })); }
public float CalculatePoints() { Loger.Log("IncidentLod OCIncident.CalculatePoints 1"); var target = (place as Settlement)?.Map ?? Find.CurrentMap; float points = StorytellerUtility.DefaultThreatPointsNow(target); //Можно переопределить формулу в каждом потомке ИЛИ проверять остальные параметры и добавлять множитель var resultPoints = points * mult * (float)SessionClientController.Data.GeneralSettings.IncidentPowerPrecent / 100f; Loger.Log($"CalculatePoints(). points={(int)points} resultPoints={resultPoints}"); Loger.Log("IncidentLod OCIncident.CalculatePoints 2"); return(resultPoints); }
public override bool TryExecuteEvent() { IncidentParms parms = new IncidentParms() { target = Find.CurrentMap, points = StorytellerUtility.DefaultThreatPointsNow(Find.CurrentMap) * RaidRatioDifficultyIncrease, }; if (!incident.Worker.TryExecute(parms)) { Messages.Message("FailedRewardEvent".Translate(defName), MessageTypeDefOf.RejectInput); return(false); } return(true); }
public static PointsWagerTarget RollNewThreatPoints(float pointsWager, IIncidentTarget target = null) { if (target == null) { target = Helper.AnyPlayerMap; if (target == null) { throw new ArgumentNullException(); } } // chance at getting a bigger raid float threatPoints = StorytellerUtility.DefaultThreatPointsNow(target); float pointsRatio = Math.Min(pointsWager / threatPoints, 5f); float chanceAtHigherRaid = (float)-((5450f / 10241f) * Math.Pow(pointsRatio, 2d)); chanceAtHigherRaid += (234705f / 10241f) * pointsRatio; chanceAtHigherRaid -= 13175f / 10241f; float chanceAtSmallerRaid = Math.Min(100, 100 - chanceAtHigherRaid); Helper.Log($"points wager: {pointsWager} threat points: {threatPoints} chanceBigRaid: {chanceAtHigherRaid} chanceSmallRaid: {chanceAtSmallerRaid}"); System.Random rand = new System.Random(); float multiplier = 1; // try for big raid if (chanceAtHigherRaid * 10 > rand.Next(1, 1000)) { Helper.Log("making bigger raid"); multiplier = (float)((1f / 1078f) * Math.Pow(pointsRatio, 2d)); multiplier += (579f / 10780f) * pointsRatio; multiplier += 1083f / 1078f; } // try for small raid else if (chanceAtSmallerRaid * 10 > rand.Next(1, 1000)) { multiplier = (float)((0.003887f) * Math.Pow(pointsRatio, 2d)); multiplier += (0.05977f * pointsRatio); multiplier += 0.594f; } Helper.Log("raid multiplier is " + multiplier); return(new PointsWagerTarget(threatPoints * multiplier, target)); }