vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 if (not Nurfed_CombatLog) then
2  
3 local utility = Nurfed_Utility:New();
4 local unitlib = Nurfed_Units:New();
5 local options = Nurfed_Options:New();
6  
7 Nurfed_CombatLog = {};
8  
9 Nurfed_CombatLog.index = {
10 Heal = 2,
11 Hit = 3,
12 Spell = 4,
13 Dot = 5,
14 SpellMiss = 6,
15 Environment = 7,
16 PowerGain = 8,
17 Debuff = 9,
18 Buff = 10,
19 AuraFade = 11,
20 MeleeMiss = 12,
21 Resist = 13,
22 SpellFail = 14,
23 Cast = 15,
24 Perform = 16,
25 };
26  
27 Nurfed_CombatLog.events = {
28 ["AURA"] = { "Aura" },
29 ["BUFF"] = { "Heal", "Hot", "Dot", "Aura", "Cast", "Perform", "SpellMiss", "SpellFail", "Resists" },
30 ["HITS"] = { "Hit", "Env" },
31 ["MISSES"] = { "Miss" },
32 ["DAMAGE"] = { "Spell", "Dot", "Aura", "Resists", "SpellMiss", "SpellFail", "Cast", "Perform" },
33 ["DEATH"] = { "Death" },
34 };
35  
36 function Nurfed_CombatLog:New()
37 local object = {};
38 setmetatable(object, self);
39 self.__index = self;
40 return object;
41 end
42  
43 function Nurfed_CombatLog:Init()
44 for _, event in Nurfed_CombatLog_Strings do
45 for _, v in event do
46 v.s = utility:FormatGS(v.s, true);
47 end
48 end
49  
50 for _, v in Nurfed_CombatLog_Trailers do
51 v.s = utility:FormatGS(v.s);
52 end
53 end
54  
55 function Nurfed_CombatLog:ParseEvent(event, arg1)
56 local eventtable, result, out, outtype;
57  
58 for e, t in self.events do
59 if (string.find(event, e, 1, true)) then
60 eventtable = t;
61 break;
62 end
63 end
64  
65 if (eventtable) then
66 local found;
67 for _, v in eventtable do
68 for _, text in Nurfed_CombatLog_Strings[v] do
69 if (string.find(arg1, text.s)) then
70 result = {string.find(arg1, text.s)};
71 out = text.o;
72 outtype = text.t;
73 found = true;
74 break;
75 end
76 end
77 if (found) then
78 break;
79 end
80 end
81 end
82  
83 if (result and out) then
84 local args = {};
85 for k, v in out do
86 if (type(v) == "number") then
87 args[k] = string.gsub(result[v + 2], "^%l", string.upper);
88 else
89 args[k] = v;
90 end
91 end
92 self:Output(args, outtype, arg1);
93 end
94 end
95  
96 function Nurfed_CombatLog:ParseTrailer(text, damage)
97 damage = tonumber(damage);
98 local totaldamage = damage;
99 local totalreduction = 0;
100 local i, start, value, reduced, trailer;
101 for i = 1, 3 do
102 start, _, value = string.find(text, Nurfed_CombatLog_Trailers[i].s);
103 if (start ~= nil) then
104 reduced = tonumber(value);
105 totaldamage = totaldamage + reduced;
106 totalreduction = totalreduction + reduced;
107 value = self:FormatRGB(MISS)..value.."|r";
108 if (trailer) then
109 trailer = trailer..", "..Nurfed_CombatLog_Trailers[i].o..value.."|r";
110 else
111 trailer = Nurfed_CombatLog_Trailers[i].o..value.."|r";
112 end
113 end
114 end
115  
116 if (totalreduction > 0) then
117 totalreduction = self:FormatRGB(MISS)..tostring(totalreduction).."|r";
118 totaldamage = self:FormatRGB("damage")..tostring(totaldamage).."|r";
119 trailer = "("..trailer.."; "..totalreduction.."|r/"..totaldamage.."|r)";
120 end
121  
122 if (string.find(text, CRUSHING_TRAILER, 1, true)) then
123 if (trailer) then
124 trailer = trailer.."|cffff0000"..CRUSHING_TRAILER.."|r";
125 else
126 trailer = "|cffff0000"..CRUSHING_TRAILER.."|r";
127 end
128 end
129  
130 if (string.find(text, GLANCING_TRAILER, 1, true)) then
131 if (trailer) then
132 trailer = trailer.."|cffffff00"..GLANCING_TRAILER.."|r";
133 else
134 trailer = "|cffffff00"..GLANCING_TRAILER.."|r";
135 end
136 end
137 return trailer;
138 end
139  
140 function Nurfed_CombatLog:FormatRGB(option, crit)
141 local info = options:GetOption("combatlog", option);
142 if (not info) then
143 return "|cffffffff";
144 end
145 local r, g, b;
146 if (crit) then
147 local overlay = options:GetOption("combatlog", "overlay");
148 r = (info[1]/2) + (overlay[1]/2);
149 g = (info[2]/2) + (overlay[2]/2);
150 b = (info[3]/2) + (overlay[3]/2);
151 else
152 r = info[1];
153 g = info[2];
154 b = info[3];
155 end
156 return string.format("|cff%02x%02x%02x", (r*255), (g*255), (b*255));
157 end
158  
159 function Nurfed_CombatLog:FormatName(name, option, t, noformat)
160 if (not name) then
161 return nil;
162 end
163  
164 local unit;
165 local out = {};
166 local format = options:GetOption("combatlog", option);
167 local watches = options:GetOption("combatlog", "watches");
168  
169 if (name == YOU) then
170 unit = "You";
171 elseif (UnitExists("pet") and name == UnitName("pet")) then
172 unit = "Pet";
173 else
174 local info = unitlib:GetUnit(name);
175 if (info) then
176 unit = info.t;
177 else
178 unit = "Enemy";
179 end
180 end
181  
182 local index = self.index[t];
183  
184 if (t ~= "Death") then
185 if (watches[name] and watches[name][index] == 1) then
186 table.insert(out, watches[name][1]);
187 end
188 if (watches[unit] and watches[unit][index] == 1) then
189 table.insert(out, watches[unit][1]);
190 end
191 if (UnitExists("target") and name == UnitName("target") and watches["Target"] and watches["Target"][index] == 1) then
192 table.insert(out, watches["Target"][1]);
193 end
194 end
195 name = self:FormatRGB(unit)..name.."|r";
196 if (not noformat) then
197 name = string.gsub(format, "$n", name);
198 end
199 return name, out;
200 end
201  
202 function Nurfed_CombatLog:Output(vars, t, text)
203 local source, spell, target, amount, damagetype, trailer, out1, out2, format;
204 local out = {};
205 local sent = {};
206 if (t == "Heal" or t == "Hit" or t == "Spell" or t == "Dot" or t == "SpellMiss") then
207 source, out1 = self:FormatName(vars[1], "source", t);
208 target, out2 = self:FormatName(vars[3], "target", t);
209  
210 if (not out1 and not out2) then
211 return;
212 end
213  
214 spell = self:FormatRGB(vars[5])..vars[2].."|r";
215 if (vars[5] == "Heal") then
216 amount = self:FormatRGB("Heal", vars[6]).."+"..vars[4].."|r";
217 else
218 amount = self:FormatRGB("damage", vars[6])..vars[4].."|r";
219 end
220  
221 if (string.find(vars[4], "[1-9]") and t ~= "Heal") then
222 trailer = self:ParseTrailer(text, vars[4]);
223 end
224  
225 if (vars[6]) then
226 format = options:GetOption("combatlog", "crit");
227 amount = string.gsub(format, "$d", amount);
228 spell = spell.." Crit";
229 end
230  
231 table.insert(out, source);
232 table.insert(out, spell);
233 table.insert(out, target);
234 table.insert(out, amount);
235 if (trailer) then
236 table.insert(out, trailer);
237 end
238 elseif (t == "Environment") then
239 target, out1 = self:FormatName(vars[1], "target", t);
240  
241 if (not out1) then
242 return;
243 end
244  
245 spell = self:FormatRGB(vars[4])..vars[2].."|r";
246 amount = self:FormatRGB("damage")..vars[3].."|r";
247  
248 if (string.find(vars[3], "[1-9]")) then
249 trailer = self:ParseTrailer(text, vars[3]);
250 end
251  
252 table.insert(out, target);
253 table.insert(out, spell);
254 table.insert(out, amount);
255 if (trailer) then
256 table.insert(out, trailer);
257 end
258 elseif (t == "Death" or t == "Destroyed") then
259 local deathout = options:GetOption("combatlog", "deathout");
260 if (deathout == 0) then
261 return;
262 end
263 target = self:FormatName(vars[1], "target", t, true);
264 source = self:FormatName(vars[3], "source", t, true);
265  
266 if (t == "Destroyed") then
267 local destroyed = options:GetOption("combatlog", "destroyed");
268 if (destroyed ~= 1) then
269 return;
270 end
271 end
272 out1 = { deathout };
273 spell = vars[2];
274  
275 format = options:GetOption("combatlog", "death");
276 target = string.gsub(format, "$n", target);
277  
278 table.insert(out, target);
279 table.insert(out, spell);
280 if (source) then
281 table.insert(out, "("..source..")");
282 end
283 elseif (t == "PowerGain") then
284 target, out1 = self:FormatName(vars[1], "target", t);
285 if (not out1) then
286 return;
287 end
288 local color = self:FormatRGB(vars[3]);
289 amount = color..vars[2].." "..vars[3].."|r".." ("..color..vars[4].."|r)";
290  
291  
292 table.insert(out, target);
293 table.insert(out, amount);
294 elseif (t == "Debuff") then
295 target, out1 = self:FormatName(vars[1], "target", t);
296 if (not out1) then
297 return;
298 end
299 spell = vars[2].." "..self:FormatRGB("debuff")..vars[3].."|r";
300  
301 table.insert(out, target);
302 table.insert(out, spell);
303 elseif (t == "Buff") then
304 target, out1 = self:FormatName(vars[1], "target", t);
305 if (not out1) then
306 return;
307 end
308 spell = vars[2].." "..self:FormatRGB("buff")..vars[3].."|r";
309  
310 table.insert(out, target);
311 table.insert(out, spell);
312 elseif (t == "AuraFade") then
313 target, out1 = self:FormatName(vars[1], "target", t);
314 if (not out1) then
315 return;
316 end
317 spell = self:FormatRGB("buff")..vars[2].."|r "..vars[3];
318  
319 table.insert(out, target);
320 table.insert(out, spell);
321 elseif (t == "MeleeMiss") then
322 source, out1 = self:FormatName(vars[1], "source", t);
323 target, out2 = self:FormatName(vars[3], "target", t);
324  
325 if (not out1 and not out2) then
326 return;
327 end
328 spell = self:FormatRGB(MISS)..vars[2].."|r";
329  
330 table.insert(out, source);
331 table.insert(out, spell);
332 table.insert(out, target);
333 elseif (t == "Resist" or t == "SpellFail") then
334 source, out1 = self:FormatName(vars[1], "source", t);
335 target, out2 = self:FormatName(vars[3], "target", t);
336  
337 if (not out1 and not out2) then
338 return;
339 end
340 spell = vars[2];
341 amount = self:FormatRGB(MISS)..vars[4].."|r";
342  
343 table.insert(out, source);
344 table.insert(out, spell);
345 table.insert(out, target);
346 table.insert(out, amount);
347 elseif (t == "Cast" or t == "Perform") then
348 local casted;
349 if (t == "Cast") then
350 casted = true;
351 end
352 source, out1 = self:FormatName(vars[1], "source", t, casted);
353 target, out2 = self:FormatName(vars[3], "target", t, casted);
354  
355 if (not out1 and not out2) then
356 return;
357 end
358  
359 spell = self:FormatRGB("cast")..vars[2].."|r";
360 if (casted) then
361 format = options:GetOption("combatlog", "spellalert");
362 spell = string.gsub(format, "$s", spell);
363 end
364  
365 table.insert(out, source);
366 table.insert(out, spell);
367 if (target) then
368 table.insert(out, target);
369 end
370 end
371  
372 if (out1) then
373 for k, v in out1 do
374 if (not sent[v]) then
375 utility:Print(table.concat(out, " "), v);
376 sent[v] = true;
377 end
378 end
379 end
380 if (out2) then
381 for k, v in out2 do
382 if (not sent[v]) then
383 utility:Print(table.concat(out, " "), v);
384 sent[v] = true;
385 end
386 end
387 end
388 end
389 end