public override void Arrived(Caravan caravan)
        {
            List <Thing> list = CaravanInventoryUtility.TakeThings(caravan, (Thing thing) =>
            {
                if (quest.RequestItems.ContainsKey(thing.def))
                {
                    int remaining = quest.RequestItems[thing.def];

                    int num    = Mathf.Min(remaining, thing.stackCount);
                    remaining -= num;
                    quest.RequestItems[thing.def] = remaining;

                    return(num);
                }

                return(0);
            });

            for (int i = 0; i < list.Count; i++)
            {
                list[i].Destroy();
            }

            QuestSite site = (QuestSite)mapParent;

            site.EndQuest(caravan, EndCondition.Success);
        }
Exemplo n.º 2
0
        public override void Notify_CaravanFormed(QuestSite site, Caravan caravan)
        {
            foreach (var pawn in savedPawns)
            {
                if (pawn != null && !pawn.Dead)
                {
                    caravan.AddPawn(pawn, false);

                    pawn.DestroyOrPassToWorld();
                }
            }

            saved = true;
            ResetIcon();

            Settlement settlement = Find.WorldObjects.Settlements.Where(delegate(Settlement settl)
            {
                return(settl.Faction == Faction && Find.WorldReachability.CanReach(site.Tile, settl.Tile));
            }).OrderBy(x => Find.WorldGrid.ApproxDistanceInTiles(site.Tile, x.Tile)).FirstOrDefault();

            if (settlement != null)
            {
                int arrivalTime = CaravanArrivalTimeEstimator.EstimatedTicksToArrive(site.Tile, settlement.Tile, caravan);
                TicksToPass   = arrivalTime + (3 * 60000);
                UnlimitedTime = false;

                Find.LetterStack.ReceiveLetter("Quest_MissingPeople_Stage2Title".Translate(), "Quest_MissingPeople_Stage2".Translate(TicksToPass.ToStringTicksToDays("0.#")), LetterDefOf.PositiveEvent);
                site.Tile = settlement.Tile;

                Target = new LookTargets(site.Tile);
            }

            Current.Game.DeinitAndRemoveMap(site.Map);
        }
        public override IEnumerable <Gizmo> GetGizmos(QuestSite site)
        {
            foreach (var gizmo in base.GetGizmos(site))
            {
                yield return(gizmo);
            }

            if (site.HasMap)
            {
                yield return(new Command_Action
                {
                    defaultLabel = "Quest_Archotech_567H_GetResources_SignalLabel".Translate(),
                    defaultDesc = "Quest_Archotech_567H_GetResources_SignalDescription".Translate(),
                    icon = ContentFinder <Texture2D> .Get("Quests/send-signal"),
                    action = delegate
                    {
                        if (HostileUtility.AnyNonDownedHostileOnMap(site.Map, Faction))
                        {
                            Messages.Message(Translator.Translate("EnemyOnTheMap"), MessageTypeDefOf.NeutralEvent, false);
                            return;
                        }

                        EndQuestAndGenerateRewards();
                    }
                });
            }
        }
Exemplo n.º 4
0
 public override void Notify_CaravanFormed(QuestSite site, Caravan caravan)
 {
     if (Won)
     {
         site.EndQuest(caravan, EndCondition.Success);
     }
 }
Exemplo n.º 5
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Alliance alliance = parms.target as Alliance;

            if (alliance.Factions.Count == 0)
            {
                return(false);
            }

            FactionInteraction factionInteraction = alliance.Factions.RandomElement();

            if (!Find.WorldObjects.Settlements.Where(x => x.Faction == factionInteraction.Faction &&
                                                     CaravanArrivalTimeEstimator.EstimatedTicksToArrive(Find.AnyPlayerHomeMap.Tile, x.Tile, null).TicksToDays() < 7).TryRandomElement(out Settlement settlement))
            {
                return(false);
            }

            var research     = Find.ResearchManager.currentProj;
            int pointsReward = (int)((research.baseCost - Find.ResearchManager.GetProgress(research)) * 0.3f);
            Alliance_Quest_ResearchSharing quest = new Alliance_Quest_ResearchSharing(factionInteraction.Faction, SkillDef, pointsReward);

            quest.id          = QuestsManager.Communications.UniqueIdManager.GetNextQuestID();
            quest.TicksToPass = 6 * 60000;
            quest.IncidentDef = def;
            QuestSite questSite = quest.CreateSiteFor(settlement.Tile, quest.Faction);

            Find.WorldObjects.Add(questSite);

            QuestsManager.Communications.AddQuest(quest, null);

            SendStandardLetter(parms, questSite, factionInteraction.Faction.Name, pointsReward.ToString());

            return(true);
        }
