-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathLFT.lua
2854 lines (2527 loc) · 107 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
local LFT = CreateFrame("Frame")
local me = UnitName('player')
local addonVer = '0.0.1.6'
local showedUpdateNotification = false
local LFT_ADDON_CHANNEL = 'LFT'
local LFTTypeDropDown = CreateFrame('Frame', 'LFTTypeDropDown', UIParent, 'UIDropDownMenuTemplate')
local groupsFormedThisSession = 0
--notification if group has wrong comp, 4 dps or two healers
local DEV_GROUP_SIZE = 5
LFT.class = ''
LFT.channel = 'LFT'
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.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'
}
LFT.maxDungeonsList = 11
LFT.minimapFrames = {}
LFT.myRandomTime = 0
LFT.random_min = 0
LFT.random_max = 20
LFT.RESET_TIME = 0
LFT.TANK_TIME = 2
LFT.HEALER_TIME = 5
LFT.DAMAGE_TIME = 5
LFT.FULLCHECK_TIME = 26 --time when checkGroupFull is called, has to wait for goingWith messages
LFT.TIME_MARGIN = 30
LFT.foundGroup = false
LFT.inGroup = false
LFT.isLeader = false
LFT.LFMGroup = {}
LFT.LFMDungeonCode = ''
LFT.currentGroupSize = 0
LFT.objectives = {}
LFT.objectivesFrames = {}
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" }
}
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 = '|cff888888'
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:SetScript("OnShow", function()
this.startTime = GetTime()
LFTDungeonComplete.frameIndex = 0
getglobal('LFTDungeonComplete'):SetAlpha(1)
getglobal('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
getglobal('LFTDungeonCompleteFrame'):SetTexture('Interface\\addons\\LFT\\images\\dungeon_complete\\dungeon_complete_' .. frame)
if LFTDungeonComplete.frameIndex > 119 then
getglobal('LFTDungeonComplete'):SetAlpha(getglobal('LFTDungeonComplete'):GetAlpha() - 0.03)
end
if LFTDungeonComplete.frameIndex >= 150 then
getglobal('LFTDungeonComplete'):Hide()
getglobal('LFTDungeonStatus'):Hide()
LFTDungeonComplete:Hide()
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.lastObjective = 0
LFTObjectives.leftOffset = -80
LFTObjectives.frameIndex = 0
LFTObjectives.objectivesComplete = 0
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
getglobal("LFTObjective" .. LFTObjectives.lastObjective .. 'Swoosh'):SetPoint("TOPLEFT", getglobal("LFTObjective" .. LFTObjectives.lastObjective), "TOPLEFT", LFTObjectives.leftOffset, 5)
if LFTObjectives.frameIndex <= 10 then
getglobal("LFTObjective" .. LFTObjectives.lastObjective .. 'Swoosh'):SetAlpha(LFTObjectives.frameIndex / 10)
end
if LFTObjectives.frameIndex >= 30 then
getglobal("LFTObjective" .. LFTObjectives.lastObjective .. 'Swoosh'):SetAlpha(1 - LFTObjectives.frameIndex / 40)
end
if LFTObjectives.leftOffset >= 120 then
LFTObjectives:Hide()
end
end
end)
LFTObjectives:SetScript("OnEvent", function()
if event == "CHAT_MSG_COMBAT_HOSTILE_DEATH" then
local creatureDied = arg1
-- if LFT.dungeons[zoneText] then
if LFT.bosses[LFT.groupFullCode] then
for code, boss in next, LFT.bosses[LFT.groupFullCode] do
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.offset = 0
LFTFillAvailableDungeonsDelay.triggers = 0
LFTFillAvailableDungeonsDelay.queueAfterIfPossible = false
LFTFillAvailableDungeonsDelay:Hide()
LFTFillAvailableDungeonsDelay:SetScript("OnShow", function()
this.startTime = GetTime()
end)
LFTFillAvailableDungeonsDelay:SetScript("OnHide", function()
lfdebug('LFTFillAvailableDungeonsDelay trigger ------------------------------')
if LFTFillAvailableDungeonsDelay.triggers < 10 then
LFT.fillAvailableDungeons(LFTFillAvailableDungeonsDelay.offset, LFTFillAvailableDungeonsDelay.queueAfterIfPossible)
LFTFillAvailableDungeonsDelay.triggers = LFTFillAvailableDungeonsDelay.triggers + 1
else
lferror('Error occured 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 = 5 --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
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 <= DEV_GROUP_SIZE then
if LFT.group[LFT.groupFullCode].damage2 ~= '' then
InviteByName(LFT.group[LFT.groupFullCode].damage2)
end
end
if LFTInvite.inviteIndex == 5 and LFTInvite.inviteIndex <= DEV_GROUP_SIZE 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
lfdebug(' are we queued by now ?')
if LFT.findingMore then
lfdebug('were in queue')
else
lfprint('Queueing aborted.')
end
end
end)
LFTRoleCheck:SetScript("OnUpdate", function()
local plus = 35 --seconds todo 25
if LFT.isLeader then
plus = plus + 2 --leader waits 1 more second to hide
end
local gt = GetTime() * 1000
local st = (this.startTime + plus) * 1000
if gt >= st then
lfdebug('rolecheck hide at ')
LFTRoleCheck:Hide()
if LFT.isLeader then
lfprint('Someone in your party 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)')
getglobal('findMoreButton'):Disable()
else
declineRole()
end
end
end)
-- who counter timer
local LFTWhoCounter = CreateFrame("Frame")
LFTWhoCounter:Hide()
LFTWhoCounter.people = 0
LFTWhoCounter.listening = false
LFTWhoCounter:SetScript("OnShow", function()
this.startTime = GetTime()
LFTWhoCounter.people = 0
LFTWhoCounter.listening = true
end)
LFTWhoCounter:SetScript("OnHide", function()
LFTWhoCounter.people = LFTWhoCounter.people + 1 -- + me
lfprint('Found ' .. LFTWhoCounter.people .. ' 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 someoene leaves queue from the button
local LFTGroupReadyFrameCloser = CreateFrame("Frame")
LFTGroupReadyFrameCloser:Hide()
LFTGroupReadyFrameCloser.response = ''
LFTGroupReadyFrameCloser:SetScript("OnShow", function()
this.startTime = GetTime()
this.clickedNotReady = false
end)
LFTGroupReadyFrameCloser:SetScript("OnHide", function()
end)
LFTGroupReadyFrameCloser:SetScript("OnUpdate", function()
local plus = 30 --time after i click leave queue, afk
local plus2 = 35 --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
getglobal('LFTReadyStatus'):Hide()
lfprint('A member of your party has not accepted the invitation. You are rejoining the queue.')
if LFT.isLeader then
leaveQueue()
local offset = FauxScrollFrame_GetOffset(getglobal('DungeonListScrollFrame'));
LFT.fillAvailableDungeons(offset, 'queueAgain' == 'queueAgain')
end
if LFTGroupReadyFrameCloser.response == 'notReady' then
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:SetScript("OnEvent", function()
if event then
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' then
lfdebug(arg4 .. ' says : ' .. arg2)
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
getglobal('LFTReadyStatusReadyTank'):SetTexture('Interface\\addons\\LFT\\images\\readycheck-notready')
end
if role == 'healer' then
getglobal('LFTReadyStatusReadyHealer'):SetTexture('Interface\\addons\\LFT\\images\\readycheck-notready')
end
if role == 'damage' then
lfdebug(getglobal('LFTReadyStatusReadyDamage1'):GetTexture())
if getglobal('LFTReadyStatusReadyDamage1'):GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-waiting' then
getglobal('LFTReadyStatusReadyDamage1'):SetTexture('Interface\\addons\\LFT\\images\\readycheck-notready')
elseif getglobal('LFTReadyStatusReadyDamage2'):GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-waiting' then
getglobal('LFTReadyStatusReadyDamage2'):SetTexture('Interface\\addons\\LFT\\images\\readycheck-notready')
elseif getglobal('LFTReadyStatusReadyDamage3'):GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-waiting' then
getglobal('LFTReadyStatusReadyDamage3'):SetTexture('Interface\\addons\\LFT\\images\\readycheck-notready')
end
end
--someone hit not ready hide window in like 5 seconds ?
-- LFTGroupReadyFrameCloser
end
if string.sub(arg2, 1, 8) == 'readyAs:' then
local readyEx = string.split(arg2, ':')
local role = readyEx[2]
if role == 'tank' then
getglobal('LFTReadyStatusReadyTank'):SetTexture('Interface\\addons\\LFT\\images\\readycheck-ready')
end
if role == 'healer' then
getglobal('LFTReadyStatusReadyHealer'):SetTexture('Interface\\addons\\LFT\\images\\readycheck-ready')
end
if role == 'damage' then
lfdebug(getglobal('LFTReadyStatusReadyDamage1'):GetTexture())
if getglobal('LFTReadyStatusReadyDamage1'):GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-waiting' then
getglobal('LFTReadyStatusReadyDamage1'):SetTexture('Interface\\addons\\LFT\\images\\readycheck-ready')
elseif getglobal('LFTReadyStatusReadyDamage2'):GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-waiting' then
getglobal('LFTReadyStatusReadyDamage2'):SetTexture('Interface\\addons\\LFT\\images\\readycheck-ready')
elseif getglobal('LFTReadyStatusReadyDamage3'):GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-waiting' then
getglobal('LFTReadyStatusReadyDamage3'):SetTexture('Interface\\addons\\LFT\\images\\readycheck-ready')
end
end
if getglobal('LFTReadyStatusReadyTank'):GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-ready' and
getglobal('LFTReadyStatusReadyHealer'):GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-ready' and
getglobal('LFTReadyStatusReadyDamage1'):GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-ready' and
getglobal('LFTReadyStatusReadyDamage2'):GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-ready' and
getglobal('LFTReadyStatusReadyDamage3'):GetTexture() == 'Interface\\addons\\LFT\\images\\readycheck-ready' then
getglobal('LFTReadyStatus'):Hide()
LFT.showDungeonObjectives()
end
end
if string.sub(arg2, 1, 11) == 'LFTVersion:' and arg4 ~= me then
if not 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')
showedUpdateNotification = true
end
end
end
-- fake fill minimap frames
if string.sub(arg2, 1, 11) == 'leaveQueue:' and arg4 ~= me then
leaveQueue()
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.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
--untick everything
for i, frame in LFT.availableDungeons do
getglobal('Dungeon_' .. LFT.groupFullCode):SetChecked(false)
end
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
getglobal('LFTGroupReadyBackground'):SetTexture('Interface\\addons\\LFT\\images\\background\\ui-lfg-background-' .. background)
getglobal('LFTGroupReadyRole'):SetTexture('Interface\\addons\\LFT\\images\\' .. LFT_ROLE .. '2')
getglobal('LFTGroupReadyMyRole'):SetText(LFT.ucFirst(LFT_ROLE))
getglobal('LFTGroupReadyDungeonName'):SetText(dungeonName)
getglobal('LFTGroupReadyObjectivesCompleted'):SetText(objectivesCompleted .. '/' .. objectivesTotal .. ' Bosses Defeated')
LFT.readyStatusReset()
getglobal('LFTGroupReady'):Show()
LFTGroupReadyFrameCloser:Show()
PlaySoundFile("Interface\\Addons\\LFT\\sound\\levelup2.ogg")
LFT.fixMainButton()
getglobal('LFTMain'):Hide()
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()
if LFT.isLeader then
lfdebug('is leader')
if LFT_ROLE == 'tank' then LFT.LFMGroup.tank = me end
if LFT_ROLE == 'healer' then LFT.LFMGroup.healer = me end
if LFT_ROLE == 'damage' then LFT.LFMGroup.damage1 = me end
else
getglobal('LFTRoleCheckQForText'):SetText(COLOR_WHITE .. "Queued for " .. COLOR_YELLOW .. LFT.dungeonNameFromCode(mCode))
getglobal('LFTRoleCheck'):Show()
getglobal('LFTGroupReady'):Hide()
lfdebug('group ready show in rolecheck: else')
end
LFTRoleCheck:Show()
end
if string.sub(arg2, 1, 11) == 'acceptRole:' then
local roleEx = string.split(arg2, ':')
local roleColor = ''
if roleEx[2] == 'tank' then
if LFT_ROLE == 'tank' then
--todo text
lfdebug(LFT.playerClass(arg4))
lfprint(COLOR_TANK .. 'Tank ' .. COLOR_WHITE .. 'role has already been filled by ' .. LFT.classColors[LFT.playerClass(arg4)].c .. arg4
.. COLOR_WHITE .. '. Please select a different role to rejoin the queue.')
leaveQueue()
return false
end
LFT.LFMGroup.tank = arg4
roleColor = COLOR_TANK
end
if roleEx[2] == 'healer' then
LFT.LFMGroup.healer = arg4
roleColor = COLOR_HEALER
end
if roleEx[2] == 'damage' then
if LFT.LFMGroup.damage1 == '' then
LFT.LFMGroup.damage1 = arg4
elseif LFT.LFMGroup.damage2 == '' then
LFT.LFMGroup.damage2 = arg4
elseif LFT.LFMGroup.damage3 == '' then
LFT.LFMGroup.damage3 = arg4
end
roleColor = COLOR_DAMAGE
end
if arg4 == me then
lfprint('You have chosen: ' .. roleColor .. LFT.ucFirst(roleEx[2]))
else
lfprint(arg4 .. ' has chosen: ' .. roleColor .. LFT.ucFirst(roleEx[2]))
end
LFT.checkLFMgroup()
end
if string.sub(arg2, 1, 12) == 'declineRole:' then
PlaySoundFile("Interface\\Addons\\LFT\\sound\\lfg_denied.ogg")
LFT.checkLFMgroup(arg4)
end
end
if event == 'PARTY_INVITE_REQUEST' and LFT.acceptNextInvite then
if arg1 == LFT.onlyAcceptFrom then
LFT.AcceptGroupInvite()
LFT.acceptNextInvite = false
else
LFT.DeclineGroupInvite()
end
end
if event == 'CHAT_MSG_CHANNEL_LEAVE' then
LFT.removePlayerFromVirtualParty(arg2, false) --unknown role
end
if event == 'CHAT_MSG_CHANNEL' and string.find(arg1, '[LFT]', 1, true) and arg8 == LFT.channelIndex and arg2 ~= me and --for lfm
string.find(arg1, '(LFM)', 1, true) then
--[LFT]:stratlive:(LFM):name
local mEx = string.split(arg1, ':')
if mEx[4] == me then
LFT.onlyAcceptFrom = arg2
LFT.acceptNextInvite = true
end
end
if event == 'CHAT_MSG_CHANNEL' and arg8 == LFT.channelIndex and string.find(arg1, 'lft_group_formed', 1, true) then
local gfEx = string.split(arg1, ':')
local code = gfEx[3]
local time = tonumber(gfEx[4])
groupsFormedThisSession = groupsFormedThisSession + 1
if me == 'Er' then
lfprint(groupsFormedThisSession .. ' groups formed this session.')
end
if LFT.averageWaitTime == 0 then
LFT.averageWaitTime = time
else
LFT.averageWaitTime = math.floor((LFT.averageWaitTime + time) / 2)
end
LFT_FORMED_GROUPS[code] = LFT_FORMED_GROUPS[code] + 1
end
if event == 'CHAT_MSG_CHANNEL' and string.find(arg1, '[LFT]', 1, true) and arg8 == LFT.channelIndex and arg2 ~= me and --for lfg
string.find(arg1, 'party:ready', 1, true) then
local mEx = string.split(arg1, ':')
LFT.groupFullCode = mEx[2] --code
local healer = mEx[5]
local damage1 = mEx[6]
local damage2 = mEx[7]
local damage3 = mEx[8]
--check if party ready message is for me
if me ~= healer and me ~= damage1 and me ~= damage2 and me ~= damage3 then return end
LFT.onlyAcceptFrom = arg2
LFT.acceptNextInvite = true
local background = ''
local dungeonName = 'unknown'
for d, data in next, LFT.dungeons do
if data.code == mEx[2] then
background = data.background
dungeonName = d
end
end
getglobal('LFTGroupReadyBackground'):SetTexture('Interface\\addons\\LFT\\images\\background\\ui-lfg-background-' .. background)
getglobal('LFTGroupReadyRole'):SetTexture('Interface\\addons\\LFT\\images\\' .. LFT_ROLE .. '2')
getglobal('LFTGroupReadyMyRole'):SetText(LFT.ucFirst(LFT_ROLE))
getglobal('LFTGroupReadyDungeonName'):SetText(dungeonName)
getglobal('LFTGroupReady'):Show()
LFTGroupReadyFrameCloser:Show()
getglobal('LFTRoleCheck'):Hide()
PlaySoundFile("Interface\\Addons\\LFT\\sound\\levelup2.ogg")
LFTQueue:Hide()
LFT.findingGroup = false
LFT.findingMore = false
getglobal('LFTMain'):Hide()
LFT.fixMainButton()
end
if event == 'CHAT_MSG_CHANNEL' and arg8 == LFT.channelIndex and arg2 ~= me then
if string.sub(arg1, 1, 7) == 'whoLFT:' then
SendChatMessage('meLFT:' .. addonVer, "CHANNEL", DEFAULT_CHAT_FRAME.editBox.languageID, GetChannelName(LFT.channel))
end
if string.sub(arg1, 1, 6) == 'meLFT:' then
--lfdebug(arg1)
if LFTWhoCounter.listening then
LFTWhoCounter.people = LFTWhoCounter.people + 1
end
end
end
if event == 'CHAT_MSG_CHANNEL' and arg8 == LFT.channelIndex and not LFT.oneGroupFull and (LFT.findingGroup or LFT.findingMore) and arg2 ~= me then
if string.sub(arg1, 1, 6) == 'found:' then
local foundEx = string.split(arg1, ':')
local mRole = foundEx[2]
local mDungeon = foundEx[3]
local name = foundEx[4]
if LFT_ROLE == mRole and not LFT.foundGroup and name == me then
SendChatMessage('goingWith:' .. arg2 .. ':' .. mDungeon .. ':' .. LFT_ROLE, "CHANNEL", DEFAULT_CHAT_FRAME.editBox.languageID, GetChannelName(LFT.channel))
LFT.foundGroup = true
end
end
if string.sub(arg1, 1, 10) == 'leftQueue:' then
local leftEx = string.split(arg1, ':')
local name = arg2
local mRole = leftEx[2]
LFT.removePlayerFromVirtualParty(name, mRole)
end
if string.sub(arg1, 1, 10) == 'goingWith:' and (LFT_ROLE == 'tank' or LFT.isLeader) then
local withEx = string.split(arg1, ':')
local leader = withEx[2]
local mDungeon = withEx[3]
local mRole = withEx[4]
-- lfdebug('should remove ' .. arg2 .. ' from my group ' .. mDungeon)
--check if im queued for mDungeon
for dungeon, _ in next, LFT.group do
if dungeon == mDungeon then
if leader ~= me then
-- only healers and damages respond with goingwith
LFT.remHealerOrDamage(mDungeon, arg2)
end
end
-- otherwise, dont care
end
-- lfm leader should invite this guy now
--todo check mDungeon here
if LFT.isLeader then lfdebug('im leader') else lfdebug('im not leader') end
if LFT.isLeader and leader == me then
lfdebug('group dungeon = ' .. LFT.group[mDungeon].healer)
if LFT.isNeededInLFMGroup(mRole, arg2, mDungeon) then
lfdebug('neeeded. should invite ')
if mRole == 'tank' then LFT.addTank(mDungeon, arg2, true, true) end
if mRole == 'healer' then LFT.addHealer(mDungeon, arg2, true, true) end
if mRole == 'damage' then LFT.addDamage(mDungeon, arg2, true, true) end
LFT.inviteInLFMGroup(arg2)
end
end
end
if string.sub(arg1, 1, 4) == 'LFG:' then
local spamSplit = string.split(arg1, ':')
local mDungeonCode = spamSplit[2]
local mRole = spamSplit[3] --other's role
for dungeon, data in next, LFT.dungeons do
if data.queued and data.code == mDungeonCode then
-- LFM, leader found someone
-- if LFT.isLeader then
-- if LFT.isNeededInLFMGroup(mRole, arg2, mDungeonCode) then
-- LFT.inviteInLFMGroup(arg2)
-- end
-- return true
-- end
if LFT.isLeader then
if mRole == 'tank' then LFT.addTank(mDungeonCode, arg2) end
if mRole == 'healer' then LFT.addHealer(mDungeonCode, arg2) end
if mRole == 'damage' then LFT.addDamage(mDungeonCode, arg2) end
return false
end
if LFT_ROLE == 'tank' then
LFT.group[mDungeonCode].tank = me
if mRole == 'healer' then LFT.addHealer(mDungeonCode, arg2, false, true) end
if mRole == 'damage' then LFT.addDamage(mDungeonCode, arg2, false, true) end
end
--pseudo fill group for tooltip display
if LFT_ROLE == 'healer' then
LFT.addHealer(mDungeonCode, me, true)
if mRole == 'tank' and LFT.group[mDungeonCode].tank == '' then
LFT.group[mDungeonCode].tank = arg2
end
if mRole == 'damage' then
LFT.addDamage(mDungeonCode, arg2, true)
end
end
if LFT_ROLE == 'damage' then
LFT.addDamage(mDungeonCode, me, true)
if mRole == 'tank' and LFT.group[mDungeonCode].tank == '' then
LFT.group[mDungeonCode].tank = arg2
end
if mRole == 'healer' and LFT.group[mDungeonCode].healer == '' then
LFT.group[mDungeonCode].healer = arg2
end
end
end
end
end
end
end
end)
-- debug and print functions
function lfprint(a)
if a == nil then
DEFAULT_CHAT_FRAME:AddMessage(COLOR_HUNTER .. '[LFT]|cff0070de:' .. time() .. '|cffffffff attempt to print a nil value.')
return false
end
DEFAULT_CHAT_FRAME:AddMessage(COLOR_HUNTER .. "[LFT] |cffffffff" .. a)
end
function lferror(a)
DEFAULT_CHAT_FRAME:AddMessage('|cff69ccf0[LFTError]|cff0070de:' .. time() .. '|cffffffff[' .. a .. ']')
end
function lfdebug(a)
if not LFT_DEBUG then return false end
if me ~= 'Holystrike' and me ~= 'Cosmort' and
me ~= 'Cosmin' and me ~= 'Kzktst' and
me ~= 'Er' and me ~= 'Rake' and
me ~= 'Kaizer' and me ~= 'Laciupacapra' and
me ~= 'Pog' and me ~= 'Xerron' and
me ~= 'Holystrike' and me ~= 'Xerrtwo' then
return false
end
if type(a) == 'boolean' then
if a then
lfprint('|cff0070de[LFTDEBUG:' .. time() .. ']|cffffffff[true]')
else
lfprint('|cff0070de[LFTDEBUG:' .. time() .. ']|cffffffff[false]')
end
return true
end
lfprint('|cff0070de[LFTDEBUG:' .. time() .. ']|cffffffff[' .. a .. ']')
end
LFT:SetScript("OnEvent", function()
if event then
if event == "ADDON_LOADED" and arg1 == 'LFT' then
LFT.init()
end
if event == "PLAYER_ENTERING_WORLD" then
LFT.level = UnitLevel('player')
LFT.sendMyVersion()
end
if event == "PARTY_LEADER_CHANGED" then
LFT.isLeader = IsPartyLeader()
end
if event == "PARTY_MEMBERS_CHANGED" then
lfdebug('PARTY_MEMBERS_CHANGED')
DungeonListFrame_Update()
local someoneJoined = GetNumPartyMembers() + 1 > LFT.currentGroupSize
local someoneLeft = GetNumPartyMembers() + 1 < LFT.currentGroupSize
LFT.currentGroupSize = GetNumPartyMembers() + 1
LFT.inGroup = GetNumRaidMembers() == 0 and GetNumPartyMembers() > 0
lfdebug(GetNumPartyMembers())
if LFT.inGroup then
if LFT.isLeader then
else
getglobal('LFTMain'):Hide()
end
else -- i left the group OR everybody left
--getglobal('LFTGroupReady'):Hide()
if LFTInvite.inviteIndex == 2 then
return false
end
leaveQueue()
return false
end
if someoneJoined then
if LFT.findingMore and LFT.isLeader then
lfdebug('finding more and isleader')
local newName = ''
local joinedManually = false
for i = 1, GetNumPartyMembers() do
local name = UnitName('party' .. i)
local fromQueue = name == LFT.group[LFT.LFMDungeonCode].tank or
name == LFT.group[LFT.LFMDungeonCode].healer or
name == LFT.group[LFT.LFMDungeonCode].damage1 or
name == LFT.group[LFT.LFMDungeonCode].damage2 or
name == LFT.group[LFT.LFMDungeonCode].damage3
lfdebug('from queue check')
lfdebug('current roster = ' .. LFT.group[LFT.LFMDungeonCode].tank ..
',' .. LFT.group[LFT.LFMDungeonCode].healer .. ',' .. LFT.group[LFT.LFMDungeonCode].damage1 ..
',' .. LFT.group[LFT.LFMDungeonCode].damage2 .. ',' .. LFT.group[LFT.LFMDungeonCode].damage3 .. ',)')
if not fromQueue then
newName = name
joinedManually = true
end
end
if joinedManually then --joined manually, dont know his role
lfdebug('joined manually ')
LFTFillAvailableDungeonsDelay.queueAfterIfPossible = GetNumPartyMembers() < (DEV_GROUP_SIZE - 1)
lfdebug('num party = ' .. GetNumPartyMembers() .. ' < 4 ?')
if not LFTFillAvailableDungeonsDelay.queueAfterIfPossible then --group full
SendAddonMessage(LFT_ADDON_CHANNEL, "LFMPartyReady:" .. LFT.LFMDungeonCode .. ":" .. LFTObjectives.objectivesComplete .. ":" .. LFT.tableSize(LFT.bosses[LFT.LFMDungeonCode]), "PARTY")
return false -- so it goes into check full in timer
end
leaveQueue()
-- findMore()
else --joined from the queue, we know his role, check if group is full
-- lfdebug('player ' .. newName .. ' joined from queue')
lfdebug('check lfm group ready')
if LFT.checkLFMGroupReady(LFT.LFMDungeonCode) then
SendAddonMessage(LFT_ADDON_CHANNEL, "LFMPartyReady:" .. LFT.LFMDungeonCode .. ":" .. LFTObjectives.objectivesComplete .. ":" .. LFT.tableSize(LFT.bosses[LFT.LFMDungeonCode]), "PARTY")
else
SendAddonMessage(LFT_ADDON_CHANNEL, "weInQueue:" .. LFT.LFMDungeonCode, "PARTY")
end
end
end
end
if someoneLeft then
getglobal('LFTReadyStatus'):Hide()
getglobal('LFTGroupReady'):Hide()
-- find who left and update virtual group
if LFT.findingMore and LFT.isLeader then
--inc some getto code
--
local leftName = ''
local stillInParty = false
if LFT.group[LFT.LFMDungeonCode].tank ~= '' and LFT.group[LFT.LFMDungeonCode].tank ~= me then
leftName = LFT.group[LFT.LFMDungeonCode].tank
stillInParty = false
for i = 1, GetNumPartyMembers() do
local name = UnitName('party' .. i)
if leftName == name then
stillInParty = true
break
end
end
if not stillInParty then
LFT.group[LFT.LFMDungeonCode].tank = ''
LFT.LFMGroup.tank = ''
lfprint(leftName .. ' (' .. COLOR_TANK .. 'Tank' .. COLOR_WHITE .. ') has been removed from the queue group.')
end
end
--
if LFT.group[LFT.LFMDungeonCode].healer ~= '' and LFT.group[LFT.LFMDungeonCode].healer ~= me then
leftName = LFT.group[LFT.LFMDungeonCode].healer
stillInParty = false
for i = 1, GetNumPartyMembers() do
local name = UnitName('party' .. i)
if leftName == name then
stillInParty = true
break
end
end
if not stillInParty then
LFT.group[LFT.LFMDungeonCode].healer = ''
LFT.LFMGroup.healer = ''
lfprint(leftName .. ' (' .. COLOR_HEALER .. 'Healer' .. COLOR_WHITE .. ') has been removed from the queue group.')
end
end
--
if LFT.group[LFT.LFMDungeonCode].damage1 ~= '' and LFT.group[LFT.LFMDungeonCode].damage1 ~= me then
leftName = LFT.group[LFT.LFMDungeonCode].damage1
stillInParty = false
for i = 1, GetNumPartyMembers() do
local name = UnitName('party' .. i)
if leftName == name then
stillInParty = true
break
end
end
if not stillInParty then
LFT.group[LFT.LFMDungeonCode].damage1 = ''
LFT.LFMGroup.damage1 = ''
lfprint(leftName .. ' (' .. COLOR_DAMAGE .. 'Damage' .. COLOR_WHITE .. ') has been removed from the queue group.')
end
end
--
if LFT.group[LFT.LFMDungeonCode].damage2 ~= '' and LFT.group[LFT.LFMDungeonCode].damage2 ~= me then
leftName = LFT.group[LFT.LFMDungeonCode].damage2
stillInParty = false
for i = 1, GetNumPartyMembers() do
local name = UnitName('party' .. i)
if leftName == name then
stillInParty = true
break
end
end
if not stillInParty then
LFT.group[LFT.LFMDungeonCode].damage2 = ''
LFT.LFMGroup.damage2 = ''
lfprint(leftName .. ' (' .. COLOR_DAMAGE .. 'Damage' .. COLOR_WHITE .. ') has been removed from the queue group.')