-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHealBot_Action.lua
1285 lines (1170 loc) · 45.6 KB
/
HealBot_Action.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
local headerno=0;
HealBot_Action_HealGroup = {
"player",
"pet",
"party1",
"party2",
"party3",
"party4",
};
HealBot_Action_HealTarget = {
};
HealBot_Action_HealButtons = {
};
HealBot_Action_UnitButtons = {
};
function HealBot_Action_AddDebug(msg)
HealBot_AddDebug("Action: " .. msg);
end
function HealBot_HealthColor(unit,hlth,maxhlth)
if HealBot_UnitDebuff[unit] then
local debuff, tmp, debuff_type = UnitDebuff(unit,1, 1)
if not debuff then
HealBot_UnitDebuff[unit] = nil;
HealBot_UnitDebuff[unit.."_debuff_texture"]=nil
else
return HealBot_Config.CDCBarColour[HealBot_UnitDebuff[unit]].R,
HealBot_Config.CDCBarColour[HealBot_UnitDebuff[unit]].G,
HealBot_Config.CDCBarColour[HealBot_UnitDebuff[unit]].B,
HealBot_Config.Barcola[HealBot_Config.Current_Skin];
end
end
local text = UnitName(unit);
if not HealBot_HealsIn[text] then
HealBot_HealsIn[text]=0;
end
local pct = hlth+HealBot_HealsIn[text];
if pct<maxhlth then
pct=pct/maxhlth;
else
pct=1;
end
local r,g,b = 1.0, 1.0, 0.0;
local a=HealBot_Config.Barcola[HealBot_Config.Current_Skin];
if pct>HealBot_Config.AlertLevel then
a=HealBot_Config.bardisa[HealBot_Config.Current_Skin];
end
if pct>=0.98 then r = 0.0; end
if pct<0.98 and pct>=0.65 then r=2.94-(pct*3); end
if pct<=0.64 and pct>0.31 then g=(pct-0.31)*3; end
if pct<=0.31 then g = 0.0; end
return r,g,b,a;
end
function HealBot_Action_HealthBar(button)
local name = button:GetName();
return getglobal(name.."Bar");
end
function HealBot_Action_HealthBar2(button)
local name = button:GetName();
return getglobal(name.."Bar2");
end
function HealBot_AlwaysHeal()
return HealBot_Config.EnableHealthy==1
end
function HealBot_MayHeal(unit)
if not UnitName(unit) or not HealBot_Heals[unit] then return false end
if unit ~= 'target' then return true end
if not HealBot_Config.TargetHeals or UnitCanAttack("player",unit) then return false end
return true;
end
function HealBot_ShouldHeal(unit)
if HealBot_UnitDebuff[unit] and not UnitIsDeadOrGhost(unit) then
if HealBot_Range_Check(unit, 30)==1 then
return true;
end
end
return HealBot_MayHeal(unit) and UnitHealth(unit)>0 and not UnitIsDeadOrGhost(unit)
and (UnitHealth(unit)<UnitHealthMax(unit)*HealBot_Config.AlertLevel or HealBot_AlwaysHeal());
end
function HealBot_Action_ShouldHealSome()
return table.foreach(HealBot_Action_HealButtons, function (index,button)
if (HealBot_ShouldHeal(button.unit)) then return button.unit; end
end);
end
function HealBot_MustHeal(unit)
return HealBot_ShouldHeal(unit) and UnitHealth(unit)<UnitHealthMax(unit)*HealBot_Config.AlertLevel
end
function HealBot_Action_MustHealSome()
return table.foreach(HealBot_Action_HealButtons, function (index,button)
if (HealBot_MustHeal(button.unit)) then return button.unit; end
end);
end
function HealBot_CanHeal(unit)
local SHeal = HealBot_ShouldHeal(unit)
if SHeal then
local spell = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Left"))
if not spell then spell = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Middle")) end
if not spell then spell = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Right")) end
if not spell then spell = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Button4")) end
if not spell then spell = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Button5")) end
if not spell then
return false
else
return true
end
end
return false
end
function HealBot_Action_EnableButton(button)
local unit = button.unit;
local hlth=UnitHealth(unit);
local maxhlth=UnitHealthMax(unit);
local name = UnitName(unit);
local bar = HealBot_Action_HealthBar(button);
local bar2 = HealBot_Action_HealthBar2(button);
local btexture=HealBot_Config.btexture[HealBot_Config.Current_Skin];
local bheight=HealBot_Config.bheight[HealBot_Config.Current_Skin];
local sr=HealBot_Config.btextenabledcolr[HealBot_Config.Current_Skin];
local sg=HealBot_Config.btextenabledcolg[HealBot_Config.Current_Skin];
local sb=HealBot_Config.btextenabledcolb[HealBot_Config.Current_Skin];
local sa=HealBot_Config.btextenabledcola[HealBot_Config.Current_Skin];
local r,g,b,a = HealBot_HealthColor(button.unit,hlth,maxhlth)
local btextheight=HealBot_Config.btextheight[HealBot_Config.Current_Skin]
local bwidth = HealBot_Config.bwidth[HealBot_Config.Current_Skin]
local textlen = floor(5+(((bwidth*1.8)/btextheight)-(btextheight/2)))-2
bar:SetMinMaxValues(0,maxhlth);
bar:SetValue(hlth);
if HealBot_HealsIn[name] then
bar2:SetMinMaxValues(0,maxhlth);
bar2:SetValue(hlth+HealBot_HealsIn[name]);
else
bar2:SetValue(0);
end
bar.txt = getglobal(bar:GetName().."_text");
if (not HealBot_IsCasting and HealBot_CanHeal(unit)) then
-- button:Enable();
HealBot_Enabled[unit]=true;
bar:SetStatusBarColor(r,g,b,HealBot_Config.Barcola[HealBot_Config.Current_Skin]);
bar2:SetStatusBarColor(r,g,b,HealBot_Config.BarcolaInHeal[HealBot_Config.Current_Skin]);
if HealBot_Config.SetClassColourText==1 then
sr,sg,sb = HealBot_Action_ClassColour(unit);
sa = 1;
elseif HealBot_UnitDebuff[unit] then
sr=HealBot_Config.btextcursecolr[HealBot_Config.Current_Skin];
sg=HealBot_Config.btextcursecolg[HealBot_Config.Current_Skin];
sb=HealBot_Config.btextcursecolb[HealBot_Config.Current_Skin];
sa=HealBot_Config.btextcursecola[HealBot_Config.Current_Skin];
end
else
-- button:Disable();
HealBot_Enabled[unit]=nil;
if HealBot_Ressing[UnitName(unit)] then
if UnitIsDeadOrGhost(unit) then
sr=0.2;
sg=1.0;
sb=0.2;
sa=1;
else
HealBot_Ressing[UnitName(unit)]=nil
sr=HealBot_Config.btextdisbledcolr[HealBot_Config.Current_Skin];
sg=HealBot_Config.btextdisbledcolg[HealBot_Config.Current_Skin];
sb=HealBot_Config.btextdisbledcolb[HealBot_Config.Current_Skin];
sa=HealBot_Config.btextdisbledcola[HealBot_Config.Current_Skin];
end
else
sr=HealBot_Config.btextdisbledcolr[HealBot_Config.Current_Skin];
sg=HealBot_Config.btextdisbledcolg[HealBot_Config.Current_Skin];
sb=HealBot_Config.btextdisbledcolb[HealBot_Config.Current_Skin];
sa=HealBot_Config.btextdisbledcola[HealBot_Config.Current_Skin];
end
bar:SetStatusBarColor(r,g,b,HealBot_Config.bardisa[HealBot_Config.Current_Skin]);
bar2:SetStatusBarColor(r,g,b,HealBot_Config.bardisa[HealBot_Config.Current_Skin]);
end
if HealBot_Config.ShowClassOnBar==1 then
if UnitClass(unit) then
if HealBot_Config.ShowClassOnBarWithName==1 then
name=UnitClass(unit)..":"..name;
else
name=UnitClass(unit);
end
end
end
local barText ="";
if HealBot_Config.ShowHealthOnBar==1 and maxhlth then
if HealBot_Config.BarHealthType==1 then
barText=" ("..hlth-maxhlth..")"
else
barText=" ("..floor((hlth/maxhlth)*100).."%)"
end
textlen=textlen-string.len(barText)
if textlen<1 then textlen=1; end
end
if string.len(name)>textlen then
barText = string.sub(name,1,textlen) .. '..'..barText;
else
barText = name..barText;
end
bar.txt:SetText(barText);
bar.txt:SetTextColor(sr,sg,sb,sa);
end
function HealBot_Action_EnableButtons()
table.foreach(HealBot_Action_HealButtons, function (index,button)
HealBot_Action_EnableButton(button);
end);
end
function HealBot_Action_RefreshButton(button)
if not button then return end
if type(button)~="table" then DEFAULT_CHAT_FRAME:AddMessage("***** "..type(button)) end
local unit = button.unit;
if HealBot_MayHeal(unit) then
HealBot_Action_EnableButton(button)
end
end
function HealBot_Action_ResetSkin()
HealBot_Action_PartyChanged()
if HealBot_Options:IsVisible() then
HealBot_DiseaseColorpick:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..HealBot_Config.btexture[HealBot_Config.Current_Skin]);
HealBot_MagicColorpick:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..HealBot_Config.btexture[HealBot_Config.Current_Skin]);
HealBot_PoisonColorpick:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..HealBot_Config.btexture[HealBot_Config.Current_Skin]);
HealBot_CurseColorpick:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..HealBot_Config.btexture[HealBot_Config.Current_Skin]);
HealBot_EnTextColorpick:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..HealBot_Config.btexture[HealBot_Config.Current_Skin]);
HealBot_EnTextColorpickin:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..HealBot_Config.btexture[HealBot_Config.Current_Skin]);
HealBot_DisTextColorpick:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..HealBot_Config.btexture[HealBot_Config.Current_Skin]);
HealBot_DebTextColorpick:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..HealBot_Config.btexture[HealBot_Config.Current_Skin]);
HealBot_SetSkinColours()
end
end
function HealBot_Action_RefreshButtons()
table.foreach(HealBot_Action_HealButtons, function (index,button)
HealBot_Action_RefreshButton(button);
end);
end
function HealBot_Action_RefreshButtons(unit)
if unit and HealBot_Action_UnitButtons[unit] then
table.foreach(HealBot_Action_UnitButtons[unit], function (index,button)
HealBot_Action_RefreshButton(button);
end);
else
table.foreach(HealBot_Action_HealButtons, function (index,button)
HealBot_Action_RefreshButton(button);
end);
end
end
function HealBot_Action_PositionButton(button,OsetX,OsetY,bwidth,bheight,checked,header)
local brspace=HealBot_Config.brspace[HealBot_Config.Current_Skin] or 3;
if header then
headerno=headerno+1;
local headerobj=getglobal("HealBot_Action_Header"..headerno);
local tmpY=OsetY
headerobj:SetText(header)
headerobj:Show();
headerobj:ClearAllPoints();
headerobj:SetHeight(bheight);
headerobj:SetWidth(bwidth);
headerobj:SetPoint("TOPLEFT","HealBot_Action","TOPLEFT",OsetX,-OsetY);
headerobj:Disable();
OsetY = OsetY+headerobj:GetHeight()+brspace;
else
local unit = button.unit;
button:SetText(" ");
if (HealBot_MayHeal(unit)) then
button:Show();
button:ClearAllPoints();
button:SetHeight(bheight);
button:Enable();
if checked then
button:SetWidth(bwidth-14);
button:SetPoint("TOPLEFT","HealBot_Action","TOPLEFT",OsetX+14,-OsetY);
else
button:SetWidth(bwidth);
button:SetPoint("TOPLEFT","HealBot_Action","TOPLEFT",OsetX,-OsetY);
end
OsetY = OsetY+button:GetHeight()+brspace;
else
button:Hide();
end
end
return OsetY;
end
function HealBot_Action_SetHeightWidth(width,height,bwidth)
if HealBot_ActionHeight then
HealBot_Action:SetHeight(HealBot_ActionHeight);
end
if HealBot_Config.GrowUpwards==1 then
local left,bottom = HealBot_Action:GetLeft(),HealBot_Action:GetBottom();
if left and bottom then
if HealBot_Config.PanelAnchorX==-1 then HealBot_Config.PanelAnchorX=left; end
if HealBot_Config.PanelAnchorY==-1 then HealBot_Config.PanelAnchorY=bottom; end
HealBot_Action:ClearAllPoints();
HealBot_Action:SetPoint("BOTTOMLEFT","UIParent","BOTTOMLEFT",HealBot_Config.PanelAnchorX,HealBot_Config.PanelAnchorY);
end
else
local left,top = HealBot_Action:GetLeft(),HealBot_Action:GetTop();
if left and top then
HealBot_Action:ClearAllPoints();
HealBot_Action:SetPoint("TOPLEFT","UIParent","BOTTOMLEFT",left,top);
end
end
HealBot_Action:SetHeight(height);
HealBot_ActionHeight = height;
HealBot_Action:SetWidth(width+bwidth+10)
end
function HealBot_Action_SetHealButton(index,unit)
if not index then
HealBot_Action_HealButtons = {};
HealBot_Action_UnitButtons = {};
return nil
end
local button = getglobal("HealBot_Action_HealUnit"..index);
button.unit = unit;
if unit then
table.insert(HealBot_Action_HealButtons,button);
if not HealBot_Action_UnitButtons[unit] then HealBot_Action_UnitButtons[unit] = {} end
table.insert(HealBot_Action_UnitButtons[unit],button);
else
button:Hide();
end
return button;
end
function HealBot_Action_PartyChanged()
if not HealBot_IsFighting then
local numBars = 0;
local numHeaders = 0;
local TempMaxH=0;
local HeaderPos = {};
HealBot_Enabled = {};
for j=1,15 do
local headerobj=getglobal("HealBot_Action_Header"..j);
headerobj:SetText(" ")
headerobj:Hide();
end
local bwidth = HealBot_Config.bwidth[HealBot_Config.Current_Skin] or 85;
local sr=HealBot_Config.btextdisbledcolr[HealBot_Config.Current_Skin] or 0.4;
local sg=HealBot_Config.btextdisbledcolg[HealBot_Config.Current_Skin] or 0.4;
local sb=HealBot_Config.btextdisbledcolb[HealBot_Config.Current_Skin] or 0.4;
local sa=HealBot_Config.btextdisbledcola[HealBot_Config.Current_Skin] or 0.6;
local bheight=HealBot_Config.bheight[HealBot_Config.Current_Skin] or 18;
local btexture=HealBot_Config.btexture[HealBot_Config.Current_Skin] or 5;
local bcspace=HealBot_Config.bcspace[HealBot_Config.Current_Skin] or 4;
local cols=HealBot_Config.numcols[HealBot_Config.Current_Skin] or 2;
local btextheight=HealBot_Config.btextheight[HealBot_Config.Current_Skin] or 10;
local abortsize=HealBot_Config.abortsize[HealBot_Config.Current_Skin] or 10;
local checked_start=0;
local checked_end=0;
headerno=0;
for j=1,41 do
HealBot_Action_SetHealButton(j,nil);
end
for j=51,60 do
HealBot_Action_SetHealButton(j,nil);
end
HealBot_Action_SetHealButton();
local i = 0;
local last = 0;
local GroupValid=numBars;
last = last+6
if HealBot_Config.GroupHeals==1 then
if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then
HeaderPos[i+1] = HEALBOT_OPTIONS_GROUPHEALS
end
for _,unit in ipairs(HealBot_Action_HealGroup) do
if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then
i = i+1;
HealBot_Action_SetHealButton(i,unit);
numBars=numBars+1;
end
if i==last then break end
end
end
if numBars>GroupValid and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then
numBars=numBars+1;
numHeaders=numHeaders+1;
end
last = last+10
local TankValid=numBars;
if HealBot_Config.TankHeals==1 then
if GetNumRaidMembers()>0 and CT_RA_MainTanks then
if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then
HeaderPos[i+1] = HEALBOT_OPTIONS_TANKHEALS
end
for j=1,10 do
if CT_RA_MainTanks[j] then
for k=1,GetNumRaidMembers() do
local unit = "raid"..k;
local PossibleMT=1;
if UnitInParty(unit) and HealBot_Config.GroupHeals==1 then
if not UnitIsUnit(unit, "player") then
PossibleMT=0;
end
end
if PossibleMT==1 then
if UnitName(unit)==CT_RA_MainTanks[j] then
if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then
i = i+1;
HealBot_Action_SetHealButton(i,unit);
numBars=numBars+1;
end
end
end
end
end
if i==last then break end
end
end
end
if numBars>TankValid and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then
numBars=numBars+1;
numHeaders=numHeaders+1;
end
last = last+10;
local h=50;
local TargetValid=numBars;
if HealBot_Config.TargetHeals==1 then
if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then
HeaderPos[i+1] = HEALBOT_OPTIONS_TARGETHEALS
end
for _,unit in ipairs(HealBot_Action_HealTarget) do
if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then
i = i+1;
h = h+1;
if checked_start==0 then checked_start=i; end
checked_end=i;
HealBot_Action_SetHealButton(h,unit);
local check = getglobal("HealBot_Action_HealUnit"..h.."Check");
check.unit = unit;
check:SetChecked(1);
check:Show();
numBars=numBars+1;
end
if i==last then break end
end
last = last+1
unit = HealBot_TargetName()
if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal("target") then
i = i+1;
h = h+1;
if h<61 then
HealBot_Action_SetHealButton(h,"target");
local check = getglobal("HealBot_Action_HealUnit"..h.."Check");
check:SetChecked(0);
check.unit = unit;
if check.unit then
if checked_start==0 then checked_start=i; end
checked_end=i;
check:Show();
else
check:Hide();
end
else
HealBot_Action_SetHealButton(i,"target");
end
numBars=numBars+1;
end
end
if numBars>TargetValid and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then
numBars=numBars+1;
numHeaders=numHeaders+1;
end
last = last+40
local ExtraValid=numBars;
if HealBot_Config.EmergencyHeals==1 and GetNumRaidMembers()>0 then
local order = {};
local units = {};
if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 and HealBot_Config.ExtraOrder==1 then
HeaderPos[i+1] = HEALBOT_OPTIONS_EMERGENCYHEALS
numBars=numBars+1;
numHeaders=numHeaders+1;
end
if HealBot_Config.EmergIncMonitor==1 then
for j=1,40 do
local PossibleEmerg=1;
local unit = "raid"..j;
local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(j);
if not name then name="not known" end
if not class then class="not known" end
if not subgroup then subgroup="not known" end
if not HealBot_Config.ExtraIncGroup[subgroup] then
PossibleEmerg=0;
end
if UnitInParty(unit) and HealBot_Config.GroupHeals==1 then
PossibleEmerg=0;
end
if PossibleEmerg==1 then
if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then
if HealBot_Config.ExtraOrder==1 then
order[unit] = name;
elseif HealBot_Config.ExtraOrder==2 then
order[unit] = class;
elseif HealBot_Config.ExtraOrder==3 then
order[unit] = subgroup;
else
order[unit] = 0-UnitHealthMax(unit);
if UnitHealthMax(unit)>TempMaxH then TempMaxH=UnitHealthMax(unit); end
end
table.insert(units,unit);
numBars=numBars+1;
end
end
end
else
for j=1,40 do
local unit = "raid"..j;
local Class = UnitClass(unit);
local ProcessUnit = 0;
local PossibleEmerg=1;
local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(j);
if not name then name="not known" end
if not class then class="not known" end
if not subgroup then subgroup="not known" end
if not HealBot_Config.ExtraIncGroup[subgroup] then
PossibleEmerg=0;
end
if HealBot_EmergInc[Class]==1 then
ProcessUnit = 1;
end
if UnitInParty(unit) and HealBot_Config.GroupHeals==1 then
PossibleEmerg=0;
end
if ProcessUnit==1 and PossibleEmerg==1 then
if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then
if HealBot_Config.ExtraOrder==1 then
order[unit] = name;
elseif HealBot_Config.ExtraOrder==2 then
order[unit] = class;
elseif HealBot_Config.ExtraOrder==3 then
order[unit] = subgroup;
else
order[unit] = 0-UnitHealthMax(unit);
if UnitHealthMax(unit)>TempMaxH then TempMaxH=UnitHealthMax(unit); end
end
table.insert(units,unit);
numBars=numBars+1;
end
end
end
end
table.sort(units,function (a,b)
if order[a]<order[b] then return true end
if order[a]>order[b] then return false end
return a<b
end)
local TempSort="init"
TempMaxH=ceil(TempMaxH/1000)*1000;
for j=1,40 do
if not units[j] then break end
local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(strsub(units[j], 5));
if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 and HealBot_Config.ExtraOrder==2 and TempSort~=class then
TempSort=class
HeaderPos[i+1] = class
numBars=numBars+1;
numHeaders=numHeaders+1;
end
if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 and HealBot_Config.ExtraOrder==3 and TempSort~=subgroup then
TempSort=subgroup
HeaderPos[i+1] = HEALBOT_OPTIONS_GROUPHEALS..subgroup
numBars=numBars+1;
numHeaders=numHeaders+1;
end
if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 and HealBot_Config.ExtraOrder==4 and TempMaxH>UnitHealthMax(units[j]) then
TempMaxH=TempMaxH-1000
HeaderPos[i+1] = ">"..tostring(TempMaxH/1000).."k"
numBars=numBars+1;
numHeaders=numHeaders+1;
end
i = i+1;
HealBot_Action_SetHealButton(i,units[j]);
if i==last then break end
end
end
if numBars==ExtraValid+1 and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then
HeaderPos[i+1] = nil;
numBars=numBars-1;
end
OffsetY = 10;
OffsetX = 10;
MaxOffsetY=0;
if cols>(numBars-numHeaders) then
cols=numBars-numHeaders;
end
local h=1;
local i=0;
local z=1;
table.foreach(HealBot_Action_HealButtons, function (index,button)
i=i+1;
local checked=false;
local header;
if HeaderPos[i] then
header=HeaderPos[i];
OffsetY = HealBot_Action_PositionButton(nil,OffsetX,OffsetY,bwidth,bheight,checked,header);
if h==ceil((numBars)/cols) and z<numBars then
h=0;
if MaxOffsetY<OffsetY then MaxOffsetY = OffsetY; end
OffsetY = 10;
OffsetX = OffsetX + bwidth+bcspace;
-- z=z+1;
end
h=h+1;
z=z+1;
end
if checked_start<=i and checked_end>=i then checked=true; end
OffsetY = HealBot_Action_PositionButton(button,OffsetX,OffsetY,bwidth,bheight,checked,nil);
if h==ceil((numBars)/cols) and z<numBars then
h=0;
if MaxOffsetY<OffsetY then MaxOffsetY = OffsetY; end
OffsetY = 10;
OffsetX = OffsetX + bwidth+bcspace;
end
z=z+1;
h=h+1;
local bar = HealBot_Action_HealthBar(button);
local bar2 = HealBot_Action_HealthBar2(button);
bar.txt = getglobal(bar:GetName().."_text");
bar:SetHeight(bheight);
bar:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..btexture);
bar.txt:SetTextHeight(btextheight);
local barScale = bar:GetScale();
bar:SetScale(barScale + 0.01);
bar:SetScale(barScale);
bar2:SetHeight(bheight);
bar2:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..btexture);
end);
if MaxOffsetY<OffsetY then MaxOffsetY = OffsetY; end
if HealBot_Config.HideOptions==1 then
HealBot_Action_OptionsButton:Hide();
else
HealBot_Action_OptionsButton:SetPoint("BOTTOM","HealBot_Action","BOTTOM",0,10);
HealBot_Action_OptionsButton:Show();
MaxOffsetY = MaxOffsetY+30;
end
if HealBot_Config.HideAbort==1 then
HealBot_Action_AbortButton:Hide();
else
local bar = HealBot_Action_HealthBar(HealBot_Action_AbortButton);
local width=(bwidth-12)+(OffsetX/(6-(abortsize/3)));
bar.txt = getglobal(bar:GetName().."_text");
bar.txt:SetTextColor(sr,sg,sb,sa);
bar.txt:SetText(HEALBOT_ACTION_ABORT);
bar:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..btexture);
bar:SetMinMaxValues(0,100);
bar:SetValue(100);
bar:ClearAllPoints();
bar:SetHeight(bheight+abortsize);
bar:SetWidth(width);
bar:SetStatusBarColor(0.1,0.1,0.4,0);
MaxOffsetY = MaxOffsetY+30+abortsize;
HealBot_Action_AbortButton:ClearAllPoints();
HealBot_Action_AbortButton:SetWidth(width)
HealBot_Action_AbortButton:SetHeight(bheight+abortsize);
if HealBot_Config.HideOptions==1 then
HealBot_Action_AbortButton:SetPoint("BOTTOM","HealBot_Action","BOTTOM",0,10);
bar:SetPoint("BOTTOM","HealBot_Action","BOTTOM",0,10);
else
HealBot_Action_AbortButton:SetPoint("BOTTOM","HealBot_Action_OptionsButton","TOP",0,10);
bar:SetPoint("BOTTOM","HealBot_Action_OptionsButton","TOP",0,10);
end
HealBot_Action_AbortButton:Show();
end
HealBot_Action_SetHeightWidth(OffsetX, MaxOffsetY+10, bwidth);
end
HealBot_Action_RefreshButtons();
end
function HealBot_Action_Reset()
HealBot_Action:ClearAllPoints();
HealBot_Action:SetPoint("TOP","MinimapCluster","BOTTOM",7,10);
HealBot_Action_HealTarget = {};
HealBot_Action_PartyChanged();
end
function HealBot_Action_ClassColour(unit)
local ClassColourR,ClassColourG,ClassColourB = 0,1,0;
local class=HealBot_UnitClass(unit);
if class=="DRUID" then
ClassColourR,ClassColourG,ClassColourB = 1.0,0.49,0.04;
elseif class=="HUNTER" then
ClassColourR,ClassColourG,ClassColourB = 0.67,0.83,0.45;
elseif class=="MAGE" then
ClassColourR,ClassColourG,ClassColourB = 0.41,0.8,0.94;
elseif class=="PALADIN" then
ClassColourR,ClassColourG,ClassColourB = 0.96,0.55,0.73;
elseif class=="PRIEST" then
ClassColourR,ClassColourG,ClassColourB = 1.0,1.0,1.0;
elseif class=="ROGUE" then
ClassColourR,ClassColourG,ClassColourB = 1.0,0.96,0.41;
elseif class=="SHAMAN" then
ClassColourR,ClassColourG,ClassColourB = 0.96,0.55,0.73;
elseif class=="WARLOCK" then
ClassColourR,ClassColourG,ClassColourB = 0.58,0.51,0.79;
elseif class=="WARRIOR" then
ClassColourR,ClassColourG,ClassColourB = 0.78,0.61,0.43;
end
return ClassColourR,ClassColourG,ClassColourB;
end
function HealBot_Action_RefreshTooltip(unit)
if HealBot_Config.ShowTooltip==0 then return end
if not unit then unit = HealBot_Action_TooltipUnit end
if not unit then return end;
local hlth=UnitHealth(unit);
local maxhlth=UnitHealthMax(unit);
local spellLeft = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Left"));
local spellMiddle = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Middle"));
local spellRight = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Right"));
local spellButton4 = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Button4"));
local spellButton5 = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Button5"));
local linenum = 1
HealBot_Action_Tooltip_ClearLines();
if HealBot_Config.Tooltip_ShowTarget==1 then
if UnitName(unit) then
local cr,cg,cb = HealBot_Action_ClassColour(unit);
HealBot_Action_Tooltip_SetLineLeft(UnitName(unit).." ("..UnitClass(unit)..")",cr,cg,cb,linenum)
if hlth and maxhlth then
local r,g,b,a=HealBot_HealthColor(unit,hlth,maxhlth);
HealBot_Action_Tooltip_SetLineRight(hlth.."/"..maxhlth.." (-"..maxhlth-hlth..")",r,g,b,linenum)
end
end
end
if HealBot_Config.Tooltip_ShowSpellDetail==1 then
if spellLeft then
linenum=linenum+2
HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTONLEFT.." "..HEALBOT_OPTIONS_COMBOBUTTON..": "..spellLeft,1,1,0,linenum)
linenum=HealBot_Action_Tooltip_SpellInfo(spellLeft,linenum);
end
if spellMiddle then
linenum=linenum+2
HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTONMIDDLE.." "..HEALBOT_OPTIONS_COMBOBUTTON..": "..spellMiddle,1,1,0,linenum)
linenum=HealBot_Action_Tooltip_SpellInfo(spellMiddle,linenum);
end
if spellRight then
linenum=linenum+2
HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTONRIGHT.." "..HEALBOT_OPTIONS_COMBOBUTTON..": "..spellRight,1,1,0,linenum)
linenum=HealBot_Action_Tooltip_SpellInfo(spellRight,linenum);
end
if spellButton4 then
linenum=linenum+2
HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTON4.." "..HEALBOT_OPTIONS_COMBOBUTTON..": "..spellButton4,1,1,0,linenum)
linenum=HealBot_Action_Tooltip_SpellInfo(spellButton4,linenum);
end
if spellButton5 then
linenum=linenum+2
HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTON5.." "..HEALBOT_OPTIONS_COMBOBUTTON..": "..spellButton5,1,1,0,linenum)
linenum=HealBot_Action_Tooltip_SpellInfo(spellButton5,linenum);
end
else
if spellLeft then
linenum=linenum+1
HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTONLEFT..":",1,1,0,linenum)
HealBot_Action_Tooltip_SetLineRight(HealBot_Action_Tooltip_SpellSummary(spellLeft),1,1,1,linenum)
end
if spellMiddle then
linenum=linenum+1
HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTONMIDDLE..":",1,1,0,linenum)
HealBot_Action_Tooltip_SetLineRight(HealBot_Action_Tooltip_SpellSummary(spellMiddle),1,1,1,linenum)
end
if spellRight then
linenum=linenum+1
HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTONRIGHT..":",1,1,0,linenum)
HealBot_Action_Tooltip_SetLineRight(HealBot_Action_Tooltip_SpellSummary(spellRight),1,1,1,linenum)
end
if spellButton4 then
linenum=linenum+1
HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTON4..":",1,1,0,linenum)
HealBot_Action_Tooltip_SetLineRight(HealBot_Action_Tooltip_SpellSummary(spellButton4),1,1,1,linenum)
end
if spellButton5 then
linenum=linenum+1
HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTON5..":",1,1,0,linenum)
HealBot_Action_Tooltip_SetLineRight(HealBot_Action_Tooltip_SpellSummary(spellButton5),1,1,1,linenum)
end
end
if HealBot_Config.Tooltip_Recommend==1 then
local Instant_check=0;
if HealBot_Config.Tooltip_ShowSpellDetail==1 then linenum=linenum+1; end
linenum=linenum+1
HealBot_Action_Tooltip_SetLineLeft(HEALBOT_TOOLTIP_RECOMMENDTEXT,0.8,0.8,0,linenum)
Instant_check=0;
Instant_check,linenum=HealBot_Action_Tooltip_CheckForInstant(unit,spellLeft,"upd",linenum,Instant_check);
Instant_check,linenum=HealBot_Action_Tooltip_CheckForInstant(unit,spellMiddle,"upd",linenum,Instant_check);
Instant_check,linenum=HealBot_Action_Tooltip_CheckForInstant(unit,spellRight,"upd",linenum,Instant_check);
Instant_check,linenum=HealBot_Action_Tooltip_CheckForInstant(unit,spellButton4,"upd",linenum,Instant_check);
Instant_check,linenum=HealBot_Action_Tooltip_CheckForInstant(unit,spellButton5,"upd",linenum,Instant_check);
if Instant_check==0 then
linenum=linenum+1
HealBot_Action_Tooltip_SetLineLeft(" None",0.4,0.4,0.4,linenum)
end
end
local height = 20
local width = 0
for i = 1, linenum do
local txtL = getglobal("HealBot_TooltipTextL" .. i)
local txtR = getglobal("HealBot_TooltipTextR" .. i)
height = height + txtL:GetHeight() + 2
if (txtL:GetWidth() + txtR:GetWidth() + 25 > width) then
width = txtL:GetWidth() + txtR:GetWidth() + 25
end
end
HealBot_Tooltip:SetWidth(width)
HealBot_Tooltip:SetHeight(height)
HealBot_Tooltip:ClearAllPoints();
if HealBot_Config.TooltipPos>1 then
if HealBot_Config.TooltipPos==2 then
HealBot_Tooltip:SetPoint("TOPRIGHT","HealBot_Action","TOPLEFT",0,0);
elseif HealBot_Config.TooltipPos==3 then
HealBot_Tooltip:SetPoint("TOPLEFT","HealBot_Action","TOPRIGHT",0,0);
elseif HealBot_Config.TooltipPos==4 then
HealBot_Tooltip:SetPoint("BOTTOM","HealBot_Action","TOP",0,0);
else
HealBot_Tooltip:SetPoint("TOP","HealBot_Action","BOTTOM",0,0);
end
else
HealBot_Tooltip:SetPoint("BOTTOMRIGHT","WorldFrame","BOTTOMRIGHT",-105,105);
end
HealBot_Tooltip:Show();
end
function HealBot_Action_Tooltip_SpellInfo(spell,linenum)
local text
if HealBot_Spells[spell] then
if HealBot_Spells[spell].HealsDur>0 then
linenum=linenum+1
HealBot_Action_Tooltip_SetLineLeft(HEALBOT_WORDS_CAST..": "..HealBot_Spells[spell].CastTime.." "..HEALBOT_WORDS_SEC..".",0.8,0.8,0.8,linenum)
HealBot_Action_Tooltip_SetLineRight("Mana: "..HealBot_Spells[spell].Mana,0.5,0.5,1,linenum)
if HealBot_Spells[spell].HealsMax>0 then
local Heals = HEALBOT_HEAL.." "
if HealBot_Spells[spell].Shield then
Heals = HEALBOT_TOOLTIP_SHIELD.." "
end
if HealBot_Spells[spell].HealsMin<HealBot_Spells[spell].HealsMax then
text=Heals..format("%d", HealBot_Spells[spell].HealsMin + HealBot_Spells[spell].RealHealing) .." "..HEALBOT_WORDS_TO.." "..format("%d",HealBot_Spells[spell].HealsMax + HealBot_Spells[spell].RealHealing)
else
text=Heals..format("%d", HealBot_Spells[spell].HealsMax + HealBot_Spells[spell].RealHealing)
end
linenum=linenum+1
HealBot_Action_Tooltip_SetLineLeft(text,1,1,1,linenum)
end
if HealBot_Spells[spell].HealsExt>0 then
text=HEALBOT_HEAL.." "..HealBot_Spells[spell].HealsDur.." "..HEALBOT_WORDS_OVER.." "..HealBot_Spells[spell].Duration-HealBot_Spells[spell].CastTime.." sec."
linenum=linenum+1
HealBot_Action_Tooltip_SetLineLeft(text,1,1,1,linenum)
end
if not HealBot_Spells[spell].Shield then
text=HEALBOT_TOOLTIP_ITEMBONUS.." +"..HealBot_GetBonus().." | "..HEALBOT_TOOLTIP_ACTUALBONUS.." +"..HealBot_Spells[spell].RealHealing.." "
linenum=linenum+1
HealBot_Action_Tooltip_SetLineLeft(text,0.8,0.8,0.8,linenum)
end
end
end
return linenum
end
function HealBot_Action_Tooltip_SpellSummary(spell)
local ret_val = " ";
if HealBot_Spells[spell] then
if HealBot_Spells[spell].HealsDur>0 then
if HealBot_Spells[spell].HealsMax>0 then
local Heals = " "..HEALBOT_HEAL.." ";
if HealBot_Spells[spell].Shield then
Heals = " "..HEALBOT_TOOLTIP_SHIELD.." ";
end
if HealBot_Spells[spell].HealsMin<HealBot_Spells[spell].HealsMax then
ret_val=ret_val..Heals..format("%d", ((HealBot_Spells[spell].HealsMin+HealBot_Spells[spell].HealsMax)/2) + HealBot_Spells[spell].RealHealing);
else
ret_val=ret_val..Heals..format("%d", HealBot_Spells[spell].HealsMax + HealBot_Spells[spell].RealHealing);
end
end
if HealBot_Spells[spell].HealsExt>0 then
ret_val=ret_val.." HoT "..HealBot_Spells[spell].HealsDur;
end
ret_val=ret_val.." "..HEALBOT_WORDS_FOR.." "..HealBot_Spells[spell].Mana.." Mana";
end
end
if string.len(ret_val)<5 then ret_val = " - "..spell; end
return ret_val
end
function HealBot_Action_Tooltip_CheckForInstant(unit,spell,upd,linenum,check)
if HealBot_Spells[spell] then
if HealBot_Spells[spell].CastTime == 0 then
if HealBot_UnitAffected(unit,HealBot_Spells[spell].Buff) then return check,linenum end;
if HealBot_UnitAffected(unit,HealBot_Spells[spell].Debuff) then return check,linenum end;
if upd=="upd" then
linenum=linenum+1
HealBot_Action_Tooltip_SetLineLeft(" "..spell,1,1,1,linenum)
end
else
return check,linenum;
end
else
return check,linenum
end
return check+1,linenum;
end
function HealBot_Action_RefreshDisabledTooltip(unit)
if HealBot_Config.ShowTooltip==0 then return end
if not unit then return end;
local class=UnitClass("Player");
local combo=HealBot_Config.DisKeyCombo[class];
local linenum=1;
local AltKey="";
if IsAltKeyDown() then AltKey="Alt"; end
HealBot_Action_Tooltip_ClearLines();
if HealBot_Config.Tooltip_ShowTarget==1 then
if UnitName(unit) then
local cr,cg,cb = HealBot_Action_ClassColour(unit);
HealBot_Action_Tooltip_SetLineLeft(UnitName(unit),cr,cg,cb,linenum)
HealBot_Action_Tooltip_SetLineRight(UnitClass(unit),cr,cg,cb,linenum)
linenum=linenum+1
end
end
if combo[AltKey.."Left"] then
HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTONLEFT..": "..combo[AltKey.."Left"],1,1,0,linenum)
linenum=linenum+1
end
if combo[AltKey.."Middle"] then
HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTONMIDDLE..": "..combo[AltKey.."Middle"],1,1,0,linenum)
linenum=linenum+1
end
if combo[AltKey.."Right"] then
HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTONRIGHT..": "..combo[AltKey.."Right"],1,1,0,linenum)
end
local height = 20
local width = 0
for i = 1, linenum do
local txtL = getglobal("HealBot_TooltipTextL" .. i)
local txtR = getglobal("HealBot_TooltipTextR" .. i)
height = height + txtL:GetHeight() + 2