Thread Tools Display Modes
08-14-20, 05:53 PM   #1
OUGHT
A Deviate Faerie Dragon
 
OUGHT's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 16
Getting amount of specific quest item I have

I want to get the amount of a lootable quest items that do not show in my bags. I tried both GetItemCount and GetNumQuestItemDrops, and they both return zero.
How do I get this information?
__________________
The Mary Sue is not defined by her power, but by her lack of an even more powerful opponent. ©LessWrong
  Reply With Quote
08-14-20, 10:33 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
Originally Posted by OUGHT View Post
I want to get the amount of a lootable quest items that do not show in my bags. I tried both GetItemCount and GetNumQuestItemDrops, and they both return zero.
How do I get this information?

From memory they changed things a while back where quest items no longer take up space in the back pack so you probably will have to go through one of the Quest Functions or Events.

"QUEST_ITEM_UPDATE" - Although this may have been replaced recently

This appears to be more current
QUEST_LOG_CRITERIA_UPDATE:

parameters appear to be questID, specificTreeID, "description", numFulfilled, numRequired

I suspect the numFulfilled and numRequired will update as you collect them.

This function may allow you to monitor it more frequently via the questID


C_QuestLog.GetQuestObjectives(questID)

Arguments
# Name Type
1 questID number

Return values
# Name Type
1 objectives QuestObjectiveInfo[]

QuestObjectiveInfo
Field Type
text string
type string
finished boolean
numFulfilled number
numRequired number


You may need to request access to the quest information though ..

C_QuestLog.RequestLoadQuestByID(questID)
Arguments
# Name Type
1 questID number

And then monitor for this event and check its result before attempting to use the date

QUEST_DATA_LOAD_RESULT: questID, success
Payload
# Name Type
1 questID number
2 success boolean


The above is from this page :
https://wow.gamepedia.com/QUEST_ITEM_UPDATE

And the page the link in it takes you to.
https://www.townlong-yak.com/framexm...ST_ITEM_UPDATE
__________________
  Reply With Quote
08-15-20, 05:19 AM   #3
OUGHT
A Deviate Faerie Dragon
 
OUGHT's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 16
Thank you. But what if I do not have the quest ID, only the item name? How do I get which questID to query?
And is there any way that I can just get this information whenever I want without subscribing to events?
__________________
The Mary Sue is not defined by her power, but by her lack of an even more powerful opponent. ©LessWrong
  Reply With Quote
08-15-20, 10:56 AM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
Originally Posted by OUGHT View Post
Thank you. But what if I do not have the quest ID, only the item name? How do I get which questID to query?
And is there any way that I can just get this information whenever I want without subscribing to events?
It all depends on what you are aiming to do and when and why.

https://wow.gamepedia.com/API_GetQuestID

This is likely to trigger when a quest is added or removed from the Watch List.
QUEST_WATCH_LIST_CHANGED: questID, added
Payload
# Name Type
1 questID number?
2 added boolean?

This is how you would get the questID

The previous suggestions are also worth using .. put them in a simple addon and see if they trigger on their own ..

This one in particular also returns the QuestID.

QUEST_LOG_CRITERIA_UPDATE: questID, specificTreeID, "description", numFulfilled, numRequired
Payload
# Name Type
1 questID number
2 specificTreeID number
3 description string
4 numFulfilled number
5 numRequired number

As long as one of these events trigger when you either pick up the quest or fulfill a part of the quest it will give you access to the questID and thus the rest of the questID related functions ..

If this still doesn't help you .. find an addon that does something similar to what you want and see how they are doing it and see how you would need to add that type of code to your addon.
__________________
  Reply With Quote
08-15-20, 10:59 AM   #5
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
Maybe if you give an example of what quest items you are talking about and for what quest.

If it is only one item and one quest you are talking about use wowhead to identify the specific questID and go from there for your specific one of a kind mini addon.

If you were wanting a more generic addon for future quest item scenarios then the only way is using events to identify the questID and then use the questID for the different questID used functions.
__________________
  Reply With Quote
08-15-20, 01:28 PM   #6
OUGHT
A Deviate Faerie Dragon
 
OUGHT's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 16
I'm trying to make a simple addon that displays items that are just looted in a frame for a few seconds - amount I just got and a new total amount. Something like this: "+3 Boar Snouts (9 total)".
It works for normal items, but when I loot the quest items, I recieve: "+3 Boar Snouts (0 total)". I don't know which quest the items that were just looted belong to, I have only the ItemLink.
__________________
The Mary Sue is not defined by her power, but by her lack of an even more powerful opponent. ©LessWrong
  Reply With Quote
08-15-20, 04:10 PM   #7
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
Originally Posted by OUGHT View Post
I'm trying to make a simple addon that displays items that are just looted in a frame for a few seconds - amount I just got and a new total amount. Something like this: "+3 Boar Snouts (9 total)".
It works for normal items, but when I loot the quest items, I recieve: "+3 Boar Snouts (0 total)". I don't know which quest the items that were just looted belong to, I have only the ItemLink.
So,

I assume you are tracking a loot event to see the items you are getting ?

Just add one of the Quest specific events I mentioned and they will provide the quest related part of the equation ..

