-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.lua
More file actions
1639 lines (1629 loc) · 49.9 KB
/
main.lua
File metadata and controls
1639 lines (1629 loc) · 49.9 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
--[[--
by ALA
CREDIT shagu/pfQuest(MIT LICENSE) @ https://github.com/shagu
--]]--
local __addon, __private = ...;
local MT = __private.MT;
local CT = __private.CT;
local VT = __private.VT;
local DT = __private.DT;
--> upvalue
local select = select;
local next = next;
local wipe = table.wipe;
local strfind, gsub = string.find, string.gsub;
local floor, random = math.floor, math.random;
local bit_band = bit.band;
local IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown = IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown;
local GetQuestDifficultyColor = GetQuestDifficultyColor;
local GetNumQuestLogEntries = GetNumQuestLogEntries;
local GetQuestLogTitle = GetQuestLogTitle;
local GetNumQuestLeaderBoards = GetNumQuestLeaderBoards;
local GetQuestLogQuestText = GetQuestLogQuestText;
local GetQuestLogLeaderBoard = GetQuestLogLeaderBoard;
local GetQuestObjectives = C_QuestLog.GetQuestObjectives; -- (quest_id) returns { [line(1, 2, 3, ...)] = { [type], [finished], [numRequired], [numFulfilled], [text] } }
local GetQuestsCompleted = GetQuestsCompleted; -- ({ } or nil) return { [quest_id] = completed(true/nil), }
-- IsQuestComplete(qid)
-- IsQuestFlaggedCompleted(qid)
local GetFactionInfoByID = GetFactionInfoByID;
local GetNumSkillLines = GetNumSkillLines;
local GetSkillLineInfo = GetSkillLineInfo;
local _G = _G;
-->
local DataAgent = DT.DB;
local l10n = CT.l10n;
local EventAgent = VT.EventAgent;
--> Compatible
local _comptb = { };
VT._comptb = _comptb;
if GetMouseFocus then
_comptb.GetMouseFocus = GetMouseFocus;
elseif GetMouseFoci then
local GetMouseFoci = GetMouseFoci;
_comptb.GetMouseFocus = function()
return GetMouseFoci()[1];
end
else
_comptb.GetMouseFocus = function()
end
end
-->
MT.BuildEnv("main");
--> MAIN
local META = { };
--[[
[quest_id] = {
[title],
[flag]:whether_nodes_added,
[completed],
[num_lines],
[line(1, 2, 3, ...)] = {
[1] = shown,
[2] = objective_type,
[3] = objective_id,
[4] = description,
[5] = finished,
[6] = is_large_pin,
},
}
]]
local OBJ_LOOKUP = { ["*"] = { }, };
local QUESTS_COMPLETED = { };
local QUESTS_CONFILCTED = { };
VT.MAIN_META = META;
VT.MAIN_OBJ_LOOKUP = OBJ_LOOKUP;
VT.MAIN_QUESTS_COMPLETED = QUESTS_COMPLETED;
--> function predef
local GetColor3, RelColor3, GetColor3NextIndex, ResetColor3;
local CoreAddUUID, CoreSubUUID, CoreGetUUID, CoreResetUUID;
local GetVariedNodeTexture, AddCommonNodes, DelCommonNodes, AddLargeNodes, DelLargeNodes, AddVariedNodes, DelVariedNodes;
local AddObjectLookup;
local AddSpawn, DelSpawn, AddUnit, DelUnit, AddObject, DelObject, AddRefloot, DelRefloot, AddItem, DelItem, AddEvent, DelEvent;
local AddQuester_VariedTexture, DelQuester_VariedTexture, AddQuestStart, DelQuestStart, AddQuestEnd, DelQuestEnd;
local AddLine, DelLine;
local AddExtra, DelExtra;
local UpdateQuests;
local AddConfilct, DelConfilct;
local UpdateQuestGivers;
local CalcQuestColor;
-- setting
local SetQuestStarterShown, SetQuestEnderShown;
local SetLimitItemStarter, SetLimitItemStarterNumCoords;
-- setup
local SetupCompleted;
-->
--> -- color
local COLOR3 = { };
local PALLET = { };
do
PALLET[1] = { 192, 192, 0, };
PALLET[2] = { 192, 0, 192, };
PALLET[3] = { 0, 192, 192, };
for color = 128, 0, -64 do
for index2 = 1, 3 do
for index = 1, 3 do
local color3 = PALLET[index];
if color3[index2] > 0 then
PALLET[#PALLET + 1] = {
index2 == 1 and color or color3[1],
index2 == 2 and color or color3[2],
index2 == 3 and color or color3[3],
};
end
end
end
end
PALLET[#PALLET + 1] = { 255, 0, 0, };
PALLET[#PALLET + 1] = { 0, 255, 0, };
PALLET[#PALLET + 1] = { 0, 0, 255, };
PALLET[#PALLET + 1] = { 255, 255, 0, };
PALLET[#PALLET + 1] = { 255, 0, 255, };
PALLET[#PALLET + 1] = { 0, 255, 255, };
PALLET[#PALLET + 1] = { 63, 63, 63, };
PALLET[#PALLET + 1] = { 191, 191, 191, };
for index = 1, #PALLET do
local color3 = PALLET[index];
color3[1] = color3[1] / 255;
color3[2] = color3[2] / 255;
color3[3] = color3[3] / 255;
end
for index = 1, #PALLET do
COLOR3[PALLET[index]] = 0;
end
end
function GetColor3()
local a = 99999;
local c = nil;
for color3, i in next, COLOR3 do
if i < a then
a = i;
c = color3;
end
end
if c == nil then
c = next(COLOR3);
end
COLOR3[c] = COLOR3[c] + 1;
return c;
end
function RelColor3(color3)
if COLOR3[color3] ~= nil then
COLOR3[color3] = COLOR3[color3] - 1;
end
end
local floor = floor;
function GetColor3NextIndex(index)
local num = #PALLET;
if index == nil then
index = (random() * 10000 * num) % (num - 1);
index = index - index % 1.0 + 1;
-- index = floor((random() * 10000 * num)) % (num - 1) + 1;
else
index = index + 1;
if index > num then
index = 1;
end
end
local color3 = PALLET[index];
COLOR3[color3] = COLOR3[color3] + 1;
return color3, index;
end
function ResetColor3()
for color3, _ in next, COLOR3 do
COLOR3[color3] = 0;
end
end
MT.GetColor3 = GetColor3;
MT.RelColor3 = RelColor3;
MT.GetColor3NextIndex = GetColor3NextIndex;
-->
--> -- uuid:{ 1type, 2id, 3color3(run-time), 4{ [quest] = { [line] = TEXTURE, }, }, 5TEXTURE, 6MANUAL_CHANGED_COLOR, }
--> -- TEXTURE = 0 for invalid value -- TEXTURE = -9999 for large pin -- TEXTURE = -9998 for normal pin
--> -- line: 'start', 'end', >=1:line_quest_leader, 'extra'
--> -- uuid 对应单位/对象类型,储存任务-行信息,对应META_COMMON表坐标设置一次即可
local UUID = { event = { }, item = { }, object = { }, quest = { }, unit = { }, };
function CoreAddUUID(_T, _id, _quest, _line, _val)
local uuid = UUID[_T][_id];
if uuid == nil then
uuid = { _T, _id, GetColor3(), { }, };
UUID[_T][_id] = uuid;
elseif uuid[3] == nil then
uuid[3] = GetColor3();
end
local ref = uuid[4][_quest];
if ref == nil then
ref = { [_line] = _val or 1, };
uuid[4][_quest] = ref;
else
ref[_line] = _val or 1;
end
return uuid;
end
function CoreSubUUID(_T, _id, _quest, _line, total_del)
local uuid = UUID[_T][_id];
if uuid ~= nil then
local ref = uuid[4][_quest];
if ref ~= nil then
local val = ref[_line];
if val ~= nil then
ref[_line] = nil;
if next(ref) == nil then
uuid[4][_quest] = nil;
end
if next(uuid[4]) == nil then
RelColor3(uuid[3]);
uuid[3] = nil;
if not total_del then
ref[_line] = 0;
uuid[4][_quest] = ref;
end
return uuid, true;
else
if not total_del then
ref[_line] = 0;
uuid[4][_quest] = ref;
end
return uuid, false;
end
else
if next(ref) == nil then
uuid[4][_quest] = nil;
end
if next(uuid[4]) == nil then
RelColor3(uuid[3]);
uuid[3] = nil;
return uuid, true;
else
return uuid, false;
end
end
else
if next(uuid[4]) == nil then
RelColor3(uuid[3]);
uuid[3] = nil;
return uuid, true;
else
return uuid, false;
end
end
end
return uuid;
end
function CoreGetUUID(_T, _id)
return UUID[_T][_id];
end
function CoreResetUUID()
wipe(UUID.event);
wipe(UUID.item);
wipe(UUID.object);
wipe(UUID.quest);
wipe(UUID.unit);
end
MT.CoreAddUUID = CoreAddUUID;
MT.CoreSubUUID = CoreSubUUID;
MT.CoreGetUUID = CoreGetUUID;
if VT.__is_dev then
VT.CORE_UUID = UUID;
end
-->
--> send data to ui
local COMMON_UUID_FLAG = { };
local LARGE_UUID_FLAG = { };
local VARIED_UUID_FLAG = { };
function GetVariedNodeTexture(texture_list)
local TEXTURE = 0;
for quest, list in next, texture_list do
for _, texture in next, list do
if texture > TEXTURE then
TEXTURE = texture;
end
end
end
return TEXTURE ~= 0 and TEXTURE or nil;
end
-- common_objective pin
function AddCommonNodes(_T, _id, _quest, _line, coords_table)
local uuid = CoreAddUUID(_T, _id, _quest, _line, -9998);
if COMMON_UUID_FLAG[uuid] == nil then
if coords_table ~= nil then
MT.MapAddCommonNodes(uuid, coords_table);
end
COMMON_UUID_FLAG[uuid] = coords_table;
end
end
function DelCommonNodes(_T, _id, _quest, _line, total_del)
local uuid, del = CoreSubUUID(_T, _id, _quest, _line, total_del);
if del == false then
del = true;
for _, ref in next, uuid[4] do
for line, val in next, ref do
if val == -9998 then
del = false;
break;
end
end
end
end
if del == true then
MT.MapDelCommonNodes(uuid);
COMMON_UUID_FLAG[uuid] = nil;
elseif del == false then
MT.MapUpdCommonNodes(uuid);
end
end
-- large_objective pin
function AddLargeNodes(_T, _id, _quest, _line, coords_table)
local uuid = CoreAddUUID(_T, _id, _quest, _line, -9999);
if LARGE_UUID_FLAG[uuid] == nil then
if coords_table ~= nil then
MT.MapAddLargeNodes(uuid, coords_table);
end
LARGE_UUID_FLAG[uuid] = coords_table;
end
end
function DelLargeNodes(_T, _id, _quest, _line, total_del)
local uuid, del = CoreSubUUID(_T, _id, _quest, _line, total_del);
if del == false then
del = true;
for _, ref in next, uuid[4] do
for line, val in next, ref do
if val == -9999 then
del = false;
break;
end
end
end
end
if del == true then
MT.MapDelLargeNodes(uuid);
LARGE_UUID_FLAG[uuid] = nil;
elseif del == false then
MT.MapUpdLargeNodes(uuid);
end
end
-- varied_objective pin
function AddVariedNodes(_T, _id, _quest, _line, coords_table, varied_texture)
local uuid = CoreAddUUID(_T, _id, _quest, _line, varied_texture);
local TEXTURE = GetVariedNodeTexture(uuid[4]);
if uuid[5] ~= TEXTURE then
uuid[5] = TEXTURE;
MT.MapAddVariedNodes(uuid, coords_table, VARIED_UUID_FLAG[uuid]);
VARIED_UUID_FLAG[uuid] = coords_table;
end
end
function DelVariedNodes(_T, _id, _quest, _line)
local uuid, del = CoreSubUUID(_T, _id, _quest, _line, true);
if del == true then
uuid[5] = nil;
if VARIED_UUID_FLAG[uuid] ~= nil then
MT.MapDelVariedNodes(uuid);
VARIED_UUID_FLAG[uuid] = nil;
end
elseif del == false then
local TEXTURE = GetVariedNodeTexture(uuid[4]);
if uuid[5] ~= TEXTURE then
uuid[5] = TEXTURE;
if VARIED_UUID_FLAG[uuid] ~= nil then
MT.MapAddVariedNodes(uuid, nil, true);
end
end
end
end
-->
function AddObjectLookup(oid)
local name = l10n.object[oid];
if name ~= nil then
local to = OBJ_LOOKUP["*"][name];
if to == nil then
OBJ_LOOKUP["*"][name] = { oid };
else
to[#to + 1] = oid;
end
local info = DataAgent.object[oid];
if info ~= nil and info.coords ~= nil then
local coords = info.coords;
for i = 1, #coords do
local map = coords[i][3];
OBJ_LOOKUP[map] = OBJ_LOOKUP[map] or { };
local to = OBJ_LOOKUP[map][name];
if to == nil then
OBJ_LOOKUP[map][name] = { oid };
else
to[#to + 1] = oid;
end
end
end
end
end
--> send quest data
function AddSpawn(quest, line, spawn, show_coords, showFriend)
if spawn.U ~= nil then
for unit, _ in next, spawn.U do
local large_pin = DataAgent.large_pin:Check(quest, 'unit', unit);
AddUnit(quest, line, unit, show_coords, large_pin, showFriend);
end
end
if spawn.O ~= nil then
for object, _ in next, spawn.O do
local large_pin = DataAgent.large_pin:Check(quest, 'object', object);
AddObject(quest, line, object, show_coords, large_pin);
end
end
if spawn.I ~= nil then
for item, num in next, spawn.I do
local large_pin = DataAgent.large_pin:Check(quest, 'item', item);
AddItem(quest, line, item, show_coords, large_pin);
end
end
end
function DelSpawn(quest, line, spawn, total_del)
if spawn.U ~= nil then
for unit, _ in next, spawn.U do
local large_pin = DataAgent.large_pin:Check(quest, 'unit', unit);
DelUnit(quest, line, unit, total_del, large_pin);
end
end
if spawn.O ~= nil then
for object, _ in next, spawn.O do
local large_pin = DataAgent.large_pin:Check(quest, 'object', object);
DelObject(quest, line, object, total_del, large_pin);
end
end
if spawn.I ~= nil then
for item, num in next, spawn.I do
local large_pin = DataAgent.large_pin:Check(quest, 'item', item);
DelItem(quest, line, item, total_del, large_pin);
end
end
end
function AddUnit(quest, line, uid, show_coords, large_pin, showFriend)
local info = DataAgent.unit[uid];
if info ~= nil then
local draw = true;
if showFriend ~= nil then
local isFriend = nil;
if info.fac == nil then
if info.facId ~= nil then
local _, _, standing_rank, _, _, val = GetFactionInfoByID(info.facId);
if val > 0 then
isFriend = true;
else -- if val <= -3000 then -- 冷淡不会招致主动攻击,敌对开始主动攻击
isFriend = false;
end
else
isFriend = false;
end
else
isFriend = VT.IsUnitFacFriend[info.fac];
end
if not showFriend ~= not isFriend then
draw = false;
end
end
if info.waypoints ~= nil then
large_pin = false;
end
if draw then
MT.PreloadCoords(info);
local coords = show_coords and (info.waypoints or info.coords) or nil;
if large_pin and info.waypoints == nil then
AddLargeNodes('unit', uid, quest, line, coords);
else
AddCommonNodes('unit', uid, quest, line, coords);
end
end
local spawn = info.spawn;
if spawn ~= nil then
AddSpawn(quest, line, spawn, show_coords, showFriend);
end
end
end
function DelUnit(quest, line, uid, total_del, large_pin)
local info = DataAgent.unit[uid];
if info ~= nil then
if info.waypoints ~= nil then
large_pin = false;
end
if large_pin then
DelLargeNodes('unit', uid, quest, line, total_del);
else
DelCommonNodes('unit', uid, quest, line, total_del);
end
local spawn = info.spawn;
if spawn ~= nil then
DelSpawn(quest, line, spawn, total_del);
end
end
end
function AddObject(quest, line, oid, show_coords, large_pin)
local info = DataAgent.object[oid];
if info ~= nil then
-- if show_coords then
MT.PreloadCoords(info);
local coords = show_coords and info.coords or nil;
if large_pin then
AddLargeNodes('object', oid, quest, line, coords);
else
AddCommonNodes('object', oid, quest, line, coords);
end
-- end
local spawn = info.spawn;
if spawn ~= nil then
AddSpawn(quest, line, spawn, show_coords);
end
end
AddObjectLookup(oid);
end
function DelObject(quest, line, oid, total_del, large_pin)
local info = DataAgent.object[oid];
if info ~= nil then
if large_pin then
DelLargeNodes('object', oid, quest, line, total_del);
else
DelCommonNodes('object', oid, quest, line, total_del);
end
local spawn = info.spawn;
if spawn ~= nil then
DelSpawn(quest, line, spawn, total_del);
end
end
end
function AddRefloot(quest, line, rid, show_coords, large_pin)
local info = DataAgent.refloot[rid];
if info ~= nil then
if info.U ~= nil then
for uid, _ in next, info.U do
AddUnit(quest, line, uid, show_coords, large_pin, nil);
end
end
if info.O ~= nil then
for oid, _ in next, info.O do
AddObject(quest, line, oid, show_coords, large_pin);
end
end
end
end
function DelRefloot(quest, line, rid, total_del, large_pin)
local info = DataAgent.refloot[rid];
if info ~= nil then
if info.U ~= nil then
for uid, _ in next, info.U do
DelUnit(quest, line, uid, total_del, large_pin);
end
end
if info.O ~= nil then
for oid, _ in next, info.O do
DelObject(quest, line, oid, total_del, large_pin);
end
end
end
end
function AddItem(quest, line, iid, show_coords, large_pin)
if DataAgent.blacklist_item[iid] ~= nil then
return;
end
local info = DataAgent.item[iid];
if info ~= nil then
if info.U ~= nil then
for uid, rate in next, info.U do
if rate >= VT.SETTING.min_rate then
AddUnit(quest, line, uid, show_coords, large_pin, nil);
end
end
end
if info.O ~= nil then
for oid, rate in next, info.O do
if rate >= VT.SETTING.min_rate then
AddObject(quest, line, oid, show_coords, large_pin);
end
end
end
if info.R ~= nil then
for rid, rate in next, info.R do
if rate >= VT.SETTING.min_rate then
AddRefloot(quest, line, rid, show_coords, large_pin);
end
end
end
if info.V ~= nil then
for vid, _ in next, info.V do
AddUnit(quest, line, vid, show_coords, large_pin);
end
end
if info.I ~= nil then
for iid2, _ in next, info.I do
local large_pin = DataAgent.large_pin:Check(quest, 'item', iid2);
AddItem(quest, line, iid2, show_coords, large_pin);
end
end
end
end
function DelItem(quest, line, iid, total_del, large_pin)
if DataAgent.blacklist_item[iid] ~= nil then
return;
end
local info = DataAgent.item[iid];
if info ~= nil then
if info.U ~= nil then
for uid, rate in next, info.U do
DelUnit(quest, line, uid, total_del, large_pin);
end
end
if info.O ~= nil then
for oid, rate in next, info.O do
DelObject(quest, line, oid, total_del, large_pin);
end
end
if info.R ~= nil then
for rid, _ in next, info.R do
DelRefloot(quest, line, rid, total_del, large_pin);
end
end
if info.V ~= nil then
for vid, _ in next, info.V do
DelUnit(quest, line, vid, total_del, large_pin);
end
end
if info.I ~= nil then
for iid2, _ in next, info.I do
local large_pin = DataAgent.large_pin:Check(quest, 'item', iid2);
DelItem(quest, line, iid2, total_del, large_pin);
end
end
end
end
function AddEvent(quest, line, eid, show_coords, large_pin)
local info = DataAgent.event[eid];
if info ~= nil then
MT.PreloadCoords(info);
local coords = show_coords and info.coords or nil;
if large_pin then
AddLargeNodes('event', eid, quest, line, coords);
else
AddCommonNodes('event', eid, quest, line, coords);
end
local spawn = info.spawn;
if spawn ~= nil then
AddSpawn(quest, line, spawn, show_coords);
end
end
end
function DelEvent(quest, line, eid, total_del, large_pin)
local info = DataAgent.event[eid];
if info ~= nil then
if large_pin then
DelLargeNodes('event', eid, quest, line, total_del);
else
DelCommonNodes('event', eid, quest, line, total_del);
end
local spawn = info.spawn;
if spawn ~= nil then
DelSpawn(quest, line, spawn, total_del);
end
end
end
--
function AddQuester_VariedTexture(quest, info, which, TEXTURE)
if info ~= nil then
local O = info.O;
if O ~= nil then
for index = 1, #O do
local oid = O[index];
local info = DataAgent.object[oid];
if info ~= nil then
MT.PreloadCoords(info);
local coords = info.coords;
AddVariedNodes('object', oid, quest, which, coords, TEXTURE);
end
AddObjectLookup(oid);
end
end
local U = info.U;
if U ~= nil then
for index = 1, #U do
local uid = U[index];
local info = DataAgent.unit[uid];
if info ~= nil then
MT.PreloadCoords(info);
local coords = info.coords;
AddVariedNodes('unit', uid, quest, which, coords, TEXTURE);
end
end
end
local I = info.I;
if I ~= nil then
for index = 1, #I do
local info = DataAgent.item[I[index]];
if info ~= nil then
local O = info.O;
if O ~= nil then
for oid, rate in next, O do
if rate > 10 or not VT.SETTING.limit_item_starter_drop then
local info = DataAgent.object[oid];
if info ~= nil then
MT.PreloadCoords(info);
local wcoords = info.wcoords;
if wcoords == nil or #wcoords <= 5 or not VT.SETTING.limit_item_starter_drop_num_coords then
AddVariedNodes('object', oid, quest, which, info.coords, TEXTURE);
else
DelVariedNodes('object', oid, quest, which);
end
end
AddObjectLookup(oid);
else
DelVariedNodes('object', oid, quest, which);
end
end
end
local U = info.U;
if U ~= nil then
for uid, rate in next, U do
if rate > 10 or not VT.SETTING.limit_item_starter_drop then
local info = DataAgent.unit[uid];
if info ~= nil then
MT.PreloadCoords(info);
local wcoords = info.wcoords;
if wcoords == nil or #wcoords <= 5 or not VT.SETTING.limit_item_starter_drop_num_coords then
AddVariedNodes('unit', uid, quest, which, info.coords, TEXTURE);
else
DelVariedNodes('unit', uid, quest, which);
end
end
else
DelVariedNodes('unit', uid, quest, which);
end
end
end
local V = info.V;
if V ~= nil then
for uid, val in next, V do
local info = DataAgent.unit[uid];
if info ~= nil then
MT.PreloadCoords(info);
local wcoords = info.wcoords;
if wcoords == nil or #wcoords <= 5 or not VT.SETTING.limit_item_starter_drop_num_coords then
AddVariedNodes('unit', uid, quest, which, info.coords, TEXTURE);
else
DelVariedNodes('unit', uid, quest, which);
end
end
end
end
end
end
end
end
end
function DelQuester_VariedTexture(quest, info, which)
if info ~= nil then
local O = info.O;
if O ~= nil then
for index = 1, #O do
DelVariedNodes('object', O[index], quest, which);
end
end
local U = info.U;
if U ~= nil then
for index = 1, #U do
DelVariedNodes('unit', U[index], quest, which);
end
end
local I = info.I;
if I ~= nil then
for index = 1, #I do
local info = DataAgent.item[I[index]];
if info ~= nil then
local O = info.O;
if O ~= nil then
for oid, rate in next, O do
DelVariedNodes('object', oid, quest, which);
end
end
local U = info.U;
if U ~= nil then
for uid, rate in next, U do
DelVariedNodes('unit', uid, quest, which);
end
end
local V = info.V;
if V ~= nil then
for uid, val in next, V do
DelVariedNodes('unit', uid, quest, which);
end
end
end
end
end
end
end
function AddQuestStart(quest, info, TEXTURE)
AddQuester_VariedTexture(quest, info.start, 'start', TEXTURE or MT.GetQuestStartTexture(info));
end
function DelQuestStart(quest, info)
DelQuester_VariedTexture(quest, info.start, 'start');
end
function AddQuestEnd(quest, info, TEXTURE)
AddQuester_VariedTexture(quest, info["end"], 'end', TEXTURE);
end
function DelQuestEnd(quest, info)
DelQuester_VariedTexture(quest, info["end"], 'end');
end
-->
--> process quest log
function AddLine(quest_id, index, objective_type, _id, finished)
if objective_type == 'monster' then
local large_pin = DataAgent.large_pin:Check(quest_id, 'unit', _id);
AddUnit(quest_id, index, _id, not finished, large_pin, nil);
return large_pin;
elseif objective_type == 'item' then
local large_pin = DataAgent.large_pin:Check(quest_id, 'item', _id);
AddItem(quest_id, index, _id, not finished, large_pin);
return large_pin;
elseif objective_type == 'object' then
AddObjectLookup(_id);
local large_pin = DataAgent.large_pin:Check(quest_id, 'object', _id);
AddObject(quest_id, index, _id, not finished, large_pin);
return large_pin;
elseif objective_type == 'event' or objective_type == 'log' then
AddEvent(quest_id, index, _id, not finished, true);
return true;
elseif objective_type == 'reputation' then
elseif objective_type == 'player' or objective_type == 'progressbar' then
else
MT.Debug('comm_objective_type', quest_id, finished, objective_type);
end
return nil;
end
function DelLine(quest_id, index, objective_type, objective_id, total_del, large_pin)
local info = DataAgent.quest[quest_id];
local obj = info.obj;
if obj then
if objective_type == 'monster' then
DelUnit(quest_id, index, objective_id, total_del, large_pin);
elseif objective_type == 'item' then
DelItem(quest_id, index, objective_id, total_del, large_pin);
elseif objective_type == 'object' then
DelObject(quest_id, index, objective_id, total_del, large_pin);
elseif objective_type == 'event' or objective_type == 'log' then
local events = obj.E;
if events ~= nil then
for i = 1, #events do
local event = events[i];
DelEvent(quest_id, index, event, total_del, true);
end
end
elseif objective_type == 'reputation' then
elseif objective_type == 'player' or objective_type == 'progressbar' then
else
MT.Debug('objective_type', quest_id, index, objective_type, objective_id);
end
else
MT.Debug('obj', quest_id, index, objective_type, objective_id)
end
end
function AddExtra(quest_id, extra, text, completed)
if extra.U ~= nil then
for uid, check in next, extra.U do
local large_pin = DataAgent.large_pin:Check(quest_id, 'unit', uid);
if check == completed or check == 'always' then
AddUnit(quest_id, 'extra', uid, true, large_pin);
else
DelUnit(quest_id, 'extra', uid, false, large_pin);
end
end
end
if extra.I ~= nil then
for iid, check in next, extra.I do
local large_pin = DataAgent.large_pin:Check(quest_id, 'unit', iid);
if check == completed or check == 'always' then
AddItem(quest_id, 'extra', iid, true, large_pin);
else
DelItem(quest_id, 'extra', iid, false, large_pin);
end
end
end
if extra.O ~= nil then
for oid, check in next, extra.O do
AddObjectLookup(oid);
local large_pin = DataAgent.large_pin:Check(quest_id, 'object', oid);
if check == completed or check == 'always' then
AddObject(quest_id, 'extra', oid, true, large_pin);
else
DelObject(quest_id, 'extra', oid, false, large_pin);
end
end
end
if extra.E ~= nil then
for eid, check in next, extra.E do
if check == completed or check == 'always' then
AddEvent(quest_id, 'extra', eid, true, true);
else
DelEvent(quest_id, 'extra', eid, false, true);
end
end
end
end
function DelExtra(quest_id, extra)
if extra.U ~= nil then
for uid, check in next, extra.U do
local large_pin = DataAgent.large_pin:Check(quest_id, 'unit', uid);
DelUnit(quest_id, 'extra', uid, true, large_pin);
end
end
if extra.I ~= nil then
for iid, check in next, extra.I do
local large_pin = DataAgent.large_pin:Check(quest_id, 'unit', iid);
DelItem(quest_id, 'extra', iid, true, large_pin);
end
end
if extra.O ~= nil then
for oid, check in next, extra.O do
local large_pin = DataAgent.large_pin:Check(quest_id, 'object', oid);
DelObject(quest_id, 'extra', oid, true, large_pin);
end
end
if extra.E ~= nil then
for eid, check in next, extra.E do
DelEvent(quest_id, 'extra', eid, true, true);
end
end
end
function AddConfilct(quest_id)
-- QUESTS_CONFILCTED
local info = DataAgent.quest[quest_id];
if info ~= nil then
local _excl = info.excl;
if _excl ~= nil then
for index = 1, #_excl do
local ex = _excl[index];
if QUESTS_CONFILCTED[ex] == nil then
QUESTS_CONFILCTED[ex] = true;
AddConfilct(ex);
end
end
end
local _next = info.next;
if _next ~= nil then
if QUESTS_CONFILCTED[_next] == nil then
QUESTS_CONFILCTED[_next] = true;
AddConfilct(_next);
end
end
-- local _pres = info.preSingle;
-- if _pres ~= nil then
-- for index = 1, #_pres do
-- local ps = _pres[index];
-- if QUESTS_CONFILCTED[ps] == nil then
-- QUESTS_CONFILCTED[ps] = true;
-- AddConfilct(ps);
-- end
-- end
-- end
-- local _preg = info.preGroup;
-- if _preg ~= nil then
-- for index = 1, #_preg do
-- local pg = _preg[index];
-- if QUESTS_CONFILCTED[pg] == nil then
-- QUESTS_CONFILCTED[pg] = true;
-- AddConfilct(pg);
-- end
-- end
-- end
end
end
function DelConfilct(quest_id)
end
function UpdateQuests()
local _, num = GetNumQuestLogEntries();
local quest_changed = false;
local need_re_draw = false;
for quest_id, meta in next, META do
meta.flag = -1;
end
if num > 0 then
for index = 1, 40 do
local title, level, group, header, collapsed, completed, frequency, quest_id = GetQuestLogTitle(index);
--> completed: 1 = completed, nil = not completed, -1 = failed >> 0 = not completed
if not header and quest_id then
local info = DataAgent.quest[quest_id];
if info ~= nil then
local num_lines = GetNumQuestLeaderBoards(index);
if completed ~= -1 and num_lines == 0 then
completed = 1;
elseif completed ~= 1 and completed ~= -1 and completed ~= 0 then
completed = 0;