This repository was archived by the owner on Oct 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaieCallToArms.lua
More file actions
4203 lines (3347 loc) · 145 KB
/
aieCallToArms.lua
File metadata and controls
4203 lines (3347 loc) · 145 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
--[[ ---------------------------------------------------------------
Call To Arms - Updated for Cata by Xcamr aka Rockyoysters
English Localization Update and Testing by Sesub
---------------------------------------------------------------
@Author: Larry Lewis
@Author: Sacha Beharry
@Author: Eike Hanus (R10E)
@Author: David Glassbrenner
@DateCreated: 26th May 2005
@LastUpdate: 21 February 2011
@Release: Cata
@Interface: 40000
--]]
CTA_RELEASEVERSION = "aieCTA 4.0.8.0";
CTA_RELEASENOTE = "aieCTA 4.0.8.0";
CTA_THIS_VERSION = 408;
--[[
E-Mail David Glassbrenner: lioneljonson@gmail.com
Project Name: Call To Arms, Grouping Tool for World of Warcraft
--]]
--[[
---------------------------------------------------------------
NOTES ABOUT BUGS:
There is a problem with his addon and CensusPlus from warcraftrealms.com
---------------------------------------------------------------
--]]
--[[ Variables
---------------------------------------------------------------
--]]
CTA_DEFAULT_RAID_CHANNEL = "aieCTAChannel";
CTA_INVITE_MAGIC_WORD = "inviteme";
CTA_PLAYER = "player";
CTA_MAX_RESULTS_ITEMS = 20;
CTA_MAX_BLACKLIST_ITEMS = 15;
CTA_ALLIANCE = "Alliance";
CTA_HORDE = "Horde";
CTA_DEFAULT_LFM_TRIGGER = "lf%d?m";
CTA_DEFAULT_LFG_TRIGGER = "lfg";
aieCTA_SavedVariables = {
version = 0,
runCount = 0,
GreyList = {},
MinimapArcOffset = 223,
MinimapRadiusOffset = 75,
MinimapMsgArcOffset = 296,
MinimapMsgRadiusOffset = 95,
MainFrameTransparency = 0.85,
MonitorLfg = 1,
FilterLfg = 1,
MuteLFG = 1,
ShowOnMinimap = 1,
lfgTrigger = CTA_DEFAULT_LFG_TRIGGER,
lfmTrigger = CTA_DEFAULT_LFM_TRIGGER,
messageList = {},
FilterLevel = 5,
timeLastMsgAdded = 0,
};
CTA_CommunicationChannel = "aieCTAChannel";
CTA_MyRaid = nil;
CTA_FilteredResultsList = {};
CTA_ResultsListOffset = 0;
CTA_BlackList = {};
CTA_PlayerListOffset = 0;
CTA_MyRaidIsOnline = nil;
CTA_IgnoreBlacklisted = 1;
local CTA_RAID_TYPE_PVP = 1;
local CTA_RAID_TYPE_PVE = 0;
local CTA_RP_TYPE = 1;
local CTA_GREYLISTED = 0;
local CTA_BLACKLISTED = 1;
local CTA_WHITELISTED = 2;
local CTA_MESSAGE = "M";
local CTA_GENERAL = "I";
local CTA_GROUP_UPDATE = "G";
local CTA_BLOCK = "X";
local CTA_SEARCH = "S";
CTA_NUM_CLASSES = 10
local CTA_MESSAGE_COLOURS = {
M = { r = 1, b = 1, g = 0.5 },
I = { r = 1, b = 0.5, g = 1 },
G = { r = 0.5, b = 0.5, g = 1 },
X = { r = 1, b = 0.5, g = 0.5 },
S = { r = 0.5, b = 1, g = 0.5 }
};
local CTA_MyRaidPassword = nil;
local CTA_UpdateTicker = 0.0;
local CTA_SearchTimer = 0;
local CTA_SelectedResultListItem = 0;
local CTA_ChannelSpam = {};
local CTA_SpamTimer = 0;
local CTA_PendingMembers = {};
local CTA_GraceTimer = 0;
local CTA_HostingRaidGroup = nil;
CTA_InvitationRequests = {};
local CTA_OutstandingRequests = 0;
local CTA_RequestTimer = 0;
local CTA_myguild = nil;
local CTA_myname = nil;
CTA_PollBroadcast = nil;
CTA_PollApplyFilters = nil;
CTA_TimeSinceLastBroadcast = 0;
CTA_TimeSinceLastFilter = 0
CTA_RawGroupList = {};
CTA_JoinedChannel = nil;
CTA_AcidSummary = nil;
CTA_AnnounceTimer = 0;
CTA_WhoName = nil;
-- Search
CTA_MessageList = {};
-- R7 BEGIN
local lfxChatMessageList = {};
CTA_AutoAnnounce = nil;
CTA_ForwardThrottle = 10; --250
CTA_ForwardTimer = CTA_ForwardThrottle;
CTA_WhoFlag = nil;
CTA_AcidDetails = nil;
CTA_PlayerIsAFK = nil;
CTA_Classes = {};
--R7 END
--R11
CTA_ClassColors = {};
CTA_ClassColors["Priest"] = "ffffff";
CTA_ClassColors["Mage"] = "68ccef";
CTA_ClassColors["Warlock"] = "9382c9";
CTA_ClassColors["Druid"] = "ff7c0a";
CTA_ClassColors["Hunter"] = "aad372";
CTA_ClassColors["Rogue"] = "fff468";
CTA_ClassColors["Warrior"] = "c69b6d";
CTA_ClassColors["Paladin"] = "f48cba";
CTA_ClassColors["Shaman"] = "badb00";
CTA_ClassColors["Death Knight"] = "c41f3b";
CTA_ClassColors[CTA_PRIEST] = "ffffff"; --= { id=1, txMin=0.50, txMax=0.75, tyMin=0.25, tyMax=0.50 };
CTA_ClassColors[CTA_MAGE] = "68ccef"; --= { id=2, txMin=0.25, txMax=0.50, tyMin=0.00, tyMax=0.25 };
CTA_ClassColors[CTA_WARLOCK] = "9382c9"; --= { id=3, txMin=0.75, txMax=1.00, tyMin=0.25, tyMax=0.50 };
CTA_ClassColors[CTA_DRUID] = "ff7c0a"; --= { id=4, txMin=0.75, txMax=1.00, tyMin=0.00, tyMax=0.25 };
CTA_ClassColors[CTA_HUNTER] = "aad372"; --= { id=5, txMin=0.00, txMax=0.25, tyMin=0.25, tyMax=0.50 };
CTA_ClassColors[CTA_ROGUE] = "fff468"; --= { id=6, txMin=0.50, txMax=0.75, tyMin=0.00, tyMax=0.25 };
CTA_ClassColors[CTA_WARRIOR] = "c69b6d"; --= { id=7, txMin=0.00, txMax=0.25, tyMin=0.00, tyMax=0.25 };
CTA_ClassColors[CTA_PALADIN] = "f48cba"; --= { id=8, txMin=0.00, txMax=0.25, tyMin=0.50, tyMax=0.75 };
CTA_ClassColors[CTA_SHAMAN] = "badb00"; --= { id=9, txMin=0.25, txMax=0.50, tyMin=0.25, tyMax=0.50 };
CTA_ClassColors[CTA_DEATHKNIGHT] = "c41f3b";
CTA_IsAllianceFactionUser = nil;
CTA_Reload = 1;
CTA_UI = {};
CTA_UI.getString = function( uiObj, defaultVal )
local val = uiObj:GetText();
if( not val or val == "" ) then
return defaultVal;
else
return val;
end
end
local CLR = {}
function CLR:VALUE(s)
local v
if type(s) == "nil" then
v = "nil"
else
v = tostring(s)
end
return string.format("|cffffa0a0%s|r", v)
end
CTA_UI.getNumber = function( uiObj, defaultVal, minVal, maxVal )
for val in string.gmatch( uiObj:GetText(), "(%d+)" ) do
val = tonumber( val );
if( val >= minVal and val <= maxVal ) then
return val;
end
end
return defaultVal;
end
--[[ ---------------------------------------------------------------
OnLoad and Slash Commands
---------------------------------------------------------------
--]]
--[[ ---------------------------------------------------------------
Register events and hook functions.
---------------------------------------------------------------
--]]
function CTA_OnLoad(self)
--Register Slash Command
SlashCmdList["CallToArmsCOMMAND"] = CTA_SlashHandler;
SLASH_CallToArmsCOMMAND1 = "/cta";
--Register Event Listeners
self:RegisterEvent("CHAT_MSG_SYSTEM");
self:RegisterEvent("PARTY_MEMBERS_CHANGED");
self:RegisterEvent("PARTY_LEADER_CHANGED");
self:RegisterEvent("CHAT_MSG_WHISPER");
self:RegisterEvent("CHAT_MSG_CHANNEL");
--self:RegisterEvent("CHAT_MSG_GUILD");
self:RegisterEvent("RAID_ROSTER_UPDATE");
--self:RegisterEvent("WHO_LIST_UPDATE");
self:RegisterEvent("VARIABLES_LOADED");
self:RegisterEvent("PLAYER_ENTERING_WORLD");
--Announce AddOn to user
CTA_Error("-[ CTA "..CTA_RELEASEVERSION.." ]-");
CTA_Classes[1] = CTA_PRIEST;
CTA_Classes[2] = CTA_MAGE;
CTA_Classes[3] = CTA_WARLOCK;
CTA_Classes[4] = CTA_DRUID;
CTA_Classes[5] = CTA_HUNTER;
CTA_Classes[6] = CTA_ROGUE;
CTA_Classes[7] = CTA_WARRIOR;
CTA_Classes[8] = CTA_PALADIN;
CTA_Classes[9] = CTA_SHAMAN;
CTA_Classes[10] = CTA_DEATHKNIGHT;
CTA_Classes[CTA_PRIEST] = 1;
CTA_Classes[CTA_MAGE] = 2;
CTA_Classes[CTA_WARLOCK] = 3;
CTA_Classes[CTA_DRUID] = 4;
CTA_Classes[CTA_HUNTER] = 5;
CTA_Classes[CTA_ROGUE] = 6;
CTA_Classes[CTA_WARRIOR] = 7;
CTA_Classes[CTA_PALADIN] = 8;
CTA_Classes[CTA_SHAMAN] = 9;
CTA_Classes[CTA_DEATHKNIGHT] = 10;
CTA_myguild = "<"..(GetGuildInfo("player") or "_")..">";
CTA_myname = UnitName("player")
print(CTA_myguild, CTA_myname);
local function myChatFilter(msg)
--If chatFilter returns true, the message is discarded.
--If chatFilter returns false the second parameter as non-false/nil, the current message text is replaced with your return
if( aieCTA_SavedVariables.muteLFGChannel and ( arg9 or "?" ) == CTA_MONITOR_CHANNEL_NAME ) then
print("--MUTE--")
return;
end
--print("filtering ", this and this:GetName() or "nil", arg2 or "nil", aieCTA_SavedVariables.muteLFGChannel or "nil")
--if (true) then
-- return false, msg
--end
-- R5 : effectively makes blacklist an extended ignore list as well
if( arg2 and CTA_IgnoreBlacklisted and CTA_FindInList( arg2, CTA_BlackList ) ) then
--CTA_IconMsg( arg2, CTA_BLOCK ); -- left for testing, disabled for R7
CTA_LogMsg( CTA_BLOCKED_MESSAGE..arg2, CTA_BLOCK ); -- R7
return;
end
if( strsub(event, 1, 16) == "CHAT_MSG_WHISPER" ) then
-- R11b7: back to hiding all auto-whispers until R12
--[[
if( msg and strsub(msg, 1, 5) == "[CTA]" ) then --R11b5: visible to cta recipients as well
--CTA_IconMsg( arg2, CTA_MESSAGE );
if( arg2 == nil or arg2 ~= UnitName("player") ) then
CTA_LogMsg( ( arg2 or "nil" )..": "..msg, CTA_MESSAGE );
return; --R3
else
CTA_LogMsg( "Message was shown in chat, arg2 = "..arg2, CTA_MESSAGE );
end
end
--]]
if( msg and strsub(msg, 2, 4) == "CTA" ) then
if( strlen(event) > 16 or arg2 == nil or arg2 == UnitName("player") ) then
CTA_LogMsg( ( arg2 or "nil" )..": "..msg, CTA_MESSAGE );
return;
end
CTA_LogMsg( ( arg2 or "nil" )..": "..msg, CTA_MESSAGE );
end
--
end
if ( not msg or strsub(event, 1, 16) ~= "CHAT_MSG_WHISPER" or strsub(msg, 1, 5) ~= "/cta " ) then -- not msg: R3 bug fix
if( not msg or not CTA_MainFrame:IsVisible() or not string.find( msg, CTA_AWAY_FROM_KEYBOARD) ) then -- not msg: R3 bug fix
return false, msg
end
end
end
--ChatFrame_AddMessageEventFilter("CHAT_MSG_CHANNEL", myChatFilter)
BasicScriptErrors:SetScript("OnShow", CTA_ScriptError );
end
function CTA_ScriptError()
local message = BasicScriptErrorsText:GetText();
if (not message or not string.find( message, "CallToArms" ) ) then
--CTA_Println( "No CallToArms error found" );
return;
end
local extMsg = "Error: "..message;
extMsg = extMsg..", Addons: ";
local numAddons = GetNumAddOns();
for i = 1, numAddons do
if( IsAddOnLoaded( i ) ) then
local name = GetAddOnInfo( i );
extMsg = extMsg..name..", ";
end
end
extMsg = extMsg.." Client: "..GetLocale();
CTA_ErrorReportingFrameEditBox:SetText( extMsg );
CTA_ErrorReportingFrame:Show();
end
--[[ CTA_SlashHandler(com)
---------------------------------------------------------------
For Slash Commands (surprise)
@arg The command String
--]]
function CTA_SlashHandler(com)
if( not com or com=="" ) then
CTA_Println( CTA_CALL_TO_ARMS.." "..CTA_RELEASEVERSION );
CTA_Println( CTA_COMMANDS..": "..CTA_HELP.." | "..CTA_TOGGLE.." | "..CTA_ANNOUNCE_GROUP.." | "..CTA_DISSOLVE_RAID);
CTA_Println( CTA_COMMANDS..": "..CTA_TOGGLE_MINIMAP );
--CTA_Println( "Beta commands:" );
--CTA_Println( "/error: starts CTA error reporting function. Only works if an error has already occurred." );
return;
end
if( com==CTA_HELP ) then
CTA_Println( CTA_TOGGLE..": "..CTA_TOGGLE_HELP );
CTA_Println( CTA_ANNOUNCE_GROUP..": "..CTA_ANNOUNCE_GROUP_HELP );
CTA_Println( CTA_DISSOLVE_RAID..": "..CTA_DISSOLVE_RAID_HELP );
return;
end
if( com==CTA_TOGGLE ) then
if( CTA_MainFrame:IsVisible() ) then
CTA_MainFrame:Hide();
else
CTA_MainFrame:Show();
end
return;
end
if( com==CTA_TOGGLE_MINIMAP ) then
if( CTA_MinimapIcon:IsVisible() ) then
CTA_MinimapIcon:Hide();
else
CTA_MinimapIcon:Show();
end
return;
end
if( com==CTA_DISSOLVE_RAID ) then
if( IsRaidLeader() ) then
CTA_DissolveRaid();
else
CTA_Println( CTA_MUST_BE_LEADER_TO_DISSOLVE_RAID );
end
return;
end
if( com==CTA_AUTO_ANNOUNCE_OFF ) then
CTA_AutoAnnounce = nil;
CTA_AnnounceToLFGButton:SetText( CTA_ANNOUNCE_LFG_BTN );
CTA_AnnounceToLFGButton2:SetText( CTA_ANNOUNCE_LFG_BTN );
-- CTA_AnnounceTimer = 0; -- R10E
CTA_Println( CTA_AUTO_ANNOUNCE_TURNED_OFF );
return;
end
if( com==CTA_ANNOUNCE_GROUP.." on" ) then
CTA_AutoAnnounce = CTA_MONITOR_CHANNEL_NAME;
if CTA_AnnounceTimer == 0 then CTA_AnnounceTimer = 5 end; -- R10E
CTA_Println( CTA_AUTO_ANNOUNCE_TURNED_ON..CTA_AnnounceTimer..CTA_SECONDS );
CTA_AnnounceToLFGButton:SetText( CTA_ANNOUNCE_LFG_BTN_OFF );
CTA_AnnounceToLFGButton2:SetText( CTA_ANNOUNCE_LFG_BTN_OFF );
end
--[ [
if( com=="error" ) then
CTA_ScriptError();
return;
end
--]]
if( com == "clear_lfx" ) then
aieCTA_SavedVariables.messageList = {};
aieCTA_SavedVariables.messageList[GetRealmName()] = aieCTA_SavedVariables.messageList[GetRealmName()] or {};
aieCTA_SavedVariables.messageList[GetRealmName()][1] = aieCTA_SavedVariables.messageList[GetRealmName()][1] or {};
aieCTA_SavedVariables.messageList[GetRealmName()][2] = aieCTA_SavedVariables.messageList[GetRealmName()][2] or {};
table.wipe(CTA_MessageList);
if( (UnitFactionGroup("player")) == "Alliance" ) then
CTA_IsAllianceFactionUser = 1;
for k,v in pairs(aieCTA_SavedVariables.messageList[GetRealmName()][1]) do
CTA_MessageList[k] = v
end
CTA_Util.chatPrintln( "Showing Alliance Messages" );
else
for k,v in pairs(aieCTA_SavedVariables.messageList[GetRealmName()][2]) do
CTA_MessageList[k] = v
end
CTA_Util.chatPrintln( "Showing Horde Messages" );
end
CTA_UpdateResults();
end
if( com == "faction" ) then
if( CTA_IsAllianceFactionUser ) then
CTA_Util.chatPrintln( "Alliance Character" );
else
CTA_Util.chatPrintln( "Horde Character" );
end
end
if( com == "channels" ) then
local channelList = {EnumerateServerChannels()};
for i=1, #channelList do
CTA_Util.chatPrintln( channelList[i] );
end
end
end
--[[ ---------------------------------------------------------------
OnUpdate and OnEvent
---------------------------------------------------------------
--]]
--[[ CTA_OnUpdate()
---------------------------------------------------------------
Keep the <var>CTA_UpdateTicker</var> running.
@arg The time elapsed since the last call to this function
--]]
function CTA_OnUpdate(self, elapsed ) -- Called by XML on Update
CTA_UpdateTicker = CTA_UpdateTicker + elapsed;
CTAWM.onUpdate( self, elapsed );
if ( CTA_UpdateTicker < 1 ) then
return
end
if( CTA_AnnounceTimer > 0 ) then
CTA_AnnounceTimer = CTA_AnnounceTimer - 1;
-- r7
if( CTA_AnnounceTimer == 0 and CTA_AutoAnnounce ) then
if( CTA_PlayerIsAFK ) then
CTA_SlashHandler(CTA_AUTO_ANNOUNCE_OFF)
CTA_Println( CTA_AFK_ANNOUNCE_OFF );
elseif ( CTA_GetNumGroupMembers() > 1 and not CTA_MyRaid ) then
autoannouce = nil;
CTA_Println( CTA_JOIN_ANNOUNCE_OFF );
elseif( CTA_MyRaidIsOnline and CTA_MyRaid ) then
CTA_MyRaidInstantUpdate();
CTA_SendChatMessage( CTA_AcidSummary, "CHANNEL", CTA_MONITOR_CHANNEL_NAME );
CTA_LogMsg( "Sent to lfg channel: ".. CTA_AcidSummary );
CTA_AnnounceTimer = 300;
PlaySound("TellMessage");
CTA_IconMsg( CTA_ANNOUNCED_LFM );
CTA_Println( CTA_ANNOUNCED_LFM_EXT );
elseif( CTA_LGMPrefixLabel:GetText() and CTA_LFGDescriptionEditBox:GetText() ~= "" ) then
CTA_SendChatMessage( CTA_LGMPrefixLabel:GetText()..CTA_LFGDescriptionEditBox:GetText(), "CHANNEL", CTA_MONITOR_CHANNEL_NAME ); --CTA_AutoAnnounce );
CTA_LogMsg( "Sent to lfg channel: ".. CTA_LGMPrefixLabel:GetText()..CTA_LFGDescriptionEditBox:GetText() );
CTA_AnnounceTimer = 300;
PlaySound("TellMessage");
CTA_IconMsg( CTA_ANNOUNCED_LFG );
CTA_Println( CTA_ANNOUNCED_LFG_EXT );
else
CTA_SlashHandler(CTA_AUTO_ANNOUNCE_OFF);
CTA_Println( CTA_NOTHING_TO_ANNOUNCE );
end
end
-- /r7
end
CTA_TimeSinceLastBroadcast = CTA_TimeSinceLastBroadcast + 1;
if( CTA_TimeSinceLastBroadcast > 30 ) then
CTA_TimeSinceLastBroadcast = 0;
if( CTA_MyRaidIsOnline and CTA_MyRaid ) then
CTA_PollBroadcast = 1;
elseif( CTA_LFGCheckButton:GetChecked() and CTA_LGMPrefixLabel:GetText() and CTA_LFGDescriptionEditBox:GetText() ~= "" ) then
if( CTA_GetNumGroupMembers() > 1 ) then
CTA_LFGCheckButton:SetChecked( 0 );
CTA_Println( CTA_JOIN_STOP_LFG );
else
CTA_PollBroadcast = 3;
end
end
--/r7
end
CTA_TimeSinceLastFilter = CTA_TimeSinceLastFilter + 1;
if( CTA_TimeSinceLastFilter > 10 ) then
CTA_TimeSinceLastFilter = 0;
CTA_PollApplyFilters = 1;
end
CTA_SpamTimer = CTA_SpamTimer + CTA_UpdateTicker;
if( CTA_SpamTimer > 7 ) then
CTA_ChannelSpam = {};
CTA_SpamTimer = 0;
CTA_UpdateMinimapTexture()
-- Ok, piggybacking 10s SpamTimer to implement
-- Polled Broadcasting and
-- Auto Search Updates.
if( CTA_PollApplyFilters ) then
CTA_TimeSinceLastFilter = 0;
CTA_ApplyFiltersToGroupList();
end
if( CTA_PollBroadcast and (not CTA_PlayerIsAFK) ) then
CTA_TimeSinceLastBroadcast = 0;
if( CTA_PollBroadcast == 3 ) then --r7
if( CTA_LFGCheckButton:GetChecked() and CTA_LGMPrefixLabel:GetText() and CTA_LFGDescriptionEditBox:GetText() ~= "" ) then
local tim = CTA_GetGameTime();
local lfgT = CTA_LFGDescriptionEditBox:GetText();
--
if string.find( lfgT, ":") then lfgT = string.gsub(lfgT, ":", "."); end;
CTA_SendChatMessage( "/cta B<"..tim..":"..lfgT..":"..CTA_RELEASEVERSION..">", "CHANNEL", GetChannelName( CTA_CommunicationChannel ) );
CTA_LogMsg( "CTA Broadcast: "..tim..":"..lfgT..":"..CTA_RELEASEVERSION..">");
end
CTA_PollBroadcast = nil;
elseif( CTA_PollBroadcast == 2 ) then
CTA_SendChatMessage("/cta A<>", "CHANNEL", GetChannelName( CTA_CommunicationChannel ) );
CTA_PollBroadcast = nil;
elseif( CTA_MyRaidIsOnline and CTA_MyRaid ) then
CTA_BroadcastRaidInfo();
end
end
end
if( CTA_GraceTimer > 0 ) then
CTA_GraceTimer = CTA_GraceTimer - CTA_UpdateTicker;
--CTA_IconMsg( floor(CTA_GraceTimer) );
if( CTA_GraceTimer <= 0 ) then
if( CTA_MyRaid and not CTA_PlayerCanHostGroup() ) then
CTA_MyRaid = nil;
CTA_MyRaidIsOnline = nil;
CTA_HostingRaidGroup = nil;
CTA_SearchFrame:Show();
CTA_MyRaidFrame:Hide();
CTA_StartRaidFrame:Hide();
else
CTA_MyRaidInstantUpdate();
end
end
end
-- using new who system in r11b2 for results
CTA_RequestTimer = CTA_RequestTimer + CTA_UpdateTicker;
if( CTA_RequestTimer > 2 ) then
for i = 1, #CTA_MessageList do
if( not CTA_MessageList[i].who ) then
local name = CTA_MessageList[i].op or CTA_MessageList[i].author;
CTA_MessageList[i].whoAttempts = CTA_MessageList[i].whoAttempts or 0;
CTA_MessageList[i].who = CTAWM.toOldFormat(name);
if( CTA_MessageList[i].who ) then
--CTA_Util.logPrintln( "Got who info for ".. CLR:VALUE(name).." after ".. CLR:VALUE(CTA_MessageList[i].whoAttempts) .." attempts");
CTA_MessageList[i].whoAttempts = 0;
else
if( CTA_MessageList[i].whoAttempts < 5 ) then
if( CTAWM.getPositionInQueue( name ) == 0 ) then
CTA_MessageList[i].whoAttempts = CTA_MessageList[i].whoAttempts + 1;
--CTA_Util.logPrintln( "Asking for who info for ".. CLR:VALUE(name) ..", attempt ".. CLR:VALUE(CTA_MessageList[i].whoAttempts) );
CTAWM.addNameToWhoQueue( name );
end
else
CTA_Util.logPrintln( "Could not get who info for "..CLR:VALUE(name) .." after 5 attempts; setting who info as blank" );
local entry = {};
entry.level = 0;
CTA_MessageList[i].who = entry;
end
end
end
end
-- R11B4: updating automatic invitations to use WhoManager
if( CTA_OutstandingRequests > 0 ) then
CTA_LogMsg( CTA_OutstandingRequests..CTA_INVITATION_REQUEST_OUTSTANDING );
for name, data in pairs(CTA_InvitationRequests) do
if( data.status == 1 ) then
local pdata = CTAWM.getInformation( name );
if( pdata ) then
CTA_LogMsg( CTA_VALIDATING_REQUEST_FROM..name );
--Data format: { time, level, race, class, guild }
local level, class, guild = pdata[2], pdata[4], pdata[5];
CTA_OutstandingRequests = CTA_OutstandingRequests - 1;
if( CTA_MyRaid and level >= CTA_MyRaid.minLevel and string.find( CTA_GetClassString(CTA_MyRaid.classes),class) ) then
local v1,v2,v3,v4 = strsplit(" ", guild);
local validMainGuild = nil;
if(v1 == 'alea' and v2 == 'iacta' and v3 == 'est') then
validMainGuild = 1;
end
local subguild = v4;
local validSubGuild = nil;
for k,v in pairs(CTA_SUBGUILDS) do
if( v == subguild ) then
validSubGuild = 1;
end
end
if(subguild and validSubGuild == 1 and validMainGuild == 1) then
CTA_LogMsg( CLR:VALUE(name).."\'s request processed: Valid player - Invitation sent" );
InviteUnit( name );
CTA_InvitationRequests[name].status = 2;
CTA_InvitationRequests[name].class = class;
CTA_InvitationRequests[name].level = level;
CTA_IconMsg( CTA_INVITATION_SENT_TO.." "..name, CTA_GROUP_UPDATE );
CTA_SendAutoMsg( CTA_INVITATION_SENT_MESSAGE, name );
CTA_MyRaidInstantUpdate();
else
CTA_InvitationRequests[name] = nil;
CTA_LogMsg( CLR:VALUE(name).."\'s request processed: Invalid player - request removed" );
CTA_SendAutoMsg( CTA_WRONG_GUILD, name);
end
else
CTA_InvitationRequests[name] = nil;
CTA_LogMsg( CLR:VALUE(name).."\'s request processed: Invalid player - request removed" );
CTA_SendAutoMsg( CTA_WRONG_LEVEL_OR_CLASS, name );
end
else
data.whoAttempts = data.whoAttempts or 0;
if( data.whoAttempts < 5 ) then
if( CTAWM.getPositionInQueue( name ) == 0 ) then
data.whoAttempts = data.whoAttempts + 1;
--CTA_Util.logPrintln( "Asking for who info for ".. CLR:VALUE(name)..", attempt ".. data.whoAttempts ); -- R11B5: fixed bug
CTAWM.addNameToWhoQueue( name );
else
CTA_Util.logPrintln( "Who request for ".. CLR:VALUE(name).." is queued in position ".. CTAWM.getPositionInQueue( name ) );
end
else
CTA_Util.logPrintln( "Could not get who info for "..CLR:VALUE(name) .." after 5 attempts; removing request" );
--CTA_InvitationRequests[name] = nil;
CTA_LogMsg( "Player "..name.." could not be found. Removing from requests list." );
CTA_RemoveRequest(name); -- R11B5: fixed bug - was (CTA_WhoName)
end
end
end
end
end
CTA_RequestTimer = 0;
end
--[[
CTA_RequestTimer = CTA_RequestTimer + CTA_UpdateTicker;
if( CTA_RequestTimer > 5 ) then
if( CTA_OutstandingRequests > 0 ) then
CTA_LogMsg( CTA_OutstandingRequests..CTA_INVITATION_REQUEST_OUTSTANDING );
for name, data in CTA_InvitationRequests do
if( data.status == 1 ) then
SetWhoToUI(1);
CTA_WhoName = name;
SendWho("n-"..name);
SendWho(name);
CTA_LogMsg( CTA_VALIDATING_REQUEST_FROM..name );
break;
end
end
end
CTA_RequestTimer = 0;
end
--]]
CTA_ForwardTimer = CTA_ForwardTimer - 1;
if( CTA_ForwardTimer == 0 ) then
if( lfxChatMessageList[#lfxChatMessageList] ) then
CTA_Util.sendChatMessage( lfxChatMessageList[#lfxChatMessageList].message, "CHANNEL", GetChannelName( CTA_CommunicationChannel ) );
--CTA_Util.chatPrintln( ">>"..lfxChatMessageList[#lfxChatMessageList].message );
local name = lfxChatMessageList[#lfxChatMessageList].author;
table.remove( lfxChatMessageList, #lfxChatMessageList );
CTA_Util.logPrintln( "Forwarded msg from <"..CLR:VALUE(name)..">, pending relay count: "..#lfxChatMessageList );
end
CTA_ForwardTimer = CTA_ForwardThrottle;
end
CTA_UpdateTicker = 0;
end
function CTA_ForwardMessage(msg)
table.insert(lfxChatMessageList, 1, msg)
CTA_ForwardTimer = CTA_ForwardThrottle;
end
function CTA_MinimapIconOnClick(button)
if button == "RightButton" then
-- no op
else
CTA_ToggleMainFrame()
end
end
function CTA_UpdateMinimapTexture()
--[[
local _, _, _, _, _, _, _, _, _, _, lfgStatus, lfmStatus = GetLookingForGroup();
if lfgStatus or lfmStatus then
SetDesaturation(CTA_MinimapIconBgTexture, false)
else
SetDesaturation(CTA_MinimapIconBgTexture, true)
end
--]]
SetDesaturation(CTA_MinimapIconBgTexture, false)
end
--[[ CTA_OnEvent()
---------------------------------------------------------------
Event handler.
@arg The event to be handled
--]]
function CTA_OnEvent(self, event,... ) -- Called by XML on Event
local arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9 = ...;
if(event == "PLAYER_ENTERING_WORLD" and CTA_Reload ) then --"VARIABLES_LOADED") then
CTA_InitWorld(self,event,...)
end
-- for R2 to see if we can tell when a player does not accept your invitation to join the group
if ( event == "CHAT_MSG_SYSTEM" ) then
if ( string.find( arg1, CTA_DECLINES_YOUR_INVITATION ) or string.find( arg1, CTA_IS_ALREADY_IN_A_GROUP ) ) then
local name = string.gsub( arg1, "%s*([^%s]+).*", "%1" );
CTA_RemoveRequest( name );
CTA_LogMsg( name..CTA_HAS_DECLINED_INVITATION );
CTA_MyRaidInstantUpdate();
end
if ( string.find( arg1, CTA_NOW_AFK ) ) then
--CTA_Println( "AFK" );
CTA_PlayerIsAFK = 1;
end
if ( string.find( arg1, CTA_NO_LONGER_AFK ) ) then
--CTA_Println( "NOT AFK" );
CTA_PlayerIsAFK = nil;
end
end
-- Listen for Invitation requests
if ( event == "CHAT_MSG_WHISPER" ) then
-- CTA_Util.logPrintln( "Received Whisper: <"..arg1.."> from <"..arg2..">" );
-- If the identity mod is on (and a lot of people in AIE use it),
-- strip out the added on text before processing arg1
local the_arg1 = arg1
for msg in string.gmatch( the_arg1, "%(.*%): (.*)" ) do
the_arg1 = msg
end
-- CTA_Util.logPrintln( "New the_arg1: "..the_arg1.."" );
if( CTA_MyRaidIsOnline and string.lower( strsub(the_arg1, 1, 8) ) == CTA_INVITE_MAGIC_WORD) then
if( not CTA_FindInList( arg2, CTA_BlackList ) ) then -- R2
if( CTA_ChannelSpam[arg2] == nil ) then
CTA_ChannelSpam[arg2] = 0;
end
CTA_ChannelSpam[arg2] = CTA_ChannelSpam[arg2] + 1;
if( CTA_ChannelSpam[arg2] > 12 ) then --r7 4 -> 12
CTA_RemoveRequest( arg2 );
CTA_SendAutoMsg(arg2.." "..CTA_WAS_BLACKLISTED, arg2);
CTA_IconMsg( arg2.." "..CTA_WAS_BLACKLISTED, CTA_BLOCK );
CTA_AddPlayer( arg2, CTA_BLACKLISTED_NOTE, CTA_DEFAULT_STATUS, CTA_DEFAULT_RATING, CTA_BlackList )
else
CTA_ReceiveRaidInvitationRequest( the_arg1, arg2 );
end
end
end
if( CTA_MyRaidIsOnline and CTA_AcidDetails and string.lower( strsub(the_arg1, 1, 7) ) == "details" ) then
CTA_SendAutoMsg( CTA_AcidDetails, arg2 )
end
if( string.lower( strsub(the_arg1, 1, 4) ) == "cta?" ) then
CTA_SendAutoMsg( CTA_ABOUT_CTA_MESSAGE, arg2 )
end
end
-- Listen for LFG Channel messages
if ( event == "CHAT_MSG_CHANNEL" ) then
--arg1 = message, arg2 = sender, arg3 = language, arg4 = channelString
--arg6 = flags, arg8 = channel#, arg9 = channelName
--print("chat msg from: "..arg2)
if( not CTA_JoinedChannel ) then
CTA_Util.joinChannel( CTA_MONITOR_CHANNEL_NAME );
-- Use channel event to delay joining of aieCTAChannel
CTA_Util.joinChannel( CTA_CommunicationChannel );
CTA_JoinedChannel = 1;
end
-- CTA channel relay msgs
if( arg9 == CTA_CommunicationChannel ) then
local entry = {};
-- CTA_Util.logPrintln( "CTA-RELAY: <"..arg1.."> from <"..arg2..">" );
--R7 > Trusted CTA Channel Messages
if( arg1 == "/cta A<>" ) then
for i = 1, #CTA_MessageList do
local name = CTA_MessageList[i].author or "?";
if( name == arg2 and not CTA_MessageList[i].op ) then
table.remove( CTA_MessageList , i );
break;
end
end
CTA_PollApplyFilters = 1;
return;
end
for code, com, opt in string.gmatch( arg1, "/cta A<(%d+):(.+):(.+)>" ) do
local tim = string.sub( code, 1, 6 );
local cla = tonumber( string.sub( code, 7, 10 ) );
local siz = tonumber( string.sub( code, 11, 12 ) );
local max = tonumber( string.sub( code, 13, 14 ) );
local min = tonumber( string.sub( code, 15, 16 ) );
local pro = 0;
local typ = CTA_RAID_TYPE_PVE;
if( siz > 40 ) then
typ = CTA_RAID_TYPE_PVP;
siz = siz - 40;
end
if( max > 40 ) then
pro = 1;
max = max - 40;
end
local whoData = nil;
-- R11B4
local shownInChatAndOrMinimap = nil;
--
for i = 1, #CTA_MessageList do
local name = CTA_MessageList[i].author or "?";
if( name == arg2 and not CTA_MessageList[i].op ) then
whoData = CTA_MessageList[i].who;
shownInChatAndOrMinimap = CTA_MessageList[i].shownInChatAndOrMinimap;
table.remove( CTA_MessageList , i );
break;
end
end
entry.ctaType = "A";
entry.author = arg2 or nil;
entry.message = com or nil;
entry.time = tim or nil;
entry.options = opt or nil;
entry.who = whoData or nil;
entry.op = nil;
entry.pvtype = tonumber(typ) or nil;
entry.size = tonumber(siz) or nil;
entry.maxSize = tonumber(max) or nil;
entry.minLevel = tonumber(min) or nil;
entry.classes = tonumber(cla) or nil;
entry.passwordProtected = tonumber(pro) or nil;
entry.shownInChatAndOrMinimap = shownInChatAndOrMinimap or nil;
table.insert( CTA_MessageList, 1, entry );
CTA_PollApplyFilters = 1;
return;
end
for code, com, opt in string.gmatch( arg1, "/cta B<(%d+):(.+):(.+)>" ) do
-- Remove author from LFX list upon receiving new transmission
local whoData = nil;
-- R11B4
local shownInChatAndOrMinimap = nil;
--
for i = 1, #CTA_MessageList do
local name = CTA_MessageList[i].author or "?";
if( name == arg2 and not CTA_MessageList[i].op ) then
whoData = CTA_MessageList[i].who;
shownInChatAndOrMinimap = CTA_MessageList[i].shownInChatAndOrMinimap;
table.remove( CTA_MessageList , i );
break;
end
end
entry.ctaType = "B";
entry.author = arg2 or nil;
entry.message = com or nil;
entry.time = code or nil;
entry.options = opt or nil;
entry.who = whoData or nil;
entry.op = nil;
entry.pvtype = nil;
entry.size = nil;
entry.maxSize = nil;
entry.minLevel = nil;
entry.classes = nil;
entry.passwordProtected = nil;
entry.shownInChatAndOrMinimap = shownInChatAndOrMinimap or nil;
table.insert( CTA_MessageList, 1, entry );
CTA_PollApplyFilters = 1;
return;
end
for code, opname, com, opt in string.gmatch( arg1, "/cta C<(%d+):(.+):(.+):(.+)>" ) do
--[[ Removed for beta 4 tests
if( CTA_Util.search( com, aieCTA_SavedVariables.lfmTrigger ) > 0 ) then
--]]
-- remove this msg from our forward list
for i = 1, #lfxChatMessageList do
local name = lfxChatMessageList[i].author or "?";
if( name == opname ) then
table.remove( lfxChatMessageList, i );
CTA_Util.logPrintln( "Rx cta forward msg re: <"..CLR:VALUE(opname).."> from <"..CLR:VALUE(arg2).."> - Removed monitor entry" );
break;