forked from iamcal/wow-Non-Compos-Mentis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NonComposMentis.lua
816 lines (589 loc) · 18.1 KB
/
NonComposMentis.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
local AddonName, AddonTable = ...
local Locales = AddonTable["Locales"]
local ClientLocale = GetLocale()
local L = Locales[ClientLocale] or Locales["enUS"]
local sysCol = "ffffff00"
local function ColL(k)
if not L[k] then print(string.format("NCM: key |%s| not found",k)) end
return string.format("|c%s%s|r", sysCol, L[k])
end
NCM = {}
function NCM.OnLoad()
-- reputation values
NCM.reps_loaded = false;
NCM.prev_reps = {};
-- rep changes for this play session
NCM.has_session_data = false;
NCM.play_session = {};
-- farming sessions
NCM.farm_limit_max = 60 * 5; -- 5m
NCM.farm_limit_min = 10;
NCM.farm_session = nil;
NCM.farm_started = nil;
NCM.farm_last = nil;
NCM.farm_delta = nil;
-- dire maul time
NCM.dm_started = nil;
NCM.dm_inside = 0;
end
function NCM.OnReady()
-- init database
_G.NonComposMentisDB = _G.NonComposMentisDB or {};
_G.NonComposMentisDB.opts = _G.NonComposMentisDB.opts or {};
_G.NonComposMentisDB.farms = _G.NonComposMentisDB.farms or {};
NCMOptionsFrame.name = 'Non Compos Mentis';
InterfaceOptions_AddCategory(NCMOptionsFrame);
NCM.NewZone();
NCM.StartFrame();
end
function NCM.ShowOptions()
InterfaceOptionsFrame_OpenToCategory(NCMOptionsFrame.name);
end
function NCM.OptionClick(button, name)
if (name == 'hide') then
if (_G.NonComposMentisDB.opts.hide) then
NCM.Show();
else
NCM.Hide();
end
end
end
function NCM.OnSaving()
NCM.EndDMTimer();
NCM.EndSession();
local point, relativeTo, relativePoint, xOfs, yOfs = NCM.UIFrame:GetPoint()
_G.NonComposMentisDB.opts.frameRef = relativePoint;
_G.NonComposMentisDB.opts.frameX = xOfs;
_G.NonComposMentisDB.opts.frameY = yOfs;
_G.NonComposMentisDB.opts.frameW = NCM.UIFrame:GetWidth();
_G.NonComposMentisDB.opts.frameH = NCM.UIFrame:GetHeight();
end
function NCM.OnEvent(frame, event, ...)
if (event == 'ADDON_LOADED') then
local name = ...;
if name == 'NonComposMentis' then
NCM.OnReady();
end
end
if (event == 'PLAYER_LOGOUT') then
NCM.OnSaving();
end
if (event == 'PLAYER_ALIVE') then
NCM.UpdateFrame();
end
if (event == 'CHAT_MSG_COMBAT_FACTION_CHANGE') then
NCM.UpdateFrame();
end
if (event == 'ZONE_CHANGED_NEW_AREA') then
NCM.NewZone();
end
if (event == 'PLAYER_TARGET_CHANGED') then
NCM.NewTarget();
end
end
function NCM.NewZone()
if (NCM.IsInDireMaul()) then
NCM.StartDMTimer();
NCM.UpdateFrame();
else
NCM.EndDMTimer();
NCM.UpdateFrame();
end
end
function NCM.StartDMTimer()
if (NCM.dm_inside == 0) then
NCM.dm_inside = 1;
NCM.dm_started = GetTime();
end
end
function NCM.EndDMTimer()
if (NCM.dm_inside == 1) then
NCM.dm_inside = 0;
NCM.IncrementSimpleCounter('dm-time', GetTime() - NCM.dm_started);
NCM.UpdateFrame();
end
end
function NCM.IsInDireMaul()
if (GetRealZoneText() == L['Dire Maul']) then
local inInstance, instanceType = IsInInstance()
return (inInstance and instanceType == "party") == true
end
return false
end
function NCM.NewTarget()
local guid = UnitGUID("target");
if (guid) then
local type = tonumber(guid:sub(5,5), 16) % 8;
if (type == 3) then
local uid = tonumber(guid:sub(9,12), 16);
local spawn = guid:sub(13,18);
if (uid == 14338) then
if (not (spawn == _G.NonComposMentisDB.last_knot)) then
_G.NonComposMentisDB.last_knot = spawn;
NCM.IncrementSimpleCounter('dm-knots', 1);
NCM.UpdateFrame();
end
end
end
end
end
function NCM.OnUpdate()
NCM.TryEndSession()
end
function NCM.StartFrame()
NCM.UIFrame = _G["NCMFrame"];
NCM.UpdateFrame();
if (_G.NonComposMentisDB.opts.hide) then
NCM.UIFrame:Hide();
NCMOptionsFrameCheck1:SetChecked(false);
else
NCM.UIFrame:Show();
NCMOptionsFrameCheck1:SetChecked(true);
end
end
function NCM.Show()
_G.NonComposMentisDB.opts.hide = false;
NCM.UIFrame:Show();
NCMOptionsFrameCheck1:SetChecked(true);
print("Non Compos Mentis: Visible");
end
function NCM.Hide()
_G.NonComposMentisDB.opts.hide = true;
NCM.UIFrame:Hide();
NCMOptionsFrameCheck1:SetChecked(false);
print("Non Compos Mentis: Hidden");
end
function NCM.HideButton()
_G.NonComposMentisDB.opts.hide = true;
NCM.UIFrame:Hide();
NCMOptionsFrameCheck1:SetChecked(false);
print("Non Compos Mentis: Hidden");
print(" Use \"/ncm show\" to show again");
end
function NCM.ResetPos()
NCM.Show();
NCM.UIFrame:SetWidth(150);
NCM.UIFrame:ClearAllPoints();
NCM.UIFrame:SetPoint("CENTER", 0, 0);
end
function NCM.Toggle()
if (_G.NonComposMentisDB.opts.hide) then
NCM.Show();
else
NCM.Hide();
end
end
function NCM.FormatNumber(n)
local s = string.format("%d", n);
if (string.len(s) > 4) then
local l = string.len(s);
s = string.sub(s, 1, l - 3) .. ',' .. string.sub(s, l - 2);
end
return s;
end
function NCM.FormatNumberShort(n)
local s = string.format("%d", n);
if (n > 999) then
local l = string.len(s);
return string.sub(s, 1, l - 3) .. 'k';
end
return s;
end
function NCM.FormatPercent(p)
if (p == 0) then
return "0%";
end
local x = string.format("%.1f", p)
if (x == "0.0" or x == "99.9") then x = string.format("%.2f", p) end;
if (x == "0.00" or x == "99.99") then x = string.format("%.3f", p) end;
if (x == "0.000" or x == "99.999") then x = string.format("%.4f", p) end;
return x .. '%';
end
function NCM.UpdateFrame()
NCM.TryEndSession();
-- update text here...
local localeTxt = ""
if not Locales[ClientLocale] then
localeTxt = string.format("NCM: Client Locale '%s' is not localised!\n\n", ClientLocale)
end
local txt = localeTxt;
local indent = " ";
local reps = NCM.GetReps();
--
-- did we get any reps at all?
--
local num_reps = 0;
for _,_ in pairs(reps) do
num_reps = num_reps + 1;
end
if (num_reps == 0) then
_G.NCMFrameScrollFrameText:SetText("Reputations not loaded...");
return
end
--
-- bonuses for humans
--
local race = select(2, UnitRace("player") )
local factor = 1;
if (race == 'Human') then
factor = 1.1;
end
--
-- see what's changed since last update
--
local diffs = {};
local has_diffs = false;
if (NCM.reps_loaded) then
for k,v in pairs(reps) do
local old_v = NCM.prev_reps[k];
if (old_v) then
if (not (v == old_v)) then
diffs[k] = v - old_v;
has_diffs = true;
NCM.has_session_data = true;
NCM.play_session[k] = (NCM.play_session[k] or 0) + diffs[k];
end
end
end
else
NCM.reps_loaded = true;
end
NCM.prev_reps = reps;
NCM.CheckDiffsAndIncrement(diffs[L['Ravenholdt']], L['Ravenholdt'], 5 * factor);
NCM.CheckDiffsAndIncrement(diffs[L['Bloodsail Buccaneers']], L['Bloodsail Buccaneers'], 25 * factor);
if (NCM.IsInDireMaul()) then
NCM.CheckDiffsAndIncrementCount(diffs['Booty Bay'], 'free-knot', 350 * factor);
NCM.CheckDiffsAndIncrementCount(diffs['Booty Bay'], 'ogre-suit', 250 * factor);
NCM.CheckDiffsAndIncrementCount(diffs['Booty Bay'], 'ogre-suit', 75 * factor);
end
if (NCM.has_session_data and false) then
txt = txt .. "Changes this session:\n";
for k,v in pairs(NCM.play_session) do
txt = txt .. indent .. k .. ": " .. v .. "\n";
end
txt = txt .. "\n";
end
--
-- Ravenholdt
--
local rh = reps[L['Ravenholdt']] or 0;
local rh_remain = 42000 - rh;
if (rh_remain < 1) then
txt = txt .. ColL('Ravenholdt') ..": DONE!\n";
else
txt = txt .. ColL('Ravenholdt') .. "\n";
txt = txt .. indent .. NCM.FormatNumber(rh_remain) .. " rep remaining\n";
-- can we still kill members?
if (rh < 20999) then
local rh_remain_kill = 20999 - rh;
local rh_kills = math.ceil(rh_remain_kill / (5 * factor));
txt = txt .. indent .. "Kills until Revered: " .. rh_kills .. "\n";
if (NCM.GetSessionLength(L['Ravenholdt']) > 0) then
local len = NCM.GetSessionLength(L['Ravenholdt']);
local delta = NCM.GetSessionDelta(L['Ravenholdt']);
delta = math.floor(delta / (5 * factor));
local len_remain = (len / delta) * rh_kills;
local rh_percent = 100 * delta / (delta + rh_kills);
txt = txt .. indent .. indent .. ""..delta.." in "..NCM.FormatTime(len, "0s").." => "
..NCM.FormatTime(len_remain, "0s").." to go\n";
txt = txt .. indent .. indent .. NCM.FormatPercent(rh_percent) .. " complete\n"
end
end
-- junk box turnins
local rh_boxes = math.ceil(rh_remain / (75 * factor)) * 5;
txt = txt .. indent .. "Junk boxes to finish: " .. rh_boxes .. "\n";
end
txt = txt .. "\n";
--
-- Bloodsail Buccaneers
--
-- new default is 35500/36000 hostile, which is 6500 below 0/3000 neutral
local bb = reps[L['Bloodsail Buccaneers']] or -6500;
local bb_remain = 9000 - bb;
if (bb_remain < 1) then
txt = txt .. ColL('Bloodsail Buccaneers') .. ": DONE!\n";
else
txt = txt .. ColL('Bloodsail Buccaneers') .. "\n";
txt = txt .. indent .. NCM.FormatNumber(bb_remain) .. " rep remaining\n";
local bb_bruisers = math.ceil(bb_remain / (25 * factor));
txt = txt .. indent .. ColL('Bruiser') .. " kills to finish: " .. bb_bruisers .. "\n";
if (NCM.GetSessionLength(L['Bloodsail Buccaneers']) > 0) then
local len = NCM.GetSessionLength(L['Bloodsail Buccaneers']);
local delta = NCM.GetSessionDelta(L['Bloodsail Buccaneers']);
delta = math.floor(delta / (25 * factor));
local len_remain = (len / delta) * bb_bruisers;
local bb_percent = 100 * delta / (delta + bb_bruisers);
txt = txt .. indent .. indent .. ""..delta.." in "..NCM.FormatTime(len, "0s").." => "
..NCM.FormatTime(len_remain, "0s").." to go\n";
txt = txt .. indent .. indent .. NCM.FormatPercent(bb_percent) .. " complete\n"
end
end
txt = txt .. "\n";
--
-- Goblin Factions
--
local g1 = reps[L["Booty Bay"]] or 0;
local g2 = reps[L["Everlook"]] or 0;
local g3 = reps[L["Gadgetzan"]] or 0;
local g4 = reps[L["Ratchet"]] or 0;
local g1_remain = 42000 - g1;
local g2_remain = 42000 - g2;
local g3_remain = 42000 - g3;
local g4_remain = 42000 - g4;
local most_remain = 0;
if (g1_remain > most_remain) then most_remain = g1_remain; end
if (g2_remain > most_remain) then most_remain = g2_remain; end
if (g3_remain > most_remain) then most_remain = g3_remain; end
if (g4_remain > most_remain) then most_remain = g4_remain; end
if (most_remain < 1) then
txt = txt .. ColL("Steamwheedle Cartel") .. ": DONE!\n";
else
txt = txt .. ColL("Steamwheedle Cartel") .. "\n";
txt = txt .. indent .. NCM.FormatNumber(most_remain) .. " rep remaining\n";
txt = txt .. indent .. indent .. "(" .. NCM.FormatNumberShort(g1_remain) .. "/" .. NCM.FormatNumberShort(g2_remain) .. "/"
.. NCM.FormatNumberShort(g3_remain) .. "/" .. NCM.FormatNumberShort(g4_remain) .. ")\n";
local g_knot = math.ceil(most_remain / (350 * factor));
local g_ogre = math.ceil(most_remain / (75 * factor));
local g_both = math.ceil(most_remain / (425 * factor));
txt = txt .. indent .. ColL("Free Knot") .. " turnins to finish: " .. g_knot .. "\n";
if (NCM.GetSessionDelta('free-knot') > 0) then
txt = txt .. indent .. indent .. "Done: " .. NCM.GetSessionDelta('free-knot') .. "\n";
end
txt = txt .. indent .. ColL("Ogre Tannin") .. " turnins to finish: " .. g_ogre .. "\n";
if (NCM.GetSessionDelta('ogre-suit') > 0) then
txt = txt .. indent .. indent .. "Done: " .. NCM.GetSessionDelta('ogre-suit') .. "\n";
end
txt = txt .. indent .. "Suit+Key runs to finish: " .. g_both .. "\n";
txt = txt .. indent .. "Time spent in DM: " .. NCM.FormatTime(NCM.GetSimpleCounter('dm-time'), "None") .. "\n";
txt = txt .. indent .. "Knots encountered: " .. NCM.GetSimpleCounter('dm-knots') .. "\n";
end
txt = txt .. "\n";
--
-- Darkmoon Faire
--
local dmf = reps[L["Darkmoon Faire"]] or 0;
local dmf_remain = 42000 - dmf;
if (dmf_remain < 1) then
txt = txt .. ColL("Darkmoon Faire") .. ": DONE!\n";
else
txt = txt .. ColL("Darkmoon Faire") .. "\n";
txt = txt .. indent .. NCM.FormatNumber(dmf_remain) .. " rep remaining\n";
if (dmf < 5000) then
local dmf_quests = math.ceil((5000 - dmf) / (250 * factor));
txt = txt .. indent .. "Quests until maxed: " .. dmf_quests .. "\n";
end
local dmf_minor = math.ceil(dmf_remain / (25 * factor));
local dmf_major = math.ceil(dmf_remain / (350 * factor));
txt = txt .. indent .. "Minor decks to finish: " .. dmf_minor .. "\n";
txt = txt .. indent .. "Major decks to finish: " .. dmf_major .. "\n";
end
txt = txt .. "\n";
--
-- Shen'dralar
--
local sd = reps[L["Shen'dralar"]] or 0;
local sd_remain = 42000 - sd;
if (sd_remain < 1) then
txt = txt .. ColL("Shen'dralar") .. ": DONE!\n";
else
txt = txt .. ColL("Shen'dralar") .. "\n";
txt = txt .. indent .. NCM.FormatNumber(sd_remain) .. " rep remaining\n";
local sd_quests = math.ceil(sd_remain / (500 * factor));
txt = txt .. indent .. "Quest turnins to finish: " .. sd_quests .. "\n";
end
txt = txt .. "\n";
if (false) then
txt = txt .. "\n";
for k, v in pairs(reps) do
txt = txt .. k .. ": " .. v .. "\n";
end
end
if (false) then
txt = txt .. "\n";
txt = txt .. "NCM.farm_session: " .. (NCM.farm_session or "nil") .. "\n";
txt = txt .. "NCM.farm_started: " .. (NCM.farm_started or "nil") .. "\n";
txt = txt .. "NCM.farm_last: " .. (NCM.farm_last or "nil") .. "\n";
txt = txt .. "NCM.farm_delta: " .. (NCM.farm_delta or "nil") .. "\n";
txt = txt .. "\n";
for k, v in pairs(_G.NonComposMentisDB.farms) do
txt = txt .. k .. " = " .. v.delta .. " in " .. v.length .. "\n";
end
end
_G.NCMFrameScrollFrameText:SetText(txt);
end
function NCM.CheckDiffsAndIncrement(diff, name, value)
local lo = math.floor(value);
local hi = math.ceil(value);
if (lo == diff) then
NCM.IncrementSession(name, diff);
end
if (lo ~= hi and hi == diff) then
NCM.IncrementSession(name, diff);
end
end
function NCM.CheckDiffsAndIncrementCount(diff, name, value)
local lo = math.floor(value);
local hi = math.ceil(value);
if (lo == diff) then
NCM.IncrementSession(name, 1);
end
if (lo ~= hi and hi == diff) then
NCM.IncrementSession(name, 1);
end
end
---------------------------------------------------------------------------------------------
--
-- functions for farm session handling
--
function NCM.IncrementSession(name, delta)
-- in a different farm session?
if (NCM.farm_session and not (NCM.farm_session == name)) then
NCM.EndSession();
end
if (NCM.farm_session == name) then
NCM.farm_last = GetTime();
NCM.farm_delta = NCM.farm_delta + delta;
else
NCM.farm_session = name;
NCM.farm_started = GetTime();
NCM.farm_last = NCM.farm_started;
NCM.farm_delta = delta;
end
end
function NCM.GetSessionLength(name)
local x = 0;
if (_G.NonComposMentisDB.farms[name]) then
x = x + _G.NonComposMentisDB.farms[name].length;
end
if (NCM.farm_session == name) then
local t = GetTime() - NCM.farm_started;
if (t < NCM.farm_limit_min) then t = NCM.farm_limit_min; end
x = x + t;
end
return x;
end
function NCM.GetSessionDelta(name)
local x = 0;
if (_G.NonComposMentisDB.farms[name]) then
x = x + _G.NonComposMentisDB.farms[name].delta;
end
if (NCM.farm_session == name) then
x = x + NCM.farm_delta;
end
return x;
end
function NCM.TryEndSession()
-- see if the current session should be ended
-- because too long has passed since the last
-- event.
if (NCM.farm_session) then
local n = GetTime();
if (n - NCM.farm_last > NCM.farm_limit_max) then
NCM.EndSession();
end
end
end
function NCM.EndSession()
if (NCM.farm_session) then
local l = 0;
local d = 0;
if (_G.NonComposMentisDB.farms[NCM.farm_session]) then
l = l + _G.NonComposMentisDB.farms[NCM.farm_session].length;
d = d + _G.NonComposMentisDB.farms[NCM.farm_session].delta;
end
local this_time = NCM.farm_last - NCM.farm_started;
if (this_time < NCM.farm_limit_min) then this_time = NCM.farm_limit_min; end
l = l + this_time;
d = d + NCM.farm_delta;
_G.NonComposMentisDB.farms[NCM.farm_session] = { length = l, delta = d };
end
NCM.farm_session = nil;
NCM.farm_started = nil;
NCM.farm_last = nil;
NCM.farm_delta = nil;
NCM.UpdateFrame();
end
function NCM.GetSimpleCounter(name)
return _G.NonComposMentisDB.farms[name] or 0;
end
function NCM.IncrementSimpleCounter(name, delta)
_G.NonComposMentisDB.farms[name] = _G.NonComposMentisDB.farms[name] or 0;
_G.NonComposMentisDB.farms[name] = _G.NonComposMentisDB.farms[name] + delta;
end
---------------------------------------------------------------------------------------------
function NCM.FormatTime(t, zero)
if (t == 0) then
return zero;
end
local h = math.floor(t / (60 * 60));
t = t - (60 * 60 * h);
local m = math.floor(t / 60);
t = t - (60 * m);
local s = t;
if (h > 0) then
return string.format("%d:%02d:%02d", h, m, s);
end
if (m > 0) then
return string.format("%d:%02d", m, s);
end
return string.format("%d", s).."s";
end
function NCM.Test()
local reps = NCM.GetReps();
print(reps);
for k, v in pairs(reps) do
print(k, v)
end
print "--";
end
function NCM.GetReps()
local factionMap = {};
local factionIndex = 1
repeat
local name, description, standingId, bottomValue, topValue, earnedValue, atWarWith,
canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = GetFactionInfo(factionIndex)
if name == nil then break end
if isHeader == nil then
factionMap[name] = earnedValue;
end
factionIndex = factionIndex + 1
until factionIndex > 200
return factionMap;
end
SLASH_NONCOMPOSMENTIS1 = '/noncomposmentis';
SLASH_NONCOMPOSMENTIS2 = '/ncm';
function SlashCmdList.NONCOMPOSMENTIS(msg, editbox)
if (msg == 'show') then
NCM.Show();
elseif (msg == 'hide') then
NCM.Hide();
elseif (msg == 'toggle') then
NCM.Toggle();
elseif (msg == 'reset') then
NCM.ResetPos();
elseif (msg == 'test') then
NCM.Test();
elseif (msg == 'opts' or msg == 'options') then
NCM.ShowOptions();
else
NCM.Toggle()
print "Non Compos Mentis commands:";
print " /ncm show - Show addon";
print " /ncm hide - Hide addon";
print " /ncm reset - Reset frame position and size";
print " /ncm opts - Show options";
end
end
NCM.Frame = CreateFrame("Frame")
NCM.Frame:Show()
NCM.Frame:SetScript("OnEvent", NCM.OnEvent)
NCM.Frame:SetScript("OnUpdate", NCM.OnUpdate)
NCM.Frame:RegisterEvent("ADDON_LOADED")
NCM.Frame:RegisterEvent("PLAYER_TARGET_CHANGED")
NCM.Frame:RegisterEvent("LOOT_OPENED")
NCM.Frame:RegisterEvent("LOOT_CLOSED")
NCM.Frame:RegisterEvent("PLAYER_LOGOUT")
NCM.Frame:RegisterEvent("PLAYER_ALIVE")
NCM.Frame:RegisterEvent("CHAT_MSG_COMBAT_FACTION_CHANGE")
NCM.Frame:RegisterEvent("ZONE_CHANGED_NEW_AREA")
NCM.OnLoad()