Exemplo n.º 1
0
        private static void GenerateLabQuest()
        {
            Slate slate = new Slate();
            Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(InternalDefOf.GR_OpportunitySite_AbandonedLab, slate);

            QuestUtility.SendLetterQuestAvailable(quest);
        }
Exemplo n.º 2
0
        private static void GenerateMechLabQuestNow()
        {
            Slate slate = new Slate();
            Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(InternalDefOf.GR_OpportunitySite_BiomechanicalLab, slate);

            QuestUtility.SendLetterQuestAvailable(quest);
        }
Exemplo n.º 3
0
 static bool TryExecuteWorkerPrefix(IncidentParms parms, IncidentDef ___def)
 {
     for (int i = 0; i < WG_GOM_setting.questnum; i++)
     {
         QuestUtility.SendLetterQuestAvailable(QuestUtility.GenerateQuestAndMakeAvailable(___def.questScriptDef ?? parms.questScriptDef ?? NaturalRandomQuestChooser.ChooseNaturalRandomQuest(parms.points, parms.target), parms.points));
     }
     return(true);
 }
 public void ActivateQuest(Pawn accepter, QuestInfo questInfo)
 {
     Find.QuestManager.Add(questInfo.quest);
     questInfo.quest.Accept(accepter);
     QuestUtility.SendLetterQuestAvailable(questInfo.quest);
     questInfo.currencyInfo?.Buy(questInfo);
     availableQuests.Remove(questInfo);
 }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
 public void ActivateQuest(Pawn accepter, QuestInfo questInfo)
 {
     Log.Message("1 questInfo.quest: " + questInfo.quest.State + " - " + questInfo.quest.initiallyAccepted);
     Find.QuestManager.Add(questInfo.quest);
     questInfo.quest.Accept(accepter);
     QuestUtility.SendLetterQuestAvailable(questInfo.quest);
     questInfo.currencyInfo?.Buy(questInfo);
     availableQuests.Remove(questInfo);
     Log.Message("2 questInfo.quest: " + questInfo.quest.State + " - " + questInfo.quest.initiallyAccepted);
 }
Exemplo n.º 7
0
 protected override bool TryExecuteWorker(IncidentParms parms)
 {
     // give quest - 1.1 ver!
     QuestUtility.SendLetterQuestAvailable(QuestUtility.GenerateQuestAndMakeAvailable(def.questScriptDef ?? parms.questScriptDef ?? NaturalRandomQuestChooser.ChooseNaturalRandomQuest(parms.points, parms.target), parms.points));
     QuestUtility.SendLetterQuestAvailable(QuestUtility.GenerateQuestAndMakeAvailable(def.questScriptDef ?? parms.questScriptDef ?? NaturalRandomQuestChooser.ChooseNaturalRandomQuest(parms.points, parms.target), parms.points));
     QuestUtility.SendLetterQuestAvailable(QuestUtility.GenerateQuestAndMakeAvailable(def.questScriptDef ?? parms.questScriptDef ?? NaturalRandomQuestChooser.ChooseNaturalRandomQuest(parms.points, parms.target), parms.points));
     QuestUtility.SendLetterQuestAvailable(QuestUtility.GenerateQuestAndMakeAvailable(def.questScriptDef ?? parms.questScriptDef ?? NaturalRandomQuestChooser.ChooseNaturalRandomQuest(parms.points, parms.target), parms.points));
     QuestUtility.SendLetterQuestAvailable(QuestUtility.GenerateQuestAndMakeAvailable(def.questScriptDef ?? parms.questScriptDef ?? NaturalRandomQuestChooser.ChooseNaturalRandomQuest(parms.points, parms.target), parms.points));
     QuestUtility.SendLetterQuestAvailable(QuestUtility.GenerateQuestAndMakeAvailable(def.questScriptDef ?? parms.questScriptDef ?? NaturalRandomQuestChooser.ChooseNaturalRandomQuest(parms.points, parms.target), parms.points));
     return(true);
 }
Exemplo n.º 8
0
        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());
        }
