4 local GetSpecialization = GetSpecialization;
5 local UnitExists = UnitExists;
6 local UnitAura = UnitAura;
8 -- character specific frames
14 spec = 3, -- Retribution
16 auraFilter = "PLAYER HARMFUL",
17 x = 570, -- placed over Innervate frame
24 spec = 3, -- Retribution
25 auras = {"Divine Purpose"},
26 auraFilter = "PLAYER HELPFUL",
34 spec = 2, -- Protection
35 auras = {"Shield of the Righteous"},
36 auraFilter = "PLAYER HELPFUL",
44 auras = {"Divine Shield"},
45 auraFilter = "PLAYER HELPFUL",
56 -- unit = unitID where to check auras, not required for totem checkers
57 -- spec = player spec index to show frame, if nil show always
58 -- auras = list of auras to track, in priority order
59 -- auraFilter = filter for UnitAura
60 -- totems = list of totem slots to track, in priority order, only checked if auras is nil
61 -- x = x position relative to UIParent bottom left
62 -- y = y position relative to UIParent bottom left
66 -- global frames' settings
70 auras = {"Innervate"},
71 auraFilter = "HELPFUL",
80 "Delusions", "Entropic Blast", "Necrotic Embrace", "Flametouched", "Shadowtouched",
81 "Blazing Eruption", "Shattering Scream", "Consuming Hunger", "Unstable Soul",
82 "Time Bomb", "Broken Shard",
84 auraFilter = "HARMFUL",
93 local units = {}; -- mapping from unitID to frames
94 local totems = {}; -- mapping to frames with totems
96 for i = 1, MAX_BOSS_FRAMES do
97 bosses[i] = "boss"..i;
99 local currentSpec = 0; -- 0 is invalid
101 local Indicators = CreateFrame("Frame", "OmaTMW", UIParent);
103 local function updateAuraFrame(frame)
104 local unit = frame.unit;
105 if UnitExists(unit) and (not frame.spec or frame.spec == currentSpec) then
106 local name, icon, count, duration, expires;
107 for _, aura in pairs(frame.auras) do
108 name, _, icon, count, _, duration, expires = UnitAura(unit, aura, nil, frame.auraFilter);
111 frame.stack:SetText(count);
117 frame.cd:SetCooldown(expires - duration, duration);
122 frame.icon:SetTexture(icon);
131 local function updateAuras(unit)
133 for _, i in pairs(units[unit]) do
134 updateAuraFrame(frames[i]);
139 local function updateTotemFrame(frame)
140 print("totem frame not implemented");
143 local function updateTotems(slot)
145 for _, i in pairs(totems[slot]) do
146 updateTotemFrame(frames[i]);
151 local function createTMW(name, config, parent)
152 local frame = CreateFrame("Frame", name, parent);
153 frame:SetPoint("TOPLEFT", parent, "BOTTOMLEFT", config.x, config.y+config.height);
154 frame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", config.x+config.width, config.y);
155 frame.unit = config.unit;
156 frame.spec = config.spec;
157 frame.auras = config.auras;
158 frame.auraFilter = config.auraFilter;
159 frame.totems = config.totems;
161 frame.base = frame:CreateTexture(nil, "BACKGROUND");
162 frame.base:SetAllPoints();
163 frame.base:SetColorTexture(0, 0, 0, 0.6);
164 frame.icon = frame:CreateTexture(nil, "ARTWORK");
165 frame.icon:SetPoint("TOPLEFT", frame.base, "TOPLEFT", 1, -1);
166 frame.icon:SetPoint("BOTTOMRIGHT", frame.base, "BOTTOMRIGHT", -1, 1);
167 frame.icon:SetTexCoord(0.07, 0.93, 0.07, 0.93);
168 frame.stack = frame:CreateFontString(nil, "OVERLAY", "NumberFontNormalLarge");
169 frame.stack:SetPoint("TOPLEFT");
170 frame.cd = CreateFrame("Cooldown", name.."CD", frame, "CooldownFrameTemplate");
171 frame.cd:SetReverse(true);
172 frame.cd:SetAllPoints();
176 local function initialize()
177 Indicators:SetFrameStrata("LOW");
178 Indicators:SetPoint("BOTTOMLEFT");
179 Indicators:SetWidth(1);
180 Indicators:SetHeight(1);
181 currentSpec = GetSpecialization();
182 local name, realm = UnitFullName("player");
183 if chars[realm] and chars[realm][name] then
184 for _, config in pairs(chars[realm][name]) do
185 table.insert(settings, config)
188 for i, config in pairs(settings) do
190 if not units[config.unit] then units[config.unit] = {} end
191 table.insert(units[config.unit], i);
193 if config.totems then
194 for _, slot in pairs(config.totems) do
195 if not totems[slot] then totems[slot] = {} end
196 table.insert(totems[slot], i);
199 frames[i] = createTMW("OmaTMW"..i, config, Indicators);
202 for _, frame in pairs(frames) do
203 if frame.auras then updateAuraFrame(frame) end
204 if frame.totems then updateTotemFrame(frame) end
208 Indicators:RegisterEvent("UNIT_AURA");
209 Indicators:RegisterEvent("PLAYER_TARGET_CHANGED");
210 Indicators:RegisterEvent("PLAYER_TOTEM_UPDATE");
211 Indicators:RegisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT");
212 Indicators:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED");
213 Indicators:RegisterEvent("PLAYER_LOGIN");
214 Indicators:SetScript("OnEvent", function(self, event, arg1)
215 if event == "UNIT_AURA" then
217 elseif event == "PLAYER_TARGET_CHANGED" then
218 updateAuras("target");
219 elseif event == "PLAYER_TOTEM_UPDATE" then
221 elseif event == "INSTANCE_ENCOUNTER_ENGAGE_UNIT" then
222 for _, boss in pairs(bosses) do
225 elseif event == "PLAYER_SPECIALIZATION_CHANGED" then
226 currentSpec = GetSpecialization();
227 for _, frame in pairs(frames) do
228 if frame.auras then updateAuraFrame(frame) end
229 if frame.totems then updateTotemFrame(frame) end
231 elseif event == "PLAYER_LOGIN" then