public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            float num = 1f;

            if (Props.acceptFractionByDaysPassedCurve != null)
            {
                num *= Props.acceptFractionByDaysPassedCurve.Evaluate(GenDate.DaysPassedFloat);
            }
            if (Props.acceptPercentFactorPerThreatPointsCurve != null)
            {
                num *= Props.acceptPercentFactorPerThreatPointsCurve.Evaluate(StorytellerUtility.DefaultThreatPointsNow(target));
            }
            if (Props.acceptPercentFactorPerProgressScoreCurve != null)
            {
                num *= Props.acceptPercentFactorPerProgressScoreCurve.Evaluate(StorytellerUtility.GetProgressScore(target));
            }
            int incCount = IncidentCycleUtility.IncidentCountThisInterval(target, Find.Storyteller.storytellerComps.IndexOf(this), Props.minDaysPassed, Props.onDays, Props.offDays, Props.minSpacingDays, Props.numIncidentsRange.min, Props.numIncidentsRange.max, num);

            for (int i = 0; i < incCount; i++)
            {
                FiringIncident firingIncident = GenerateIncident(target);
                if (firingIncident != null)
                {
                    yield return(firingIncident);
                }
            }
        }
Exemple #2
0
 public string DebugString()
 {
     if (Time.frameCount % 60 == 0)
     {
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.AppendLine("GLOBAL STORYTELLER STATS");
         stringBuilder.AppendLine("------------------------");
         stringBuilder.AppendLine("Storyteller: ".PadRight(40) + def.label);
         stringBuilder.AppendLine("Adaptation days: ".PadRight(40) + Find.StoryWatcher.watcherAdaptation.AdaptDays.ToString("F1"));
         stringBuilder.AppendLine("Adapt points factor: ".PadRight(40) + Find.StoryWatcher.watcherAdaptation.TotalThreatPointsFactor.ToString("F2"));
         stringBuilder.AppendLine("Time points factor: ".PadRight(40) + Find.Storyteller.def.pointsFactorFromDaysPassed.Evaluate(GenDate.DaysPassed).ToString("F2"));
         stringBuilder.AppendLine();
         stringBuilder.AppendLine("Ally incident fraction (neutral or ally): ".PadRight(40) + StorytellerUtility.AllyIncidentFraction(fullAlliesOnly: false).ToString("F2"));
         stringBuilder.AppendLine("Ally incident fraction (ally only): ".PadRight(40) + StorytellerUtility.AllyIncidentFraction(fullAlliesOnly: true).ToString("F2"));
         stringBuilder.AppendLine();
         stringBuilder.AppendLine(StorytellerUtilityPopulation.DebugReadout().TrimEndNewlines());
         IIncidentTarget incidentTarget = Find.WorldSelector.SingleSelectedObject as IIncidentTarget;
         if (incidentTarget == null)
         {
             incidentTarget = Find.CurrentMap;
         }
         if (incidentTarget != null)
         {
             Map map = incidentTarget as Map;
             stringBuilder.AppendLine();
             stringBuilder.AppendLine("STATS FOR INCIDENT TARGET: " + incidentTarget);
             stringBuilder.AppendLine("------------------------");
             stringBuilder.AppendLine("Progress score: ".PadRight(40) + StorytellerUtility.GetProgressScore(incidentTarget).ToString("F2"));
             stringBuilder.AppendLine("Base points: ".PadRight(40) + StorytellerUtility.DefaultThreatPointsNow(incidentTarget).ToString("F0"));
             stringBuilder.AppendLine("Points factor random range: ".PadRight(40) + incidentTarget.IncidentPointsRandomFactorRange);
             stringBuilder.AppendLine("Wealth: ".PadRight(40) + incidentTarget.PlayerWealthForStoryteller.ToString("F0"));
             if (map != null)
             {
                 stringBuilder.AppendLine("- Items: ".PadRight(40) + map.wealthWatcher.WealthItems.ToString("F0"));
                 stringBuilder.AppendLine("- Buildings: ".PadRight(40) + map.wealthWatcher.WealthBuildings.ToString("F0"));
                 stringBuilder.AppendLine("- Floors: ".PadRight(40) + map.wealthWatcher.WealthFloorsOnly.ToString("F0"));
                 stringBuilder.AppendLine("- Pawns: ".PadRight(40) + map.wealthWatcher.WealthPawns.ToString("F0"));
             }
             stringBuilder.AppendLine("Pawn count human: ".PadRight(40) + incidentTarget.PlayerPawnsForStoryteller.Where((Pawn p) => p.def.race.Humanlike).Count());
             stringBuilder.AppendLine("Pawn count animal: ".PadRight(40) + incidentTarget.PlayerPawnsForStoryteller.Where((Pawn p) => p.def.race.Animal).Count());
             if (map != null)
             {
                 stringBuilder.AppendLine("StoryDanger: ".PadRight(40) + map.dangerWatcher.DangerRating);
                 stringBuilder.AppendLine("FireDanger: ".PadRight(40) + map.fireWatcher.FireDanger.ToString("F2"));
                 stringBuilder.AppendLine("LastThreatBigTick days ago: ".PadRight(40) + (Find.TickManager.TicksGame - map.storyState.LastThreatBigTick).ToStringTicksToDays());
             }
         }
         stringBuilder.AppendLine();
         stringBuilder.AppendLine("LIST OF ALL INCIDENT TARGETS");
         stringBuilder.AppendLine("------------------------");
         for (int i = 0; i < AllIncidentTargets.Count; i++)
         {
             stringBuilder.AppendLine(i + ". " + AllIncidentTargets[i].ToString());
         }
         debugStringCached = stringBuilder.ToString();
     }
     return(debugStringCached);
 }