Exemplo n.º 9
0
        public override void Execute()
        {
            QuestScriptDef scriptDef = DefDatabase <QuestScriptDef> .GetNamed("TKUtilsViewerRescue");

            float threatPoints = StorytellerUtility.DefaultSiteThreatPointsNow();

            var component = Current.Game.GetComponent <GameComponentPawns>();

            if (component != null && component.pawnHistory.ContainsKey(Viewer.username.ToLower()))
            {
                component.pawnHistory.Remove(Viewer.username.ToLower());
            }

            ViewerRescue.QueuedViewers.Enqueue(_report);
            QuestUtility.SendLetterQuestAvailable(QuestUtility.GenerateQuestAndMakeAvailable(scriptDef, threatPoints));
            Viewer.Charge(storeIncident);
        }
        public override void WorldComponentTick()
        {
            base.WorldComponentTick();



            if (tickCounter > ticksToNextQuest)
            {
                Slate slate = new Slate();
                Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(InternalDefOf.GR_OpportunitySite_AbandonedLab, slate);

                QuestUtility.SendLetterQuestAvailable(quest);
                ticksToNextQuest = (int)(60000 * Rand.RangeInclusive(10, 30) * GeneticRim_Mod.settings.GR_QuestRate);
                tickCounter      = 0;
            }
            tickCounter++;
        }
 private void GenerateQuest(QuestScriptDef script, Slate slate)
 {
     if (script.IsRootDecree)
     {
         Pawn pawn = slate.Get <Pawn>("asker");
         if (pawn.royalty.AllTitlesForReading.NullOrEmpty())
         {
             pawn.royalty.SetTitle(Faction.OfEmpire, RoyalTitleDefOf.Knight, grantRewards: false);
             Messages.Message("Dev: Gave " + RoyalTitleDefOf.Knight.label + " title to " + pawn.LabelCap, pawn, MessageTypeDefOf.NeutralEvent, historical: false);
         }
         Find.CurrentMap.StoryState.RecordDecreeFired(script);
     }
     else
     {
         Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(script, slate);
         if (!quest.hidden)
         {
             QuestUtility.SendLetterQuestAvailable(quest);
         }
     }
 }
