Ejemplo n.º 1
0
        public static bool Check(params object[] args)
        {
            using (new Profiler(nameof(QuestCollectItem)))
            {
                using (new Profiler(nameof(QuestCanAccept)))
                {
                    int      index   = (int)args[0];
                    NWPlayer player  = _.GetPCSpeaker();
                    NWObject talkTo  = Object.OBJECT_SELF;
                    int      questID = talkTo.GetLocalInt("QUEST_ID_" + index);
                    if (questID <= 0)
                    {
                        questID = talkTo.GetLocalInt("QST_ID_" + index);
                    }

                    if (DataService.GetAll <Data.Entity.Quest>().All(x => x.ID != questID))
                    {
                        _.SpeakString("ERROR: Quest #" + index + " is improperly configured. Please notify an admin");
                        return(false);
                    }

                    QuestService.RequestItemsFromPC(player, talkTo, questID);

                    return(true);
                }
            }
        }
Ejemplo n.º 2
0
        public bool CreatureHasQuestToAchieve(Player plr)
        {
            if (Entry == 0)
            {
                return(false);
            }

            List <Quest> finisher = QuestService.GetFinishersQuests(Entry);

            if (finisher == null)
            {
                return(false);
            }

            foreach (Quest q in finisher)
            {
                Character_quest cq = plr.QtsInterface.GetQuest(q.Entry);
                if (cq != null && !cq.IsDone())
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        public void Main()
        {
            NWPlaceable overridePlaceable = _.OBJECT_SELF;
            NWObject door = _.GetNearestObjectByTag("aban_director_exit", overridePlaceable);
            NWPlayer player = _.GetLastUsedBy();
            door.AssignCommand(() =>_.SetLocked(door, false));
            int questID = overridePlaceable.GetLocalInt("QUEST_ID_1");

            _.SpeakString("The tractor beam has been disabled. A door in this room has unlocked.");

            NWArea mainLevel = overridePlaceable.Area.GetLocalObject("MAIN_LEVEL");
            NWArea restrictedLevel = overridePlaceable.Area.GetLocalObject("RESTRICTED_LEVEL");
            NWArea directorsChambers = overridePlaceable.Area.GetLocalObject("DIRECTORS_CHAMBERS");

            // Enable the shuttle back to Viscara object.
            NWPlaceable teleportObject = _.GetNearestObjectByTag("aban_shuttle_exit", mainLevel);
            teleportObject.IsUseable = true;

            var quest = QuestService.GetQuestByID(questID);
            // Advance each party member's quest progression if they are in one of these three instance areas.
            foreach (var member in player.PartyMembers)
            {
                // Not in one of the three areas? Move to the next member.
                NWArea area = member.Area;
                if (area != mainLevel &&
                    area != restrictedLevel &&
                    area != directorsChambers)
                    continue;

                quest.Advance(member.Object, overridePlaceable);
            }

            // Disable this placeable from being used again for this instance.
            overridePlaceable.IsUseable = false;
        }
Ejemplo n.º 4
0
        public bool CreatureHasStartRepeatingQuest(Player plr)
        {
            if (Entry == 0)
            {
                return(false);
            }

            List <Quest> starter = QuestService.GetStartQuests(Entry);

            if (starter == null)
            {
                return(false);
            }

            foreach (Quest quest in starter)
            {
                if (quest.Repeatable && plr.QtsInterface.CanStartQuest(quest))
                {
                    return(true);
                }
            }


            return(false);
        }
Ejemplo n.º 5
0
 public void Awake()
 {
     questService = Service.Get <QuestService>();
     dispatcher   = Service.Get <EventDispatcher>();
     dispatcher.AddListener <QuestEvents.QuestUpdated>(onQuestUpdated);
     dispatcher.AddListener <HudEvents.HudInitComplete>(onHudInitCompleted);
 }
Ejemplo n.º 6
0
        public static bool Check(params object[] args)
        {
            using (new Profiler(nameof(QuestCanAccept)))
            {
                int      index   = (int)args[0];
                NWPlayer player  = _.GetPCSpeaker();
                NWObject talkTo  = _.OBJECT_SELF;
                int      questID = talkTo.GetLocalInt("QUEST_ID_" + index);
                if (questID <= 0)
                {
                    questID = talkTo.GetLocalInt("QST_ID_" + index);
                }

                if (!QuestService.QuestExistsByID(questID))
                {
                    _.SpeakString("ERROR: Quest #" + index + " is improperly configured. Please notify an admin");
                    return(false);
                }

                var quest = QuestService.GetQuestByID(questID);
                quest.Advance(player, talkTo);
            }

            return(true);
        }
Ejemplo n.º 7
0
 private void Awake()
 {
     dispatcher = Service.Get <EventDispatcher>();
     dispatcher.AddListener <JigsawEvents.CloseButton>(onCloseButton);
     dispatcher.AddListener <JigsawEvents.BackgroundSolveComplete>(onBackgroundSolveComplete);
     questService = Service.Get <QuestService>();
 }
Ejemplo n.º 8
0
        public bool Run(params object[] args)
        {
            NWPlaceable container = Object.OBJECT_SELF;

            container.IsUseable = false;

            NWPlayer      oPC     = (_.GetLastOpenedBy());
            int           questID = container.GetLocalInt("QUEST_ID");
            PCQuestStatus status  = DataService.Single <PCQuestStatus>(x => x.PlayerID == oPC.GlobalID && x.QuestID == questID);

            oPC.FloatingText("Please place the items you would like to turn in for this quest into the container. If you want to cancel this process, move away from the container.");

            string text = "Required Items: \n\n";

            var itemProgress = DataService.Where <PCQuestItemProgress>(x => x.PCQuestStatusID == status.ID);

            foreach (PCQuestItemProgress item in itemProgress)
            {
                ItemVO tempItemModel = QuestService.GetTempItemInformation(item.Resref, item.Remaining);
                text += tempItemModel.Quantity + "x " + tempItemModel.Name + "\n";
            }

            oPC.SendMessage(text);
            return(true);
        }
Ejemplo n.º 9
0
        private void HandleGiveReport(NWPlayer player, int questID)
        {
            var pcStatus = DataService.PCQuestStatus.GetByPlayerAndQuestIDOrDefault(player.GlobalID, questID);

            if (pcStatus == null)
            {
                return;
            }
            var quest            = QuestService.GetQuestByID(questID);
            var state            = quest.GetState(pcStatus.QuestState);
            var hasItemObjective = state.GetObjectives().FirstOrDefault(x => x.GetType() == typeof(CollectItemObjective)) != null;

            // Quest has at least one "collect item" objective.
            if (hasItemObjective)
            {
                QuestService.RequestItemsFromPC(player, GetDialogTarget(), questID);
            }
            // All other quest types
            else if (quest.CanComplete(player))
            {
                quest.Complete(player, _.OBJECT_SELF, null);
                EndConversation();
            }
            // Missing a requirement.
            else
            {
                player.SendMessage(ColorTokenService.Red("One or more task is incomplete. Refer to your journal for more information."));
            }
        }
Ejemplo n.º 10
0
        public void Load(List <Character_quest> quests)
        {
            if (quests == null)
            {
                return;
            }

            foreach (Character_quest quest in quests)
            {
                quest.Quest = QuestService.GetQuest(quest.QuestID);
                if (quest.Quest == null)
                {
                    continue;
                }

                foreach (Character_Objectives obj in quest._Objectives)
                {
                    obj.Objective = QuestService.GetQuestObjective(obj.ObjectiveID);
                }

                // If a quest objective has been deleted in the world db lets remove it from the player
                quest._Objectives = quest._Objectives.FindAll(o => o.Objective != null);

                if (!this.Quests.ContainsKey(quest.QuestID))
                {
                    this.Quests.Add(quest.QuestID, quest);
                }
            }
        }
Ejemplo n.º 11
0
 private void Awake()
 {
     eventDispatcher       = Service.Get <EventDispatcher>();
     zoneTransitionService = Service.Get <ZoneTransitionService>();
     gameStateController   = Service.Get <GameStateController>();
     questService          = Service.Get <QuestService>();
 }
Ejemplo n.º 12
0
        private void Start()
        {
            unlockedItemsList  = new List <T>(UnlockedArrayIncrement);
            progressionService = Service.Get <ProgressionService>();
            questService       = Service.Get <QuestService>();
            itemGroups         = new List <ItemGroup>();
            localizer          = Service.Get <Localizer>();
            layoutElementPool  = GetComponent <HorizontalScrollingLayoutElementPool>();
            HorizontalScrollingLayoutElementPool horizontalScrollingLayoutElementPool = layoutElementPool;

            horizontalScrollingLayoutElementPool.OnPoolReady = (System.Action)Delegate.Combine(horizontalScrollingLayoutElementPool.OnPoolReady, new System.Action(onPoolReady));
            HorizontalScrollingLayoutElementPool horizontalScrollingLayoutElementPool2 = layoutElementPool;

            horizontalScrollingLayoutElementPool2.OnElementShown = (Action <int, GameObject>)Delegate.Combine(horizontalScrollingLayoutElementPool2.OnElementShown, new Action <int, GameObject>(onElementShown));
            HorizontalScrollingLayoutElementPool horizontalScrollingLayoutElementPool3 = layoutElementPool;

            horizontalScrollingLayoutElementPool3.OnElementHidden = (Action <int, GameObject>)Delegate.Combine(horizontalScrollingLayoutElementPool3.OnElementHidden, new Action <int, GameObject>(onElementHidden));
            HorizontalScrollingLayoutElementPool horizontalScrollingLayoutElementPool4 = layoutElementPool;

            horizontalScrollingLayoutElementPool4.OnElementRefreshed = (Action <int, GameObject>)Delegate.Combine(horizontalScrollingLayoutElementPool4.OnElementRefreshed, new Action <int, GameObject>(onElementRefreshed));
            zeroSpacing          = Vector2.zero;
            groupSpacing         = new Vector2(GroupSpacing, 0f);
            combinedGroupSpacing = new Vector2(CombinedGroupSpacing, 0f);
            spacingRulesMap      = getSpacingRulesMap();
            parseItemGroups();
            Content.LoadAsync(onItemLoaded, ItemContentKey);
            Content.LoadAsync(onLockedItemsLoaded, LockedItemsContentKey);
            Content.LoadAsync(onGameObjectPoolLoaded, gameObjectPoolContentKey);
            start();
        }
Ejemplo n.º 13
0
        private void HandleGiveReport(NWPlayer player, int questID)
        {
            var pcStatus = DataService.PCQuestStatus.GetByPlayerAndQuestIDOrDefault(player.GlobalID, questID);

            if (pcStatus == null)
            {
                return;
            }
            var state = DataService.QuestState.GetByID(pcStatus.CurrentQuestStateID);

            // Quest is calling for collecting items. Run that method.
            if (state.QuestTypeID == (int)QuestType.CollectItems)
            {
                QuestService.RequestItemsFromPC(player, GetDialogTarget(), questID);
            }
            // All other quest types
            else if (QuestService.CanPlayerCompleteQuest(player, questID))
            {
                QuestService.CompleteQuest(player, GetDialogTarget(), questID, null);
                EndConversation();
            }
            // Missing a requirement.
            else
            {
                player.SendMessage(ColorTokenService.Red("One or more task is incomplete. Refer to your journal for more information."));
            }
        }
Ejemplo n.º 14
0
        public static bool Check(params object[] args)
        {
            using (new Profiler(nameof(QuestIsDone)))
            {
                int      index     = (int)args[0];
                NWPlayer player    = _.GetPCSpeaker();
                NWObject talkingTo = _.OBJECT_SELF;
                int      questID   = talkingTo.GetLocalInt("QUEST_ID_" + index);
                if (questID <= 0)
                {
                    questID = talkingTo.GetLocalInt("QST_ID_" + index);
                }

                if (!QuestService.QuestExistsByID(questID))
                {
                    _.SpeakString("ERROR: Quest #" + index + " is improperly configured. Please notify an admin");
                    return(false);
                }

                var status = DataService.PCQuestStatus.GetByPlayerAndQuestIDOrDefault(player.GlobalID, questID);
                if (status == null)
                {
                    return(false);
                }

                var quest             = QuestService.GetQuestByID(questID);
                var currentQuestState = quest.GetState(status.QuestState);
                var lastState         = quest.GetStates().Last();
                return(currentQuestState == lastState &&
                       status.CompletionDate != null);
            }
        }
Ejemplo n.º 15
0
 protected override void OnEnable()
 {
     if (Owner.CompareTag("Player"))
     {
         QuestService questService = Service.Get <QuestService>();
         questService.SendEvent(QuestEvent);
     }
 }
Ejemplo n.º 16
0
        public static bool Check(int index, int customRuleIndex)
        {
            using (new Profiler(nameof(QuestComplete) + ".Index" + index + ".Rule" + customRuleIndex))
            {
                NWPlayer player  = _.GetPCSpeaker();
                NWObject talkTo  = NWGameObject.OBJECT_SELF;
                int      questID = talkTo.GetLocalInt("QUEST_ID_" + index);
                if (questID <= 0)
                {
                    questID = talkTo.GetLocalInt("QST_ID_" + index);
                }

                if (!DataService.Quest.ExistsByID(questID))
                {
                    _.SpeakString("ERROR: Quest #" + index + " is improperly configured. Please notify an admin");
                    return(false);
                }

                string rule     = string.Empty;
                string ruleArgs = string.Empty;
                if (customRuleIndex > 0)
                {
                    string ruleName = "QUEST_ID_" + index + "_RULE_" + customRuleIndex;
                    rule     = talkTo.GetLocalString(ruleName);
                    ruleArgs = talkTo.GetLocalString("QUEST_ID_" + index + "_RULE_ARGS_" + customRuleIndex);

                    if (string.IsNullOrWhiteSpace(rule))
                    {
                        _.SpeakString("ERROR: Quest #" + index + ", rule #" + customRuleIndex + " is improperly configured. Please notify an admin.");
                        return(false);
                    }
                }

                QuestService.CompleteQuest(player, talkTo, questID, null);

                if (!string.IsNullOrWhiteSpace(rule))
                {
                    Data.Entity.Quest quest = DataService.Quest.GetByID(questID);
                    var ruleAction          = QuestService.GetQuestRule(rule);

                    string[] argsArray = null;

                    if (string.IsNullOrWhiteSpace(ruleArgs))
                    {
                        ruleArgs = quest.OnCompleteArgs;
                    }

                    if (!string.IsNullOrWhiteSpace(ruleArgs))
                    {
                        argsArray = ruleArgs.Split(',');
                    }

                    ruleAction.Run(player, talkTo, questID, argsArray);
                }

                return(true);
            }
        }
Ejemplo n.º 17
0
        private void HandleRewardSelection(int responseID)
        {
            Model model  = GetDialogCustomData <Model>();
            var   reward = GetResponseByID("MainPage", responseID).CustomData as IQuestReward;
            var   quest  = QuestService.GetQuestByID(model.QuestID);

            quest.Complete(GetPC(), GetPC(), reward);
            EndConversation();
        }
Ejemplo n.º 18
0
        private void HandleRewardSelection(int responseID)
        {
            Model  model    = GetDialogCustomData <Model>();
            ItemVO tempItem = (ItemVO)GetResponseByID("MainPage", responseID).CustomData;

            QuestService.CompleteQuest(GetPC(), null, model.QuestID, tempItem);

            EndConversation();
        }
        public void CanReadQuestCsv()
        {
            var questService = new QuestService(null);

            using var stream = new MemoryStream(Encoding.UTF8.GetBytes(QuestCsvString));

            var quests = questService.ReadCsv(stream);

            Assert.NotEmpty(quests);
        }
Ejemplo n.º 20
0
        public bool HasQuestFinisher(ushort questID)
        {
            List <Quest> quests = QuestService.GetFinishersQuests(Entry);

            if (quests != null)
            {
                return(QuestService.GetFinishersQuests(Entry).Find(info => info.Entry == questID) != null);
            }

            return(false);
        }
Ejemplo n.º 21
0
        public bool CreatureHasStartQuest(Player plr)
        {
            if (Entry == 0)
            {
                return(false);
            }

            List <Quest> starter = QuestService.GetStartQuests(Entry);

            return(starter?.Find(q => plr.QtsInterface.CanStartQuest(q)) != null);
        }
Ejemplo n.º 22
0
 public HttpResponseMessage NewQuest(QuestDTO quest)
 {
     try
     {
         QuestService.AddNewQuest(quest);
         return(Request.CreateResponse(HttpStatusCode.OK, true));
     }
     catch (Exception e)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, "There was an InternalServerError: " + e));
     }
 }
