-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.lua
More file actions
1351 lines (1248 loc) · 50.9 KB
/
Copy pathMain.lua
File metadata and controls
1351 lines (1248 loc) · 50.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
------------------------------------------------------
-- Main.lua
------------------------------------------------------
local addon, _ = ...
local version = GetAddOnMetadata(addon, "Version");
-- make sure classic version...
local classicOnly = select(4, GetBuildInfo()) < 20000
if (not classicOnly) then
print("|cffa330c9"..addon.." "..version..": Classic Version Only!|r");
end;
local CALENDAR_FILTER_DARKMOON = _G.CALENDAR_FILTER_DARKMOON;
local ITEM_BIND_ON_PICKUP = _G.ITEM_BIND_ON_PICKUP;
local ITEM_BIND_TO_BNETACCOUNT = _G.ITEM_BIND_TO_BNETACCOUNT;
local ITEM_BIND_TO_ACCOUNT = _G.ITEM_BIND_TO_ACCOUNT;
local MERCHANT_ITEMS_PER_PAGE = _G.MERCHANT_ITEMS_PER_PAGE;
local UNKNOWN = _G.UNKNOWN;
local defaultsDB = {
CoinFormat = FT.ICON, --< Icon, Short, Long
NoDisplay = false,
NoSound = false,
Displacement = -1,
};
function initiateDB(a,b)
if type(a) ~= "table" then return {}; end;
if type(b) ~= "table" then b = {}; end;
for k, v in pairs(a) do
if type(v) == "table" then
b[k] = initiateDB(v, b[k]);
elseif type(b[k]) ~= type(v) then
b[k] = v;
end;
end;
return b;
end;
function cleanNewInfo()
if (FT_NewItemInfo) then
FT_NewItemInfo = wipe(FT_NewItemInfo);
else
FT_NewItemInfo = {};
end;
end;
local FT_VersionFrame = CreateFrame("FRAME");
FT_VersionFrame:RegisterEvent("ADDON_LOADED");
function FT_VersionFrame:OnEvent(event, arg1)
if event == "ADDON_LOADED" and arg1 == addon then
FleecingTipDB = initiateDB(defaultsDB, FleecingTipDB)
if FleecingTipDB.Version == nil then
cleanNewInfo();
FleecingTipDB.Version = version;
elseif FleecingTipDB.Version ~= version then
cleanNewInfo();
FleecingTipDB.Version = version;
end;
FT_VersionFrame:UnregisterEvent("ADDON_LOADED");
if ( classicOnly ) then
FTUtils.PrintOnce(addon.." "..FTUtils.LightYellow(version)..": addon Loaded.", 60);
end;
end;
end;
FT_VersionFrame:SetScript("OnEvent", FT_VersionFrame.OnEvent);
function FT_HookTooltip(frame)
if (frame:GetScript("OnTooltipSetItem")) then
frame:HookScript("OnTooltipSetItem", FT_OnTooltipSetItem);
else
frame:SetScript("OnTooltipSetItem", FT_OnTooltipSetItem);
end;
end;
--[[ check active event at present time...
function CheckEventActive(worldEvent)
if (not worldEvent) then return ""; end;
-- Darkmoon Faire Only
if (worldEvent == FT.DARKMOON_FAIRE) then
local e;
local date = C_Calendar.GetDate();
local today = date.monthDay;
local numDayEvents = C_Calendar.GetNumDayEvents(0,today);
for e = 1,numDayEvents do
local event = C_Calendar.GetDayEvent(0, today, e);
if event.title == CALENDAR_FILTER_DARKMOON then
return "|cff00ff00"..FT.ACTIVE.."|r";
end;
end;
return "|cffff0000"..FT.NO_ACTIVE.."|r";
end;
local WEList = {
-- Children's Week
-- [FT.HOLIDAY_EVENT_CW] = { 235444, 235445, 235446 },
-- Brewfest
[FT.HOLIDAY_EVENT_Brew] = { 0, 0, 0 },
-- Hallow's End
[FT.HOLIDAY_EVENT_HE] = { 235460, 235461, 235462 },
-- Love is in the Air
[FT.HOLIDAY_EVENT_LiitA] = { 0, 0, 0 },
-- Lunar Festival
[FT.HOLIDAY_EVENT_LF] = { 235469, 235470, 235471 },
-- Harvest Festival
[FT.HOLIDAY_EVENT_HF] = { 235472, 235473, 235474 },
-- Noblegarden
[FT.HOLIDAY_EVENT_Noble] = { 235475, 235476, 235477 },
-- Midsummer Fire Festival
[FT.HOLIDAY_EVENT_MFF] = { 0, 0, 0 },
};
local calendar = C_Calendar.GetDate();
local month, day, year = calendar.month, calendar.monthDay, calendar.year;
local monthInfo = C_Calendar.GetMonthInfo();
local curMonth, curYear = monthInfo.month, monthInfo.year;
local monthOffset = -12 * (curYear - year) + month - curMonth;
local numEvents = C_Calendar.GetNumDayEvents(monthOffset, day);
-- print("numEvents = "..tostring(numEvents));
-- local event = C_Calendar.GetDayEvent(monthOffset, day, 1);
-- print("event.iconTexture = "..tostring(event.iconTexture));
-- print("event.sequenceType = "..tostring(event.sequenceType));
-- print("event.title = "..tostring(event.title));
-- local event2 = C_Calendar.GetHolidayInfo(monthOffset, day, 1);
-- print("event2.name = "..tostring(event2.name));
-- print("event2.texture = "..tostring(event2.texture));
for i=1, numEvents do
local event = C_Calendar.GetDayEvent(monthOffset, day, i);
-- print("event.iconTexture = "..tostring(event.iconTexture));
-- event.sequenceType = "ONGOING";
-- print("event.sequenceType = "..tostring(event.sequenceType));
local listEvent = WEList[worldEvent];
-- listEvent = WEList[FT.HOLIDAY_EVENT_Noble];
if (listEvent) then
-- print("YES!!!");
local okay = nil;
for w=1, table.getn(listEvent) do
-- print("listEvent[w] = "..tostring(listEvent[w]));
local eventFound = event.iconTexture;
if (listEvent[w] == eventFound) then okay = true; end;
end;
if (okay) then
-- print("OKAY!!!");
if (event.sequenceType == "ONGOING") then
return "|cff00ff00"..FT.ACTIVE.."|r";
else
local hour = GetGameTime();
if event.sequenceType == "END" and hour <= event.endTime.hour or
event.sequenceType == "START" and hour >= event.startTime.hour then
return "|cff00ff00"..FT.ACTIVE.."|r";
end;
end;
else
return "|cffff0000"..FT.NO_ACTIVE.."|r";
end;
else
return "|cffff0000"..UNKNOWN.."|r";
end;
end;
return "---";
end;
]]--
-- return the real zone name for BC or WoD...
function FT_RealMapName(mapID)
if (not mapID) then return nil; end;
-- some reason no mapID for instances!
local ClassicDungeons = {
[33] = "Shadowfang Keep",
[34] = "The Stockade",
[36] = "The Deadmines",
[43] = "Wailing Caverns",
[47] = "Razorfen Kraul",
[48] = "Blackfathom Deeps",
[70] = "Uldaman",
[90] = "Gnomeregan",
[109] = "The Temple of Atal'Hakkar",
[129] = "Razorfen Downs",
[209] = "Zul'Farrak",
[229] = "Blackrock Spire",
[230] = "Blackrock Depths",
[249] = "Onyxia's Lair",
[289] = "Scholomance",
[309] = "Zul'Gurub",
[329] = "Stratholme",
[349] = "Maraudon",
[389] = "Ragefire Chasm",
[407] = "Darkmoon Faire",
[409] = "Molten Core",
[429] = "Dire Maul",
[469] = "Blackwing Lair",
[509] = "Ruins of Ahn'Qiraj",
[531] = "Temple of Ahn'Qiraj",
[533] = "Naxxramas",
[1001] = "Scarlet Halls",
[1004] = "Scarlet Monastery",
[1007] = "Scholomance",
};
local mapName = ClassicDungeons[mapID];
if (not mapName) then
local mapDetails = C_Map.GetMapInfo(mapID);
mapName = mapDetails.name;
end;
return mapName;
end;
function FT_GetVendorLocation(faction,npc)
if (not faction) or (not npc) then return nil; end;
local locationText = "";
local vendorCoords = FT_VendorLocations[faction][npc];
if ( vendorCoords ~= nil) then
local uiD = vendorCoords[1];
if (not uiD) then return locationText; end;
if (uiD > 0) then
locationText = FT_RealMapName(uiD);
end;
end;
return locationText;
end;
function FT_GetVendorCoordinates(faction,npc)
if (not faction) or (not npc) then return nil; end;
local tex = nil;
local vendorCoords = FT_VendorLocations[faction][npc];
-- print("faction, npc, vendorCoords = "..tostring(faction)..", "..tostring(npc)..", "..tostring(vendorCoords[1]));
if ( vendorCoords ~= nil) then
local Ct = "";
local Rt = FT_VendorLocations[faction][npc][2] or "";
if (string.len(Rt) == 4) then Rt = string.format("%.1f|r",tonumber(Rt)); end;
local Lt = FT_VendorLocations[faction][npc][3] or "";
if (string.len(Lt) == 4) then Lt = string.format("%.1f|r",tonumber(Lt)); end;
if (FT_VendorLocations[faction][npc][3]) then Ct = ", "; end;
if (FT_VendorLocations[faction][npc][2]) then
tex = " ["..Rt..Ct..Lt.."]";
else
tex = "";
end;
end;
return tex;
end;
function ERROR_ItemInfo(id,npc)
local iN, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = GetItemInfo(id) or "";
FTUtils.PrintOnce(FTUtils.Red(addon.." "..version.." error: ").."Can't find any information on item ["..tostring(id).."] / '"..iN.."' :: Vendor:'"..npc.."' ? ".."Please report this on the website.", 60);
end;
function ERROR_VendorInformation(npc)
FTUtils.PrintOnce(FTUtils.Red(addon.." "..version.." error: ").."Can't find any information on '"..npc.."' ? ".."Please report this on the website.", 60);
end;
function ERROR_VendorLocation(npc)
FTUtils.PrintOnce(FTUtils.Red(addon.." "..version.." error: ").."Can't find location for '"..npc.."' ? ".."Please report this on the website.", 60);
end;
--function ERROR_VendorCoordinates(npc)
-- FTUtils.PrintOnce(FTUtils.Red(addon.." "..version.." error: ").."'"..npc.."' coordinates coming soon!", 60);
--end
function FT_FindVendorLocation(faction, npc)
local vendorFound = FT_VendorLocations[faction][npc];
if (vendorFound == nil) then
vendorFound = FT_VendorLocations["Neutral"][npc];
if (vendorFound) then
faction = "Neutral";
else
return faction, nil;
end;
end;
return faction, vendorFound;
end;
function FT_OnTooltipSetItem(self)
if ( not classicOnly ) then return; end;
if (MerchantFrame:IsVisible()) then
for buttonIndex = 1, MERCHANT_ITEMS_PER_PAGE do
local button = _G["MerchantItem"..buttonIndex.."ItemButton"];
if (self:IsOwned(button)) then return; end;
end;
end;
local name, link = self:GetItem();
if (not link) then return; end;
-- workaround for OnTooltipSetItem being called twice for recipes
local _, _, _, _, _, itemType, _, _, _, _, _, _, _, _, _, _, _ = GetItemInfo(link);
if (itemType == FT.RECIPE and self.lastLink ~= link) then
for i = 1, self:NumLines() do
local line = _G[self:GetName().."TextLeft"..i];
local text = line:GetText();
if (text and string.sub(text, 1, 1) == "\n") then
self.lastLink = link;
return;
end;
end;
end;
self.lastLink = nil;
if (link) then
self:AddLine(" ");
local _, _, itemID = string.find(link, "item:(%d+)");
itemID = tonumber(itemID);
-- itemID = 3736 --#TESTING#--
local newItem = false;
if (FT_NewItemInfo[itemID]) and (not FT_ItemInfo[itemID])then
newItem = true;
end;
if (newItem) then
local faction = UnitFactionGroup("player");
local newInspect = FT_NewItemInfo[itemID][faction];
local name = newInspect.vendor;
local location = newInspect.location;
local cost = FTUtils.GSC(newInspect.cost);
local colour = FTUtils.FONT_COLOR;
self:AddLine(string.format(FT.NEW_ITEM, name, location, cost), colour.r, colour.g, colour.b);
return false;
end;
if (not FleecingTipDB.NoDisplay) and (not FT_ItemBlacklist(itemID)) and (FT_ItemInfo[itemID]) and (not newItem)then
local myFaction = UnitFactionGroup("player");
local itemInfo = FT_VendorInfo[myFaction][itemID];
if (not itemInfo) then
itemInfo = FT_VendorInfo["Neutral"][itemID];
if (not itemInfo) then
return false;
end;
end;
local numVendors = 0;
local soldBy = itemInfo;
if ( itemInfo.vendors ) then
soldBy = itemInfo.vendors;
numVendors = table.getn(soldBy)
else
numVendors = table.getn(soldBy)
end;
if ( FT_VendorInfo[myFaction][itemID] ) and ( FT_VendorInfo["Neutral"][itemID] ) then
soldBy = FTTable.Merge(FT_VendorInfo[myFaction][itemID], FT_VendorInfo["Neutral"][itemID]);
if ( FT_VendorInfo[myFaction][itemID].vendors ) and ( FT_VendorInfo["Neutral"][itemID].vendors ) then
soldBy = FTTable.Merge(FT_VendorInfo[myFaction][itemID].vendors, FT_VendorInfo["Neutral"][itemID].vendors);
numVendors = table.getn(soldBy)
end;
end;
local numCost = 0;
local costBy = false;
if ( itemInfo.cost ) then
costBy = itemInfo.cost;
numCost = table.getn(costBy);
end;
if ( FT_VendorInfo[myFaction][itemID] ) and ( FT_VendorInfo["Neutral"][itemID] ) then
if ( FT_VendorInfo[myFaction][itemID].cost ) and ( FT_VendorInfo["Neutral"][itemID].cost ) then
costBy = FTTable.Merge(FT_VendorInfo[myFaction][itemID].cost, FT_VendorInfo["Neutral"][itemID].cost);
numCost = table.getn(costBy);
end;
end;
-- print("myFaction = "..tostring(myFaction));
-- print("itemID = "..tostring(itemID));
-- print("numVendors = "..tostring(numVendors));
-- print("numCost = "..tostring(numCost));
local itemInspect = FT_ItemInfo[itemID];
local intro = FT.SOLD_BY
local color = FTUtils.FONT_COLOR;
local note = itemInspect.note or "";
if (itemInspect.note ~= nil) then
color = FT.SPECIAL_VENDOR_COLOR;
end;
if (itemInspect.drop ~= nil) then
color = FT.DROP_COLOR;
intro = FT.DROPPED_BY;
end;
if (itemInspect.quest) or (itemInspect.fished) then
color = FT.QUEST_COLOR;
intro = FT.OPTAINABLE_BY;
end;
if (itemInspect.craft ~= nil) then
color = FT.PATTERN_COLOR;
intro = FT.MADE_BY;
end;
if (itemInspect.mobs ~= nil) then
intro = FT.DROPPED_BY;
end;
if (itemInspect.useless ~= nil) then
color = FT.USELESS_COLOR;
end;
if (itemInspect.ap ~= nil) then
note = string.format(FT.AVERAGE_PRICE, FTUtils.GSC(itemInspect.ap));
end;
-- print("myFaction, intro, color, note, worldevent, profession = "..tostring(myFaction)..", "..tostring(intro)..", "..tostring(color)..", "..tostring(note)..", "..tostring(worldevent)..", "..tostring(profession) );
local dropfound = FT_ItemInfo[itemID].drop or nil;
if (dropfound) then myFaction = "Drops"; end;
local mobDrops = FT_ItemInfo[itemID].mobs or nil;
if (numVendors > 1) then
local num = 1;
self:AddLine(intro..":", color.r, color.g, color.b);
for i, aVendor in pairs(soldBy) do
local locFaction, locVendor = FT_FindVendorLocation(myFaction,aVendor)
if (locVendor ~= nil) or (profession and itemInfo.vendors) or (dropfound) then
local vendorName = FT[aVendor] or aVendor;
local vendorLocation = FT_GetVendorLocation(locFaction,aVendor);
local vendorCoordinates = FT_GetVendorCoordinates(locFaction,aVendor);
local vendorCost = "";
if ( numCost > 1 ) and ( not FT_ItemInfo[itemID].ap ) then
vendorCost = costBy[num];
vendorCost = FT.COST_SPACE..FTUtils.GSC(vendorCost);
num = num + 1;
end;
if (dropfound) then
vendorLocation = FT_GetVendorLocation("Drops",vendorName) or "";
vendorCoordinates = FT_GetVendorCoordinates("Drops",vendorName) or "";
if (FT_VendorLocations["Drops"][vendorName][4] ~= nil) then
local spec = FT_VendorLocations["Drops"][vendorName][4];
vendorName = vendorName.." ("..spec..")";
end;
end;
if (vendorLocation) ~= nil then
self:AddDoubleLine(string.format(FT.VENDOR_LOCATION_FORMAT, vendorName, vendorLocation, vendorCoordinates, vendorCost), " ", color.r, color.g, color.b, nil, nil, nil);
else
self:AddLine(vendorName..vendorCost, color.r, color.g, color.b);
-- if (not profession) then
-- ERROR_VendorCoordinates(aVendor);
-- end;
end;
else
ERROR_VendorInformation(aVendor);
if (aVendor == numVendors) then
return false;
end;
end;
end;
elseif (numVendors == 1 and not itemInfo.boe) then
local locFaction, locVendor = FT_FindVendorLocation(myFaction,soldBy[1]);
if (locVendor ~= nil) or (profession and itemInfo.vendors) or (dropfound) then
local vendorName = FT[soldBy[1]] or soldBy[1];
local vendorLocation = FT_GetVendorLocation(locFaction,aVendor);
local vendorCoordinates = FT_GetVendorCoordinates(locFaction,aVendor);
local vendorCost = "";
if ( numCost == 1 ) and ( not FT_ItemInfo[itemID].ap ) then
vendorCost = costBy[1];
vendorCost = FT.COST_SPACE..FTUtils.GSC(vendorCost);
end;
if (dropfound) then
vendorLocation = FT_GetVendorLocation("Drops",vendorName) or "";
vendorCoordinates = FT_GetVendorCoordinates("Drops",vendorName) or "";
if (FT_VendorLocations["Drops"][vendorName][4] ~= nil) then
local spec = FT_VendorLocations["Drops"][vendorName][4];
vendorName = vendorName.." ("..spec..")";
end;
end;
if (itemInspect.craft) then
vendorLocation = FT_ItemInfo[itemID].craft.prof or "";
vendorLocation = vendorLocation.." "..string.format(FT.SKILL_LEVEL_REQUIRED, FT_ItemInfo[itemID].craft.sk);
end;
if (mobDrops) then
vendorLocation = string.format(FT.LEVEL_DROP, FT_ItemInfo[itemID].mobs or "");
end;
if (itemInspect.quest) then
local questFaction = locFaction;
if (FT_VendorInfo["Neutral"][itemID]) then
questFaction = "Neutral";
end;
vendorLocation = FT_FactionQuest[questFaction][itemID];
local questName = itemInspect.npc;
local questLocation = FT_GetVendorLocation(questFaction,questName);
local questCoordinates = FT_GetVendorCoordinates(questFaction,questName);
note = questName..", "..questLocation..questCoordinates;
end;
if (vendorLocation ~= nil) and (vendorName ~= "Useless") then
if (not vendorCoordinates) then
self:AddDoubleLine(intro.." "..vendorName..": "..vendorLocation..vendorCost, " ", color.r, color.g, color.b, nil, nil, nil);
else
self:AddLine(intro..":", color.r, color.g, color.b);
self:AddDoubleLine(string.format(FT.VENDOR_LOCATION_FORMAT, vendorName, vendorLocation, vendorCoordinates, vendorCost), " ", color.r, color.g, color.b, nil, nil, nil);
end;
else
if (vendorName == "Useless") then
self:AddLine(FT.ITEM_WARNING, color.r, color.g, color.b);
else
self:AddLine(intro.." "..vendorName..vendorCost, color.r, color.g, color.b);
end;
end;
else
ERROR_VendorInformation(vendors[1]);
return false;
end;
else
local found = false;
for _, faction in pairs({"Alliance", "Horde", "Neutral"}) do
if (FT_VendorInfo[faction][itemID]) then
found = true;
break; -- get out quick! :)
end;
end;
if (not found) then
local link, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = GetItemInfo(itemID) or "";
FTUtils.PrintOnce(FTUtils.Red(addon.." "..version.." error: ").."'"..link.."'["..itemID.."] is listed but has no vendors.", 60);
FTUtils.PrintOnce("Please report this on the mod website.", 60);
return false;
end;
end;
if (note ~= nil) then
-- self:AddLine(note, 1.0, 0.5, 0.25);
self:AddLine(note, color.r, color.g, color.b);
end;
FTUtils.PlaySound(itemID, 30);
return true;
end;
-- FactionFriend also shows tooltips for this stuff; if it's present, let it take over
-- if (FFF_Config and not FFF_Config.NoTooltip) then return; end;
end;
end;
function FT_OnEvent(self, event, arg1)
FT_ScanMerchant();
end;
function FT_OnLoad(self)
-- Register Slash Commands
SLASH_FLEECINGTIP1 = "/fleecingtip";
SLASH_FLEECINGTIP2 = "/ft";
SlashCmdList["FLEECINGTIP"] = function(msg)
FT_ChatCommandHandler(msg);
-- FT_DisabledChatCommandHandler(msg);
end;
-- Register for Events
self:RegisterEvent("MERCHANT_SHOW");
self:RegisterEvent("MERCHANT_UPDATE");
FT_HookTooltip(GameTooltip);
FT_HookTooltip(ItemRefTooltip);
end;
function FT_ChatCommandHandler(msg)
-- Print Help
if ( msg == "help" ) or ( msg == "" ) then
FTUtils.Print(addon.." "..version..":");
FTUtils.Print("/fleecingtip (or /ft)");
FTUtils.Print("- "..FTUtils.Hilite("help").." - Display this help list.");
FTUtils.Print("- "..FTUtils.Hilite("[item link]").." - Show info for an item in the chat window.");
FTUtils.Print("- "..FTUtils.Hilite("status").." - Check current settings.");
FTUtils.Print("- "..FTUtils.Hilite("money icon").." | "..FTUtils.Hilite("short").." | "..FTUtils.Hilite("long").." - Money format display.");
FTUtils.Print("- "..FTUtils.Hilite("sound on").." | "..FTUtils.Hilite("off").." - Found an item sound.");
FTUtils.Print("- "..FTUtils.Hilite("show on").." | "..FTUtils.Hilite("off").." - Display 'Fleecing Tip' information in tooltip.");
FTUtils.Print("- "..FTUtils.Hilite("config").." - Open options.");
return;
end
if (msg == "version") then
FTUtils.Print(addon.." "..version);
return;
end
if ( msg == "sound on" ) or ( msg == "sound off" ) then
FleecingTipDB.NoSound = not FleecingTipDB.NoSound;
if (FleecingTipDB.NoSound) then
FTUtils.Print(addon.." sound is now set to "..FTUtils.Hilite("off")..".");
else
FTUtils.Print(addon.." sound is now set to "..FTUtils.Hilite("on")..".");
end
return;
end
if ( msg == "money icon" ) then
FleecingTipDB.CoinFormat = FT.ICON;
FTUtils.Print(addon.." money format is set to "..FTUtils.Hilite("icon")..".");
return;
end
if ( msg == "money short" ) then
FleecingTipDB.CoinFormat = FT.SHORT;
FTUtils.Print(addon.." money format is set to "..FTUtils.Hilite("short")..".");
return;
end
if ( msg == "money long" ) then
FleecingTipDB.CoinFormat = FT.LONG;
FTUtils.Print(addon.." money format is set to "..FTUtils.Hilite("long")..".");
return;
end
if ( msg == "show on" ) then
FleecingTipDB.NoDisplay = false
FTUtils.Print(addon.." is "..FTUtils.Hilite("on")..", and showing tooltip information.");
return;
end
if ( msg == "show off" ) then
FleecingTipDB.NoDisplay = true
FTUtils.Print(addon.." showing tooltip information is "..FTUtils.Hilite("off")..".");
return;
end
if ( msg == "status" ) then
FTUtils.Print(addon.." status:");
FTUtils.Print("Money format is "..FTUtils.Hilite(FleecingTipDB.CoinFormat)..".");
if (FleecingTipDB.NoSound) then
FTUtils.Print("Sound is "..FTUtils.Hilite("off")..".");
else
FTUtils.Print("Sound is "..FTUtils.Hilite("on")..".");
end;
local gotSomething;
if (not FleecingTipDB.NoDisplay) then
FTUtils.Print("Show "..FTUtils.Hilite("on").." Displaying tooltip information for "..addon..".");
gotSomething = true;
end;
if (not gotSomething) then
FTUtils.Print("Show "..FTUtils.Hilite("off ")..addon.." is not adding any information to tooltip.");
end;
return;
end;
if ( msg == "config" ) then
InterfaceOptionsFrame_OpenToCategory(addon); -- get over options bug...
InterfaceOptionsFrame_OpenToCategory(addon); -- workaround to get to FT options call twice!
return;
end;
if (msg == "test") then
FTUtils.Print(addon..", Data Stats:");
local itemInfoCount = 0;
for getID in pairs(FT_ItemInfo) do
local found = false;
for _, faction in pairs({"Alliance", "Horde", "Neutral"}) do
if (FT_VendorInfo[faction][getID]) and (FT_ItemInfo[getID]) then
found = true;
end;
end;
if (found == false) then
FTUtils.Print("Item ID "..getID.." not found in FT_VendorInfo.");
end;
itemInfoCount = itemInfoCount + 1;
end;
FTUtils.Print(" - "..itemInfoCount.." entries in FT_ItemInfo.");
for _, faction in pairs({"Alliance", "Horde", "Neutral"}) do
local vendorInfoCount = 0;
for getID in pairs(FT_VendorInfo[faction]) do
if (FT_VendorInfo[faction][getID]) and (not FT_ItemInfo[getID]) then
print("FT_VendorInfo["..faction.."] found, not in FT_ItemInfo");
FTUtils.Print("Item ID "..getID.." not found in FT_ItemInfo.");
end;
vendorInfoCount = vendorInfoCount + 1;
end;
FTUtils.Print(" - "..vendorInfoCount.." entries in FT_VendorInfo["..faction.."].");
end;
local dropCount = 0;
for itemID in pairs(FT_ItemInfo) do
if (FT_ItemInfo[itemID].drop == true) then
local dropfound = false;
local dropName = tostring(_G.UNKNOWN);
local loc = dropName;
for _, faction in pairs({"Alliance", "Horde", "Neutral"}) do
if (FT_VendorInfo[faction][itemID]) then
dropName = FT_VendorInfo[faction][itemID][1];
loc = faction;
-- print("Name: "..tostring(dropName)); -- *Debug*
if ( FT_VendorLocations["Drops"][dropName]) then
dropfound = true;
end;
end;
end;
if not (dropfound) then
FTUtils.Print("Drop '"..dropName.."' not found for ["..loc.."] "..itemID.." itemID.");
end;
dropCount = dropCount + 1;
end;
end;
FTUtils.Print(" - "..dropCount.." Drop entries.");
return;
end;
local _, _, cmd, args = string.find(msg, "^([%l%d']+) *(.*)");
if (cmd) then cmd = string.lower(cmd); end
if (args == nil or args == "") then
args = msg;
end
local postedText;
for itemLink in string.gmatch(args, "|c%x+|Hitem:[-%d:]+|h%[.-%]|h|r") do
postedText = nil;
local _, _, itemID = string.find(itemLink, "item:(%d+)");
if (itemID == nil or itemID == "") then
FTUtils.Print("Usage: "..FTUtils.Hilite("/ft info <item link>"));
return;
end
itemID = tonumber(itemID);
FTUtils.Print(addon..": found...");
local itemInfo = FT_ItemInfo[itemID];
if (itemInfo) then
local myFaction = UnitFactionGroup("player");
local vendors = FTTable.Merge(FT_VendorInfo[myFaction][itemID], FT_VendorInfo["Neutral"][itemID]);
local note = itemInfo.note;
local intro = itemLink..": "..string.format(FT.SOLD_BY, FTUtils.GSC(itemInfo.b));
if (vendors == nil or vendors == {}) then
FTUtils.Print(FTUtils.Red(addon.." "..version.." error: ")..itemLink.."("..itemID..") is listed but has no vendors. Please report this at the website you downloaded from.");
return;
end
FTUtils.Print(intro);
for i, aVendor in pairs(vendors) do
local vendorName = FT[aVendor] or aVendor;
local vendorNPC = FT_GetVendorCoordinates(myFaction,aVendor)
FTUtils.Print(string.format(FT.VENDOR_LOCATION_FORMAT, vendorName, vendorNPC));
end
if (note and note ~= "") then
FTUtils.Print(FTUtils.Hilite(note));
end
postedText = 1;
end
if (not postedText) then
FTUtils.Print("Nothing known about "..itemLink..".");
end
return;
end
if (postedText) then
return;
end
-- if we made it down here, there were args we didn't understand... time to remind the user what to do.
FT_ChatCommandHandler("help");
end;
function FT_DisabledChatCommandHandler(msg)
if ( msg ) then
FTUtils.Print(FTUtils.Gray(addon.." "..version.." Commands are disabled. (Sorry!)"));
end;
end;
function FT_CheckMerchant(itemID)
for merchantIndex = 1, GetMerchantNumItems() do
local link = GetMerchantItemLink(merchantIndex);
local _, _, merchantItemID = string.find(link, "item:(%d+)");
if (tonumber(merchantItemID) == itemID) then
return true;
end
end
return false;
end
function FT_ScanMerchant()
for index = 1, GetMerchantNumItems() do
local link = GetMerchantItemLink(index);
if ( link ) then
local itemName, _, _, _, _, itemType, subType, _, _, _, _, _, _, _, _, _, _ = GetItemInfo(link);
if (not FT_ItemIsBoP(index)) and (not FT_ItemBlacklist(link)) and ((itemType == FT.RECIPE) or (itemType == FT.MISCELLANEOUS and ((subType == FT.PET) or (subType == FT.MOUNT))) or (itemType == FT.CONTAINER and subType == FT.BAG)) then
local itemID = FTUtils.DecomposeItemLink(link);
-- print("itemID="..tostring(itemID));
-- if (FT_ItemInfo[itemID]) then
-- print(FTUtils.Red("** GET OWD'A HERE! **"));
-- return;
-- end;
local added;
local _, _, price, _, _, _, _, extendedCost = GetMerchantItemInfo(index);
local priceSummmary;
if (price and price > 0) then
priceSummmary = FTUtils.GSC(price);
else
priceSummmary = "";
end;
local itemSummary = "";
if (price == 0 and extendedCost) then
itemCount = GetMerchantItemCostInfo(index);
if (itemCount and itemCount > 0) then
for costIndex = 1, itemCount, 1 do
local itemTexture, itemValue, itemLink, itemName = GetMerchantItemCostItem(index, costIndex);
if (not itemName) then
itemName, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = GetItemInfo(itemLink);
if (not itemName) then
itemName = "Unknown Item";
end;
end;
itemSummary = itemSummary .. string.format(" + %d %s", itemValue, itemName);
end;
end;
priceSummmary = priceSummmary .. itemSummary;
itemSummary = string.gsub(itemSummary, "^ %+ ", "");
priceSummmary = string.gsub(priceSummmary, "^ %+ ", "");
priceSummmary = string.gsub(priceSummmary, " %+ $", "");
if (itemSummary == "") then
itemSummary = nil;
end;
end;
local vendorName = UnitName("npc");
local vendorFaction = UnitFactionGroup("npc");
if (vendorFaction ~= UnitFactionGroup("player")) then
vendorFaction = "Neutral";
end
local vendorZone = GetRealZoneText() or _G.UNKNOWN;
if (not FT_ItemInfo[itemID]) and (not FT_NewItemInfo[itemID]) then
FT_NewItemInfo[itemID] = FT_NewItemInfo[itemID] or {};
FT_NewItemInfo[itemID][vendorFaction] = FT_NewItemInfo[itemID][vendorFaction] or {};
FT_NewItemInfo[itemID][vendorFaction] = { vendor=vendorName, cost=price, item=itemName, location=vendorZone, note=itemSummary };
added = true;
end;
if (added) then
FTUtils.PrintOnce(string.format(addon.." %s has detected new data! Please report the following message: %s [%s] sold for %s by %s (%s) in %s.", version, link, FTUtils.LightYellow(itemID), FTUtils.Hilite(priceSummmary), FTUtils.Hilite(vendorName), vendorFaction, FTUtils.Hilite(vendorZone)));
end;
end;
end;
end;
end;
-- Attempt #2 at a BoP check, seems to work better =P
-- Version 4.2b adds a BoA check as well.
function FT_ItemIsBoP(index)
FT_BoPCheckingTooltip:ClearLines();
FT_BoPCheckingTooltip:SetMerchantItem(index);
for lineNum=1, FT_BoPCheckingTooltip:NumLines() do
if lineNum > 4 then
return false;
end;
local leftText = _G["FT_BoPCheckingTooltipTextLeft"..lineNum]:GetText();
if string.find(leftText, ITEM_BIND_ON_PICKUP) then
return true;
-- elseif string.find(leftText, ITEM_BIND_TO_BNETACCOUNT) then
-- return true;
-- elseif string.find(leftText, ITEM_BIND_TO_ACCOUNT) then
-- return true;
end;
end;
end;
-- A list of items that we don't want to detect.
function FT_ItemBlacklist(link)
local result = false;
local FT_Blacklist = {
-- [4496] = true, -- Small Brown Pouch, sold everywhere.
-- [4497] = true, -- Heavy Brown Bag, sold everywhere.
-- [4498] = true, -- Brown Leather Satchel, sold everywhere.
-- [4499] = true, -- Huge Brown Sack, sold everywhere.
-- [17200] = true, -- Recipe: Gingerbread Cookie. Blacklisted because otherwise it would list neutral vendors available in enemy faction cities which serves no purpose (even if you CAN buy them there.)
-- [17201] = true, -- Recipe: Egg Nog. Blacklisted because otherwise it would list neutral vendors available in enemy faction cities which serves no purpose (even if you CAN buy them there.)
[22200] = true, -- Silver Shafted Arrow. Blacklisted because it is not a pet but is detected as one.
[20758] = true, -- Formula: Minor Wizard Oil
[20753] = true, -- Formula: Lesser Wizard Oil
[20752] = true, -- Formula: Minor Mana Oil
[7091] = true, -- Pattern: Truefaith Gloves. To many mob drops.
-- Created Cloth Armor -->
[22758] = true, -- Sylvan Shoulders
[22757] = true, -- Sylvan Crown
[22756] = true, -- Sylvan Vest
[22655] = true, -- Glacial Wrists
[22654] = true, -- Glacial Gloves
[22652] = true, -- Glacial Vest
[20539] = true, -- Runed Stygian Belt
[20538] = true, -- Runed Stygian Leggings
[20537] = true, -- Runed Stygian Boots
[19999] = true, -- Bloodvine Goggles
[19684] = true, -- Bloodvine Boots
[19683] = true, -- Bloodvine Leggings
[19682] = true, -- Bloodvine Vest
[19165] = true, -- Flarecore Leggings
[19156] = true, -- Flarecore Robe
[19059] = true, -- Argent Shoulders
[19056] = true, -- Argent Boots
[19050] = true, -- Mantle of the Timbermaw
[19047] = true, -- Wisdom of the Timbermaw
[18486] = true, -- Mooncloth Robe
[18409] = true, -- Mooncloth Gloves
[18408] = true, -- Inferno Gloves
[18407] = true, -- Felcloth Gloves
[18405] = true, -- Belt of the Archmage
[18263] = true, -- Flarecore Wraps
[16980] = true, -- Flarecore Mantle
[16979] = true, -- Flarecore Gloves
[16008] = true, -- Master Engineer's Goggles
[15999] = true, -- Spellpower Goggles Xtreme Plus
[15802] = true, -- Mooncloth Boots
[14146] = true, -- Gloves of Spell Mastery
[14144] = true, -- Ghostweave Pants
[14143] = true, -- Ghostweave Belt
[14142] = true, -- Ghostweave Gloves
[14141] = true, -- Ghostweave Vest
[14140] = true, -- Mooncloth Circlet
[14139] = true, -- Mooncloth Shoulders
[14138] = true, -- Mooncloth Vest
[14137] = true, -- Mooncloth Leggings
[14136] = true, -- Robe of Winter Night
[14132] = true, -- Wizardweave Leggings
[14130] = true, -- Wizardweave Turban
[14128] = true, -- Wizardweave Robe
[14112] = true, -- Felcloth Shoulders
[14111] = true, -- Felcloth Hood
[14108] = true, -- Felcloth Boots
[14107] = true, -- Felcloth Pants
[14106] = true, -- Felcloth Robe
[14104] = true, -- Brightcloth Pants
[14101] = true, -- Brightcloth Gloves
[14100] = true, -- Brightcloth Robe
[14045] = true, -- Cindercloth Pants
[14043] = true, -- Cindercloth Gloves
[14042] = true, -- Cindercloth Vest
[13871] = true, -- Frostweave Pants
[13870] = true, -- Frostweave Gloves
[13869] = true, -- Frostweave Tunic
[13868] = true, -- Frostweave Robe
[13867] = true, -- Runecloth Shoulders
[13866] = true, -- Runecloth Headband
[13865] = true, -- Runecloth Pants
[13864] = true, -- Runecloth Boots
[13863] = true, -- Runecloth Gloves
[13858] = true, -- Runecloth Robe
[13857] = true, -- Runecloth Tunic
[13856] = true, -- Runecloth Belt
[10726] = true, -- Gnomish Mind Control Cap
[10724] = true, -- Gnomish Rocket Boots
[10588] = true, -- Goblin Rocket Helmet
[10506] = true, -- Deepdive Helmet
[10504] = true, -- Green Lens
[10503] = true, -- Rose Colored Goggles
[10502] = true, -- Spellpower Goggles Xtreme
[10501] = true, -- Catseye Ultra Goggles
[10500] = true, -- Fire Goggles
[10499] = true, -- Bright-Eye Goggles
[10048] = true, -- Colorful Kilt
[10044] = true, -- Cindercloth Boots
[10042] = true, -- Cindercloth Robe
[10041] = true, -- Dreamweave Circlet
[10031] = true, -- Shadoweave Boots
[10030] = true, -- Admiral's Hat
[10029] = true, -- Red Mageweave Shoulders
[10028] = true, -- Shadoweave Shoulders
[10027] = true, -- Black Mageweave Shoulders
[10026] = true, -- Black Mageweave Boots
[10025] = true, -- Shadoweave Mask
[10024] = true, -- Black Mageweave Headband
[10023] = true, -- Shadoweave Gloves
[10021] = true, -- Dreamweave Vest
[10019] = true, -- Dreamweave Gloves
[10018] = true, -- Red Mageweave Gloves
[10009] = true, -- Red Mageweave Pants
[10008] = true, -- White Bandit Mask
[10007] = true, -- Red Mageweave Vest
[10004] = true, -- Shadoweave Robe
[10003] = true, -- Black Mageweave Gloves
[10002] = true, -- Shadoweave Pants
[10001] = true, -- Black Mageweave Robe
[9999] = true, -- Black Mageweave Leggings
[9998] = true, -- Black Mageweave Vest
[7189] = true, -- Goblin Rocket Boots
[7065] = true, -- Green Silk Armor
[7064] = true, -- Crimson Silk Gloves
[7063] = true, -- Crimson Silk Robe
[7061] = true, -- Earthen Silk Belt
[7060] = true, -- Azure Shoulders
[7059] = true, -- Crimson Silk Shoulders
[7057] = true, -- Green Silken Shoulders
[7055] = true, -- Crimson Silk Belt
[7052] = true, -- Azure Silk Belt
[7051] = true, -- Earthen Vest
[7049] = true, -- Truefaith Gloves