View Single Post
08-17-20, 05:09 PM   #10
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
It looks like there are some adjustments made to the Quest System that appears to make it somewhat possible ..

My Code running in Shadowlands Beta
Lua Code:
  1. local addonName, addonData = ...
  2.  
  3. local QuestTracker = {}
  4. XQuestData = XQuestData or {}
  5. local lastQuest = nil
  6.  
  7. local function EventWatcher(self,event,...)
  8.     local args = {...}
  9.     print(event)    
  10.     if event == "QUEST_ACCEPTED" then
  11.         XQuestData[args[1]] = {}
  12.         QuestTracker[args[1]] = {}
  13.         print("Accepted Quest ID ", args[1], " named ", C_QuestLog.GetTitleForQuestID(args[1]))
  14.         self:RegisterEvent("QUEST_DATA_LOAD_RESULT")
  15.         C_QuestLog.RequestLoadQuestByID(args[1])
  16.     elseif event == "QUEST_WATCH_UPDATE" then
  17.         print("Quest ID: ", args[1])
  18.         self:RegisterEvent("QUEST_LOG_UPDATE")
  19.         lastQuest = args[1]
  20.     elseif event == "QUEST_LOG_UPDATE" then        
  21.         self:UnregisterEvent("QUEST_LOG_UPDATE")
  22.         self:RegisterEvent("QUEST_DATA_LOAD_RESULT")
  23.         C_QuestLog.RequestLoadQuestByID(lastQuest)
  24.     elseif event == "QUEST_LOG_CRITERA_UPDATE" then        
  25.         for i,v in pairs(args) do
  26.             print(i,v)
  27.         end
  28.     elseif event == "QUEST_DATA_LOAD_RESULT" then
  29.         self:UnregisterEvent("QUEST_DATA_LOAD_RESULT")
  30.         print("QuestID: ",args[1],"Success:",args[2])
  31.         if not args[2] then return end
  32.         XQuestData[args[1]] = XQuestData[args[1]] or {}
  33.         QuestTracker[args[1]] = QuestTracker[args[1]] or {}
  34.         QuestTracker[args[1]].DataRequested = C_QuestLog.GetQuestObjectives(args[1]) or {}        
  35.         for i,v in pairs(QuestTracker[args[1]].DataRequested) do
  36.             print(i,v)            
  37.         end
  38.         XQuestData[args[1]].Data = C_QuestLog.GetQuestObjectives(args[1]) or {}  
  39.     end    
  40. end
  41.  
  42. local f = CreateFrame("Frame")
  43. f:RegisterEvent("PLAYER_LOGIN")
  44. f:RegisterEvent("QUEST_ACCEPTED")
  45. f:RegisterEvent("QUEST_LOG_CRITERIA_UPDATE")
  46. f:RegisterEvent("QUEST_WATCH_UPDATE")
  47. f:SetScript("OnEvent", EventWatcher)

WTF file containing contents of XQuestData table
Lua Code:
  1. XQuestData = {
  2.     [25545] = {
  3.         ["Data"] = {
  4.             {
  5.                 ["type"] = "item",
  6.                 ["numRequired"] = 4,
  7.                 ["text"] = "0/4 Stormwind Breastplate",
  8.                 ["finished"] = false,
  9.                 ["numFulfilled"] = 0,
  10.             }, -- [1]
  11.             {
  12.                 ["type"] = "item",
  13.                 ["numRequired"] = 4,
  14.                 ["text"] = "3/4 Stormwind Helm",
  15.                 ["finished"] = false,
  16.                 ["numFulfilled"] = 3,
  17.             }, -- [2]
  18.             {
  19.                 ["type"] = "item",
  20.                 ["numRequired"] = 4,
  21.                 ["text"] = "1/4 Stormwind Spear",
  22.                 ["finished"] = false,
  23.                 ["numFulfilled"] = 1,
  24.             }, -- [3]
  25.             {
  26.                 ["type"] = "item",
  27.                 ["numRequired"] = 4,
  28.                 ["text"] = "1/4 Stormwind Shield",
  29.                 ["finished"] = false,
  30.                 ["numFulfilled"] = 1,
  31.             }, -- [4]
  32.         },
  33.     },
  34. }



The order of process appears to be ...

1. You loot/find a quest item
2. It triggers the QUEST_WATCH_UPDATE event with the questID affected .. instead of a watchlistnumber
3. The information regarding the quest changes aren't ready at that point but will be using a QUEST_LOG_UPDATE. So, start the questID we want to get info on later ...
4. When the QUEST_LOG_UPDATE event triggers we want to ask for quest details .. as follows:
self:RegisterEvent("QUEST_DATA_LOAD_RESULT")
C_QuestLog.RequestLoadQuestByID(lastQuest)
5. When the details are ready it will trigger the QUEST_DATA_LOAD_RESULT with the relevant updated info. It is at this point you can use the type field to choose whether it is a type of item you wanted to do extra work on.

I've left the other events in .. but for what you need it to do .. you won't need it as just picking an item up for an existing quest allows you to get up to date info on that quest.


Anyway, even though it doesn't help you now, you have something to work towards ready for Shadowlands.

Good Luck in your endeavours.
__________________
  Reply With Quote