Ejemplo n.º 23
0
 private void Start()
 {
     questService = Service.Get <QuestService>();
     for (int i = 0; i < nodes.Length; i++)
     {
         nodes[i].ColliderRadius = NodeRadius;
         nodes[i].NodeIndex      = i;
         if (i > 0)
         {
             nodes[i - 1].NextNode = nodes[i];
         }
     }
 }
Ejemplo n.º 24
0
    private void SendEvent(string evt)
    {
        QuestService questService = Service.Get <QuestService>();
        Quest        activeQuest  = questService.ActiveQuest;

        if (activeQuest != null && activeQuest.Definition.name == QuestName)
        {
            questService.SendEvent(evt);
            if (eventHook != null)
            {
                eventHook(evt);
            }
        }
    }
        public void CanCorrectlyReadFirstQuest()
        {
            var questService = new QuestService(null);

            using var stream = new MemoryStream(Encoding.UTF8.GetBytes(QuestCsvString));

            var firstQuest = questService.ReadCsv(stream).FirstOrDefault();

            Assert.NotNull(firstQuest);
            Assert.Equal("Cook's Assistant", firstQuest.Title);
            Assert.Equal(new DateTime(2001, 01, 04), firstQuest.ReleaseDate);
            Assert.Equal((uint?)1, firstQuest.Order);
            Assert.True(Uri.TryCreate(firstQuest.WikiLink, UriKind.Absolute, out _));
            Assert.False(firstQuest.MiniQuest);
        }
