-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPowerAurasAuraClasses.lua
2596 lines (2301 loc) · 89.6 KB
/
PowerAurasAuraClasses.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
------------cPowaAura----------------
-- cPowaAura is the base class and is not instanced directly, the other classes inherit properties and methods from it
--===========================
cPowaAura = PowaClass(function(aura, id, base)
--PowaAuras:ShowText("cPowaAura constructor id=", id, " base=", base);
aura.off = false;
aura.Debug = nil;
aura.bufftype = PowaAuras.BuffTypes.Buff;
aura.buffname = "";
aura.texmode = 1;
aura.wowtex = false;
aura.customtex = false;
aura.textaura = false;
aura.owntex = false;
aura.realaura = 1;
aura.texture = 1;
aura.customname = "";
aura.aurastext = "";
aura.aurastextfont = 1;
aura.icon = "";
aura.timerduration = 0;
-- Sound Settings
aura.sound = 0;
aura.customsound = "";
aura.soundend = 0;
aura.customsoundend = "";
-- Animation Settings
aura.begin = 0;
aura.anim1 = 1;
aura.anim2 = 0;
aura.speed = 1.00;
aura.finish = 1;
aura.isSecondary = false;
aura.beginSpin = false;
aura.duration = 0;
-- Appearance Settings
aura.alpha = 0.75;
aura.size = 0.75;
aura.torsion = 1;
aura.symetrie = 0;
aura.x = 0;
aura.y = -30;
aura.randomcolor = false;
aura.r = 1.0;
aura.g = 1.0;
aura.b = 1.0;
aura.inverse = false;
aura.ignoremaj = true;
aura.exact = false;
aura.stacks = 0;
aura.stacksLower = 0;
aura.stacksOperator = PowaAuras.DefaultOperator;
aura.threshold = 50;
aura.thresholdinvert = false;
aura.mine = false;
aura.focus = false;
aura.target = false;
aura.targetfriend = false;
aura.raid = false;
aura.groupOrSelf = false;
aura.party = false;
aura.groupany = true;
aura.optunitn = false;
aura.unitn = "";
aura.inRaid = 0;
aura.inParty = 0;
aura.ismounted = false;
aura.isResting = false;
aura.inVehicle = false;
aura.combat = 0;
aura.isAlive = true;
aura.PvP = 0;
aura.Instance5Man = 0;
aura.Instance5ManHeroic = 0;
aura.Instance10Man = 0;
aura.Instance10ManHeroic = 0;
aura.Instance25Man = 0;
aura.Instance25ManHeroic = 0;
aura.InstanceBg = 0;
aura.InstanceArena = 0;
aura.spec1 = true;
aura.spec2 = true;
aura.spec3 = true;
aura.gcd = false;
aura.stance = 10;
aura.GTFO = 0;
aura.multiids = "";
aura.tooltipCheck = "";
aura.UseOldAnimations = false;
if (base) then
for k, v in pairs (aura) do
local varType = type(v);
if (varType == "string"
or varType == "boolean"
or varType == "number"
or k=="ShowOptions"
or k=="CheckBoxes"
or k=="OptionText"
or k=="OptionTernary") then
if (base[k] ~= nil) then
aura[k] = base[k];
end
end
end
end
aura.Showing = false;
aura.Active = false;
aura.HideRequest = false;
aura.id = id;
if (aura.minDuration) then
aura.duration = math.max(aura.duration, aura.minDuration);
--PowaAuras:ShowText("duration ", aura.duration, " minDuration ", aura.minDuration);
end
--PowaAuras:ShowText("base ", base);
if (base) then
local tempForSettings = PowaAuras.AuraClasses[base.bufftype];
--PowaAuras:ShowText("base.Timer ", base.Timer, " isSecondary ", base.isSecondary);
if (base.Timer and not aura.isSecondary) then
aura.Timer = cPowaTimer(aura, base.Timer);
end
if (base.Stacks and not base.isSecondary and tempForSettings:StacksAllowed()) then
aura.Stacks = cPowaStacks(aura, base.Stacks);
end
end
aura:Init();
end);
function cPowaAura:Init()
end
function cPowaAura:CustomEvents()
end
function cPowaAura:TimerShowing()
if (not self.Timer) then return false; end
return self.Timer.Showing;
end
function cPowaAura:StacksShowing()
if (not self.Stacks) then return false; end
return self.Stacks.Showing;
end
function cPowaAura:FullTimerAllowed()
--PowaAuras:ShowText("TimerAllowed CanHaveTimer", self.CanHaveTimer, " inverse ", self.inverse, " CanHaveTimerOnInverse ", self.CanHaveTimerOnInverse);
return (self.CanHaveTimer and not self.inverse) or (self.CanHaveTimerOnInverse and self.inverse);
end
function cPowaAura:StacksAllowed()
return (self.CanHaveStacks and not self.inverse);
end
function cPowaAura:HideShowTabs()
if (self:StacksAllowed()) then
PowaEditorTab5:Show();
if (not self.Stacks) then
self.Stacks = cPowaStacks(self);
end
else
PowaEditorTab5:Hide();
if (self.Stacks) then
self.Stacks.enabled = false;
end
end
end
cPowaAura.TooltipOptions = {r=1.0, g=1.0, b=1.0};
function cPowaAura:AddExtraTooltipInfo(tooltip)
tooltip:SetText("|cffFFFFFF["..self.id.."] |r"..self.OptionText.typeText, self.TooltipOptions.r, self.TooltipOptions.g, self.TooltipOptions.b, 1);
if (self.TooltipOptions.showBuffName and self.buffname ~= "???") then
tooltip:AddLine(self.buffname, nil, nil, nil, nil, 1);
end
if (self.TooltipOptions.stacksColour) then
tooltip:AddLine(PowaAuras.Text.nomStacks..self.stacksOperator..self.stacks, self.TooltipOptions.stacksColour.r, self.TooltipOptions.stacksColour.g, self.TooltipOptions.stacksColour.b, 1);
end
if (self.TooltipOptions.showThreshold) then
tooltip:AddLine(self.threshold, self.TooltipOptions.r, self.TooltipOptions.g, self.TooltipOptions.b, 1);
end
if (self.TooltipOptions.showStance) then
tooltip:AddLine(PowaAuras.PowaStance[self.stance], self.TooltipOptions.r, self.TooltipOptions.g, self.TooltipOptions.b, 1);
end
if (self.TooltipOptions.showGTFO) then
tooltip:AddLine(PowaAuras.PowaGTFO[self.GTFO], self.TooltipOptions.r, self.TooltipOptions.g, self.TooltipOptions.b, 1);
end
end
function cPowaAura:CreateFrames()
local frame = self:GetFrame();
if (frame==nil) then
--PowaAuras:UnitTestInfo("New Frames", self.id);
--PowaAuras:UnitTestDebug("Creating frame for aura ", self.id);
--- Frame ---
frame = CreateFrame("Frame","Frame"..self.id, UIParent);
self:SetFrame(frame);
frame:SetFrameStrata("LOW");
frame:Hide();
frame.baseL = 256;
frame.baseH = 256;
end
local texture = self:GetTexture();
if (texture==nil) then
--PowaAuras:UnitTestInfo("New Texture", self.id);
if self.textaura then
--PowaAuras:UnitTestDebug("Creating new textstring texture for aura ", self.id);
texture = frame:CreateFontString(nil, "OVERLAY");
texture:ClearAllPoints();
texture:SetPoint("CENTER",frame);
texture:SetFont(STANDARD_TEXT_FONT, 20);
texture:SetTextColor(self.r,self.g,self.b);
texture:SetJustifyH("CENTER");
else
texture = frame:CreateTexture(nil,"BACKGROUND");
texture:SetBlendMode("ADD");
texture:SetAllPoints(frame); --- attache la texture a la frame
frame.texture = texture;
end
self:SetTexture(texture);
else
if self.textaura then
--PowaAuras:UnitTestDebug("textaura ", texture:GetObjectType());
if texture:GetObjectType() == "Texture" then
--PowaAuras:UnitTestInfo("Converting to textstring texture for aura ", self.id);
--PowaAuras:UnitTestDebug("Converting to textstring texture for aura ", self.id);
texture:SetTexture(nil);
texture = frame:CreateFontString(nil, "OVERLAY");
texture:ClearAllPoints();
texture:SetPoint("CENTER",frame);
texture:SetFont(STANDARD_TEXT_FONT, 20);
texture:SetTextColor(self.r,self.g,self.b);
texture:SetJustifyH("CENTER");
self:SetTexture(texture);
end
else
if texture:GetObjectType() == "FontString" then
--PowaAuras:UnitTestInfo("Converting from textstring texture for aura ", self.id);
texture:SetText("");
texture = frame:CreateTexture(nil,"BACKGROUND");
texture:SetBlendMode("ADD");
texture:SetAllPoints(frame); --- attache la texture a la frame
frame.texture = texture;
self:SetTexture(texture);
end
end
end
return frame, texture;
end
function cPowaAura:Hide(skipEndAnimationStop)
--PowaAuras:UnitTestInfo("Aura.Hide ", self.id);
--PowaAuras:ShowText("cPowaAura:Hide ", self.id);
if (self.BeginAnimation and self.BeginAnimation:IsPlaying()) then
self.BeginAnimation:Stop();
end
if (self.MainAnimation and self.MainAnimation:IsPlaying()) then
self.MainAnimation:Stop();
end
if (not skipEndAnimationStop and (self.EndAnimation and self.EndAnimation:IsPlaying())) then
self.EndAnimation:Stop();
end
local frame = self:GetFrame();
if (frame) then
frame:Hide();
end
if (not self.isSecondary) then
if (self.Timer and (PowaAuras.ModTest or self.off)) then self.Timer:Hide(); end -- Hide Aura
if (self.Stacks) then self.Stacks:Hide(); end
local frame = PowaAuras.Frames[self.id];
if (frame) then
frame:Hide();
end
local secondaryAura = PowaAuras.SecondaryAuras[self.id];
if (secondaryAura) then
secondaryAura:Hide();
end
end
self.Showing = false;
end
function cPowaAura:AddEffect()
table.insert(PowaAuras.AurasByType[self.AuraType], self.id);
end
function cPowaAura:IsPlayerAura()
return (not self.target)
and (not self.targetfriend)
and (not self.party)
and (not self.raid)
and (not (self.groupOrSelf and (GetNumPartyMembers()>0 or GetNumRaidMembers()>0)))
and (not self.focus)
and (not self.optunitn);
end
function cPowaAura:ShowTimerDurationSlider()
return false;
end
function cPowaAura:IconIsRequired()
--PowaAuras:Message(" owntex=",self.owntex, " .icon=",self.icon, " IconRequired=",self.IconRequired);
return (self.owntex == true or self.icon == "" or self.IconRequired);
end
function cPowaAura:SetIcon(texturePath)
if (texturePath==nil or string.len(texturePath)==0 or not self:IconIsRequired()) then
return;
end
if (texturePath ~= self.icon) then
if (self.owntex) then
local texture = self:GetTexture();
if (texture) then
texture:SetTexture(texturePath);
end
end
self.icon = texturePath;
end
self.IconRequired = nil;
end
function cPowaAura:CheckState(giveReason)
--- player aura but player is dead
if (self:IsPlayerAura() and ((PowaAuras.WeAreAlive == true and self.isAlive == false) or (PowaAuras.WeAreAlive == false and self.isAlive == true))) then
if (not giveReason) then return false; end
if (PowaAuras.WeAreAlive == false) then
return false, PowaAuras.Text.nomReasonPlayerDead;
else
return false, PowaAuras.Text.nomReasonPlayerAlive;
end
end
--- target checks
if (not self.targetfriend or self.AuraType~="SpellAlert") then
if (self.target or self.targetfriend) then
if (UnitName("target") == nil) then
if (not giveReason) then return false; end
return false, PowaAuras.Text.nomReasonNoTarget;
end
if (UnitName("target") == UnitName("player")) then
if (not giveReason) then return false; end
return false, PowaAuras.Text.nomReasonTargetPlayer;
end
local targetIsDead = UnitIsDead("target");
if ((targetIsDead and self.isAlive == true) or (not PowaAuras.targetIsDead and self.isAlive == false)) then
if (not giveReason) then return false; end
if (targetIsDead) then
return false, PowaAuras.Text.nomReasonTargetDead;
end
return false, PowaAuras.Text.nomReasonTargetAlive;
end
end
--- regarde si la cible est ennemie
if (self.target and self.targetfriend == false and UnitIsFriend("player","target")) then --- cible amie alors que faut pas
if (not giveReason) then return false; end
return false, PowaAuras.Text.nomReasonTargetFriendly;
end
--- regarde si la cible est amie
if (self.target == false and self.targetfriend and not UnitIsFriend("player","target")) then --- cible ennemie
if (not giveReason) then return false; end
return false, PowaAuras.Text.nomReasonTargetNotFriendly;
end
end
--- party
if (self.party and not ((GetNumPartyMembers() > 0) or (GetNumRaidMembers() > 0))) then --- partycheck yes, but not in party
if (not giveReason) then return false; end
return false, PowaAuras.Text.nomReasonNotInParty;
end
--- focus
if (self.focus and (UnitName("focus") == nil or UnitName("focus") == UnitName("player"))) then --- focuscheck
if (not giveReason) then return false; end
return false, PowaAuras.Text.nomReasonNoFocus;
end
--- unit
if (self.optunitn and not ((GetNumPartyMembers() > 0) or (GetNumRaidMembers() > 0) or UnitExists("pet"))) then --- Unitn yes, but not in party/raid or with pet
if (not giveReason) then return false; end
return false, self:InsertText(self.Text.nomReasonNoCustomUnit, self.unitn);
end
--- raid
if (self.raid and numrm == 0) then --- raidcheck yes, but not in raid
if (not giveReason) then return false; end
return false, PowaAuras.Text.nomReasonNotInRaid;
end
--- dual spec check
if ((not self.spec2 and PowaAuras.ActiveTalentGroup == 2) or (not self.spec1 and PowaAuras.ActiveTalentGroup == 1) or (not self.spec3 and PowaAuras.ActiveTalentGroup == 3)) then
if (not giveReason) then return false; end
return false, PowaAuras.Text.nomReasonNotForTalentSpec;
end
--- mode combat
if ((PowaAuras.WeAreInCombat == true and self.combat == false) or (PowaAuras.WeAreInCombat == false and self.combat == true)) then
if (not giveReason) then return false; end
if (self.combat == true) then
return false, PowaAuras.Text.nomReasonNotInCombat;
end
return false, PowaAuras.Text.nomReasonInCombat;
end
--if (self.PvP==true) then
-- PowaAuras:ShowText("PvPFlagSet=", PowaAuras.PvPFlagSet, " aura.PvP=", self.PvP);
--end
if ((PowaAuras.PvPFlagSet == 1 and self.PvP == false) or (PowaAuras.PvPFlagSet ~= 1 and self.PvP == true)) then
if (not giveReason) then return false; end
if (self.PvP == true) then
return false, PowaAuras.Text.nomReasonPvPFlagNotSet;
end
return false, PowaAuras.Text.nomReasonPvPFlagSet;
end
if ((PowaAuras.WeAreInRaid == true and self.inRaid == false) or (PowaAuras.WeAreInRaid == false and self.inRaid == true)) then
if (not giveReason) then return false; end
if (self.inRaid == true) then
return false, PowaAuras.Text.nomReasonNotInRaid;
end
return false, PowaAuras.Text.nomReasonInRaid;
end
if ((PowaAuras.WeAreInParty == true and self.inParty == false) or (PowaAuras.WeAreInParty == false and self.inParty == true)) then
if (not giveReason) then return false; end
if (self.inParty == true) then
return false, PowaAuras.Text.nomReasonNotInParty;
end
return false, PowaAuras.Text.nomReasonInParty;
end
if ((PowaAuras.WeAreMounted == true and self.ismounted == false) or (PowaAuras.WeAreMounted == false and self.ismounted == true)) then
if (not giveReason) then return false; end
if (self.ismounted == true) then
return false, PowaAuras.Text.nomReasonNotMounted;
end
return false, PowaAuras.Text.nomReasonMounted;
end
if ((PowaAuras.WeAreInVehicle == true and self.inVehicle == false) or (PowaAuras.WeAreInVehicle == false and self.inVehicle == true)) then
if (not giveReason) then return false; end
if (self.inVehicle == true) then
return false, PowaAuras.Text.nomReasonNotInVehicle;
end
return false, PowaAuras.Text.nomReasonInVehicle;
end
-- Instance checks
--PowaAuras:ShowText("Instance ", PowaAuras.Instance);
--PowaAuras:ShowText(" Instance5Man ", self.Instance5Man);
local show, reason;
show, reason = self:ShouldShowForInstanceType("5Man", giveReason);
if (not show) then return show, reason; end
show, reason = self:ShouldShowForInstanceType("5ManHeroic", giveReason);
if (not show) then return show, reason; end
show, reason = self:ShouldShowForInstanceType("10Man", giveReason);
if (not show) then return show, reason; end
show, reason = self:ShouldShowForInstanceType("10ManHeroic", giveReason);
if (not show) then return show, reason; end
show, reason = self:ShouldShowForInstanceType("25Man", giveReason);
if (not show) then return show, reason; end
show, reason = self:ShouldShowForInstanceType("25ManHeroic", giveReason);
if (not show) then return show, reason; end
show, reason = self:ShouldShowForInstanceType("Bg", giveReason);
if (not show) then return show, reason; end
show, reason = self:ShouldShowForInstanceType("Arena", giveReason);
if (not show) then return show, reason; end
-- It's not dead it's restin'
if ((self.isResting==false and IsResting()==1 and not PowaAuras.WeAreInCombat) or (self.isResting==true and (IsResting()~=1))) then
if (not giveReason) then return false; end
if (self.isResting == true) then
return false, PowaAuras.Text.nomReasonNotResting;
end
return false, PowaAuras.Text.nomReasonResting;
end
if (not giveReason) then return true; end
return true, PowaAuras.Text.nomReasonStateOK;
end
function cPowaAura:ShouldShowForInstanceType(instanceType, giveReason)
local flag = "Instance"..instanceType;
--PowaAuras:ShowText(PowaAuras.Instance, " ", instanceType, " ", flag, "=", self[flag]);
if ((PowaAuras.Instance==instanceType and self[flag] == false) or (PowaAuras.Instance~=instanceType and self[flag] == true)) then
if (not giveReason) then return false; end
if (self[flag] == true) then
return false, PowaAuras.Text["nomReasonNotIn"..instanceType.."Instance"];
end
return false, PowaAuras.Text["nomReasonIn"..instanceType.."Instance"];
end
return true;
end
function cPowaAura:ShouldShow(giveReason, reverse)
----PowaAuras:UnitTestInfo("ShouldShow", self.id);
--PowaAuras:ShowText("ShouldShow", self.id);
if (PowaMisc.Disabled) then
return false, PowaAuras.Text.nomReasonDisabled;
end
--PowaAuras.AuraCheckCount = PowaAuras.AuraCheckCount + 1;
local stateResult, reason = self:CheckState(giveReason);
if (not stateResult) then
self.InactiveDueToState = true;
return stateResult, reason;
end
--PowaAuras.AuraCheckShowCount = PowaAuras.AuraCheckShowCount + 1;
self.InactiveDueToState = false;
local result, reason = self:CheckIfShouldShow(giveReason);
--PowaAuras:ShowText("ShouldShow result=",result, " inv=", self.inverse, " rev=", reverse);
if (result==-1) then
return result, reason;
end
if (result~=nil and (self.inverse or reverse) and not (self.inverse and reverse)) then
result = not result;
if (giveReason) then
reason = PowaAuras:InsertText(PowaAuras.Text.nomReasonInverted, reason);
end
end
return result, reason;
end
function cPowaAura:Display()
PowaAuras:Message("Aura Display id=", self.id); --OK
for k,v in pairs (self) do
PowaAuras:Message(" "..tostring(k).." = "..tostring(v)); --OK
end
end
function cPowaAura:GetFrame()
if (self.isSecondary) then
return PowaAuras.SecondaryFrames[self.id];
end
return PowaAuras.Frames[self.id];
end
function cPowaAura:GetTexture()
if (self.isSecondary) then
return PowaAuras.SecondaryTextures[self.id];
end
return PowaAuras.Textures[self.id];
end
function cPowaAura:SetFrame(frame)
if (self.isSecondary) then
PowaAuras.SecondaryFrames[self.id] = frame;
return;
end
PowaAuras.Frames[self.id] = frame;
end
function cPowaAura:SetTexture(texture)
if (self.isSecondary) then
PowaAuras.SecondaryTextures[self.id] = texture;
return;
end
PowaAuras.Textures[self.id] = texture;
end
function cPowaAura:GetSpellNameFromMatch(spellMatch)
local _, _,spellId = string.find(spellMatch, "%[(%d+)%]")
if (spellId) then
local spellName, rank, spellIcon = GetSpellInfo(tonumber(spellId));
return spellName, spellIcon;
end
return spellMatch;
end
function cPowaAura:SetStacks(text)
local _, _,curStacksLower, curOperator, curStacks = string.find(text, "(%d*)(%D+)(%d*)")
if (curStacks == nil or curStacks == "") then curStacks = "0"; end
local stacks = tonumber(curStacks);
--PowaAuras:Debug(stacks);
if (stacks ~= self.stacks) then
if (stacks > 100) or (stacks < 0) then stacks = 0; end
self.stacks = stacks or 0;
end
if (curStacksLower == nil or curStacksLower == "") then curStacksLower = "0"; end
local stacksLower = tonumber(curStacksLower);
--PowaAuras:Debug(stacksLower);
if (stacksLower ~= self.stacksLower) then
if (stacksLower > 100) or (stacksLower < 0) or (stacksLower > stacks) then stacksLower = 0; end
self.stacksLower = stacksLower or 0;
end
if (curOperator ~= self.stacksOperator) then
if (not PowaAuras.allowedOperators[curOperator]) then
curOperator = PowaAuras.DefaultOperator;
end
self.stacksOperator = curOperator;
end
end
function cPowaAura:Trim(s)
return (string.gsub(s, "^%s*(.-)%s*$", "%1"));
end
function cPowaAura:MatchSpell(spellName, spellTexture, textToFind)
if (spellName==nil or textToFind==nil) then
return false;
end
if (textToFind=="*") then
return true;
end
if (self.Debug) then
PowaAuras:Message(" MatchSpell spellName =",spellName); --OK
--PowaAuras:Message(" spellTexture=",spellTexture); --OK
PowaAuras:Message(" textToFind =",textToFind); --OK
end
for pword in string.gmatch(textToFind, "[^/]+") do
pword = self:Trim(pword);
if (string.len(pword)>0) then
local textToSearch;
local textureMatch;
if string.find(pword, "_") then
_, _,textToSearch = string.find(spellTexture, "([%w_]*)$")
else
textToSearch = spellName;
pword, textureMatch = self:GetSpellNameFromMatch(pword);
end
--PowaAuras:ShowText("textureMatch=", textureMatch);
if (not textureMatch or textureMatch==spellTexture) then
if (textToSearch) then
if (self.ignoremaj) then
textToSearch = string.upper(textToSearch)
pword = string.upper(pword);
end
if (self.Debug) then
PowaAuras:Message("pword="..tostring(pword).."<<");
PowaAuras:Message("search="..tostring(textToSearch).."<<");
end
if (self.exact) then
if (self.Debug) then
PowaAuras:Message("exact=", (textToSearch == pword)); --OK
end
if (textToSearch == pword) then
return true;
end
else
if (self.Debug) then
PowaAuras:Message("find=", string.find(textToSearch, pword, 1, true)); --OK
end
if (string.find(textToSearch, pword, 1, true)) then
return true;
end
end
end
end
end
end
return nil;
end
function cPowaAura:MatchText(textToSearch, textToFind)
if (textToSearch==nil or textToFind==nil) then
return false;
end
if (textToFind=="*") then
return true;
end
if (self.Debug) then
PowaAuras:Message("MatchText textToSearch=",textToSearch," textToFind=",textToFind); --OK
end
if (self.ignoremaj) then
textToFind = string.upper(textToFind);
textToSearch = string.upper(textToSearch);
end
if (self.Debug) then
PowaAuras:Message("MatchText textToSearch=",textToSearch," textToFind=",textToFind, " ignoremaj=", self.ignoremaj, " exact=", self.exact); --OK
end
for pword in string.gmatch(textToFind, "[^/]+") do
if (self.Debug) then
PowaAuras:Message("pword=", pword," find=",string.find(textToSearch, pword, 1, true)); --OK
end
if (self.exact and textToSearch == textToFind) then
return true;
elseif (string.find(textToSearch, pword, 1, true)) then
return true;
end
end
return nil;
end
function cPowaAura:CreateAuraString(keepLink)
local tempstr = "Version:st"..PowaMisc.Version.."; ";
local varpref = "";
for k, v in pairs (self) do
--- multi condition checks not supported for export.
if ((k == "multiids" and not keepLink) or k=="Debug") then
v = "";
end
local varType = type(v);
if (varType == "string" or varType == "boolean" or varType == "number") then
tempstr = tempstr..k..":"..string.sub(varType,1,2)
if (varType == "string") then
tempstr = tempstr..v;
else
tempstr = tempstr..tostring(v);
end
tempstr = tempstr.."; ";
end
end
if (self.Timer and self.Timer.enabled) then
for k, v in pairs (self.Timer) do
local varType = type(v);
if (varType == "string" or varType == "boolean" or varType == "number") then
tempstr = tempstr.."timer."..k..":"..string.sub(varType,1,2);
if (varType == "string") then
tempstr = tempstr..v;
else
tempstr = tempstr..tostring(v);
end
tempstr = tempstr.."; ";
end
end
end
if (self.Stacks and self.Stacks.enabled) then
for k, v in pairs (self.Stacks) do
local varType = type(v);
if (varType == "string" or varType == "boolean" or varType == "number") then
tempstr = tempstr.."stacks."..k..":"..string.sub(varType,1,2);
if (varType == "string") then
tempstr = tempstr..v;
else
tempstr = tempstr..tostring(v);
end
tempstr = tempstr.."; ";
end
end
end
if tempstr and tempstr ~= "" then
tempstr = strtrim(tempstr);
tempstr = string.sub(tempstr, 1, string.len(tempstr)-1);
end
--PowaAuras:Debug("Aura-string length: "..tostring(string.len(tempstr)));
return tempstr;
end
function cPowaAura:GetUnit()
if (self.target or self.targetfriend) then
return "target";
elseif (self.focus) then
return "focus";
elseif (self.party) then
return "party";
elseif (self.raid) then
return "raid";
elseif (self.groupOrSelf) then
return "groupOrSelf";
elseif (self.optunitn) then
return self.unitn;
else
return "player";
end
return nil;
end
function cPowaAura:CheckAllUnits(giveReason)
local unit = self:GetUnit();
--PowaAuras:Debug("on unit "..unit);
local numpm = GetNumPartyMembers();
local numrm = GetNumRaidMembers();
if unit == "party" then
for pm = 1, numpm do
unit = "party"..pm;
if self:CheckUnit(unit) then
if (not giveReason) then return true; end
return true, PowaAuras:InsertText(PowaAuras.Text.ReasonStat[self.ValueName].MatchReason, unit);
end
end
elseif unit == "raid" then
for rm = 1, numrm do
unit = "raid"..rm;
if self:CheckUnit(unit) then
if (not giveReason) then return true; end
return true, PowaAuras:InsertText(PowaAuras.Text.ReasonStat[self.ValueName].MatchReason, unit);
end
end
elseif unit == "groupOrSelf" then
if (numrm>0) then
for rm = 1, numrm do
unit = "raid"..rm;
if self:CheckUnit(unit) then
if (not giveReason) then return true; end
return true, PowaAuras:InsertText(PowaAuras.Text.ReasonStat[self.ValueName].MatchReason, unit);
end
end
elseif (numpm>0) then
for pm = 1, numpm do
unit = "party"..pm;
if self:CheckUnit(unit) then
if (not giveReason) then return true; end
return true, PowaAuras:InsertText(PowaAuras.Text.ReasonStat[self.ValueName].MatchReason, unit);
end
end
if self:CheckUnit("player") then
if (not giveReason) then return true; end
return true, PowaAuras:InsertText(PowaAuras.Text.ReasonStat[self.ValueName].MatchReason, unit);
end
end
else
if self:CheckUnit(unit) then
if (not giveReason) then return true; end
return true, PowaAuras:InsertText(PowaAuras.Text.ReasonStat[self.ValueName].MatchReason, unit);
end
end
if (not giveReason) then return false; end
return false, PowaAuras:InsertText(PowaAuras.Text.ReasonStat[self.ValueName].NoMatchReason, unit);
end
function cPowaAura:CheckStacks(count)
local operator = self.stacksOperator or PowaAuras.DefaultOperator;
local stacks = self.stacks or 0;
local stacksLower = self.stacksLower or 0;
--PowaAuras:Debug("Stack op=",operator," stacks=",stacks,"Stack Count=",count);
return ((operator == "=" and stacks == 0)
or (operator == ">=" and count >= stacks)
or (operator == "<=" and count <= stacks)
or (operator == ">" and count > stacks)
or (operator == "<" and count < stacks)
or (operator == "=" and count == stacks)
or (operator == "-" and count >= stacksLower and count <= stacks)
or (operator == "!" and count ~= stacks));
end
function cPowaAura:StacksText()
local stacksText = self.stacksOperator..tostring(self.stacks);
if (self.stacksOperator=="-") then
stacksText = tostring(self.stacksLower)..stacksText;
end
return stacksText;
end
function cPowaAura:CheckTimerInvert()
if (PowaAuras.ModTest or self.Timer.InvertAuraBelow==nil or self.Timer.InvertAuraBelow==0 or self.InvertTest) then
return;
end
local timeValue = 0;
if (self.Timer.DurationInfo and self.Timer.DurationInfo > 0) then
timeValue = math.max(self.Timer.DurationInfo - GetTime(), 0);
end
if (PowaAuras.DebugCycle or self.Debug) then
PowaAuras:DisplayText("=================");
PowaAuras:DisplayText("CheckTimerInvert");
PowaAuras:DisplayText("id=",self.id);
PowaAuras:DisplayText("timeValue=",timeValue);
PowaAuras:DisplayText("InvertAuraBelow=",self.Timer.InvertAuraBelow);
PowaAuras:DisplayText("ForceTimeInvert=",self.ForceTimeInvert);
PowaAuras:DisplayText("InvertTimeHides=",self.InvertTimeHides);
end
local oldForceTimeInvert = self.ForceTimeInvert;
if (timeValue and timeValue > 0 and ((not self.InvertTimeHides and timeValue<=self.Timer.InvertAuraBelow))
or (self.InvertTimeHides and timeValue>=self.Timer.InvertAuraBelow) ) then
self.ForceTimeInvert = true;
else
self.ForceTimeInvert = nil;
end
if (oldForceTimeInvert ~= self.ForceTimeInvert) then
self.InvertTest = true; -- To prevent infinite loop
--PowaAuras:ShowText("Change in ForceTimeInvert=", self.ForceTimeInvert);
PowaAuras:TestThisEffect(self.id);
self.InvertTest = nil;
end
end
cPowaBuffBase = PowaClass(cPowaAura, {CanHaveTimer=true, CanHaveStacks=true, CanHaveInvertTime=true, InvertTimeHides=true});
function cPowaBuffBase:AddEffect()
if not self.target
and not self.targetfriend
and not self.party
and not self.raid
and not self.groupOrSelf
and not self.focus
and not self.optunitn then --- self-buff
table.insert(PowaAuras.AurasByType.Buffs, self.id);
end
if self.party then --- party buffs
table.insert(PowaAuras.AurasByType.PartyBuffs, self.id);
end
if self.focus then --- focus buffs
table.insert(PowaAuras.AurasByType.FocusBuffs, self.id);
end
if self.raid then --- raid buffs
table.insert(PowaAuras.AurasByType.RaidBuffs, self.id);
end
if self.groupOrSelf then --- groupOrSelf buffs
table.insert(PowaAuras.AurasByType.GroupOrSelfBuffs, self.id);
end
if self.optunitn then --- unit buffs
table.insert(PowaAuras.AurasByType.UnitBuffs, self.id);
end
if (self.target or self.targetfriend) then --- target buff
table.insert(PowaAuras.AurasByType.TargetBuffs, self.id);
end
end
function cPowaBuffBase:IsPresent(unittarget, s, giveReason, textToCheck)
--PowaAuras:Debug("IsPresent on ",unittarget," buffid ",s," type", self.buffAuraType);
--PowaAuras.BuffSlotCount = PowaAuras.BuffSlotCount + 1;
local auraName, _, auraTexture, count, _, _, expirationTime, caster = UnitAura(unittarget, s, self.buffAuraType);
if (auraName == nil) then return nil; end
--PowaAuras:Debug("Aura=",auraName," count=",count," expirationTime=", expirationTime," caster=",caster);
if (not self:CompareAura(unittarget, s, auraName, auraTexture, textToCheck)) then
--PowaAuras:Debug("CompareAura not found");
return false;
end
local isMine = (caster~=nil) and UnitExists(caster) and UnitIsUnit("player", caster);
local bemine = self.mine;
--PowaAuras:ShowText("Bemine=",bemine," isMine=",isMine);
if (bemine and not isMine) then
if (not giveReason) then return nil; end
return nil, PowaAuras.Text.nomReasonBuffPresentNotMine;
end
if (not self:CheckStacks(count)) then
if (giveReason) then return nil, PowaAuras:InsertText(PowaAuras.Text.nomReasonStacksMismatch, count, self:StacksText()); end
return nil;
end
if (self.Stacks) then
self.Stacks:SetStackCount(count);
end
--PowaAuras:ShowText("Present!");
if (self.Timer) then
self.Timer:SetDurationInfo(expirationTime);
self:CheckTimerInvert();
if (self.ForceTimeInvert) then
if (not giveReason) then return false; end
return false, PowaAuras.Text.nomReasonBuffPresentTimerInvert;
end
end
if (giveReason) then return true, PowaAuras.Text.nomReasonBuffFound; end
return true;
end
function cPowaBuffBase:CheckTooltip(text, target, index)
if (text==nil or string.len(text) == 0) then
return true;
end
--PowaAuras:Debug("Search in tooltip for ",text);