Exemplo n.º 6
0
        public override bool CanLeaveFromSite(QuestSite site)
        {
            if (HostileUtility.AnyNonDownedHostileOnMap(site.Map, Faction.OfAncientsHostile))
            {
                Messages.Message(Translator.Translate("EnemyOnTheMap"), MessageTypeDefOf.NeutralEvent, false);
                return(false);
            }

            return(true);
        }
Exemplo n.º 7
0
        public override bool CanLeaveFromSite(QuestSite site)
        {
            if (GenHostility.AnyHostileActiveThreatToPlayer(site.Map))
            {
                Messages.Message(Translator.Translate("EnemyOnTheMap"), MessageTypeDefOf.NeutralEvent, false);
                return(false);
            }

            return(true);
        }
Exemplo n.º 8
0
        public override void PostSiteRemove(QuestSite site)
        {
            base.PostSiteRemove(site);

            if (!Won)
            {
                EndQuest(null, EndCondition.Fail);
            }
            else
            {
                EndQuest(null, EndCondition.Success);
            }
        }
Exemplo n.º 9
0
        public override void PostSiteRemove(QuestSite site)
        {
            base.PostSiteRemove(site);

            if (Visited && (Informator == null || Informator.Dead))
            {
                EndQuest(null, EndCondition.Success);
            }
            else
            {
                EndQuest(null, EndCondition.Fail);
            }
        }
Exemplo n.º 10
0
        public override void PostSiteRemove(QuestSite site)
        {
            base.PostSiteRemove(site);

            if (!signalSended)
            {
                EndQuest(null, EndCondition.None);
            }
            else
            {
                EndQuest(null, EndCondition.Success);
            }
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!settings.Active)
            {
                return(false);
            }

            Faction           faction      = GetFaction();
            List <Settlement> factionBases = Find.WorldObjects.Settlements.Where(x => x.Faction == faction &&
                                                                                 CaravanArrivalTimeEstimator.EstimatedTicksToArrive(Find.AnyPlayerHomeMap.Tile, x.Tile, null).TicksToDays() < 7).ToList();

            if (factionBases.Count == 0)
            {
                return(false);
            }

            Settlement factionBase = factionBases.RandomElement();

            if (Find.WorldObjects.WorldObjectAt(factionBase.Tile, QuestRim.WorldObjectDefOfLocal.QuestPlace) != null)
            {
                return(false);
            }

            Quest_ThingsHelp quest = new Quest_ThingsHelp
            {
                id      = QuestsManager.Communications.UniqueIdManager.GetNextQuestID(),
                Faction = faction
            };
            float marketValue = GenerateRequestItems(quest, Find.AnyPlayerHomeMap);

            quest.GenerateRewards(quest.GetQuestThingFilter(), new FloatRange(marketValue * 1.3f, marketValue * 1.7f), new IntRange(3, 6), null, null);

            LookTargets target = new LookTargets(factionBase.Tile);

            quest.Target      = target;
            quest.TicksToPass = Rand.Range(12, 25) * 60000;

            QuestSite questPlace = (QuestSite)WorldObjectMaker.MakeWorldObject(QuestRim.WorldObjectDefOfLocal.QuestPlace);

            questPlace.Tile = factionBase.Tile;
            questPlace.SetFaction(faction);
            questPlace.Init(quest);
            quest.Site = questPlace;

            Find.WorldObjects.Add(questPlace);
            QuestsManager.Communications.AddQuest(quest, QuestsManager.Communications.MakeQuestLetter(quest, description: def.description, lookTarget: target));

            return(true);
        }
Exemplo n.º 12
0
        public override void Notify_CaravanFormed(QuestSite site, Caravan caravan)
        {
            base.Notify_CaravanFormed(site, caravan);

            if (!caravan.pawns.InnerListForReading.Any(x => DropedPawns.Contains(x)))
            {
                Site.EndQuest(null, EndCondition.None);

                Find.LetterStack.ReceiveLetter("Quest_PrisonShipAccident_NCTitle".Translate(), "Quest_PrisonShipAccident_NCDesc".Translate(), LetterDefOf.NeutralEvent);
            }

            DropedPawns.RemoveAll(x => !caravan.ContainsPawn(x));

            UnlimitedTime = false;
            TicksToPass   = 4 * 60000;
        }