Unfortunately I can't see an item to quest conversion as most iems are not for quests .. but most quest have items whether it be physical items or units ( kills ).

Edit:
I've rigged up something quickly to see how it would work ( only theoretical so far ). Will post up the code for you to test and utilise once I get something working.
__________________

Last edited by Xrystal : 08-15-20 at 04:35 PM.
  Reply With Quote
08-15-20, 07:08 PM   #8
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
Ah .. it looks like they still haven't implemented the problems we noticed a few years back ..
https://www.wowinterface.com/forums/...ad.php?t=56622

I tried the following events to know joy .. whether QuestReward items or Quest Goals or actual Quest Items looted for the quest .. they never triggered at all.

f:RegisterEvent("QUEST_LOG_CRITERIA_UPDATE")
f:RegisterEvent("QUEST_LOOT_RECEIVED")

QUEST_LOG_UPDATE works often and best registered after QUEST_WATCH_UPDATE to have it trigger less often

However, QuestLogUpdate does not have any quest reference you can use to get specific quest details so you would have to look through all the quests you have to retrieve the information you need...

Here is the code I got kinda working .. it still has errors though..

Lua Code:
  1. local addonName, addonData = ...
  2.  
  3. local QuestIndexInfo = {}
  4. local ID_IDX = {}
  5. local QuestDataRequested = {}
  6.  
  7. local function EventWatcher(self,event,...)
  8.     local args = {...}
  9.     print(event)    
  10.     if event == "QUEST_ACCEPTED" then
  11.         ID_IDX[args[2]] = args[1]
  12.         QuestIndexInfo[args[1]] = {}
  13.         QuestIndexInfo[args[1]].ID = args[2]
  14.         QuestIndexInfo[args[1]].Name = C_QuestLog.GetQuestInfo(args[2])
  15.         self:RegisterEvent("QUEST_DATA_LOAD_RESULT")
  16.         C_QuestLog.RequestLoadQuestByID(args[2])
  17.         print("Accepted Quest ID ", args[2], " at index ", args[1], " named ", QuestIndexInfo[args[1]].Name)
  18.  
  19.     elseif event == "QUEST_WATCH_UPDATE" then
  20.         print("Quest Index: ", args[1])
  21.         self:RegisterEvent("QUEST_LOG_UPDATE")
  22.         local questID = QuestIndexInfo[args[1]].ID
  23.         self:RegisterEvent("QUEST_DATA_LOAD_RESULT")
  24.         C_QuestLog.RequestLoadQuestByID(questID)
  25.  
  26.     elseif event == "QUEST_LOG_UPDATE" then        
  27.         self:UnregisterEvent("QUEST_LOG_UPDATE")
  28.  
  29.     elseif event == "QUEST_LOG_CRITERA_UPDATE" then        
  30.         for i,v in pairs(args) do
  31.             print(i,v)
  32.         end
  33.  
  34.     elseif event == "QUEST_DATA_LOAD_RESULT" then
  35.         self:UnregisterEvent("QUEST_DATA_LOAD_RESULT")
  36.         print("QuestID: ",args[1],"Success:",args[2])
  37.         if not args[2] then return end
  38.         local questIndex = ID_IDX[args[1]]
  39.         QuestIndexInfo[questIndex].DataRequested = C_QuestLog.GetQuestObjectives(args[1])  
  40.         for i,v in pairs(QuestIndexInfo[questIndex].DataRequested) do
  41.             print(i,v)
  42.         end
  43.  
  44.     end    
  45. end
  46.  
  47. local f = CreateFrame("Frame")
  48. f:RegisterEvent("PLAYER_LOGIN")
  49. f:RegisterEvent("QUEST_ACCEPTED")
  50. f:RegisterEvent("QUEST_LOG_CRITERIA_UPDATE")
  51. f:RegisterEvent("QUEST_LOOT_RECEIVED")
  52. f:RegisterEvent("QUEST_WATCH_UPDATE")
  53. f:SetScript("OnEvent", EventWatcher)

Using this addon code .. When I first accepted the quest I told it to create a QuestIndex and QuestID and QuestInfo table so that I could keep it updated. At this point QuestID was 25545 and QuestIndex was 5 ... great, so far so good. Then QUEST_WATCH_UPDATE triggered when I picked up the loot for that new quest picked up. That's what we wanted right ? Yes, but this time it returned QuestIndex 3 not 5. And thats where the error happens .. as I have a QuestIndex 5 = QuestID 25545 connection and the reverse but not with QuestIndex 3.

Looking at the issues and the only solution to the issues .. there is simply no point as you would be practically creating your personal quest watching system.

Anyway, that's my thoughts on this and unfortunately it hasn't resolved the problem for you.

Hopefully someone has a better knowledge of quest info grabbing to get at the information you want .. but I really dont think there is a way until blizzard fixes these almost perfect events/functions only to have them mess up along the way or plain not work, at least for addons.
__________________
  Reply With Quote
08-16-20, 06:50 PM   #9
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Or you can just keep a tally yourself.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
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

WoWInterface » Developer Discussions » Lua/XML Help » Getting amount of specific quest item I have

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off