Пример #1
0
        public void IssueDecree(bool causedByMentalBreak, string mentalBreakReason = null)
        {
            if (!ModLister.RoyaltyInstalled)
            {
                Log.ErrorOnce("Decrees are a Royalty-specific game system. If you want to use this code please check ModLister.RoyaltyInstalled before calling it. See rules on the Ludeon forum for more info.", 281653);
                return;
            }
            IIncidentTarget mapHeld = pawn.MapHeld;
            IIncidentTarget target  = mapHeld ?? Find.World;

            if (PossibleDecreeQuests.TryRandomElementByWeight((QuestScriptDef x) => NaturalRandomQuestChooser.GetNaturalDecreeSelectionWeight(x, target.StoryState), out QuestScriptDef result))
            {
                lastDecreeTicks = Find.TickManager.TicksGame;
                Slate slate = new Slate();
                slate.Set("points", StorytellerUtility.DefaultThreatPointsNow(target));
                slate.Set("asker", pawn);
                Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(result, slate);
                target.StoryState.RecordDecreeFired(result);
                string str  = (!causedByMentalBreak) ? ((string)"LetterLabelRandomDecree".Translate(pawn)) : ((string)("WildDecree".Translate() + ": " + pawn.LabelShortCap));
                string text = (!causedByMentalBreak) ? ((string)"LetterRandomDecree".Translate(pawn)) : ((string)"LetterDecreeMentalBreak".Translate(pawn));
                if (mentalBreakReason != null)
                {
                    text = text + "\n\n" + mentalBreakReason;
                }
                text += "\n\n" + "LetterDecree_Quest".Translate(quest.name);
                ChoiceLetter let = LetterMaker.MakeLetter(str, text, IncidentDefOf.GiveQuest_Random.letterDef, LookTargets.Invalid, null, quest);
                Find.LetterStack.ReceiveLetter(let);
            }
        }
        protected override void GiveQuest(IncidentParms parms, QuestScriptDef questDef)
        {
            Slate slate = new Slate();

            slate.Set("points", parms.points);
            slate.Set("map", (Map)parms.target);
            QuestUtility.SendLetterQuestAvailable(QuestUtility.GenerateQuestAndMakeAvailable(questDef, slate));
        }
Пример #3
0
 public override void Notify_QuestSignalReceived(Signal signal)
 {
     base.Notify_QuestSignalReceived(signal);
     if (signal.tag == inSignal)
     {
         QuestUtility.GenerateQuestAndMakeAvailable(questDef, GetSlate()).Accept(acceptee);
     }
 }
Пример #4
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(def.questScriptDef ?? parms.questScriptDef ?? NaturalRandomQuestChooser.ChooseNaturalRandomQuest(parms.points, parms.target), parms.points);

            if (!quest.hidden)
            {
                QuestUtility.SendLetterQuestAvailable(quest);
            }
            return(true);
        }
Пример #5
0
        public static void GenerateBestowingCeremonyQuest(Pawn pawn, Faction faction)
        {
            Slate slate = new Slate();

            slate.Set("titleHolder", pawn);
            slate.Set("bestowingFaction", faction);
            if (QuestScriptDefOf.BestowingCeremony.CanRun(slate))
            {
                QuestUtility.SendLetterQuestAvailable(QuestUtility.GenerateQuestAndMakeAvailable(QuestScriptDefOf.BestowingCeremony, slate));
            }
        }
        protected override void DoFind(Pawn worker)
        {
            Slate slate = new Slate();

            slate.Set("map", parent.Map);
            slate.Set("targetMineable", targetMineable);
            slate.Set("worker", worker);
            if (QuestScriptDefOf.LongRangeMineralScannerLump.CanRun(slate))
            {
                Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(QuestScriptDefOf.LongRangeMineralScannerLump, slate);
                Find.LetterStack.ReceiveLetter(quest.name, quest.description, LetterDefOf.PositiveEvent, null, null, quest);
            }
        }
Пример #7
0
        private static DiaOption RequestAICoreQuest(Map map, Faction faction, Pawn negotiator)
        {
            TaggedString taggedString = "RequestAICoreInformation".Translate(ThingDefOf.AIPersonaCore.label, 1500.ToString());

            if (faction.PlayerGoodwill < 40)
            {
                DiaOption diaOption = new DiaOption(taggedString);
                diaOption.Disable("NeedGoodwill".Translate(40.ToString("F0")));
                return(diaOption);
            }
            bool  num   = PlayerItemAccessibilityUtility.ItemStashHas(ThingDefOf.AIPersonaCore);
            Slate slate = new Slate();

            slate.Set("points", StorytellerUtility.DefaultThreatPointsNow(Find.World));
            slate.Set("asker", faction.leader);
            slate.Set("itemStashSingleThing", ThingDefOf.AIPersonaCore);
            bool flag = QuestScriptDefOf.OpportunitySite_ItemStash.CanRun(slate);

            if (num || !flag)
            {
                DiaOption diaOption2 = new DiaOption(taggedString);
                diaOption2.Disable("NoKnownAICore".Translate(1500));
                return(diaOption2);
            }
            if (AmountSendableSilver(map) < 1500)
            {
                DiaOption diaOption3 = new DiaOption(taggedString);
                diaOption3.Disable("NeedSilverLaunchable".Translate(1500));
                return(diaOption3);
            }
            return(new DiaOption(taggedString)
            {
                action = delegate
                {
                    Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(QuestScriptDefOf.OpportunitySite_ItemStash, slate);
                    if (!quest.hidden)
                    {
                        QuestUtility.SendLetterQuestAvailable(quest);
                    }
                    TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, 1500, map, null);
                    Current.Game.GetComponent <GameComponent_OnetimeNotification>().sendAICoreRequestReminder = false;
                },
                link = new DiaNode("RequestAICoreInformationResult".Translate(faction.leader).CapitalizeFirst())
                {
                    options =
                    {
                        OKToRoot(faction, negotiator)
                    }
                }
            });
        }