Exemplo n.º 13
0
        public override bool CanLeaveFromSite(QuestSite site)
        {
            if (TargetPawn != null && !TargetPawn.Dead)
            {
                Messages.Message("OrderedTargetStillAlive".Translate(TargetPawn.Name.ToStringFull), MessageTypeDefOf.NeutralEvent, false);
                return(false);
            }

            if (TargetPawn != null && HostileUtility.AnyNonDownedHostileOnMap(site.Map, TargetPawn.Faction))
            {
                Messages.Message(Translator.Translate("EnemyOnTheMap"), MessageTypeDefOf.NeutralEvent, false);
                return(false);
            }

            return(true);
        }
Exemplo n.º 14
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!settings.Active)
            {
                return(false);
            }

            Faction faction = GetFaction();
            Map     map     = Find.AnyPlayerHomeMap;

            if (!TryGetNewTile(map.Tile, out int newTile))
            {
                return(false);
            }

            int days                  = Rand.Range(11, 20);
            int passedDays            = Rand.Range(days + 3, days + 7);
            Quest_MissingPeople quest = new Quest_MissingPeople(Rand.Range(3, 9), days, passedDays);

            quest.id      = QuestsManager.Communications.UniqueIdManager.GetNextQuestID();
            quest.Faction = faction;

            int additionalValue = passedDays * 25;

            quest.GenerateRewards(quest.GetQuestThingFilter(), new FloatRange(1200 + additionalValue, 1800 + additionalValue), new IntRange(2, 8), null, null);

            LookTargets target = new LookTargets(newTile);

            quest.Target = target;

            QuestSite questPlace = (QuestSite)WorldObjectMaker.MakeWorldObject(QuestRim.WorldObjectDefOfLocal.QuestPlace);

            questPlace.Tile = newTile;
            questPlace.SetFaction(faction);
            questPlace.Init(quest);
            questPlace.RemoveAfterLeave = false;

            quest.Site = questPlace;

            Find.WorldObjects.Add(questPlace);

            string text = string.Format(def.letterText, faction.Name, days, passedDays, quest.TicksToPass.TicksToDays().ToString("f2")).CapitalizeFirst();

            QuestsManager.Communications.AddQuest(quest, QuestsManager.Communications.MakeQuestLetter(quest, description: text, lookTarget: target));

            return(true);
        }
        public override IEnumerable <Gizmo> GetGizmos(QuestSite site)
        {
            foreach (var gizmo in base.GetGizmos(site))
            {
                yield return(gizmo);
            }

            if (!signalSended && site.HasMap)
            {
                yield return(new Command_Action
                {
                    defaultLabel = "Quest_Archotech_567H_GetResources_SignalLabel".Translate(),
                    defaultDesc = "Quest_Archotech_567H_GetResources_SignalDescription".Translate(),
                    icon = ContentFinder <Texture2D> .Get("Quests/send-signal"),
                    action = delegate
                    {
                        signalSended = true;

                        DiaNode node = new DiaNode("Quest_Archotech_567H_GetResources_SignalDialog".Translate());
                        DiaOption option = new DiaOption("OK");
                        node.options.Add(option);
                        option.resolveTree = true;

                        var dialog = new Dialog_NodeTree(node);
                        Find.WindowStack.Add(dialog);

                        List <Pawn> pawns = site.Map.mapPawns.AllPawnsSpawned.Where(p => p.Faction == Faction && !p.Downed && !p.Dead).ToList();

                        LordJob lordJob = new LordJob_AssaultColony(Faction, canKidnap: false, canTimeoutOrFlee: false, canSteal: false);
                        Lord lord = LordMaker.MakeNewLord(Faction, lordJob, site.Map);
                        lord.numPawnsLostViolently = int.MaxValue;

                        foreach (var p in pawns)
                        {
                            Lord lastLord = p.GetLord();
                            if (lastLord != null)
                            {
                                site.Map.lordManager.RemoveLord(lastLord);
                            }

                            p.ClearMind();
                            lord.AddPawn(p);
                        }
                    }
                });
            }
        }
        private void TryTransfer(Caravan caravan)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("Quest_MissingPeople_End".Translate());
            int saved = 0;

            foreach (var pawn in quest.SavedPawns)
            {
                if (caravan.ContainsPawn(pawn))
                {
                    caravan.RemovePawn(pawn);
                    saved++;
                    builder.AppendLine($"- {pawn.Name.ToStringFull}");
                    pawn.Destroy();
                }
            }

            EndCondition condition = EndCondition.Success;

            if (saved == quest.SavedPawns.Count)
            {
                builder.Append("Quest_MissingPeople_EndFull".Translate(Quest.Faction.Name));
            }
            else
            {
                if (saved == 0)
                {
                    builder.Append("Quest_MissingPeople_Fiasko".Translate(Quest.Faction.Name));
                    condition = EndCondition.Fail;
                }
                else
                {
                    builder.Append("Quest_MissingPeople_EndPart".Translate());
                }
            }

            if (caravan.pawns.Count == 0)
            {
                Find.WorldObjects.Remove(caravan);
            }

            Find.LetterStack.ReceiveLetter("Quest_MissingPeople_EndQuest".Translate(), builder.ToString(), LetterDefOf.NeutralEvent);
            QuestSite site = (QuestSite)mapParent;

            site.EndQuest(caravan, condition);
        }
