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.º 2
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);
        }
Exemplo n.º 3
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 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.º 5
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);
        }
Exemplo n.º 6
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);
        }
        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);
        }
        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);
        }