-
Notifications
You must be signed in to change notification settings - Fork 1
/
FlaskFoodCheck.lua
742 lines (629 loc) · 27.4 KB
/
FlaskFoodCheck.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
-------------------------------------------------------------------------------
-- FlaskFoodCheck
-- Checks if all raid members have flask, food and rune buff.
-------------------------------------------------------------------------------
-- Copyright (C) 2018 Elotheon-Arthas-EU
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-------------------------------------------------------------------------------
FlaskFoodCheck = select(2, ...)
local FFC = FlaskFoodCheck
local L = FFC.L
-- we use the name of this spell to get the correct locale of the "Well Fed" buff
local FFC_WELLFED_SPELL_REF = 160726
-- we use the name of this spell to get the correct locale of the "Food" (=eating) buff
local FFC_EATING_SPELL_REF = 433
local FFC_MAX_UNIT_BUFFS = 40
local FFC_FOOD_TABLE = {
-- LEGION
[201223] = 12, -- critical strike
[201330] = 12, -- haste
[201332] = 12, -- mastery
[201334] = 12, -- versatility
[201336] = 12, -- fire volley proc
[225597] = 16, -- critical strike
[225598] = 16, -- haste
[225599] = 16, -- mastery
[225600] = 16, -- versatility
[225601] = 16, -- fire volley proc
[225602] = 19, -- critical strike
[225603] = 19, -- haste
[225604] = 19, -- mastery
[225605] = 19, -- versatility
[225606] = 19, -- fire volley proc
-- BATTLE FOR AZEROTH
[257408] = 53, -- critical strike
[257413] = 53, -- haste
[257418] = 53, -- mastery
[257422] = 53, -- versatility
[257410] = 70, -- critical strike
[257415] = 70, -- haste
[257420] = 70, -- mastery
[257424] = 70, -- versatility
[259448] = 75, -- agility
[259449] = 75, -- intellect
[259452] = 75, -- strength
[259453] = 75, -- 113 stamina
[259454] = 100, -- agility
[259455] = 100, -- intellect
[259456] = 100, -- strength
[259457] = 100, -- 150 stamina
}
local FFC_FLASK_TABLE = {
-- LEGION
[188035] = 59, -- stamina
[188031] = 59, -- intellect
[188033] = 59, -- agility
[188034] = 59, -- strength
[188116] = 59, -- flask from cauldron
-- BATTLE FOR AZEROTH
[251836] = 238, -- agility
[251837] = 238, -- intellect
[251838] = 238, -- 357 stamina
[251839] = 238, -- strength
}
local FFC_RUNE_TABLE = {
-- LEGION
[224001] = 15, -- intellect, agility and strength
-- BATTLE FOR AZEROTH
[270058] = 60, -- intellect, agility and strength
}
local FFC_EATING_TABLE = {
[433] = 1, -- food
[430] = 1, -- drink
[160598] = 1, -- food
[160599] = 1, -- drink
[170906] = 1, -- food & drink
[192002] = 1, -- food & drink
[225743] = 1, -- food & drink
[251232] = 1, -- food & drink
[272819] = 1, -- food & drink
}
-------------------------------------------------------------------------------
-- Addon Functionality
-------------------------------------------------------------------------------
function FFC:OnInitialize()
local defaults = {
debug = false,
muted = false,
playerLevelMin = 100,
foodStatsMin = 100,
flaskStatsMin = 250,
runeStatsMin = 50,
expiresWarnSec = 480,
requireRightsForAutoRun = 1,
checkFood = true,
checkFlask = true,
checkRune = false,
}
FlaskFoodCheckDB = FlaskFoodCheckDB or {}
for key, value in pairs(defaults) do
if( FlaskFoodCheckDB[key] == nil ) then
FlaskFoodCheckDB[key] = value
end
end
self.db = FlaskFoodCheckDB
end
function FFC:debug(msg)
if self.db.debug then
print(string.format("|cffff0088[FFC][%s.%3d]|r %s",
date("%H:%M:%S"), (GetTime() % 1) * 1000, msg))
end
end
function FFC:PlayerName(name)
if string.find(name, "-") then
return name, GetRealmName()
else
local _, _, fname, frealm = string.find(name, "([^-]+)-([^-]+)")
return fname, frealm
end
end
function FFC:UnitBuffBySpellId(player, spellId)
for i = 1, FFC_MAX_UNIT_BUFFS do
local name, _, _, _, _, expires, _, _, _, id, _, _, _, _, value1, value2, value3 = UnitBuff(player, i, nil)
if id == spellId then
return name, expires, value1, value2, value3
end
end
return nil
end
function FFC:UnitBuffBySpellName(player, spellName)
for i = 1, FFC_MAX_UNIT_BUFFS do
local name, _, _, _, _, expires, _, _, _, id, _, _, _, _, value1, value2, value3 = UnitBuff(player, i, nil)
if name == spellName then
return name, expires, value1, value2, value3
end
end
return nil
end
function FFC:GetPlayerBuffValueAndRemaining(player, spellTable, fallbackSpellId)
for spellId, amount in pairs(spellTable) do
local name, expires, value1, value2, value3 = FFC:UnitBuffBySpellId(player, spellId)
if name then
if value2 and value2 > 0 then amount = value2 end
local remaining = 0
if expires > 0 then remaining = math.ceil(expires - GetTime()) end
return amount, remaining
end
end
if fallbackSpellId then
-- fallback: try to find a buff called "Well Fed"/"Food"/etc in the
-- current locale and read its special value2
local fallbackSpellName = GetSpellInfo(fallbackSpellId)
local name, expires, value1, value2, value3 = FFC:UnitBuffBySpellName(player, fallbackSpellName)
if name then
local remaining = 0
if expires > 0 then remaining = math.ceil(expires - GetTime()) end
if value2 and value2 > 0 then
return value2, remaining
else
-- return 1 if we found such a buff but cannot read its value2
return 1, remaining
end
end
end
return 0, 0
end
function FFC:GetPlayerFood(player)
return self:GetPlayerBuffValueAndRemaining(player, FFC_FOOD_TABLE, FFC_WELLFED_SPELL_REF)
end
function FFC:GetPlayerFlask(player)
return self:GetPlayerBuffValueAndRemaining(player, FFC_FLASK_TABLE)
end
function FFC:GetPlayerRune(player)
return self:GetPlayerBuffValueAndRemaining(player, FFC_RUNE_TABLE)
end
function FFC:GetPlayerEating(player)
local amount, remaining = self:GetPlayerBuffValueAndRemaining(player, FFC_EATING_TABLE, FFC_EATING_SPELL_REF)
return (amount > 0)
end
function FFC:IsInSameZone(zone)
local zonereal = GetRealZoneText()
local zonetext = GetZoneText()
local zoneinst = GetInstanceInfo()
if zone and ((zonereal and zonereal == zone) or
(zonetext and zonetext == zone) or
(zoneinst and zoneinst == zone)) then
return true
end
return false
end
function FFC:AggregateSelfInfo()
local raid = {}
if UnitLevel("player") >= self.db.playerLevelMin and not UnitIsDeadOrGhost("player") then
local name = UnitName("player");
raid[name] = {}
raid[name]["food"] = { self:GetPlayerFood(name) }
raid[name]["flask"] = { self:GetPlayerFlask(name) }
raid[name]["rune"] = { self:GetPlayerRune(name) }
raid[name]["eating"] = self:GetPlayerEating(name)
end
return raid
end
function FFC:AggregatePartyInfo()
local raid = {}
for i = 1, GetNumGroupMembers() do
local unit = ""
if i == GetNumGroupMembers() then unit = "player" else unit = "party"..i end
if UnitLevel(unit) >= self.db.playerLevelMin and not UnitIsDeadOrGhost(unit) then
local name = UnitName(unit);
if name then
-- local simplename = self:PlayerName(name)
raid[name] = {}
raid[name]["food"] = { self:GetPlayerFood(name) }
raid[name]["flask"] = { self:GetPlayerFlask(name) }
raid[name]["rune"] = { self:GetPlayerRune(name) }
raid[name]["eating"] = self:GetPlayerEating(name)
end
end
end
return raid
end
function FFC:AggregateRaidInfo()
local raid = {}
-- loop through raid members and aggregate information
for i = 1, GetNumGroupMembers() do
local name, rank, subgroup, level, class, _, zone,
online, isdead, role, isml = GetRaidRosterInfo(i)
if name and level and level >= self.db.playerLevelMin and online and not isdead then
-- and self:IsInSameZone(zone)
-- local simplename = self:PlayerName(name)
raid[name] = {}
raid[name]["food"] = { self:GetPlayerFood(name) }
raid[name]["flask"] = { self:GetPlayerFlask(name) }
raid[name]["rune"] = { self:GetPlayerRune(name) }
raid[name]["eating"] = self:GetPlayerEating(name)
end
end
return raid
end
function FFC:AnalyseInformation(infoTable, outputChannel)
local foodMissingCount = 0
local foodLowStatCount = 0
local foodExpiresCount = 0
local flaskMissingCount = 0
local flaskLowStatCount = 0
local flaskExpiresCount = 0
local runeMissingCount = 0
local runeLowStatCount = 0
local runeExpiresCount = 0
local foodMissing = {}
local foodLowStat = {}
local foodExpires = {}
local flaskMissing = {}
local flaskLowStat = {}
local flaskExpires = {}
local runeMissing = {}
local runeLowStat = {}
local runeExpires = {}
for name, info in pairs(infoTable) do
if info["food"][1] == 0 then
foodMissingCount = foodMissingCount + 1
if info["eating"] then
table.insert(foodMissing, name..L[" (eating)"])
else
table.insert(foodMissing, name)
end
else
if info["food"][1] < self.db.foodStatsMin then
foodLowStatCount = foodLowStatCount + 1
if info["eating"] then
table.insert(foodLowStat, name..L[" (eating)"])
else
table.insert(foodLowStat, name .. " (" .. info["food"][1] .. ")")
end
else
if info["food"][2] > 0 and info["food"][2] < self.db.expiresWarnSec then
foodExpiresCount = foodExpiresCount + 1
if info["eating"] then
table.insert(foodExpires, name..L[" (eating)"])
else
table.insert(foodExpires, name .. " (" ..
string.format(L["%d min"], info["food"][2] / 60) .. ")")
end
end
end
end
if info["flask"][1] == 0 then
flaskMissingCount = flaskMissingCount + 1
table.insert(flaskMissing, name)
else
if info["flask"][1] < self.db.flaskStatsMin then
flaskLowStatCount = flaskLowStatCount + 1
table.insert(flaskLowStat, name .. " (" .. info["flask"][1] .. ")")
else
if info["flask"][2] > 0 and info["flask"][2] < self.db.expiresWarnSec then
flaskExpiresCount = flaskExpiresCount + 1
table.insert(flaskExpires, name .. " (" ..
string.format(L["%d min"], math.ceil(info["flask"][2] / 60)) .. ")")
end
end
end
if info["rune"][1] == 0 then
runeMissingCount = runeMissingCount + 1
table.insert(runeMissing, name)
else
if info["rune"][1] < self.db.runeStatsMin then
runeLowStatCount = runeLowStatCount + 1
table.insert(runeLowStat, name .. " (" .. info["rune"][1] .. ")")
else
if info["rune"][2] > 0 and info["rune"][2] < self.db.expiresWarnSec then
runeExpiresCount = runeExpiresCount + 1
table.insert(runeExpires, name .. " (" ..
string.format(L["%d min"], math.ceil(info["rune"][2] / 60)) .. ")")
end
end
end
end
if self.db.checkFood then
if flaskMissingCount > 0 then self:PrintToChannel(L["Flask missing: "] ..
table.concat(flaskMissing, ", "), outputChannel) end
if flaskLowStatCount > 0 then self:PrintToChannel(L["Flask with low stats: "] ..
table.concat(flaskLowStat, ", "), outputChannel) end
if flaskExpiresCount > 0 then self:PrintToChannel(L["Flask expires: "] ..
table.concat(flaskExpires, ", "), outputChannel) end
end
if self.db.checkFlask then
if foodMissingCount > 0 then self:PrintToChannel(L["Food missing: "] ..
table.concat(foodMissing, ", "), outputChannel) end
if foodLowStatCount > 0 then self:PrintToChannel(L["Food with low stats: "] ..
table.concat(foodLowStat, ", "), outputChannel) end
if foodExpiresCount > 0 then self:PrintToChannel(L["Food expires: "] ..
table.concat(foodExpires, ", "), outputChannel) end
end
if self.db.checkRune then
if runeMissingCount > 0 then self:PrintToChannel(L["Rune missing: "] ..
table.concat(runeMissing, ", "), outputChannel) end
if runeLowStatCount > 0 then self:PrintToChannel(L["Rune with low stats: "] ..
table.concat(runeLowStat, ", "), outputChannel) end
if runeExpiresCount > 0 then self:PrintToChannel(L["Rune expires: "] ..
table.concat(runeExpires, ", "), outputChannel) end
end
if self.db.checkFood and self.db.checkFlask and self.db.checkRune and
foodMissingCount == 0 and foodLowStatCount == 0 and foodExpiresCount == 0 and
flaskMissingCount == 0 and flaskLowStatCount == 0 and flaskExpiresCount == 0 and
runeMissingCount == 0 and runeLowStatCount == 0 and runeExpiresCount == 0 then
-- wow, everyone got everything
self:PrintToChannel(L["Hooray, everyone has food, flask and rune buff! #incredibleraid"], outputChannel)
elseif self.db.checkFood and self.db.checkFlask and not self.db.checkRune and
foodMissingCount == 0 and foodLowStatCount == 0 and foodExpiresCount == 0 and
flaskMissingCount == 0 and flaskLowStatCount == 0 and flaskExpiresCount == 0 then
-- yay, everyone got flask and food
self:PrintToChannel(L["Everyone has flask and food buff! #bestraid"], outputChannel)
else
-- something somewhere missing
if self.db.checkFood and foodMissingCount == 0 and foodLowStatCount == 0 and foodExpiresCount == 0 then
self:PrintToChannel(L["Everyone has food buff."], outputChannel)
end
if self.db.checkFlask and flaskMissingCount == 0 and flaskLowStatCount == 0 and flaskExpiresCount == 0 then
self:PrintToChannel(L["Everyone has flask buff."], outputChannel)
end
if self.db.checkRune and runeMissingCount == 0 and runeLowStatCount == 0 and runeExpiresCount == 0 then
self:PrintToChannel(L["Everyone has rune buff."], outputChannel)
end
end
end
function FFC:RunCheck(isReadyCheck)
if isReadyCheck then
-- called because of a ready check
if IsInRaid() and self:IsRealRaid() then
-- always display information in a raid, but only to raid channel if sufficient rights
if self:HasRaidRights() then
self:AnalyseInformation(self:AggregateRaidInfo(), "raid")
else
self:AnalyseInformation(self:AggregateRaidInfo(), "self")
end
elseif IsInInstance() and self:IsRealChallengeMode() then
-- always display information in a challenge mode
self:AnalyseInformation(self:AggregatePartyInfo(), "instance")
end
else
-- called manually, always print
if IsInRaid() then
self:debug("raid analysis")
self:AnalyseInformation(self:AggregateRaidInfo(), "raid")
elseif IsInInstance() then
self:debug("party analysis")
self:AnalyseInformation(self:AggregatePartyInfo(), "instance")
elseif IsInGroup() then
self:debug("party analysis")
self:AnalyseInformation(self:AggregatePartyInfo(), "group")
else
self:debug("self analysis")
self:AnalyseInformation(self:AggregateSelfInfo(), "self")
end
end
end
function FFC:HasRaidRights()
if (self.db.requireRightsForAutoRun == 2 and UnitIsGroupLeader("player")) or
(self.db.requireRightsForAutoRun == 1 and (UnitIsGroupLeader("player") or UnitIsRaidOfficer("player"))) or
(self.db.requireRightsForAutoRun == 0) then
return true
end
return false
end
function FFC:IsRealRaid()
-- see http://wow.gamepedia.com/API_GetDifficultyInfo
local difficulty = GetRaidDifficultyID()
if difficulty == 14 or difficulty == 15 or difficulty == 16 then
return true
end
return false
end
function FFC:IsRealChallengeMode()
return (GetRaidDifficultyID() == 8)
end
function FFC:PrintToChannel(msg, channel)
-- never print anything to a channel when muted
if self.db.muted then
channel = "self"
end
-- if channel not specified, find the right channel
if not channel then
if IsInRaid() then
channel = "raid"
elseif IsInInstance() then
channel = "instance"
elseif IsInGroup() then
channel = "party"
else
channel = "self"
end
end
-- print to correct channel
if channel == "self" then
DEFAULT_CHAT_FRAME:AddMessage(msg)
elseif channel == "raid" then
SendChatMessage(msg, "RAID")
elseif channel == "instance" then
SendChatMessage(msg, "INSTANCE_CHAT")
elseif channel == "group" then
SendChatMessage(msg, "PARTY")
else
DEFAULT_CHAT_FRAME:AddMessage(msg)
end
end
function FFC:PrintCurrentRequirements()
if self.db.requireRightsForAutoRun == 0 then
self:Print(L["No special raid rights are now required for printing to raid channel."])
elseif self.db.requireRightsForAutoRun == 1 then
self:Print(L["Currently being assistant is required for printing to raid channel."])
elseif self.db.requireRightsForAutoRun == 2 then
self:Print(L["Currently being raidlead is required for printing to raid channel."])
else
self:Print(L["Unknown value."])
end
end
function FFC:PrintCurrentRequirementsShort()
if self.db.requireRightsForAutoRun == 0 then
self:Print("require any")
elseif self.db.requireRightsForAutoRun == 1 then
self:Print("require assist")
elseif self.db.requireRightsForAutoRun == 2 then
self:Print("require raidlead")
end
end
function FFC:PrintCurrentToggles()
local msg = L["Currently checking for:"]
if self.db.checkFood then msg = msg .. " " .. L["food"] end
if self.db.checkFlask then msg = msg .. " " .. L["flask"] end
if self.db.checkRune then msg = msg .. " " .. L["rune"] end
self:Print(msg)
end
function FFC:PrintCurrentTogglesShort()
local msg = "check"
if self.db.checkFood then msg = msg .. " food" end
if self.db.checkFlask then msg = msg .. " flask" end
if self.db.checkRune then msg = msg .. " rune" end
self:Print(msg)
end
function FFC:Print(msg)
DEFAULT_CHAT_FRAME:AddMessage("|cff006ee8FlaskFoodCheck:|r " .. msg)
end
-------------------------------------------------------------------------------
-- Slash Command Handling
-------------------------------------------------------------------------------
SLASH_FFC1 = "/ffc"
SLASH_FFC2 = "/flaskfoodcheck"
SlashCmdList["FFC"] = function(msg)
msg = msg or ""
local cmd, arg = string.split(" ", msg, 2)
cmd = string.lower(cmd or "")
arg = string.lower(arg or "")
local self = FFC
self:debug("cmd is '"..cmd.."'")
self:debug("arg is '"..arg.."'")
if cmd == "run" then
self:RunCheck(false)
elseif cmd == "mute" then
self.db.muted = true
self:Print(L["Muted."])
elseif cmd == "unmute" then
self.db.muted = false
self:Print(L["Unmuted."])
elseif cmd == "minlevel" and arg == "" then
self:Print(string.format(L["Minimum player level is currently set to %d."], self.db.playerLevelMin))
elseif cmd == "minlevel" and arg ~= "" then
self.db.playerLevelMin = tonumber(string.match(arg, "%d+"))
self:Print(string.format(L["Minimum player level set to %d."], self.db.playerLevelMin))
elseif cmd == "minfood" and arg == "" then
self:Print(string.format(L["Minimum stats on food is currently set to %d."], self.db.foodStatsMin))
elseif cmd == "minfood" and arg ~= "" then
self.db.foodStatsMin = tonumber(string.match(arg, "%d+"))
self:Print(string.format(L["Minimum stats on food set to %d."], self.db.foodStatsMin))
elseif cmd == "minflask" and arg == "" then
self:Print(string.format(L["Minimum stats on flask is currently set to %d."], self.db.flaskStatsMin))
elseif cmd == "minflask" and arg ~= "" then
self.db.flaskStatsMin = tonumber(string.match(arg, "%d+"))
self:Print(string.format(L["Minimum stats on flask set to %d."], self.db.flaskStatsMin))
elseif cmd == "minrune" and arg == "" then
self:Print(string.format(L["Minimum stats on rune is currently set to %d."], self.db.runeStatsMin))
elseif cmd == "minrune" and arg ~= "" then
self.db.runeStatsMin = tonumber(string.match(arg, "%d+"))
self:Print(string.format(L["Minimum stats on rune set to %d."], self.db.runeStatsMin))
elseif cmd == "expire" and arg == "" then
self:Print(string.format(L["Expiration warning is currently set to %d seconds (approx. %d min)."], self.db.expiresWarnSec, math.ceil(self.db.expiresWarnSec / 60)))
elseif cmd == "expire" and arg ~= "" then
self.db.expiresWarnSec = tonumber(string.match(arg, "%d+"))
self:Print(string.format(L["Expiration warning set to %d seconds (approx. %d min)."], self.db.expiresWarnSec, math.ceil(self.db.expiresWarnSec / 60)))
elseif cmd == "require" and arg == "" then
self:PrintCurrentRequirements()
elseif cmd == "require" and arg ~= "" then
if arg == "any" then
self.db.requireRightsForAutoRun = 0
self:Print(L["No special raid rights are now required for printing to raid channel."])
elseif arg == "assist" then
self.db.requireRightsForAutoRun = 1
self:Print(L["Being assistant is now required for printing to raid channel."])
elseif arg == "raidlead" then
self.db.requireRightsForAutoRun = 2
self:Print(L["Being raidlead is now required for printing to raid channel."])
else
self:Print(L["Unknown command."])
end
elseif cmd == "check" and arg == "" then
self:PrintCurrentToggles()
elseif cmd == "check" and arg ~= "" then
if arg == "food" then
self.db.checkFood = not self.db.checkFood
elseif arg == "flask" then
self.db.checkFlask = not self.db.checkFlask
elseif arg == "rune" then
self.db.checkRune = not self.db.checkRune
else
self:Print(L["Unknown command."])
end
self:PrintCurrentToggles()
elseif cmd == "values" then
if self.db.muted then self:Print(L["Muted."]) end
self:Print(string.format(L["Minimum player level is currently set to %d."], self.db.playerLevelMin))
self:Print(string.format(L["Minimum stats on food is currently set to %d."], self.db.foodStatsMin))
self:Print(string.format(L["Minimum stats on flask is currently set to %d."], self.db.flaskStatsMin))
self:Print(string.format(L["Minimum stats on rune is currently set to %d."], self.db.runeStatsMin))
self:Print(string.format(L["Expiration warning is currently set to %d seconds (approx. %d min)."], self.db.expiresWarnSec, math.ceil(self.db.expiresWarnSec / 60)))
self:PrintCurrentRequirements()
self:PrintCurrentToggles()
elseif cmd == "val" then
if self.db.muted then self:Print("muted") end
self:Print(string.format("minplayer %d", self.db.playerLevelMin))
self:Print(string.format("minfood %d", self.db.foodStatsMin))
self:Print(string.format("minflask %d", self.db.flaskStatsMin))
self:Print(string.format("minrune %d", self.db.runeStatsMin))
self:Print(string.format("expire %d sec (~%d min)", self.db.expiresWarnSec, math.ceil(self.db.expiresWarnSec / 60)))
self:PrintCurrentRequirementsShort()
self:PrintCurrentTogglesShort()
elseif cmd == "debug" then
self.db.debug = not self.db.debug
if self.db.debug then
self:Print("Debugging enabled.")
else
self:Print("Debugging disabled.")
end
else
self:Print(L["Slash commands"])
DEFAULT_CHAT_FRAME:AddMessage(L["/ffc run - Manually trigger a flask and food buff check."])
DEFAULT_CHAT_FRAME:AddMessage(L["/ffc mute - Mute the addon (do not write to raid channel, but display locally)."])
DEFAULT_CHAT_FRAME:AddMessage(L["/ffc unmute - Unmute if previously muted."])
DEFAULT_CHAT_FRAME:AddMessage(L["/ffc require any - Print messages on every ready check in a raid, regardless of rights."])
DEFAULT_CHAT_FRAME:AddMessage(L["/ffc require assist - Print messages on every read check in a raid if you have at least assistant rights (default)."])
DEFAULT_CHAT_FRAME:AddMessage(L["/ffc require raidlead - Print messages on every read check in a raid if you are the raid leader."])
DEFAULT_CHAT_FRAME:AddMessage(L["/ffc check food - Enable or disable food check (default on)."])
DEFAULT_CHAT_FRAME:AddMessage(L["/ffc check flask - Enable or disable flask check (default on)."])
DEFAULT_CHAT_FRAME:AddMessage(L["/ffc check rune - Enable or disable rune check (default off)."])
DEFAULT_CHAT_FRAME:AddMessage(L["/ffc minlevel <level> - Minimum player level in order to appear in the output (default 100)."])
DEFAULT_CHAT_FRAME:AddMessage(L["/ffc minfood <amount> - Mininum stats required on food buff (default 100)."])
DEFAULT_CHAT_FRAME:AddMessage(L["/ffc minflask <amount> - Mininum stats required on flask buff (default 250)."])
DEFAULT_CHAT_FRAME:AddMessage(L["/ffc minrune <amount> - Mininum stats required on rune buff (default 50)."])
DEFAULT_CHAT_FRAME:AddMessage(L["/ffc expire <seconds> - Seconds before a buff is marked as expiring (default 480 = 8 min)."])
DEFAULT_CHAT_FRAME:AddMessage(L["/ffc values - List all values currently set (minfood, minflask, etc.)."])
DEFAULT_CHAT_FRAME:AddMessage(L["/ffc val - Same as above, but shorter."])
end
end
-------------------------------------------------------------------------------
-- Event Handling
-------------------------------------------------------------------------------
local frame = CreateFrame("Frame")
frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("READY_CHECK")
frame:SetScript("OnEvent",
function(self, event, ...)
if event == "ADDON_LOADED" then
FFC:OnInitialize()
self:UnregisterEvent("ADDON_LOADED")
elseif event == "READY_CHECK" then
FFC:RunCheck(true)
end
end
)