Exemplo n.º 17
0
        public override void TakeQuestByQuester(QuestPawn quester, bool notify = true)
        {
            TileFinder.TryFindPassableTileWithTraversalDistance(Find.AnyPlayerHomeMap.Tile, 6, 24, out int result);

            QuestSite questPlace = (QuestSite)WorldObjectMaker.MakeWorldObject(QuestRim.WorldObjectDefOfLocal.QuestPlace);

            questPlace.Tile = result;
            questPlace.SetFaction(Faction);
            questPlace.Init(this);
            questPlace.RemoveAfterLeave = false;

            Target = questPlace;
            Site   = questPlace;

            Find.WorldObjects.Add(questPlace);

            base.TakeQuestByQuester(quester, notify);
        }
        public override bool CanLeaveFromSite(QuestSite site)
        {
            if (!Defended)
            {
                Messages.Message(Translator.Translate("Quest_Archotech_567H_GetResources_NeedDefend"), MessageTypeDefOf.NeutralEvent, false);
                return(false);
            }

            if (HostileUtility.AnyNonDownedHostileOnMap(site.Map, Faction))
            {
                Messages.Message(Translator.Translate("EnemyOnTheMap"), MessageTypeDefOf.NeutralEvent, false);
                return(false);
            }

            Won = true;

            return(true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!TileFinder.TryFindPassableTileWithTraversalDistance(Find.AnyPlayerHomeMap.Tile, 7, 15, out int newTile, (int i) => !Find.WorldObjects.AnyWorldObjectAt(i)))
            {
                return(false);
            }

            if (GssRaids.GssFaction == null)
            {
                return(false);
            }

            DarkNet darkNet = Current.Game.GetComponent <DarkNet>();

            if (darkNet == null || darkNet.Traders == null)
            {
                return(false);
            }

            DarkNetTrader trader = darkNet.Traders.RandomElement();

            Quest_DarkNetKillInformator quest = new Quest_DarkNetKillInformator(trader.def);

            quest.GenerateRewards(quest.GetQuestThingFilter(), new FloatRange(1200, 2500), new IntRange(1, 4), null, null);

            quest.id          = QuestsManager.Communications.UniqueIdManager.GetNextQuestID();
            quest.TicksToPass = 10 * 60000;
            quest.Faction     = GssRaids.GssFaction;

            string title = string.Format(def.letterLabel, trader.def.LabelCap, quest.Faction.Name);
            string desc  = string.Format(def.letterText, trader.def.LabelCap, quest.Faction.Name);

            QuestSite site = QuestsHandler.CreateSiteFor(quest, newTile, quest.Faction);

            Find.WorldObjects.Add(site);

            QuestsManager.Communications.AddQuest(quest);

            Find.LetterStack.ReceiveLetter(title, desc, def.letterDef, new LookTargets(site));

            return(true);
        }
        public override void DoAction(EmailMessage message, EmailBox box, Pawn speaker)
        {
            if (!TileFinder.TryFindPassableTileWithTraversalDistance(Find.AnyPlayerHomeMap.Tile, 8, 20, out int result))
            {
                Log.Warning("Cannon find place, try again");
                return;
            }

            Faction traderFaction = Find.FactionManager.FirstFactionOfDef(FactionDefOfLocal.DarkNetTraders);

            Quest_Laboratory quest = new Quest_Laboratory();

            quest.TicksToPass = 10 * 60000;
            quest.Faction     = traderFaction;
            quest.id          = QuestsManager.Communications.UniqueIdManager.GetNextQuestID();
            quest.GenerateRewards(quest.GetQuestThingFilter(), new FloatRange(2000, 3500), new IntRange(5, 10), null, null);
            Thing silver = ThingMaker.MakeThing(ThingDefOf.Silver);

            silver.stackCount = Rand.Range(1000, 2000);
            quest.Rewards.Add(silver);

            QuestSite questPlace = (QuestSite)WorldObjectMaker.MakeWorldObject(QuestRim.WorldObjectDefOfLocal.QuestPlace);

            questPlace.Tile = result;
            questPlace.SetFaction(traderFaction);
            questPlace.Init(quest);
            questPlace.RemoveAfterLeave = false;

            quest.Target = questPlace;
            quest.Site   = questPlace;

            Find.WorldObjects.Add(questPlace);

            QuestsManager.Communications.AddQuest(quest, QuestsManager.Communications.MakeQuestLetter(quest, description: quest.Description, lookTarget: questPlace));

            var component = QuestsManager.Communications.Components.Where(x => x is EmailMessageTimeComp_QuestLaboratory).FirstOrDefault();

            if (component != null)
            {
                QuestsManager.Communications.RemoveComponent(component);
            }
        }