Ejemplo n.º 26
0
        public void Main()
        {
            const int   QuestID = 30;
            NWPlaceable crystal = _.OBJECT_SELF;
            NWPlayer    player  = _.GetLastUsedBy();

            // Check player's current quest state. If they aren't on stage 2 of the quest only show a message.
            var status = DataService.PCQuestStatus.GetByPlayerAndQuestID(player.GlobalID, QuestID);

            if (status.QuestState != 2)
            {
                player.SendMessage("The crystal glows quietly...");
                return;
            }

            // Player is on stage 2, so they're able to click the crystal, get a cluster, complete the quest, and teleport back to the cavern.
            int    type = crystal.GetLocalInt("CRYSTAL_COLOR_TYPE");
            string cluster;

            switch (type)
            {
            case 1: cluster = "c_cluster_blue"; break;    // Blue

            case 2: cluster = "c_cluster_red"; break;     // Red

            case 3: cluster = "c_cluster_green"; break;   // Green

            case 4: cluster = "c_cluster_yellow"; break;  // Yellow

            default: throw new Exception("Invalid crystal color type.");
            }

            _.CreateItemOnObject(cluster, player);

            var quest = QuestService.GetQuestByID(QuestID);

            quest.Advance(player, crystal);

            // Hide the "Source of Power?" placeable so the player can't use it again.
            ObjectVisibilityService.AdjustVisibility(player, "81533EBB-2084-4C97-B004-8E1D8C395F56", false);

            NWObject tpWP = _.GetObjectByTag("FORCE_QUEST_LANDING");

            player.AssignCommand(() => _.ActionJumpToLocation(tpWP.Location));

            // Notify the player that new lightsaber perks have unlocked.
            player.FloatingText("You have unlocked the Lightsaber Blueprints perk. Find this under the Engineering category in your perks menu.");
        }
