-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathController.lua
More file actions
1023 lines (846 loc) · 49.7 KB
/
Controller.lua
File metadata and controls
1023 lines (846 loc) · 49.7 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
AutoBiographer_Controller = {
CharacterData = {},
Logs = {},
Temp = {},
}
local Controller = AutoBiographer_Controller
function Controller:AddEvent(event)
table.insert(self.CharacterData.Events, event)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog(Event.ToString(self.CharacterData.Events[#self.CharacterData.Events], self.CharacterData.Catalogs), AutoBiographerEnum.LogLevel.Debug) end
end
function Controller:AddLog(text, logLevel)
if (logLevel == nil) then error("Unspecified logLevel. Log Text: '" .. text .. "'") end
table.insert(self.Logs, {
Level = logLevel, Text = tostring(text),
Timestamp = time(),
})
if (AutoBiographer_DebugWindow and AutoBiographer_DebugWindow.LogsUpdated) then
AutoBiographer_DebugWindow:LogsUpdated()
end
end
function Controller:AddOtherPlayerInGroupTime(otherPlayerGuid, seconds)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("AddOtherPlayerInGroupTime: " .. " #" .. tostring(otherPlayerGuid) .. ", " .. tostring(seconds) .. " seconds.", AutoBiographerEnum.LogLevel.Debug) end
if (not otherPlayerGuid) then
Controller:AddLog("otherPlayerGuid was nil.", AutoBiographerEnum.LogLevel.Error)
return
end
if (not self:GetCurrentLevelStatistics().OtherPlayerStatisticsByOtherPlayer[otherPlayerGuid]) then self:GetCurrentLevelStatistics().OtherPlayerStatisticsByOtherPlayer[otherPlayerGuid] = OtherPlayerStatistics.New() end
OtherPlayerStatistics.Add(self:GetCurrentLevelStatistics().OtherPlayerStatisticsByOtherPlayer[otherPlayerGuid], AutoBiographerEnum.OtherPlayerTrackingType.TimeSpentGroupedWithPlayer, seconds)
end
function Controller:AddTime(timeTrackingType, seconds, zone, subZone)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("Adding " .. tostring(seconds) .. " seconds of timeTrackingType " .. tostring(timeTrackingType) .. " to " .. tostring(subZone) .. " (" .. tostring(zone) .. ").", AutoBiographerEnum.LogLevel.Debug) end
local areaId = tostring(zone) .. "-" .. tostring(subZone)
if (not self:GetCurrentLevelStatistics().TimeStatisticsByArea[areaId]) then self:GetCurrentLevelStatistics().TimeStatisticsByArea[areaId] = TimeStatistics.New() end
TimeStatistics.AddTime(self:GetCurrentLevelStatistics().TimeStatisticsByArea[areaId], timeTrackingType, seconds)
end
function Controller:CatalogItemIsIncomplete(catalogItemId)
return not self.CharacterData.Catalogs.ItemCatalog[catalogItemId] or not self.CharacterData.Catalogs.ItemCatalog[catalogItemId].Name or not self.CharacterData.Catalogs.ItemCatalog[catalogItemId].Rarity
end
function Controller:CatalogUnitIsIncomplete(catalogUnitId)
return self.CharacterData.Catalogs.UnitCatalog[catalogUnitId] == nil or self.CharacterData.Catalogs.UnitCatalog[catalogUnitId].Name == nil
end
function Controller:GetAggregatedItemStatisticsDictionary(minLevel, maxLevel)
local itemStatisticsDictionary = {}
for levelNum, levelStatistics in pairs(self.CharacterData.Levels) do
if (levelNum >= minLevel and levelNum <= maxLevel) then
for catalogItemId, itemStatistics in pairs(levelStatistics.ItemStatisticsByItem) do
if (not itemStatisticsDictionary[catalogItemId]) then
itemStatisticsDictionary[catalogItemId] = ItemStatistics.New()
end
for k, itemAcquisitionMethod in pairs(AutoBiographerEnum.ItemAcquisitionMethod) do
if (itemStatistics[itemAcquisitionMethod]) then
if (itemStatisticsDictionary[catalogItemId][itemAcquisitionMethod] == nil) then itemStatisticsDictionary[catalogItemId][itemAcquisitionMethod] = 0 end
itemStatisticsDictionary[catalogItemId][itemAcquisitionMethod] = itemStatisticsDictionary[catalogItemId][itemAcquisitionMethod] + itemStatistics[itemAcquisitionMethod]
end
end
end
end
end
return itemStatisticsDictionary
end
function Controller:GetAggregatedKillStatisticsTotals(minLevel, maxLevel)
local killStatisticsDictionary = self:GetAggregatedKillStatisticsDictionary(minLevel, maxLevel)
local totalsKillStatistics = KillStatistics.New()
for catalogUnitId, killStatistics in pairs(killStatisticsDictionary) do
for k, killTrackingType in pairs(AutoBiographerEnum.KillTrackingType) do
if (killStatistics[killTrackingType]) then
if (totalsKillStatistics[killTrackingType] == nil) then totalsKillStatistics[killTrackingType] = 0 end
totalsKillStatistics[killTrackingType] = totalsKillStatistics[killTrackingType] + killStatistics[killTrackingType]
end
end
end
return totalsKillStatistics
end
function Controller:GetAggregatedKillStatisticsByCatalogUnitId(catalogUnitId, minLevel, maxLevel)
local killStatisticsByCatalogUnitId = KillStatistics.New()
for levelNum, levelStatistics in pairs(self.CharacterData.Levels) do
if (levelNum >= minLevel and levelNum <= maxLevel) then
local killStatistics = levelStatistics.KillStatisticsByUnit[catalogUnitId]
if (killStatistics) then
for k, killTrackingType in pairs(AutoBiographerEnum.KillTrackingType) do
if (killStatistics[killTrackingType]) then
if (killStatisticsByCatalogUnitId[killTrackingType] == nil) then killStatisticsByCatalogUnitId[killTrackingType] = 0 end
killStatisticsByCatalogUnitId[killTrackingType] = killStatisticsByCatalogUnitId[killTrackingType] + killStatistics[killTrackingType]
end
end
end
end
end
return killStatisticsByCatalogUnitId
end
function Controller:GetAggregatedKillStatisticsDictionary(minLevel, maxLevel)
local killStatisticsDictionary = {}
for levelNum, levelStatistics in pairs(self.CharacterData.Levels) do
if (levelNum >= minLevel and levelNum <= maxLevel) then
for catalogUnitId, killStatistics in pairs(levelStatistics.KillStatisticsByUnit) do
if (not killStatisticsDictionary[catalogUnitId]) then
killStatisticsDictionary[catalogUnitId] = KillStatistics.New()
end
for k, killTrackingType in pairs(AutoBiographerEnum.KillTrackingType) do
if (killStatistics[killTrackingType]) then
if (killStatisticsDictionary[catalogUnitId][killTrackingType] == nil) then killStatisticsDictionary[catalogUnitId][killTrackingType] = 0 end
killStatisticsDictionary[catalogUnitId][killTrackingType] = killStatisticsDictionary[catalogUnitId][killTrackingType] + killStatistics[killTrackingType]
end
end
end
end
end
return killStatisticsDictionary
end
function Controller:GetAggregatedOtherPlayerStatisticsByCatalogUnitId(catalogUnitId, minLevel, maxLevel)
local otherPlayerStatisticsByCatalogUnitId = OtherPlayerStatistics.New()
for levelNum, levelStatistics in pairs(self.CharacterData.Levels) do
if (levelNum >= minLevel and levelNum <= maxLevel) then
local otherPlayerStatistics = levelStatistics.OtherPlayerStatisticsByOtherPlayer[catalogUnitId]
if (otherPlayerStatistics) then
for k, otherPlayerTrackingType in pairs(AutoBiographerEnum.OtherPlayerTrackingType) do
if (otherPlayerStatistics[otherPlayerTrackingType]) then
if (otherPlayerStatisticsByCatalogUnitId[otherPlayerTrackingType] == nil) then otherPlayerStatisticsByCatalogUnitId[otherPlayerTrackingType] = 0 end
otherPlayerStatisticsByCatalogUnitId[otherPlayerTrackingType] = otherPlayerStatisticsByCatalogUnitId[otherPlayerTrackingType] + otherPlayerStatistics[otherPlayerTrackingType]
end
end
end
end
end
return otherPlayerStatisticsByCatalogUnitId
end
function Controller:GetAggregatedOtherPlayerStatisticsDictionary(minLevel, maxLevel)
local otherPlayerStatisticsDictionary = {}
for levelNum, levelStatistics in pairs(self.CharacterData.Levels) do
if (levelNum >= minLevel and levelNum <= maxLevel) then
for catalogUnitId, otherPlayerStatistics in pairs(levelStatistics.OtherPlayerStatisticsByOtherPlayer) do
if (not otherPlayerStatisticsDictionary[catalogUnitId]) then
otherPlayerStatisticsDictionary[catalogUnitId] = OtherPlayerStatistics.New()
end
for k, otherPlayerTrackingType in pairs(AutoBiographerEnum.OtherPlayerTrackingType) do
if (otherPlayerStatistics[otherPlayerTrackingType]) then
if (otherPlayerStatisticsDictionary[catalogUnitId][otherPlayerTrackingType] == nil) then otherPlayerStatisticsDictionary[catalogUnitId][otherPlayerTrackingType] = 0 end
otherPlayerStatisticsDictionary[catalogUnitId][otherPlayerTrackingType] = otherPlayerStatisticsDictionary[catalogUnitId][otherPlayerTrackingType] + otherPlayerStatistics[otherPlayerTrackingType]
end
end
end
end
end
return otherPlayerStatisticsDictionary
end
function Controller:GetAggregatedQuestStatisticsDictionary(minLevel, maxLevel)
local questStatisticsDictionary = {}
for levelNum, levelStatistics in pairs(self.CharacterData.Levels) do
if (levelNum >= minLevel and levelNum <= maxLevel) then
for questId, questStatistics in pairs(levelStatistics.QuestStatisticsByQuest) do
if (not questStatisticsDictionary[questId]) then
questStatisticsDictionary[questId] = QuestStatistics.New()
end
for k, questTrackingType in pairs(AutoBiographerEnum.QuestTrackingType) do
if (questStatistics[questTrackingType]) then
if (questStatisticsDictionary[questId][questTrackingType] == nil) then questStatisticsDictionary[questId][questTrackingType] = 0 end
questStatisticsDictionary[questId][questTrackingType] = questStatisticsDictionary[questId][questTrackingType] + questStatistics[questTrackingType]
end
end
end
end
end
return questStatisticsDictionary
end
function Controller:GetAggregatedQuestStatisticsTotals(minLevel, maxLevel, questStatisticsDictionary)
if (not questStatisticsDictionary) then questStatisticsDictionary = self:GetAggregatedQuestStatisticsDictionary(minLevel, maxLevel) end
local totalsQuestStatistics = QuestStatistics.New()
for catalogUnitId, questStatistics in pairs(questStatisticsDictionary) do
for k, questTrackingType in pairs(AutoBiographerEnum.QuestTrackingType) do
if (questStatistics[questTrackingType]) then
if (totalsQuestStatistics[questTrackingType] == nil) then totalsQuestStatistics[questTrackingType] = 0 end
totalsQuestStatistics[questTrackingType] = totalsQuestStatistics[questTrackingType] + questStatistics[questTrackingType]
end
end
end
return totalsQuestStatistics
end
function Controller:GetAggregatedSpellStatisticsDictionary(minLevel, maxLevel)
local spellStatisticsDictionary = {}
for levelNum, levelStatistics in pairs(self.CharacterData.Levels) do
if (levelNum >= minLevel and levelNum <= maxLevel) then
for catalogSpellId, spellStatistics in pairs(levelStatistics.SpellStatisticsBySpell) do
if (not spellStatisticsDictionary[catalogSpellId]) then
spellStatisticsDictionary[catalogSpellId] = SpellStatistics.New()
end
for k, spellTrackingType in pairs(AutoBiographerEnum.SpellTrackingType) do
if (spellStatistics[spellTrackingType]) then
if (spellStatisticsDictionary[catalogSpellId][spellTrackingType] == nil) then spellStatisticsDictionary[catalogSpellId][spellTrackingType] = 0 end
spellStatisticsDictionary[catalogSpellId][spellTrackingType] = spellStatisticsDictionary[catalogSpellId][spellTrackingType] + spellStatistics[spellTrackingType]
end
end
end
end
end
return spellStatisticsDictionary
end
function Controller:GetAggregatedTimeStatisticsDictionary(minLevel, maxLevel)
local timeStatisticsDictionary = {}
for levelNum, levelStatistics in pairs(self.CharacterData.Levels) do
if (levelNum >= minLevel and levelNum <= maxLevel) then
for areaId, timeStatistics in pairs(levelStatistics.TimeStatisticsByArea) do
if (not timeStatisticsDictionary[areaId]) then
timeStatisticsDictionary[areaId] = TimeStatistics.New()
end
for k, timeTrackingType in pairs(AutoBiographerEnum.TimeTrackingType) do
if (timeStatistics[timeTrackingType]) then
if (timeStatisticsDictionary[areaId][timeTrackingType] == nil) then timeStatisticsDictionary[areaId][timeTrackingType] = 0 end
timeStatisticsDictionary[areaId][timeTrackingType] = timeStatisticsDictionary[areaId][timeTrackingType] + timeStatistics[timeTrackingType]
end
end
end
end
end
return timeStatisticsDictionary
end
function Controller:GetArenaStatsByRegistrationTypeAndTeamSize(registered, teamSize, minLevel, maxLevel)
local joined = 0
local losses = 0
local wins = 0
for k,v in pairs(self.CharacterData.Levels) do
if (k >= minLevel and k <= maxLevel) then
local subObject
if (registered) then subObject = v.ArenaStatistics.Registered
else subObject = v.ArenaStatistics.Unregistered
end
if (subObject and subObject[teamSize]) then
joined = joined + subObject[teamSize].joined
losses = losses + subObject[teamSize].losses
wins = wins + subObject[teamSize].wins
end
end
end
return joined, losses, wins
end
function Controller:GetBattlegroundStatsByBattlegroundId(battlegroundId, minLevel, maxLevel)
local joined = 0
local losses = 0
local wins = 0
for k,v in pairs(self.CharacterData.Levels) do
if (k >= minLevel and k <= maxLevel) then
if (v.BattlegroundStatistics[battlegroundId]) then
joined = joined + v.BattlegroundStatistics[battlegroundId].joined
losses = losses + v.BattlegroundStatistics[battlegroundId].losses
wins = wins + v.BattlegroundStatistics[battlegroundId].wins
end
end
end
return joined, losses, wins
end
function Controller:GetCurrentLevelNum()
return HelperFunctions.GetLastKeyFromTable(self.CharacterData.Levels)
end
function Controller:GetCurrentLevelStatistics()
return self.CharacterData.Levels[self:GetCurrentLevelNum()]
end
function Controller:GetDamageOrHealing(damageOrHealingCategory, minLevel, maxLevel)
local amountSum = 0
local overSum = 0
for k,v in pairs(self.CharacterData.Levels) do
if (k >= minLevel and k <= maxLevel) then
if (v.DamageStatistics[damageOrHealingCategory]) then
amountSum = amountSum + v.DamageStatistics[damageOrHealingCategory].Amount
overSum = overSum + v.DamageStatistics[damageOrHealingCategory].Over
end
end
end
return amountSum, overSum
end
function Controller:GetDeathsByDeathTrackingType(deathTrackingType, minLevel, maxLevel)
local sum = 0
for k,v in pairs(self.CharacterData.Levels) do
if (k >= minLevel and k <= maxLevel) then
if (v.DeathStatistics[deathTrackingType]) then
sum = sum + v.DeathStatistics[deathTrackingType]
end
end
end
return sum
end
function Controller:GetEvents()
return self.CharacterData.Events
end
function Controller:GetEventString(event)
return Event.ToString(event, self.CharacterData.Catalogs)
end
function Controller:GetExperienceByExperienceTrackingType(experienceTrackingType, minLevel, maxLevel)
local sum = 0
for k,v in pairs(self.CharacterData.Levels) do
if (k >= minLevel and k <= maxLevel) then
if (v.ExperienceStatistics[experienceTrackingType]) then
sum = sum + v.ExperienceStatistics[experienceTrackingType]
end
end
end
return sum
end
function Controller:GetItemCountForAcquisitionMethod(itemAcquisitionMethod, minLevel, maxLevel)
local sum = 0
for k,v in pairs(self.CharacterData.Levels) do
if (k >= minLevel and k <= maxLevel) then
for k2,v2 in pairs(v.ItemStatisticsByItem) do
if (v2[itemAcquisitionMethod]) then
sum = sum + v2[itemAcquisitionMethod]
end
end
end
end
return sum
end
function Controller:GetLogs()
return self.Logs
end
function Controller:GetMiscellaneousStatByMiscellaneousTrackingType(miscellaneousTrackingType, minLevel, maxLevel)
local sum = 0
for k,v in pairs(self.CharacterData.Levels) do
if (k >= minLevel and k <= maxLevel) then
if (v.MiscellaneousStatistics[miscellaneousTrackingType]) then
sum = sum + v.MiscellaneousStatistics[miscellaneousTrackingType]
end
end
end
return sum
end
function Controller:GetMoneyForAcquisitionMethod(moneyAcquisitionMethod, minLevel, maxLevel)
local sum = 0
for k,v in pairs(self.CharacterData.Levels) do
if (k >= minLevel and k <= maxLevel) then
if (v.MoneyStatistics[moneyAcquisitionMethod]) then
sum = sum + v.MoneyStatistics[moneyAcquisitionMethod]
end
end
end
return sum
end
function Controller:GetNotes()
return self.CharacterData.Notes
end
function Controller:GetOtherPlayerStatByOtherPlayerTrackingType(otherPlayerTrackingType, minLevel, maxLevel)
local sum = 0
for k,v in pairs(self.CharacterData.Levels) do
if (k >= minLevel and k <= maxLevel) then
for k2,v2 in pairs(v.OtherPlayerStatisticsByOtherPlayer) do
if (v2[otherPlayerTrackingType]) then
sum = sum + v2[otherPlayerTrackingType]
end
end
end
end
return sum
end
function Controller:GetSpellCountBySpellTrackingType(spellTrackingType, minLevel, maxLevel)
local sum = 0
for k,v in pairs(self.CharacterData.Levels) do
if (k >= minLevel and k <= maxLevel) then
for k2,v2 in pairs(v.SpellStatisticsBySpell) do
if (v2[spellTrackingType]) then
sum = sum + v2[spellTrackingType]
end
end
end
end
return sum
end
function Controller:GetTotalMoneyGained(minLevel, maxLevel)
local sum = 0
for k,v in pairs(self.CharacterData.Levels) do
if (k >= minLevel and k <= maxLevel) then
sum = sum + v.MoneyStatistics.TotalMoneyGained
end
end
return sum
end
function Controller:GetTotalMoneyLost(minLevel, maxLevel)
local sum = 0
for k,v in pairs(self.CharacterData.Levels) do
if (k >= minLevel and k <= maxLevel) then
sum = sum + v.MoneyStatistics.TotalMoneyLost
end
end
return sum
end
function Controller:GetTimeForTimeTrackingType(timeTrackingType, minLevel, maxLevel)
local sum = 0
for k,v in pairs(self.CharacterData.Levels) do
if (k >= minLevel and k <= maxLevel) then
for k2,v2 in pairs(v.TimeStatisticsByArea) do
if (v2[timeTrackingType]) then
sum = sum + v2[timeTrackingType]
end
end
end
end
return sum
end
-- *** Events ***
function Controller:OnAchievementEarned(achievementId)
if (AutoBiographer_Settings.Options["TakeScreenshotOnAchievementEarned"]) then
self:TakeScreenshot(1.0)
end
end
function Controller:OnAcquiredItem(timestamp, coordinates, itemAcquisitionMethod, catalogItem, quantity)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("AcquiredItem: " .. CatalogItem.ToString(catalogItem) .. ". Quantity: " .. tostring(quantity) .. ". Method: " .. tostring(itemAcquisitionMethod) .. ".", AutoBiographerEnum.LogLevel.Debug) end
if (not Catalogs.PlayerHasAcquiredItem(self.CharacterData.Catalogs, catalogItem.Id)) then
catalogItem.Acquired = true
self:UpdateCatalogItem(catalogItem)
self:AddEvent(FirstAcquiredItemEvent.New(timestamp, coordinates, catalogItem.Id))
end
if (not self:GetCurrentLevelStatistics().ItemStatisticsByItem[catalogItem.Id]) then self:GetCurrentLevelStatistics().ItemStatisticsByItem[catalogItem.Id] = ItemStatistics.New() end
ItemStatistics.AddCount(self:GetCurrentLevelStatistics().ItemStatisticsByItem[catalogItem.Id], itemAcquisitionMethod, quantity)
end
function Controller:OnArenaFinished(timestamp, registered, teamSize, arenaId, playerWon)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("ArenaFinished: " .. tostring(registered) .. ", " .. tostring(teamSize) .. ", " .. tostring(arenaId) .. ", " .. tostring(playerWon) .. ".", AutoBiographerEnum.LogLevel.Debug) end
if (playerWon) then
self:AddEvent(ArenaWonEvent.New(timestamp, registered, teamSize, arenaId))
ArenaStatistics.IncrementWins(self:GetCurrentLevelStatistics().ArenaStatistics, registered, teamSize)
else
self:AddEvent(ArenaLostEvent.New(timestamp, registered, teamSize, arenaId))
ArenaStatistics.IncrementLosses(self:GetCurrentLevelStatistics().ArenaStatistics, registered, teamSize)
end
end
function Controller:OnArenaJoined(timestamp, registered, teamSize, arenaId)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("ArenaJoined: " .. tostring(registered) .. ", " .. tostring(teamSize) .. ", " .. tostring(arenaId) .. ", " .. tostring(playerWon) .. ".", AutoBiographerEnum.LogLevel.Debug) end
self:AddEvent(ArenaJoinedEvent.New(timestamp, registered, teamSize, arenaId))
ArenaStatistics.IncrementJoined(self:GetCurrentLevelStatistics().ArenaStatistics, registered, teamSize)
end
function Controller:OnBattlegroundFinished(timestamp, battlegroundId, playerWon)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("BattlegroundFinished: " .. tostring(battlegroundId) .. ", " .. tostring(playerWon) .. ".", AutoBiographerEnum.LogLevel.Debug) end
if (playerWon) then
self:AddEvent(BattlegroundWonEvent.New(timestamp, battlegroundId))
BattlegroundStatistics.IncrementWins(self:GetCurrentLevelStatistics().BattlegroundStatistics, battlegroundId)
else
self:AddEvent(BattlegroundLostEvent.New(timestamp, battlegroundId))
BattlegroundStatistics.IncrementLosses(self:GetCurrentLevelStatistics().BattlegroundStatistics, battlegroundId)
end
end
function Controller:OnBattlegroundJoined(timestamp, battlegroundId)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("BattlegroundJoined: " .. tostring(battlegroundId) .. ".", AutoBiographerEnum.LogLevel.Debug) end
self:AddEvent(BattlegroundJoinedEvent.New(timestamp, battlegroundId))
BattlegroundStatistics.IncrementJoined(self:GetCurrentLevelStatistics().BattlegroundStatistics, battlegroundId)
end
function Controller:OnBossKill(timestamp, coordinates, bossId, bossName, hasKilledBossBefore)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("BossKill: " .. tostring(bossName) .. " (#" .. tostring(bossId) .. ").", AutoBiographerEnum.LogLevel.Debug) end
local catalogUnit = self.CharacterData.Catalogs.UnitCatalog[bossId]
local isFromRegularKillEvent = catalogUnit ~= nil and catalogUnit.Name == bossName
local matchingBossKillEvent = nil
local matchingEventIndex = #self.CharacterData.Events
while (matchingBossKillEvent == nil and timestamp - self.CharacterData.Events[matchingEventIndex].Timestamp < 2) do
local event = self.CharacterData.Events[matchingEventIndex]
if (event.Type == AutoBiographerEnum.EventType.Kill and event.SubType == AutoBiographerEnum.EventSubType.BossKill and event.BossName == bossName) then
matchingBossKillEvent = event
else
matchingEventIndex = matchingEventIndex - 1
end
end
if (matchingBossKillEvent ~= nil) then
if (isFromRegularKillEvent) then
Controller:AddLog("This is a regular unit kill and I found a matching boss kill event from an actual boss. Returning.", AutoBiographerEnum.LogLevel.Debug)
return
else
Controller:AddLog("This is a boss unit kill and I found a matching boss kill event from a regular unit. Deleting other event.", AutoBiographerEnum.LogLevel.Debug)
local indexesToDelete = {}
indexesToDelete[matchingEventIndex] = true
HelperFunctions.RemoveElementsFromArrayAtIndexes(self.CharacterData.Events, indexesToDelete)
hasKilledBossBefore = true
end
end
self:AddEvent(BossKillEvent.New(timestamp, coordinates, bossId, bossName))
if (AutoBiographer_Settings.Options["TakeScreenshotOnBossKill"] and (not AutoBiographer_Settings.Options["TakeScreenshotOnlyOnFirstBossKill"] or not hasKilledBossBefore)) then
self:TakeScreenshot(0.5)
end
end
function Controller:OnChangedSubZone(timestamp, coordinates, zoneName, subZoneName)
if (subZoneName == nil or subZoneName == "") then return end
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("ChangedSubZone: " .. tostring(subZoneName) .. " (" .. tostring(zoneName) .. ").", AutoBiographerEnum.LogLevel.Debug) end
if (self.CharacterData.Catalogs.SubZoneCatalog[subZoneName] == nil) then
self.CharacterData.Catalogs.SubZoneCatalog[subZoneName] = CatalogSubZone.New(subZoneName, true, zoneName)
self:AddEvent(SubZoneFirstVisitEvent.New(timestamp, coordinates, subZoneName))
end
end
function Controller:OnChangedZone(timestamp, coordinates, zoneName)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("ChangedZone: " .. tostring(zoneName) .. ".", AutoBiographerEnum.LogLevel.Debug) end
if (self.CharacterData.Catalogs.ZoneCatalog[zoneName] == nil) then
self.CharacterData.Catalogs.ZoneCatalog[zoneName] = CatalogZone.New(zoneName, true)
self:AddEvent(ZoneFirstVisitEvent.New(timestamp, coordinates, zoneName))
end
end
function Controller:OnDamageOrHealing(damageOrHealingCategory, amount, overkill)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("DamageOrHealingCategory: " .. tostring(damageOrHealingCategory) .. ". Amount: " .. tostring(amount) .. ", over: " .. tostring(overkill), AutoBiographerEnum.LogLevel.Debug) end
DamageStatistics.Add(self:GetCurrentLevelStatistics().DamageStatistics, damageOrHealingCategory, amount, overkill)
if (AutoBiographer_Settings.Options["EnableMilestoneMessages"]) then
local damageOrHealingMilestoneThreshold
if (self:GetCurrentLevelNum() < 30) then
damageOrHealingMilestoneThreshold = 100000
elseif (self:GetCurrentLevelNum() < 60) then
damageOrHealingMilestoneThreshold = 1000000
elseif (self:GetCurrentLevelNum() < 70) then
damageOrHealingMilestoneThreshold = 5000000
elseif (self:GetCurrentLevelNum() < 80) then
damageOrHealingMilestoneThreshold = 10000000
else
damageOrHealingMilestoneThreshold = 20000000
end
if (damageOrHealingCategory == AutoBiographerEnum.DamageOrHealingCategory.DamageDealt) then
if (self.Temp.LastMilestoneMessageDamageCheckTimestamp and GetTime() - self.Temp.LastMilestoneMessageDamageCheckTimestamp < 1) then
if (not self.Temp.IsPendingMilestoneMessageDamageCheck) then
self.Temp.IsPendingMilestoneMessageDamageCheck = true
C_Timer.After(GetTime() - self.Temp.LastMilestoneMessageDamageCheckTimestamp, function()
Controller:CheckDamageForMilestoneMessage(amount, damageOrHealingMilestoneThreshold)
end)
end
else
Controller:CheckDamageForMilestoneMessage(amount, damageOrHealingMilestoneThreshold)
end
elseif (damageOrHealingCategory == AutoBiographerEnum.DamageOrHealingCategory.HealingDealtToOthers or
damageOrHealingCategory == AutoBiographerEnum.DamageOrHealingCategory.HealingDealtToSelf) then
if (self.Temp.LastMilestoneMessageHealingCheckTimestamp and GetTime() - self.Temp.LastMilestoneMessageHealingCheckTimestamp < 1) then
if (not self.Temp.IsPendingMilestoneMessageHealingCheck) then
self.Temp.IsPendingMilestoneMessageHealingCheck = true
C_Timer.After(GetTime() - self.Temp.LastMilestoneMessageHealingCheckTimestamp, function()
Controller:CheckHealingForMilestoneMessage(amount, damageOrHealingMilestoneThreshold)
end)
end
else
Controller:CheckHealingForMilestoneMessage(amount, damageOrHealingMilestoneThreshold)
end
end
end
end
function Controller:CheckDamageForMilestoneMessage(thisAmount, threshold)
self.Temp.IsPendingMilestoneMessageDamageCheck = false
self.Temp.LastMilestoneMessageDamageCheckTimestamp = GetTime()
local totalDamage = self:GetDamageOrHealing(AutoBiographerEnum.DamageOrHealingCategory.DamageDealt, 1, self:GetCurrentLevelNum())
local damageDifference = thisAmount
if (self.Temp.LastMilestoneMessageDamageCheckTotalDamageDealt ~= nil) then
damageDifference = totalDamage - self.Temp.LastMilestoneMessageDamageCheckTotalDamageDealt
end
-- print("Total damage: " .. totalDamage .. ". Last total damage: " .. tostring(self.Temp.LastMilestoneMessageDamageCheckTotalDamageDealt) .. ". Damage difference: " .. damageDifference)
if (totalDamage % threshold < damageDifference) then
print("\124cFFFFD700[AutoBiographer] You have dealt " .. HelperFunctions.CommaValue(HelperFunctions.Round(totalDamage / threshold) * threshold) .. " damage!")
end
self.Temp.LastMilestoneMessageDamageCheckTotalDamageDealt = totalDamage
end
function Controller:CheckHealingForMilestoneMessage(thisAmount, threshold)
self.Temp.IsPendingMilestoneMessageHealingCheck = false
self.Temp.LastMilestoneMessageHealingCheckTimestamp = GetTime()
local healingOtherAmount = self:GetDamageOrHealing(AutoBiographerEnum.DamageOrHealingCategory.HealingDealtToOthers, 1, self:GetCurrentLevelNum())
local healingSelfAmount = self:GetDamageOrHealing(AutoBiographerEnum.DamageOrHealingCategory.HealingDealtToSelf, 1, self:GetCurrentLevelNum())
local totalHealing = healingOtherAmount + healingSelfAmount
local healingDifference = thisAmount
if (self.Temp.LastMilestoneMessageDamageCheckTotalHealingDealt ~= nil) then
healingDifference = totalHealing - self.Temp.LastMilestoneMessageDamageCheckTotalHealingDealt
end
-- print("Total healing: " .. totalHealing .. ". Last total healing: " .. tostring(self.Temp.LastMilestoneMessageDamageCheckTotalHealingDealt) .. ". Healing difference: " .. healingDifference)
if (totalHealing % threshold < healingDifference) then
print("\124cFFFFD700[AutoBiographer] You have done " .. HelperFunctions.CommaValue(HelperFunctions.Round(totalHealing / threshold) * threshold) .. " healing!")
end
self.Temp.LastMilestoneMessageDamageCheckTotalHealingDealt = totalHealing
end
function Controller:OnDeath(timestamp, coordinates, killerCatalogUnitId, killerLevel)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("Death: " .. " #" .. tostring(killerCatalogUnitId) .. ".", AutoBiographerEnum.LogLevel.Debug) end
self:AddEvent(PlayerDeathEvent.New(timestamp, coordinates, killerCatalogUnitId, killerLevel))
local deathTrackingType
if (killerCatalogUnitId == nil) then
deathTrackingType = AutoBiographerEnum.DeathTrackingType.DeathToEnvironment
else
local killerUnitType = HelperFunctions.GetUnitTypeFromCatalogUnitId(killerCatalogUnitId)
if (killerUnitType == AutoBiographerEnum.UnitType.Creature) then
deathTrackingType = AutoBiographerEnum.DeathTrackingType.DeathToCreature
elseif (killerUnitType == AutoBiographerEnum.UnitType.GameObject) then
deathTrackingType = AutoBiographerEnum.DeathTrackingType.DeathToGameObject
elseif (killerUnitType == AutoBiographerEnum.UnitType.Pet) then
deathTrackingType = AutoBiographerEnum.DeathTrackingType.DeathToPet
elseif (killerUnitType == AutoBiographerEnum.UnitType.Player) then
deathTrackingType = AutoBiographerEnum.DeathTrackingType.DeathToPlayer
elseif (killerUnitType == AutoBiographerEnum.UnitType.Unknown) then
deathTrackingType = AutoBiographerEnum.DeathTrackingType.DeathToUnknown
end
end
if (not deathTrackingType) then
Controller:AddLog("Death not tracked. killerCatalogUnitId: '" .. tostring(killerCatalogUnitId) .. "'.", AutoBiographerEnum.LogLevel.Warning)
return
end
DeathStatistics.Increment(self:GetCurrentLevelStatistics().DeathStatistics, deathTrackingType)
end
function Controller:OnDuelLost(timestamp, coordinates, winnerCatalogUnitId, winnerName)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("DuelLost: " .. " #" .. tostring(winnerCatalogUnitId) .. " (" .. winnerName .. ").", AutoBiographerEnum.LogLevel.Debug) end
if (not winnerCatalogUnitId) then
Controller:AddLog("winnerCatalogUnitId was nil.", AutoBiographerEnum.LogLevel.Error)
return
end
if (not self:GetCurrentLevelStatistics().OtherPlayerStatisticsByOtherPlayer[winnerCatalogUnitId]) then self:GetCurrentLevelStatistics().OtherPlayerStatisticsByOtherPlayer[winnerCatalogUnitId] = OtherPlayerStatistics.New() end
OtherPlayerStatistics.Add(self:GetCurrentLevelStatistics().OtherPlayerStatisticsByOtherPlayer[winnerCatalogUnitId], AutoBiographerEnum.OtherPlayerTrackingType.DuelsWonAgainstPlayer, 1)
end
function Controller:OnDuelWon(timestamp, coordinates, loserCatalogUnitId, loserName)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("DuelWon: " .. " #" .. tostring(loserCatalogUnitId) .. " (" .. loserName .. ").", AutoBiographerEnum.LogLevel.Debug) end
if (not loserCatalogUnitId) then
Controller:AddLog("loserCatalogUnitId was nil.", AutoBiographerEnum.LogLevel.Error)
return
end
if (not self:GetCurrentLevelStatistics().OtherPlayerStatisticsByOtherPlayer[loserCatalogUnitId]) then self:GetCurrentLevelStatistics().OtherPlayerStatisticsByOtherPlayer[loserCatalogUnitId] = OtherPlayerStatistics.New() end
OtherPlayerStatistics.Add(self:GetCurrentLevelStatistics().OtherPlayerStatisticsByOtherPlayer[loserCatalogUnitId], AutoBiographerEnum.OtherPlayerTrackingType.DuelsLostToPlayer, 1)
end
function Controller:OnGainedExperience(timestamp, coordinates, experienceTrackingType, amount)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("GainedExperience: " .. tostring(amount) .. ". Experience Tracking Type: " .. tostring(experienceTrackingType) .. ".", AutoBiographerEnum.LogLevel.Debug) end
ExperienceStatistics.AddExperience(self:GetCurrentLevelStatistics().ExperienceStatistics, experienceTrackingType, amount)
end
function Controller:OnGainedMoney(timestamp, coordinates, moneyAcquisitionMethod, money)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("GainedMoney: " .. tostring(money) .. ". Acquisition Method: " .. tostring(moneyAcquisitionMethod) .. ".", AutoBiographerEnum.LogLevel.Debug) end
MoneyStatistics.AddMoney(self:GetCurrentLevelStatistics().MoneyStatistics, moneyAcquisitionMethod, money)
end
function Controller:OnGuildRankChanged(timestamp, guildRankIndex, guildRankName)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("GuildRankChanged: " .. " " .. tostring(guildRankName) .. " (" .. tostring(guildRankIndex) .. ").", AutoBiographerEnum.LogLevel.Debug) end
self:AddEvent(GuildRankChangedEvent.New(timestamp, guildRankIndex, guildRankName))
end
function Controller:OnJoinedGuild(timestamp, guildName)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("JoinedGuild: " .. " " .. tostring(guildName) .. ".", AutoBiographerEnum.LogLevel.Debug) end
self:AddEvent(GuildJoinedEvent.New(timestamp, guildName))
end
function Controller:OnJump(timestamp)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("Jump.", AutoBiographerEnum.LogLevel.Debug) end
MiscellaneousStatistics.Add(self:GetCurrentLevelStatistics().MiscellaneousStatistics, AutoBiographerEnum.MiscellaneousTrackingType.Jumps, 1)
if (AutoBiographer_Settings.Options["EnableMilestoneMessages"]) then
local jumpCount = self:GetMiscellaneousStatByMiscellaneousTrackingType(AutoBiographerEnum.MiscellaneousTrackingType.Jumps, 1, self:GetCurrentLevelNum())
if (jumpCount % 1000 == 0) then
print("\124cFFFFD700[AutoBiographer] You have jumped " .. HelperFunctions.CommaValue(jumpCount) .. " times!")
end
end
end
function Controller:OnKill(timestamp, coordinates, kill)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("Kill: " .. " #" .. tostring(kill.CatalogUnitId) .. ".", AutoBiographerEnum.LogLevel.Debug) end
if (not self:GetCurrentLevelStatistics().KillStatisticsByUnit[kill.CatalogUnitId]) then self:GetCurrentLevelStatistics().KillStatisticsByUnit[kill.CatalogUnitId] = KillStatistics.New() end
KillStatistics.AddKill(self:GetCurrentLevelStatistics().KillStatisticsByUnit[kill.CatalogUnitId], kill)
if (kill.PlayerHasTag) then
local hasKilledUnitBefore = true
if (not Catalogs.PlayerHasKilledUnit(self.CharacterData.Catalogs, kill.CatalogUnitId)) then
hasKilledUnitBefore = false
self:UpdateCatalogUnit(CatalogUnit.New(kill.CatalogUnitId, nil, nil, nil, nil, nil, nil, true, nil))
if (self.CharacterData.Catalogs.UnitCatalog[kill.CatalogUnitId].UType == AutoBiographerEnum.UnitType.Creature) then
self:AddEvent(FirstKillEvent.New(timestamp, coordinates, kill.CatalogUnitId))
end
end
if (AutoBiographer_Databases.BossDatabase[kill.CatalogUnitId]) then
Controller:OnBossKill(time(), HelperFunctions.GetCoordinatesByUnitId("player"), kill.CatalogUnitId, self.CharacterData.Catalogs.UnitCatalog[kill.CatalogUnitId].Name, hasKilledUnitBefore)
end
if (AutoBiographer_Settings.Options["EnableMilestoneMessages"]) then
if (self.Temp.LastMilestoneMessageKillsCheckTimestamp and GetTime() - self.Temp.LastMilestoneMessageKillsCheckTimestamp < 1) then
if (not self.Temp.IsPendingMilestoneMessageKillsCheck) then
self.Temp.IsPendingMilestoneMessageKillsCheck = true
C_Timer.After(GetTime() - self.Temp.LastMilestoneMessageKillsCheckTimestamp, function()
Controller:CheckKillsForMilestoneMessage()
end)
end
else
Controller:CheckKillsForMilestoneMessage()
end
end
end
end
function Controller:CheckKillsForMilestoneMessage()
self.Temp.IsPendingMilestoneMessageKillsCheck = false
self.Temp.LastMilestoneMessageKillsCheckTimestamp = GetTime()
local totalsKillStatistics = self:GetAggregatedKillStatisticsTotals(1, self:GetCurrentLevelNum())
local totalTaggedKills = KillStatistics.GetSum(totalsKillStatistics, { AutoBiographerEnum.KillTrackingType.TaggedAssist, AutoBiographerEnum.KillTrackingType.TaggedGroupAssistOrKillingBlow, AutoBiographerEnum.KillTrackingType.TaggedKillingBlow })
local killDifference = 1
if (self.Temp.LastMilestoneMessageKillsCheckTotalTaggedKills ~= nil) then
killDifference = totalTaggedKills - self.Temp.LastMilestoneMessageKillsCheckTotalTaggedKills
end
local threshold = 1000
if (totalTaggedKills % threshold < killDifference) then
print("\124cFFFFD700[AutoBiographer] You have " .. HelperFunctions.CommaValue(HelperFunctions.Round(totalTaggedKills / threshold) * threshold) .. " tagged kills!")
end
self.Temp.LastMilestoneMessageKillsCheckTotalTaggedKills = totalTaggedKills
end
function Controller:OnLeftGuild(timestamp, guildName)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("LeftGuild: " .. " " .. tostring(guildName) .. ".", AutoBiographerEnum.LogLevel.Debug) end
self:AddEvent(GuildLeftEvent.New(timestamp, guildName))
end
function Controller:OnLevelUp(timestamp, coordinates, levelNum, totalTimePlayedAtDing)
if self.CharacterData.Levels[levelNum] ~= nil then error("Can not add level " .. levelNum .. " because it was already added.") end
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("LevelUp: " .. tostring(levelNum) .. ", " .. HelperFunctions.SecondsToTimeString(totalTimePlayedAtDing) .. ".", AutoBiographerEnum.LogLevel.Debug) end
self.CharacterData.Levels[levelNum] = LevelStatistics.New(levelNum, totalTimePlayedAtDing, nil)
local currentLevel = self.CharacterData.Levels[levelNum]
local previousLevel = self.CharacterData.Levels[levelNum - 1]
if (previousLevel and previousLevel.TotalTimePlayedAtDing and currentLevel.TotalTimePlayedAtDing) then
previousLevel.TimePlayedThisLevel = currentLevel.TotalTimePlayedAtDing - previousLevel.TotalTimePlayedAtDing
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("Time played last level = " .. HelperFunctions.SecondsToTimeString(previousLevel.TimePlayedThisLevel), AutoBiographerEnum.LogLevel.Debug) end
end
if (timestamp) then
self:AddEvent(LevelUpEvent.New(timestamp, coordinates, levelNum))
if (AutoBiographer_Settings.Options["TakeScreenshotOnLevelUp"] and levelNum > 1) then
self:TakeScreenshot(1.0)
end
end
if (AutoBiographer_Settings.Options["ShowLowRankCombatSkillWarnings"]) then
C_Timer.After(10, function()
self:CheckForLowRankSkills()
end)
end
end
function Controller:CheckForLowRankSkills()
local mainHandItemLink = GetInventoryItemLink("player", 16)
local mainHandItemSubType = nil
if (mainHandItemLink) then
_, _, _, _, _, _, mainHandItemSubType, _, _, _, _ = GetItemInfo(mainHandItemLink)
end
local offHandItemLink = GetInventoryItemLink("player", 17)
local offHandItemSubType = nil
if (offHandItemLink) then
_, _, _, _, _, _, offHandItemSubType, _, _, _, _ = GetItemInfo(offHandItemLink)
end
local rangedItemLink = GetInventoryItemLink("player", 18)
local rangedItemSubType = nil
if (rangedItemLink) then
_, _, _, _, _, _, rangedItemSubType, _, _, _, _ = GetItemInfo(rangedItemLink)
end
local lowRankSkills = {}
for skillIndex = 1, GetNumSkillLines() do
local skillName, isHeader, isExpanded, skillRank, numTempPoints, skillModifier,
skillMaxRank, isAbandonable, stepCost, rankCost, minLevel, skillCostType,
skillDescription = GetSkillLineInfo(skillIndex)
if (not isHeader and skillRank < skillMaxRank - 10 and
(skillName == "Defense" or skillName == mainHandItemSubType or skillName == offHandItemSubType or skillName == rangedItemSubType)) then
-- print(string.format("Skill: %s - %s", skillName, skillRank))
lowRankSkills[#lowRankSkills + 1] = {
skillName = skillName,
skillRank = skillRank,
skillMaxRank = skillMaxRank,
}
end
end
if (#lowRankSkills == 0) then
return
end
local lowRankSkillsString = ""
for i = 1, #lowRankSkills do
if (i > 1) then
lowRankSkillsString = lowRankSkillsString .. ", "
end
lowRankSkillsString = lowRankSkillsString .. lowRankSkills[i].skillName .. " (" .. lowRankSkills[i].skillRank .. "/" .. lowRankSkills[i].skillMaxRank .. ")"
end
local pluralS = #lowRankSkills ~= 1 and "s" or ""
print("\124cFFFFD700[AutoBiographer] Your character has a low rank in " .. #lowRankSkills .. " important combat skill" .. pluralS .. ": " .. lowRankSkillsString)
end
function Controller:OnMoneyChanged(timestamp, coordinates, deltaMoney)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("MoneyChanged: " .. tostring(deltaMoney) .. ".", AutoBiographerEnum.LogLevel.Debug) end
MoneyStatistics.TotalMoneyChanged(self:GetCurrentLevelStatistics().MoneyStatistics, deltaMoney)
end
function Controller:OnQuestTurnedIn(timestamp, coordinates, questId, questTitle, xpGained, moneyGained)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("QuestTurnedIn: " .. tostring(questTitle) .. " (#" .. tostring(questId) .. "), " .. tostring(xpGained) .. ", " .. tostring(moneyGained) .. ".", AutoBiographerEnum.LogLevel.Debug) end
self:AddEvent(QuestTurnInEvent.New(timestamp, coordinates, questId, questTitle, xpGained, moneyGained))
if (not self:GetCurrentLevelStatistics().QuestStatisticsByQuest[questId]) then self:GetCurrentLevelStatistics().QuestStatisticsByQuest[questId] = QuestStatistics.New() end
QuestStatistics.Increment(self:GetCurrentLevelStatistics().QuestStatisticsByQuest[questId], AutoBiographerEnum.QuestTrackingType.Completed)
if (AutoBiographer_Settings.Options["EnableMilestoneMessages"]) then
local aggregatedQuestStatisticsDictionary = self:GetAggregatedQuestStatisticsDictionary(1, self:GetCurrentLevelNum())
local totalsQuestStatistics = self:GetAggregatedQuestStatisticsTotals(1, self:GetCurrentLevelNum(), aggregatedQuestStatisticsDictionary)
local totalQuestsCompleted = QuestStatistics.GetSum(totalsQuestStatistics, { AutoBiographerEnum.QuestTrackingType.Completed })
if (totalQuestsCompleted % 100 == 0) then
print("\124cFFFFD700[AutoBiographer] You have completed " .. HelperFunctions.CommaValue(totalQuestsCompleted) .. " quests!")
end
end
end
function Controller:OnReputationLevelChanged(timestamp, coordinates, faction, reputationLevel)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("ReputationLevelChanged: " .. tostring(faction) .. ", " .. tostring(reputationLevel) .. ".", AutoBiographerEnum.LogLevel.Debug) end
self:AddEvent(ReputationLevelChangedEvent.New(timestamp, coordinates, faction, reputationLevel))
end
function Controller:OnSpellLearned(timestamp, coordinates, spellId, spellName, spellRank)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("SpellLearned: " .. tostring(spellName) .. " (#" .. tostring(spellId) .. "), " .. tostring(spellRank) .. ".", AutoBiographerEnum.LogLevel.Debug) end
if (not self.CharacterData.Catalogs.SpellCatalog[spellId]) then
self.CharacterData.Catalogs.SpellCatalog[spellId] = CatalogSpell.New(spellId, spellName, spellRank)
self:AddEvent(SpellLearnedEvent.New(timestamp, coordinates, spellId))
end
end
function Controller:OnSpellStartedCasting(timestamp, coordinates, spellId, spellName, spellRank)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("SpellStartedCasting: " .. tostring(spellName) .. " (#" .. tostring(spellId) .. "), " .. tostring(spellRank) .. ".", AutoBiographerEnum.LogLevel.Debug) end
if (not spellId) then
Controller:AddLog("spellId was nil.", AutoBiographerEnum.LogLevel.Error)
return
end
if (not self.CharacterData.Catalogs.SpellCatalog[spellId]) then
self.CharacterData.Catalogs.SpellCatalog[spellId] = CatalogSpell.New(spellId, spellName, spellRank)
end
if (not self:GetCurrentLevelStatistics().SpellStatisticsBySpell[spellId]) then self:GetCurrentLevelStatistics().SpellStatisticsBySpell[spellId] = SpellStatistics.New() end
SpellStatistics.Increment(self:GetCurrentLevelStatistics().SpellStatisticsBySpell[spellId], AutoBiographerEnum.SpellTrackingType.StartedCasting)
end
function Controller:OnSpellSuccessfullyCast(timestamp, coordinates, spellId, spellName, spellRank)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("SpellSuccessfullyCast: " .. tostring(spellName) .. " (#" .. tostring(spellId) .. "), " .. tostring(spellRank) .. ".", AutoBiographerEnum.LogLevel.Debug) end
if (not spellId) then
Controller:AddLog("spellId was nil.", AutoBiographerEnum.LogLevel.Error)
return
end
if (not self.CharacterData.Catalogs.SpellCatalog[spellId]) then
self.CharacterData.Catalogs.SpellCatalog[spellId] = CatalogSpell.New(spellId, spellName, spellRank)
end
if (not self:GetCurrentLevelStatistics().SpellStatisticsBySpell[spellId]) then self:GetCurrentLevelStatistics().SpellStatisticsBySpell[spellId] = SpellStatistics.New() end
SpellStatistics.Increment(self:GetCurrentLevelStatistics().SpellStatisticsBySpell[spellId], AutoBiographerEnum.SpellTrackingType.SuccessfullyCast)
end
function Controller:OnSkillLevelIncreased(timestamp, coordinates, skillName, skillLevel)
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("SkillLevelIncreased: " .. " " .. tostring(skillName) .. " (" .. tostring(skillLevel) .. ").", AutoBiographerEnum.LogLevel.Debug) end
if (skillLevel % 75 == 0) then
self:AddEvent(SkillMilestoneEvent.New(timestamp, coordinates, skillName, skillLevel))
end
end
function Controller:PrintEvents()
for _,v in pairs(self.CharacterData.Events) do
print(Event.ToString(v, self.CharacterData.Catalogs))
end
end
function Controller:PrintLastEvent()
print(Event.ToString(self.CharacterData.Events[#self.CharacterData.Events], self.CharacterData.Catalogs))
end
function Controller:TakeScreenshot(secondsToDelay)
if (not secondsToDelay) then secondsToDelay = 0 end
C_Timer.After(secondsToDelay, function()
if (self.Temp.LastScreenshotTimestamp and GetTime() - self.Temp.LastScreenshotTimestamp < 1) then
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then print("[AutoBiographer] Skipping screenshot, another was just taken.") end
return
end
self.Temp.LastScreenshotTimestamp = GetTime()
Screenshot()
if (AutoBiographer_Settings.Options["EnableDebugLogging"]) then Controller:AddLog("Screenshot captured after" .. tostring(secondsToDelay) .. "s delay .", AutoBiographerEnum.LogLevel.Debug) end
end)
end
function Controller:UpdateCatalogBoss(catalogBoss)
if (self.CharacterData.Catalogs.BossCatalog[catalogBoss.Id] == nil) then
self.CharacterData.Catalogs.BossCatalog[catalogBoss.Id] = catalogBoss
else
CatalogBoss.Update(self.CharacterData.Catalogs.BossCatalog[catalogBoss.Id], catalogBoss.Id, catalogBoss.Name, catalogBoss.Killed)
end