-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvents.lua
More file actions
1120 lines (827 loc) · 31.8 KB
/
Events.lua
File metadata and controls
1120 lines (827 loc) · 31.8 KB
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
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local addonName, AdventureGuide = ...;
--[[
temp fix
]]
if not InterfaceOptions_AddCategory then
function InterfaceOptions_AddCategory(AddonThing)
local category, layout = Settings.RegisterCanvasLayoutCategory(AddonThing, AddonThing.name, AddonThing.name);
category.ID = AddonThing.name;
Settings.RegisterAddOnCategory(category)
end
end
local SavedVariables = AdventureGuide.SavedVariables;
local EventFrame = CreateFrame("FRAME")
--EventFrame:RegisterEvent("ADDON_LOADED")
EventFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
-- EventFrame:RegisterEvent("PLAYER_INTERACTION_MANAGER_FRAME_SHOW")
EventFrame:RegisterEvent("QUEST_ACCEPTED")
EventFrame:RegisterEvent("QUEST_TURNED_IN")
--EventFrame:RegisterEvent("QUEST_LOG_UPDATE")
EventFrame:RegisterEvent("QUEST_LOG_CRITERIA_UPDATE")
EventFrame:RegisterEvent("QUEST_WATCH_UPDATE")
EventFrame:RegisterEvent("QUEST_REMOVED")
EventFrame:RegisterEvent("ZONE_CHANGED_NEW_AREA")
EventFrame:RegisterEvent("PLAYER_LEVEL_UP")
EventFrame:RegisterEvent("NAME_PLATE_UNIT_ADDED")
EventFrame:RegisterEvent('CVAR_UPDATE')
-- EventFrame:RegisterEvent('BANKFRAME_OPENED')
-- EventFrame:RegisterEvent('BANKFRAME_CLOSED')
-- EventFrame:RegisterEvent('BAG_UPDATE_DELAYED')
-- EventFrame:RegisterEvent('BAG_OPEN')
-- EventFrame:RegisterEvent('UNIT_STATS')
EventFrame:SetScript("OnEvent", function(self, event, ...)
if self[event] then
self[event](self, ...)
end
end)
function EventFrame:CVAR_UPDATE(cvar, val)
if cvar == "uiScale" then
AdventureGuide.CallbackRegistry:TriggerEvent("CVarInfo_UiScaleChanged", val)
end
end
function EventFrame:PLAYER_ENTERING_WORLD(isInitial, isReload)
--SavedVariables:Reset()
local _name, realm = UnitName("player")
if not realm then
realm = GetNormalizedRealmName()
end
local nameRealm = string.format("%s-%s", _name, realm)
if isInitial then
local _, _, classID = UnitClass("player")
local _, _, raceID = UnitRace("player")
local level = UnitLevel("player")
local unitFaction = UnitFactionGroup("player")
SavedVariables:Init()
SavedVariables:NewCharacter(nameRealm, classID, level, raceID, unitFaction)
local currentProfile = SavedVariables:GetProfile(nameRealm)
AdventureGuide.ActiveProfile = AdventureGuide.CharacterProfile:CreateFromData(currentProfile)
AdventureGuide.ActiveProfile:SetPlayerLevel(level)
AdventureGuide.ActiveProfile:UpdateCompletedQuests()
AdventureGuide.ActiveProfile:ScanQuestLog()
else
SavedVariables:Connect()
if not AdventureGuide.Profiles[nameRealm] then
local currentProfile = SavedVariables:GetProfile(nameRealm)
local profile = AdventureGuide.CharacterProfile:CreateFromData(currentProfile)
AdventureGuide.Profiles[nameRealm] = profile
AdventureGuide.ActiveProfile = AdventureGuide.Profiles[nameRealm]
end
AdventureGuide.ActiveProfile:UpdateCompletedQuests()
AdventureGuide.ActiveProfile:ScanQuestLog()
end
if ViragDevTool_AddData then
ViragDevTool_AddData(AdventureGuide.ActiveProfile, "AdventureGuide_ActiveProfile")
ViragDevTool_AddData(SavedVariables, "SavedVariables")
ViragDevTool_AddData(AdventureGuide.Profiles, "AdventureGuide.Profiles")
end
-- ADVENTURE_GUIDE_CHARACTER = {}
-- for _, info in ipairs(AdventureGuide.Dungeons) do
-- for k, v in ipairs(info.bosses) do
-- ADVENTURE_GUIDE_CHARACTER[v.npcID] = v.name
-- end
-- end
local category, layout = Settings.RegisterCanvasLayoutCategory(AdventureGuide.SettingsPanel, addonName, addonName);
category.ID = addonName;
Settings.RegisterAddOnCategory(category)
end
function EventFrame:NAME_PLATE_UNIT_ADDED(unitToken)
AdventureGuide.CallbackRegistry:TriggerEvent("NamePlate_OnUnitAdded", unitToken)
end
function EventFrame:NAME_PLATE_UNIT_REMOVED(unitToken)
AdventureGuide.CallbackRegistry:TriggerEvent("NamePlate_OnUnitRemoved", unitToken)
end
function EventFrame:UNIT_STATS(...)
if ... == "player" then
end
end
function EventFrame:PLAYER_LEVEL_UP(...)
local newLevel = ...;
AdventureGuide.ActiveProfile:SetPlayerLevel(newLevel)
AdventureGuide.CallbackRegistry:TriggerEvent("Player_OnLevelChanged")
end
function EventFrame:QUEST_WATCH_UPDATE(questID)
C_Timer.After(1, function()
AdventureGuide.CallbackRegistry:TriggerEvent("Quest_OnQuestCriteriaUpdated", questID)
AdventureGuide.ActiveProfile:ScanQuestLog()
if IsQuestComplete(questID) then
AdventureGuide.CallbackRegistry:TriggerEvent("Quest_OnQuestCriteriaCompleted", questID)
end
end)
end
function EventFrame:ZONE_CHANGED_NEW_AREA()
AdventureGuide.CallbackRegistry:TriggerEvent("Zone_OnChangedNewArea")
end
function EventFrame:QUEST_LOG_UPDATE()
AdventureGuide.CallbackRegistry:TriggerEvent("Quest_OnQuestLogUpdated")
end
function EventFrame:QUEST_REMOVED(questID)
AdventureGuide.ActiveProfile:RemoveQuest(questID)
AdventureGuide.CallbackRegistry:TriggerEvent("Quest_OnQuestRemoved", questID)
end
function EventFrame:QUEST_ACCEPTED(questLogIndex)
local questID = select(8, GetQuestLogTitle(questLogIndex))
AdventureGuide.ActiveProfile:SetQuestAccepted(questID)
AdventureGuide.CallbackRegistry:TriggerEvent("Quest_OnQuestAccepted", questID)
end
function EventFrame:QUEST_TURNED_IN(questID)
AdventureGuide.ActiveProfile:SetQuestTurnedIn(questID)
AdventureGuide.CallbackRegistry:TriggerEvent("Quest_OnQuestTurnIn", questID)
end
local bankScanned = false
function EventFrame:BANKFRAME_CLOSED()
end
function EventFrame:BANKFRAME_OPENED()
end
function EventFrame:BAG_UPDATE_DELAYED()
end
function EventFrame:ADDON_LOADED(...)
end
function EventFrame:CreateNpcLocales()
ADVENTURE_GUIDE_GLOBAL = {}
for npcID, info in pairs(AdventureGuide.NpcData) do
--ADVENTURE_GUIDE_GLOBAL[info.name:gsub(" ", "_"):gsub("'", ""):upper()] = info.name
ADVENTURE_GUIDE_GLOBAL[npcID] = {
name = info.name:gsub(" ", "_"):gsub("'", ""):upper(),
spawnLocations = info.spawnLocations,
npcID = npcID,
}
end
end
--[[
classID|raceID|faction|level 4|3|1|6
0000|000|0|000001
WARRIOR 1 0000
PALADIN 2 0001
HUNTER 3 0010
ROGUE 4 0011
PRIEST 5 0100
DK
SHAMAN 7 0110
MAGE 8 0111
WARLOCK 9 1000
MONK
DRUID 11 1010
HUMAN 1 000
ORC 2 001
DWARF 3 010
NIGHTELF 4 011
UNDEAD 5 100
TAUREN 6 101
GNOME 7 110
TROLL 8 111
ALLIANCE 0
HORDE 1
THIS IS OLD CODE WHICH MAY PROVE USEFUL DURING DEVELOPMENT - MIGHT ALSO BE JUNK
function EventFrame:makePlusmouseData()
ADVENTURE_GUIDE_CHARACTER = {}
for mapID, items in pairs(addon.nodes.herbs) do
for k, v in ipairs(items) do
local item = Item:CreateFromItemID(v.itemID)
if not item:IsItemEmpty() then
item:ContinueOnItemLoad(function()
ADVENTURE_GUIDE_CHARACTER[v.itemID] = {
name = item:GetItemName(),
link = item:GetItemLink(),
category = "herbs"
}
end)
end
end
end
for mapID, items in pairs(addon.nodes.mining) do
for k, v in ipairs(items) do
local item = Item:CreateFromItemID(v.itemID)
if not item:IsItemEmpty() then
item:ContinueOnItemLoad(function()
ADVENTURE_GUIDE_CHARACTER[v.itemID] = {
name = item:GetItemName(),
link = item:GetItemLink(),
category = "mining"
}
end)
end
end
end
end
function EventFrame:createItemToQuestMapping()
local t = {}
for itemID, info in pairs(addon.itemData) do
for qid, info2 in pairs(addon.rawQuestDataKeyed) do
if info2.objectives and info2.objectives.items then
for k, v in ipairs(info2.objectives.items) do
if v == itemID then
if not t[itemID] then
t[itemID] = {}
end
table.insert(t[itemID], info2.questID)
end
end
end
end
end
ADVENTURE_GUIDE_CHARACTER = t;
end
local function decodeLoc(id)
return floor(id/1000000)/10000, floor(id % 1000000 / 100)/10000
end
function EventFrame:generateNodeData()
ADVENTURE_GUIDE_CHARACTER = {
mining = {},
herbs = {},
}
for mapID, nodes in pairs(addon.miningData) do
if not ADVENTURE_GUIDE_CHARACTER.mining[mapID] then
ADVENTURE_GUIDE_CHARACTER.mining[mapID] = {}
end
for coords, id in pairs(nodes) do
local x, y = decodeLoc(coords)
if addon.nodeIDs[id] then
table.insert(ADVENTURE_GUIDE_CHARACTER.mining[mapID], {
itemID = addon.nodeIDs[id].itemID,
x = x*100,
y = y*100,
})
end
end
end
for mapID, nodes in pairs(addon.herbData) do
if not ADVENTURE_GUIDE_CHARACTER.herbs[mapID] then
ADVENTURE_GUIDE_CHARACTER.herbs[mapID] = {}
end
for coords, id in pairs(nodes) do
local x, y = decodeLoc(coords)
if addon.nodeIDs[id] then
table.insert(ADVENTURE_GUIDE_CHARACTER.herbs[mapID], {
itemID = addon.nodeIDs[id].itemID,
x = x*100,
y = y*100,
})
end
end
end
end
function EventFrame:generateData()
ADVENTURE_GUIDE_CHARACTER = {}
-- for id, info in pairs(addon.itemData) do
-- if info[12] == 12 then
-- ADVENTURE_GUIDE_CHARACTER[tostring(id)] = {
-- itemID = id,
-- name = info[1],
-- dropsFrom = {
-- info[2],
-- info[3],
-- info[4],
-- },
-- startsQuest = info[5],
-- }
-- end
-- end
for id, info in pairs(addon.objectData) do
if info[2] == nil and info[3] == nil then
else
local spawnLocations = {}
if info[4] then
for k, v in pairs(info[4]) do
local id = addon.zoneIdToMapId[k]
if id then
spawnLocations[id] = v;
end
end
end
ADVENTURE_GUIDE_CHARACTER[tostring(id)] = {
objectID = id,
name = info[1],
spawnLocations = spawnLocations,
}
end
end
end
function EventFrame:generateNpcData()
ADVENTURE_GUIDE_CHARACTER = {}
for id, info in pairs(addon.npcData) do
if info[7] then
local spawnLocations = {}
for k, v in pairs(info[7]) do
local id = zoneID[k]
if id then
spawnLocations[id] = v;
end
end
ADVENTURE_GUIDE_CHARACTER[tostring(id)] = {
npcID = id,
npcName = info[1],
spawnLocations = spawnLocations,
}
end
end
end
function EventFrame:generateZoneData()
ADVENTURE_GUIDE_CHARACTER = {}
for id, tab in pairs(addon.questData.zones) do
if type(id) == "number" then
local quests = addon.questData.chapters[id]
local questData = addon.questData.zones[id]
if quests and questData then
local starterQuests = {}
for k, chapter in ipairs(quests) do
local id = chapter[1]
local levelReq;
local previousQ;
for _, q in ipairs(questData) do
if q.questID == id then
levelReq = q.levelRequired
previousQ = q.previousQuests
end
end
table.insert(starterQuests, {
qid = id,
lvl = levelReq,
prev = previousQ,
})
end
table.sort(starterQuests, function(a, b)
return a.lvl < b.lvl;
end)
local t = {}
for k, v in ipairs(starterQuests) do
for _, chapter in ipairs(quests) do
if chapter[1] == v.qid then
if #chapter == 1 then
table.insert(t, {
isStartQuest = true,
questId = chapter[1],
previousQuests = {},
})
else
table.insert(t, {
isStartQuest = true,
questId = chapter[1],
previousQuests = v.prev,
})
for i = 2, #chapter do
table.insert(t, {
questId = chapter[i],
isStartQuest = false,
previousQuests = v.prev,
})
end
end
end
end
end
end
end
end
end
function EventFrame:modBags()
local overlays = {
--junkOverlay = "bags-glow-artifact",
greenOverlay = "bags-glow-green",
blueOverlay = "bags-glow-blue",
purpleOverlay = "bags-glow-purple",
--questOverlay = "bags-glow-heirloom"
questOverlay = "bags-glow-artifact"
}
-- for b = 1, 5 do
-- for s = 0, 32 do
-- if _G['ContainerFrame'..b..'Item'..s] then
-- local f = _G['ContainerFrame'..b..'Item'..s]
-- if f then
-- for k, v in pairs(overlays) do
-- f[k] = f:CreateTexture(nil, "OVERLAY")
-- f[k]:SetAllPoints()
-- f[k]:SetAtlas(v)
-- f[k]:Hide()
-- f:HookScript("OnClick", function(f, button)
-- end)
-- end
-- end
-- end
-- end
-- end
for containerIndex = 1, 13 do
for slot = 1, 36 do
local itemButton = _G["ContainerFrame" .. containerIndex .. "Item" .. slot]
if itemButton then
for k, v in pairs(overlays) do
itemButton[k] = itemButton:CreateTexture(nil, "OVERLAY")
itemButton[k]:SetAllPoints()
itemButton[k]:SetAtlas(v)
itemButton[k]:Hide()
end
-- itemButton:HookScript("OnClick", function(but)
-- local info = C_Container.GetContainerItemInfo(but:GetParent():GetID(), but:GetID());
-- if info and IsAltKeyDown() then
-- addon:TriggerEvent("Character_OnContainerItemClicked", info)
-- end
-- end)
end
end
end
end
function EventFrame:generateObjectData()
ADVENTURE_GUIDE_CHARACTER = {}
for objectID, info in pairs(objectData) do
local spawnLoc = {}
if type(info[4]) == "table" then
for zoneID, t in pairs(info[4]) do
local mapID = addon.zoneIdToMapId[zoneID]
if mapID then
spawnLoc[mapID] = t
end
end
local t = {
objectID = objectID,
name = info[1],
spawnLocations = spawnLoc
}
ADVENTURE_GUIDE_CHARACTER[objectID] = t
else
print(info[1])
end
end
end
local classID_new = {
[1] = 1, -- 0000000000 0000000001
[2] = 2, -- 0000000000 0000000010
[3] = 4, -- 0000000000 0000000100
[4] = 8, -- 0000000000 0000001000
[5] = 16, -- 0000000000 0000010000
[6] = 32, -- 0000000000 0000100000
[7] = 64, -- 0000000000 0001000000
[8] = 128, -- 0000000000 0010000000
[9] = 256, -- 0000000000 0100000000
[11] = 512, -- 0000000000 1000000000
}
local classID = {
[1] = 1, -- 0000000000 0000000001
[2] = 2, -- 0000000000 0000000010
[4] = 3, -- 0000000000 0000000100
[8] = 4, -- 0000000000 0000001000
[16] = 5, -- 0000000000 0000010000
[32] = 6, -- 0000000000 0000100000
[64] = 7, -- 0000000000 0001000000
[128] = 8, -- 0000000000 0010000000
[256] = 9, -- 0000000000 0100000000
[1024] = 11, -- 0000000000 1000000000
}
local raceID = {
[0] = "any", -- 1111111111 0000000000 1047552
[1] = 1, --human 0000000001 0000000000 1024
[2] = 2, --orc 0000000010 0000000000 2048
[4] = 3, --dwarf 0000000100 0000000000 4096
[8] = 4, --nelf 0000001000 0000000000 8192
[16] = 5, --undead 0000010000 0000000000 16384
[32] = 6, --tauren 0000100000 0000000000 32768
[64] = 7, --gnome 0001000000 0000000000 65536
[128] = 8, --troll 0010000000 0000000000 131072
[512] = 10, --belf 0100000000 0000000000 262144
[1024] = 11, --goat 1000000000 0000000000 524288
[77] = "allianceQuest", -- 0001001101 0000000000 78848
[178] = "hordeQuest", -- 1110110010 0000000000 968704
}
local questSorting = {
[61] = 9, --warlock
[82] = 7, --shaman
[161] = 8, --mage
[261] = 3, --hunter
[263] = 11, --druid
[81] = 1, --warrior
[141] = 2, --paladin
[162] = 4, --rogue
[262] = 5, --priest
[372] = 6, --dk
[24] = 182, --herbalism
[121] = 164, --BS
[182] = 165, --LW
[264] = 197, --tailoring
[324] = 129, --FA
[371] = 773, --insc
[101] = 356, --fishing
[181] = 171, --alch
[201] = 202, --eng
[302] = 185, --cooking
[373] = 755, --JC
[762] = "riding",
[1] = "questSort_Epic",
[22] = "questSort_Seasonal",
[25] = "questSort_BG",
[364] = "questSort_DMF",
[366] = "questSort_LunarFestival",
[370] = "questSort_Brewfest",
[375] = "questSort_PilgrimsBounty",
[344] = "questSort_Legendary",
[369] = "questSort_Midsummer",
[374] = "questSort_Noblegarden",
[376] = "questSort_LIITA",
[365] = "questSort_AQwar",
}
function EventFrame:processRawQuestData()
ADVENTURE_GUIDE_CHARACTER = {}
local zones = {}
local dodgy = {}
for k, quest in ipairs(addon.rawQuestData) do
if quest.startMapID then
if not zones[quest.startMapID] then
zones[quest.startMapID] = {}
end
table.insert(zones[quest.startMapID], quest.questID)
else
table.insert(dodgy, quest.questID)
end
end
ADVENTURE_GUIDE_CHARACTER = {
mapIDs = zones,
badQuests = dodgy,
}
end
function EventFrame:generateQuestDb()
ADVENTURE_GUIDE_CHARACTER = {}
local function questHasNextQuest(quest)
return quest.nextQuest and true or false;
end
local quest;
local mapID;
--for k, quest in ipairs(addon.rawQuestData) do
for questID, quest in pairs(addon.rawQuestDataKeyed) do
--if addon.rawQuestDataKeyed["qid-"..quest.questID] then
if not quest.requiredQuest then
mapID = quest.startMapID
if type(mapID) == "number" then
if not ADVENTURE_GUIDE_CHARACTER[mapID] then
ADVENTURE_GUIDE_CHARACTER[mapID] = {}
end
local chain = {}
quest = addon.rawQuestDataKeyed["qid-"..quest.questID]
table.insert(chain, quest.questID)
while (questHasNextQuest(quest)) do
quest = addon.rawQuestDataKeyed["qid-"..quest.nextQuest]
table.insert(chain, quest.questID)
end
table.insert(ADVENTURE_GUIDE_CHARACTER[mapID], chain)
elseif type(mapID) == "table" then
for k, v in ipairs(mapID) do
if not ADVENTURE_GUIDE_CHARACTER[v] then
ADVENTURE_GUIDE_CHARACTER[v] = {}
end
local chain = {}
quest = addon.rawQuestDataKeyed["qid-"..quest.questID]
table.insert(chain, quest.questID)
while (questHasNextQuest(quest)) do
quest = addon.rawQuestDataKeyed["qid-"..quest.nextQuest]
table.insert(chain, quest.questID)
end
table.insert(ADVENTURE_GUIDE_CHARACTER[v], chain)
end
end
end
--end
end
end
function EventFrame:ScanCodexQuests()
ADVENTURE_GUIDE_CHARACTER = {}
for questID, info in pairs(addon.codexQuestData) do
if type(questID) == "number" then
local endZone
local objectives = {}
if info.obj then
if info.obj.I then
objectives.items = info.obj.I
end
if info.obj.O then
objectives.objects = info.obj.O
end
if info.obj.U then
objectives.npc = info.obj.U
end
end
local endPoint = info["end"] or {}
local newEndPoint = {}
if endPoint.U then
newEndPoint.npc = endPoint.U;
if addon.npcData[endPoint.U[1] ] then
newEndPoint.spawnLocations = addon.npcData[endPoint.U[1] ].spawnLocations
for zoneID, _ in pairs(addon.npcData[endPoint.U[1] ].spawnLocations) do
endZone = zoneID
end
end
end
if endPoint.I then
newEndPoint.item = endPoint.I;
for k, itemID in ipairs(endPoint.I) do
if addon.itemData[itemID] then
if not newEndPoint.dropLocations then
newEndPoint.dropLocations = {}
end
newEndPoint.dropLocations[itemID] = addon.itemData[itemID].dropsFrom
end
end
end
if endPoint.O then
newEndPoint.object = endPoint.O;
if addon.objectData[endPoint.O[1] ] then
newEndPoint.spawnLocations = addon.objectData[endPoint.O[1] ].spawnLocations
for zoneID, _ in pairs(addon.objectData[endPoint.O[1] ].spawnLocations) do
endZone = zoneID
end
end
end
local startZone;
--local startItemDroppers = {}
local startPoint = info["start"] or {}
local newStartPoint = {}
if startPoint.U then
newStartPoint.npc = startPoint.U;
if addon.npcData[startPoint.U[1] ] then
newStartPoint.spawnLocations = addon.npcData[startPoint.U[1] ].spawnLocations
for zoneID, _ in pairs(addon.npcData[startPoint.U[1] ].spawnLocations) do
startZone = zoneID
end
end
end
if startPoint.I then
newStartPoint.item = startPoint.I;
for k, itemID in ipairs(startPoint.I) do
if addon.itemData[itemID] then
if not newStartPoint.dropLocations then
newStartPoint.dropLocations = {}
end
newStartPoint.dropLocations[itemID] = addon.itemData[itemID].dropsFrom
if addon.itemData[itemID].dropsFrom[1] then
for k, dropperNpcID in ipairs(addon.itemData[itemID].dropsFrom[1]) do
local npcInfo = addon.npcData[dropperNpcID]
if npcInfo and npcInfo.spawnLocations then
print("got spawn locations", questID)
startZone = {}
for mapID, locations in pairs(npcInfo.spawnLocations) do
table.insert(startZone, mapID)
end
end
end
end
end
end
end
if startPoint.O then
newStartPoint.object = startPoint.O;
if addon.objectData[startPoint.O[1] ] then
newStartPoint.spawnLocations = addon.objectData[startPoint.O[1] ].spawnLocations
for zoneID, _ in pairs(addon.objectData[startPoint.O[1] ].spawnLocations) do
startZone = zoneID
end
end
end
ADVENTURE_GUIDE_CHARACTER["qid-"..questID] = {
questID = questID,
minLevel = info.min,
level = info.lvl,
startPoint = newStartPoint,
--startItemDroppers = startItemDroppers,
finishPoint = newEndPoint,
nextQuest = info.next,
requiredQuest = info.pre,
class = classID[info.class],
race = raceID[info.race],
startMapID = startZone,
finishMapID = endZone,
objectives = objectives,
}
-- table.insert(ADVENTURE_GUIDE_CHARACTER, {
-- questID = questID,
-- minLevel = info.min,
-- level = info.lvl,
-- startPoint = newStartPoint,
-- --startItemDroppers = startItemDroppers,
-- finishPoint = newEndPoint,
-- nextQuest = info.next,
-- requiredQuest = info.pre,
-- class = classID[info.class],
-- race = raceID[info.race],
-- startMapID = startZone,
-- finishMapID = endZone,
-- objectives = objectives,
-- })
end
end
end
function EventFrame:processQuests()
ADVENTURE_GUIDE_CHARACTER = {}
for questID, data in pairs(addon.quests) do
local races = {}
if type(data[6]) == "table" then
for k, v in ipairs(data[6]) do
table.insert(races, raceID[v])
end
else
races = {raceID[data[6] ]}
end
local class = {}
if type(data[7]) == "table" then
for k, v in ipairs(data[7]) do
table.insert(class, classID[v])
end
else
class = {classID[data[7] ]}
end
local requiredQuests = {}
if data[12] then
requiredQuests = data[12]
end
if data[13] then
requiredQuests = data[13]