Exemplo n.º 12
0
        public override void Tick()
        {
            base.Tick();

            tickCounter--;

            if (tickCounter % tickInterval == 0)
            {
                light = !light;
                InternalDefOf.GR_Beep.PlayOneShot(new TargetInfo(this.Position, this.Map, false));
            }

            if (tickCounter == 400)
            {
                tickInterval = 30;
            }
            if (tickCounter == 250)
            {
                tickInterval = 15;
            }
            if (tickCounter == 150)
            {
                tickInterval = 10;
            }
            if (tickCounter == 75)
            {
                tickInterval = 5;
            }

            if (tickCounter <= 0)
            {
                GenExplosion.DoExplosion(this.Position, this.Map, 2.9f, DamageDefOf.Flame, this, -1, -1, null, null, null, null, null, 0f, 1, false, null, 0f, 1);
                Slate slate = new Slate();
                Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(InternalDefOf.GR_OpportunitySite_BiomechanicalLab, slate);

                QuestUtility.SendLetterQuestAvailable(quest);
                this.Destroy();
            }
        }
        private static void GenerateQuests(int count, bool logDescOnly)
        {
            Action <QuestScriptDef, Slate> generateQuest = delegate(QuestScriptDef script, Slate slate)
            {
                int num = 0;
                for (int i = 0; i < count; i++)
                {
                    if (script.IsRootDecree)
                    {
                        Pawn pawn = slate.Get <Pawn>("asker");
                        if (pawn.royalty.AllTitlesForReading.NullOrEmpty())
                        {
                            pawn.royalty.SetTitle(Faction.Empire, RoyalTitleDefOf.Knight, grantRewards: false);
                            Messages.Message("Dev: Gave " + RoyalTitleDefOf.Knight.label + " title to " + pawn.LabelCap, pawn, MessageTypeDefOf.NeutralEvent, historical: false);
                        }
                        Find.CurrentMap.StoryState.RecordDecreeFired(script);
                    }
                    if (count != 1 && !script.CanRun(slate))
                    {
                        num++;
                    }
                    else if (!logDescOnly)
                    {
                        Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(script, slate);
                        if (!quest.hidden)
                        {
                            QuestUtility.SendLetterQuestAvailable(quest);
                        }
                    }
                    else
                    {
                        Quest  quest2 = QuestUtility.GenerateQuestAndMakeAvailable(script, slate);
                        string text2  = quest2.name;
                        if (slate.Exists("points"))
                        {
                            text2 = text2 + "(" + slate.Get("points", 0f) + " points)";
                        }
                        if (slate.Exists("population"))
                        {
                            text2 = text2 + "(" + slate.Get("population", 0) + " population)";
                        }
                        text2 += "\n--------------\n" + quest2.description + "\n--------------";
                        Log.Message(text2);
                        Find.QuestManager.Remove(quest2);
                    }
                }
                if (num != 0)
                {
                    Messages.Message("Dev: Generated only " + (count - num) + " quests.", MessageTypeDefOf.RejectInput, historical: false);
                }
            };
            Action <QuestScriptDef, Slate, Action> selectPoints = delegate(QuestScriptDef script, Slate slate, Action next)
            {
                List <DebugMenuOption> list3 = new List <DebugMenuOption>();
                float localPoints            = default(float);
                foreach (float item in DebugActionsUtility.PointsOptions(extended: false))
                {
                    localPoints = item;
                    string text = item.ToString("F0") + " points";
                    if (script != null)
                    {
                        if (script.IsRootDecree)
                        {
                            slate.Set("asker", PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonists.RandomElement());
                        }
                        if (script == QuestScriptDefOf.LongRangeMineralScannerLump)
                        {
                            slate.Set("targetMineableThing", ThingDefOf.Gold);
                            slate.Set("targetMineable", ThingDefOf.MineableGold);
                            slate.Set("worker", PawnsFinder.AllMaps_FreeColonists.FirstOrDefault());
                        }
                        slate.Set("points", localPoints);
                        if (!script.CanRun(slate))
                        {
                            text += " [not now]";
                        }
                    }
                    list3.Add(new DebugMenuOption(text, DebugMenuOptionMode.Action, delegate
                    {
                        slate.Set("points", localPoints);
                        next();
                    }));
                }
                Find.WindowStack.Add(new Dialog_DebugOptionListLister(list3));
            };
            Action <Slate, Action> selectPopulation = delegate(Slate slate, Action next)
            {
                List <DebugMenuOption> list2 = new List <DebugMenuOption>
                {
                    new DebugMenuOption("*Don't set", DebugMenuOptionMode.Action, next)
                };
                int localPopulation = default(int);
                foreach (int item2 in DebugActionsUtility.PopulationOptions())
                {
                    localPopulation = item2;
                    list2.Add(new DebugMenuOption(item2.ToString("F0") + " colony population", DebugMenuOptionMode.Action, delegate
                    {
                        slate.Set("population", localPopulation);
                        next();
                    }));
                }
                Find.WindowStack.Add(new Dialog_DebugOptionListLister(list2));
            };
            List <DebugMenuOption> list = new List <DebugMenuOption>();

            list.Add(new DebugMenuOption("*Natural random", DebugMenuOptionMode.Action, delegate
            {
                Slate slate3 = new Slate();
                selectPoints(null, slate3, delegate
                {
                    float points           = slate3.Get("points", 0f);
                    QuestScriptDef script2 = NaturalRandomQuestChooser.ChooseNaturalRandomQuest(points, Find.CurrentMap);
                    if (script2.affectedByPopulation)
                    {
                        selectPopulation(slate3, delegate
                        {
                            generateQuest(script2, slate3);
                        });
                    }
                    else
                    {
                        generateQuest(script2, slate3);
                    }
                });
            }));
            foreach (QuestScriptDef scriptDef in DefDatabase <QuestScriptDef> .AllDefs.Where((QuestScriptDef x) => x.IsRootAny))
            {
                QuestScriptDef localScriptDef = scriptDef;
                string         defName        = localScriptDef.defName;
                list.Add(new DebugMenuOption(defName, DebugMenuOptionMode.Action, delegate
                {
                    Slate slate2 = new Slate();
                    if (localScriptDef.affectedByPoints && localScriptDef.affectedByPopulation)
                    {
                        selectPoints(localScriptDef, slate2, delegate
                        {
                            selectPopulation(slate2, delegate
                            {
                                generateQuest(localScriptDef, slate2);
                            });
                        });
                    }
                    else if (scriptDef.affectedByPoints)
                    {
                        selectPoints(localScriptDef, slate2, delegate
                        {
                            generateQuest(localScriptDef, slate2);
                        });
                    }
                    else if (localScriptDef.affectedByPopulation)
                    {
                        selectPopulation(slate2, delegate
                        {
                            generateQuest(localScriptDef, slate2);
                        });
                    }
                    else
                    {
                        generateQuest(localScriptDef, slate2);
                    }
                }));
            }
            Find.WindowStack.Add(new Dialog_DebugOptionListLister(list.OrderBy((DebugMenuOption op) => op.label)));
        }