Exemplo n.º 21
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!TryResolveTwoFactions(out Faction alliedFaction, out Faction enemyFaction))
            {
                return(false);
            }

            if (enemyFaction.leader == null)
            {
                return(false);
            }

            if (!TileFinder.TryFindPassableTileWithTraversalDistance(Find.AnyPlayerHomeMap.Tile, 7, 16, out int result))
            {
                return(false);
            }

            Quest_KillLeader quest = new Quest_KillLeader(enemyFaction.leader, Rand.Range(11, 17));

            quest.Faction = alliedFaction;
            quest.id      = QuestsManager.Communications.UniqueIdManager.GetNextQuestID();
            quest.GenerateRewards(quest.GetQuestThingFilter(), new FloatRange(600, 800) * (float)enemyFaction.def.techLevel, new IntRange(1, 3), null, null);

            QuestSite questPlace = (QuestSite)WorldObjectMaker.MakeWorldObject(QuestRim.WorldObjectDefOfLocal.QuestPlace);

            questPlace.Tile = result;
            questPlace.SetFaction(alliedFaction);
            questPlace.Init(quest);
            questPlace.RemoveAfterLeave = false;

            quest.Target = questPlace;
            quest.Site   = questPlace;

            Find.WorldObjects.Add(questPlace);

            string description = string.Format(def.letterText, alliedFaction.Name, enemyFaction.leader.Name.ToString(), enemyFaction.Name);

            QuestsManager.Communications.AddQuest(quest, QuestsManager.Communications.MakeQuestLetter(quest, description: description, lookTarget: questPlace));

            return(true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            DarkNet darkNet = Current.Game.GetComponent <DarkNet>();

            if (darkNet == null || darkNet.Traders == null)
            {
                return(false);
            }

            DarkNetTrader trader   = darkNet.Traders.RandomElement();
            Faction       attacker = Find.FactionManager.FirstFactionOfDef(MoreEvents.FactionDefOfLocal.Pirate);

            if (attacker == null || attacker.defeated)
            {
                return(false);
            }

            if (!TileFinder.TryFindPassableTileWithTraversalDistance(Find.AnyPlayerHomeMap.Tile, 5, 12, out int newTile, (int i) => !Find.WorldObjects.AnyWorldObjectAt(i)))
            {
                return(false);
            }

            Quest_DarkNetCaptureMaterials quest = new Quest_DarkNetCaptureMaterials(trader.def);

            quest.id          = QuestsManager.Communications.UniqueIdManager.GetNextQuestID();
            quest.TicksToPass = 7 * 60000;
            quest.Faction     = attacker;

            string title = string.Format(def.letterLabel, trader.def.LabelCap);
            string desc  = string.Format(def.letterText, trader.def.LabelCap);

            QuestSite site = QuestsHandler.CreateSiteFor(quest, newTile, quest.Faction);

            Find.WorldObjects.Add(site);

            QuestsManager.Communications.AddQuest(quest);

            Find.LetterStack.ReceiveLetter(title, desc, def.letterDef, new LookTargets(site));

            return(true);
        }
