Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
            }
        }
Exemplo 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;
        }
Exemplo n.º 4
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."));
            }
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
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.");
        }
Exemplo n.º 7
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);
            }
        }
Exemplo n.º 8
0
        private void TaskDetailsPageResponses(int responseID)
        {
            var player = GetPC();
            var model  = GetDialogCustomData <Model>();
            var task   = DataService.GuildTask.GetByID(model.TaskID);
            var quest  = QuestService.GetQuestByID(task.QuestID);

            switch (responseID)
            {
            case 1:     // Accept Task
                quest.Accept(player, _.OBJECT_SELF);
                LoadTaskDetailsPage();
                LoadTaskListPage();
                break;

            case 2:     // Give Report
                HandleGiveReport(player, task.QuestID);
                break;
            }
        }
Exemplo n.º 9
0
        public void Main()
        {
            const int   QuestID = 30;
            NWPlaceable crystal = _.OBJECT_SELF;
            NWPlayer    player  = _.GetLastUsedBy();

            player.SendMessage("You pick up the strange looking cube which seemingly opens itself at your touch. A stream of swirling blue light" +
                               " shifts into what seems to be a recording of a robed humanoid assembling a weapon. With time, you think you may be able to do this yourself.");

            var quest = QuestService.GetQuestByID(QuestID);

            quest.Advance(player, crystal);
            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);

            _.PlaySound("dt_ordi_11");
            // 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.");
        }
Exemplo n.º 10
0
        public static bool Check(int index, int customRuleIndex)
        {
            using (new Profiler(nameof(QuestComplete) + ".Index" + index + ".Rule" + customRuleIndex))
            {
                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.Complete(player, talkTo, null);
                return(true);
            }
        }
Exemplo n.º 11
0
        public override void Initialize()
        {
            int questID = GetPC().GetLocalInt("QST_REWARD_SELECTION_QUEST_ID");

            GetPC().DeleteLocalInt("QST_REWARD_SELECTION_QUEST_ID");
            Quest quest       = QuestService.GetQuestByID(questID);
            var   rewardItems = DataService.QuestRewardItem.GetAllByQuestID(quest.ID).ToList();

            Model model = GetDialogCustomData <Model>();

            model.QuestID = questID;

            foreach (QuestRewardItem reward in rewardItems)
            {
                ItemVO tempItem   = QuestService.GetTempItemInformation(reward.Resref, reward.Quantity);
                string rewardName = tempItem.Name;
                if (tempItem.Quantity > 1)
                {
                    rewardName += " x" + tempItem.Quantity;
                }

                AddResponseToPage("MainPage", rewardName, true, tempItem);
            }
        }
Exemplo n.º 12
0
        private void LoadTaskDetailsPage()
        {
            var  player          = GetPC();
            var  model           = GetDialogCustomData <Model>();
            var  task            = DataService.GuildTask.GetByID(model.TaskID);
            var  quest           = QuestService.GetQuestByID(task.QuestID);
            var  status          = DataService.PCQuestStatus.GetByPlayerAndQuestIDOrDefault(player.GlobalID, task.QuestID);
            bool showQuestAccept = status == null || status.CompletionDate != null; // Never accepted, or has already been completed once.
            bool showGiveReport  = status != null && status.CompletionDate == null; // Accepted, but not completed.
            var  gpRewards       = quest.GetRewards().Where(x => x.GetType() == typeof(QuestGPReward)).Cast <QuestGPReward>();
            var  goldRewards     = quest.GetRewards().Where(x => x.GetType() == typeof(QuestGoldReward)).Cast <QuestGoldReward>();

            int gpAmount   = 0;
            int goldAmount = 0;

            foreach (var gpReward in gpRewards)
            {
                gpAmount += GuildService.CalculateGPReward(player, gpReward.Guild, gpReward.Amount);
            }

            foreach (var goldReward in goldRewards)
            {
                goldAmount += goldReward.Amount;
            }

            string header = ColorTokenService.Green("Task: ") + quest.Name + "\n\n";

            header += "Rewards:\n\n";
            header += ColorTokenService.Green("Credits: ") + goldAmount + "\n";
            header += ColorTokenService.Green("Guild Points: ") + gpAmount;

            SetPageHeader("TaskDetailsPage", header);

            SetResponseVisible("TaskDetailsPage", 1, showQuestAccept);
            SetResponseVisible("TaskDetailsPage", 2, showGiveReport);
        }
Exemplo n.º 13
0
        public bool MeetsPrerequisite(NWPlayer player)
        {
            var quest = QuestService.GetQuestByID(_questID);

            return(quest.IsComplete(player));
        }