Пример #8
0
        public static DiaNode RoyalHeirChangeCandidates(Faction faction, Pawn factionRepresentative, Pawn negotiator)
        {
            DiaNode       diaNode = new DiaNode("ChooseHeir".Translate(negotiator.Named("HOLDER")));
            RoyalTitleDef title   = negotiator.royalty.GetCurrentTitle(faction);
            Pawn          heir2   = negotiator.royalty.GetHeir(faction);

            foreach (Pawn item in PawnsFinder.AllMaps_FreeColonistsAndPrisonersSpawned)
            {
                DiaOption diaOption = new DiaOption(item.Name.ToStringFull);
                if (item == negotiator || item == heir2)
                {
                    continue;
                }
                if (item.royalty != null)
                {
                    RoyalTitleDef currentTitle = item.royalty.GetCurrentTitle(faction);
                    if (currentTitle != null && currentTitle.seniority >= title.seniority)
                    {
                        continue;
                    }
                }
                if (item.IsQuestLodger())
                {
                    continue;
                }
                Pawn   heir         = item;
                Action confirmedAct = delegate
                {
                    QuestScriptDef changeRoyalHeir = QuestScriptDefOf.ChangeRoyalHeir;
                    Slate          slate           = new Slate();
                    slate.Set("points", title.changeHeirQuestPoints);
                    slate.Set("asker", factionRepresentative);
                    slate.Set("titleHolder", negotiator);
                    slate.Set("titleHeir", heir);
                    slate.Set("titlePreviousHeir", negotiator.royalty.GetHeir(faction));
                    Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(changeRoyalHeir, slate);
                    if (!quest.hidden)
                    {
                        QuestUtility.SendLetterQuestAvailable(quest);
                    }
                };
                diaOption.link = RoyalHeirChangeConfirm(faction, negotiator, heir2, confirmedAct);
                diaNode.options.Add(diaOption);
            }
            DiaOption diaOption2 = new DiaOption("GoBack".Translate());

            diaOption2.linkLateBind = ResetToRoot(faction, negotiator);
            diaNode.options.Add(diaOption2);
            return(diaNode);
        }
 private void CallShuttle(IntVec3 landingCell)
 {
     if (caller.Spawned)
     {
         QuestScriptDef permit_CallShuttle = QuestScriptDefOf.Permit_CallShuttle;
         Slate          slate = new Slate();
         slate.Set("asker", caller);
         slate.Set("map", caller.Map);
         slate.Set("landingCell", landingCell);
         slate.Set("permitFaction", calledFaction);
         QuestUtility.GenerateQuestAndMakeAvailable(permit_CallShuttle, slate);
         caller.royalty.GetPermit(def, calledFaction).Notify_Used();
         if (!free)
         {
             caller.royalty.TryRemoveFavor(calledFaction, def.royalAid.favorCost);
         }
     }
 }
 private void CallLaborers(Pawn pawn, Map map, Faction faction, bool free)
 {
     if (!faction.HostileTo(Faction.OfPlayer))
     {
         QuestScriptDef permit_CallLaborers = QuestScriptDefOf.Permit_CallLaborers;
         Slate          slate = new Slate();
         slate.Set("map", map);
         slate.Set("laborersCount", def.royalAid.pawnCount);
         slate.Set("permitFaction", faction);
         slate.Set("laborersPawnKind", def.royalAid.pawnKindDef);
         slate.Set("laborersDurationDays", def.royalAid.aidDurationDays);
         QuestUtility.GenerateQuestAndMakeAvailable(permit_CallLaborers, slate);
         pawn.royalty.GetPermit(def, faction).Notify_Used();
         if (!free)
         {
             pawn.royalty.TryRemoveFavor(faction, def.royalAid.favorCost);
         }
     }
 }
Пример #11
0
 protected virtual void GiveQuest(IncidentParms parms, QuestScriptDef questDef)
 {
     QuestUtility.SendLetterQuestAvailable(QuestUtility.GenerateQuestAndMakeAvailable(questDef, parms.points));
 }