Repository navigation
Expand file tree
/
Copy pathCore.lua
More file actions
6880 lines (6507 loc) · 307 KB
/
Copy pathCore.lua
File metadata and controls
6880 lines (6507 loc) · 307 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
-- Manners -- core: the addon object, secret-safe access, failure handling,
-- defaults and their repair, the capability probe, which buff for which
-- person, unit inspection, names, and the lifecycle with its events.
--
-- Blizzard will not let an addon cast a spell on its own: CastSpellByName and
-- friends are protected and only run from a hardware event. So this addon does
-- every part of the job except the keypress -- it decides who deserves a buff
-- and parks that decision on a secure button. Prompt/ owns that button; this
-- file and the eight after it in Manners.toc work out what goes on it:
--
-- Range.lua how near a passer-by has to be
-- Speech.lua the phrase sets and the line said with a click
-- Queue.lua debts, refusals, the never-offer list, friends, BuildQueue
-- GroupBuffs.lua one cast for a whole party in place of single casts
-- Requests.lua people who ask for a buff in chat
-- Favours.lua noticing that somebody buffed you
-- Clicks.lua what became of a press, the global cooldown, the macro
-- Commands.lua first run, test console, snooze, sharing, slash commands
--
-- A local one of them needs from another goes on ns where it is defined: a
-- later file copies it into a local at load, an earlier one (this, for the
-- lifecycle) reads it off ns at call time. "Core" in another file means this
-- file and those eight.
local ns = select(2, ...)
local L = ns.L
local addon = LibStub("AceAddon-3.0"):NewAddon((...), "AceEvent-3.0", "AceConsole-3.0", "AceTimer-3.0")
ns.addon = addon
-- Every line Manners prints to your chat frame goes through addon:Print. With
-- "Say nothing at all in chat" on (silentChat) none does -- not the few lines
-- the chat switch above it leaves, about a title earned, the game refusing a
-- person or a skip in a fight -- except the answer to a command you typed
-- (ns.answering, Commands.lua) and what addon:Reply says: the result of
-- pasting settings, the lines of a set you loaded or tried.
do
local acePrint = addon.Print
function addon:Print(...)
local db = self.db and self.db.profile
if db and db.silentChat == true and not ns.answering then return end
return acePrint(self, ...)
end
function addon:Reply(...) return acePrint(self, ...) end
end
local MANA = (Enum and Enum.PowerType and Enum.PowerType.Mana) or 0
ns.MANA = MANA
-- The label for Bindings.xml's entry under Options > Keybindings (this client's
-- game menu has no Key Bindings entry). A CLICK binding's name is not a Lua
-- identifier, so the label is set through _G.
_G["BINDING_NAME_CLICK MannersPrompt:LeftButton"] = L["Buff the prompted player"]
_G["BINDING_NAME_CLICK MannersSupplies:LeftButton"] = L["Use the item on the consumables button"]
-- The break-free button (Prompt/BreakFree.lua), for a Forsaken.
_G["BINDING_NAME_CLICK MannersBreakFree:LeftButton"] = L["Break free: Will of the Forsaken"]
---------------------------------------------------------------------------
-- secret-safe access
--
-- The protection policy. On Forever and retail most API calls hand back a
-- secret rather than throw, so a result is made safe with plain(), which
-- turns a secret into nil ("cannot tell"), and the call itself is not
-- wrapped. A function that may be missing gets a type() check on the global,
-- read at call time.
--
-- pcall is only for calls that can throw:
-- - the aura reads the client restricts per spell. These keep a bare inline
-- pcall per read, never safecall, behind the aura cache;
-- - third-party library code (LibRangeCheck);
-- - calls handed a value that may be secret, such as a GUID;
-- - APIs whose signature differs between client generations;
-- - macro and settings setup.
--
-- Everything else on a busy path (per unit, per event, per repaint) calls the
-- client directly: type check, call, then plain() on each return it uses.
-- safecall costs about 310 ns a call against about 45 ns for the direct form,
-- so it is for once-per-scan and UI-rate calls, where it costs nothing
-- measurable.
--
-- ns.Guard stays at event, timer and module boundaries: one pcall per event,
-- about 80 ns. One fault is then named in /manners errors and never stops the
-- scanner. A throw inside the scan is caught there, not read as "cannot tell".
--
-- tests/scenarios/perf-budget.lua holds the scan to this on every client: a
-- budget of pcalls, calls to the client and memory per scan for each place
-- (a city is about 10 pcalls, a raid 14).
---------------------------------------------------------------------------
local issecretvalue = _G.issecretvalue
local InCombatLockdown = _G.InCombatLockdown
local GetTime = _G.GetTime
-- Secrets throw on comparison and arithmetic, so anything branched on comes
-- through here: nil when we may not look.
local function plain(v)
if issecretvalue and issecretvalue(v) then return nil end
return v
end
ns.plain = plain
-- For the once-per-scan and UI-rate places the policy above allows: nil when
-- the call is missing or throws, else its first three returns made plain.
local function safecall(fn, ...)
if type(fn) ~= "function" then return nil end
local ok, a, b, c = pcall(fn, ...)
if not ok then return nil end
if issecretvalue then
if issecretvalue(a) then a = nil end
if issecretvalue(b) then b = nil end
if issecretvalue(c) then c = nil end
end
return a, b, c
end
ns.safecall = safecall
-- One token swapped for one piece of text, never read as a pattern: in a gsub
-- template "%" is an escape, and players type the reason lines and phrases
-- ("10% left"); a function replacement is returned verbatim.
--
-- A repaint asks this about seventeen times, mostly for a token its line does
-- not hold, so a plain find answers that first; every token is a literal
-- "{word}", which a plain find and gsub read alike. One file-level function
-- hands back the value, not a closure per call.
do
local swapValue
local function SwapValue() return swapValue end
function ns.Swap(text, token, value)
text = text or ""
if not text:find(token, 1, true) then return text end
swapValue = value or ""
return (text:gsub(token, SwapValue))
end
end
---------------------------------------------------------------------------
-- failure handling
--
-- Script errors are invisible unless the player turned them on, and a repeating
-- timer whose function throws simply stops. Anything that can fail goes through
-- here so the failure is named instead.
---------------------------------------------------------------------------
-- The trail: the last TRAIL_MAX things Manners saw or did -- a favour noticed,
-- somebody new on the prompt, a press, what became of it, a refusal, a fight
-- starting and ending, the bar macro written, an error -- for the full check-up
-- (Options/Diagnostics.lua, ns.FullReport), so a report shows what led up to a
-- bug and not only how things stand. Kept in the character's saved variables,
-- so it survives the /reload a player makes before reporting. One short line per
-- event, never per scan; `who` is the person's name, which the report replaces
-- with an alias.
do
local TRAIL_MAX = 200
function ns.Trail(kind, text, who)
local db = ns.addon and ns.addon.db
local char = db and db.char
if type(char) ~= "table" then return end
local trail = char.trail
if type(trail) ~= "table" then
trail = {}
char.trail = trail
end
trail[#trail + 1] = { at = time(), kind = tostring(kind), text = tostring(text or ""),
who = type(who) == "string" and who or nil }
while #trail > TRAIL_MAX do table.remove(trail, 1) end
end
end
-- The last thirty failures (Guard wraps the tick, so one can repeat 2.5 times a
-- second), the count of all of them ever, and which labels have been announced.
ns.errors = {}
ns.errorCount = 0
ns.shouted = {}
-- A fault that repeats: the same label failing BROKEN_AFTER times with no gap
-- of BROKEN_SECONDS between them (the scan, failing 2.5 times a second, gets
-- there in about a second; a rare fault never does). Per label, the run's
-- count and the time of its last failure. While one lasts, ns.Broken() names
-- it, and the launcher's state says so in red ahead of everything but "off"
-- (Options/Launcher.lua, kind "broken"): its tooltip, its broker text and the
-- options window's strip, all places a player who chose "Say nothing at all
-- in chat" still looks. For that player, whose chat line silentChat swallows,
-- one line goes on screen as well (UIErrorsFrame, not chat), once a session.
local BROKEN_AFTER, BROKEN_SECONDS = 3, 10
local failing = {}
local broken = { shown = false, told = false }
function ns.Broken()
local now, worst = GetTime(), nil
for label, run in pairs(failing) do
if run.n >= BROKEN_AFTER and now - run.last <= BROKEN_SECONDS
and (not worst or run.n > failing[worst].n) then
worst = label
end
end
return worst
end
-- Noted from Guard on every failure; never throws (Guard's own rule).
local function NoteFailing(label)
local now = GetTime()
local run = failing[label]
if not run or now - run.last > BROKEN_SECONDS then
run = { n = 0 }
failing[label] = run
end
run.n, run.last = run.n + 1, now
if run.n ~= BROKEN_AFTER then return end
broken.shown = true
local db = ns.addon and ns.addon.db and ns.addon.db.profile
if not broken.told and db and db.silentChat == true then
broken.told = true
local screen = _G.UIErrorsFrame
if type(screen) == "table" and type(screen.AddMessage) == "function" then
-- The tab and the button by their own keys, so a translation names
-- what the window shows; the command as it is typed.
pcall(screen.AddMessage, screen, L["Manners keeps failing in %s, so the prompt may stop changing. %s on the %s tab (%s) says what."]
:format(label, L["Run a full check-up"], L["Diagnostics"], "/manners"), 1, 0.25, 0.25)
end
end
if ns.RepaintOptions and label ~= "options repaint" and label ~= "broker text" then ns.RepaintOptions() end
end
-- From the scan, after a good one: once the run has lapsed, the mark comes
-- down where it was shown. Costs one test of a flag while nothing is broken.
local function MendedScan()
if broken.shown and not ns.Broken() then
broken.shown = false
if ns.RepaintOptions then ns.RepaintOptions() end
end
end
function ns.Guard(label, fn, ...)
local ok, err = pcall(fn, ...)
if ok then return true end
-- On the trail too, once a label: one that repeats each tick says so once.
if not ns.shouted[label] then pcall(ns.Trail, "error", tostring(label) .. ": " .. tostring(err)) end
-- This function is the thing that stops a failure being silent, so it must
-- never be the thing that throws.
label = tostring(label)
err = tostring(err)
ns.errorCount = (ns.errorCount or 0) + 1
ns.errors[#ns.errors + 1] = { at = date("%H:%M:%S"), where = label, err = err }
while #ns.errors > 30 do table.remove(ns.errors, 1) end
pcall(NoteFailing, label)
if not ns.shouted[label] then
ns.shouted[label] = true
-- Handed on to the game's error handler as well, once per label, so an
-- error addon (or the game's own Lua error window, if the player turned
-- it on) sees what broke as it sees any addon's failure. Protected: the
-- handler is somebody else's code.
local getHandler = _G.geterrorhandler
local handler = type(getHandler) == "function" and getHandler()
if type(handler) == "function" then pcall(handler, "Manners: " .. label .. ": " .. err) end
if ns.addon and ns.addon.Print then
-- The label is the code's own name for the handler and the command
-- is typed as it stands, so neither is the translator's to change.
ns.addon:Print(L["|cffff4040something broke in %s|r -- %s |cff808080(%s for the rest)|r"]
:format(label, err, "/manners errors"))
end
-- Repaint Diagnostics once per new failure, but not for a failure of
-- the repaint itself, which would only fail again.
if ns.RepaintOptions and label ~= "options repaint" and label ~= "broker text" then
ns.RepaintOptions()
end
end
return false
end
---------------------------------------------------------------------------
-- telling the settings UI that something changed under it
--
-- AceConfig reads a control's value, name and `hidden` only while drawing, and
-- the broker text is assigned once, so anything that changes a setting outside
-- its own control (slash commands, the minimap right-click, a fight starting
-- or ending) calls this. Both halves are optional and guarded: Options/ may
-- not have loaded, and a failed repaint must not take down the caller.
---------------------------------------------------------------------------
function ns.RepaintOptions()
if ns.RefreshOptionsDisplay then
ns.Guard("options repaint", ns.RefreshOptionsDisplay)
end
if ns.RefreshBrokerText then
ns.Guard("broker text", ns.RefreshBrokerText)
end
end
---------------------------------------------------------------------------
-- defaults
---------------------------------------------------------------------------
-- LibSharedMedia ships only "None", so Prompt/Prompt.lua registers our own.
-- A file id rather than a path, because Register rejects paths under Sound\.
ns.SOUND_KEY = "Manners alert"
ns.SOUND_FILE = 567458
local defaults = {
profile = {
enabled = true,
verbose = true, -- "X buffed you", and why a cast failed
-- Stronger than verbose: not one line of its own in chat (addon:Print).
silentChat = false,
-- One line in chat a while after login while Manners has no key
-- (Options/Start.lua, ns.KeyNudge): three logins at most.
keyReminder = true,
debugClicks = false, -- raw attribute dump on every click; on via /manners clicks
-- Milestones (Milestones.lua): the whole of it, its toast, the toast's sound.
milestones = { enabled = true, toast = true, sound = true },
buff = {
choice = "auto",
-- The class's spells switched off, as a sparse set (absent = on).
-- Keys are class-unique, so a shared profile cannot cross classes.
skip = {},
-- The buffs held to the tanks of your group (Buffs.lua, tankChoice), a
-- sparse set like skip: absent is everybody.
tanksOnly = {},
-- Of those, the ones still offered to everybody outside your group
-- (Offer to: Tanks, and anyone outside my group; what Tanks only did
-- until it was made to mean it): the same sparse set. Absent, Tanks
-- only holds a buff from everybody outside the group too.
tanksOutside = {},
-- Of the buffs held to tanks, the ones still reminded of on you
-- whatever your role (Offer to: Tanks and me; asked for on
-- CurseForge): the same sparse set, always beside tanksOnly.
tanksMe = {},
-- The buffs offered to nobody but you (Buffs.lua, tankChoice: a
-- druid's Thorns on herself): the same sparse set.
meOnly = {},
-- Of the buffs a player may hold to tanks (Buffs.lua, tankChoice: a
-- druid's Thorns), the ones never reminded of on you inside a
-- dungeon or a raid, whatever Offer to says (asked for on CurseForge
-- by a druid who heals there): the same sparse set, absent is as ever.
notMeInside = {},
-- The buffs kept for a favour and a request by name (Buffs.lua,
-- returnOnly: Unending Breath) because the player chose that: a sparse
-- set, absent is offered to everybody, as it was before 1.11.19.
keptBack = {},
-- A blessing for each class (Who to buff, under the buff order; a
-- paladin's ask on CurseForge: Wisdom for mages rather than Kings):
-- CLASS -> the key of the buff of yours tried first for somebody of
-- that class, for a class whose buffs replace one another
-- (PickBuffFor's exclusive branch). Absent is the walk as it stands.
forClass = {},
-- The buffs that are off until they are switched on (Buffs.lua, optIn:
-- Detect Invisibility for your group), switched on: a sparse set, absent
-- is off (ns.OptedOut).
optIn = {},
-- A buff held to your group by Manners' choice (Buffs.lua, membersOnly:
-- a warlock's Detect Invisibility) offered to passers-by too, and to a
-- passer-by who asks for it: asked for by a player. Off, so it stays
-- the group's alone until somebody ticks it (ns.PassersToo).
detectPassers = false,
-- A paladin who knows Blessing of Kings offers it to everybody ahead of
-- the rest (Buffs.lua, `strongest`; CastableBuffs). On: the strongest
-- blessing first is what was asked for, and somebody already carrying
-- one of yours, or Kings from another paladin, is handled as ever.
kingsFirst = true,
-- A paladin leaves alone anybody who carries a blessing from another
-- paladin (PickBuffFor's exclusive branch): in a group where the
-- blessings are shared out, theirs is the one they were given. Off,
-- because blessings from two paladins stack and today it is offered.
leaveBlessed = false,
-- A paladin's Might is not offered to a mage, a warlock or a priest,
-- for whom it does nothing (Core.lua, Castable): asked for on
-- CurseForge. On since the right-buff audit (it was off, "because it
-- takes away an offer somebody gets today"): melee attack power on a
-- mage is the wrong buff, and whoever asks for it by name still gets it.
skipCasters = true,
-- WoW Forever: somebody wearing a Fish Bowl's Boosted Stats (8% to all
-- stats, which Kings replaces) is offered the paladin's other blessings
-- first, and Kings only when nothing else of his is missing for them
-- (Core.lua, SparesFishBowl). Asked for on GitHub (issue 12). Off,
-- because it takes away an offer somebody gets today.
spareFishBowl = false,
-- Under it (GitHub issue 17): never Kings while they wear it, not
-- even with nothing else of yours missing. A request by name still
-- gets it. Read only while the switch above is on.
neverFishBowl = false,
-- WoW Forever: a campsite's Boosted Stamina, Intellect or Spirit is
-- never cast over, whatever it is worth beside yours (Core.lua,
-- UnitHasBuff; Buffs.lua, statTiers). Asked for on CurseForge. Off:
-- the stronger buff is what somebody gets today.
spareCamp = false,
-- The order a class's buffs are tried in, set by hand (Who to buff, Buff
-- order): order[CLASS] = { key, key, ... }, every buff of that class the
-- client that wrote it has. Absent is Automatic -- the list as the buff
-- set gives it, Kings ahead of it while kingsFirst is on -- and one that
-- is there wins over kingsFirst. Per class, since the profile is shared by
-- every character; a key this client lacks is kept for the client that
-- has it (ns.ClampSettings, ns.WalkBuffs).
order = {},
},
sources = {
owed = true, -- people who buffed us
group = true, -- party/raid missing it
-- The pets of the people in it too: a hunter's beast, a warlock's
-- demon (asked for on CurseForge by a hunter and a warlock). Off,
-- and walked only with `group` on (Queue.lua, IterateUnits): a pet
-- is reached by its name alone, which a player has to want.
pets = false,
-- Your resurrection for the group's dead, out of a fight (Resurrect.lua).
-- On, the one offer here nobody ticked: it is for a member of your
-- group, and only ever adds an offer. For a dead passer-by too: off.
res = true,
resStrangers = false,
-- The group split with the other Manners users of your class in it
-- (Share.lua), so two of you are not sent to the same member. On: it
-- only takes double offers away, and does nothing with no other user.
share = true,
strangers = true, -- nearby non-group players
-- A poison, a disease, a curse or a harmful spell taken off somebody,
-- out of combat (Cures.lua): your party and raid, and passers-by.
-- Both off: casting on other people in a new way is the player's
-- to choose. Neither waits on `group` or `strangers` above.
cures = false,
curesStrangers = false,
-- And on yourself (Cures.lua, ns.CureSelf), out of a fight: off, like
-- the rest of the cures, a switch the player turns on.
curesSelf = false,
owedClassBuffsOnly = true, -- ignore stray HoTs and procs
-- People who ask for your buff in chat. Off, because reading chat is
-- guesswork, so the player should choose it.
asked = false,
-- A class's courtesies for whoever asks for one (Courtesy.lua), under
-- `asked`, each off until ticked: a mage's water and food and his
-- portals, a warlock's healthstones and summons.
courtesyRefresh = false,
courtesyPortals = false,
courtesyHealthstones = false,
courtesySummons = false,
-- Yourself, missing your own buff. On: it costs nobody anything and reads
-- your own auras, which the game does not hide.
self = true,
-- Somebody who could cast a buff you would want and do not wear,
-- asked for it with one polite line (Ask.lua). Off: it speaks to
-- other players, so the player chooses it.
ask = false,
},
-- How an ask is said (Ask.lua): a whisper or /say, which of the three
-- plain lines, and whether anybody is asked in a city or an inn.
ask = {
channel = "WHISPER",
line = "moment",
-- My own words (Ask.lua, line "own"): empty until written.
own = "",
inTowns = false,
},
-- A hunter's pet (HunterPet.lua): care, each with its own switch under
-- Myself, and the moments with it (Bond with my pet). All on.
beast = {
call = true,
revive = true,
feed = true,
mend = true,
bond = true,
-- All on but Growl's reminder; moments come Sometimes.
all = true, leaveFood = true, growl = false, training = true, fightMend = true,
pace = "sometimes", answer = true, words = true, memory = true,
praise = true, comfort = true, welcome = true, sorry = true, hello = true, morning = true,
road = true, play = true, share = true, family = true, missed = true, saved = true,
grown = true, anniversary = true,
},
-- The rest of "Myself": the buffs only your class puts on itself
-- (Buffs.lua, VANILLA_OWN), and where you are reminded of any of it.
ownBuffs = {
-- Off: nobody needs Inner Fire at the auction house, and a prompt
-- that nags in town teaches you to ignore it. One rule for
-- everything on yourself, your group buff included (SelfEntry):
-- two rules for one "You" on the prompt would be a puzzle.
inCities = false,
-- On: the reminders for what comes out of the bags -- an oil or a
-- stone for the weapon, food -- come up only in a dungeon or a
-- raid. A rogue's poisons and a fishing lure are not held to it.
itemsInDungeons = false,
-- On: your own food, a stone or an oil for the weapon, a flask, an elixir
-- and a scroll wait behind everybody else on the prompt (Queue.lua,
-- PRIORITY.selfLast), so a busy place offers other people first.
-- Asked for on CurseForge (GitHub issue 27).
itemsLast = false,
-- Off: a warrior's Battle Shout is never offered to you (it covers you
-- when it goes on your party). On: with nobody in your group, a missing
-- or running-out shout is offered to you too (CastsOnSelf).
shoutAlone = false,
-- On: Dampen Magic (Buffs.lua, `solo`) is offered only while you are
-- in no group: in one it cuts the healing you get (asked for on
-- GitHub). Off: offered in a group too.
dampenAlone = true,
-- The same for Amplify Magic (Buffs.lua, `solo`), a switch of its own.
amplifyAlone = true,
-- On: a shaman's weapon imbues come ahead of his shield on the prompt
-- (KnownOwnFamilies), for one who is short of mana for the shield.
imbueFirst = false,
-- On: the sleeping bag comes up again in Well-Rested's last five
-- minutes, not only once it has gone (OwnVerdict).
restedEarly = false,
-- Off: food, flasks, elixirs, scrolls and a weapon's oils, stones and
-- poisons come up on the prompt as "You". On: on a button of their
-- own (Prompt/Supplies.lua, ns.SupplyEntry), asked for on CurseForge,
-- so the prompt can stay in plain sight and they out of the way.
apart = false,
-- Off: no scroll of any kind is offered (Buffs.lua, isScroll: the stat
-- scrolls, a mage's familiar and imbue on Forever) and their switches
-- leave the page; each keeps its pick below for when this is on again.
-- On by default, which is how they were before the switch.
scrolls = true,
-- Which pet the journal brings out with the companion pet switch on
-- (Companion.lua, Forever): "last" (the one out last, else a
-- favourite, else any), "favourite" or "random" (any pet).
petChoice = "last",
-- Which food Well Fed reminds you to eat with several in the bags
-- (Core.lua, FoodByChoice): "best" (the first you can eat in the
-- table's order, as it always was), "weakest" (the lowest level first)
-- or a food's own key ("food" and its item id).
foodOrder = "best",
-- Per family, by its key: "auto" (Automatic, or ticked for a family of one),
-- a spell's key (always that one), or "off" (Don't remind me). Filled below.
pick = {},
-- Per spell, by its key, of a family of several: true leaves it out
-- of what is reminded ("Never remind me about"), whatever the
-- pick. Filled below with a false for each, so it is shared,
-- repaired and reset like the picks.
leave = {},
-- Elixirs to keep up (Classic Era and Forever, whose elixirs have no
-- slot in the data: Buffs.lua, `keep`): per spell key, true for each
-- elixir to keep on at once, each reminded of in turn while it is in
-- the bags (Core.lua, KeepAnswer). Empty: any one elixir will do.
elixirKeep = {},
},
-- The order of the queue, not who is on it.
priority = {
target = true, -- a deliberate target outranks a favour owed
-- Friends and guildmates ahead of the rest of their kind. On,
-- because it only reorders people who were offered anyway.
friends = true,
-- Group members missing your buff go first while a ready check runs, and so
-- does somebody just back from the dead. On, for the same reason as friends.
readyCheck = true,
revived = true,
},
-- One cast for a whole party (GroupBuffs.lua). On: only somebody who has
-- learned the group version and carries its reagent gets it -- nobody does
-- but to use it -- and it saves the mana and presses of one by one.
groupBuffs = {
use = true,
-- How many of one party (or, for a Greater Blessing, one class)
-- must be missing the buff. Three: fewer is as quick one by one,
-- and not worth a reagent.
atLeast = 3,
},
-- People never to offer anything to, as a set of filed names. Somebody
-- on it who buffs you is still offered the favour back (STATUS.md).
never = {},
filters = {
relevantOnly = true, -- skip people the buff does nothing for
requireInRange = true,
-- How near a passer-by has to be: cast | near | beside. Not "cast",
-- because thirty yards of a city square is twenty-odd nameplates.
proximity = "near",
-- Passers-by only where the game calls you resting. Off, because
-- it takes away offers somebody gets today.
restingOnly = false,
-- Nothing offered to anybody, passers-by, your group and a favour
-- you owe alike, while the game calls you resting: a city or an
-- inn. Off, because it takes away offers somebody gets today.
quietInTowns = false,
-- Where that holds: both | cities | inns. A city is one of the capitals
-- by the client's own map ids (Range.lua, ns.InCity), an inn anywhere
-- else the game calls you resting. Both, as it always was.
quietInTownsWhere = "both",
-- On: while resting in a city or an inn, the buffs that last this many
-- minutes or less are not offered (Core.lua, Castable): Thorns held
-- back where Mark of the Wild still goes (a CurseForge comment).
quietShortInTowns = false,
quietShortMinutes = 15,
-- The same inside a dungeon or a raid (Queue.lua, Inside): nothing
-- for anybody but a target or focus. A battleground or an arena goes
-- by battle.team below, which ticking this one unticks.
quietInInstances = false,
-- On: the two rules above hold back the target and focus too, which
-- they leave alone otherwise (asked for on GitHub, issue 8).
quietTargets = false,
-- Guilds nobody is offered anything from, one name a line (Queue.lua,
-- SkippedGuilds): asked for on CurseForge.
skipGuilds = "",
-- Classes left out as passers-by, as a sparse set of class tokens
-- (absent = offered): asked for on CurseForge. Your group, a favour,
-- a request and your target or focus are not held to it.
skipNearbyClasses = {},
reachableOnly = true, -- hide people we cannot actually reach
restoreTarget = true, -- hand your target back after buffing
whenBuffed = "skip", -- skip | refresh | always
-- The most minutes before a buff ends that a top-up is ever offered
-- (the ceiling of its lead, worked out from how long the buff lasts:
-- see "how early a top-up is offered").
refreshUnder = 5,
-- In a raid or a dungeon the lead is this many times longer: a fight
-- and the drinking after it take minutes.
refreshRaid = 2,
-- Your own buffs, and the ones you put on yourself, are topped up
-- before they run out whatever whenBuffed says for other people
-- (ns.SelfWhenBuffed), and selfLead minutes ahead when set (0: the
-- moment worked out from the buff's length, ns.LeadFor).
selfTopUp = true,
selfLead = 0,
-- Off: somebody whose buffs the client will not show is offered,
-- "unverified" (but not in the first seconds after a fight:
-- UNVERIFIED_SECONDS). On, never: a player asked for it.
verifiedOnly = false,
-- Off: somebody who buffed you and already wears everything you
-- could give them, with more than the top-up lead left, whoever cast
-- it, is offered nothing, and the favour is let go at once (Queue.lua,
-- "covered"). On, the buff they hold is refreshed to return it, as it
-- always was until a priest asked (CurseForge).
repayCovered = false,
minLevel = 1,
-- A cure is offered only for a debuff with more than this many
-- seconds left (Cures.lua): one about to run out is not worth the press.
cureSeconds = 10,
-- Off, because a press on a mount dismounts you, which somebody
-- buffing from the saddle may want. Dead, taxi and vehicle need no
-- switch: nothing can be cast there, so BuildQueue offers nobody.
hideMounted = false,
-- Nobody flagged for PvP, while you are not flagged yourself
-- (Queue.lua, "flagged for PvP"). On: a buff on them flags you
-- too, for minutes, which nobody asked for by buffing back.
skipPvP = true,
-- Nobody the game says is in a fight (Queue.lua, "in a fight"): a
-- buff on them pulls you in. Off: asked for on CurseForge.
skipFighting = false,
-- Off: an option a player asked for (see SelfServed in Queue.lua).
skipSameClass = false,
-- The share of your mana (0-90) kept for yourself: below it, only
-- a favour owed or a request from chat is offered. 0 is off.
manaFloor = 0,
-- What it still offers below it (Queue.lua, ns.ManaFloorKeeps):
-- "asked" (favours, requests and your own buff, as it always did),
-- "self" (your own buff alone) or "none".
manaFloorKeeps = "asked",
-- The raid groups (1-8) switched off, as a sparse set (absent = on): in a
-- raid, those groups are offered nothing unasked.
skipRaidGroups = {},
},
-- In battlegrounds and arenas (Battle.lua, When to offer): a section of
-- its own, which decides there whatever Offer nothing in dungeons, raids
-- and battlegrounds says.
battle = {
-- On: your team is offered there -- freely before the gates open,
-- then out of combat and within reach. Off: nobody else is.
team = true,
-- Off: no line is said with a cast there, in any channel.
speak = false,
-- On: the /thank and the whispered thank-you go there too, to your
-- own team alone. Off: nobody is thanked there, as before 1.11.25.
thank = true,
-- Off: what Consumables only in dungeons and raids holds back stays
-- held there. On: a battleground or an arena counts as a dungeon.
items = false,
},
timing = {
reciprocateWindow = 120,
retryCooldown = 12,
-- How long a right-click on the prompt (or Not now) leaves somebody, or
-- your own buff, alone. Was the retry cooldown's number until 1.11.14.
skipSeconds = 12,
-- How long a right-click on one of your own buffs leaves it alone, in minutes; 0 follows skipSeconds.
ownSkipMinutes = 0,
scanInterval = 0.4,
graceSeconds = 45,
keepDebts = true,
},
prompt = {
locked = true,
-- Unlocked while the game's Edit Mode is open, locked again when it
-- closes (Prompt/Button.lua, "Edit Mode").
moveInEditMode = true,
-- Just above the action bars rather than over the play area, where
-- it would swallow clicks. The bottom edge keeps that distance at
-- any resolution, which a CENTER offset does not.
point = "BOTTOM",
relPoint = "BOTTOM",
x = 0,
y = 300,
width = 220,
height = 44,
scale = 1,
alpha = 1,
-- Only suppresses the click-outcome flash in a fight: Hide() on a
-- protected frame is refused in combat. The key keeps its old name
-- because renaming it would silently reset everyone's setting.
hideInCombat = false,
-- The whole prompt off the screen for a fight, its key, its list and
-- the bar macro casting nothing meanwhile (Prompt/Fight.lua).
hideInFight = false,
-- In a fight, with the prompt left up, each press moves the button
-- on to the next person the queue held as the fight began
-- (Prompt/Fight.lua, the fight's rota). Off, a fight holds the
-- prompt on the one person, as it did before 1.11.19.
fightRota = true,
-- A Forsaken's Will of the Forsaken on a button of its own beside
-- the prompt, shown in every fight and lit up while feared,
-- charmed or asleep (Prompt/BreakFree.lua). Only a character with
-- the ability ever sees the switch.
breakFree = true,
-- When the Will of the Forsaken and Mend Pet buttons show in a fight
-- (Prompt/BreakFree.lua, Prompt/MendPet.lua): needed, out of sight (alpha
-- 0) until Manners sees the need; always, dim for the whole fight as before
-- 1.11.34. The cure button keeps its own rule.
fightButtons = "needed",
-- The class's cure on a button of its own beside the prompt for a
-- fight, out of sight until somebody near you needs it
-- (Prompt/CureFight.lua). Off until ticked.
cureFight = false,
-- The spell the prompt's own key casts in a fight, by a row key of
-- Prompt/FightKey.lua's list, kept per class (CLASS -> key) because
-- every character shares the profile; none, or "none", keeps the key
-- to buffs. The key is pointed at a button of its own for the length
-- of the fight. (Before 1.11.35 one key for all: fightKeySpell, which
-- ClampSettings carries over once.)
fightKeySpells = {},
-- Who that spell lands on, for a spell that can go on others, on a client
-- where [@unit] resolves: "friend" (the player under the mouse, else
-- the target, else you) or "me".
fightKeyOn = "friend",
-- The built-in looks (Glass, Framed, Minimal) draw the prompt at about
-- half strength in a fight when this is on, so it reads as held. Off by
-- default: a dim that stacks with a low Opacity made it vanish.
dimInCombat = false,
-- The options window fading after a change on Look, so the prompt
-- shows behind it (Options/Window/Window.lua, PeekTarget). Off since
-- 1.11.20: players found it in the way.
peekOnChange = false,
-- Glass again from 1.5.1: 1.5.0 made Luxe the default, and in the game its
-- reason tag read white on white for a passer-by -- the preview renderer draws
-- light layers far gentler than the client does. AceDB never saves a value
-- equal to its default, so everybody who never picked a look is back on
-- Glass; a look somebody picked, Luxe included, is kept.
style = "glass",
-- Use my class's look on each character (Looks/Looks.lua, ONE LOOK A
-- CLASS): off. classStyles: CLASS -> the one of that class's own looks
-- picked; prompt.profileStyle (no default) is the profile's own look
-- while it is on.
classLook = false,
classStyles = {},
accentByReason = true,
-- standard | colourblind: which reason colours (Prompt/Prompt.lua).
reasonPalette = "standard",
accentMode = "icon", -- icon | stripe | both | off
flashStyle = "pulse", -- pulse | once | off
-- /thank somebody who buffs you (Favours.lua). Off: an emote is
-- seen by everybody nearby, so the player chooses to make one.
thankEmote = false,
-- Which emote it is (1.11.3): one of ns.THANK_EMOTES, by token. /thank until
-- the player picks another; the emote is made at the person who buffed you.
thankEmoteToken = "THANK",
-- Others to pick from at random (1.11.20, asked for on CurseForge): a
-- sparse set of tokens of ns.THANK_EMOTES, ticked true. Empty, the
-- emote above is the only one.
thankEmoteMore = {},
-- A thank-you whispered to somebody who buffs you and is owed nothing
-- back (Speech.lua, ns.ThankWhisper). Off: it goes to a stranger.
thankWhisper = false,
-- Both of those after a pause of a second or three rather than the
-- moment the buff lands (Favours.lua, ThankFavour). Off: somebody who
-- buffs in passing on a mount may be gone by then.
thankDelay = false,
-- The emote with nobody targeted for a class buff whose caster the
-- game names to nobody, and the whispered thank-you by name to
-- somebody only the combat log names (Favours.lua, ThankUnseen and
-- ThankByName; asked for on CurseForge). Off: an emote at nobody is
-- still seen by everybody near.
thankUnseen = false,
-- Every thank above waits for a press of the prompt instead of going
-- out by itself (ThankPress.lua; asked for on CurseForge). Off: the
-- thanks go as they always have.
thankAsk = false,
-- No /thank and no whispered thank-you while you are in a party or a
-- raid outside a battleground (Favours.lua, Held; asked for on
-- CurseForge). Off: thanks go as before.
thankNotInGroup = false,
-- full | calm: calm is the prompt without the animations.
effects = "full",
-- The global cooldown swept over the spell icon.
showCooldown = true,
showIcon = true,
iconSize = 30,
roundIcon = false,
-- The built-in looks' bezel round the icon, and the shadow (and on
-- Minimal the outline) under the words: on, as the looks were drawn;
-- off for a flat prompt, the icon and the words with nothing round
-- them (Prompt/Panel.lua, Prompt/Text.lua).
iconFrame = true,
-- Glass's gryphons, one at each end (Looks/Glass.lua): off until
-- they are switched on, since not everybody wants the bar that wide.
gryphons = false,
-- Earlier art: every look drawn as it was before its painted frame
-- (Looks/Painted.lua), for whoever liked it better. Off: a look with a
-- painting wears it.
classicArt = false,
-- Show my key on the prompt: "look" as the look has it (a painted
-- look's own default from Looks/PaintedData.lua: shown on the class
-- and themed looks, hidden on the calmer ones), "show" or "hide" on
-- every look. No key bound shows nothing whatever it says.
keycap = "look",
textShadow = true,
showCount = true,
showQueue = false,
queueRows = 3,
-- A left click on a name in that list buffs them (Prompt/Rows.lua).
-- Off: the list is only to read.
clickRows = true,
-- What hovering the prompt or a name in the list shows
-- (Prompt/Button.lua): full | short | shift | off. Short is the name,
-- why and a hint that Shift gives the rest; shift shows nothing until
-- Shift is held; off none (the drag tooltip of an unlocked prompt
-- stays, it explains the drag).
tooltip = "short",
-- Where it goes: beside (above or below the prompt and its list,
-- whichever side has more room) | game (where the client puts its own
-- tooltips).
tooltipPosition = "beside",
-- LibSharedMedia's own default font for this client's language: "Friz
-- Quadrata TT" on most, but koKR, zhCN and zhTW register no such name,
-- and a profile holding it read "(not loaded)" on its own Look page
-- though nothing was wrong. AceDB writes no value equal to the default
-- into the saved file, so an untouched profile follows the language of
-- whichever client opens it, and only a font the player picked is kept.
font = (function()
local lsm = LibStub and LibStub("LibSharedMedia-3.0", true)
local media = lsm and type(lsm.DefaultMedia) == "table" and lsm.DefaultMedia.font
return type(media) == "string" and media ~= "" and media or "Friz Quadrata TT"
end)(),
fontSize = 13,
fontColor = { 1, 1, 1, 1 },
bgColor = { 0.04, 0.04, 0.06, 0.88 },
accentColor = { 0.45, 0.4, 0.9, 1 },
format = "{name}",
showSub = true,
-- Their guild, <Name>, after the reason on the second line.
showGuild = false,
-- Short to fit the 220px default width. They start in the player's
-- language; AceDB stores a line only once somebody types their own.
-- Each reason has its own words, so colour is never the only cue.
reasonTarget = L["your target"],
reasonOwed = L["buffed you"],
reasonGroup = L["in your group"],
reasonNearby = L["needs {buff}"],
reasonAsked = L["asked for it"],
-- Under "You" on the first line: which of your own buffs is off.
reasonSelf = L["your own {buff}"],
-- A top-up gets its own line rather than qualifying the player's
-- text. {time} is what their current aura has left.
reasonRefresh = L["expires in {time}"],
reasonUnknown = L["unverified"],
classColor = true,
},
speech = {
enabled = false,
channel = "SAY",
-- Off from 1.5.1: with this on by default, a player ticked "Say a line when I
-- buff someone", buffed a passer-by and heard nothing. The thank-you quick
-- choices on Start here still switch it on for themselves.
onlyWhenReturning = false,
-- Filled in at load from the Roleplay set.
phrases = "",
-- The player's own lines said among the In character ones (Speech.lua,
-- MixedIn): one a line, about one press in three while it holds any.
-- Asked for on CurseForge by a player on the RP server.
mixedLines = "",
-- Say nothing in a party, Say nothing in a raid (Speech.lua,
-- ns.GroupQuiet): no line goes out with a cast there, to anybody.
-- Asked for by the author.
quietInParty = false,
quietInRaid = false,
-- First name only (Speech.lua, ns.SaidName): {name} says the first
-- word of a name with a surname. How often my own lines are said
-- (Speech.lua, OwnTurn): "third", "half", "twothirds" or "always".
-- Lines left out (Phrases.lua, RP.Pick): In character lines as
-- written, never chosen. Asked for on CurseForge by a player on a
-- roleplay realm.
firstNameOnly = false,
mixedShare = "third",
leftOut = {},
},
-- owedOnly, to match the flash, which only pulses for a favour owed.
sound = { enabled = false, file = ns.SOUND_KEY, owedOnly = true },
-- A place of our own on the minimap's rim: LibDBIcon puts every addon at 225
-- degrees, where the button sat on another addon's, and a player saw its "!"
-- and got Manners' tooltip (1.5.1). A dragged button keeps its place.
minimap = { hide = false, minimapPos = 195 },
-- The consumables button (Prompt/Supplies.lua), shown with
-- ownBuffs.apart on: where it sits (left of the prompt's default
-- spot, above the action bars) and its size in pixels.
supplies = { point = "BOTTOM", relPoint = "BOTTOM", x = -170, y = 300, size = 40 },
},
}
ns.defaults = defaults
-- The emotes a favour can be answered with: tokens the client's emote call takes,
-- each a friendly gesture to a stranger. Written as the slash command, which stays
-- English (Options/Say.lua). A set beside the list, for the repair and the call.
-- The first eight since 1.11.3; the rest since 1.11.15, asked for on CurseForge.
-- Every one a token of each client's own emote list (Blizzard_ChatFrameBase,
-- ChatEmoteConstants.lua on the live, forever, classic, classic_anniversary and
-- classic_era branches), and every one friendly.
ns.THANK_EMOTES = { "THANK", "CHEER", "BOW", "CLAP", "SALUTE", "WAVE", "NOD", "SMILE",
"APPLAUD", "BLUSH", "CURTSEY", "FLEX", "GREET", "GRIN", "HAIL", "HAPPY", "HIGHFIVE", "HUG",
"KISS", "KNEEL", "LOVE", "PRAISE", "PROUD", "WELCOME" }
ns.THANK_EMOTE_SET = {}
for _, token in ipairs(ns.THANK_EMOTES) do ns.THANK_EMOTE_SET[token] = true end
-- Every family of every class Automatic, so a profile shared by a mage and a
-- priest holds both, and no family's default is missing for the repair, the
-- reset or a settings string. Buffs.lua loads first.
for _, families in pairs(ns.OWN_BUFFS or {}) do
for _, family in ipairs(families) do defaults.profile.ownBuffs.pick[family.key] = "auto" end
end
-- Well Fed is off until a player turns it on: it reads every food in the bags, and
-- a reminder to eat nobody asked for would be the first thing to switch off.
-- Well-Rested too, the sleeping bag's (Buffs.lua, bagged).
for _, families in pairs(ns.OWN_BUFFS or {}) do
for _, family in ipairs(families) do
if family.food then defaults.profile.ownBuffs.pick[family.key] = "off" end
if family.rest then defaults.profile.ownBuffs.pick[family.key] = "off" end
-- And the companion pet (Buffs.lua, pet), which nobody is owed.
if family.pet then defaults.profile.ownBuffs.pick[family.key] = "off" end
-- Flasks, elixirs and scrolls the same (Buffs.lua, consumable).
if family.consumable then defaults.profile.ownBuffs.pick[family.key] = "off" end
-- And a spell few keep up, asked for by those who do (Buffs.lua, optIn).
if family.optIn then defaults.profile.ownBuffs.pick[family.key] = "off" end
end
end
for _, families in pairs(ns.OWN_BUFFS or {}) do
for _, family in ipairs(families) do
if ns.OwnLeaveable(family) then
for _, spell in ipairs(family.spells) do defaults.profile.ownBuffs.leave[spell.key] = false end
end
end
end
-- Whether the prompt's first line says anything at all; shared by the repair at
-- load and the box's setter so they agree on what an empty line is.
function ns.UsableFormat(text)
return type(text) == "string" and text:find("%S") ~= nil
end
---------------------------------------------------------------------------
-- capability probe
---------------------------------------------------------------------------
local caps = { buffs = {} }
ns.caps = caps
local playerClass
-- For the files after this one, read at call time: each probe sets it again.
function ns.PlayerClass() return playerClass end
-- nil when this client does not have the id. Both generations are tried.
local function SpellNameFor(id)
return safecall(C_Spell and C_Spell.GetSpellName, id)
or safecall(_G.GetSpellInfo, id)
end
ns.SpellNameFor = SpellNameFor
-- Whether UnitName's second return is a surname here rather than a realm. Reads
-- ns.Flavour, settled at load, because callers can run before the first probe;
-- caps.unitNameIsSurname is set from this so the two cannot disagree.
local function SurnameClient()
return (ns.Flavour and ns.Flavour.flavour) == "camelot"
end
-- The probe's helpers, in a block of their own for the main chunk's 200 locals.
do
-- Whether you know spell `id`. The client's own calls first: Forever
-- 1.60.1 keeps IsSpellKnown and IsPlayerSpell only as shims, in
-- Blizzard_DeprecatedSpellBook, behind the loadDeprecationFallbacks
-- setting; with that off both are gone and every class read as knowing
-- nothing. These are the two calls the shims make. Only the probe asks,
-- never a busy path.
local function SpellKnown(id)