Ejemplo n.º 27
0
        public bool CreatureHasQuestToComplete(Player plr)
        {
            if (Entry == 0)
            {
                return(false);
            }

            List <Quest> finisher = QuestService.GetFinishersQuests(Entry);

            if (finisher == null)
            {
                return(false);
            }

            return(finisher.Find(q => plr.QtsInterface.CanEndQuest(q)) != null);
        }
Ejemplo n.º 28
0
        public override void Initialize()
        {
            int questID = GetPC().GetLocalInt("QST_REWARD_SELECTION_QUEST_ID");

            GetPC().DeleteLocalInt("QST_REWARD_SELECTION_QUEST_ID");
            var quest       = QuestService.GetQuestByID(questID);
            var rewardItems = quest.GetRewards().Where(x => x.IsSelectable);

            Model model = GetDialogCustomData <Model>();

            model.QuestID = questID;

            foreach (var reward in rewardItems)
            {
                AddResponseToPage("MainPage", reward.MenuName, true, reward);
            }
        }
Ejemplo n.º 29
0
        public QuestItemReward(string resref, int quantity, bool isSelectable)
        {
            _resref      = resref;
            _quantity    = quantity;
            IsSelectable = isSelectable;

            var itemVO = QuestService.GetTempItemInformation(resref, quantity);

            if (_quantity > 1)
            {
                MenuName = _quantity + "x " + itemVO.Name;
            }
            else
            {
                MenuName = itemVO.Name;
            }
        }
        public void OnStateChanged(string state)
        {
            if (!(state == HandledState) || !(rootStateMachine != null))
            {
                return;
            }
            CPDataEntityCollection cPDataEntityCollection = Service.Get <CPDataEntityCollection>();

            if (cPDataEntityCollection == null || cPDataEntityCollection.LocalPlayerHandle.IsNull)
            {
                throw new Exception("Unable to resolve data entity collection");
            }
            if (cPDataEntityCollection.TryGetComponent <ProfileData>(cPDataEntityCollection.LocalPlayerHandle, out var component))
            {
                MembershipService membershipService = Service.Get <MembershipService>();
                string            text;
                if (component.IsFirstTimePlayer && !membershipService.LoginViaMembership && !membershipService.LoginViaRestore)
                {
                    QuestService        questService        = Service.Get <QuestService>();
                    GameStateController gameStateController = Service.Get <GameStateController>();
                    text = ((questService.ActiveQuest == null || !(questService.ActiveQuest.Id == gameStateController.FTUEConfig.FtueQuestId)) ? FirstTimePlayerEvent : ReturnPlayerEvent);
                }
                else
                {
                    if (membershipService.LoginViaRestore)
                    {
                        SessionManager sessionManager = Service.Get <SessionManager>();
                        if (sessionManager.HasSession)
                        {
                            sessionManager.ReturnToRestorePurchases();
                        }
                        Service.Get <ICPSwrveService>().Funnel(Service.Get <MembershipService>().AccountFunnelName, "21", "check_cpremixprofile", "ReturnToSettings");
                        AccountPopupController componentInParent = GetComponentInParent <AccountPopupController>();
                        componentInParent.OnClosePopup();
                        return;
                    }
                    text = ReturnPlayerEvent;
                }
                Service.Get <ICPSwrveService>().Funnel(Service.Get <MembershipService>().AccountFunnelName, "21", "check_cpremixprofile", text);
                rootStateMachine.SendEvent(text);
                return;
            }
            throw new MissingReferenceException("No profile data found for local player");
        }