-
Notifications
You must be signed in to change notification settings - Fork 14
/
WorldQuestTracker_MapAPI.lua
761 lines (642 loc) · 25.1 KB
/
WorldQuestTracker_MapAPI.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
local addonId, wqtInternal = ...
--world quest tracker object
local WorldQuestTracker = WorldQuestTrackerAddon
if (not WorldQuestTracker) then
return
end
--framework
local DF = _G ["DetailsFramework"]
if (not DF) then
print ("|cFFFFAA00World Quest Tracker: framework not found, if you just installed or updated the addon, please restart your client.|r")
return
end
local GetItemInfo = C_Item and C_Item.GetItemInfo or GetItemInfo
--localization
local L = DF.Language.GetLanguageTable(addonId)
local _
local GetQuestsForPlayerByMapID = C_TaskQuest.GetQuestsForPlayerByMapID or C_TaskQuest.GetQuestsOnMap
local isWorldQuest = QuestUtils_IsQuestWorldQuest
local GetNumQuestLogRewardCurrencies = WorldQuestTrackerAddon.GetNumQuestLogRewardCurrencies
local GetQuestLogRewardInfo = GetQuestLogRewardInfo
local GetQuestLogRewardCurrencyInfo = WorldQuestTrackerAddon.GetQuestLogRewardCurrencyInfo
local GetQuestLogRewardMoney = GetQuestLogRewardMoney
local GetNumQuestLogRewards = GetNumQuestLogRewards
---return a boolean representing if the quest is a racing world quest
---@param tagID number
---@return boolean
function WorldQuestTracker.IsRacingQuest(tagID)
if (tagID == 281) then
return true
end
return false
end
local triggerScheduledWidgetUpdate = function(timerObject)
local widget = timerObject.widget
local questID = widget.questID
if (not widget:IsShown()) then
return
end
if (HaveQuestRewardData(questID)) then
--is a zone widget placed in the world hub
if (widget.IsWorldZoneQuestButton) then
WorldQuestTracker.SetupWorldQuestButton(widget, true)
--is a square button in the world map
elseif (widget.IsWorldQuestButton) then
WorldQuestTracker.UpdateWorldWidget(widget, widget.questData)
--is a zone widget placed in the zone
elseif (widget.IsZoneQuestButton) then
WorldQuestTracker.SetupWorldQuestButton(widget, true)
--is a zone widget placed in the taxi map
elseif (widget.IsTaxiQuestButton) then
WorldQuestTracker.SetupWorldQuestButton(widget, true)
--is a zone widget placed in the zone summary frame
elseif (widget.IsZoneSummaryButton) then
WorldQuestTracker.SetupWorldQuestButton(widget, true)
end
else
WorldQuestTracker.CheckQuestRewardDataForWidget(widget, false, true)
end
end
function WorldQuestTracker.CheckQuestRewardDataForWidget(widget, noScheduleRefresh, noRequestData)
local questID = widget.questID
if (not questID) then
return false
end
if (not HaveQuestRewardData(questID)) then
--if this is from a re-schedule it already requested the data
if (not noRequestData) then
--ask que server for the reward data
C_TaskQuest.RequestPreloadRewardData(questID)
end
if (not noScheduleRefresh) then
local timer = C_Timer.NewTimer(1, triggerScheduledWidgetUpdate)
timer.widget = widget
return false, true
end
return false
end
return true
end
function WorldQuestTracker.HaveDataForQuest (questID)
local haveQuestData = HaveQuestData(questID)
local haveQuestRewardData = HaveQuestRewardData(questID)
if (not haveQuestData) then
if (WorldQuestTracker.__debug) then
WorldQuestTracker:Msg("no HaveQuestData(4) for quest", questID)
end
return
end
if (not haveQuestRewardData) then
if (WorldQuestTracker.__debug) then
WorldQuestTracker:Msg("no HaveQuestRewardData(1) for quest", questID)
end
return
end
return haveQuestData and haveQuestRewardData
end
--return the list of quests on the tracker
function WorldQuestTracker.GetTrackedQuests()
return WorldQuestTracker.QuestTrackList
end
--does the the zone have world quests?
function WorldQuestTracker.ZoneHaveWorldQuest (mapID)
--print (WorldQuestTracker.MapData, WorldQuestTracker.MapData.WorldQuestZones)
return WorldQuestTracker.MapData.WorldQuestZones [mapID or WorldQuestTracker.GetCurrentMapAreaID()]
end
--is a argus zone? - back compatibility with mods
function WorldQuestTracker.IsArgusZone (mapID)
return WorldQuestTracker.IsNewEXPZone (mapID)
end
--check if the zone is a new zone added
function WorldQuestTracker.IsNewEXPZone (mapID)
--battle for azeroth
--if (WorldQuestTracker.MapData.ZoneIDs.NAZJATAR == mapID) then
-- return true
--elseif (WorldQuestTracker.MapData.ZoneIDs.MECHAGON == mapID) then
-- return true
--end
--[=[
--Legion
if (WorldQuestTracker.MapData.ZoneIDs.ANTORAN == mapID) then
return true
elseif (WorldQuestTracker.MapData.ZoneIDs.KROKUUN == mapID) then
return true
elseif (WorldQuestTracker.MapData.ZoneIDs.MCCAREE == mapID) then
return true
end
--]=]
end
---return if the quest is a warband quest and if the quest give reputation
---@param questID number
---@param factionID number
---@return boolean, boolean
function WorldQuestTracker.GetQuestWarbandInfo(questID, factionID)
local bWarband = WorldQuestTracker.MapData.FactionHasWarbandReputation[factionID]
if (bWarband) then
if (C_QuestLog.DoesQuestAwardReputationWithFaction(questID or 0, factionID or 0)) then
return true, true --is warband and give reputation
end
return true, false --is warband but don't give reputation
end
return false, false --not warband
end
--is the current map zone a world quest hub?
function WorldQuestTracker.IsWorldQuestHub (mapID)
return WorldQuestTracker.MapData.QuestHubs [mapID]
end
--is the current map a quest hub? (wait why there's two same functions?)
function WorldQuestTracker.IsCurrentMapQuestHub()
local currentMap = WorldQuestTracker.GetCurrentMapAreaID()
return WorldQuestTracker.MapData.QuestHubs [currentMap]
end
--return if the zone is a quest hub or if a common zone
function WorldQuestTracker.GetCurrentZoneType()
if (WorldQuestTracker.ZoneHaveWorldQuest (WorldQuestTracker.GetCurrentMapAreaID())) then
return "zone"
elseif (WorldQuestTracker.IsWorldQuestHub (WorldMapFrame.mapID) or WorldQuestTracker.IsCurrentMapQuestHub()) then
return "world"
end
end
function WorldQuestTracker.GetMapInfo (uiMapId)
if (not uiMapId) then
uiMapId = C_Map.GetBestMapForUnit ("player")
if (uiMapId) then
return C_Map.GetMapInfo (uiMapId)
else
--print ("C_Map.GetBestMapForUnit ('player1'): returned NIL")
end
else
return C_Map.GetMapInfo (uiMapId)
end
end
function WorldQuestTracker.GetMapName (uiMapId)
local mapInfo = C_Map.GetMapInfo (uiMapId)
if (mapInfo) then
local mapName = mapInfo and mapInfo.name or "wrong map id"
return mapName
else
return "wrong map id"
end
end
--verifica se pode mostrar os widgets de broken isles
function WorldQuestTracker.CanShowWorldMapWidgets (noFade)
if (WorldQuestTracker.IsWorldQuestHub (WorldMapFrame.mapID) or WorldQuestTracker.IsCurrentMapQuestHub()) then
if (noFade) then
WorldQuestTracker.UpdateWorldQuestsOnWorldMap()
else
WorldQuestTracker.UpdateWorldQuestsOnWorldMap (false, true)
end
else
WorldQuestTracker.HideWorldQuestsOnWorldMap()
end
end
--return which are the current bounty quest id selected
function WorldQuestTracker.GetCurrentBountyQuest()
return WorldQuestTracker.DataProvider.bountyQuestID or 0
end
--return a map table with quest ids as key and true as value
function WorldQuestTracker.GetAllWorldQuests_Ids()
local allQuests, dataUnavaliable = {}, false
for mapId, configTable in pairs (WorldQuestTracker.mapTables) do
local taskInfo = GetQuestsForPlayerByMapID (mapId)
if (taskInfo and #taskInfo > 0) then
for i, info in ipairs (taskInfo) do
local questID = info.questID
if (HaveQuestData (questID)) then
local isWorldQuest = isWorldQuest(questID)
if (isWorldQuest) then
allQuests [questID] = true
if (not HaveQuestRewardData (questID)) then
C_TaskQuest.RequestPreloadRewardData (questID)
end
end
else
dataUnavaliable = true
end
end
else
dataUnavaliable = true
end
end
return allQuests, dataUnavaliable
end
--pega o nome da zona
function WorldQuestTracker.GetZoneName (mapID)
if (not mapID) then
return ""
end
local mapInfo = WorldQuestTracker.GetMapInfo (mapID)
return mapInfo and mapInfo.name or ""
end
function WorldQuestTracker.GetConduitQuestData(questID)
local data = WorldQuestTracker.CachedConduitData[questID]
if (data) then
return unpack(data)
end
end
function WorldQuestTracker.HasCachedQuestData(questID)
if (WorldQuestTracker.CachedQuestData[questID]) then
return true
end
end
local cacheDebug = -1
local questIDtoDebug = -1
local bCacheEnabled = false
function WorldQuestTracker.GetOrLoadQuestData(questID, canCache, dontCatchAP) --func
if (questIDtoDebug == questID) then
WorldQuestTracker:Msg("=== GetOrLoadQuestData() called ===")
end
local data = WorldQuestTracker.CachedQuestData[questID]
if (data) then
if (questIDtoDebug == questID) then
WorldQuestTracker:Msg("(debug) GetOrLoadQuestData(): quest data was cached")
end
if (cacheDebug == questID) then
print("RESTORING FROM CACHE")
print(unpack(data))
end
return unpack(data)
end
local gold, goldFormated = WorldQuestTracker.GetQuestReward_Gold(questID)
if (questIDtoDebug == questID) then
WorldQuestTracker:Msg("(debug) GetOrLoadQuestData(): gold:", gold, goldFormated)
end
local rewardName, rewardTexture, numRewardItems = WorldQuestTracker.GetQuestReward_Resource(questID)
if (questIDtoDebug == questID) then
WorldQuestTracker:Msg("(debug) GetOrLoadQuestData(): rewardName:", rewardName, rewardTexture, numRewardItems)
end
local title, factionID, tagID, tagName, worldQuestType, questQuality, isElite, tradeskillLineIndex, arg1, arg2 = WorldQuestTracker.GetQuest_Info(questID)
if (questIDtoDebug == questID) then
WorldQuestTracker:Msg("(debug) GetOrLoadQuestData(): info:", title, factionID, tagID, tagName, worldQuestType, questQuality, isElite, tradeskillLineIndex, arg1, arg2)
end
local itemName, itemTexture, itemLevel, itemQuantity, itemQuality, isUsable, itemID, isArtifact, artifactPower, isStackable, stackAmount, conduitType, borderTexture, borderColor, itemLink
if (not dontCatchAP) then
itemName, itemTexture, itemLevel, itemQuantity, itemQuality, isUsable, itemID, isArtifact, artifactPower, isStackable, stackAmount, conduitType, borderTexture, borderColor, itemLink = WorldQuestTracker.GetQuestReward_Item (questID)
end
if (questIDtoDebug == questID) then
WorldQuestTracker:Msg("(debug) GetOrLoadQuestData(): item:", itemName, itemTexture, itemLevel, itemQuantity, itemQuality, isUsable, itemID, isArtifact, artifactPower, isStackable, stackAmount, conduitType, borderTexture, borderColor)
end
local allowDisplayPastCritical = false
if (WorldQuestTracker.CanCacheQuestData and canCache and bCacheEnabled) then
if (cacheDebug == questID) then
print("ADD TO CACHE")
print(title, factionID, tagID, tagName, worldQuestType, questQuality, isElite, tradeskillLineIndex, allowDisplayPastCritical, gold, goldFormated, rewardName, rewardTexture, numRewardItems, itemName, itemTexture, itemLevel, itemQuantity, itemQuality, isUsable, itemID, isArtifact, artifactPower, isStackable, stackAmount)
end
WorldQuestTracker.CachedQuestData[questID] = {title, factionID, tagID, tagName, worldQuestType, questQuality, isElite, tradeskillLineIndex, allowDisplayPastCritical, gold, goldFormated, rewardName, rewardTexture, numRewardItems, itemName, itemTexture, itemLevel, itemQuantity, itemQuality, isUsable, itemID, isArtifact, artifactPower, isStackable, stackAmount} --31 indexes
end
return title, factionID, tagID, tagName, worldQuestType, questQuality, isElite, tradeskillLineIndex, allowDisplayPastCritical, gold, goldFormated, rewardName, rewardTexture, numRewardItems, itemName, itemTexture, itemLevel, itemQuantity, itemQuality, isUsable, itemID, isArtifact, artifactPower, isStackable, stackAmount, conduitType, borderTexture, borderColor
end
function WorldQuestTracker.GetCurrentStandingMapAreaID()
if (C_Map) then
local mapId = C_Map.GetBestMapForUnit ("player")
if (mapId) then
return mapId
else
return 0
end
else
return GetCurrentMapAreaID()
end
end
--return the current map the map is showing
function WorldQuestTracker.GetCurrentMapAreaID()
--local mapID = WorldQuestTracker.DataProvider:GetMap():GetMapID()
local mapID = WorldMapFrame.mapID
if (mapID) then
return mapID
else
if (C_Map) then
local mapId = C_Map.GetBestMapForUnit ("player")
if (mapId) then
return mapId
else
return 0
end
else
return GetCurrentMapAreaID()
end
end
end
---@param mapID number
---@return boolean
function WorldQuestTracker.DoesMapHasWorldQuests(mapID)
return WorldQuestTracker.MapData.WorldQuestZones[mapID] and true or false
end
function WorldQuestTracker.PreloadWorldQuestsForQuestHub(questHubMapId)
if (questHubMapId) then
--get the zones of this quest hub
local zones = WorldQuestTracker.mapTables
for mapID, zoneInfo in pairs(zones) do
if (zoneInfo.show_on_map[questHubMapId]) then
WorldQuestTracker.PreloadWorldQuestsForMap(mapID)
end
end
end
end
function WorldQuestTracker.PreloadWorldQuestsForMap(mapID)
if (WorldQuestTracker.DoesMapHasWorldQuests(mapID)) then
local taskInfo = GetQuestsForPlayerByMapID(mapID)
if (taskInfo and #taskInfo > 0) then
for i, info in ipairs(taskInfo) do
local questID = info.questID
local bIsWorldQuest = isWorldQuest(questID)
if (bIsWorldQuest) then
if (not HaveQuestData(questID) or not HaveQuestRewardData(questID)) then
C_Timer.After(RandomFloatInRange(0.1, 2), function()
C_TaskQuest.RequestPreloadRewardData(questID)
end)
end
end
end
end
end
end
--not in use
function WorldQuestTracker.CanShowQuest(info)
local canShowQuest = WorldQuestTracker.DataProvider:ShouldShowQuest(info)
return canShowQuest
end
-- ~filter
function WorldQuestTracker.GetQuestFilterTypeAndOrder(worldQuestType, gold, rewardName, itemName, isArtifact, stackAmount, numRewardItems, rewardTexture, tagID)
local filter, order
--[=[
/run for key, value in pairs (_G) do if type(key) == "string" and key:find ("LE_QUEST_TAG") then print (key, value) end end
LE_QUEST_TAG_TYPE_PVP = 3
LE_QUEST_TAG_TYPE_PET_BATTLE = 4
LE_QUEST_TAG_TYPE_NORMAL = 2
LE_QUEST_TAG_TYPE_PROFESSION = 1
LE_QUEST_TAG_TYPE_DUNGEON = 6
LE_QUEST_TAG_TYPE_RAID = 8
LE_QUEST_TAG_TYPE_TAG = 0
LE_QUEST_TAG_TYPE_BOUNTY = 5
LE_QUEST_TAG_TYPE_INVASION = 7
LE_QUEST_TAG_TYPE_INVASION_WRAPPER = 11
--]=]
--debug
if (worldQuestType == LE_QUEST_TAG_TYPE_NORMAL) then
-- print (LE_QUEST_TAG_TYPE_NORMAL, gold, rewardName, itemName, isArtifact, stackAmount, numRewardItems, rewardTexture)
end
if (worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE) then
return FILTER_TYPE_PET_BATTLES, WorldQuestTracker.db.profile.sort_order[WQT_QUESTTYPE_PETBATTLE]
elseif (worldQuestType == LE_QUEST_TAG_TYPE_PVP) then
return FILTER_TYPE_PVP, WorldQuestTracker.db.profile.sort_order[WQT_QUESTTYPE_PVP]
elseif (worldQuestType == LE_QUEST_TAG_TYPE_PROFESSION) then
return FILTER_TYPE_PROFESSION, WorldQuestTracker.db.profile.sort_order[WQT_QUESTTYPE_PROFESSION]
elseif (worldQuestType == LE_QUEST_TAG_TYPE_DUNGEON) then
filter = FILTER_TYPE_DUNGEON
order = WorldQuestTracker.db.profile.sort_order[WQT_QUESTTYPE_DUNGEON]
end
if (gold and gold > 0) then
order = WorldQuestTracker.db.profile.sort_order[WQT_QUESTTYPE_GOLD]
filter = FILTER_TYPE_GOLD
end
--print (rewardName, rewardTexture)
if (rewardName) then
--print (rewardName, rewardTexture) --reputation token
--resources
if (WorldQuestTracker.MapData.ResourceIcons[rewardTexture]) then
order = WorldQuestTracker.db.profile.sort_order[WQT_QUESTTYPE_RESOURCE]
filter = FILTER_TYPE_GARRISON_RESOURCE
--reputation
elseif (WorldQuestTracker.MapData.ReputationIcons[rewardTexture]) then
order = WorldQuestTracker.db.profile.sort_order[WQT_QUESTTYPE_REPUTATION]
filter = FILTER_TYPE_REPUTATION_TOKEN
--trade skill
elseif (WorldQuestTracker.MapData.TradeSkillIcons[rewardTexture]) then
order = WorldQuestTracker.db.profile.sort_order[WQT_QUESTTYPE_TRADE]
filter = FILTER_TYPE_TRADESKILL
end
end
if (WorldQuestTracker.IsRacingQuest(tagID)) then
order = WorldQuestTracker.db.profile.sort_order[WQT_QUESTTYPE_RACING] --order = 5
return FILTER_TYPE_RACING, order
end
if (isArtifact) then
order = WorldQuestTracker.db.profile.sort_order[WQT_QUESTTYPE_APOWER]
filter = FILTER_TYPE_ARTIFACT_POWER
elseif (itemName) then
if (stackAmount > 1) then
order = WorldQuestTracker.db.profile.sort_order[WQT_QUESTTYPE_TRADE]
filter = FILTER_TYPE_TRADESKILL
else
order = WorldQuestTracker.db.profile.sort_order[WQT_QUESTTYPE_EQUIPMENT]
filter = FILTER_TYPE_EQUIPMENT
end
end
--> if dungeons are disabled, override the quest type to dungeon
if (worldQuestType == LE_QUEST_TAG_TYPE_DUNGEON) then
if (not WorldQuestTracker.db.profile.filters[FILTER_TYPE_DUNGEON]) then
filter = FILTER_TYPE_DUNGEON
end
end
if (not filter) then
filter = FILTER_TYPE_GARRISON_RESOURCE
order = 9
end
return filter, order
end
--create a tooltip scanner
local GameTooltipFrame = CreateFrame ("GameTooltip", "WorldQuestTrackerScanTooltip", nil, "GameTooltipTemplate")
local ItemTooltipScan = CreateFrame ("GameTooltip", "WQTItemTooltipScan", UIParent, "InternalEmbeddedItemTooltipTemplate")
--gold amount
function WorldQuestTracker.GetQuestReward_Gold (questID)
local gold = GetQuestLogRewardMoney (questID) or 0
local formated
if (gold > 10000000) then
formated = gold / 10000 --remove os zeros
formated = string.format ("%.1fK", formated / 1000)
else
formated = floor (gold / 10000)
end
return gold, formated
end
--resource amount
function WorldQuestTracker.GetQuestReward_Resource(questID)
--local a = C_QuestLog.GetQuestRewardCurrencies(questID) --returning an empty table
--print(type(a))
--if (next(a)) then
-- dumpt(a)
--end
--local r = C_QuestInfoSystem.GetQuestRewardCurrencies(questID) --?
--dumpt(r)
--local p = C_QuestLog.GetQuestRewardCurrencies(questID)
--dumpt(p)
--C_Timer.After(3, function()
-- local p = C_QuestLog.GetQuestRewardCurrencies(questID) --got data after waiting
-- dumpt(p)
--end)
--dumpt(C_QuestLog.GetQuestRewardCurrencyInfo(questID))
--GetNumQuestRewards
--print(numQuestCurrencies, C_QuestLog.GetTitleForQuestID(questID))
---@type number
local numQuestCurrencies = GetNumQuestLogRewardCurrencies(questID)
if (numQuestCurrencies == 2) then
for currencyIndex = 1, numQuestCurrencies do
--name, texture, baseRewardAmount, currencyID, bonusRewardAmount
local name, texture, numItems, currencyId, bonusAmount = WorldQuestTracker.GetQuestLogRewardCurrencyInfo(currencyIndex, questID)
--legion invasion quest
if (texture and
(
(type (texture) == "number" and texture == 132775) or
(type (texture) == "string" and (texture:find ("inv_datacrystal01") or texture:find ("inv_misc_summonable_boss_token")))
)
) then -- [[Interface\Icons\inv_datacrystal01]]
--BFA invasion quest (this check will force it to get the second reward
elseif (not WorldQuestTracker.MapData.IgnoredRewardTexures[texture]) then
return name, texture, numItems, currencyId, bonusAmount
end
end
else
for currencyIndex = 1, numQuestCurrencies do
local name, texture, numItems, currencyId, bonusAmount = WorldQuestTracker.GetQuestLogRewardCurrencyInfo(currencyIndex, questID)
if (name) then
return name, texture, numItems, currencyId, bonusAmount
end
end
end
end
function WorldQuestTracker.GetQuestRewardConduit(questID, itemID)
if (C_Soulbinds.IsItemConduitByItemInfo(itemID)) then
local conduitType, borderColor
for i = 1, 4 do
local textString = _G ["WQTItemTooltipScanTooltipTextLeft" .. i]
local text = textString and textString:GetText()
if (text and text ~= "") then
--shadowlands
if (text == CONDUIT_TYPE_POTENCY) then
conduitType = CONDUIT_TYPE_POTENCY
elseif (text == CONDUIT_TYPE_FINESSE) then
conduitType = CONDUIT_TYPE_FINESSE
elseif (text == CONDUIT_TYPE_ENDURANCE) then
conduitType = CONDUIT_TYPE_ENDURANCE
end
if (conduitType) then
break
end
end
end
if (conduitType) then
if (not borderColor) then
borderColor = {.9, .9, .9, 1}
end
WorldQuestTracker.CachedConduitData[questID] = {conduitType, borderTexture, borderColor, itemLink}
end
return conduitType, borderColor
end
end
--pega o premio item da quest
--[=[]]
[2031] = table {
["1"] = 'Dragonscale Expedition'
["2"] = 4687628
["3"] = 75
["4"] = 2031
["5"] = 1
}
[2109] = table {
["1"] = 'Iskaara Tuskarr'
["2"] = 4687629
["3"] = 75
["4"] = 2109
["5"] = 1
}
[2106] = table {
["1"] = 'Valdrakken Accord'
["2"] = 4687630
["3"] = 75
["4"] = 2106
["5"] = 1
}
--]=]
--aaaa = {}
function WorldQuestTracker.GetQuestReward_Item(questID)
if (not HaveQuestData(questID)) then
if (WorldQuestTracker.__debug) then
WorldQuestTracker:Msg("no HaveQuestData(5) for quest", questID)
end
return
end
local numQuestCurrencies = GetNumQuestLogRewardCurrencies(questID)
if (numQuestCurrencies == 1) then
--is artifact power? bfa
do
local name, texture, numItems, currencyId, quality = GetQuestLogRewardCurrencyInfo(1, questID)
if (texture == 1830317 or texture == 2065624) then --azerite textures
--numItems are now given the amount of azerite (BFA 17-09-2018), no more tooltip scan required
return name, texture, 0, 1, 1, false, 0, 8, numItems or 0, false, 1
end
end
--is artifact power wow11
do
local name, texture, baseRewardAmount, currencyId, bonusRewardAmount = GetQuestLogRewardCurrencyInfo(1, questID)
if (texture == 2967113) then --resonance crystals
return name, texture, 0, 1, 1, false, 0, 8, baseRewardAmount or 0, false, 1
end
end
end
local numQuestRewards = GetNumQuestLogRewards(questID)
if (numQuestRewards > 0) then
local itemName, itemTexture, quantity, itemQuality, isUsable, itemID, itemLevel = GetQuestLogRewardInfo(1, questID)
itemLevel = itemLevel or 0
if (itemID) then
local itemName, itemLink, itemRarity, nopItemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemSellPrice, itemClassID, itemSubClassID = GetItemInfo(itemID)
local borderTexture
local borderColor
if (itemName) then
EmbeddedItemTooltip_SetItemByQuestReward(ItemTooltipScan, 1, questID) --GetQuestRewardConduit depends on this
borderTexture = ItemTooltipScan.IconOverlay:IsShown() and ItemTooltipScan.IconOverlay:GetTexture() == 3735314 and 3735314
if (borderTexture) then
borderColor = {ItemTooltipScan.IconOverlay:GetVertexColor()}
end
local conduitType, conduitBorderColor = WorldQuestTracker.GetQuestRewardConduit(questID, itemID)
if (conduitType) then
borderColor = conduitBorderColor
end
local icon = WorldQuestTracker.MapData.EquipmentIcons[itemEquipLoc]
if (not icon and itemClassID == 3 and itemSubClassID == 11) then
icon = WorldQuestTracker.MapData.EquipmentIcons["Relic"]
end
if (icon and not WorldQuestTracker.db.profile.use_old_icons) then
itemTexture = icon
end
local isArtifact, artifactPower = false, 0
if (not isArtifact) then
--shadowlands
if (C_Item.IsAnimaItemByID(itemID)) then
local animaAmount = itemQuality == 3 and 35 * quantity or itemQuality == 4 and 250 * quantity or 35
isArtifact = 9
artifactPower = animaAmount
--scan for anima (shadowlands)
for i = 1, 4 do
local textString = _G ["WQTItemTooltipScanTooltipTextLeft" .. i]
local text = textString and textString:GetText()
if (text and text ~= "") then
text = text:gsub("(|c).*(|r)", "")
if ((WORLD_QUEST_REWARD_FILTERS_ANIMA and text:find(_G.WORLD_QUEST_REWARD_FILTERS_ANIMA)) or (WORLD_QUEST_REWARD_FILTERS_ANIMA and text:find(_G.WORLD_QUEST_REWARD_FILTERS_ANIMA:lower()) or text:find("анимы"))) then
local animaAmount = tonumber(text:match("%d+"))
if (animaAmount) then
isArtifact = 9
artifactPower = animaAmount * quantity
break
end
end
end
end
end
end
if (isArtifact) then
return itemName, itemTexture, itemLevel, quantity, itemQuality, isUsable, itemID, 9, artifactPower, itemStackCount > 1, itemStackCount, conduitType or false, borderTexture or "", borderColor or {1, 1, 1, 1}, itemLink
else
--Returning an equipment
return itemName, itemTexture, itemLevel, quantity, itemQuality, isUsable, itemID, false, 0, itemStackCount > 1, itemStackCount, conduitType or false, borderTexture or "", borderColor or {1, 1, 1, 1}, itemLink
end
else
--ainda n�o possui info do item
return
end
else
--ainda n�o possui info do item
return
end
end
end