-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDKPProfiler.lua
922 lines (811 loc) · 25.8 KB
/
DKPProfiler.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
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
DKPProfiler = {};
DKPProfilerCharInfo = {};
DKPProfilerGuildBank = {};
DKPProfilerBankTabTime = {};
DKPProfilerAchCat = {};
BankOpenedOnce = false;
local DKPPVersion = "0.707 (2015-08-05)";
function DKPProfiler_OnLoad(this)
--his:RegisterEvent("CHAT_MSG_WHISPER");
--this:RegisterEvent("PLAYER_ENTERING_WORLD");
SlashCmdList["DKPProfiler"] = DKPProfiler_SlashHandler;
SLASH_DKPProfiler1 = "/dkpp";
SLASH_DKPProfiler2 = "/gbk";
this:RegisterEvent("SPELLS_CHANGED");
this:RegisterEvent("BANKFRAME_OPENED");
this:RegisterEvent("GUILDBANKFRAME_OPENED");
this:RegisterEvent("GUILDBANK_UPDATE_TABS");
this:RegisterEvent("GUILDBANKBAGSLOTS_CHANGED");
this:RegisterEvent("PLAYERBANKSLOTS_CHANGED");
this:RegisterEvent("BAG_UPDATE");
this:RegisterEvent("TRADE_SKILL_SHOW");
this:RegisterEvent("CRAFT_SHOW");
this:RegisterEvent("CRAFT_UPDATE");
this:RegisterEvent("TRADE_SKILL_UPDATE");
this:RegisterEvent("CHARACTER_POINTS_CHANGED");
this:RegisterEvent("CONFIRM_TALENT_WIPE");
this:RegisterEvent("CHAT_MSG_SKILL");
this:RegisterEvent("PLAYER_ENTERING_WORLD");
this:RegisterEvent("CHAT_MSG_MONEY");
this:RegisterEvent("UPDATE_FACTION");
this:RegisterEvent("QUEST_WATCH_UPDATE");
this:RegisterEvent("QUEST_FINISHED");
this:RegisterEvent("QUEST_COMPLETE");
this:RegisterEvent("QUEST_PROGRESS");
this:RegisterEvent("ARENA_TEAM_UPDATE");
this:RegisterEvent("ACHIEVEMENT_EARNED");
this:RegisterEvent("ARCHAEOLOGY_TOGGLE");
this:RegisterEvent("ARENA_TEAM_ROSTER_UPDATE");
DEFAULT_CHAT_FRAME:AddMessage("DKP Profiler (from DKPSystem.com) Version "..DKPPVersion.." loaded. ");
DEFAULT_CHAT_FRAME:AddMessage("DKP Profiler will attempt to profile your character while you play, but typing |c00ffff00/dkpp|r will manually initiate a snapshot of the data available to the DKPProfiler mod");
end
function DKPPinitialize()
if(DKPProfilerCharInfo == nil) then
DKPProfilerCharInfo = {};
end
if DKPProfiler == nil then
DKPProfiler = {};
end
end
function DKPProfiler_OnEvent(self,event,...)
local arg1 = ...;
--GRSSPrint("Event: "..event);
if (event == "BANKFRAME_OPENED") then
BankOpenedOnce = true;
elseif (event == "GUILDBANKFRAME_OPENED") then
DKPPRefreshAllBankTabs();
DKPPAverageItemLevel();
elseif (event == "GUILDBANK_UPDATE_TABS" or event=="GUILDBANKBAGSLOTS_CHANGED") then
DKPPStoreGuildBankItems();
elseif (event == "TRADE_SKILL_SHOW" or event == "TRADE_SKILL_UPDATE") then
DKPPGetCurrentTradeSkill();
DKPPGetTalents();
DKPPGetQuests();
elseif (event == "ACHIEVEMENT_EARNED") then
DKPPGetAchievements();
DKPPGetGold();
elseif (event == "CHAT_MSG_SKILL") then
DKPPGetTalents();
elseif (event == "SPELLS_CHANGED") then
DKPPInitializeTradeSkills();
elseif (event == "ADDON_LOADED") then
DKPPinitialize();
DKPPGetPvP();
DKPPGetTalents();
DKPPGetGold();
DKPPStorePlayerItems();
DKPPInitializeTradeSkills();
elseif (event == "QUEST_WATCH_UPDATE" or event=="QUEST_FINISHED" or event=="QUEST_COMPLETE" or event=="QUEST_PROGRESS") then
DKPPGetQuests();
elseif (event == "CHARACTER_POINTS_CHANGED" or event=="CONFIRM_TALENT_WIPE" or event=="PLAYER_ENTERING_WORLD") then
DKPPGetTalents();
elseif (event == "UPDATE_FACTION") then
DKPPGetReputations();
elseif (event == "CHAT_MSG_MONEY") then
DKPPGetGold();
elseif (event == "ARENA_TEAM_UPDATE" or event=="ARENA_TEAM_ROSTER_UPDATE") then
DKPPGetPvP();
elseif (event == "ARCHAEOLOGY_TOGGLE") then
DKPPGetArchaeology();
end
if (event=="GUILDBANKFRAME_OPENED" or (BankOpenedOnce==true and (event == "BANKFRAME_OPENED" or (event == "PLAYERBANKSLOTS_CHANGED" and arg1 == nil) or (event == "BAG_UPDATE" and arg1 >= 6 and arg1 <= 10)))) then
DKPPGetTalents();
DKPPGetPvP();
DKPPGetQuests();
DKPPPurgeResistance();
if(event == "BANKFRAME_OPENED") then
DKPPStorePlayerItems();
DKPPStoreBankItems();
elseif(event == "GUILDBANKFRAME_OPENED") then
DKPPStoreGuildBankGold();
end
DKPPGetGold();
end
end
function DKPPRefreshAllBankTabs()
local i;
for i = 1,GetNumGuildBankTabs() do
QueryGuildBankTab(i);
end
end
function DKPPPurgeResistance()
local player = UnitName("player");
if(DKPProfilerCharInfo[player] == nil) then
DKPProfilerCharInfo[player] = {};
end
DKPProfilerCharInfo[player].resistances = {};
end
function DKPProfiler_SlashHandler(msg)
DEFAULT_CHAT_FRAME:AddMessage("DKP Profiler Version "..DKPPVersion);
DKPPGetTalents();
DKPPGetPvP();
DKPPGetQuests();
DKPPPurgeResistance();
DKPPStorePlayerItems();
DKPPGetGold();
DKPPGetAchievements();
DKPPInitializeTradeSkills();
end
function DKPPGetAchievements()
local player = UnitName("player");
if(DKPProfilerCharInfo[player] == nil) then
DKPPRofilerCharInfo[player] = {};
end
DKPProfilerCharInfo[player].achievements = {};
local cats = GetCategoryList();
local cat,ach,achs;
local achi = 1;
local achpoints,comp,desc;
local catrec = {};
DKPProfilerAchCat = {};
for i,catid in pairs(cats) do
cat,parentcatid = GetCategoryInfo(catid);
DKPProfilerAchCat[catid] = {
["category"] = cat,
["parentcatid"] = parentcatid
};
--DKPPPrint("ach cat"..catid);
local numach = GetCategoryNumAchievements(catid);
--DKPPPrint("ok");
for ii = 1,numach do
local numdone = 0;
achid,ach,achpoints,comp,M,D,Y,desc = GetAchievementInfo(catid,ii);
catrec = {};
catrec.catid = catid;
catrec.ach = ach;
catrec.description = desc;
catrec.completed = comp;
catrec.crit = {};
catrec.points = achpoints;
local numcrit = GetAchievementNumCriteria(achid);
for iii = 1,numcrit do
local crit,_,critcomp = GetAchievementCriteriaInfo(achid,iii);
if critcomp == false then
catrec.crit[iii] = crit;
else
numdone = numdone + 1;
catrec.crit[iii] = "<strike>"..crit.."</strike>";
end
end
if numcrit == 0 then
catrec.progress = nil;
else
catrec.progress = numdone.."/"..numcrit;
end
if comp == true then
catrec.date = M.."/"..D.."/"..(Y+2000);
end
if comp or numdone>0 then
DKPProfilerCharInfo[player].achievements[achi] = catrec;
achi = achi + 1;
end
end
end
end
function DKPPGetReputations()
local faction,repstr, lvl, i, standingid,header,top,bot,mylvl,mymax,cat,counter;
local player = UnitName("player");
counter = 0;
DKPPinitialize();
if(DKPProfilerCharInfo[player] == nil) then
DKPProfilerCharInfo[player] = {};
end
if GetNumFactions() > 0 then
DKPProfilerCharInfo[player].factions = {};
for i = 1,GetNumFactions() do
faction,_,standingid,bot,top,lvl,_,_,header = GetFactionInfo(i);
if header == nil and faction~=nil then
mylvl = lvl-bot;
mymax = top-bot;
DKPProfilerCharInfo[player].factions[counter] = {};
DKPProfilerCharInfo[player].factions[counter].category = cat;
DKPProfilerCharInfo[player].factions[counter].faction = faction;
DKPProfilerCharInfo[player].factions[counter].standinglabel=getglobal("FACTION_STANDING_LABEL"..standingid);
DKPProfilerCharInfo[player].factions[counter].standingid=standingid;
DKPProfilerCharInfo[player].factions[counter].level=mylvl;
DKPProfilerCharInfo[player].factions[counter].maxlvl=mymax;
counter = counter + 1;
else
cat = faction;
end
end
end
end
function DKPPGetQuests()
local player = UnitName("player");
counter = 0;
DKPPinitialize();
if(DKPProfilerCharInfo[player] == nil) then
DKPProfilerCharInfo[player] = {};
end
DKPProfilerCharInfo[player].quests = {};
local i=1;
local headername = "";
local questTitle = "";
while (questTitle ~= nil and i < 80) do
questTitle, level, tag, suggestedGroup, header, collapsed, completed = GetQuestLogTitle(i);
if (not header) then
DKPProfilerCharInfo[player].quests[counter] = {};
DKPProfilerCharInfo[player].quests[counter].title = questTitle;
DKPProfilerCharInfo[player].quests[counter].tag = tag;
DKPProfilerCharInfo[player].quests[counter].header = headername;
DKPProfilerCharInfo[player].quests[counter].completed = completed;
DKPProfilerCharInfo[player].quests[counter].objectives = {};
--local numobj = GetNumQuestLogLeaderBoards(i); --number of objectives
local o = 1;
local desc,done;
desc = "dgdsgdfgdghfdhfdghf";
while desc~=nil and desc~="" and o<10 do
desc,_,done = GetQuestLogLeaderBoard(o,i);
if(desc) then
DKPProfilerCharInfo[player].quests[counter].objectives[o] = {};
DKPProfilerCharInfo[player].quests[counter].objectives[o].text = desc;
DKPProfilerCharInfo[player].quests[counter].objectives[o].done = done;
end
o = o + 1;
end
counter = counter + 1
else
headername = questTitle;
end
i = i + 1;
end
end
function DKPPAverageItemLevel()
local player = UnitName("player")
local total,count,k=0,0
for i=1,18 do
k=GetInventoryItemLink(player,i)
if i~=4 and k then
total=total+select(4,GetItemInfo(k))
count=count+1
end
end
if count > 0 then
local AvgItemLevel = total/count;
if DKPProfilerCharInfo[player] ~= nil then
DKPProfilerCharInfo[player].avgitemlevel = AvgItemLevel;
DKPPStoreMetricHistory("avgitemlevel",AvgItemLevel);
end
end
end
function DKPPGetGold()
local c = GetMoney();
local g,s,level,race,class,apoints;
g = math.floor(c/10000);
c = c - (g*10000);
s = math.floor(c/100);
c = c - (s*100);
local player = UnitName("player");
if(DKPProfilerCharInfo[player] == nil) then
DKPProfilerCharInfo[player] = {};
end
local moneystring = g.." Gold, "..s.." Silver,"..c.." Copper";
DKPProfilerCharInfo[player].money = moneystring;
DKPPStoreMetricHistory("money",math.floor(GetMoney()/10000));
level = UnitLevel("player");
race = UnitRace("player");
class = UnitClass("player");
apoints = GetTotalAchievementPoints();
DKPProfilerCharInfo[player].achpoints = apoints;
DKPPStoreMetricHistory("achpoints",apoints);
DKPPAverageItemLevel();
if level~=nil then
DKPProfilerCharInfo[player].level = level;
DKPPStoreMetricHistory("level",level);
end
if race~=nil then
DKPProfilerCharInfo[player].race = race
end
if class~=nil then
DKPProfilerCharInfo[player].class = class;
end
DKPProfilerCharInfo[player].realm = GetRealmName();
end
function DKPPGetTalents()
local player = UnitName("player");
if(DKPProfilerCharInfo[player] == nil) then
DKPProfilerCharInfo[player] = {};
end
DKPProfilerCharInfo[player].talents = {};
Groups = GetNumSpecGroups();
for i = 1, Groups do
DKPProfilerCharInfo[player].talents[i] = DKPPGetTalents_Specific(i);
end
end
function DKPPGetWebsiteClassKey()
local class = UnitClass("player");
local ClassKeys = {
["Death Knight"] = "d",
["Druid"] = "U",
["Hunter"] = "Y",
["Mage"] = "e",
["Monk"] = "f",
["Paladin"] = "b",
["Priest"] = "X",
["Rogue"] = "c",
["Shaman"] = "W",
["Warlock"] = "V",
["Warrior"] = "Z"
};
return ClassKeys[class];
end
function DKPPGetTalents_Specific(GroupNum)
local tab,tabname,talentname,column,selected, i;
local talentstring = DKPPGetWebsiteClassKey() .. "!";
local tt = {};
if GetTalentInfo(1,nil,GroupNum)~=nil then
tt.Talents = {};
for i = 1, GetNumTalents(GroupNum) do
talentname,_,tier,column,selected = GetTalentInfo(i,nil,GroupNum);
if selected then
tt.Talents[tier] = {};
tt.Talents[tier].name = talentname;
talentstring = talentstring .. (column-1);
end
end
end
local currentSpec = GetSpecialization(nil,nil,GroupNum);
local currentSpecName = currentSpec and select(2, GetSpecializationInfo(currentSpec)) or "None";
tt.Specialization = currentSpecName;
tt.Glyphs = DKPPGetTalents_Glyphs(GroupNum);
tt.talentstring = talentstring;
return tt;
end
function DKPPGetTalents_Glyphs(GroupNum)
local glyphs = {};
local max = GetNumGlyphSockets();
for i = 1,max do
enabled = GetGlyphSocketInfo(i,GroupNum);
if enabled then
local link = GetGlyphLink(i,GroupNum);
if link ~= "" then
local item = DKPPNameFromLink(link,true)
--GRSSPrint(item);
glyphs[i] = item;
end
end
end
return glyphs;
end
function DKPPInitializeTradeSkills()
local player = UnitName("player");
local profs = {GetProfessions()};
if DKPProfilerCharInfo[player].professions == nil then
DKPProfilerCharInfo[player].professions = {};
end
local usedprofs = {};
for i,profindex in pairs(profs) do
if profindex ~= nil then
--DKPPPrint("Prof:"..profindex);
local profname,_,level = GetProfessionInfo(profindex);
usedprofs[profname] = profname;
if DKPProfilerCharInfo[player].professions[profname]==nil then
DKPProfilerCharInfo[player].professions[profname] = {};
end
DKPProfilerCharInfo[player].professions[profname].lvl = level;
--DKPPPrint("Prof:"..profindex..":"..profname..":"..level);
DKPPStoreMetricHistory("Profession: "..profname,level);
end
end
for profname,profinfo in pairs(DKPProfilerCharInfo[player].professions) do
if usedprofs[profname] == nil then
DKPProfilerCharInfo[player].professions[profname] = nil
end
end
end
function DKPPGetArchaeology()
local player = UnitName("player");
local profname = "Archaeology";
if DKPProfilerCharInfo[player].professions[profname]==nil then
DKPProfilerCharInfo[player].professions[profname] = {};
end
if DKPProfilerCharInfo[player].professions[profname].skills==nil then
DKPProfilerCharInfo[player].professions[profname].skills = {};
end
local rarities = {};
local races = GetNumArchaeologyRaces();
for r=1,races do
local arts = GetNumArtifactsByRace(r);
for a = 2,arts do
local item,_,rarity = GetArtifactInfoByRace(r,a);
DKPProfilerCharInfo[player].professions[profname].skills[item] = item;
end
end
end
function DKPPGetCurrentTradeSkill()
DKPPInitializeTradeSkills();
local profname, lvl, max = GetTradeSkillLine();
local linked,linkedplayer = IsTradeSkillLinked();
if linked then
--do nothing
--TODO: Add tracking for guildies?
else
local player = UnitName("player");
if profname ~= nil and profname ~= "UNKNOWN" then
if DKPProfilerCharInfo[player].professions == nil then
DKPProfilerCharInfo[player].professions = {};
end
if DKPProfilerCharInfo[player].professions[profname]==nil then
DKPProfilerCharInfo[player].professions[profname] = {};
end
if DKPProfilerCharInfo[player].professions[profname].skills == nil then
DKPProfilerCharInfo[player].professions[profname].skills = {};
end
DKPProfilerCharInfo[player].professions[profname].level = lvl;
DKPPStoreMetricHistory("Profession: "..profname,lvl);
local i, name, type;
for i = 1,GetNumTradeSkills() do
name, type, _, _ = GetTradeSkillInfo(i);
if(type ~= "header")then
DKPProfilerCharInfo[player].professions[profname].skills[name]=name;
end
end
end
end
end
function DKPPGetPvP()
local player = UnitName("player");
local realm = GetRealmName();
if(DKPProfilerCharInfo[player] == nil) then
DKPProfilerCharInfo[player] = {};
end
if(DKPProfilerCharInfo[player].pvp == nil) then
DKPProfilerCharInfo[player].pvp = {};
end
DKPProfilerCharInfo[player].pvp.arena = {};
--[[
--Arena teams currently disabled.
local team,size,rating,played,wins;
for i = 1,3 do
team,size,rating,_,_,wins,played = GetArenaTeam(i);
if size ~= nil and size>0 then
num = GetNumArenaTeamMembers(i);
local players = {};
for mi = 1,num do
pname,_,plevel,pclass,_,_,_,pplayed,pwins,prating = GetArenaTeamRosterInfo(i,mi);
players[mi] = {
["name"]=pname,
["class"]=pclass,
["won"]=pwins,
["played"]=pplayed,
["rating"]=prating,
};
end
DKPProfilerCharInfo[player].pvp.arena[i] = {
["teamname"] = team,
["size"] = size,
["rating"] = rating,
["players"] = players,
["wins"] = wins,
["played"] = played
};
DKPPStoreMetricHistory(size.."v"..size..": "..team,rating);
end
end
--]]
local hk,dk,rank,rankid;
hk, dk = GetPVPLifetimeStats();
rankid = GetCurrentTitle();
if rank ~= nil then
rank = GetTitleName(rankid);
else
rank = nil;
end
DKPProfilerCharInfo[player].pvp.rankid = rankid;
DKPProfilerCharInfo[player].pvp.rank = rank;
DKPProfilerCharInfo[player].pvp.LifetimeHKs = hk;
DKPProfilerCharInfo[player].pvp.LifetimeDKs = dk;
_,ValorPoints = GetCurrencyInfo(396);
_,HonorPoints = GetCurrencyInfo(392);
_,ConquestPoints = GetCurrencyInfo(390)
_,JusticePoints = GetCurrencyInfo(395);
_,DKPProfilerCharInfo[player].pvp.ValorPoints = ValorPoints;
_,DKPProfilerCharInfo[player].pvp.HonorPoints = HonorPoints;
_,DKPProfilerCharInfo[player].pvp.ConquestPoints = ConquestPoints;
_,DKPProfilerCharInfo[player].pvp.JusticePoints = JusticePoints;
DKPPStoreMetricHistory("Valor Points",ValorPoints);
DKPPStoreMetricHistory("Honor Points",HonorPoints);
DKPPStoreMetricHistory("Conquest Points",ConquestPoints);
DKPPStoreMetricHistory("Justice Points",JusticePoints);
local Realm, Players
-- Old GearScore (3.0)
if GS_Data ~= nil and GS_Data[realm] ~= nil and GS_Data[realm].Players ~= nil then
Players = GS_Data[realm].Players
if Players[player] ~= nil and Players[player].GearScore ~= nil then
local gs = GearScore;
DKPProfilerCharInfo[player].gearscore = Players[player].GearScore;
DKPPStoreMetricHistory("gearscore",GearScore);
end
end
--New GearScore (4.0)
if TenTonHammer_Database ~= nil and TenTonHammer_Database[realm]~=nil and TenTonHammer_Database[realm][player]~=nil then
GSString = TenTonHammer_Database[realm][player];
local a = {};
for v in string.gmatch(GSString, "[^:]+") do tinsert(a, v); end
local GearScore, RaidScore, PVEScore, PVPScore = a[2], a[3], a[4], a[5];
DKPProfilerCharInfo[player].gearscore = GearScore;
DKPPStoreMetricHistory("gearscore",GearScore);
end
end
function PurgeNecessarySkills()
local player = UnitName("player");
local skill,v;
for skill in pairs(DKPProfilerCharInfo[player].professions) do
--DKPPPrint("Attempting to Purge: "..skill);
if (IsMySkill(skill)==0) then
--DKPPPrint("purging "..skill);
DKPProfilerCharInfo[player].professions[skill] = nil;
end
end
end
function DKPPPrint(msg)
DEFAULT_CHAT_FRAME:AddMessage("DKPP: "..msg);
end
function DKPPPrintAll()
--DKPPPrint("Printing it");
local i, v;
local player = UnitName("player");
for i, v in ipairs(DKPProfiler[player]["Bank"]) do DKPPPrint("Bank: " .. i .. " x " .. v) end
for i, v in ipairs(DKPProfiler[player]["Bags"]) do DKPPPrint("Bags: " .. i .. " x " .. v) end
end
function DKPPNameFromLink(link,ItemNameOnly)
local quality;
local s,e=string.find(link,"%[.*]");
local itemname = string.sub(link,s+1,e-1);
if ItemNameOnly then
return itemname;
else
s,e = string.find(link,"item:%d+:%d+:%d+:%d+");
local itemid = string.sub(link,s,e);
local _,_,quality,_,itype,isubtype = GetItemInfo(itemid);
if(quality == nil) then
quality = 1;
end
return quality..":::"..itemname;
end
end
--StoredPlace can be: "Bank","Bags","Player" for Bank, Player's Bags, and Currently Equipped
function DKPPStoreBag(BagNum,StoredPlace)
local items,name,itemtype,itemsubtype,equiploc,ttlevel;
local player = UnitName("player");
local i;
local qty,quality,itemstring;
local s,e;
--DKPPPrint("Bag: "..BagNum);
items = GetContainerNumSlots(BagNum);
if (items) then
for i = 1, items do
link = GetContainerItemLink(BagNum, i);
_, qty = GetContainerItemInfo(BagNum, i);
if( link ) then
--DKPPPrint("Doing Item: "..link);
--name,quality = DKPPNameFromLink(link);
name,_,quality,_,level,itemtype,itemsubtype,_,equiploc = GetItemInfo(link);
class,ttlevel = DKPPGetClassAndLevelOfItem(BagNum,i);
local totalitem = name;
if class~=nil and string.len(class)>0 then
totalitem=totalitem..";;"..class;
end
if ttlevel~=nil and string.len(ttlevel)>0 then
totalitem=totalitem..";;"..ttlevel;
end
if (DKPProfiler[player][StoredPlace][totalitem]==nil or type(DKPProfiler[player][StoredPlace][totalitem])~="table") then
DKPProfiler[player][StoredPlace][totalitem]={};
if(qty==0) then
qty=1;
end
DKPProfiler[player][StoredPlace][totalitem].qty=qty;
DKPProfiler[player][StoredPlace][totalitem].quality=quality;
if(level>0) then
DKPProfiler[player][StoredPlace][totalitem].level=level;
end
DKPProfiler[player][StoredPlace][totalitem].itemtype=itemtype;
DKPProfiler[player][StoredPlace][totalitem].itemsubtype=itemsubtype;
DKPProfiler[player][StoredPlace][totalitem].equiploc=getglobal(equiploc);
DKPProfiler[player][StoredPlace][totalitem].itemclasses=class;
else
DKPProfiler[player][StoredPlace][totalitem].qty=DKPProfiler[player][StoredPlace][totalitem].qty+qty;
end
end
end
end
end
function DKPPStorePlayer()
local StoredPlace="Player";
local player=UnitName("player");
local classlvl,ttlevel;
local i, link, name, s, e
for i = 0,19 do
link = GetInventoryItemLink("player", i);
if (link) then
--name = DKPPNameFromLink(link);
name,_,quality,_,level,itemtype,itemsubtype,_,equiploc = GetItemInfo(link);
class,ttlevel = DKPPGetClassAndLevelOfItem("player",i);
local totalitem = name;
if class ~= nil and string.len(class)>0 then
totalitem=totalitem..";;"..class
end
if ttlevel ~= nil and string.len(ttlevel)>0 then
totalitem=totalitem..";;"..ttlevel;
end
DKPProfiler[player][StoredPlace][totalitem]={};
DKPProfiler[player][StoredPlace][totalitem].qty=qty;
DKPProfiler[player][StoredPlace][totalitem].quality=quality;
if(level>0) then
DKPProfiler[player][StoredPlace][totalitem].level=level;
end
DKPProfiler[player][StoredPlace][totalitem].itemtype=itemtype;
DKPProfiler[player][StoredPlace][totalitem].itemsubtype=itemsubtype;
DKPProfiler[player][StoredPlace][totalitem].itemclasses=class;
DKPProfiler[player][StoredPlace][totalitem].equiploc=getglobal(equiploc);
end
end
end
function DKPPStoreBankItems()
local StoredPlace="Bank";
local player = UnitName("player");
local i;
DKPProfiler[player][StoredPlace]={};
DKPPStoreBag(BANK_CONTAINER,StoredPlace);
for i = 5,10 do
DKPPStoreBag(i,StoredPlace);
end
end
function DKPPStorePlayerItems()
local i;
local player=UnitName("player");
local StoredPlace="Bags";
DKPPinitialize();
if(DKPProfiler[player]==nil) then
DKPProfiler[player]={};
end
DKPProfiler[player]["Player"]={};
DKPPStorePlayer();
DKPProfiler[player]["Bags"]={};
for i = 0,4 do
DKPPStoreBag(i,StoredPlace);
end
DKPPStoreBag(-2,StoredPlace);
end
function B(t)
if( t == nil) then
return "[Blank]";
else
return t;
end
end
function DKPPStoreGuildBankItems()
local name;
local qty;
local tabs;
local i,j,items;
tabs = GetNumGuildBankTabs();
local CurTime = GetTime();
for i = 1,tabs do
if DKPProfilerBankTabTime[i] == nil or CurTime > DKPProfilerBankTabTime[i] + 0.5 then
--DKPPPrint("Loading Tab: "..i);
DKPProfilerGuildBank[i] = {};
name = GetGuildBankTabInfo(i);
DKPProfilerGuildBank[i].name = name;
DKPProfilerGuildBank[i].items = {};
TotalItems = 0
for j = 1,98 do
_,qty = GetGuildBankItemInfo(i,j);
item = GetGuildBankItemLink(i,j);
if(item~=nil) then
TotalItems = TotalItems + 1;
name,_,quality,_,level,itemtype,itemsubtype,_,equiploc = GetItemInfo(item);
class,ttlevel = DKPPGetClassAndLevelOfBankItem(i,j);
local totalitem = name;
if class ~= nil and string.len(class)>0 then
totalitem=totalitem..";;"..class
end
if ttlevel ~= nil and string.len(ttlevel)>0 then
totalitem=totalitem..";;"..ttlevel;
end
if (DKPProfilerGuildBank[i].items[totalitem]==nil or type(DKPProfilerGuildBank[i].items[totalitem])~="table") then
DKPProfilerGuildBank[i].items[totalitem]={};
DKPProfilerGuildBank[i].items[totalitem].qty=qty;
DKPProfilerGuildBank[i].items[totalitem].quality=quality;
if(level>0) then
DKPProfilerGuildBank[i].items[totalitem].level=level;
end
DKPProfilerGuildBank[i].items[totalitem].itemtype=itemtype;
DKPProfilerGuildBank[i].items[totalitem].itemsubtype=itemsubtype;
DKPProfilerGuildBank[i].items[totalitem].itemclasses=class;
DKPProfilerGuildBank[i].items[totalitem].equiploc=getglobal(equiploc);
else
DKPProfilerGuildBank[i].items[totalitem].qty=DKPProfilerGuildBank[i].items[totalitem].qty+qty;
end
end
end
if TotalItems > 0 then
DKPProfilerBankTabTime[i] = CurTime;
end
else
--DKPPPrint("Tab "..i.." Loaded Recently: skipping");
end
end
end
function DKPPStoreGuildBankGold()
end
function DKPPNumNilZero(v)
v = tonumber(v);
if v == nil then
v = 0
end
return v;
end
function DKPPGetClassAndLevelOfBankItem(tab,slot)
local class,level=nil,nil;
DKPPKTooltip:ClearLines();
DKPPKTooltip:SetGuildBankItem(tab,slot);
local textadd="";
--DKPPPrint(DKPPKTooltip:NumLines());
for i = 1,30 do
local left = getglobal("DKPPKTooltipTextLeft"..i);
local text;
if left ~= nil then
text = left:GetText();
if text~=nil then
_,_,c = string.find(text,"Classes:%s*(.+)%s*");
if c~=nil then
class = c;
else
_,_,l = string.find(text,"(Level%s%d*)");
if l~=nil then
level = l;
end
end
end
end
end
return class,level;
end
function DKPPGetClassAndLevelOfItem(bag,slot)
local class,level=nil,nil;
DKPPKTooltip:ClearLines();
if(bag=="player") then
DKPPKTooltip:SetInventoryItem("player",slot);
else
DKPPKTooltip:SetBagItem(bag,slot);
end
local textadd="";
--DKPPPrint(DKPPKTooltip:NumLines());
for i = 1,30 do
local left = getglobal("DKPPKTooltipTextLeft"..i);
local text;
if left ~= nil then
text = left:GetText();
if text~=nil then
_,_,c = string.find(text,"Classes:%s*(.+)%s*");
if c~=nil then
class = c;
else
_,_,l = string.find(text,"(Level%s%d*)");
if l~=nil then
level = l;
end
end
end
end
end
return class,level;
end
function DKPPStoreMetricHistory(Metric,Value)
local player=UnitName("player");
--DKPPPrint("player: "..player);
if DKPProfilerCharInfo[player]==nil then
DKPProfilerCharInfo[player]={};
end
if DKPProfilerCharInfo[player].history == nil then
DKPProfilerCharInfo[player].history = {};
end
if DKPProfilerCharInfo[player].history[Metric] == nil then
DKPProfilerCharInfo[player].history[Metric] = {};
end
Date = date("%Y-%m-%d");
--DKPPPrint("Storing Metric '" .. Metric .. "' (" .. Date .."): ");
DKPProfilerCharInfo[player].history[Metric][Date] = Value;
end