Exemplo n.º 14
0
        public void Main()
        {
            NWPlaceable container = _.OBJECT_SELF;
            NWObject    owner     = container.GetLocalObject("QUEST_OWNER");

            NWPlayer player            = _.GetLastDisturbed();
            NWItem   item              = _.GetInventoryDisturbItem();
            var      disturbType       = _.GetInventoryDisturbType();
            string   crafterPlayerID   = item.GetLocalString("CRAFTER_PLAYER_ID");
            Guid?    crafterPlayerGUID = null;

            if (!string.IsNullOrWhiteSpace(crafterPlayerID))
            {
                crafterPlayerGUID = new Guid(crafterPlayerID);
            }

            if (disturbType == DisturbType.Added)
            {
                int                 questID  = container.GetLocalInt("QUEST_ID");
                PCQuestStatus       status   = DataService.PCQuestStatus.GetByPlayerAndQuestID(player.GlobalID, questID);
                PCQuestItemProgress progress = DataService.PCQuestItemProgress.GetByPCQuestStatusIDAndResrefOrDefault(status.ID, item.Resref);
                DatabaseActionType  action   = DatabaseActionType.Update;

                if (progress == null)
                {
                    _.CopyItem(item, player, true);
                    player.SendMessage(ColorTokenService.Red("That item is not required for this quest."));
                }
                else if (progress.MustBeCraftedByPlayer && crafterPlayerGUID != player.GlobalID)
                {
                    _.CopyItem(item, player, true);
                    player.SendMessage(ColorTokenService.Red("You may only submit items which you have personally created for this quest."));
                }
                else
                {
                    progress.Remaining--;

                    if (progress.Remaining <= 0)
                    {
                        var progressCopy = progress;
                        progress = DataService.PCQuestItemProgress.GetByID(progressCopy.ID);
                        action   = DatabaseActionType.Delete;
                    }
                    DataService.SubmitDataChange(progress, action);

                    // Recalc the remaining items needed.
                    int remainingCount = DataService.PCQuestItemProgress.GetCountByPCQuestStatusID(status.ID);
                    if (remainingCount <= 0)
                    {
                        var quest = QuestService.GetQuestByID(questID);
                        quest.Advance(player, owner);
                    }

                    player.SendMessage("You need " + progress.Remaining + "x " + item.Name + " for this quest.");
                }
                item.Destroy();

                var questItemProgresses = DataService.PCQuestItemProgress.GetAllByPCQuestStatusID(status.ID);
                if (!questItemProgresses.Any())
                {
                    string conversation = _.GetLocalString(owner, "CONVERSATION");

                    // Either start a SWLOR conversation
                    if (!string.IsNullOrWhiteSpace(conversation))
                    {
                        DialogService.StartConversation(player, owner, conversation);
                    }
                    // Or a regular NWN conversation.
                    else
                    {
                        player.AssignCommand(() => { _.ActionStartConversation(owner, "", true, false); });
                    }
                }
            }
        }
Exemplo n.º 15
0
        private void LoadTaskListPage()
        {
            var    player = GetPC();
            var    model  = GetDialogCustomData <Model>();
            string header = "These are our currently available tasks. Please check back periodically because our needs are always changing.";

            SetPageHeader("TaskListPage", header);

            ClearPageResponses("TaskListPage");

            var lastUpdate = DataService.ServerConfiguration.Get().LastGuildTaskUpdate;
            var pcGP       = DataService.PCGuildPoint.GetByPlayerIDAndGuildID(player.GlobalID, (int)model.Guild);

            // It's possible for players to have tasks which are no longer offered.
            // In this case, we still display them on the menu. Once they complete them, they'll disappear from the list.
            var questIDs = DataService.PCQuestStatus
                           .GetAllByPlayerID(player.GlobalID)
                           .Where(x => x.CompletionDate == null)
                           .Select(s => s.QuestID);
            var expiredTasks = DataService.GuildTask
                               .GetAll()
                               .Where(x => !x.IsCurrentlyOffered &&
                                      questIDs.Contains(x.QuestID) &&
                                      x.GuildID == (int)model.Guild)
                               .OrderByDescending(o => o.RequiredRank);

            foreach (var task in expiredTasks)
            {
                var    quest  = QuestService.GetQuestByID(task.QuestID);
                string status = ColorTokenService.Green("{ACCEPTED}");
                AddResponseToPage("TaskListPage", quest.Name + " [Rank " + (task.RequiredRank + 1) + "] " + status + ColorTokenService.Red(" [EXPIRED]"), true, task.ID);
            }

            // Pull back all currently available tasks. This list rotates after 24 hours and a reboot occurs.
            var tasks = DataService.GuildTask
                        .GetAllByCurrentlyOffered()
                        .Where(x => x.GuildID == (int)model.Guild &&
                               x.RequiredRank <= pcGP.Rank)
                        .OrderByDescending(o => o.RequiredRank);

            foreach (var task in tasks)
            {
                var quest       = QuestService.GetQuestByID(task.QuestID);
                var questStatus = DataService.PCQuestStatus.GetByPlayerAndQuestIDOrDefault(player.GlobalID, task.QuestID);

                // If the player has completed the task during this task cycle, it will be excluded from this list.
                // The reason for this is to prevent players from repeating the same tasks over and over without impunity.
                if (questStatus != null && questStatus.CompletionDate >= lastUpdate)
                {
                    continue;
                }

                string status = ColorTokenService.Green("{ACCEPTED}");
                // Player has never accepted the quest, or they've already completed it at least once and can accept it again.
                if (questStatus == null || questStatus.CompletionDate != null)
                {
                    status = ColorTokenService.Yellow("{Available}");
                }

                AddResponseToPage("TaskListPage", quest.Name + " [Rank " + (task.RequiredRank + 1) + "] " + status, true, task.ID);
            }
        }