vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | function GB_Get(bar, button, param3) |
2 | if (not GB_INITIALIZED) then return; end |
||
3 | if (param3) then |
||
4 | return GB_Settings[GB_INDEX][bar].Button[button][param3]; |
||
5 | elseif (button) then |
||
6 | return GB_Settings[GB_INDEX][bar].Button[button]; |
||
7 | else |
||
8 | return GB_Settings[GB_INDEX][bar]; |
||
9 | end |
||
10 | end |
||
11 | |||
12 | function GB_Set(bar, arg2, arg3, arg4) |
||
13 | if (arg4 ~= nil) then |
||
14 | GB_Settings[GB_INDEX][bar].Button[arg2][arg3] = arg4; |
||
15 | elseif (arg3 ~= nil) then |
||
16 | GB_Settings[GB_INDEX][bar][arg2] = arg3; |
||
17 | else |
||
18 | GB_Settings[GB_INDEX][bar] = arg2; |
||
19 | end |
||
20 | end |
||
21 | |||
22 | function GB_Get_ActionUsuable(name, rank, button) |
||
23 | if (GB_Get("disableActionInProgressSpam") and GB_SPELLISCASTING) then |
||
24 | return false; |
||
25 | end |
||
26 | if (GB_Get("disableOutOfRangeSpam")) then |
||
27 | local range = GB_SPELLS[name][rank].range; |
||
28 | if (range) then |
||
29 | if (IsActionInRange(range) == 0 and button:GetParent().unit == "target") then |
||
30 | return false; |
||
31 | end |
||
32 | end |
||
33 | end |
||
34 | if (GB_Get("disableCantDoYetSpam")) then |
||
35 | local _,duration = GetSpellCooldown(GB_SPELLS[name][rank].id, BOOKTYPE_SPELL); |
||
36 | if (duration ~= 0) then return; end |
||
37 | end |
||
38 | return true; |
||
39 | end |
||
40 | |||
41 | function GB_Get_AnnounceText(spellName, spellRank, unit, announceNum) |
||
42 | local text = GB_Settings[GB_INDEX].announcements[announceNum]; |
||
43 | local target = UnitName(unit); |
||
44 | if (not target) then target = ""; end |
||
45 | local castingTime = GB_SPELLS[spellName][spellRank].castingTime; |
||
46 | if (not castingTime) then castingTime = ""; end |
||
47 | local healAmount = math.floor(GB_SPELLS[spellName][spellRank].avg); |
||
48 | if (not healAmount) then healAmount = ""; end |
||
49 | local manaRemaining = math.floor(UnitMana("player") / UnitManaMax("player") * 100); |
||
50 | if (manaRemaining) then |
||
51 | manaRemaining = manaRemaining.."%%"; |
||
52 | else |
||
53 | manaRemaining = ""; |
||
54 | end |
||
55 | text = string.gsub(text, '$t', target); |
||
56 | text = string.gsub(text, '$r', spellRank); |
||
57 | text = string.gsub(text, '$s', spellName); |
||
58 | text = string.gsub(text, '$c', castingTime); |
||
59 | text = string.gsub(text, '$m', manaRemaining); |
||
60 | text = string.gsub(text, '$a', healAmount); |
||
61 | |||
62 | GB_ANNOUNCED = {}; |
||
63 | GB_ANNOUNCED.spellName = spellName; |
||
64 | GB_ANNOUNCED.spellRank = spellRank; |
||
65 | GB_ANNOUNCED.target = target; |
||
66 | |||
67 | return text; |
||
68 | end |
||
69 | |||
70 | function GB_Get_BuffMatch(buff, target) |
||
71 | if (GB_BUFFS[target] and GB_BUFFS[target][buff]) then |
||
72 | return GB_BUFFS[target][buff]; |
||
73 | elseif (GB_BUFFS[target] and GB_SPELLS[buff]) then |
||
74 | for i in GB_SPELLS[buff] do |
||
75 | return GB_BUFFS[target][GetSpellTexture(GB_SPELLS[buff][i].id, "BOOKTYPE_SPELL")]; |
||
76 | end |
||
77 | end |
||
78 | end |
||
79 | |||
80 | function GB_Get_BuffTarget(name) |
||
81 | if (not GB_Get_BuffMatch(name, "player")) then |
||
82 | return "player"; |
||
83 | end |
||
84 | local unit; |
||
85 | for i=1,4 do |
||
86 | if (UnitIsVisible("party"..i)) then |
||
87 | if ((not GB_Get("limitlhrange")) or CheckInteractDistance("party"..i, 4)) then |
||
88 | unit = "party"..i; |
||
89 | if ((not GB_Get_BuffMatch(name, unit)) and UnitName(unit)) then |
||
90 | return unit; |
||
91 | end |
||
92 | end |
||
93 | end |
||
94 | end |
||
95 | if (GB_Settings[GB_INDEX].includePets) then |
||
96 | if ((not GB_Get_BuffMatch(name, "pet")) and UnitName("pet")) then return "pet"; end |
||
97 | for i=1,4 do |
||
98 | if (UnitIsVisible("partypet"..i)) then |
||
99 | if ((not GB_Get("limitlhrange")) or CheckInteractDistance("partypet"..i, 4)) then |
||
100 | unit = "partypet"..i; |
||
101 | if ((not GB_Get_BuffMatch(name, unit)) and UnitName(unit)) then |
||
102 | return unit; |
||
103 | end |
||
104 | end |
||
105 | end |
||
106 | end |
||
107 | end |
||
108 | if (GB_Settings[GB_INDEX].includeRaid) then |
||
109 | for i=1,GetNumRaidMembers() do |
||
110 | if (UnitIsVisible("raid"..i)) then |
||
111 | unit = "raid"..i; |
||
112 | if ((not GB_Get("limitlhrange")) or CheckInteractDistance(unit, 4)) then |
||
113 | if ((not GB_Get_BuffMatch(name, unit)) and UnitName(unit)) then |
||
114 | return unit; |
||
115 | end |
||
116 | end |
||
117 | end |
||
118 | end |
||
119 | end |
||
120 | return; |
||
121 | end |
||
122 | |||
123 | function GB_Get_CorrectSpell(bar, button, target, overridePO) |
||
124 | local name = GB_Settings[GB_INDEX][bar].Button[button].name; |
||
125 | local rank = GB_Settings[GB_INDEX][bar].Button[button].rank; |
||
126 | |||
127 | if (not name) then |
||
128 | return; |
||
129 | end |
||
130 | |||
131 | if (GB_Settings[GB_INDEX][bar].Button[button].preventRebuff) then |
||
132 | local buffFound = GB_Get_BuffMatch(name, target); |
||
133 | if (not buffFound) then |
||
134 | buffFound = GB_Get_DebuffMatch(name, target); |
||
135 | end |
||
136 | if (buffFound) then |
||
137 | GB_Feedback(GB_TEXT.PreventedRebuff); |
||
138 | return; |
||
139 | end |
||
140 | end |
||
141 | |||
142 | if (name and GB_Settings[GB_INDEX][bar].Button[button].scaleRank) then |
||
143 | name, rank = GB_Get_ScaledRank(name, rank, target); |
||
144 | end |
||
145 | |||
146 | if (name and GB_Settings[GB_INDEX][bar].Button[button].preventOverhealing and (not overridePO)) then |
||
147 | name, rank = GB_Get_EfficientHeal(name, rank, target, GB_Settings[GB_INDEX][bar].Button[button].matchCastingTime, GB_Settings[GB_INDEX][bar].Button[button].matchSpellName); |
||
148 | end |
||
149 | |||
150 | if (name and GB_Settings[GB_INDEX][bar].Button[button].preventOverkill and (not overridePO)) then |
||
151 | name, rank = GB_Get_EfficientDamage(name, rank); |
||
152 | end |
||
153 | |||
154 | if (name and GB_Settings[GB_INDEX][bar].Button[button].lowManaRank) then |
||
155 | name, rank = GB_Get_EnoughManaRank(name, rank); |
||
156 | end |
||
157 | |||
158 | return name, rank; |
||
159 | end |
||
160 | |||
161 | function GB_Get_CureTarget(name) |
||
162 | local effects; |
||
163 | for _, v in GB_CURES do |
||
164 | if (v.text == name) then |
||
165 | effects = v.effects; |
||
166 | break; |
||
167 | end |
||
168 | end |
||
169 | for _, status in effects do |
||
170 | if (GB_Get_DebuffMatch(status, "player", 1)) then |
||
171 | return "player"; |
||
172 | end |
||
173 | local unit; |
||
174 | for i=1,4 do |
||
175 | if (UnitIsVisible("party"..i)) then |
||
176 | unit = "party"..i; |
||
177 | if ((not GB_Get("limitlhrange")) or CheckInteractDistance(unit, 4)) then |
||
178 | if (GB_Get_DebuffMatch(status, unit, 1)) then |
||
179 | return unit; |
||
180 | end |
||
181 | end |
||
182 | end |
||
183 | end |
||
184 | if (GB_Settings[GB_INDEX].includePets) then |
||
185 | if (GB_Get_DebuffMatch(status, "pet", 1)) then return "pet"; end |
||
186 | for i=1,4 do |
||
187 | if (UnitIsVisible("partypet"..i)) then |
||
188 | unit = "partypet"..i; |
||
189 | if ((not GB_Get("limitlhrange")) or CheckInteractDistance(unit, 4)) then |
||
190 | if (GB_Get_DebuffMatch(status, unit, 1)) then |
||
191 | return unit; |
||
192 | end |
||
193 | end |
||
194 | end |
||
195 | end |
||
196 | end |
||
197 | if (GB_Settings[GB_INDEX].includeRaid) then |
||
198 | for i=1,GetNumRaidMembers() do |
||
199 | if (UnitIsVisible("raid"..i)) then |
||
200 | unit = "raid"..i; |
||
201 | if ((not GB_Get("limitlhrange")) or CheckInteractDistance(unit, 4)) then |
||
202 | if (GB_Get_DebuffMatch(status, unit, 1)) then |
||
203 | return unit; |
||
204 | end |
||
205 | end |
||
206 | end |
||
207 | end |
||
208 | end |
||
209 | end |
||
210 | return; |
||
211 | end |
||
212 | |||
213 | function GB_Get_CurrentForm() |
||
214 | for i=1,GetNumShapeshiftForms() do |
||
215 | local _, _, isActive = GetShapeshiftFormInfo(i); |
||
216 | if isActive then return i; end |
||
217 | end |
||
218 | return 0; |
||
219 | end |
||
220 | |||
221 | function GB_Get_DebuffMatch(buff, target, statustoggle) |
||
222 | if (GB_DEBUFFS[target]) then |
||
223 | return GB_DEBUFFS[target][buff]; |
||
224 | end |
||
225 | end |
||
226 | |||
227 | function GB_Get_DefaultButtonSettings() |
||
228 | local value = { |
||
229 | name = nil, |
||
230 | rank = nil, |
||
231 | idType = "", |
||
232 | hide = false, |
||
233 | context = "Always", |
||
234 | inCombat = false, |
||
235 | notInCombat = false, |
||
236 | outdoors = false, |
||
237 | form = nil, |
||
238 | preventOverhealing = false, |
||
239 | preventOverkill = false, |
||
240 | preventRebuff = false, |
||
241 | matchCastingTime = false, |
||
242 | matchSpellName = false, |
||
243 | assist = false, |
||
244 | autoUpdate = false, |
||
245 | validTarget = false, |
||
246 | classes = { [GB_TEXT.Priest] = true, |
||
247 | [GB_TEXT.Warrior] = true, |
||
248 | [GB_TEXT.Paladin] = true, |
||
249 | [GB_TEXT.Mage] = true, |
||
250 | [GB_TEXT.Hunter] = true, |
||
251 | [GB_TEXT.Shaman] = true, |
||
252 | [GB_TEXT.Druid] = true, |
||
253 | [GB_TEXT.Rogue] = true, |
||
254 | [GB_TEXT.Warlock] = true |
||
255 | }, |
||
256 | scaleRank = false, |
||
257 | announce = false, |
||
258 | announceText = 1, |
||
259 | lowManaRank = false, |
||
260 | OOCoption = "hide", |
||
261 | flashInContext = false |
||
262 | }; |
||
263 | return value; |
||
264 | end |
||
265 | |||
266 | function GB_Get_EfficientDamage(name, rank) |
||
267 | if (not MobHealthFrame) then return name, rank; end |
||
268 | if (GB_SPELLS[name][rank].type ~= "damage") then |
||
269 | if (GB_SPELLS[name][rank].type == "DoT") then |
||
270 | if (GB_SPELLS[name][rank].avg == 0) then |
||
271 | return name, rank; |
||
272 | end |
||
273 | else |
||
274 | return name, rank; |
||
275 | end |
||
276 | end |
||
277 | health = MobHealth_GetTargetCurHP(); |
||
278 | if ((not health) or health == 0) then return name, rank; end |
||
279 | local difference = math.abs(GB_SPELLS[name][rank].min - health); |
||
280 | local origRank = rank; |
||
281 | for spellrank, spelldata in GB_SPELLS[name] do |
||
282 | local diff2 = math.abs(spelldata.min - health); |
||
283 | if (diff2 < difference and spelldata.min > health) then |
||
284 | difference = diff2; |
||
285 | rank = spellrank; |
||
286 | end |
||
287 | end |
||
288 | if (origRank ~= rank) then |
||
289 | GB_SpellChanged(GB_TEXT.POkillChangedSpell, name, rank); |
||
290 | end |
||
291 | return name, rank; |
||
292 | end |
||
293 | |||
294 | function GB_Get_EfficientHeal(name, rank, target, matchTime, matchName) |
||
295 | if (UnitHealthMax(target) == 100) then |
||
296 | return name, rank; |
||
297 | end |
||
298 | if (GB_SPELLS[name][rank].type ~= "heal") then |
||
299 | if (GB_SPELLS[name][rank].type == "HoT") then |
||
300 | if (GB_SPELLS[name][rank].avg == 0) then |
||
301 | return name, rank; |
||
302 | end |
||
303 | else |
||
304 | return name, rank; |
||
305 | end |
||
306 | end |
||
307 | local origName, origRank = name, rank; |
||
308 | local damage = UnitHealthMax(target) - UnitHealth(target); |
||
309 | local pastThreshold = GB_Get_PastThreshold("cancelHealThreshold", target); |
||
310 | if ((not pastThreshold) or damage == 0) then |
||
311 | GB_Feedback(GB_TEXT.HealPrevented); |
||
312 | return; |
||
313 | end |
||
314 | local modifier = 1; |
||
315 | if (GB_Get_BuffMatch(GB_TEXT.PowerInfusion, "player")) then |
||
316 | modifier = 1.2; |
||
317 | end |
||
318 | local difference = math.abs(GB_SPELLS[name][rank].avg * modifier - damage); |
||
319 | if ((not matchTime) and (not matchName)) then |
||
320 | local lowestMana = 99999; |
||
321 | for spellname, ranks in GB_SPELLS do |
||
322 | for spellrank, spelldata in ranks do |
||
323 | if (spelldata.type == "heal" and spelldata.avg > 0 and spelldata.avg * modifier > damage and (not GB_SKIP_SPELLS[spellname])) then |
||
324 | if (spelldata.mana and spelldata.mana < lowestMana) then |
||
325 | lowestMana = spelldata.mana; |
||
326 | name = spellname; |
||
327 | rank = spellrank; |
||
328 | end |
||
329 | end |
||
330 | end |
||
331 | end |
||
332 | elseif (matchName) then |
||
333 | for spellrank, spelldata in GB_SPELLS[name] do |
||
334 | local diff2 = math.abs(spelldata.avg * modifier - damage); |
||
335 | if (diff2 < difference) then |
||
336 | difference = diff2; |
||
337 | rank = spellrank; |
||
338 | end |
||
339 | end |
||
340 | elseif (matchTime) then |
||
341 | local basetime = GB_SPELLS[name][rank].castingTime; |
||
342 | for spellname, ranks in GB_SPELLS do |
||
343 | for spellrank, spelldata in ranks do |
||
344 | if (spelldata.type == "heal" and spelldata.castingTime == basetime and (not GB_SKIP_SPELLS[spellname])) then |
||
345 | local diff2 = math.abs(spelldata.avg * modifier - damage); |
||
346 | if (diff2 < difference) then |
||
347 | difference = diff2; |
||
348 | name = spellname; |
||
349 | rank = spellrank; |
||
350 | end |
||
351 | end |
||
352 | end |
||
353 | end |
||
354 | end |
||
355 | if (origName == name) then |
||
356 | local _,_,orignum = string.find(origRank, " (%d*)"); |
||
357 | local _,_,ranknum = string.find(rank, " (%d*)"); |
||
358 | orignum = tonumber(orignum); |
||
359 | ranknum = tonumber(ranknum); |
||
360 | if (orignum and ranknum) then |
||
361 | if (ranknum > orignum) then |
||
362 | name = origName; |
||
363 | rank = origRank; |
||
364 | end |
||
365 | end |
||
366 | end |
||
367 | if (origName ~= name or origRank ~= rank) then |
||
368 | GB_SpellChanged(GB_TEXT.POChangedSpell, name, rank); |
||
369 | end |
||
370 | return name, rank; |
||
371 | end |
||
372 | |||
373 | function GB_Get_EnoughManaRank(name, rank) |
||
374 | if (GB_Get_BuffMatch(GB_TEXT.InnerFocus, "player") or GB_Get_BuffMatch(GB_TEXT.Clearcasting, "player") or GB_Get_BuffMatch(GB_TEXT.SpiritOfRedemption, "player")) then return name, rank; end |
||
375 | local mana = UnitMana("player"); |
||
376 | local newrank = rank; |
||
377 | local _,_,ranknum = string.find(rank, " (%d*)"); |
||
378 | ranknum = tonumber(ranknum); |
||
379 | local difference = 99999; |
||
380 | for spellrank, data in GB_SPELLS[name] do |
||
381 | if (data.mana < mana) then |
||
382 | if ( (mana - data.mana) < difference) then |
||
383 | local _,_,newranknum = string.find(spellrank, " (%d*)"); |
||
384 | newranknum = tonumber(newranknum); |
||
385 | if (ranknum and newranknum) then |
||
386 | if (newranknum <= ranknum) then |
||
387 | difference = mana - data.mana; |
||
388 | newrank = spellrank; |
||
389 | end |
||
390 | end |
||
391 | end |
||
392 | end |
||
393 | end |
||
394 | if (GB_SPELLS[name][newrank].mana > mana) then |
||
395 | GB_Feedback(GB_TEXT.TooLowForAnyRank); |
||
396 | return; |
||
397 | end |
||
398 | if (newrank ~= rank) then |
||
399 | GB_SpellChanged(GB_TEXT.NotEnoughMana, name, newrank); |
||
400 | end |
||
401 | return name, newrank; |
||
402 | end |
||
403 | |||
404 | function GB_Get_HealthPercent(unit) |
||
405 | if (UnitIsGhost(unit)) then |
||
406 | return 2; |
||
407 | elseif (UnitHealthMax(unit) <= 0) then |
||
408 | return 1; |
||
409 | elseif (UnitHealth(unit) <= 0) then |
||
410 | return 2; |
||
411 | else |
||
412 | return UnitHealth(unit)/UnitHealthMax(unit); |
||
413 | end |
||
414 | end |
||
415 | |||
416 | function GB_Get_InContext(button) |
||
417 | local context = 0; |
||
418 | if (button.InContext) then |
||
419 | for i, value in button.InContext do |
||
420 | if (value == -1) then return false; end |
||
421 | end |
||
422 | end |
||
423 | return true; |
||
424 | end |
||
425 | |||
426 | function GB_Get_ItemName(bag, slot) |
||
427 | local itemname, itemlink; |
||
428 | if (slot) then |
||
429 | itemlink = GetContainerItemLink(bag,slot); |
||
430 | else |
||
431 | itemlink = GetInventoryItemLink("player", bag); |
||
432 | end |
||
433 | if (itemlink) then |
||
434 | itemname = string.sub(itemlink, string.find(itemlink, "[", 1, true) + 1, string.find(itemlink, "]", 1, true) - 1); |
||
435 | end |
||
436 | return itemname; |
||
437 | end |
||
438 | |||
439 | function GB_Get_ItemCount(itemname) |
||
440 | local itemCount = 0; |
||
441 | for bag = 0, 4 do |
||
442 | local bagslots = GetContainerNumSlots(bag); |
||
443 | if (bagslots) then |
||
444 | for slot = 1, bagslots do |
||
445 | itemlink = GetContainerItemLink(bag,slot); |
||
446 | if (itemlink) then |
||
447 | local itemname2 = GB_Get_ItemName(bag, slot); |
||
448 | if (itemname == itemname2) then |
||
449 | local ic2; |
||
450 | _, ic2 = GetContainerItemInfo(bag, slot); |
||
451 | itemCount = itemCount + ic2; |
||
452 | end |
||
453 | end |
||
454 | end |
||
455 | end |
||
456 | end |
||
457 | return itemCount; |
||
458 | end |
||
459 | |||
460 | function GB_Get_LowestHealthUnit() |
||
461 | local unit = "player"; |
||
462 | local lowest = GB_Get_HealthPercent("player"); |
||
463 | local check; |
||
464 | for i=1,4 do |
||
465 | if (UnitIsVisible("party"..i)) then |
||
466 | if ((not GB_Get("limitlhrange")) or CheckInteractDistance("party"..i, 4)) then |
||
467 | check = GB_Get_HealthPercent("party"..i); |
||
468 | if (check < lowest) then |
||
469 | lowest = check; |
||
470 | unit = "party"..i; |
||
471 | end |
||
472 | end |
||
473 | end |
||
474 | end |
||
475 | if (GB_Settings[GB_INDEX].includePets) then |
||
476 | if ((not GB_Get("limitlhrange")) or CheckInteractDistance("pet", 4)) then |
||
477 | check = GB_Get_HealthPercent("pet"); |
||
478 | if (check < lowest) then |
||
479 | lowest = check; |
||
480 | unit = "pet"; |
||
481 | end |
||
482 | end |
||
483 | for i=1,4 do |
||
484 | if (UnitIsVisible("partypet"..i)) then |
||
485 | if ((not GB_Get("limitlhrange")) or CheckInteractDistance("partypet"..i, 4)) then |
||
486 | check = GB_Get_HealthPercent("partypet"..i); |
||
487 | if (check < lowest) then |
||
488 | lowest = check; |
||
489 | unit = "partypet"..i; |
||
490 | end |
||
491 | end |
||
492 | end |
||
493 | end |
||
494 | end |
||
495 | if (GB_Settings[GB_INDEX].includeRaid) then |
||
496 | for i=1,GetNumRaidMembers() do |
||
497 | if (UnitIsVisible("raid"..i)) then |
||
498 | if ((not GB_Get("limitlhrange")) or CheckInteractDistance("raid"..i, 4)) then |
||
499 | check = GB_Get_HealthPercent("raid"..i); |
||
500 | if (check < lowest) then |
||
501 | lowest = check; |
||
502 | unit = "raid"..i; |
||
503 | end |
||
504 | end |
||
505 | end |
||
506 | end |
||
507 | end |
||
508 | return unit; |
||
509 | end |
||
510 | |||
511 | function GB_Get_PastThreshold(threshold, target, thresholdnum) |
||
512 | if ((not thresholdnum) or thresholdnum == "mana") then |
||
513 | threshold = GB_Settings[GB_INDEX][threshold]; |
||
514 | else |
||
515 | threshold = GB_Settings[GB_INDEX][threshold][thresholdnum]; |
||
516 | end |
||
517 | |||
518 | if ((not threshold) or threshold == "") then return true; end |
||
519 | if (UnitHealthMax(target) == 0 or (not UnitHealthMax(target))) then return 0; end |
||
520 | |||
521 | local damage = UnitHealthMax(target) - UnitHealth(target); |
||
522 | local percent = 100 - UnitHealth(target) / UnitHealthMax(target) * 100; |
||
523 | if (thresholdnum == "mana") then |
||
524 | damage = UnitManaMax(target) - UnitMana(target); |
||
525 | percent = 100 - UnitMana(target) / UnitManaMax(target) * 100; |
||
526 | end |
||
527 | if (threshold) then |
||
528 | if (string.find(threshold, "%%")) then |
||
529 | _,_,threshold = string.find(threshold, "(%d*)%%"); |
||
530 | threshold = tonumber(threshold); |
||
531 | if (threshold and percent < threshold) then |
||
532 | return false; |
||
533 | end |
||
534 | else |
||
535 | threshold = tonumber(threshold); |
||
536 | if (UnitHealthMax(target) == 100 or (not threshold)) then return 0; end |
||
537 | if (damage < threshold) then |
||
538 | return false; |
||
539 | end |
||
540 | end |
||
541 | end |
||
542 | return true; |
||
543 | end |
||
544 | |||
545 | function GB_Get_ScaledRank(name, rank, target) |
||
546 | local level = UnitLevel(target); |
||
547 | if (level == -1) then return name, rank; end |
||
548 | local _,_,orignum = string.find(rank, " (%d*)"); |
||
549 | orignum = tonumber(orignum); |
||
550 | local ranknum = orignum; |
||
551 | if (name==GB_MINLVL_SPELLS.Renew) then |
||
552 | if (level < 4) then ranknum = 1; |
||
553 | elseif (level < 10) then ranknum = 2; |
||
554 | elseif (level < 16) then ranknum = 3; |
||
555 | elseif (level < 22) then ranknum = 4; |
||
556 | elseif (level < 28) then ranknum = 5; |
||
557 | elseif (level < 34) then ranknum = 6; |
||
558 | elseif (level < 40) then ranknum = 7; |
||
559 | elseif (level < 46) then ranknum = 8; |
||
560 | elseif (level < 50) then ranknum = 9; |
||
561 | else ranknum = 10; end |
||
562 | if (ranknum == 10 and GB_SPELLS[GB_MINLVL_SPELLS.Renew][GB_TEXT.Rank..11]) then |
||
563 | ranknum = 11; |
||
564 | end |
||
565 | elseif (name==GB_MINLVL_SPELLS.PWFortitude) then |
||
566 | if (level < 2) then ranknum = 1; |
||
567 | elseif (level < 14) then ranknum = 2; |
||
568 | elseif (level < 26) then ranknum = 3; |
||
569 | elseif (level < 38) then ranknum = 4; |
||
570 | elseif (level < 50) then ranknum = 5; |
||
571 | else ranknum = 6; end |
||
572 | elseif (name==GB_MINLVL_SPELLS.DampenMagic) then |
||
573 | if (level < 2) then ranknum = 0; |
||
574 | elseif (level < 14) then ranknum = 1; |
||
575 | elseif (level < 26) then ranknum = 2; |
||
576 | elseif (level < 38) then ranknum = 3; |
||
577 | elseif (level < 50) then ranknum = 4; |
||
578 | else ranknum = 5; end |
||
579 | elseif (name==GB_MINLVL_SPELLS.AmplifyMagic) then |
||
580 | if (level < 8) then ranknum = 0; |
||
581 | elseif (level < 20) then ranknum = 1; |
||
582 | elseif (level < 32) then ranknum = 2; |
||
583 | elseif (level < 44) then ranknum = 3; |
||
584 | else ranknum = 4; end |
||
585 | elseif (name==GB_MINLVL_SPELLS.DivineSpirit) then |
||
586 | if (level < 20) then ranknum = 0; |
||
587 | elseif (level < 30) then ranknum = 1; |
||
588 | elseif (level < 40) then ranknum = 2; |
||
589 | elseif (level < 50) then ranknum = 3; |
||
590 | else ranknum = 4; end |
||
591 | elseif (name==GB_MINLVL_SPELLS.ShadowProtection) then |
||
592 | if (level < 20) then ranknum = 0; |
||
593 | elseif (level < 32) then ranknum = 1; |
||
594 | elseif (level < 46) then ranknum = 2; |
||
595 | else ranknum = 3; end |
||
596 | elseif (name==GB_MINLVL_SPELLS.PWShield) then |
||
597 | if (level < 2) then ranknum = 1; |
||
598 | elseif (level < 8) then ranknum = 2; |
||
599 | elseif (level < 14) then ranknum = 3; |
||
600 | elseif (level < 20) then ranknum = 4; |
||
601 | elseif (level < 26) then ranknum = 5; |
||
602 | elseif (level < 32) then ranknum = 6; |
||
603 | elseif (level < 38) then ranknum = 7; |
||
604 | elseif (level < 44) then ranknum = 8; |
||
605 | elseif (level < 50) then ranknum = 9; |
||
606 | else ranknum = 10; end |
||
607 | elseif (name==GB_MINLVL_SPELLS.MarkOfTheWild) then |
||
608 | if (level < 10) then ranknum = 2; |
||
609 | elseif (level < 20) then ranknum = 3; |
||
610 | elseif (level < 30) then ranknum = 4; |
||
611 | elseif (level < 40) then ranknum = 5; |
||
612 | elseif (level < 50) then ranknum = 6; |
||
613 | else ranknum = 7; end |
||
614 | elseif (name==GB_MINLVL_SPELLS.Rejuvenation) then |
||
615 | if (level < 6) then ranknum = 2; |
||
616 | elseif (level < 12) then ranknum = 3; |
||
617 | elseif (level < 18) then ranknum = 4; |
||
618 | elseif (level < 24) then ranknum = 5; |
||
619 | elseif (level < 30) then ranknum = 6; |
||
620 | elseif (level < 36) then ranknum = 7; |
||
621 | elseif (level < 42) then ranknum = 8; |
||
622 | elseif (level < 48) then ranknum = 9; |
||
623 | else ranknum = 10; end |
||
624 | elseif (name==GB_MINLVL_SPELLS.Thorns) then |
||
625 | if (level < 4) then ranknum = 1; |
||
626 | elseif (level < 14) then ranknum = 2; |
||
627 | elseif (level < 24) then ranknum = 3; |
||
628 | elseif (level < 34) then ranknum = 4; |
||
629 | elseif (level < 44) then ranknum = 5; |
||
630 | else ranknum = 6; end |
||
631 | elseif (name==GB_MINLVL_SPELLS.Regrowth) then |
||
632 | if (level < 2) then ranknum = 0; |
||
633 | elseif (level < 8) then ranknum = 1; |
||
634 | elseif (level < 14) then ranknum = 2; |
||
635 | elseif (level < 20) then ranknum = 3; |
||
636 | elseif (level < 26) then ranknum = 4; |
||
637 | elseif (level < 32) then ranknum = 5; |
||
638 | elseif (level < 38) then ranknum = 6; |
||
639 | elseif (level < 44) then ranknum = 7; |
||
640 | elseif (level < 50) then ranknum = 8; |
||
641 | else ranknum = 9; end |
||
642 | elseif (name==GB_MINLVL_SPELLS.ArcaneIntellect) then |
||
643 | if (level < 4) then ranknum = 1; |
||
644 | elseif (level < 18) then ranknum = 2; |
||
645 | elseif (level < 32) then ranknum = 3; |
||
646 | elseif (level < 46) then ranknum = 4; |
||
647 | else ranknum = 5; end |
||
648 | elseif (name==GB_MINLVL_SPELLS.BlessingMight) then |
||
649 | if (level < 2) then ranknum = 1; |
||
650 | elseif (level < 12) then ranknum = 2; |
||
651 | elseif (level < 22) then ranknum = 3; |
||
652 | elseif (level < 32) then ranknum = 4; |
||
653 | elseif (level < 42) then ranknum = 5; |
||
654 | elseif (level < 52) then ranknum = 6; |
||
655 | else ranknum = 7; end |
||
656 | if (ranknum == 7 and GB_SPELLS[GB_MINLVL_SPELLS.BlessingMight][GB_TEXT.Rank..8]) then |
||
657 | ranknum = 8; |
||
658 | end |
||
659 | elseif (name==GB_MINLVL_SPELLS.BlessingProtection) then |
||
660 | if (level < 14) then ranknum = 1; |
||
661 | elseif (level < 28) then ranknum = 2; |
||
662 | else ranknum = 3; end |
||
663 | elseif (name==GB_MINLVL_SPELLS.BlessingWisdom) then |
||
664 | if (level < 4) then ranknum = 0; |
||
665 | elseif (level < 14) then ranknum = 1; |
||
666 | elseif (level < 24) then ranknum = 2; |
||
667 | elseif (level < 34) then ranknum = 3; |
||
668 | elseif (level < 44) then ranknum = 4; |
||
669 | else ranknum = 5; end |
||
670 | if (ranknum == 5 and GB_SPELLS[GB_MINLVL_SPELLS.BlessingWisdom][GB_TEXT.Rank..6] and level > 49) then |
||
671 | ranknum = 6; |
||
672 | end |
||
673 | elseif (name==GB_MINLVL_SPELLS.BlessingFreedom) then |
||
674 | if (level < 8) then ranknum = 0; end |
||
675 | elseif (name==GB_MINLVL_SPELLS.BlessingSalvation) then |
||
676 | if (level < 16) then ranknum = 0; end |
||
677 | elseif (name==GB_MINLVL_SPELLS.AbolishDisease) then |
||
678 | if (level < 22) then ranknum = 0; end |
||
679 | elseif (name==GB_MINLVL_SPELLS.AbolishPoison) then |
||
680 | if (level < 16) then ranknum = 0; end |
||
681 | elseif (name==GB_MINLVL_SPELLS.BlessingSanctuary) then |
||
682 | if (level < 20) then ranknum = 0; |
||
683 | elseif (level < 30) then ranknum = 1; |
||
684 | elseif (level < 40) then ranknum = 2; |
||
685 | elseif (level < 50) then ranknum = 3; |
||
686 | else ranknum = 4; end |
||
687 | elseif (name==GB_MINLVL_SPELLS.BlessingLight) then |
||
688 | if (level < 30) then ranknum = 0; |
||
689 | elseif (level < 40) then ranknum = 1; |
||
690 | elseif (level < 50) then ranknum = 2; |
||
691 | else ranknum = 3; end |
||
692 | elseif (name==GB_MINLVL_SPELLS.BlessingKings) then |
||
693 | if (level < 30) then ranknum = 0; end |
||
694 | elseif (name==GB_MINLVL_SPELLS.BlessingSacrifice) then |
||
695 | if (level < 36) then ranknum = 0; |
||
696 | elseif (level < 44) then ranknum = 1; |
||
697 | else ranknum = 2; end |
||
698 | end |
||
699 | if ( ranknum == 0 ) then |
||
700 | GB_Feedback(GB_TEXT.LevelTooLow); |
||
701 | return false; |
||
702 | else |
||
703 | if (ranknum and ranknum < orignum) then |
||
704 | rank = GB_TEXT.Rank..ranknum; |
||
705 | GB_SpellChanged(GB_TEXT.RankScaled, name, rank); |
||
706 | end |
||
707 | return name, rank; |
||
708 | end |
||
709 | end |
||
710 | |||
711 | function GB_Get_Texture(bar, button) |
||
712 | if (not GB_INITIALIZED) then return; end |
||
713 | local name = GB_Settings[GB_INDEX][bar].Button[button].name; |
||
714 | local idType = GB_Settings[GB_INDEX][bar].Button[button].idType; |
||
715 | local texture = "Interface\\AddOns\\GroupButtons\\EmptyButton"; |
||
716 | if (not name) then |
||
717 | return texture; |
||
718 | end |
||
719 | local id; |
||
720 | if (idType == "spell") then |
||
721 | id = GB_SPELLS[name][GB_Settings[GB_INDEX][bar].Button[button].rank].id; |
||
722 | texture = GetSpellTexture(id, "BOOKTYPE_SPELL"); |
||
723 | elseif (idType == "item" and GB_ITEMS[name]) then |
||
724 | id = GB_ITEMS[name]; |
||
725 | texture = GetContainerItemInfo(id.bag, id.slot); |
||
726 | elseif (idType == "inv" and GB_INVENTORY[name]) then |
||
727 | id = GB_INVENTORY[name].id; |
||
728 | texture = GetInventoryItemTexture("player", id); |
||
729 | elseif (idType == "macro" and GB_MACROS[name]) then |
||
730 | id = GB_MACROS[name].id; |
||
731 | _, texture = GetMacroInfo(id); |
||
732 | end |
||
733 | return texture; |
||
734 | end |
||
735 | |||
736 | function GB_Get_UnitBar(param) |
||
737 | if (not param) then return; end |
||
738 | local value; |
||
739 | if (param == "self" or param == "player") then |
||
740 | value = "GB_PlayerBar"; |
||
741 | elseif (param == "party1") then |
||
742 | value = "GB_PartyBar1"; |
||
743 | elseif (param == "party2") then |
||
744 | value = "GB_PartyBar2"; |
||
745 | elseif (param == "party3") then |
||
746 | value = "GB_PartyBar3"; |
||
747 | elseif (param == "party4") then |
||
748 | value = "GB_PartyBar4"; |
||
749 | elseif (param == "target") then |
||
750 | if (GB_HostileTargetBar:IsVisible()) then |
||
751 | value = "GB_HostileTargetBar"; |
||
752 | elseif (GB_FriendlyTargetBar:IsVisible()) then |
||
753 | value = "GB_FriendlyTargetBar"; |
||
754 | elseif (UnitName(param)) then |
||
755 | if (UnitCanAttack("player", param)) then |
||
756 | value = "GB_HostileTargetBar"; |
||
757 | elseif (UnitIsPlayer(param) and UnitFactionGroup("player") ~= UnitFactionGroup(param)) then |
||
758 | value = "GB_HostileTargetBar"; |
||
759 | else |
||
760 | value = "GB_FriendlyTargetBar"; |
||
761 | end |
||
762 | end |
||
763 | elseif (param == "targettarget") then |
||
764 | if (UnitName(param)) then |
||
765 | if (UnitCanAttack("player", param)) then |
||
766 | value = "GB_HostileTargetBar"; |
||
767 | elseif (UnitIsPlayer(param) and UnitFactionGroup("player") ~= UnitFactionGroup(param)) then |
||
768 | value = "GB_HostileTargetBar"; |
||
769 | else |
||
770 | value = "GB_FriendlyTargetBar"; |
||
771 | end |
||
772 | end |
||
773 | elseif (param == "lowesthealth") then |
||
774 | value = "GB_LowestHealthBar"; |
||
775 | elseif (param == "hostiletarget") then |
||
776 | value = "GB_HostileTargetBar"; |
||
777 | elseif (param == "friendlytarget") then |
||
778 | value = "GB_FriendlyTargetBar"; |
||
779 | elseif (type(param) == "function") then |
||
780 | value = "GB_LowestHealthBar"; |
||
781 | elseif (string.find(param, "raid")) then |
||
782 | local _,_,raidnum = string.find(param, "raid(%d*)"); |
||
783 | value = "GB_RaidBar"..raidnum; |
||
784 | elseif (param == "pet") then |
||
785 | value = "GB_PetBar0"; |
||
786 | elseif (string.find(param, "partypet")) then |
||
787 | local _,_,petnum = string.find(param, "partypet(%d*)"); |
||
788 | value = "GB_PetBar"..petnum; |
||
789 | end |
||
790 | return value; |
||
791 | end |