Exemplo n.º 23
0
        public override void TakeQuestByQuester(QuestPawn quester, bool notify = true)
        {
            IncidentWorker_Quest_MissingPeople.TryGetNewTile(quester.Pawn.Tile, out int newTile);

            LookTargets target = new LookTargets(newTile);

            Target = target;

            QuestSite questPlace = (QuestSite)WorldObjectMaker.MakeWorldObject(QuestRim.WorldObjectDefOfLocal.QuestPlace);

            questPlace.Tile = newTile;
            questPlace.SetFaction(Faction);
            questPlace.Init(this);
            questPlace.RemoveAfterLeave = false;

            Site = questPlace;

            Find.WorldObjects.Add(questPlace);

            base.TakeQuestByQuester(quester, notify);
        }
Exemplo n.º 24
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Faction faction = GetFaction();

            if (!Find.WorldObjects.Settlements.Where(x => x.Faction == faction &&
                                                     CaravanArrivalTimeEstimator.EstimatedTicksToArrive(Find.AnyPlayerHomeMap.Tile, x.Tile, null).TicksToDays() < 6).TryRandomElement(out Settlement factionBase))
            {
                return(false);
            }

            List <int> neighbors = new List <int>();

            Find.WorldGrid.GetTileNeighbors(factionBase.Tile, neighbors);

            if (neighbors.Count == 0)
            {
                return(false);
            }

            int rebelPos = neighbors.RandomElement();

            Quest_SuppressionRebellion quest = new Quest_SuppressionRebellion();

            quest.id          = QuestsManager.Communications.UniqueIdManager.GetNextQuestID();
            quest.Faction     = factionBase.Faction;
            quest.TicksToPass = Rand.Range(10, 20) * 60000;
            quest.GenerateRewards(quest.GetQuestThingFilter(), quest.Faction.GetRangeByFactionTechLevel(400, 700), new IntRange(3, 8), null, null);
            QuestSite questSite = quest.CreateSiteFor(rebelPos, quest.Faction);

            quest.RebelSettlement      = factionBase;
            questSite.RemoveAfterLeave = false;

            Find.WorldObjects.Add(questSite);

            string desc = string.Format(def.letterText, factionBase.Faction.leader.Name.ToStringFull, factionBase.Name, factionBase.Faction.Name);

            QuestsManager.Communications.AddQuest(quest, QuestsManager.Communications.MakeQuestLetter(quest, description: desc, lookTarget: questSite));

            return(true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!TryResolveTwoFaction(out Faction faction1, out Faction faction2))
            {
                return(false);
            }

            if (!TileFinder.TryFindPassableTileWithTraversalDistance(Find.AnyPlayerHomeMap.Tile, 7, 15, out int result))
            {
                return(false);
            }

            Pawn pawn = PawnGenerator.GeneratePawn(PawnKindDefOf.AncientSoldier, faction2);

            Find.WorldPawns.PassToWorld(pawn);

            Quest_KillOrder quest = new Quest_KillOrder(pawn, Rand.Range(10, 17));

            quest.Faction = faction1;
            quest.id      = QuestsManager.Communications.UniqueIdManager.GetNextQuestID();
            quest.GenerateRewards();

            QuestSite questPlace = (QuestSite)WorldObjectMaker.MakeWorldObject(QuestRim.WorldObjectDefOfLocal.QuestPlace);

            questPlace.Tile = result;
            questPlace.SetFaction(faction1);
            questPlace.Init(quest);
            questPlace.RemoveAfterLeave = false;

            quest.Target = questPlace;
            quest.Site   = questPlace;

            Find.WorldObjects.Add(questPlace);

            string description = string.Format(def.letterText, faction1.Name, pawn.Name.ToString(), faction2.Name);

            QuestsManager.Communications.AddQuest(quest, QuestsManager.Communications.MakeQuestLetter(quest, description: description, lookTarget: questPlace));

            return(true);
        }
