vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 DHUD_variables = {
2  
3 ["<spellname>"] = {
4 func = function(text, unit)
5 local time = DHUD.spellname;
6 if time then
7 text = DHUD:gsub(text, '<spellname>', time);
8 else
9 text = DHUD:gsub(text, '<spellname>', "");
10 end
11 return text;
12 end,
13 events = { },
14 hideval = "",
15 },
16  
17 ["<casttime>"] = {
18 func = function(text, unit)
19 local time = DHUD.casting_time;
20 if time then
21 text = DHUD:gsub(text, '<casttime>', time);
22 else
23 text = DHUD:gsub(text, '<casttime>', "");
24 end
25 return text;
26 end,
27 events = { },
28 hideval = "",
29 },
30  
31 ["<casttime_remain>"] = {
32 func = function(text, unit)
33 local time = DHUD.casting_time_rev;
34 if time then
35 text = DHUD:gsub(text, '<casttime_remain>', time);
36 else
37 text = DHUD:gsub(text, '<casttime_remain>', "");
38 end
39 return text;
40 end,
41 events = { },
42 hideval = "",
43 },
44  
45 ["<casttime_delay>"] = {
46 func = function(text, unit)
47 local time = DHUD.casting_time_del;
48 if time then
49 if tonumber(time) == 0 then
50 time = "";
51 end
52 text = DHUD:gsub(text, '<casttime_delay>', time);
53 else
54 text = DHUD:gsub(text, '<casttime_delay>', "");
55 end
56 return text;
57 end,
58 events = { },
59 hideval = "",
60 },
61  
62 ["<name>"] = {
63 func = function(text, unit)
64 if unit then
65 local unitname = UnitName(unit);
66 if unitname then
67 text = DHUD:gsub(text, '<name>', unitname);
68 else
69 text = DHUD:gsub(text, '<name>', "");
70 end
71 end
72 return text;
73 end,
74 events = { "UNIT_NAME_UPDATE" },
75 hideval = "",
76 },
77  
78 ["<hp_percent>"] = {
79 func = function(text, unit)
80 local percent = 0;
81 local health = UnitHealth(unit);
82 local healthmax = UnitHealthMax(unit);
83 if (healthmax > 0) then
84 percent = math.floor(health/healthmax * 100);
85 else
86 percent = 0;
87 end
88 text = DHUD:gsub(text, '<hp_percent>', percent.."%%");
89 return text;
90 end,
91 events = { "UNIT_HEALTH", "UNIT_MAXHEALTH" },
92 hideval = "0%%",
93 },
94  
95 ["<hp_value>"] = {
96 func = function(text, unit)
97 local h;
98  
99 if unit == "target" then
100 -- mobhealth2
101 if MobHealth_GetTargetCurHP then
102 h = MobHealth_GetTargetCurHP();
103 -- mobinfo
104 elseif MobHealth_PPP and UnitName(unit) and UnitLevel(unit) then
105 local mi = UnitName(unit)..":"..UnitLevel(unit);
106 local p = MobHealth_PPP(mi);
107 h = math.floor(UnitHealth(unit) * p + 0.5);
108 -- telos mobhealth
109 elseif MobHealthDB and UnitName(unit) and UnitLevel(unit) then
110 local mi = UnitName(unit)..":"..UnitLevel(unit);
111 local p = DHUD_MobHealth_PPP(mi);
112 h = math.floor(UnitHealth(unit) * p + 0.5);
113 -- blizz
114 else
115 h = UnitHealth(unit);
116 end
117 else
118 h = UnitHealth(unit);
119 end
120  
121 if ((not h) or h == 0) then
122 h = UnitHealth(unit);
123 end
124  
125 text = DHUD:gsub(text, '<hp_value>', h);
126 return text;
127 end,
128 events = { "UNIT_HEALTH", "UNIT_MAXHEALTH" },
129 hideval = "0",
130 },
131  
132 ["<hp_max>"] = {
133 func = function(text, unit)
134 local h;
135  
136 if unit == "target" then
137 -- mobhealth2
138 if MobHealth_GetTargetMaxHP and UnitHealth(unit) > 0 then
139 h = MobHealth_GetTargetMaxHP();
140 -- mobinfo
141 elseif MobHealth_PPP and UnitName(unit) and UnitLevel(unit) then
142 local mi = UnitName(unit)..":"..UnitLevel(unit);
143 local p = MobHealth_PPP(mi);
144 h = math.floor(100 * p + 0.5);
145 -- telos mobhealth
146 elseif MobHealthDB and UnitName(unit) and UnitLevel(unit) then
147 local mi = UnitName(unit)..":"..UnitLevel(unit);
148 local p = DHUD_MobHealth_PPP(mi);
149 h = math.floor(100 * p + 0.5);
150 -- blizz
151 else
152 h = UnitHealthMax(unit);
153 end
154 else
155 h = UnitHealthMax(unit);
156 end
157  
158 if ((not h) or h == 0) then
159 h = UnitHealthMax(unit);
160 end
161  
162 text = DHUD:gsub(text, '<hp_max>', h);
163 return text;
164 end,
165 events = { "UNIT_HEALTH", "UNIT_MAXHEALTH" },
166 hideval = "0",
167 },
168  
169 ["<hp_diff>"] = {
170 func = function(text, unit)
171 local m;
172  
173 if unit == "target" then
174 -- mobhealth2
175 if MobHealth_GetTargetMaxHP and UnitHealth(unit) > 0 then
176 m = MobHealth_GetTargetMaxHP();
177 h = MobHealth_GetTargetCurHP();
178 -- mobinfo
179 elseif MobHealth_PPP and UnitName(unit) and UnitLevel(unit) then
180 local mi = UnitName(unit)..":"..UnitLevel(unit);
181 local p = MobHealth_PPP(mi);
182 m = math.floor(100 * p + 0.5);
183 h = math.floor(UnitHealth(unit) * p + 0.5);
184 -- telos mobhealth
185 elseif MobHealthDB and UnitName(unit) and UnitLevel(unit) then
186 local mi = UnitName(unit)..":"..UnitLevel(unit);
187 local p = DHUD_MobHealth_PPP(mi);
188 m = math.floor(100 * p + 0.5);
189 h = math.floor(UnitHealth(unit) * p + 0.5);
190 -- blizz
191 else
192 m = UnitHealthMax(unit);
193 h = UnitHealth(unit);
194 end
195 else
196 m = UnitHealthMax(unit);
197 h = UnitHealth(unit);
198 end
199  
200 if ((not h) or h == 0) then
201 m = UnitHealthMax(unit);
202 h = UnitHealth(unit);
203 end
204  
205 local d = m - h;
206 if d > 0 and d < m then
207 d = "-"..d;
208 else
209 d = "";
210 end
211  
212 text = DHUD:gsub(text, '<hp_diff>', d);
213 return text;
214 end,
215 events = { "UNIT_HEALTH", "UNIT_MAXHEALTH" },
216 hideval = "",
217 },
218  
219 ["<mp_percent>"] = {
220 func = function(text, unit)
221 local percent = 0;
222 local mana = UnitMana(unit);
223 local manamax = UnitManaMax(unit);
224 if (manamax > 0) then
225 percent = math.floor(mana/manamax * 100);
226 else
227 percent = 0;
228 end
229 text = DHUD:gsub(text, '<mp_percent>', percent.."%%");
230 return text;
231 end,
232 events = { "UNIT_MANA","UNIT_MAXMANA","UNIT_FOCUS","UNIT_FOCUSMAX","UNIT_RAGE","UNIT_RAGEMAX","UNIT_ENERGY","UNIT_ENERGYMAX","UNIT_DISPLAYPOWER" },
233 hideval = "0%%",
234 },
235  
236 ["<mp_value>"] = {
237 func = function(text, unit)
238 local m = UnitMana(unit);
239 text = DHUD:gsub(text, '<mp_value>', m);
240 return text;
241 end,
242 events = { "UNIT_MANA","UNIT_MAXMANA","UNIT_FOCUS","UNIT_FOCUSMAX","UNIT_RAGE","UNIT_RAGEMAX","UNIT_ENERGY","UNIT_ENERGYMAX","UNIT_DISPLAYPOWER" },
243 hideval = "0",
244 },
245  
246 ["<mp_value_druid>"] = {
247 func = function(text, unit)
248 local dm;
249 if UnitPowerType("player") ~= 0 and DruidBarKey then
250 dm = math.floor(DruidBarKey.keepthemana);
251 else
252 dm = "";
253 end
254 text = DHUD:gsub(text, '<mp_value_druid>', dm);
255 return text;
256 end,
257 events = { "UNIT_MANA","UNIT_MAXMANA","UNIT_FOCUS","UNIT_FOCUSMAX","UNIT_RAGE","UNIT_RAGEMAX","UNIT_ENERGY","UNIT_ENERGYMAX","UNIT_DISPLAYPOWER","UPDATE_SHAPESHIFT_FORMS" },
258 hideval = "",
259 },
260  
261 ["<mp_max_druid>"] = {
262 func = function(text, unit)
263 local dm;
264 if UnitPowerType("player") ~= 0 and DruidBarKey then
265 dm = math.floor(DruidBarKey.maxmana);
266 else
267 dm = "";
268 end
269 text = DHUD:gsub(text, '<mp_max_druid>', dm);
270 return text;
271 end,
272 events = { "UNIT_MANA","UNIT_MAXMANA","UNIT_FOCUS","UNIT_FOCUSMAX","UNIT_RAGE","UNIT_RAGEMAX","UNIT_ENERGY","UNIT_ENERGYMAX","UNIT_DISPLAYPOWER","UPDATE_SHAPESHIFT_FORMS" },
273 hideval = "",
274 },
275  
276 ["<mp_percent_druid>"] = {
277 func = function(text, unit)
278 local dm;
279 if UnitPowerType("player") ~= 0 and DruidBarKey then
280 dm = math.floor(DruidBarKey.keepthemana / DruidBarKey.maxmana * 100);
281 else
282 dm = "";
283 end
284 text = DHUD:gsub(text, '<mp_percent_druid>', dm);
285 return text;
286 end,
287 events = { "UNIT_MANA","UNIT_MAXMANA","UNIT_FOCUS","UNIT_FOCUSMAX","UNIT_RAGE","UNIT_RAGEMAX","UNIT_ENERGY","UNIT_ENERGYMAX","UNIT_DISPLAYPOWER","UPDATE_SHAPESHIFT_FORMS" },
288 hideval = "",
289 },
290  
291 ["<mp_max>"] = {
292 func = function(text, unit)
293 local m = UnitManaMax(unit);
294 text = DHUD:gsub(text, '<mp_max>', m);
295 return text;
296 end,
297 events = { "UNIT_MANA","UNIT_MAXMANA","UNIT_FOCUS","UNIT_FOCUSMAX","UNIT_RAGE","UNIT_RAGEMAX","UNIT_ENERGY","UNIT_ENERGYMAX","UNIT_DISPLAYPOWER" },
298 hideval = "0",
299 },
300  
301  
302 ["<mp_diff>"] = {
303 func = function(text, unit)
304 local m = UnitManaMax(unit) - UnitMana(unit);
305 if m > 0 and m < UnitManaMax(unit) then
306 m = "-"..m;
307 else
308 m = "";
309 end
310 text = DHUD:gsub(text, '<mp_diff>', m);
311 return text;
312 end,
313 events = { "UNIT_MANA","UNIT_MAXMANA","UNIT_FOCUS","UNIT_FOCUSMAX","UNIT_RAGE","UNIT_RAGEMAX","UNIT_ENERGY","UNIT_ENERGYMAX","UNIT_DISPLAYPOWER" },
314 hideval = "",
315 },
316  
317 ["<color>"] = {
318 func = function(text, unit)
319 text = DHUD:gsub(text, '<color>', '|cff');
320 return text;
321 end,
322 events = { },
323 hideval = "|cff",
324 },
325 ["</color>"] = {
326 func = function(text, unit)
327 text = DHUD:gsub(text, '</color>', '|r');
328 return text;
329 end,
330 events = { },
331 hideval = "|r",
332 },
333 ["<level>"] = {
334 func = function(text, unit)
335 local level = UnitLevel(unit);
336 if level > 90 or level < 0 then
337 level = "??";
338 end
339 text = DHUD:gsub(text, '<level>', level );
340 return text;
341 end,
342 events = { "UNIT_LEVEL" },
343 hideval = "0",
344 },
345 ["<color_level>"] = {
346 func = function(text, unit)
347 local level = UnitLevel(unit);
348 if level < 0 then
349 level = 99;
350 end
351 local color = GetDifficultyColor(level);
352 if color and UnitExists(unit) then
353 text = DHUD:gsub(text, '<color_level>', "|cff"..DHUD_DecToHex(color.r,color.g,color.b) );
354 else
355 text = DHUD:gsub(text, '<color_level>', "|cffffffff" );
356 end
357 return text;
358 end,
359 events = { "UNIT_LEVEL" },
360 hideval = "|cffffffff",
361 },
362 ["<color_class>"] = {
363 func = function(text, unit)
364 local targetclass, eclass = UnitClass(unit);
365 local color = RAID_CLASS_COLORS[eclass or nil];
366 if color and UnitExists(unit) then
367 text = DHUD:gsub(text, '<color_class>', "|cff"..DHUD_DecToHex(color.r,color.g,color.b) );
368 else
369 text = DHUD:gsub(text, '<color_class>', "");
370 end
371 return text;
372 end,
373 events = { "UNIT_NAME_UPDATE" },
374 hideval = "",
375 },
376 ["<elite>"] = {
377 func = function(text, unit)
378 local elite = DHUD:CheckElite(unit)
379 text = DHUD:gsub(text, '<elite>', elite );
380 return text;
381 end,
382 events = { "UNIT_CLASSIFICATION_CHANGED" },
383 hideval = "",
384 },
385 ["<color_reaction>"] = {
386 func = function(text, unit)
387 local color = DHUD:GetReactionColor(unit);
388 if color and UnitExists(unit) then
389 text = DHUD:gsub(text, '<color_reaction>', "|cff"..color );
390 else
391 text = DHUD:gsub(text, '<color_reaction>', "");
392 end
393 return text;
394 end,
395 events = { "UNIT_CLASSIFICATION_CHANGED" },
396 hideval = "",
397 },
398 ["<type>"] = {
399 func = function(text, unit)
400 local creatureType = UnitCreatureType(unit);
401 if (UnitIsPlayer(unit)) then creatureType = ""; end
402 if DHUD:TargetIsNPC() then creatureType = ""; end
403 if DHUD:TargetIsPet() then creatureType = ""; end
404 text = DHUD:gsub(text, '<type>', creatureType );
405 return text;
406 end,
407 events = { "UNIT_CLASSIFICATION_CHANGED" },
408 hideval = "",
409 },
410 ["<class>"] = {
411 func = function(text, unit)
412 local targetclass, eclass = UnitClass("target");
413 if not UnitIsPlayer(unit) then targetclass = ""; end
414 text = DHUD:gsub(text, '<class>', targetclass );
415 return text;
416 end,
417 events = { "UNIT_NAME_UPDATE" },
418 hideval = "",
419 },
420 ["<pet>"] = {
421 func = function(text, unit)
422 if DHUD:TargetIsPet() then
423 text = DHUD:gsub(text, '<pet>', "Pet" );
424 else
425 text = DHUD:gsub(text, '<pet>', "" );
426 end
427 return text;
428 end,
429 events = { "UNIT_NAME_UPDATE" },
430 hideval = "",
431 },
432 ["<npc>"] = {
433 func = function(text, unit)
434 if DHUD:TargetIsNPC() then
435 text = DHUD:gsub(text, '<npc>', "NPC" );
436 else
437 text = DHUD:gsub(text, '<npc>', "" );
438 end
439 return text;
440 end,
441 events = { "UNIT_NAME_UPDATE" },
442 hideval = "",
443 },
444  
445 ["<faction>"] = {
446 func = function(text, unit)
447 local value = UnitFactionGroup(unit);
448 if (not UnitName(unit)) then value = ""; end
449 text = DHUD:gsub(text, '<faction>', value);
450 return text;
451 end,
452 events = {"UNIT_FACTION"},
453 hideval = "",
454  
455 },
456  
457  
458 ["<combopoints>"] = {
459 func = function(text, unit)
460 unit = target;
461 local value = GetComboPoints();
462 if value == 0 then value = ""; end;
463 text = DHUD:gsub(text, '<combopoints>', value);
464 return text;
465 end,
466 events = {"PLAYER_COMBO_POINTS"},
467 hideval = "",
468  
469 },
470  
471  
472 ["<pvp>"] = {
473 func = function(text, unit)
474 if (UnitIsPVPFreeForAll(unit) or UnitIsPVP(unit)) and not DHUD:TargetIsNPC() then
475 text = DHUD:gsub(text, '<pvp>', "PVP");
476 else
477 text = DHUD:gsub(text, '<pvp>', "");
478 end
479  
480 return text;
481 end,
482 events = {"UNIT_PVP_UPDATE"},
483 hideval = "",
484  
485 },
486  
487 ["<pvp_rank>"] = {
488  
489 func = function(text, unit)
490 local value = GetPVPRankInfo(UnitPVPRank(unit), unit);
491 text = DHUD:gsub(text, '<pvp_rank>', value);
492 return text;
493 end,
494 events = {"UNIT_PVP_UPDATE"} ,
495 hideval = "",
496  
497  
498 },
499  
500 ["<raidgroup>"] = {
501 func = function(text, unit)
502 local value;
503 for i = 1, GetNumRaidMembers() do
504 if (UnitIsUnit("raid"..i, unit)) then
505 _, _, value = GetRaidRosterInfo(i);
506 break;
507 end
508 end
509 if value then
510 text = DHUD:gsub(text, '<raidgroup>', value);
511 else
512 text = DHUD:gsub(text, '<raidgroup>', "");
513 end
514 return text;
515 end,
516 events = { "RAID_ROSTER_UPDATE" },
517 hideval = "",
518 },
519  
520  
521 ["<color_hp>"] = {
522 func = function(text, unit)
523 local percent;
524 local health = UnitHealth(unit);
525 local healthmax = UnitHealthMax(unit);
526 if (healthmax > 0 and UnitExists(unit) ) then
527 percent = health/healthmax;
528 local typunit = DHUD:getTypUnit(unit,"health")
529 local color = DHUD_DecToHex(DHUD:Colorize(typunit,percent));
530 text = DHUD:gsub(text, '<color_hp>', "|cff"..color );
531 else
532 text = DHUD:gsub(text, '<color_hp>', "|cffffffff" );
533 end
534 return text;
535 end,
536 events = { "UNIT_HEALTH", "UNIT_MAXHEALTH" },
537 hideval = "|cffffffff",
538 },
539 ["<color_mp>"] = {
540 func = function(text, unit)
541 local percent;
542 local health = UnitMana(unit);
543 local healthmax = UnitManaMax(unit);
544 local uc = 0;
545  
546 if DruidBarKey and DHUD.player_class == "DRUID" and unit == "pet" then
547 healthmax = DruidBarKey.maxmana;
548 health = DruidBarKey.keepthemana;
549 unit = "player";
550 uc = 1;
551 end
552  
553 if (healthmax > 0 and UnitExists(unit)) then
554 percent = health/healthmax;
555 local typunit = DHUD:getTypUnit(unit,"mana");
556  
557 if DruidBarKey and DHUD.player_class == "DRUID" and uc == 1 then
558 typunit = "mana_player";
559 end
560  
561 local color = DHUD_DecToHex(DHUD:Colorize(typunit,percent));
562 if uc == 1 and UnitPowerType("player") == 0 then
563 color = "ffffff";
564 end
565  
566 text = DHUD:gsub(text, '<color_mp>', "|cff"..color);
567 else
568 text = DHUD:gsub(text, '<color_mp>', "|cffffffff" );
569 end
570 return text;
571 end,
572 events = { "UNIT_MANA","UNIT_MAXMANA","UNIT_FOCUS","UNIT_FOCUSMAX","UNIT_RAGE","UNIT_RAGEMAX","UNIT_ENERGY","UNIT_ENERGYMAX" },
573 hideval = "|cffffffff",
574 },
575 ["<guild>"] = {
576 func = function(text, unit)
577 local v = GetGuildInfo(unit);
578 text = DHUD:gsub(text, '<guild>', v);
579 return text;
580 end,
581 events = { "UNIT_NAME_UPDATE" },
582 hideval = "",
583 },
584 }