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.")); } }
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); } }
private void HandleRewardSelection(int responseID) { Model model = GetDialogCustomData <Model>(); ItemVO tempItem = (ItemVO)GetResponseByID("MainPage", responseID).CustomData; QuestService.CompleteQuest(GetPC(), null, model.QuestID, tempItem); EndConversation(); }