Exemplo n.º 26
0
        public override void TakeQuestByQuester(QuestPawn quester, bool notify = true)
        {
            TileFinder.TryFindPassableTileWithTraversalDistance(Find.AnyPlayerHomeMap.Tile, 5, 12, out int newTile, (int i) => !Find.WorldObjects.AnyWorldObjectAt(i));

            LookTargets target = new LookTargets(newTile);

            Target = target;

            QuestSite questPlace = QuestsHandler.CreateSiteFor(this, newTile, Faction);

            Site = questPlace;

            Find.WorldObjects.Add(questPlace);

            ShowInConsole = true;

            TicksToPass = DaysRange.RandomInRange * 60000;

            if (notify)
            {
                Find.LetterStack.ReceiveLetter(QuestsManager.Communications.MakeQuestLetter(this, "TakeQuestFromPawnLetter".Translate(CardLabel), "TakeQuestFromPawnLetterDesc".Translate(CardLabel, Description)));
            }
        }
Exemplo n.º 27
0
        static bool Prefix(ExitMapGrid __instance, ref bool __result)
        {
            Map map = (Map)(typeof(ExitMapGrid).GetField("map", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
                                                         | BindingFlags.Static).GetValue(__instance));

            if (map != null)
            {
                QuestSite site = Find.WorldObjects.WorldObjectAt <QuestSite>(map.Tile);
                if (site != null)
                {
                    __result = site.HasExitCells;
                    return(false);
                }

                var comp = map.Parent.GetComponent <HasExitCellsComp>();
                if (comp != null)
                {
                    __result = false;
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 28
0
        public override void PostSiteRemove(QuestSite site)
        {
            base.PostSiteRemove(site);

            EndQuest();
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!settings.Active)
            {
                return(false);
            }

            Faction faction = GetFaction();

            foreach (var q in QuestsManager.Communications.Quests)
            {
                if (q.Faction == faction && q is Quest_BuildNewBase)
                {
                    return(false);
                }
            }

            List <Settlement> factionBases = Find.WorldObjects.Settlements.Where(x => x.Faction == faction).ToList();

            if (factionBases.Count == 0)
            {
                return(false);
            }

            Settlement factionBase = factionBases.RandomElement();

            if (!TryGetNewTile(factionBase.Tile, out int newTile))
            {
                return(false);
            }

            Quest_BuildNewBase quest = new Quest_BuildNewBase();

            quest.id      = QuestsManager.Communications.UniqueIdManager.GetNextQuestID();
            quest.Faction = faction;

            int playerPawns = 0;

            foreach (var map in Find.Maps)
            {
                if (map.IsPlayerHome)
                {
                    playerPawns += map.mapPawns.ColonistCount;
                }
            }
            playerPawns         = Mathf.Max(2, playerPawns);
            quest.PawnsRequired = Rand.Range(1, playerPawns);

            float value = (250 * quest.PawnsRequired) * 1.8f;

            quest.GenerateRewards(quest.GetQuestThingFilter(), new FloatRange(value, value), new IntRange(2, 5), null, null);

            QuestOption_IncreaseReward questOption_IncreaseReward = new QuestOption_IncreaseReward(15, SkillDefOf.Social, new FloatRange(value, value) * 1.3f, new IntRange(2, 7));

            quest.Options = new List <QuestOption>
            {
                questOption_IncreaseReward
            };

            LookTargets target = new LookTargets(newTile);

            quest.Target      = target;
            quest.TicksToPass = Rand.Range(12, 17) * 60000;
            quest.TicksToEnd  = Rand.Range(3, 5) * 60000;

            QuestSite questPlace = (QuestSite)WorldObjectMaker.MakeWorldObject(QuestRim.WorldObjectDefOfLocal.QuestPlace);

            quest.Site          = questPlace;
            quest.OldSettlement = factionBase;

            questPlace.Tile = newTile;
            questPlace.SetFaction(faction);
            questPlace.Init(quest);

            Find.WorldObjects.Add(questPlace);

            string text = string.Format(def.letterText, faction.Name).CapitalizeFirst();

            QuestsManager.Communications.AddQuest(quest, QuestsManager.Communications.MakeQuestLetter(quest, description: text, lookTarget: target));

            return(true);
        }
 public CaravanArrivalAction_EnterToQuestMap(MapParent mapParent)
 {
     this.mapParent = mapParent;
     this.questSite = (QuestSite)mapParent;
 }