forked from BobSemple/LFT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LFT.lua
5068 lines (4361 loc) · 185 KB
/
LFT.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
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
BINDING_HEADER_LFT = "Looking For Turtles"
BINDING_NAME_LFT = "Togle Turtle Finder"
local _G, _ = _G or getfenv()
local LFT = CreateFrame("Frame")
local me = UnitName('player')
local addonVer = '0.0.3.3'
local LFT_ADDON_CHANNEL = 'LFT'
local groupsFormedThisSession = 0
-- check: while in group, window closes at 0 and 30
-- check: rare case when goingWith is sent but i join a manual group and someone with lft
-- will invite me (maybe add a not inGroup check before sending goingWith)
-- todo : stats like "x players is looking for groups at the moment" available at all times
--- [5:09 PM] Dogenovi: LFM Idea: Group forming for elite quests.
--- Group forms when 3 players accumulate
--- Doesn't respect class roles (They are not too important for outdoor content as you don't engage a lot of mobs at once)
--- Keeps looking for players after a party of 3 is formed.
ROLE_TANK_TOOLTIP = 'Indicates that you are willing to\nprotect allies from harm by\nensuring that enemies are\nattacking you instead of them.'
ROLE_HEALER_TOOLTIP = 'Indicates that you are willing to\nheal your allies when they take\ndamage.'
ROLE_DAMAGE_TOOLTIP = 'Indicates that you are willing to\ntake on the role of dealing\ndamage to enemies.'
ROLE_BAD_TOOLTIP = 'Your class may not perform this role.'
LFT.tab = 1
LFT.dungeonsSpam = {}
LFT.dungeonsSpamDisplay = {}
LFT.dungeonsSpamDisplayLFM = {}
LFT.browseFrames = {}
LFT.showedUpdateNotification = false
LFT.maxDungeonsInQueue = 5
LFT.groupSizeMax = 5
LFT.class = ''
LFT.channel = LFT_ADDON_CHANNEL
LFT.channelIndex = 0
LFT.level = UnitLevel('player')
LFT.findingGroup = false
LFT.findingMore = false
LFT:RegisterEvent("ADDON_LOADED")
LFT:RegisterEvent("PLAYER_ENTERING_WORLD")
LFT:RegisterEvent("PARTY_MEMBERS_CHANGED")
LFT:RegisterEvent("PARTY_LEADER_CHANGED")
LFT:RegisterEvent("PLAYER_LEVEL_UP")
LFT:RegisterEvent("PLAYER_TARGET_CHANGED")
LFT.availableDungeons = {}
LFT.group = {}
LFT.oneGroupFull = false
LFT.groupFullCode = ''
LFT.acceptNextInvite = false
LFT.onlyAcceptFrom = ''
LFT.queueStartTime = 0
LFT.averageWaitTime = 0
LFT.types = {
[1] = 'Suggested Dungeons',
-- [2] = 'Random Dungeon',
[3] = 'All Available Dungeons',
--[4] = 'Elite Quests'
}
local TYPE_ELITE_QUESTS = 4
LFT.quests = {}
LFT.maxDungeonsList = 11
LFT.minimapFrames = {}
LFT.myRandomTime = 0
LFT.random_min = 0
LFT.random_max = 5
LFT.RESET_TIME = 0
LFT.TANK_TIME = 2
LFT.HEALER_TIME = 10
LFT.DAMAGE_TIME = 18
LFT.FULLCHECK_TIME = 26 --time when checkGroupFull is called, has to wait for goingWith messages
LFT.TIME_MARGIN = 30
LFT.ROLE_CHECK_TIME = 50
LFT.foundGroup = false
LFT.inGroup = false
LFT.isLeader = false
LFT.LFMGroup = {}
LFT.LFMDungeonCode = ''
LFT.currentGroupSize = 1
LFT.objectivesFrames = {}
LFT.peopleLookingForGroups = 0
LFT.peopleLookingForGroupsDisplay = 0
LFT.gotOnline = false
LFT.gotUptime = false
LFT.gotTimeFromServer = false
LFT.sentServerInfoRequest = false
LFT.hookExecutions = 0
LFT.currentGroupRoles = {}
LFT.supress = {}
LFT.classColors = {
["warrior"] = { r = 0.78, g = 0.61, b = 0.43, c = "|cffc79c6e" },
["mage"] = { r = 0.41, g = 0.8, b = 0.94, c = "|cff69ccf0" },
["rogue"] = { r = 1, g = 0.96, b = 0.41, c = "|cfffff569" },
["druid"] = { r = 1, g = 0.49, b = 0.04, c = "|cffff7d0a" },
["hunter"] = { r = 0.67, g = 0.83, b = 0.45, c = "|cffabd473" },
["shaman"] = { r = 0.14, g = 0.35, b = 1.0, c = "|cff0070de" },
["priest"] = { r = 1, g = 1, b = 1, c = "|cffffffff" },
["warlock"] = { r = 0.58, g = 0.51, b = 0.79, c = "|cff9482c9" },
["paladin"] = { r = 0.96, g = 0.55, b = 0.73, c = "|cfff58cba" }
}
--quest watcher
local LFTQuestWatcher = CreateFrame("Frame")
--LFTQuestWatcher:RegisterEvent("QUEST_ACCEPTED")
--LFTQuestWatcher:RegisterEvent("QUEST_REMOVED")
--LFTQuestWatcher:RegisterEvent("QUEST_TURNED_IN")
LFTQuestWatcher:RegisterEvent("QUEST_LOG_UPDATE")
LFTQuestWatcher:Show()
LFTQuestWatcher:SetScript("OnEvent", function()
if event then
if event == "QUEST_LOG_UPDATE" then
if LFT_TYPE == TYPE_ELITE_QUESTS then
lfdebug(event)
LFT.getEliteQuests()
DungeonListFrame_Update()
end
end
end
end)
-- delay leave queue, to check if im really ungrouped
local LFTDelayLeaveQueue = CreateFrame("Frame")
LFTDelayLeaveQueue:Hide()
LFTDelayLeaveQueue.reason = ''
LFTDelayLeaveQueue:SetScript("OnShow", function()
this.startTime = GetTime()
end)
LFTDelayLeaveQueue:SetScript("OnUpdate", function()
local plus = 2 --seconds
local gt = GetTime() * 1000
local st = (this.startTime + plus) * 1000
if gt >= st then
LFT.inGroup = GetNumRaidMembers() == 0 and GetNumPartyMembers() > 0
if not LFT.inGroup then
leaveQueue(LFTDelayLeaveQueue.reason)
LFTDelayLeaveQueue.reason = ''
LFT.hidePartyRoleIcons()
end
LFTDelayLeaveQueue:Hide()
end
end)
local LFTMinimapAnimation = CreateFrame("Frame")
LFTMinimapAnimation:Hide()
LFTMinimapAnimation:SetScript("OnShow", function()
this.startTime = GetTime()
this.frameIndex = 0
end)
LFTMinimapAnimation:SetScript("OnHide", function()
_G['LFT_MinimapEye']:SetTexture('Interface\\Addons\\LFT\\images\\eye\\battlenetworking0')
end)
LFTMinimapAnimation:SetScript("OnUpdate", function()
local plus = 0.10 --seconds
local gt = GetTime() * 1000
local st = (this.startTime + plus) * 1000
if gt >= st then
if this.frameIndex < 28 then
this.frameIndex = this.frameIndex + 1
else
this.frameIndex = 0
end
_G['LFT_MinimapEye']:SetTexture('Interface\\Addons\\LFT\\images\\eye\\battlenetworking' .. this.frameIndex)
this.startTime = GetTime()
end
end)
local LFTTime = CreateFrame("Frame")
LFTTime:Hide()
LFTTime.second = -1
LFTTime.diff = 0
LFTTime:SetScript("OnShow", function()
lfdebug('lfttime SHOW call LFTTime.second = ' .. LFTTime.second .. ' my:' .. tonumber(date("%S", time())))
lfdebug('diff = ' .. LFTTime.diff)
this.startTime = GetTime()
this.execAt = {}
this.resetAt = {}
end)
LFTTime:SetScript("OnUpdate", function()
local plus = 0.5 --seconds
local gt = GetTime() * 1000
local st = (this.startTime + plus) * 1000
if gt >= st then
this.startTime = GetTime()
--LFT.currentGroupSize = GetNumPartyMembers() + 1
LFTTime.second = tonumber(date("%S", time())) + LFTTime.diff
if LFTTime.second < 0 then
LFTTime.second = LFTTime.second + 60
end
if LFTTime.second >= 60 then
LFTTime.second = LFTTime.second - 60
end
if LFTTime.second == LFT.RESET_TIME or LFTTime.second == LFT.TIME_MARGIN then
if not this.resetAt[LFTTime.second] then
this.resetAt[LFTTime.second] = true
if LFT.peopleLookingForGroupsDisplay < LFT.peopleLookingForGroups or LFT.peopleLookingForGroups == 0 then
LFT.peopleLookingForGroupsDisplay = LFT.peopleLookingForGroups
end
LFT.peopleLookingForGroups = 0
LFT.browseNames = {}
lfdebug("RESET --- TIME IS 0 OR 30")
for dungeon, data in next, LFT.dungeons do
--reset dungeon spam
LFT.dungeonsSpam[data.code] = { tank = 0, healer = 0, damage = 0 }
--reset myRole
if LFT.groupFullCode == '' and not LFT.inGroup then
LFT.dungeons[dungeon].myRole = ''
end
end
this.execAt = {}
end
end
if (LFTTime.second > 2 and LFTTime.second < 27) or
(LFTTime.second > 32 and LFTTime.second < 57) then
this.resetAt = {}
if not this.execAt[LFTTime.second] then
BrowseDungeonListFrame_Update()
this.execAt[LFTTime.second] = true
end
end
if LFTTime.second == 28 or LFTTime.second == 58 then
--check for 0 at 28 and 58
for dungeon, data in next, LFT.dungeons do
if LFT.dungeonsSpam[data.code].tank == 0 then
LFT.dungeonsSpamDisplay[data.code].tank = LFT.dungeonsSpam[data.code].tank
end
if LFT.dungeonsSpam[data.code].healer == 0 then
LFT.dungeonsSpamDisplay[data.code].healer = LFT.dungeonsSpam[data.code].healer
end
if LFT.dungeonsSpam[data.code].damage == 0 then
LFT.dungeonsSpamDisplay[data.code].damage = LFT.dungeonsSpam[data.code].damage
end
LFT.dungeonsSpamDisplayLFM[data.code] = 0
end
end
end
end)
local LFTGoingWithPicker = CreateFrame("Frame")
LFTGoingWithPicker:Hide()
LFTGoingWithPicker.candidate = ''
LFTGoingWithPicker.priority = 0
LFTGoingWithPicker.dungeon = ''
LFTGoingWithPicker.myRole = ''
LFTGoingWithPicker:SetScript("OnShow", function()
this.startTime = GetTime()
end)
LFTGoingWithPicker:SetScript("OnHide", function()
end)
LFTGoingWithPicker:SetScript("OnUpdate", function()
local plus = 1 --seconds
local gt = GetTime() * 1000
local st = (this.startTime + plus) * 1000
if gt >= st then
LFT.dungeons[LFT.dungeonNameFromCode(LFTGoingWithPicker.dungeon)].myRole = LFTGoingWithPicker.myRole
SendChatMessage('goingWith:' .. LFTGoingWithPicker.candidate .. ':' .. LFTGoingWithPicker.dungeon
.. ':' .. LFTGoingWithPicker.myRole, "CHANNEL", DEFAULT_CHAT_FRAME.editBox.languageID, GetChannelName(LFT.channel))
LFT.foundGroup = true
LFTGoingWithPicker.candidate = ''
LFTGoingWithPicker.myRole = ''
LFTGoingWithPicker.priority = 0
LFTGoingWithPicker.dungeon = ''
LFTGoingWithPicker:Hide()
end
end)
local COLOR_RED = '|cffff222a'
local COLOR_ORANGE = '|cffff8000'
local COLOR_GREEN = '|cff1fba1f'
local COLOR_HUNTER = '|cffabd473'
local COLOR_YELLOW = '|cffffff00'
local COLOR_WHITE = '|cffffffff'
local COLOR_DISABLED = '|cffaaaaaa'
local COLOR_DISABLED2 = '|cff666666'
local COLOR_TANK = '|cff0070de'
local COLOR_HEALER = COLOR_GREEN
local COLOR_DAMAGE = COLOR_RED
-- dungeon complete animation
local LFTDungeonComplete = CreateFrame("Frame")
LFTDungeonComplete:Hide()
LFTDungeonComplete.frameIndex = 0
LFTDungeonComplete.dungeonInProgress = false
LFTDungeonComplete:SetScript("OnShow", function()
this.startTime = GetTime()
LFTDungeonComplete.frameIndex = 0
_G['LFTDungeonComplete']:SetAlpha(0)
_G['LFTDungeonComplete']:Show()
end)
LFTDungeonComplete:SetScript("OnHide", function()
-- this.startTime = GetTime()
end)
LFTDungeonComplete:SetScript("OnUpdate", function()
local plus = 0.03 --seconds
local gt = GetTime() * 1000
local st = (this.startTime + plus) * 1000
if gt >= st then
this.startTime = GetTime()
local frame = ''
if LFTDungeonComplete.frameIndex < 10 then
frame = frame .. '0' .. LFTDungeonComplete.frameIndex
else
frame = frame .. LFTDungeonComplete.frameIndex
end
_G['LFTDungeonCompleteFrame']:SetTexture('Interface\\addons\\LFT\\images\\dungeon_complete\\dungeon_complete_' .. frame)
if LFTDungeonComplete.frameIndex < 35 then
_G['LFTDungeonComplete']:SetAlpha(_G['LFTDungeonComplete']:GetAlpha() + 0.03)
end
if LFTDungeonComplete.frameIndex > 119 then
_G['LFTDungeonComplete']:SetAlpha(_G['LFTDungeonComplete']:GetAlpha() - 0.03)
end
if LFTDungeonComplete.frameIndex >= 150 then
_G['LFTDungeonComplete']:Hide()
_G['LFTDungeonStatus']:Hide()
_G['LFTDungeonCompleteFrame']:SetTexture('Interface\\addons\\LFT\\images\\dungeon_complete\\dungeon_complete_00')
LFTDungeonComplete:Hide()
local index = 0
for _, boss in next, LFT.bosses[LFT.groupFullCode] do
index = index + 1
LFT.objectivesFrames[index]:Hide()
LFT.objectivesFrames[index].completed = false
_G["LFTObjective" .. index .. 'ObjectiveComplete']:Hide()
_G["LFTObjective" .. index .. 'ObjectivePending']:Hide()
_G["LFTObjective" .. index .. 'Objective']:SetText('')
end
--LFT.objectivesFrames = {}
end
LFTDungeonComplete.frameIndex = LFTDungeonComplete.frameIndex + 1
end
end)
-- objectives
local LFTObjectives = CreateFrame("Frame")
LFTObjectives:Hide()
--LFTObjectives:RegisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH")
LFTObjectives.collapsed = false
LFTObjectives.closedByUser = false
LFTObjectives.lastObjective = 0
LFTObjectives.leftOffset = -80
LFTObjectives.frameIndex = 0
LFTObjectives.objectivesComplete = 0
function close_lft_objectives()
LFTObjectives.closedByUser = true
_G['LFTDungeonStatus']:Hide()
end
-- swoooooooosh
LFTObjectives:SetScript("OnShow", function()
LFTObjectives.leftOffset = -80
LFTObjectives.frameIndex = 0
this.startTime = GetTime()
end)
LFTObjectives:SetScript("OnHide", function()
-- this.startTime = GetTime()
end)
LFTObjectives:SetScript("OnUpdate", function()
local plus = 0.001 --seconds
local gt = GetTime() * 1000
local st = (this.startTime + plus) * 1000
if gt >= st then
this.startTime = GetTime()
LFTObjectives.frameIndex = LFTObjectives.frameIndex + 1
LFTObjectives.leftOffset = LFTObjectives.leftOffset + 5
_G["LFTObjective" .. LFTObjectives.lastObjective .. 'Swoosh']:SetPoint("TOPLEFT", _G["LFTObjective" .. LFTObjectives.lastObjective], "TOPLEFT", LFTObjectives.leftOffset, 5)
if LFTObjectives.frameIndex <= 10 then
_G["LFTObjective" .. LFTObjectives.lastObjective .. 'Swoosh']:SetAlpha(LFTObjectives.frameIndex / 10)
end
if LFTObjectives.frameIndex >= 30 then
_G["LFTObjective" .. LFTObjectives.lastObjective .. 'Swoosh']:SetAlpha(1 - LFTObjectives.frameIndex / 40)
end
if LFTObjectives.leftOffset >= 120 then
LFTObjectives:Hide()
_G["LFTObjective" .. LFTObjectives.lastObjective .. 'Swoosh']:SetAlpha(0)
end
end
end)
LFTObjectives:SetScript("OnEvent", function()
if event then
if event == "CHAT_MSG_COMBAT_HOSTILE_DEATH" then
local creatureDied = arg1
--lfdebug(creatureDied)
if LFT.bosses[LFT.groupFullCode] then
for _, boss in next, LFT.bosses[LFT.groupFullCode] do
--creatureDied == 'You have slain ' .. boss .. '!'
if creatureDied == boss .. ' dies.' then
LFTObjectives.objectiveComplete(boss)
return true
end
end
end
end
end
end)
-- fill available dungeons delayer because UnitLevel(member who just joined) returns 0
local LFTFillAvailableDungeonsDelay = CreateFrame("Frame")
LFTFillAvailableDungeonsDelay.triggers = 0
LFTFillAvailableDungeonsDelay.queueAfterIfPossible = false
LFTFillAvailableDungeonsDelay:Hide()
LFTFillAvailableDungeonsDelay:SetScript("OnShow", function()
this.startTime = GetTime()
end)
LFTFillAvailableDungeonsDelay:SetScript("OnHide", function()
if LFTFillAvailableDungeonsDelay.triggers < 10 then
LFT.fillAvailableDungeons(LFTFillAvailableDungeonsDelay.queueAfterIfPossible)
LFTFillAvailableDungeonsDelay.triggers = LFTFillAvailableDungeonsDelay.triggers + 1
else
lferror('Error occurred at LFTFillAvailableDungeonsDelay triggers = 10. Please report this to Xerron/Er.')
end
end)
LFTFillAvailableDungeonsDelay:SetScript("OnUpdate", function()
local plus = 0.1 --seconds
local gt = GetTime() * 1000
local st = (this.startTime + plus) * 1000
if gt >= st then
LFTFillAvailableDungeonsDelay:Hide()
end
end)
-- channel join delayer
local LFTChannelJoinDelay = CreateFrame("Frame")
LFTChannelJoinDelay:Hide()
LFTChannelJoinDelay:SetScript("OnShow", function()
this.startTime = GetTime()
end)
LFTChannelJoinDelay:SetScript("OnHide", function()
LFT.checkLFTChannel()
end)
LFTChannelJoinDelay:SetScript("OnUpdate", function()
local plus = 15 --seconds
local gt = GetTime() * 1000
local st = (this.startTime + plus) * 1000
if gt >= st then
LFTChannelJoinDelay:Hide()
end
end)
local LFTQueue = CreateFrame("Frame")
LFTQueue:Hide()
-- group invite timer
local LFTInvite = CreateFrame("Frame")
LFTInvite:Hide()
LFTInvite.inviteIndex = 1
LFTInvite:SetScript("OnShow", function()
this.startTime = GetTime()
LFTInvite.inviteIndex = 1
local awesomeButton = _G['LFTGroupReadyAwesome']
awesomeButton:SetText('Waiting Players (' .. LFT.groupSizeMax - GetNumPartyMembers() - 1 .. ')')
awesomeButton:Disable()
end)
LFTInvite:SetScript("OnUpdate", function()
local plus = 0.5 --seconds
local gt = GetTime() * 1000
local st = (this.startTime + plus) * 1000
if gt >= st then
this.startTime = GetTime()
LFTInvite.inviteIndex = this.inviteIndex + 1
if LFTInvite.inviteIndex == 2 then
if LFT.group[LFT.groupFullCode].healer ~= '' then
InviteByName(LFT.group[LFT.groupFullCode].healer)
end
end
if LFTInvite.inviteIndex == 3 then
if LFT.group[LFT.groupFullCode].damage1 ~= '' then
InviteByName(LFT.group[LFT.groupFullCode].damage1)
end
end
if LFTInvite.inviteIndex == 4 and LFTInvite.inviteIndex <= LFT.groupSizeMax then
if LFT.group[LFT.groupFullCode].damage2 ~= '' then
InviteByName(LFT.group[LFT.groupFullCode].damage2)
end
end
if LFTInvite.inviteIndex == 5 and LFTInvite.inviteIndex <= LFT.groupSizeMax then
if LFT.group[LFT.groupFullCode].damage3 ~= '' then
InviteByName(LFT.group[LFT.groupFullCode].damage3)
LFTInvite:Hide()
LFTInvite.inviteIndex = 1
end
end
end
end)
-- role check timer
local LFTRoleCheck = CreateFrame("Frame")
LFTRoleCheck:Hide()
LFTRoleCheck:SetScript("OnShow", function()
this.startTime = GetTime()
end)
LFTRoleCheck:SetScript("OnHide", function()
if LFT.isLeader then
if LFT.findingMore then
else
lfprint('A member of your group has not confirmed his role.')
PlaySoundFile("Interface\\Addons\\LFT\\sound\\lfg_denied.ogg")
_G['findMoreButton']:Enable()
end
end
_G['LFTRoleCheck']:Hide()
end)
LFTRoleCheck:SetScript("OnUpdate", function()
local plus = LFT.ROLE_CHECK_TIME --seconds
if LFT.isLeader then
plus = plus + 2 --leader waits 2 more second to hide
end
local gt = GetTime() * 1000
local st = (this.startTime + plus) * 1000
if gt >= st then
LFTRoleCheck:Hide()
if LFT.isLeader then
lfprint('A member of your group does not have the ' .. COLOR_HUNTER .. '[LFT] ' .. COLOR_WHITE ..
'addon. Looking for more is disabled. (Type ' .. COLOR_HUNTER .. '/lft advertise ' .. COLOR_WHITE .. ' to send them a link)')
_G['findMoreButton']:Disable()
else
declineRole()
end
end
end)
-- who counter timer
local LFTWhoCounter = CreateFrame("Frame")
LFTWhoCounter:Hide()
LFTWhoCounter.people = 0
LFTWhoCounter.total = 0
LFTWhoCounter.listening = false
LFTWhoCounter:SetScript("OnShow", function()
this.startTime = GetTime()
LFTWhoCounter.people = 0
LFTWhoCounter.listening = true
lfprint('Checking people online with the addon (5secs)...')
end)
LFTWhoCounter:SetScript("OnHide", function()
LFTWhoCounter.people = LFTWhoCounter.people + 1 -- + me
lfprint('Found ' .. COLOR_GREEN .. LFTWhoCounter.people .. COLOR_WHITE .. '/' .. LFTWhoCounter.total .. ' online using LFT addon.')
LFTWhoCounter.listening = false
end)
LFTWhoCounter:SetScript("OnUpdate", function()
local plus = 5 --seconds
local gt = GetTime() * 1000
local st = (this.startTime + plus) * 1000
if gt >= st then
LFTWhoCounter:Hide()
end
end)
--closes the group ready frame when someone leaves queue from the button
local LFTGroupReadyFrameCloser = CreateFrame("Frame")
LFTGroupReadyFrameCloser:Hide()
LFTGroupReadyFrameCloser.response = ''
LFTGroupReadyFrameCloser:SetScript("OnShow", function()
this.startTime = GetTime()
end)
LFTGroupReadyFrameCloser:SetScript("OnHide", function()
end)
LFTGroupReadyFrameCloser:SetScript("OnUpdate", function()
local plus = LFT.ROLE_CHECK_TIME --time after i click leave queue, afk
local plus2 = LFT.ROLE_CHECK_TIME + 5 --time after i close the window
local gt = GetTime() * 1000
local st = (this.startTime + plus) * 1000
local st2 = (this.startTime + plus2) * 1000
if gt >= st then
if LFTGroupReadyFrameCloser.response == '' then
sayNotReady()
end
end
if gt >= st2 then
_G['LFTReadyStatus']:Hide()
lfprint('A member of your group has not accepted the invitation. You are rejoining the queue.')
if LFT.isLeader then
leaveQueue('LFTGroupReadyFrameCloser isleader = true')
LFT.fillAvailableDungeons('queueAgain' == 'queueAgain')
end
if LFTGroupReadyFrameCloser.response == 'notReady' then
--doesnt trigger for leader, cause it leaves queue
--which resets response to ''
--LeaveParty()
LFTGroupReadyFrameCloser.response = ''
end
LFTGroupReadyFrameCloser:Hide()
end
end)
-- communication
local LFTComms = CreateFrame("Frame")
LFTComms:Hide()
LFTComms:RegisterEvent("CHAT_MSG_CHANNEL")
LFTComms:RegisterEvent("CHAT_MSG_WHISPER")
LFTComms:RegisterEvent("CHAT_MSG_CHANNEL_LEAVE")
LFTComms:RegisterEvent("PARTY_INVITE_REQUEST")
LFTComms:RegisterEvent("CHAT_MSG_ADDON")
LFTComms:RegisterEvent("CHAT_MSG_CHANNEL_NOTICE")
LFTComms:RegisterEvent("CHAT_MSG_CHANNEL_NOTICE_USER")
LFTComms:RegisterEvent("CHAT_MSG_SYSTEM")
--"CHAT_MSG_CHANNEL_NOTICE_USER"
--Category: Communication
--
--Fired when something changes in the channel like moderation enabled, user is kicked, announcements changed and so on. CHAT_*_NOTICE in GlobalStrings.lua has a full list of available types.
--
--arg1
--type ("ANNOUNCEMENTS_OFF", "ANNOUNCEMENTS_ON", "BANNED", "OWNER_CHANGED", "INVALID_NAME", "INVITE", "MODERATION_OFF", "MODERATION_ON", "MUTED", "NOT_MEMBER", "NOT_MODERATED", "SET_MODERATOR", "UNSET_MODERATOR" )
--arg2
--If arg5 has a value then this is the user affected ( eg: "Player Foo has been kicked by Bar" ), if arg5 has no value then it's the person who caused the event ( eg: "Channel Moderation has been enabled by Bar" )
--arg4
--Channel name with number
--arg5
--Player that caused the event (eg "Player Foo has been kicked by Bar" )
LFTComms:SetScript("OnEvent", function()
if event then
if event == 'CHAT_MSG_SYSTEM' then
if string.find(arg1, 'Server uptime:', 1, true) and
not LFT.gotUptime and
(string.find(arg1, 'Days', 1, true) or
string.find(arg1, 'Hours', 1, true) or
string.find(arg1, 'Minutes', 1, true) or
string.find(arg1, 'Seconds', 1, true)) then
if string.find(arg1, 'Seconds', 1, true) then
local mSplit = string.split(arg1, ' ')
if not tonumber(mSplit[LFT.tableSize(mSplit) - 1]) then
return false
end
LFTTime.second = tonumber(mSplit[LFT.tableSize(mSplit) - 1])
LFTTime:Hide()
LFTTime.diff = LFTTime.second - tonumber(date("%S", time()))
LFTTime:Show()
else
LFTTime.second = 0
LFTTime:Hide()
LFTTime.diff = LFTTime.second - tonumber(date("%S", time()))
LFTTime:Show() --default 0
end
return true
end
end
if event == 'CHAT_MSG_CHANNEL_NOTICE_USER' then
if arg1 == 'PLAYER_ALREADY_MEMBER' then
-- probably only used when reloadui
LFT.checkLFTChannel()
end
--lfdebug('CHAT_MSG_CHANNEL_NOTICE_USER')
--lfdebug(arg1) --event,
--lfdebug(arg2) -- somename
--lfdebug(arg3) -- blank
--lfdebug(arg4) -- 6.Lft
--lfdebug(arg5) -- blank
--lfdebug('channel index = ' .. LFT.channelIndex) -- blank
end
if event == 'CHAT_MSG_CHANNEL_NOTICE' then
if arg9 == LFT.channel and arg1 == 'YOU_JOINED' then
LFT.channelIndex = arg8
end
end
if event == 'CHAT_MSG_ADDON' and arg1 == LFT_ADDON_CHANNEL then
lfdebug(arg4 .. ' says : ' .. arg2)
if string.sub(arg2, 1, 11) == 'objectives:' and arg4 ~= me then
local objEx = string.split(arg2, ':')
if LFT.groupFullCode ~= objEx[2] then
LFT.groupFullCode = objEx[2]
end
local objectivesString = string.split(objEx[3], '-')
local complete = 0
for stringIndex, s in next, objectivesString do
if s then
if s == '1' then
complete = complete + 1
local index = 0
for _, boss in next, LFT.bosses[LFT.groupFullCode] do
index = index + 1
if index == stringIndex then
LFTObjectives.objectiveComplete(boss, true)
end
end
end
end
end
if not LFTObjectives.closedByUser and not _G["LFTDungeonStatus"]:IsVisible() then
LFT.showDungeonObjectives('code_for_debug_only', complete)
end
end
if string.sub(arg2, 1, 11) == 'notReadyAs:' then
PlaySoundFile("Interface\\Addons\\LFT\\sound\\lfg_denied.ogg")
local readyEx = string.split(arg2, ':')
local role = readyEx[2]
if role == 'tank' then
_G['LFTReadyStatusReadyTank']:SetTexture('Interface\\addons\\LFT\\images\\readycheck-notready')
end
if role == 'healer' then
_G['LFTReadyStatusReadyHealer']:SetTexture('Interface\\addons\\LFT\\images\\readycheck-notready')
end
if role == 'damage' then
if _G['LFTReadyStatusReadyDamage1']:GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-waiting' then
_G['LFTReadyStatusReadyDamage1']:SetTexture('Interface\\addons\\LFT\\images\\readycheck-notready')
elseif _G['LFTReadyStatusReadyDamage2']:GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-waiting' then
_G['LFTReadyStatusReadyDamage2']:SetTexture('Interface\\addons\\LFT\\images\\readycheck-notready')
elseif _G['LFTReadyStatusReadyDamage3']:GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-waiting' then
_G['LFTReadyStatusReadyDamage3']:SetTexture('Interface\\addons\\LFT\\images\\readycheck-notready')
end
end
end
if string.sub(arg2, 1, 8) == 'readyAs:' then
local readyEx = string.split(arg2, ':')
local role = readyEx[2]
LFT.showPartyRoleIcons(role, arg4)
if role == 'tank' then
_G['LFTReadyStatusReadyTank']:SetTexture('Interface\\addons\\LFT\\images\\readycheck-ready')
end
if role == 'healer' then
_G['LFTReadyStatusReadyHealer']:SetTexture('Interface\\addons\\LFT\\images\\readycheck-ready')
end
if role == 'damage' then
if _G['LFTReadyStatusReadyDamage1']:GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-waiting' then
_G['LFTReadyStatusReadyDamage1']:SetTexture('Interface\\addons\\LFT\\images\\readycheck-ready')
elseif _G['LFTReadyStatusReadyDamage2']:GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-waiting' then
_G['LFTReadyStatusReadyDamage2']:SetTexture('Interface\\addons\\LFT\\images\\readycheck-ready')
elseif _G['LFTReadyStatusReadyDamage3']:GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-waiting' then
_G['LFTReadyStatusReadyDamage3']:SetTexture('Interface\\addons\\LFT\\images\\readycheck-ready')
end
end
if _G['LFTReadyStatusReadyTank']:GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-ready' and
_G['LFTReadyStatusReadyHealer']:GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-ready' and
_G['LFTReadyStatusReadyDamage1']:GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-ready' and
_G['LFTReadyStatusReadyDamage2']:GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-ready' and
_G['LFTReadyStatusReadyDamage3']:GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-ready' then
_G['LFTReadyStatus']:Hide()
LFTGroupReadyFrameCloser:Hide()
local _, numCompletedObjectives = LFT.getDungeonCompletion()
LFT.showDungeonObjectives('dummy', numCompletedObjectives)
--promote the tank to leader
end
if LFT.isLeader and role == 'tank' and arg4 ~= me then
PromoteByName(arg4)
end
end
if string.sub(arg2, 1, 11) == 'LFTVersion:' and arg4 ~= me then
if not LFT.showedUpdateNotification then
local verEx = string.split(arg2, ':')
if LFT.ver(verEx[2]) > LFT.ver(addonVer) then
lfprint(COLOR_HUNTER .. 'Looking For Turtles ' .. COLOR_WHITE .. ' - new version available ' ..
COLOR_GREEN .. 'v' .. verEx[2] .. COLOR_WHITE .. ' (current version ' ..
COLOR_ORANGE .. 'v' .. addonVer .. COLOR_WHITE .. ')')
lfprint('Update yours at ' .. COLOR_HUNTER .. 'https://github.com/CosminPOP/LFT')
LFT.showedUpdateNotification = true
end
end
end
if string.sub(arg2, 1, 11) == 'leaveQueue:' and arg4 ~= me then
leaveQueue('leaveQueue: addon party')
end
if string.sub(arg2, 1, 8) == 'minimap:' then
if not LFT.isLeader then
local miniEx = string.split(arg2, ':')
local code = miniEx[2]
local tank = tonumber(miniEx[3])
local healer = tonumber(miniEx[4])
local damage = tonumber(miniEx[5])
LFT.LFMDungeonCode = code
LFT.group = {} --reset old entries
LFT.group[code] = {
tank = '',
healer = '',
damage1 = '',
damage2 = '',
damage3 = ''
}
if tank == 1 then
LFT.group[code].tank = 'DummyTank'
end
if healer == 1 then
LFT.group[code].healer = 'DummyHealer'
end
if damage > 0 then
LFT.group[code].damage1 = 'DummyDamage1'
end
if damage > 1 then
LFT.group[code].damage2 = 'DummyDamage2'
end
if damage > 2 then
LFT.group[code].damage3 = 'DummyDamage3'
end
end
end
if string.sub(arg2, 1, 14) == 'LFMPartyReady:' then
local queueEx = string.split(arg2, ':')
local mCode = queueEx[2]
local objectivesCompleted = queueEx[3]
local objectivesTotal = queueEx[4]
LFT.groupFullCode = mCode
LFT.LFMDungeonCode = mCode
--uncheck everything
_G['Dungeon_' .. LFT.groupFullCode .. '_CheckButton']:SetChecked(false)
LFT.findingGroup = false
LFT.findingMore = false
local background = ''
local dungeonName = 'unknown'
for d, data in next, LFT.dungeons do
if data.code == mCode then
background = data.background
dungeonName = d
end
end
local myRole = LFT.dungeons[LFT.dungeonNameFromCode(mCode)].myRole
LFT.SetSingleRole(myRole)
_G['LFTGroupReadyBackground']:SetTexture('Interface\\addons\\LFT\\images\\background\\ui-lfg-background-' .. background)
_G['LFTGroupReadyRole']:SetTexture('Interface\\addons\\LFT\\images\\' .. myRole .. '2')
_G['LFTGroupReadyMyRole']:SetText(LFT.ucFirst(myRole))
_G['LFTGroupReadyDungeonName']:SetText(dungeonName)
_G['LFTGroupReadyObjectivesCompleted']:SetText(objectivesCompleted .. '/' .. objectivesTotal .. ' Bosses Defeated')
LFT.readyStatusReset()
_G['LFTGroupReady']:Show()
LFTGroupReadyFrameCloser:Show()
LFT.fixMainButton()
_G['LFTlft']:Hide()
PlaySoundFile("Interface\\Addons\\LFT\\sound\\levelup2.ogg")
LFTQueue:Hide()
if LFT.isLeader then
SendChatMessage("[LFT]:lft_group_formed:" .. mCode .. ":" .. time() - LFT.queueStartTime, "CHANNEL", DEFAULT_CHAT_FRAME.editBox.languageID, GetChannelName(LFT.channel))
end
end
if string.sub(arg2, 1, 10) == 'weInQueue:' then
local queueEx = string.split(arg2, ':')
LFT.weInQueue(queueEx[2])
end
if string.sub(arg2, 1, 10) == 'roleCheck:' then
if arg4 ~= me then
PlaySoundFile("Interface\\AddOns\\LFT\\sound\\lfg_rolecheck.ogg")
end
lfprint('A role check has been initiated. Your group will be queued when all members have selected a role.')
UIErrorsFrame:AddMessage("|cff69ccf0[LFT] |cffffff00A role check has been initiated. Your group will be queued when all members have selected a role.")
local argEx = string.split(arg2, ':')
local mCode = argEx[2]
LFT.LFMDungeonCode = mCode
LFT.resetGroup()
lfdebug('my role is : ' .. LFT.dungeons[LFT.dungeonNameFromCode(LFT.LFMDungeonCode)].myRole)
--if we dont know my prev role
if LFT.dungeons[LFT.dungeonNameFromCode(LFT.LFMDungeonCode)].myRole == '' then
if _G['RoleTank']:GetChecked() then
LFT.dungeons[LFT.dungeonNameFromCode(LFT.LFMDungeonCode)].myRole = 'tank'
elseif _G['RoleHealer']:GetChecked() then
LFT.dungeons[LFT.dungeonNameFromCode(LFT.LFMDungeonCode)].myRole = 'healer'
elseif _G['RoleDamage']:GetChecked() then
LFT.dungeons[LFT.dungeonNameFromCode(LFT.LFMDungeonCode)].myRole = 'damage'
else
LFT.dungeons[LFT.dungeonNameFromCode(LFT.LFMDungeonCode)].myRole = LFT.GetPossibleRoles()
end
end
_G['roleCheckTank']:SetChecked(LFT.dungeons[LFT.dungeonNameFromCode(LFT.LFMDungeonCode)].myRole == 'tank')
_G['roleCheckHealer']:SetChecked(LFT.dungeons[LFT.dungeonNameFromCode(LFT.LFMDungeonCode)].myRole == 'healer')
_G['roleCheckDamage']:SetChecked(LFT.dungeons[LFT.dungeonNameFromCode(LFT.LFMDungeonCode)].myRole == 'damage')
lfdebug(' my role after checks : ' .. LFT.dungeons[LFT.dungeonNameFromCode(LFT.LFMDungeonCode)].myRole)
_G['LFTRoleCheckAcceptRole']:Enable()
--commented this to show my rolecheck window
--if LFT.isLeader then
-- lfdebug('is leader')
-- if LFT_ROLE == 'tank' then
-- LFT.LFMGroup.tank = me
-- SendAddonMessage(LFT_ADDON_CHANNEL, "acceptRole:" .. LFT_ROLE, "PARTY")
-- end
-- if LFT_ROLE == 'healer' then
-- LFT.LFMGroup.healer = me
-- SendAddonMessage(LFT_ADDON_CHANNEL, "acceptRole:" .. LFT_ROLE, "PARTY")
-- end
-- if LFT_ROLE == 'damage' then
-- LFT.LFMGroup.damage1 = me
-- SendAddonMessage(LFT_ADDON_CHANNEL, "acceptRole:" .. LFT_ROLE, "PARTY")
-- end
--else
_G['LFTRoleCheckQForText']:SetText(COLOR_WHITE .. "Queued for " .. COLOR_YELLOW .. LFT.dungeonNameFromCode(mCode))
_G['LFTRoleCheck']:Show()
_G['LFTGroupReady']:Hide()
--end
LFTRoleCheck:Show()
end
if string.sub(arg2, 1, 11) == 'acceptRole:' then
local roleEx = string.split(arg2, ':')
local roleColor = ''
if arg4 == me and not LFT.isLeader then
LFTRoleCheck:Hide()
end
LFT.showPartyRoleIcons(roleEx[2], arg4)
if roleEx[2] == 'tank' then
roleColor = COLOR_TANK
end
if roleEx[2] == 'healer' then
roleColor = COLOR_HEALER
end
if roleEx[2] == 'damage' then
roleColor = COLOR_DAMAGE