Exemplo n.º 14
0
        public override void DoWindowContents(Rect inRect)
        {
            var num = inRect.y;

            //if (!this.title.NullOrEmpty())
            //{
            Verse.Text.Font = GameFont.Medium;
            Widgets.Label(new Rect(0f, num, inRect.width, TitleHeight), title);
            num += TitleHeight;
            //}
            Verse.Text.Font = GameFont.Small;
            var outRect  = new Rect(inRect.x, num, inRect.width, inRect.height - ButtonHeight - 5f - num);
            var width    = outRect.width - 16f;
            var viewRect = new Rect(0f, 0f, width, CalcHeight(width) + CalcOptionsHeight(width));

            Widgets.BeginScrollView(outRect, ref scrollPosition, viewRect, true);
            Widgets.Label(new Rect(0f, 0f, viewRect.width, viewRect.height - CalcOptionsHeight(width)),
                          Text.AdjustedFor(questPawn.pawn));
            if (questPawn.questsAndIncidents.Count == 0)
            {
                questPawn.GenerateQuestsAndIncidents();
            }
            for (var index = 0; index < questPawn.questsAndIncidents.Count; index++)
            {
                string defname;
                string keyedName;
                object questDef  = null;
                var    questName = string.Empty;
                if (questPawn.questsAndIncidents[index] is QuestScriptDef questScriptDef)
                {
                    defname   = questScriptDef.defName;
                    keyedName = "RimQuest_" + defname;
                    if ((!Prefs.DevMode && keyedName.Translate() == keyedName) || (Prefs.DevMode && keyedName.Translate().ToString().Contains("RìṁQùèșṭ_")))
                    {
                        if (defname.Contains("_"))
                        {
                            defname = questScriptDef.defName.Split('_')[1];
                        }
                        if (questScriptDef.defName.Contains("Hospitality"))
                        {
                            defname = questScriptDef.defName.Replace("_", " ");
                        }
                        questName = Regex.Replace(defname, "(\\B[A-Z])", " $1");
                    }
                    else
                    {
                        questName = keyedName.Translate();
                    }
                    questDef = questScriptDef;
                }
                if (questPawn.questsAndIncidents[index] is IncidentDef incidentDef)
                {
                    defname   = incidentDef.defName;
                    questName = incidentDef.LabelCap;
                    questDef  = incidentDef;
                }
                if (string.IsNullOrEmpty(questName))
                {
                    continue;
                }

                var rect6 = new Rect(24f,
                                     viewRect.height - CalcOptionsHeight(width) +
                                     ((Verse.Text.CalcHeight(questName, width) + 12f) * index) + 8f, viewRect.width / 2f,
                                     Verse.Text.CalcHeight(questName, width));
                if (Mouse.IsOver(rect6))
                {
                    Widgets.DrawHighlight(rect6);
                }
                if (Widgets.RadioButtonLabeled(rect6, questName, selectedQuest == questDef))
                {
                    selectedQuest = questDef;
                }
            }
            Widgets.EndScrollView();
            if (Widgets.ButtonText(new Rect(0f, inRect.height - ButtonHeight, (inRect.width / 2f) - 20f, ButtonHeight),
                                   "CancelButton".Translate(), true, false, true))
            {
                Close(true);
            }
            if (actualPlayerSilver >= actualSilverCost)
            {
                if (selectedQuest != null &&
                    Widgets.ButtonText(
                        new Rect((inRect.width / 2f) + 20f, inRect.height - ButtonHeight, (inRect.width / 2f) - 20f, ButtonHeight),
                        "Confirm".Translate() + " (" + "RQ_SilverAmt".Translate(actualSilverCost) + ")", true, false, true))
                {
                    if (selectedQuest is QuestScriptDef questDef)
                    {
                        var incidentParms   = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.GiveQuest, Find.World);
                        var storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) =>
                                                                                      x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain);
                        incidentParms = storytellerComp.GenerateParms(IncidentCategoryDefOf.GiveQuest, incidentParms.target);
                        QuestUtility.SendLetterQuestAvailable(QuestUtility.GenerateQuestAndMakeAvailable(questDef, incidentParms.points));
                    }
                    if (selectedQuest is IncidentDef incidentDef)
                    {
                        IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(incidentDef.category, Find.World);
                        if (incidentDef.pointsScaleable)
                        {
                            StorytellerComp storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) =>
                                                                                                      x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain);
                            incidentParms = storytellerComp.GenerateParms(incidentDef.category, incidentParms.target);
                        }
                        incidentDef.Worker.TryExecute(incidentParms);
                    }
                    var questPawns = Find.World.GetComponent <RimQuestTracker>().questPawns;
                    if (questPawns != null && questPawns.Contains(questPawn))
                    {
                        questPawns.Remove(questPawn);
                    }

                    SoundDefOf.ExecuteTrade.PlayOneShotOnCamera(null);
                    ReceiveSilver(questPawn.pawn, actualSilverCost);
                    Close(true);
                    Find.WindowStack.Add(new Dialog_MessageBox(
                                             "RQ_QuestDialogTwo".Translate(questPawn.pawn.LabelShort, interactor.LabelShort)
                                             .AdjustedFor(questPawn.pawn), "OK".Translate(), null, null, null, title));
                }
            }
            else
            {
                if (Widgets.ButtonText(
                        new Rect((inRect.width / 2f) + 20f, inRect.height - ButtonHeight, (inRect.width / 2f) - 20f, ButtonHeight),
                        "RQ_LackFunds".Translate(), true, false, true))
                {
                    SoundDefOf.ClickReject.PlayOneShotOnCamera(null);
                    Messages.Message("RQ_LackFundsMessage".Translate(), MessageTypeDefOf.RejectInput);
                }
            }
        }
