vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Conditionals functions for FlexBar |
||
3 | Last Modified |
||
4 | 02/09/2005 Initial version |
||
5 | 08/16/2005 Added logic to handle non-visible creatures when determining creature type - Ratbert_CP |
||
6 | --]] |
||
7 | |||
8 | local util = Utility_Class:New() |
||
9 | local precedence = {["or<>"] = 1, ["and<>"] = 2, ["not<>"] = 3, ["begin<>"] = 4, ["end<>"] = 5} |
||
10 | local eval = Stack_Class:New() |
||
11 | local parse = Stack_Class:New() |
||
12 | |||
13 | |||
14 | function FB_CheckConditional(ifstr) |
||
15 | -- Function to evaluate the if= |
||
16 | local i |
||
17 | for i in ipairs(parse) do |
||
18 | parse[i] = nil |
||
19 | end |
||
20 | |||
21 | for i in ipairs(eval) do |
||
22 | eval[i] = nil |
||
23 | end |
||
24 | |||
25 | ifstr = string.gsub(ifstr,"\"","'") |
||
26 | local capture |
||
27 | _,_,capture = string.find(ifstr,"(%a+%b<>)") |
||
28 | if (ifstr == capture) then |
||
29 | -- A single condition |
||
30 | local firsti,lasti,capture2 = string.find(capture,"(%b<>)") |
||
31 | local target = string.sub(capture2,2,-2) |
||
32 | local iftarg |
||
33 | if target ~= "" then |
||
34 | target="iftarg=" .. target |
||
35 | iftarg=FBcmd:GetParameters(target)["iftarg"] |
||
36 | else |
||
37 | iftarg = nil |
||
38 | end |
||
39 | local condition = string.lower(string.sub(capture,1,firsti - 1)) |
||
40 | if FBConditions[condition] then |
||
41 | local dispatch = FBConditions[condition] |
||
42 | eval:Push(dispatch(iftarg)) |
||
43 | end |
||
44 | else |
||
45 | -- This one needs the parser |
||
46 | ifstr = string.gsub(ifstr,"not ","not<> ") |
||
47 | ifstr = string.gsub(ifstr,"and ","and<> ") |
||
48 | ifstr = string.gsub(ifstr,"or " ,"or<> " ) |
||
49 | ifstr = string.gsub(ifstr,"%(","begin<>") |
||
50 | ifstr = string.gsub(ifstr,"%)","end<>") |
||
51 | local capture |
||
52 | for capture in string.gfind(ifstr,"(%w+%b<>)") do |
||
53 | if not FB_IsOp(capture) then |
||
54 | local firsti,lasti,capture2 = string.find(capture,"(%b<>)") |
||
55 | local target = string.sub(capture2,2,-2) |
||
56 | local iftarg |
||
57 | if target ~= "" then |
||
58 | target="iftarg=" .. target |
||
59 | iftarg=FBcmd:GetParameters(target)["iftarg"] |
||
60 | else |
||
61 | iftarg = nil |
||
62 | end |
||
63 | local condition = string.lower(string.sub(capture,1,firsti - 1)) |
||
64 | if FBConditions[condition] then |
||
65 | local dispatch = FBConditions[condition] |
||
66 | eval:Push(dispatch(iftarg)) |
||
67 | end |
||
68 | else |
||
69 | while not parse:IsEmpty() and ((precedence[parse:Top()] > precedence[capture]) or capture=="end<>") do |
||
70 | local temp = parse:Pop() |
||
71 | if temp ~= "begin<>" then |
||
72 | if temp == "not<>" then |
||
73 | local value = eval:Pop() |
||
74 | eval:Push(not value) |
||
75 | elseif temp == "and<>" then |
||
76 | local value1 = eval:Pop() |
||
77 | local value2 = eval:Pop() |
||
78 | eval:Push(value1 and value2) |
||
79 | elseif temp == "or<>" then |
||
80 | local value1 = eval:Pop() |
||
81 | local value2 = eval:Pop() |
||
82 | eval:Push(value1 or value2) |
||
83 | end |
||
84 | end |
||
85 | end |
||
86 | if capture ~= "end<>" then parse:Push(capture) end |
||
87 | end |
||
88 | end |
||
89 | while not parse:IsEmpty() do |
||
90 | local temp = parse:Pop() |
||
91 | if temp ~= "begin<>" then |
||
92 | if temp == "not<>" then |
||
93 | local value = eval:Pop() |
||
94 | eval:Push(not value) |
||
95 | elseif temp == "and<>" then |
||
96 | local value1 = eval:Pop() |
||
97 | local value2 = eval:Pop() |
||
98 | eval:Push(value1 and value2) |
||
99 | elseif temp == "or<>" then |
||
100 | local value1 = eval:Pop() |
||
101 | local value2 = eval:Pop() |
||
102 | eval:Push(value1 or value2) |
||
103 | end |
||
104 | end |
||
105 | end |
||
106 | end |
||
107 | return eval:Top() |
||
108 | end |
||
109 | |||
110 | function FB_IsOp(text) |
||
111 | -- check for an operator |
||
112 | if text=="not<>" or text=="or<>" or text=="and<>" or text=="begin<>" or text=="end<>" then |
||
113 | return true |
||
114 | else |
||
115 | return false |
||
116 | end |
||
117 | end |
||
118 | |||
119 | -- Functions to evaluate conditions |
||
120 | |||
121 | -- conditional for hidden |
||
122 | -- if the target is a number - check for the button being hidden |
||
123 | -- if the target is a string, see if there is a global frame of that |
||
124 | -- name and return its hidden state |
||
125 | FBConditions["hidden"] = |
||
126 | function(target) |
||
127 | if not target then return false end |
||
128 | if type(target) ~= "table" then |
||
129 | target = { target } |
||
130 | end |
||
131 | |||
132 | local index, value |
||
133 | for index, value in pairs(target) do |
||
134 | if type(value) == "number" then |
||
135 | local frame, button = FB_GetWidgets(value) |
||
136 | if not frame:IsVisible() then |
||
137 | return true |
||
138 | end |
||
139 | elseif type(value) == "string" then |
||
140 | local frame = getglobal(value) |
||
141 | if frame and not frame:IsVisible() then |
||
142 | return true |
||
143 | end |
||
144 | end |
||
145 | end |
||
146 | return false |
||
147 | end |
||
148 | |||
149 | -- conditional for visible - put in because doing: |
||
150 | -- not hidden<[]> indicates that they are all visible |
||
151 | -- visible<[]> means one of the items is visible |
||
152 | -- if the target is a number - check for the button being visible |
||
153 | -- if the target is a string, see if there is a global frame of that |
||
154 | -- name and return its visible state |
||
155 | FBConditions["visible"] = |
||
156 | function(target) |
||
157 | if not target then return false end |
||
158 | if type(target) ~= "table" then |
||
159 | target = { target } |
||
160 | end |
||
161 | |||
162 | local index, value |
||
163 | for index, value in pairs(target) do |
||
164 | if type(value) == "number" then |
||
165 | local frame, button = FB_GetWidgets(value) |
||
166 | if frame:IsVisible() then |
||
167 | return true |
||
168 | end |
||
169 | elseif type(value) == "string" then |
||
170 | local frame = getglobal(value) |
||
171 | if frame and frame:IsVisible() then |
||
172 | return true |
||
173 | end |
||
174 | end |
||
175 | end |
||
176 | return false |
||
177 | end |
||
178 | |||
179 | -- conditional for remaped |
||
180 | FBConditions["remapped"] = |
||
181 | function(target) |
||
182 | if not target then return false end |
||
183 | if type(target) ~= "table" then |
||
184 | target = { target } |
||
185 | end |
||
186 | |||
187 | local index, value |
||
188 | for index, value in pairs(target) do |
||
189 | if type(value) == "number" then |
||
190 | if FBState[value]["remap"] then |
||
191 | return true |
||
192 | end |
||
193 | end |
||
194 | end |
||
195 | return false |
||
196 | end |
||
197 | |||
198 | -- conditional for shaded |
||
199 | FBConditions["shaded"] = |
||
200 | function(target) |
||
201 | if not target then return false end |
||
202 | if type(target) ~= "table" then |
||
203 | target = { target } |
||
204 | end |
||
205 | |||
206 | local index, value |
||
207 | for index, value in pairs(target) do |
||
208 | if type(value) == "number" then |
||
209 | if FBState[value]["icon"] then |
||
210 | return true |
||
211 | end |
||
212 | end |
||
213 | end |
||
214 | return false |
||
215 | end |
||
216 | |||
217 | -- conditional for faded |
||
218 | FBConditions["faded"] = |
||
219 | function(target) |
||
220 | if not target then return false end |
||
221 | if type(target) ~= "table" then |
||
222 | target = { target } |
||
223 | end |
||
224 | |||
225 | local index, value |
||
226 | for index, value in pairs(target) do |
||
227 | if type(value) == "number" then |
||
228 | if FBState[value]["alpha"] and FBState[value]["alpha"] ~= 10 then |
||
229 | return true |
||
230 | end |
||
231 | end |
||
232 | end |
||
233 | return false |
||
234 | end |
||
235 | |||
236 | -- conditional for scale |
||
237 | FBConditions["scaled"] = |
||
238 | function(target) |
||
239 | if not target then return false end |
||
240 | if type(target) ~= "table" then |
||
241 | target = { target } |
||
242 | end |
||
243 | |||
244 | local index, value |
||
245 | for index, value in pairs(target) do |
||
246 | if type(value) == "number" then |
||
247 | if FBState[value]["scale"] and FBState[value]["scale"] ~= 10 then |
||
248 | return true |
||
249 | end |
||
250 | end |
||
251 | end |
||
252 | return false |
||
253 | end |
||
254 | |||
255 | -- conditional for enoughmana |
||
256 | FBConditions["enoughmana"] = |
||
257 | function(target) |
||
258 | if not target then return false end |
||
259 | if type(target) ~= "table" then |
||
260 | target = { target } |
||
261 | end |
||
262 | |||
263 | local index, value |
||
264 | for index, value in pairs(target) do |
||
265 | if type(value) == "number" then |
||
266 | local button = FB_GetWidgets(value) |
||
267 | local isUsable, notEnoughMana = IsUsableAction(button:GetID()); |
||
268 | if not notEnoughMana then |
||
269 | return true |
||
270 | end |
||
271 | end |
||
272 | end |
||
273 | return false |
||
274 | end |
||
275 | |||
276 | -- conditional for usable |
||
277 | FBConditions["usable"] = |
||
278 | function(target) |
||
279 | if not target then return false end |
||
280 | if type(target) ~= "table" then |
||
281 | target = { target } |
||
282 | end |
||
283 | |||
284 | local index, value |
||
285 | for index, value in pairs(target) do |
||
286 | if type(value) == "number" then |
||
287 | local button = FB_GetWidgets(value) |
||
288 | local isUsable, enoughMana = IsUsableAction(button:GetID()); |
||
289 | if isUsable then |
||
290 | return true |
||
291 | end |
||
292 | end |
||
293 | end |
||
294 | return false |
||
295 | end |
||
296 | |||
297 | -- conditional for inrange |
||
298 | FBConditions["inrange"] = |
||
299 | function(target) |
||
300 | if not target then return false end |
||
301 | if type(target) ~= "table" then |
||
302 | target = { target } |
||
303 | end |
||
304 | |||
305 | local index, value |
||
306 | for index, value in pairs(target) do |
||
307 | if type(value) == "number" then |
||
308 | local button = FB_GetWidgets(value) |
||
309 | local inRange = IsActionInRange(button:GetID()); |
||
310 | if inRange ~= 0 then |
||
311 | return true |
||
312 | end |
||
313 | end |
||
314 | end |
||
315 | return false |
||
316 | end |
||
317 | |||
318 | -- conditional for incooldown |
||
319 | FBConditions["incooldown"] = |
||
320 | function(target) |
||
321 | if not target then return false end |
||
322 | if type(target) ~= "table" then |
||
323 | target = { target } |
||
324 | end |
||
325 | |||
326 | local index, value |
||
327 | for index, value in pairs(target) do |
||
328 | if type(value) == "number" then |
||
329 | local button = FB_GetWidgets(value) |
||
330 | local start = GetActionCooldown(button:GetID()); |
||
331 | if start ~= 0 then |
||
332 | return true |
||
333 | end |
||
334 | end |
||
335 | end |
||
336 | return false |
||
337 | end |
||
338 | |||
339 | -- conditional for isadvanced |
||
340 | FBConditions["isadvanced"] = |
||
341 | function(target) |
||
342 | if not target then return false end |
||
343 | if type(target) ~= "table" then |
||
344 | target = { target } |
||
345 | end |
||
346 | |||
347 | local index, value |
||
348 | for index, value in pairs(target) do |
||
349 | if type(value) == "number" then |
||
350 | if FBState[value]["advanced"] then |
||
351 | return true |
||
352 | end |
||
353 | end |
||
354 | end |
||
355 | return false |
||
356 | end |
||
357 | |||
358 | -- conditional for isdisabled |
||
359 | FBConditions["isdisabled"] = |
||
360 | function(target) |
||
361 | if not target then return false end |
||
362 | if type(target) ~= "table" then |
||
363 | target = { target } |
||
364 | end |
||
365 | |||
366 | local index, value |
||
367 | for index, value in pairs(target) do |
||
368 | if type(value) == "number" then |
||
369 | if FBState[value]["disabled"] then |
||
370 | return true |
||
371 | end |
||
372 | end |
||
373 | end |
||
374 | return false |
||
375 | end |
||
376 | |||
377 | -- conditional for unitexists |
||
378 | FBConditions["unitexists"] = |
||
379 | function(target) |
||
380 | if not target then return false end |
||
381 | if type(target) ~= "table" then |
||
382 | target = { target } |
||
383 | end |
||
384 | |||
385 | local index, value |
||
386 | for index, value in pairs(target) do |
||
387 | if type(value) == "string" then |
||
388 | value = string.lower(value) |
||
389 | if UnitExists(value) then |
||
390 | return true |
||
391 | end |
||
392 | end |
||
393 | end |
||
394 | return false |
||
395 | end |
||
396 | |||
397 | -- conditional for unitalive |
||
398 | FBConditions["unitisalive"] = |
||
399 | function(target) |
||
400 | if not target then return false end |
||
401 | if type(target) ~= "table" then |
||
402 | target = { target } |
||
403 | end |
||
404 | |||
405 | local index, value |
||
406 | for index, value in pairs(target) do |
||
407 | if type(value) == "string" then |
||
408 | value = string.lower(value) |
||
409 | if UnitExists(value) and not UnitIsDeadOrGhost(value) then |
||
410 | return true |
||
411 | end |
||
412 | end |
||
413 | end |
||
414 | return false |
||
415 | end |
||
416 | |||
417 | -- conditional for unitishostile |
||
418 | FBConditions["unitishostile"] = |
||
419 | function(target) |
||
420 | if not target then return false end |
||
421 | if type(target) ~= "table" then |
||
422 | target = { target } |
||
423 | end |
||
424 | |||
425 | local index, value |
||
426 | for index, value in pairs(target) do |
||
427 | if type(value) == "string" then |
||
428 | value = string.lower(value) |
||
429 | if UnitExists(value) and UnitIsEnemy("player",value) then |
||
430 | return true |
||
431 | end |
||
432 | end |
||
433 | end |
||
434 | return false |
||
435 | end |
||
436 | |||
437 | -- conditional for unitisfriendly |
||
438 | FBConditions["unitisfriendly"] = |
||
439 | function(target) |
||
440 | if not target then return false end |
||
441 | if type(target) ~= "table" then |
||
442 | target = { target } |
||
443 | end |
||
444 | |||
445 | local index, value |
||
446 | for index, value in pairs(target) do |
||
447 | if type(value) == "string" then |
||
448 | value = string.lower(value) |
||
449 | if UnitExists(value) and UnitIsFriend("player",value) then |
||
450 | return true |
||
451 | end |
||
452 | end |
||
453 | end |
||
454 | return false |
||
455 | end |
||
456 | |||
457 | -- conditional for unitisneutral |
||
458 | FBConditions["unitisneutral"] = |
||
459 | function(target) |
||
460 | if not target then return false end |
||
461 | if type(target) ~= "table" then |
||
462 | target = { target } |
||
463 | end |
||
464 | |||
465 | local index, value |
||
466 | for index, value in pairs(target) do |
||
467 | if type(value) == "string" then |
||
468 | value = string.lower(value) |
||
469 | if UnitExists(value) and not UnitIsEnemy("player",value) and not UnitIsFriend("player",value) then |
||
470 | return true |
||
471 | end |
||
472 | end |
||
473 | end |
||
474 | return false |
||
475 | end |
||
476 | |||
477 | |||
478 | -- conditional for unitiscorpse |
||
479 | FBConditions["unitiscorpse"] = |
||
480 | function(target) |
||
481 | if not target then return false end |
||
482 | if type(target) ~= "table" then |
||
483 | target = { target } |
||
484 | end |
||
485 | |||
486 | local index, value |
||
487 | for index, value in pairs(target) do |
||
488 | if type(value) == "string" then |
||
489 | value = string.lower(value) |
||
490 | if UnitExists(value) and UnitIsDeadOrGhost(value) then |
||
491 | return true |
||
492 | end |
||
493 | end |
||
494 | end |
||
495 | return false |
||
496 | end |
||
497 | |||
498 | -- conditional for unitistapped |
||
499 | FBConditions["unitistapped"] = |
||
500 | function(target) |
||
501 | if not target then return false end |
||
502 | if type(target) ~= "table" then |
||
503 | target = { target } |
||
504 | end |
||
505 | |||
506 | local index, value |
||
507 | for index, value in pairs(target) do |
||
508 | if type(value) == "string" then |
||
509 | value = string.lower(value) |
||
510 | if UnitExists(value) and UnitIsTapped(value) then |
||
511 | return true |
||
512 | end |
||
513 | end |
||
514 | end |
||
515 | return false |
||
516 | end |
||
517 | |||
518 | -- conditional for hasaura |
||
519 | FBConditions["hasaura"] = |
||
520 | function(target) |
||
521 | if not target then return false end |
||
522 | if type(target) ~= "table" then |
||
523 | target = { target } |
||
524 | end |
||
525 | |||
526 | local index, value |
||
527 | for index, value in pairs(target) do |
||
528 | if type(value) == "string" then |
||
529 | if string.lower(FBLastform) == string.lower(value) then |
||
530 | return true |
||
531 | end |
||
532 | end |
||
533 | end |
||
534 | return false |
||
535 | end |
||
536 | |||
537 | -- health conditionals |
||
538 | -- below 10% |
||
539 | FBConditions["healthbelow10"] = |
||
540 | function(target) |
||
541 | if not target then return false end |
||
542 | if type(target) ~= "table" then |
||
543 | target = { target } |
||
544 | end |
||
545 | |||
546 | local index, value |
||
547 | for index, value in pairs(target) do |
||
548 | if type(value) == "string" then |
||
549 | value = string.lower(value) |
||
550 | if UnitHealth(value)/UnitHealthMax(value) < .1 then |
||
551 | return true |
||
552 | end |
||
553 | end |
||
554 | end |
||
555 | return false |
||
556 | end |
||
557 | |||
558 | -- below 20% |
||
559 | FBConditions["healthbelow20"] = |
||
560 | function(target) |
||
561 | if not target then return false end |
||
562 | if type(target) ~= "table" then |
||
563 | target = { target } |
||
564 | end |
||
565 | |||
566 | local index, value |
||
567 | for index, value in pairs(target) do |
||
568 | if type(value) == "string" then |
||
569 | value = string.lower(value) |
||
570 | if UnitHealth(value)/UnitHealthMax(value) < .2 then |
||
571 | return true |
||
572 | end |
||
573 | end |
||
574 | end |
||
575 | return false |
||
576 | end |
||
577 | |||
578 | -- below 30% |
||
579 | FBConditions["healthbelow30"] = |
||
580 | function(target) |
||
581 | if not target then return false end |
||
582 | if type(target) ~= "table" then |
||
583 | target = { target } |
||
584 | end |
||
585 | |||
586 | local index, value |
||
587 | for index, value in pairs(target) do |
||
588 | if type(value) == "string" then |
||
589 | value = string.lower(value) |
||
590 | if UnitHealth(value)/UnitHealthMax(value) < .3 then |
||
591 | return true |
||
592 | end |
||
593 | end |
||
594 | end |
||
595 | return false |
||
596 | end |
||
597 | |||
598 | -- below 40% |
||
599 | FBConditions["healthbelow40"] = |
||
600 | function(target) |
||
601 | if not target then return false end |
||
602 | if type(target) ~= "table" then |
||
603 | target = { target } |
||
604 | end |
||
605 | |||
606 | local index, value |
||
607 | for index, value in pairs(target) do |
||
608 | if type(value) == "string" then |
||
609 | value = string.lower(value) |
||
610 | if UnitHealth(value)/UnitHealthMax(value) < .4 then |
||
611 | return true |
||
612 | end |
||
613 | end |
||
614 | end |
||
615 | return false |
||
616 | end |
||
617 | |||
618 | -- below 50% |
||
619 | FBConditions["healthbelow50"] = |
||
620 | function(target) |
||
621 | if not target then return false end |
||
622 | if type(target) ~= "table" then |
||
623 | target = { target } |
||
624 | end |
||
625 | |||
626 | local index, value |
||
627 | for index, value in pairs(target) do |
||
628 | if type(value) == "string" then |
||
629 | value = string.lower(value) |
||
630 | if UnitHealth(value)/UnitHealthMax(value) < .5 then |
||
631 | return true |
||
632 | end |
||
633 | end |
||
634 | end |
||
635 | return false |
||
636 | end |
||
637 | |||
638 | -- below 60% |
||
639 | FBConditions["healthbelow60"] = |
||
640 | function(target) |
||
641 | if not target then return false end |
||
642 | if type(target) ~= "table" then |
||
643 | target = { target } |
||
644 | end |
||
645 | |||
646 | local index, value |
||
647 | for index, value in pairs(target) do |
||
648 | if type(value) == "string" then |
||
649 | value = string.lower(value) |
||
650 | if UnitHealth(value)/UnitHealthMax(value) < .6 then |
||
651 | return true |
||
652 | end |
||
653 | end |
||
654 | end |
||
655 | return false |
||
656 | end |
||
657 | |||
658 | -- below 70% |
||
659 | FBConditions["healthbelow70"] = |
||
660 | function(target) |
||
661 | if not target then return false end |
||
662 | if type(target) ~= "table" then |
||
663 | target = { target } |
||
664 | end |
||
665 | |||
666 | local index, value |
||
667 | for index, value in pairs(target) do |
||
668 | if type(value) == "string" then |
||
669 | value = string.lower(value) |
||
670 | if UnitHealth(value)/UnitHealthMax(value) < .7 then |
||
671 | return true |
||
672 | end |
||
673 | end |
||
674 | end |
||
675 | return false |
||
676 | end |
||
677 | |||
678 | -- below 80% |
||
679 | FBConditions["healthbelow80"] = |
||
680 | function(target) |
||
681 | if not target then return false end |
||
682 | if type(target) ~= "table" then |
||
683 | target = { target } |
||
684 | end |
||
685 | |||
686 | local index, value |
||
687 | for index, value in pairs(target) do |
||
688 | if type(value) == "string" then |
||
689 | value = string.lower(value) |
||
690 | if UnitHealth(value)/UnitHealthMax(value) < .8 then |
||
691 | return true |
||
692 | end |
||
693 | end |
||
694 | end |
||
695 | return false |
||
696 | end |
||
697 | |||
698 | -- below 90% |
||
699 | FBConditions["healthbelow90"] = |
||
700 | function(target) |
||
701 | if not target then return false end |
||
702 | if type(target) ~= "table" then |
||
703 | target = { target } |
||
704 | end |
||
705 | |||
706 | local index, value |
||
707 | for index, value in pairs(target) do |
||
708 | if type(value) == "string" then |
||
709 | value = string.lower(value) |
||
710 | if UnitHealth(value)/UnitHealthMax(value) < .9 then |
||
711 | return true |
||
712 | end |
||
713 | end |
||
714 | end |
||
715 | return false |
||
716 | end |
||
717 | |||
718 | -- below 100% |
||
719 | FBConditions["healthbelow100"] = |
||
720 | function(target) |
||
721 | if not target then return false end |
||
722 | if type(target) ~= "table" then |
||
723 | target = { target } |
||
724 | end |
||
725 | |||
726 | local index, value |
||
727 | for index, value in pairs(target) do |
||
728 | if type(value) == "string" then |
||
729 | value = string.lower(value) |
||
730 | if UnitHealth(value)/UnitHealthMax(value) < 1 then |
||
731 | return true |
||
732 | end |
||
733 | end |
||
734 | end |
||
735 | return false |
||
736 | end |
||
737 | |||
738 | -- above 10% |
||
739 | FBConditions["healthabove10"] = |
||
740 | function(target) |
||
741 | if not target then return false end |
||
742 | if type(target) ~= "table" then |
||
743 | target = { target } |
||
744 | end |
||
745 | |||
746 | local index, value |
||
747 | for index, value in pairs(target) do |
||
748 | if type(value) == "string" then |
||
749 | value = string.lower(value) |
||
750 | if UnitHealth(value)/UnitHealthMax(value) > .1 then |
||
751 | return true |
||
752 | end |
||
753 | end |
||
754 | end |
||
755 | return false |
||
756 | end |
||
757 | |||
758 | -- above 20% |
||
759 | FBConditions["healthabove20"] = |
||
760 | function(target) |
||
761 | if not target then return false end |
||
762 | if type(target) ~= "table" then |
||
763 | target = { target } |
||
764 | end |
||
765 | |||
766 | local index, value |
||
767 | for index, value in pairs(target) do |
||
768 | if type(value) == "string" then |
||
769 | value = string.lower(value) |
||
770 | if UnitHealth(value)/UnitHealthMax(value) > .2 then |
||
771 | return true |
||
772 | end |
||
773 | end |
||
774 | end |
||
775 | return false |
||
776 | end |
||
777 | |||
778 | -- above 30% |
||
779 | FBConditions["healthabove30"] = |
||
780 | function(target) |
||
781 | if not target then return false end |
||
782 | if type(target) ~= "table" then |
||
783 | target = { target } |
||
784 | end |
||
785 | |||
786 | local index, value |
||
787 | for index, value in pairs(target) do |
||
788 | if type(value) == "string" then |
||
789 | value = string.lower(value) |
||
790 | if UnitHealth(value)/UnitHealthMax(value) > .3 then |
||
791 | return true |
||
792 | end |
||
793 | end |
||
794 | end |
||
795 | return false |
||
796 | end |
||
797 | |||
798 | -- above 40% |
||
799 | FBConditions["healthabove40"] = |
||
800 | function(target) |
||
801 | if not target then return false end |
||
802 | if type(target) ~= "table" then |
||
803 | target = { target } |
||
804 | end |
||
805 | |||
806 | local index, value |
||
807 | for index, value in pairs(target) do |
||
808 | if type(value) == "string" then |
||
809 | value = string.lower(value) |
||
810 | if UnitHealth(value)/UnitHealthMax(value) > .4 then |
||
811 | return true |
||
812 | end |
||
813 | end |
||
814 | end |
||
815 | return false |
||
816 | end |
||
817 | |||
818 | -- above 50% |
||
819 | FBConditions["healthabove50"] = |
||
820 | function(target) |
||
821 | if not target then return false end |
||
822 | if type(target) ~= "table" then |
||
823 | target = { target } |
||
824 | end |
||
825 | |||
826 | local index, value |
||
827 | for index, value in pairs(target) do |
||
828 | if type(value) == "string" then |
||
829 | value = string.lower(value) |
||
830 | if UnitHealth(value)/UnitHealthMax(value) > .5 then |
||
831 | return true |
||
832 | end |
||
833 | end |
||
834 | end |
||
835 | return false |
||
836 | end |
||
837 | |||
838 | -- above 60% |
||
839 | FBConditions["healthabove60"] = |
||
840 | function(target) |
||
841 | if not target then return false end |
||
842 | if type(target) ~= "table" then |
||
843 | target = { target } |
||
844 | end |
||
845 | |||
846 | local index, value |
||
847 | for index, value in pairs(target) do |
||
848 | if type(value) == "string" then |
||
849 | if UnitHealth(value)/UnitHealthMax(value) > .6 then |
||
850 | return true |
||
851 | end |
||
852 | end |
||
853 | end |
||
854 | return false |
||
855 | end |
||
856 | |||
857 | -- above 70% |
||
858 | FBConditions["healthabove70"] = |
||
859 | function(target) |
||
860 | if not target then return false end |
||
861 | if type(target) ~= "table" then |
||
862 | target = { target } |
||
863 | end |
||
864 | |||
865 | local index, value |
||
866 | for index, value in pairs(target) do |
||
867 | if type(value) == "string" then |
||
868 | value = string.lower(value) |
||
869 | if UnitHealth(value)/UnitHealthMax(value) > .7 then |
||
870 | return true |
||
871 | end |
||
872 | end |
||
873 | end |
||
874 | return false |
||
875 | end |
||
876 | |||
877 | -- above 80% |
||
878 | FBConditions["healthabove80"] = |
||
879 | function(target) |
||
880 | if not target then return false end |
||
881 | if type(target) ~= "table" then |
||
882 | target = { target } |
||
883 | end |
||
884 | |||
885 | local index, value |
||
886 | for index, value in pairs(target) do |
||
887 | if type(value) == "string" then |
||
888 | value = string.lower(value) |
||
889 | if UnitHealth(value)/UnitHealthMax(value) > .8 then |
||
890 | return true |
||
891 | end |
||
892 | end |
||
893 | end |
||
894 | return false |
||
895 | end |
||
896 | |||
897 | -- above 90% |
||
898 | FBConditions["healthabove90"] = |
||
899 | function(target) |
||
900 | if not target then return false end |
||
901 | if type(target) ~= "table" then |
||
902 | target = { target } |
||
903 | end |
||
904 | |||
905 | local index, value |
||
906 | for index, value in pairs(target) do |
||
907 | if type(value) == "string" then |
||
908 | value = string.lower(value) |
||
909 | if UnitHealth(value)/UnitHealthMax(value) > .9 then |
||
910 | return true |
||
911 | end |
||
912 | end |
||
913 | end |
||
914 | return false |
||
915 | end |
||
916 | |||
917 | -- full |
||
918 | FBConditions["healthfull"] = |
||
919 | function(target) |
||
920 | if not target then return false end |
||
921 | if type(target) ~= "table" then |
||
922 | target = { target } |
||
923 | end |
||
924 | |||
925 | local index, value |
||
926 | for index, value in pairs(target) do |
||
927 | if type(value) == "string" then |
||
928 | value = string.lower(value) |
||
929 | if UnitHealth(value)/UnitHealthMax(value) > .99 then |
||
930 | return true |
||
931 | end |
||
932 | end |
||
933 | end |
||
934 | return false |
||
935 | end |
||
936 | |||
937 | |||
938 | -- mana conditionals |
||
939 | -- below 10% |
||
940 | FBConditions["manabelow10"] = |
||
941 | function(target) |
||
942 | if not target then return false end |
||
943 | if type(target) ~= "table" then |
||
944 | target = { target } |
||
945 | end |
||
946 | |||
947 | local index, value |
||
948 | for index, value in pairs(target) do |
||
949 | if type(value) == "string" then |
||
950 | value = string.lower(value) |
||
951 | if UnitMana(value)/UnitManaMax(value) < .1 then |
||
952 | return true |
||
953 | end |
||
954 | end |
||
955 | end |
||
956 | return false |
||
957 | end |
||
958 | |||
959 | -- below 20% |
||
960 | FBConditions["manabelow20"] = |
||
961 | function(target) |
||
962 | if not target then return false end |
||
963 | if type(target) ~= "table" then |
||
964 | target = { target } |
||
965 | end |
||
966 | |||
967 | local index, value |
||
968 | for index, value in pairs(target) do |
||
969 | if type(value) == "string" then |
||
970 | value = string.lower(value) |
||
971 | if UnitMana(value)/UnitManaMax(value) < .2 then |
||
972 | return true |
||
973 | end |
||
974 | end |
||
975 | end |
||
976 | return false |
||
977 | end |
||
978 | |||
979 | -- below 30% |
||
980 | FBConditions["manabelow30"] = |
||
981 | function(target) |
||
982 | if not target then return false end |
||
983 | if type(target) ~= "table" then |
||
984 | target = { target } |
||
985 | end |
||
986 | |||
987 | local index, value |
||
988 | for index, value in pairs(target) do |
||
989 | if type(value) == "string" then |
||
990 | value = string.lower(value) |
||
991 | if UnitMana(value)/UnitManaMax(value) < .3 then |
||
992 | return true |
||
993 | end |
||
994 | end |
||
995 | end |
||
996 | return false |
||
997 | end |
||
998 | |||
999 | -- below 40% |
||
1000 | FBConditions["manabelow40"] = |
||
1001 | function(target) |
||
1002 | if not target then return false end |
||
1003 | if type(target) ~= "table" then |
||
1004 | target = { target } |
||
1005 | end |
||
1006 | |||
1007 | local index, value |
||
1008 | for index, value in pairs(target) do |
||
1009 | if type(value) == "string" then |
||
1010 | value = string.lower(value) |
||
1011 | if UnitMana(value)/UnitManaMax(value) < .4 then |
||
1012 | return true |
||
1013 | end |
||
1014 | end |
||
1015 | end |
||
1016 | return false |
||
1017 | end |
||
1018 | |||
1019 | -- below 50% |
||
1020 | FBConditions["manabelow50"] = |
||
1021 | function(target) |
||
1022 | if not target then return false end |
||
1023 | if type(target) ~= "table" then |
||
1024 | target = { target } |
||
1025 | end |
||
1026 | |||
1027 | local index, value |
||
1028 | for index, value in pairs(target) do |
||
1029 | if type(value) == "string" then |
||
1030 | value = string.lower(value) |
||
1031 | if UnitMana(value)/UnitManaMax(value) < .5 then |
||
1032 | return true |
||
1033 | end |
||
1034 | end |
||
1035 | end |
||
1036 | return false |
||
1037 | end |
||
1038 | |||
1039 | -- below 60% |
||
1040 | FBConditions["manabelow60"] = |
||
1041 | function(target) |
||
1042 | if not target then return false end |
||
1043 | if type(target) ~= "table" then |
||
1044 | target = { target } |
||
1045 | end |
||
1046 | |||
1047 | local index, value |
||
1048 | for index, value in pairs(target) do |
||
1049 | if type(value) == "string" then |
||
1050 | value = string.lower(value) |
||
1051 | if UnitMana(value)/UnitManaMax(value) < .6 then |
||
1052 | return true |
||
1053 | end |
||
1054 | end |
||
1055 | end |
||
1056 | return false |
||
1057 | end |
||
1058 | |||
1059 | -- below 70% |
||
1060 | FBConditions["manabelow70"] = |
||
1061 | function(target) |
||
1062 | if not target then return false end |
||
1063 | if type(target) ~= "table" then |
||
1064 | target = { target } |
||
1065 | end |
||
1066 | |||
1067 | local index, value |
||
1068 | for index, value in pairs(target) do |
||
1069 | if type(value) == "string" then |
||
1070 | value = string.lower(value) |
||
1071 | if UnitMana(value)/UnitManaMax(value) < .7 then |
||
1072 | return true |
||
1073 | end |
||
1074 | end |
||
1075 | end |
||
1076 | return false |
||
1077 | end |
||
1078 | |||
1079 | -- below 80% |
||
1080 | FBConditions["manabelow80"] = |
||
1081 | function(target) |
||
1082 | if not target then return false end |
||
1083 | if type(target) ~= "table" then |
||
1084 | target = { target } |
||
1085 | end |
||
1086 | |||
1087 | local index, value |
||
1088 | for index, value in pairs(target) do |
||
1089 | if type(value) == "string" then |
||
1090 | value = string.lower(value) |
||
1091 | if UnitMana(value)/UnitManaMax(value) < .8 then |
||
1092 | return true |
||
1093 | end |
||
1094 | end |
||
1095 | end |
||
1096 | return false |
||
1097 | end |
||
1098 | |||
1099 | -- below 90% |
||
1100 | FBConditions["manabelow90"] = |
||
1101 | function(target) |
||
1102 | if not target then return false end |
||
1103 | if type(target) ~= "table" then |
||
1104 | target = { target } |
||
1105 | end |
||
1106 | |||
1107 | local index, value |
||
1108 | for index, value in pairs(target) do |
||
1109 | if type(value) == "string" then |
||
1110 | value = string.lower(value) |
||
1111 | if UnitMana(value)/UnitManaMax(value) < .9 then |
||
1112 | return true |
||
1113 | end |
||
1114 | end |
||
1115 | end |
||
1116 | return false |
||
1117 | end |
||
1118 | |||
1119 | -- below 100% |
||
1120 | FBConditions["manabelow100"] = |
||
1121 | function(target) |
||
1122 | if not target then return false end |
||
1123 | if type(target) ~= "table" then |
||
1124 | target = { target } |
||
1125 | end |
||
1126 | |||
1127 | local index, value |
||
1128 | for index, value in pairs(target) do |
||
1129 | if type(value) == "string" then |
||
1130 | value = string.lower(value) |
||
1131 | if UnitMana(value)/UnitManaMax(value) < 1 then |
||
1132 | return true |
||
1133 | end |
||
1134 | end |
||
1135 | end |
||
1136 | return false |
||
1137 | end |
||
1138 | |||
1139 | -- above 10% |
||
1140 | FBConditions["manaabove10"] = |
||
1141 | function(target) |
||
1142 | if not target then return false end |
||
1143 | if type(target) ~= "table" then |
||
1144 | target = { target } |
||
1145 | end |
||
1146 | |||
1147 | local index, value |
||
1148 | for index, value in pairs(target) do |
||
1149 | if type(value) == "string" then |
||
1150 | value = string.lower(value) |
||
1151 | if UnitMana(value)/UnitManaMax(value) > .1 then |
||
1152 | return true |
||
1153 | end |
||
1154 | end |
||
1155 | end |
||
1156 | return false |
||
1157 | end |
||
1158 | |||
1159 | -- above 20% |
||
1160 | FBConditions["manaabove20"] = |
||
1161 | function(target) |
||
1162 | if not target then return false end |
||
1163 | if type(target) ~= "table" then |
||
1164 | target = { target } |
||
1165 | end |
||
1166 | |||
1167 | local index, value |
||
1168 | for index, value in pairs(target) do |
||
1169 | if type(value) == "string" then |
||
1170 | value = string.lower(value) |
||
1171 | if UnitMana(value)/UnitManaMax(value) > .2 then |
||
1172 | return true |
||
1173 | end |
||
1174 | end |
||
1175 | end |
||
1176 | return false |
||
1177 | end |
||
1178 | |||
1179 | -- above 30% |
||
1180 | FBConditions["manaabove30"] = |
||
1181 | function(target) |
||
1182 | if not target then return false end |
||
1183 | if type(target) ~= "table" then |
||
1184 | target = { target } |
||
1185 | end |
||
1186 | |||
1187 | local index, value |
||
1188 | for index, value in pairs(target) do |
||
1189 | if type(value) == "string" then |
||
1190 | value = string.lower(value) |
||
1191 | if UnitMana(value)/UnitManaMax(value) > .3 then |
||
1192 | return true |
||
1193 | end |
||
1194 | end |
||
1195 | end |
||
1196 | return false |
||
1197 | end |
||
1198 | |||
1199 | -- above 40% |
||
1200 | FBConditions["manaabove40"] = |
||
1201 | function(target) |
||
1202 | if not target then return false end |
||
1203 | if type(target) ~= "table" then |
||
1204 | target = { target } |
||
1205 | end |
||
1206 | |||
1207 | local index, value |
||
1208 | for index, value in pairs(target) do |
||
1209 | if type(value) == "string" then |
||
1210 | value = string.lower(value) |
||
1211 | if UnitMana(value)/UnitManaMax(value) > .4 then |
||
1212 | return true |
||
1213 | end |
||
1214 | end |
||
1215 | end |
||
1216 | return false |
||
1217 | end |
||
1218 | |||
1219 | -- above 50% |
||
1220 | FBConditions["manaabove50"] = |
||
1221 | function(target) |
||
1222 | if not target then return false end |
||
1223 | if type(target) ~= "table" then |
||
1224 | target = { target } |
||
1225 | end |
||
1226 | |||
1227 | local index, value |
||
1228 | for index, value in pairs(target) do |
||
1229 | if type(value) == "string" then |
||
1230 | value = string.lower(value) |
||
1231 | if UnitMana(value)/UnitManaMax(value) > .5 then |
||
1232 | return true |
||
1233 | end |
||
1234 | end |
||
1235 | end |
||
1236 | return false |
||
1237 | end |
||
1238 | |||
1239 | -- above 60% |
||
1240 | FBConditions["manaabove60"] = |
||
1241 | function(target) |
||
1242 | if not target then return false end |
||
1243 | if type(target) ~= "table" then |
||
1244 | target = { target } |
||
1245 | end |
||
1246 | |||
1247 | local index, value |
||
1248 | for index, value in pairs(target) do |
||
1249 | if type(value) == "string" then |
||
1250 | value = string.lower(value) |
||
1251 | if UnitMana(value)/UnitManaMax(value) > .6 then |
||
1252 | return true |
||
1253 | end |
||
1254 | end |
||
1255 | end |
||
1256 | return false |
||
1257 | end |
||
1258 | |||
1259 | -- above 70% |
||
1260 | FBConditions["manaabove70"] = |
||
1261 | function(target) |
||
1262 | if not target then return false end |
||
1263 | if type(target) ~= "table" then |
||
1264 | target = { target } |
||
1265 | end |
||
1266 | |||
1267 | local index, value |
||
1268 | for index, value in pairs(target) do |
||
1269 | if type(value) == "string" then |
||
1270 | value = string.lower(value) |
||
1271 | if UnitMana(value)/UnitManaMax(value) > .7 then |
||
1272 | return true |
||
1273 | end |
||
1274 | end |
||
1275 | end |
||
1276 | return false |
||
1277 | end |
||
1278 | |||
1279 | -- above 80% |
||
1280 | FBConditions["manaabove80"] = |
||
1281 | function(target) |
||
1282 | if not target then return false end |
||
1283 | if type(target) ~= "table" then |
||
1284 | target = { target } |
||
1285 | end |
||
1286 | |||
1287 | local index, value |
||
1288 | for index, value in pairs(target) do |
||
1289 | if type(value) == "string" then |
||
1290 | value = string.lower(value) |
||
1291 | if UnitMana(value)/UnitManaMax(value) > .8 then |
||
1292 | return true |
||
1293 | end |
||
1294 | end |
||
1295 | end |
||
1296 | return false |
||
1297 | end |
||
1298 | |||
1299 | -- above 90% |
||
1300 | FBConditions["manaabove90"] = |
||
1301 | function(target) |
||
1302 | if not target then return false end |
||
1303 | if type(target) ~= "table" then |
||
1304 | target = { target } |
||
1305 | end |
||
1306 | |||
1307 | local index, value |
||
1308 | for index, value in pairs(target) do |
||
1309 | if type(value) == "string" then |
||
1310 | value = string.lower(value) |
||
1311 | if UnitMana(value)/UnitManaMax(value) > .9 then |
||
1312 | return true |
||
1313 | end |
||
1314 | end |
||
1315 | end |
||
1316 | return false |
||
1317 | end |
||
1318 | |||
1319 | -- full |
||
1320 | FBConditions["manafull"] = |
||
1321 | function(target) |
||
1322 | if not target then return false end |
||
1323 | if type(target) ~= "table" then |
||
1324 | target = { target } |
||
1325 | end |
||
1326 | |||
1327 | local index, value |
||
1328 | for index, value in pairs(target) do |
||
1329 | if type(value) == "string" then |
||
1330 | value = string.lower(value) |
||
1331 | if UnitMana(value)/UnitManaMax(value) > .99 then |
||
1332 | return true |
||
1333 | end |
||
1334 | end |
||
1335 | end |
||
1336 | return false |
||
1337 | end |
||
1338 | |||
1339 | -- in combat |
||
1340 | FBConditions["incombat"] = |
||
1341 | function() |
||
1342 | if FBConditionalState["incombat"] then return true else return false end |
||
1343 | end |
||
1344 | |||
1345 | -- has aggro |
||
1346 | FBConditions["hasaggro"] = |
||
1347 | function() |
||
1348 | if FBConditionalState["hasaggro"] then return true else return false end |
||
1349 | end |
||
1350 | |||
1351 | -- shift down |
||
1352 | FBConditions["shiftdown"] = |
||
1353 | function() |
||
1354 | if IsShiftKeyDown() then return true else return false end |
||
1355 | end |
||
1356 | |||
1357 | -- control down |
||
1358 | FBConditions["controldown"] = |
||
1359 | function() |
||
1360 | if IsControlKeyDown() then return true else return false end |
||
1361 | end |
||
1362 | |||
1363 | -- alt down |
||
1364 | FBConditions["altdown"] = |
||
1365 | function() |
||
1366 | if IsAltKeyDown() then return true else return false end |
||
1367 | end |
||
1368 | |||
1369 | -- Is running (for timers such as on raise) |
||
1370 | FBConditions["isrunning"] = |
||
1371 | function(target) |
||
1372 | if not target then return false end |
||
1373 | if type(target) ~= "table" then |
||
1374 | target = { target } |
||
1375 | end |
||
1376 | |||
1377 | local index, value |
||
1378 | for index, value in pairs(target) do |
||
1379 | if type(value) == "string" then |
||
1380 | if FBTimers[value]:GetRunning() then |
||
1381 | return true |
||
1382 | end |
||
1383 | end |
||
1384 | end |
||
1385 | return false |
||
1386 | end |
||
1387 | |||
1388 | -- In group - is cursor in group bounds |
||
1389 | FBConditions["ingroup"] = |
||
1390 | function(target) |
||
1391 | if not target then return false end |
||
1392 | if type(target) ~= "table" then |
||
1393 | target = { target } |
||
1394 | end |
||
1395 | |||
1396 | local index, value |
||
1397 | for index, value in pairs(target) do |
||
1398 | if type(value) == "number" then |
||
1399 | local x,y = GetCursorPosition() |
||
1400 | if FB_InGroupBounds(value, x, y) then |
||
1401 | return true |
||
1402 | end |
||
1403 | end |
||
1404 | end |
||
1405 | return false |
||
1406 | end |
||
1407 | |||
1408 | -- check for custom condition - no target |
||
1409 | FBConditions["custom"] = |
||
1410 | function(target) |
||
1411 | if not target then return false end |
||
1412 | if type(target) ~= "table" then |
||
1413 | target = { target } |
||
1414 | end |
||
1415 | |||
1416 | local index, value |
||
1417 | for index, value in pairs(target) do |
||
1418 | if FBCustom[value] then return true end |
||
1419 | end |
||
1420 | return false |
||
1421 | end |
||
1422 | |||
1423 | -- check for buff existing |
||
1424 | FBConditions["hasbuff"] = |
||
1425 | function(target) |
||
1426 | if not target then return false end |
||
1427 | if type(target) ~= "table" then |
||
1428 | target = { target } |
||
1429 | end |
||
1430 | |||
1431 | if not FBLastBuffs["buffs"]["player"] then return false end |
||
1432 | |||
1433 | local index, value |
||
1434 | for index, value in pairs(target) do |
||
1435 | value = string.lower(value) |
||
1436 | if FBLastBuffs["buffs"]["player"][value] then |
||
1437 | return true |
||
1438 | end |
||
1439 | end |
||
1440 | return false |
||
1441 | end |
||
1442 | |||
1443 | -- check for debuff existing |
||
1444 | FBConditions["hasdebuff"] = |
||
1445 | function(target) |
||
1446 | if not target then return false end |
||
1447 | if type(target) ~= "table" then |
||
1448 | target = { target } |
||
1449 | end |
||
1450 | |||
1451 | |||
1452 | if not FBLastBuffs["debuffs"]["player"] then return false end |
||
1453 | |||
1454 | local index, value |
||
1455 | for index, value in pairs(target) do |
||
1456 | value = string.lower(value) |
||
1457 | if FBLastBuffs["debuffs"]["player"][value] then |
||
1458 | return true |
||
1459 | end |
||
1460 | end |
||
1461 | return false |
||
1462 | end |
||
1463 | |||
1464 | -- check for debufftype existing |
||
1465 | FBConditions["hasdebufftype"] = |
||
1466 | function(target) |
||
1467 | if not target then return false end |
||
1468 | if type(target) ~= "table" then |
||
1469 | target = { target } |
||
1470 | end |
||
1471 | |||
1472 | |||
1473 | if not FBLastBuffs["buffs"]["player"] then return false end |
||
1474 | |||
1475 | local index, value |
||
1476 | for index, value in pairs(target) do |
||
1477 | value = string.lower(value) |
||
1478 | if FBLastBuffs["debufftypes"]["player"][value] then |
||
1479 | return true |
||
1480 | end |
||
1481 | end |
||
1482 | return false |
||
1483 | end |
||
1484 | |||
1485 | -- unit version takes unit, buff list |
||
1486 | FBConditions["unitbuff"] = |
||
1487 | function(target) |
||
1488 | if not target then return false end |
||
1489 | if type(target) ~= "table" then |
||
1490 | return false |
||
1491 | end |
||
1492 | |||
1493 | local i=1 |
||
1494 | while target[i] do |
||
1495 | target[i] = string.lower(target[i]) |
||
1496 | i=i+1 |
||
1497 | end |
||
1498 | |||
1499 | if not FBLastBuffs["buffs"][target[1]] then return false end |
||
1500 | |||
1501 | local index = 2 |
||
1502 | while target[index] do |
||
1503 | if FBLastBuffs["buffs"][target[1]][target[index]] then |
||
1504 | return true |
||
1505 | end |
||
1506 | index = index+1 |
||
1507 | end |
||
1508 | return false |
||
1509 | end |
||
1510 | |||
1511 | -- unit version takes unit, debuff list |
||
1512 | FBConditions["unitdebuff"] = |
||
1513 | function(target) |
||
1514 | if not target then return false end |
||
1515 | if type(target) ~= "table" then |
||
1516 | return false |
||
1517 | end |
||
1518 | |||
1519 | local i=1 |
||
1520 | while target[i] do |
||
1521 | target[i] = string.lower(target[i]) |
||
1522 | i=i+1 |
||
1523 | end |
||
1524 | |||
1525 | if not FBLastBuffs["debuffs"][target[1]] then return false end |
||
1526 | |||
1527 | local index = 2 |
||
1528 | while target[index] do |
||
1529 | if FBLastBuffs["debuffs"][target[1]][target[index]] then |
||
1530 | return true |
||
1531 | end |
||
1532 | index = index+1 |
||
1533 | end |
||
1534 | return false |
||
1535 | end |
||
1536 | |||
1537 | -- unit version takes unit, debufftype list |
||
1538 | FBConditions["unitdebufftype"] = |
||
1539 | function(target) |
||
1540 | if not target then return false end |
||
1541 | if type(target) ~= "table" then |
||
1542 | return false |
||
1543 | end |
||
1544 | |||
1545 | local i=1 |
||
1546 | while target[i] do |
||
1547 | target[i] = string.lower(target[i]) |
||
1548 | i=i+1 |
||
1549 | end |
||
1550 | |||
1551 | if not FBLastBuffs["debufftypes"][target[1]] then return false end |
||
1552 | |||
1553 | local index = 2 |
||
1554 | while target[index] do |
||
1555 | if FBLastBuffs["debufftypes"][target[1]][target[index]] then |
||
1556 | return true |
||
1557 | end |
||
1558 | index = index+1 |
||
1559 | end |
||
1560 | |||
1561 | return false |
||
1562 | end |
||
1563 | |||
1564 | FBConditions["unitcreaturetype"] = |
||
1565 | function(target) |
||
1566 | if not target then return false end |
||
1567 | if type(target) ~= "table" then |
||
1568 | return false |
||
1569 | end |
||
1570 | |||
1571 | local i=1 |
||
1572 | while target[i] do |
||
1573 | target[i] = string.lower(target[i]) |
||
1574 | i=i+1 |
||
1575 | end |
||
1576 | |||
1577 | -- Validate UnitCreatureType and UnitExists |
||
1578 | -- If you target a non-visible creature, the unitcreaturetype conditional will fail |
||
1579 | -- I think (untested as of 8/16/2005) that when the target becomes visible, another PLAYER_TARGET_CHANGED |
||
1580 | -- event will fire, causing a new GainTarget event, thereby updating the creature type. |
||
1581 | local targetType |
||
1582 | if not UnitExists(target[1]) then |
||
1583 | return false |
||
1584 | else |
||
1585 | targetType = UnitCreatureType(target[1]) |
||
1586 | if targetType == nil then return false end |
||
1587 | targetType = string.lower(targetType) |
||
1588 | end |
||
1589 | |||
1590 | local index = 2 |
||
1591 | while target[index] do |
||
1592 | if targetType == target[index] then return true end |
||
1593 | index = index+1 |
||
1594 | end |
||
1595 | return false |
||
1596 | end |
||
1597 | |||
1598 | FBConditions["unitclass"] = |
||
1599 | function(target) |
||
1600 | -- returns true if the first element in target is any of the classes specified in the following elements |
||
1601 | if not target then return false end |
||
1602 | if type(target) ~= "table" then |
||
1603 | return false |
||
1604 | end |
||
1605 | |||
1606 | local i=1 |
||
1607 | while target[i] do |
||
1608 | target[i] = string.lower(target[i]) |
||
1609 | i=i+1 |
||
1610 | end |
||
1611 | |||
1612 | if not UnitExists(target[1]) then return false end |
||
1613 | |||
1614 | local index = 2 |
||
1615 | while target[index] do |
||
1616 | if string.lower(UnitClass(target[1])) == target[index] then return true end |
||
1617 | index = index+1 |
||
1618 | end |
||
1619 | return false |
||
1620 | end |
||
1621 | |||
1622 | local list = { "player","pet","party1","party2","party3","party4","partypet1","partypet2","partypet3","partypet4" } |
||
1623 | FBConditions["partydebufftype"] = |
||
1624 | function(target) |
||
1625 | -- returns true if any of the party have one of the specified debufftypes |
||
1626 | if not target then return false end |
||
1627 | if type(target) ~= "table" then |
||
1628 | return false |
||
1629 | end |
||
1630 | |||
1631 | local i=1 |
||
1632 | while target[i] do |
||
1633 | target[i] = string.lower(target[i]) |
||
1634 | i=i+1 |
||
1635 | end |
||
1636 | |||
1637 | local index = 1 |
||
1638 | while target[index] do |
||
1639 | for i, unit in ipairs(list) do |
||
1640 | if UnitExists(unit) and FBLastBuffs["debufftypes"][unit][target[index]] then |
||
1641 | return true |
||
1642 | end |
||
1643 | end |
||
1644 | index = index+1 |
||
1645 | end |
||
1646 | return false |
||
1647 | end |
||
1648 | |||
1649 | -- Check for having an main hand item enchantment |
||
1650 | FBConditions["mainhandenchant"] = |
||
1651 | function(target) |
||
1652 | local hasMainHandEnchant, mainHandExpiration, mainHandCharges, |
||
1653 | hasOffHandEnchant, offHandExpiration, offHandCharges = GetWeaponEnchantInfo() |
||
1654 | if hasMainHandEnchant then return true else return false end |
||
1655 | end |
||
1656 | |||
1657 | -- Check for Main hand charges equal to target |
||
1658 | FBConditions["mainhandchargeseq"] = |
||
1659 | function(target) |
||
1660 | if not target then return false end |
||
1661 | if type(target) ~= "number" then return false end |
||
1662 | local hasMainHandEnchant, mainHandExpiration, mainHandCharges, |
||
1663 | hasOffHandEnchant, offHandExpiration, offHandCharges = GetWeaponEnchantInfo() |
||
1664 | if not hasMainHandEnchant or mainHandCharges ~= target then return false else return true end |
||
1665 | end |
||
1666 | |||
1667 | -- Check for Main hand charges greater than target |
||
1668 | FBConditions["mainhandchargesgt"] = |
||
1669 | function(target) |
||
1670 | if not target then return false end |
||
1671 | if type(target) ~= "number" then return false end |
||
1672 | local hasMainHandEnchant, mainHandExpiration, mainHandCharges, |
||
1673 | hasOffHandEnchant, offHandExpiration, offHandCharges = GetWeaponEnchantInfo() |
||
1674 | if not hasMainHandEnchant or mainHandCharges <= target then return false else return true end |
||
1675 | end |
||
1676 | |||
1677 | -- Check for Main hand charges less than target |
||
1678 | FBConditions["mainhandchargeslt"] = |
||
1679 | function(target) |
||
1680 | if not target then return false end |
||
1681 | if type(target) ~= "number" then return false end |
||
1682 | local hasMainHandEnchant, mainHandExpiration, mainHandCharges, |
||
1683 | hasOffHandEnchant, offHandExpiration, offHandCharges = GetWeaponEnchantInfo() |
||
1684 | if not hasMainHandEnchant or mainHandCharges >= target then return false else return true end |
||
1685 | end |
||
1686 | |||
1687 | -- Check for having an off hand item enchantment |
||
1688 | FBConditions["offhandenchant"] = |
||
1689 | function(target) |
||
1690 | local hasMainHandEnchant, mainHandExpiration, mainHandCharges, |
||
1691 | hasOffHandEnchant, offHandExpiration, offHandCharges = GetWeaponEnchantInfo() |
||
1692 | if hasOffHandEnchant then return true else return false end |
||
1693 | end |
||
1694 | |||
1695 | -- Check for Off hand charges equal to target |
||
1696 | FBConditions["offhandchargeseq"] = |
||
1697 | function(target) |
||
1698 | if not target then return false end |
||
1699 | if type(target) ~= "number" then return false end |
||
1700 | local hasMainHandEnchant, mainHandExpiration, mainHandCharges, |
||
1701 | hasOffHandEnchant, offHandExpiration, offHandCharges = GetWeaponEnchantInfo() |
||
1702 | if not hasOffHandEnchant or OffHandCharges ~= target then return false else return true end |
||
1703 | end |
||
1704 | |||
1705 | -- Check for Off hand charges greater than target |
||
1706 | FBConditions["offhandchargesgt"] = |
||
1707 | function(target) |
||
1708 | if not target then return false end |
||
1709 | if type(target) ~= "number" then return false end |
||
1710 | local hasMainHandEnchant, mainHandExpiration, mainHandCharges, |
||
1711 | hasOffHandEnchant, offHandExpiration, offHandCharges = GetWeaponEnchantInfo() |
||
1712 | if not hasOffHandEnchant or offHandCharges <= target then return false else return true end |
||
1713 | end |
||
1714 | |||
1715 | -- Check for Off hand charges less than target |
||
1716 | FBConditions["offhandchargeslt"] = |
||
1717 | function(target) |
||
1718 | if not target then return false end |
||
1719 | if type(target) ~= "number" then return false end |
||
1720 | local hasMainHandEnchant, mainHandExpiration, mainHandCharges, |
||
1721 | hasOffHandEnchant, offHandExpiration, offHandCharges = GetWeaponEnchantInfo() |
||
1722 | if not hasOffHandEnchant or offHandCharges >= target then return false else return true end |
||
1723 | end |
||
1724 | |||
1725 | -- Check for Main hand charges equal to target |
||
1726 | FBConditions["mainhandchargeseq"] = |
||
1727 | function(target) |
||
1728 | if not target then return false end |
||
1729 | if type(target) ~= "number" then return false end |
||
1730 | local hasMainHandEnchant, mainHandExpiration, mainHandCharges, |
||
1731 | hasOffHandEnchant, offHandExpiration, offHandCharges = GetWeaponEnchantInfo() |
||
1732 | if not hasMainHandEnchant or mainHandCharges ~= target then return false else return true end |
||
1733 | end |
||
1734 | |||
1735 | -- Check for Main hand charges greater than target |
||
1736 | FBConditions["mainhandchargesgt"] = |
||
1737 | function(target) |
||
1738 | if not target then return false end |
||
1739 | if type(target) ~= "number" then return false end |
||
1740 | local hasMainHandEnchant, mainHandExpiration, mainHandCharges, |
||
1741 | hasOffHandEnchant, offHandExpiration, offHandCharges = GetWeaponEnchantInfo() |
||
1742 | if not hasMainHandEnchant or mainHandCharges <= target then return false else return true end |
||
1743 | end |
||
1744 | |||
1745 | -- Check for having item |
||
1746 | FBConditions["hasitem"] = |
||
1747 | function(target) |
||
1748 | if not target then return false end |
||
1749 | if type(target) ~= "table" then |
||
1750 | target = { target } |
||
1751 | end |
||
1752 | |||
1753 | local index, value |
||
1754 | for index, value in pairs(target) do |
||
1755 | value = string.lower(value) |
||
1756 | if FBBagContents[value] then return true end |
||
1757 | end |
||
1758 | return false |
||
1759 | end |
||
1760 | |||
1761 | -- Check for Affecting Combat |
||
1762 | FBConditions["affectingcombat"] = |
||
1763 | function(target) |
||
1764 | if not target then return false end |
||
1765 | if type(target) ~= "table" then |
||
1766 | target = { target } |
||
1767 | end |
||
1768 | |||
1769 | local index, value |
||
1770 | for index, value in pairs(target) do |
||
1771 | value = string.lower(value) |
||
1772 | if UnitAffectingCombat(value) then return true end |
||
1773 | end |
||
1774 | return false |
||
1775 | end |
||
1776 | |||
1777 | -- Check for Combo Point equal to target |
||
1778 | FBConditions["comboptseq"] = |
||
1779 | function(target) |
||
1780 | if not target then return false end |
||
1781 | if type(target) ~= "number" then return false end |
||
1782 | |||
1783 | if GetComboPoints() == target then return true else return false end |
||
1784 | end |
||
1785 | |||
1786 | -- Check for Combo Point lessthan to target |
||
1787 | FBConditions["comboptslt"] = |
||
1788 | function(target) |
||
1789 | if not target then return false end |
||
1790 | if type(target) ~= "number" then return false end |
||
1791 | |||
1792 | if GetComboPoints() < target then return true else return false end |
||
1793 | end |
||
1794 | |||
1795 | -- Check for Combo Point greater than to target |
||
1796 | FBConditions["comboptsgt"] = |
||
1797 | function(target) |
||
1798 | if not target then return false end |
||
1799 | if type(target) ~= "number" then return false end |
||
1800 | |||
1801 | if GetComboPoints() > target then return true else return false end |
||
1802 | end |
||
1803 | |||
1804 | FBConditions["true"] = function() return true end |
||
1805 | FBConditions["false"] = function() return false end |