Exemple #3
0
        public static float GetNaturalRandomSelectionWeight(QuestScriptDef quest, float points, StoryState storyState)
        {
            if (quest.rootSelectionWeight <= 0f || points < quest.rootMinPoints || StorytellerUtility.GetProgressScore(storyState.Target) < quest.rootMinProgressScore)
            {
                return(0f);
            }
            float num = quest.rootSelectionWeight;

            for (int i = 0; i < storyState.RecentRandomQuests.Count; i++)
            {
                if (storyState.RecentRandomQuests[i] == quest)
                {
                    switch (i)
                    {
                    case 0:
                        num *= 0.01f;
                        break;

                    case 1:
                        num *= 0.3f;
                        break;

                    case 2:
                        num *= 0.5f;
                        break;

                    case 3:
                        num *= 0.7f;
                        break;

                    case 4:
                        num *= 0.9f;
                        break;
                    }
                }
            }
            if (!quest.canGiveRoyalFavor && PlayerWantsRoyalFavorFromAnyFaction())
            {
                int   num2 = (storyState.LastRoyalFavorQuestTick != -1) ? storyState.LastRoyalFavorQuestTick : 0;
                float x    = (float)(Find.TickManager.TicksGame - num2) / 60000f;
                num *= QuestTuning.NonFavorQuestSelectionWeightFactorByDaysSinceFavorQuestCurve.Evaluate(x);
            }
            return(num);

            bool PlayerWantsRoyalFavorFromAnyFaction()
            {
                List <Faction> allFactionsListForReading = Find.FactionManager.AllFactionsListForReading;

                for (int j = 0; j < allFactionsListForReading.Count; j++)
                {
                    if (allFactionsListForReading[j].allowRoyalFavorRewards && allFactionsListForReading[j] != Faction.OfPlayer && allFactionsListForReading[j].def.HasRoyalTitles)
                    {
                        return(true);
                    }
                }
                return(false);
            }
        }
Exemple #4
0
        public static float GetNaturalRandomSelectionWeight(QuestScriptDef quest, float points, StoryState storyState)
        {
            if (quest.rootSelectionWeight <= 0f || points < quest.rootMinPoints || StorytellerUtility.GetProgressScore(storyState.Target) < quest.rootMinProgressScore)
            {
                return(0f);
            }
            float num = quest.rootSelectionWeight;

            if (quest.rootSelectionWeightFactorFromPointsCurve != null)
            {
                num *= quest.rootSelectionWeightFactorFromPointsCurve.Evaluate(points);
            }
            for (int i = 0; i < storyState.RecentRandomQuests.Count; i++)
            {
                if (storyState.RecentRandomQuests[i] == quest)
                {
                    switch (i)
                    {
                    case 0:
                        num *= 0.01f;
                        break;

                    case 1:
                        num *= 0.3f;
                        break;

                    case 2:
                        num *= 0.5f;
                        break;

                    case 3:
                        num *= 0.7f;
                        break;

                    case 4:
                        num *= 0.9f;
                        break;
                    }
                }
            }
            if (!quest.canGiveRoyalFavor && PlayerWantsRoyalFavorFromAnyFaction())
            {
                int   num2 = ((storyState.LastRoyalFavorQuestTick != -1) ? storyState.LastRoyalFavorQuestTick : 0);
                float x    = (float)(Find.TickManager.TicksGame - num2) / 60000f;
                num *= QuestTuning.NonFavorQuestSelectionWeightFactorByDaysSinceFavorQuestCurve.Evaluate(x);
            }
            return(num);