Exemplo n.º 15
0
        private static void GenerateQuests(int count, bool logDescOnly)
        {
            List <DebugMenuOption> list      = new List <DebugMenuOption>();
            float localPoints                = default(float);
            Slate testSlate                  = default(Slate);
            Action <QuestScriptDef> generate = delegate(QuestScriptDef script)
            {
                List <DebugMenuOption> list2 = new List <DebugMenuOption>();
                foreach (float item in DebugActionsUtility.PointsOptions(extended: false))
                {
                    localPoints = item;
                    string text = item.ToString("F0");
                    testSlate = new Slate();
                    testSlate.Set("points", localPoints);
                    if (script != null)
                    {
                        if (script.IsRootDecree)
                        {
                            testSlate.Set("asker", PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonists.RandomElement());
                        }
                        if (script == QuestScriptDefOf.LongRangeMineralScannerLump)
                        {
                            testSlate.Set("targetMineable", ThingDefOf.MineableGold);
                            testSlate.Set("worker", PawnsFinder.AllMaps_FreeColonists.FirstOrDefault());
                        }
                        if (!script.CanRun(testSlate))
                        {
                            text += " [not now]";
                        }
                    }
                    list2.Add(new DebugMenuOption(text, DebugMenuOptionMode.Action, delegate
                    {
                        int num   = 0;
                        bool flag = script == null;
                        for (int i = 0; i < count; i++)
                        {
                            if (flag)
                            {
                                script = NaturalRandomQuestChooser.ChooseNaturalRandomQuest(localPoints, Find.CurrentMap);
                                Find.CurrentMap.StoryState.RecordRandomQuestFired(script);
                            }
                            if (script.IsRootDecree)
                            {
                                Pawn pawn = testSlate.Get <Pawn>("asker");
                                if (pawn.royalty.AllTitlesForReading.NullOrEmpty())
                                {
                                    pawn.royalty.SetTitle(Faction.Empire, RoyalTitleDefOf.Knight, grantRewards: false);
                                    Messages.Message("Dev: Gave " + RoyalTitleDefOf.Knight.label + " title to " + pawn.LabelCap, pawn, MessageTypeDefOf.NeutralEvent, historical: false);
                                }
                                Find.CurrentMap.StoryState.RecordDecreeFired(script);
                            }
                            if (count != 1 && !script.CanRun(testSlate))
                            {
                                num++;
                            }
                            else if (!logDescOnly)
                            {
                                QuestUtility.SendLetterQuestAvailable(QuestUtility.GenerateQuestAndMakeAvailable(script, testSlate));
                            }
                            else
                            {
                                Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(script, testSlate);
                                Log.Message(quest.name + " (" + localPoints + " points)\n--------------\n" + quest.description + "\n--------------");
                                Find.QuestManager.Remove(quest);
                            }
                        }
                        if (num != 0)
                        {
                            Messages.Message("Dev: Generated only " + (count - num) + " quests.", MessageTypeDefOf.RejectInput, historical: false);
                        }
                    }));
                }
                Find.WindowStack.Add(new Dialog_DebugOptionListLister(list2));
            };

            list.Add(new DebugMenuOption("*Natural random", DebugMenuOptionMode.Action, delegate
            {
                generate(null);
            }));
            foreach (QuestScriptDef item2 in DefDatabase <QuestScriptDef> .AllDefs.Where((QuestScriptDef x) => x.IsRootAny))
            {
                QuestScriptDef localRuleDef = item2;
                string         defName      = localRuleDef.defName;
                list.Add(new DebugMenuOption(defName, DebugMenuOptionMode.Action, delegate
                {
                    generate(localRuleDef);
                }));
            }
            Find.WindowStack.Add(new Dialog_DebugOptionListLister(list.OrderBy((DebugMenuOption op) => op.label)));
        }