vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | local headerno=0; |
2 | |||
3 | HealBot_Action_HealGroup = { |
||
4 | "player", |
||
5 | "pet", |
||
6 | "party1", |
||
7 | "party2", |
||
8 | "party3", |
||
9 | "party4", |
||
10 | }; |
||
11 | |||
12 | HealBot_Action_HealTarget = { |
||
13 | }; |
||
14 | |||
15 | HealBot_Action_HealButtons = { |
||
16 | }; |
||
17 | |||
18 | HealBot_Action_UnitButtons = { |
||
19 | }; |
||
20 | |||
21 | function HealBot_Action_AddDebug(msg) |
||
22 | HealBot_AddDebug("Action: " .. msg); |
||
23 | end |
||
24 | |||
25 | function HealBot_HealthColor(unit,hlth,maxhlth) |
||
26 | if HealBot_UnitDebuff[unit] then |
||
27 | local debuff, tmp, debuff_type = UnitDebuff(unit,1, 1) |
||
28 | if not debuff then |
||
29 | HealBot_UnitDebuff[unit] = nil; |
||
30 | HealBot_UnitDebuff[unit.."_debuff_texture"]=nil |
||
31 | else |
||
32 | return HealBot_Config.CDCBarColour[HealBot_UnitDebuff[unit]].R, |
||
33 | HealBot_Config.CDCBarColour[HealBot_UnitDebuff[unit]].G, |
||
34 | HealBot_Config.CDCBarColour[HealBot_UnitDebuff[unit]].B, |
||
35 | HealBot_Config.Barcola[HealBot_Config.Current_Skin]; |
||
36 | end |
||
37 | end |
||
38 | local text = UnitName(unit); |
||
39 | if not HealBot_HealsIn[text] then |
||
40 | HealBot_HealsIn[text]=0; |
||
41 | end |
||
42 | |||
43 | local pct = hlth+HealBot_HealsIn[text]; |
||
44 | if pct<maxhlth then |
||
45 | pct=pct/maxhlth; |
||
46 | else |
||
47 | pct=1; |
||
48 | end |
||
49 | |||
50 | local r,g,b = 1.0, 1.0, 0.0; |
||
51 | local a=HealBot_Config.Barcola[HealBot_Config.Current_Skin]; |
||
52 | if pct>HealBot_Config.AlertLevel then |
||
53 | a=HealBot_Config.bardisa[HealBot_Config.Current_Skin]; |
||
54 | end |
||
55 | |||
56 | if pct>=0.98 then r = 0.0; end |
||
57 | if pct<0.98 and pct>=0.65 then r=2.94-(pct*3); end |
||
58 | if pct<=0.64 and pct>0.31 then g=(pct-0.31)*3; end |
||
59 | if pct<=0.31 then g = 0.0; end |
||
60 | return r,g,b,a; |
||
61 | end |
||
62 | |||
63 | function HealBot_Action_HealthBar(button) |
||
64 | local name = button:GetName(); |
||
65 | return getglobal(name.."Bar"); |
||
66 | end |
||
67 | |||
68 | function HealBot_Action_HealthBar2(button) |
||
69 | local name = button:GetName(); |
||
70 | return getglobal(name.."Bar2"); |
||
71 | end |
||
72 | |||
73 | function HealBot_AlwaysHeal() |
||
74 | return HealBot_Config.EnableHealthy==1 |
||
75 | end |
||
76 | |||
77 | function HealBot_MayHeal(unit) |
||
78 | if not UnitName(unit) or not HealBot_Heals[unit] then return false end |
||
79 | if unit ~= 'target' then return true end |
||
80 | if not HealBot_Config.TargetHeals or UnitCanAttack("player",unit) then return false end |
||
81 | return true; |
||
82 | end |
||
83 | |||
84 | function HealBot_ShouldHeal(unit) |
||
85 | if HealBot_UnitDebuff[unit] and not UnitIsDeadOrGhost(unit) then |
||
86 | if HealBot_Range_Check(unit, 30)==1 then |
||
87 | return true; |
||
88 | end |
||
89 | end |
||
90 | return HealBot_MayHeal(unit) and UnitHealth(unit)>0 and not UnitIsDeadOrGhost(unit) |
||
91 | and (UnitHealth(unit)<UnitHealthMax(unit)*HealBot_Config.AlertLevel or HealBot_AlwaysHeal()); |
||
92 | end |
||
93 | |||
94 | function HealBot_Action_ShouldHealSome() |
||
95 | return table.foreach(HealBot_Action_HealButtons, function (index,button) |
||
96 | if (HealBot_ShouldHeal(button.unit)) then return button.unit; end |
||
97 | end); |
||
98 | end |
||
99 | |||
100 | function HealBot_MustHeal(unit) |
||
101 | return HealBot_ShouldHeal(unit) and UnitHealth(unit)<UnitHealthMax(unit)*HealBot_Config.AlertLevel |
||
102 | end |
||
103 | |||
104 | function HealBot_Action_MustHealSome() |
||
105 | return table.foreach(HealBot_Action_HealButtons, function (index,button) |
||
106 | if (HealBot_MustHeal(button.unit)) then return button.unit; end |
||
107 | end); |
||
108 | end |
||
109 | |||
110 | function HealBot_CanHeal(unit) |
||
111 | local SHeal = HealBot_ShouldHeal(unit) |
||
112 | if SHeal then |
||
113 | local spell = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Left")) |
||
114 | if not spell then spell = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Middle")) end |
||
115 | if not spell then spell = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Right")) end |
||
116 | if not spell then spell = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Button4")) end |
||
117 | if not spell then spell = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Button5")) end |
||
118 | if not spell then |
||
119 | return false |
||
120 | else |
||
121 | return true |
||
122 | end |
||
123 | end |
||
124 | return false |
||
125 | end |
||
126 | |||
127 | function HealBot_Action_EnableButton(button) |
||
128 | local unit = button.unit; |
||
129 | local hlth=UnitHealth(unit); |
||
130 | local maxhlth=UnitHealthMax(unit); |
||
131 | local name = UnitName(unit); |
||
132 | local bar = HealBot_Action_HealthBar(button); |
||
133 | local bar2 = HealBot_Action_HealthBar2(button); |
||
134 | local btexture=HealBot_Config.btexture[HealBot_Config.Current_Skin]; |
||
135 | local bheight=HealBot_Config.bheight[HealBot_Config.Current_Skin]; |
||
136 | local sr=HealBot_Config.btextenabledcolr[HealBot_Config.Current_Skin]; |
||
137 | local sg=HealBot_Config.btextenabledcolg[HealBot_Config.Current_Skin]; |
||
138 | local sb=HealBot_Config.btextenabledcolb[HealBot_Config.Current_Skin]; |
||
139 | local sa=HealBot_Config.btextenabledcola[HealBot_Config.Current_Skin]; |
||
140 | local r,g,b,a = HealBot_HealthColor(button.unit,hlth,maxhlth) |
||
141 | local btextheight=HealBot_Config.btextheight[HealBot_Config.Current_Skin] |
||
142 | local bwidth = HealBot_Config.bwidth[HealBot_Config.Current_Skin] |
||
143 | local textlen = floor(5+(((bwidth*1.8)/btextheight)-(btextheight/2))) |
||
144 | |||
145 | bar:SetMinMaxValues(0,maxhlth); |
||
146 | bar:SetValue(hlth); |
||
147 | if HealBot_HealsIn[name] then |
||
148 | bar2:SetMinMaxValues(0,maxhlth); |
||
149 | bar2:SetValue(hlth+HealBot_HealsIn[name]); |
||
150 | else |
||
151 | bar2:SetValue(0); |
||
152 | end |
||
153 | bar.txt = getglobal(bar:GetName().."_text"); |
||
154 | if (not HealBot_IsCasting and HealBot_CanHeal(unit)) then |
||
155 | button:Enable(); |
||
156 | bar:SetStatusBarColor(r,g,b,HealBot_Config.Barcola[HealBot_Config.Current_Skin]); |
||
157 | bar2:SetStatusBarColor(r,g,b,HealBot_Config.BarcolaInHeal[HealBot_Config.Current_Skin]); |
||
158 | if HealBot_UnitDebuff[unit] then |
||
159 | sr=HealBot_Config.btextcursecolr[HealBot_Config.Current_Skin]; |
||
160 | sg=HealBot_Config.btextcursecolg[HealBot_Config.Current_Skin]; |
||
161 | sb=HealBot_Config.btextcursecolb[HealBot_Config.Current_Skin]; |
||
162 | sa=HealBot_Config.btextcursecola[HealBot_Config.Current_Skin]; |
||
163 | end |
||
164 | else |
||
165 | button:Disable(); |
||
166 | sr=HealBot_Config.btextdisbledcolr[HealBot_Config.Current_Skin]; |
||
167 | sg=HealBot_Config.btextdisbledcolg[HealBot_Config.Current_Skin]; |
||
168 | sb=HealBot_Config.btextdisbledcolb[HealBot_Config.Current_Skin]; |
||
169 | sa=HealBot_Config.btextdisbledcola[HealBot_Config.Current_Skin]; |
||
170 | bar:SetStatusBarColor(r,g,b,HealBot_Config.bardisa[HealBot_Config.Current_Skin]); |
||
171 | bar2:SetStatusBarColor(r,g,b,HealBot_Config.bardisa[HealBot_Config.Current_Skin]); |
||
172 | end |
||
173 | if string.len(name)>textlen then |
||
174 | name = string.sub(name,1,textlen-3) .. '...'; |
||
175 | end |
||
176 | bar.txt:SetText(name); |
||
177 | bar.txt:SetTextColor(sr,sg,sb,sa); |
||
178 | end |
||
179 | |||
180 | function HealBot_Action_EnableButtons() |
||
181 | table.foreach(HealBot_Action_HealButtons, function (index,button) |
||
182 | HealBot_Action_EnableButton(button); |
||
183 | end); |
||
184 | end |
||
185 | |||
186 | function HealBot_Action_RefreshButton(button) |
||
187 | if not button then return end |
||
188 | if type(button)~="table" then DEFAULT_CHAT_FRAME:AddMessage("***** "..type(button)) end |
||
189 | local unit = button.unit; |
||
190 | if HealBot_MayHeal(unit) then |
||
191 | HealBot_Action_EnableButton(button) |
||
192 | end |
||
193 | end |
||
194 | |||
195 | function HealBot_Action_ResetSkin() |
||
196 | HealBot_Action_PartyChanged() |
||
197 | if HealBot_Options:IsVisible() then |
||
198 | HealBot_DiseaseColorpick:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..HealBot_Config.btexture[HealBot_Config.Current_Skin]); |
||
199 | HealBot_MagicColorpick:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..HealBot_Config.btexture[HealBot_Config.Current_Skin]); |
||
200 | HealBot_PoisonColorpick:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..HealBot_Config.btexture[HealBot_Config.Current_Skin]); |
||
201 | HealBot_CurseColorpick:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..HealBot_Config.btexture[HealBot_Config.Current_Skin]); |
||
202 | HealBot_EnTextColorpick:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..HealBot_Config.btexture[HealBot_Config.Current_Skin]); |
||
203 | HealBot_EnTextColorpickin:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..HealBot_Config.btexture[HealBot_Config.Current_Skin]); |
||
204 | HealBot_DisTextColorpick:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..HealBot_Config.btexture[HealBot_Config.Current_Skin]); |
||
205 | HealBot_DebTextColorpick:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..HealBot_Config.btexture[HealBot_Config.Current_Skin]); |
||
206 | HealBot_SetSkinColours() |
||
207 | end |
||
208 | end |
||
209 | |||
210 | function HealBot_Action_RefreshButtons() |
||
211 | table.foreach(HealBot_Action_HealButtons, function (index,button) |
||
212 | HealBot_Action_RefreshButton(button); |
||
213 | end); |
||
214 | end |
||
215 | |||
216 | function HealBot_Action_RefreshButtons(unit) |
||
217 | if unit and HealBot_Action_UnitButtons[unit] then |
||
218 | table.foreach(HealBot_Action_UnitButtons[unit], function (index,button) |
||
219 | HealBot_Action_RefreshButton(button); |
||
220 | end); |
||
221 | else |
||
222 | table.foreach(HealBot_Action_HealButtons, function (index,button) |
||
223 | HealBot_Action_RefreshButton(button); |
||
224 | end); |
||
225 | end |
||
226 | end |
||
227 | |||
228 | function HealBot_Action_PositionButton(button,OsetX,OsetY,bwidth,bheight,checked,header) |
||
229 | local brspace=HealBot_Config.brspace[HealBot_Config.Current_Skin] or 3; |
||
230 | if header then |
||
231 | headerno=headerno+1; |
||
232 | local headerobj=getglobal("HealBot_Action_Header"..headerno); |
||
233 | local tmpY=OsetY |
||
234 | headerobj:SetText(header) |
||
235 | headerobj:Show(); |
||
236 | headerobj:ClearAllPoints(); |
||
237 | headerobj:SetHeight(bheight); |
||
238 | headerobj:SetWidth(bwidth); |
||
239 | headerobj:SetPoint("TOPLEFT","HealBot_Action","TOPLEFT",OsetX,-OsetY); |
||
240 | headerobj:Disable(); |
||
241 | OsetY = OsetY+headerobj:GetHeight()+brspace; |
||
242 | else |
||
243 | local unit = button.unit; |
||
244 | button:SetText(" "); |
||
245 | if (HealBot_MayHeal(unit)) then |
||
246 | button:Show(); |
||
247 | button:ClearAllPoints(); |
||
248 | button:SetHeight(bheight); |
||
249 | if checked then |
||
250 | button:SetWidth(bwidth-14); |
||
251 | button:SetPoint("TOPLEFT","HealBot_Action","TOPLEFT",OsetX+14,-OsetY); |
||
252 | else |
||
253 | button:SetWidth(bwidth); |
||
254 | button:SetPoint("TOPLEFT","HealBot_Action","TOPLEFT",OsetX,-OsetY); |
||
255 | end |
||
256 | OsetY = OsetY+button:GetHeight()+brspace; |
||
257 | else |
||
258 | button:Hide(); |
||
259 | end |
||
260 | end |
||
261 | return OsetY; |
||
262 | end |
||
263 | |||
264 | function HealBot_Action_SetHeightWidth(width,height,bwidth) |
||
265 | if HealBot_ActionHeight then |
||
266 | HealBot_Action:SetHeight(HealBot_ActionHeight); |
||
267 | end |
||
268 | if HealBot_Config.GrowUpwards==1 then |
||
269 | local left,bottom = HealBot_Action:GetLeft(),HealBot_Action:GetBottom(); |
||
270 | if left and bottom then |
||
271 | if HealBot_Config.PanelAnchorX==-1 then HealBot_Config.PanelAnchorX=left; end |
||
272 | if HealBot_Config.PanelAnchorY==-1 then HealBot_Config.PanelAnchorY=bottom; end |
||
273 | HealBot_Action:ClearAllPoints(); |
||
274 | HealBot_Action:SetPoint("BOTTOMLEFT","UIParent","BOTTOMLEFT",HealBot_Config.PanelAnchorX,HealBot_Config.PanelAnchorY); |
||
275 | end |
||
276 | else |
||
277 | local left,top = HealBot_Action:GetLeft(),HealBot_Action:GetTop(); |
||
278 | if left and top then |
||
279 | HealBot_Action:ClearAllPoints(); |
||
280 | HealBot_Action:SetPoint("TOPLEFT","UIParent","BOTTOMLEFT",left,top); |
||
281 | end |
||
282 | end |
||
283 | HealBot_Action:SetHeight(height); |
||
284 | HealBot_ActionHeight = height; |
||
285 | HealBot_Action:SetWidth(width+bwidth+10) |
||
286 | end |
||
287 | |||
288 | function HealBot_Action_SetHealButton(index,unit) |
||
289 | if not index then |
||
290 | HealBot_Action_HealButtons = {}; |
||
291 | HealBot_Action_UnitButtons = {}; |
||
292 | return nil |
||
293 | end |
||
294 | local button = getglobal("HealBot_Action_HealUnit"..index); |
||
295 | button.unit = unit; |
||
296 | if unit then |
||
297 | table.insert(HealBot_Action_HealButtons,button); |
||
298 | if not HealBot_Action_UnitButtons[unit] then HealBot_Action_UnitButtons[unit] = {} end |
||
299 | table.insert(HealBot_Action_UnitButtons[unit],button); |
||
300 | else |
||
301 | button:Hide(); |
||
302 | end |
||
303 | return button; |
||
304 | end |
||
305 | |||
306 | function HealBot_Action_PartyChanged() |
||
307 | |||
308 | if not HealBot_IsFighting then |
||
309 | |||
310 | local numBars = 0; |
||
311 | local numHeaders = 0; |
||
312 | local TempMaxH=0; |
||
313 | local HeaderPos = {}; |
||
314 | |||
315 | for j=1,15 do |
||
316 | local headerobj=getglobal("HealBot_Action_Header"..j); |
||
317 | headerobj:SetText(" ") |
||
318 | headerobj:Hide(); |
||
319 | end |
||
320 | |||
321 | local bwidth = HealBot_Config.bwidth[HealBot_Config.Current_Skin] or 85; |
||
322 | local sr=HealBot_Config.btextdisbledcolr[HealBot_Config.Current_Skin] or 0.4; |
||
323 | local sg=HealBot_Config.btextdisbledcolg[HealBot_Config.Current_Skin] or 0.4; |
||
324 | local sb=HealBot_Config.btextdisbledcolb[HealBot_Config.Current_Skin] or 0.4; |
||
325 | local sa=HealBot_Config.btextdisbledcola[HealBot_Config.Current_Skin] or 0.6; |
||
326 | local bheight=HealBot_Config.bheight[HealBot_Config.Current_Skin] or 18; |
||
327 | local btexture=HealBot_Config.btexture[HealBot_Config.Current_Skin] or 5; |
||
328 | local bcspace=HealBot_Config.bcspace[HealBot_Config.Current_Skin] or 4; |
||
329 | local cols=HealBot_Config.numcols[HealBot_Config.Current_Skin] or 2; |
||
330 | local btextheight=HealBot_Config.btextheight[HealBot_Config.Current_Skin] or 10; |
||
331 | local abortsize=HealBot_Config.abortsize[HealBot_Config.Current_Skin] or 10; |
||
332 | local checked_start=0; |
||
333 | local checked_end=0; |
||
334 | headerno=0; |
||
335 | |||
336 | for j=1,41 do |
||
337 | HealBot_Action_SetHealButton(j,nil); |
||
338 | end |
||
339 | for j=51,60 do |
||
340 | HealBot_Action_SetHealButton(j,nil); |
||
341 | end |
||
342 | HealBot_Action_SetHealButton(); |
||
343 | local i = 0; |
||
344 | local last = 0; |
||
345 | local GroupValid=numBars; |
||
346 | last = last+6 |
||
347 | if HealBot_Config.GroupHeals==1 then |
||
348 | if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then |
||
349 | HeaderPos[i+1] = HEALBOT_OPTIONS_GROUPHEALS |
||
350 | end |
||
351 | for _,unit in ipairs(HealBot_Action_HealGroup) do |
||
352 | if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then |
||
353 | i = i+1; |
||
354 | HealBot_Action_SetHealButton(i,unit); |
||
355 | numBars=numBars+1; |
||
356 | end |
||
357 | if i==last then break end |
||
358 | end |
||
359 | end |
||
360 | if numBars>GroupValid and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then |
||
361 | numBars=numBars+1; |
||
362 | numHeaders=numHeaders+1; |
||
363 | end |
||
364 | |||
365 | last = last+10 |
||
366 | local TankValid=numBars; |
||
367 | if HealBot_Config.TankHeals==1 then |
||
368 | if GetNumRaidMembers()>0 and CT_RA_MainTanks then |
||
369 | if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then |
||
370 | HeaderPos[i+1] = HEALBOT_OPTIONS_TANKHEALS |
||
371 | end |
||
372 | for j=1,10 do |
||
373 | if CT_RA_MainTanks[j] then |
||
374 | for k=1,GetNumRaidMembers() do |
||
375 | local unit = "raid"..k; |
||
376 | local PossibleMT=1; |
||
377 | if UnitInParty(unit) and HealBot_Config.GroupHeals==1 then |
||
378 | if not UnitIsUnit(unit, "player") then |
||
379 | PossibleMT=0; |
||
380 | end |
||
381 | end |
||
382 | if PossibleMT==1 then |
||
383 | if UnitName(unit)==CT_RA_MainTanks[j] then |
||
384 | if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then |
||
385 | i = i+1; |
||
386 | HealBot_Action_SetHealButton(i,unit); |
||
387 | numBars=numBars+1; |
||
388 | end |
||
389 | end |
||
390 | end |
||
391 | end |
||
392 | end |
||
393 | if i==last then break end |
||
394 | end |
||
395 | end |
||
396 | end |
||
397 | if numBars>TankValid and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then |
||
398 | numBars=numBars+1; |
||
399 | numHeaders=numHeaders+1; |
||
400 | end |
||
401 | |||
402 | last = last+10; |
||
403 | local h=50; |
||
404 | local TargetValid=numBars; |
||
405 | if HealBot_Config.TargetHeals==1 then |
||
406 | if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then |
||
407 | HeaderPos[i+1] = HEALBOT_OPTIONS_TARGETHEALS |
||
408 | end |
||
409 | for _,unit in ipairs(HealBot_Action_HealTarget) do |
||
410 | if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then |
||
411 | i = i+1; |
||
412 | h = h+1; |
||
413 | if checked_start==0 then checked_start=i; end |
||
414 | checked_end=i; |
||
415 | HealBot_Action_SetHealButton(h,unit); |
||
416 | local check = getglobal("HealBot_Action_HealUnit"..h.."Check"); |
||
417 | check.unit = unit; |
||
418 | check:SetChecked(1); |
||
419 | check:Show(); |
||
420 | numBars=numBars+1; |
||
421 | end |
||
422 | if i==last then break end |
||
423 | end |
||
424 | |||
425 | last = last+1 |
||
426 | unit = HealBot_TargetName() |
||
427 | if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal("target") then |
||
428 | i = i+1; |
||
429 | h = h+1; |
||
430 | if h<61 then |
||
431 | HealBot_Action_SetHealButton(h,"target"); |
||
432 | local check = getglobal("HealBot_Action_HealUnit"..h.."Check"); |
||
433 | |||
434 | check:SetChecked(0); |
||
435 | check.unit = unit; |
||
436 | if check.unit then |
||
437 | if checked_start==0 then checked_start=i; end |
||
438 | checked_end=i; |
||
439 | check:Show(); |
||
440 | else |
||
441 | check:Hide(); |
||
442 | end |
||
443 | else |
||
444 | HealBot_Action_SetHealButton(i,"target"); |
||
445 | end |
||
446 | numBars=numBars+1; |
||
447 | end |
||
448 | end |
||
449 | if numBars>TargetValid and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then |
||
450 | numBars=numBars+1; |
||
451 | numHeaders=numHeaders+1; |
||
452 | end |
||
453 | |||
454 | last = last+40 |
||
455 | local ExtraValid=numBars; |
||
456 | if HealBot_Config.EmergencyHeals==1 then |
||
457 | local order = {}; |
||
458 | local units = {}; |
||
459 | if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 and HealBot_Config.ExtraOrder==1 then |
||
460 | HeaderPos[i+1] = HEALBOT_OPTIONS_EMERGENCYHEALS |
||
461 | numBars=numBars+1; |
||
462 | numHeaders=numHeaders+1; |
||
463 | end |
||
464 | if HealBot_Config.EmergIncMonitor==1 then |
||
465 | if GetNumRaidMembers()>0 then |
||
466 | for j=1,40 do |
||
467 | local PossibleEmerg=1; |
||
468 | local unit = "raid"..j; |
||
469 | local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(j); |
||
470 | if not name then name="not known" end |
||
471 | if not class then class="not known" end |
||
472 | if not subgroup then subgroup="not known" end |
||
473 | |||
474 | if UnitInParty(unit) and HealBot_Config.GroupHeals==1 then |
||
475 | PossibleEmerg=0; |
||
476 | end |
||
477 | if PossibleEmerg==1 then |
||
478 | if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then |
||
479 | if HealBot_Config.ExtraOrder==1 then |
||
480 | order[unit] = name; |
||
481 | elseif HealBot_Config.ExtraOrder==2 then |
||
482 | order[unit] = class; |
||
483 | elseif HealBot_Config.ExtraOrder==3 then |
||
484 | order[unit] = subgroup; |
||
485 | else |
||
486 | order[unit] = 0-UnitHealthMax(unit); |
||
487 | if UnitHealthMax(unit)>TempMaxH then TempMaxH=UnitHealthMax(unit); end |
||
488 | end |
||
489 | table.insert(units,unit); |
||
490 | numBars=numBars+1; |
||
491 | end |
||
492 | end |
||
493 | end |
||
494 | else |
||
495 | for _,unit in ipairs(HealBot_Action_HealGroup) do |
||
496 | if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then |
||
497 | if HealBot_Config.ExtraOrder==1 then |
||
498 | order[unit] = name; |
||
499 | elseif HealBot_Config.ExtraOrder==2 then |
||
500 | order[unit] = class; |
||
501 | elseif HealBot_Config.ExtraOrder==3 then |
||
502 | order[unit] = subgroup; |
||
503 | else |
||
504 | order[unit] = 0-UnitHealthMax(unit); |
||
505 | if UnitHealthMax(unit)>TempMaxH then TempMaxH=UnitHealthMax(unit); end |
||
506 | end |
||
507 | table.insert(units,unit); |
||
508 | numBars=numBars+1; |
||
509 | end |
||
510 | end |
||
511 | end |
||
512 | else |
||
513 | if GetNumRaidMembers()>0 then |
||
514 | for j=1,40 do |
||
515 | |||
516 | local unit = "raid"..j; |
||
517 | local Class = UnitClass(unit); |
||
518 | local ProcessUnit = 0; |
||
519 | local PossibleEmerg=1; |
||
520 | local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(j); |
||
521 | if not name then name="not known" end |
||
522 | if not class then class="not known" end |
||
523 | if not subgroup then subgroup="not known" end |
||
524 | |||
525 | if HealBot_EmergInc[Class]==1 then |
||
526 | ProcessUnit = 1; |
||
527 | end |
||
528 | if UnitInParty(unit) and HealBot_Config.GroupHeals==1 then |
||
529 | PossibleEmerg=0; |
||
530 | end |
||
531 | |||
532 | if ProcessUnit==1 and PossibleEmerg==1 then |
||
533 | if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then |
||
534 | if HealBot_Config.ExtraOrder==1 then |
||
535 | order[unit] = name; |
||
536 | elseif HealBot_Config.ExtraOrder==2 then |
||
537 | order[unit] = class; |
||
538 | elseif HealBot_Config.ExtraOrder==3 then |
||
539 | order[unit] = subgroup; |
||
540 | else |
||
541 | order[unit] = 0-UnitHealthMax(unit); |
||
542 | if UnitHealthMax(unit)>TempMaxH then TempMaxH=UnitHealthMax(unit); end |
||
543 | end |
||
544 | table.insert(units,unit); |
||
545 | numBars=numBars+1; |
||
546 | end |
||
547 | end |
||
548 | end |
||
549 | else |
||
550 | for _,unit in ipairs(HealBot_Action_HealGroup) do |
||
551 | if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then |
||
552 | if HealBot_Config.ExtraOrder==1 then |
||
553 | order[unit] = name; |
||
554 | elseif HealBot_Config.ExtraOrder==2 then |
||
555 | order[unit] = class; |
||
556 | elseif HealBot_Config.ExtraOrder==3 then |
||
557 | order[unit] = subgroup; |
||
558 | else |
||
559 | order[unit] = 0-UnitHealthMax(unit); |
||
560 | if UnitHealthMax(unit)>TempMaxH then TempMaxH=UnitHealthMax(unit); end |
||
561 | end |
||
562 | table.insert(units,unit); |
||
563 | numBars=numBars+1; |
||
564 | end |
||
565 | end |
||
566 | end |
||
567 | end |
||
568 | table.sort(units,function (a,b) |
||
569 | if order[a]<order[b] then return true end |
||
570 | if order[a]>order[b] then return false end |
||
571 | return a<b |
||
572 | end) |
||
573 | local TempSort="init" |
||
574 | TempMaxH=ceil(TempMaxH/1000)*1000; |
||
575 | |||
576 | if GetNumRaidMembers()>0 then |
||
577 | for j=1,40 do |
||
578 | if not units[j] then break end |
||
579 | local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(strsub(units[j], 5)); |
||
580 | if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 and HealBot_Config.ExtraOrder==2 and TempSort~=class then |
||
581 | TempSort=class |
||
582 | HeaderPos[i+1] = class |
||
583 | numBars=numBars+1; |
||
584 | numHeaders=numHeaders+1; |
||
585 | end |
||
586 | if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 and HealBot_Config.ExtraOrder==3 and TempSort~=subgroup then |
||
587 | TempSort=subgroup |
||
588 | HeaderPos[i+1] = HEALBOT_OPTIONS_GROUPHEALS..subgroup |
||
589 | numBars=numBars+1; |
||
590 | numHeaders=numHeaders+1; |
||
591 | end |
||
592 | if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 and HealBot_Config.ExtraOrder==4 and TempMaxH>UnitHealthMax(units[j]) then |
||
593 | TempMaxH=TempMaxH-1000 |
||
594 | HeaderPos[i+1] = ">"..tostring(TempMaxH/1000).."k" |
||
595 | numBars=numBars+1; |
||
596 | numHeaders=numHeaders+1; |
||
597 | end |
||
598 | i = i+1; |
||
599 | HealBot_Action_SetHealButton(i,units[j]); |
||
600 | if i==last then break end |
||
601 | end |
||
602 | end |
||
603 | end |
||
604 | if numBars==ExtraValid+1 and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then |
||
605 | HeaderPos[i+1] = nil; |
||
606 | numBars=numBars-1; |
||
607 | end |
||
608 | |||
609 | OffsetY = 10; |
||
610 | OffsetX = 10; |
||
611 | MaxOffsetY=0; |
||
612 | |||
613 | if cols>(numBars-numHeaders) then |
||
614 | cols=numBars-numHeaders; |
||
615 | end |
||
616 | |||
617 | local h=1; |
||
618 | local i=0; |
||
619 | local z=1; |
||
620 | |||
621 | table.foreach(HealBot_Action_HealButtons, function (index,button) |
||
622 | i=i+1; |
||
623 | local checked=false; |
||
624 | local header; |
||
625 | |||
626 | if HeaderPos[i] then |
||
627 | header=HeaderPos[i]; |
||
628 | OffsetY = HealBot_Action_PositionButton(nil,OffsetX,OffsetY,bwidth,bheight,checked,header); |
||
629 | if h==ceil((numBars)/cols) and z<numBars then |
||
630 | h=0; |
||
631 | if MaxOffsetY<OffsetY then MaxOffsetY = OffsetY; end |
||
632 | OffsetY = 10; |
||
633 | OffsetX = OffsetX + bwidth+bcspace; |
||
634 | -- z=z+1; |
||
635 | end |
||
636 | h=h+1; |
||
637 | z=z+1; |
||
638 | end |
||
639 | |||
640 | if checked_start<=i and checked_end>=i then checked=true; end |
||
641 | OffsetY = HealBot_Action_PositionButton(button,OffsetX,OffsetY,bwidth,bheight,checked,nil); |
||
642 | if h==ceil((numBars)/cols) and z<numBars then |
||
643 | h=0; |
||
644 | if MaxOffsetY<OffsetY then MaxOffsetY = OffsetY; end |
||
645 | OffsetY = 10; |
||
646 | OffsetX = OffsetX + bwidth+bcspace; |
||
647 | end |
||
648 | z=z+1; |
||
649 | h=h+1; |
||
650 | local bar = HealBot_Action_HealthBar(button); |
||
651 | local bar2 = HealBot_Action_HealthBar2(button); |
||
652 | bar.txt = getglobal(bar:GetName().."_text"); |
||
653 | bar:SetHeight(bheight); |
||
654 | bar:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..btexture); |
||
655 | bar.txt:SetTextHeight(btextheight); |
||
656 | local barScale = bar:GetScale(); |
||
657 | bar:SetScale(barScale + 0.01); |
||
658 | bar:SetScale(barScale); |
||
659 | bar2:SetHeight(bheight); |
||
660 | bar2:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..btexture); |
||
661 | end); |
||
662 | |||
663 | if MaxOffsetY<OffsetY then MaxOffsetY = OffsetY; end |
||
664 | |||
665 | if HealBot_Config.HideOptions==1 then |
||
666 | HealBot_Action_OptionsButton:Hide(); |
||
667 | else |
||
668 | HealBot_Action_OptionsButton:SetPoint("BOTTOM","HealBot_Action","BOTTOM",0,10); |
||
669 | HealBot_Action_OptionsButton:Show(); |
||
670 | MaxOffsetY = MaxOffsetY+30; |
||
671 | end |
||
672 | |||
673 | if HealBot_Config.HideAbort==1 then |
||
674 | HealBot_Action_AbortButton:Hide(); |
||
675 | else |
||
676 | local bar = HealBot_Action_HealthBar(HealBot_Action_AbortButton); |
||
677 | local width=(bwidth-12)+(OffsetX/(6-(abortsize/3))); |
||
678 | |||
679 | bar.txt = getglobal(bar:GetName().."_text"); |
||
680 | bar.txt:SetTextColor(sr,sg,sb,sa); |
||
681 | bar.txt:SetText(HEALBOT_ACTION_ABORT); |
||
682 | bar:SetStatusBarTexture("Interface\\AddOns\\HealBot\\images\\bar"..btexture); |
||
683 | bar:SetMinMaxValues(0,100); |
||
684 | bar:SetValue(100); |
||
685 | bar:ClearAllPoints(); |
||
686 | bar:SetHeight(bheight+abortsize); |
||
687 | bar:SetWidth(width); |
||
688 | bar:SetStatusBarColor(0.1,0.1,0.4,0); |
||
689 | MaxOffsetY = MaxOffsetY+30+abortsize; |
||
690 | HealBot_Action_AbortButton:ClearAllPoints(); |
||
691 | HealBot_Action_AbortButton:SetWidth(width) |
||
692 | HealBot_Action_AbortButton:SetHeight(bheight+abortsize); |
||
693 | if HealBot_Config.HideOptions==1 then |
||
694 | HealBot_Action_AbortButton:SetPoint("BOTTOM","HealBot_Action","BOTTOM",0,10); |
||
695 | bar:SetPoint("BOTTOM","HealBot_Action","BOTTOM",0,10); |
||
696 | else |
||
697 | HealBot_Action_AbortButton:SetPoint("BOTTOM","HealBot_Action_OptionsButton","TOP",0,10); |
||
698 | bar:SetPoint("BOTTOM","HealBot_Action_OptionsButton","TOP",0,10); |
||
699 | end |
||
700 | HealBot_Action_AbortButton:Show(); |
||
701 | end |
||
702 | |||
703 | |||
704 | |||
705 | HealBot_Action_SetHeightWidth(OffsetX, MaxOffsetY+10, bwidth); |
||
706 | end |
||
707 | HealBot_Action_RefreshButtons(); |
||
708 | end |
||
709 | |||
710 | function HealBot_Action_Reset() |
||
711 | HealBot_Action:ClearAllPoints(); |
||
712 | HealBot_Action:SetPoint("TOP","MinimapCluster","BOTTOM",7,10); |
||
713 | HealBot_Action_HealTarget = {}; |
||
714 | HealBot_Action_PartyChanged(); |
||
715 | end |
||
716 | |||
717 | function HealBot_Action_RefreshTooltip(unit) |
||
718 | if HealBot_Config.ShowTooltip==0 then return end |
||
719 | if not unit then unit = HealBot_Action_TooltipUnit end |
||
720 | if not unit then return end; |
||
721 | |||
722 | local hlth=UnitHealth(unit); |
||
723 | local maxhlth=UnitHealthMax(unit); |
||
724 | |||
725 | local spellLeft = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Left")); |
||
726 | local spellMiddle = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Middle")); |
||
727 | local spellRight = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Right")); |
||
728 | local spellButton4 = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Button4")); |
||
729 | local spellButton5 = HealBot_GetHealSpell(unit,HealBot_Action_SpellPattern("Button5")); |
||
730 | local linenum = 1 |
||
731 | |||
732 | HealBot_Action_Tooltip_ClearLines(); |
||
733 | |||
734 | if HealBot_Config.Tooltip_ShowTarget==1 then |
||
735 | if UnitName(unit) then |
||
736 | HealBot_Action_Tooltip_SetLineLeft(UnitName(unit),0,1,0,linenum) |
||
737 | if hlth and maxhlth then |
||
738 | local r,g,b,a=HealBot_HealthColor(unit,hlth,maxhlth); |
||
739 | HealBot_Action_Tooltip_SetLineRight(hlth.."/"..maxhlth.." (-"..maxhlth-hlth..")",r,g,b,linenum) |
||
740 | end |
||
741 | end |
||
742 | end |
||
743 | |||
744 | if HealBot_Config.Tooltip_ShowSpellDetail==1 then |
||
745 | |||
746 | if spellLeft then |
||
747 | linenum=linenum+2 |
||
748 | HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTONLEFT.." "..HEALBOT_OPTIONS_COMBOBUTTON..": "..spellLeft,1,1,0,linenum) |
||
749 | linenum=HealBot_Action_Tooltip_SpellInfo(spellLeft,linenum); |
||
750 | end |
||
751 | if spellMiddle then |
||
752 | linenum=linenum+2 |
||
753 | HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTONMIDDLE.." "..HEALBOT_OPTIONS_COMBOBUTTON..": "..spellMiddle,1,1,0,linenum) |
||
754 | linenum=HealBot_Action_Tooltip_SpellInfo(spellMiddle,linenum); |
||
755 | end |
||
756 | if spellRight then |
||
757 | linenum=linenum+2 |
||
758 | HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTONRIGHT.." "..HEALBOT_OPTIONS_COMBOBUTTON..": "..spellRight,1,1,0,linenum) |
||
759 | linenum=HealBot_Action_Tooltip_SpellInfo(spellRight,linenum); |
||
760 | end |
||
761 | if spellButton4 then |
||
762 | linenum=linenum+2 |
||
763 | HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTON4.." "..HEALBOT_OPTIONS_COMBOBUTTON..": "..spellButton4,1,1,0,linenum) |
||
764 | linenum=HealBot_Action_Tooltip_SpellInfo(spellButton4,linenum); |
||
765 | end |
||
766 | if spellButton5 then |
||
767 | linenum=linenum+2 |
||
768 | HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTON5.." "..HEALBOT_OPTIONS_COMBOBUTTON..": "..spellButton5,1,1,0,linenum) |
||
769 | linenum=HealBot_Action_Tooltip_SpellInfo(spellButton5,linenum); |
||
770 | end |
||
771 | else |
||
772 | if spellLeft then |
||
773 | linenum=linenum+1 |
||
774 | HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTONLEFT..":",1,1,0,linenum) |
||
775 | HealBot_Action_Tooltip_SetLineRight(HealBot_Action_Tooltip_SpellSummary(spellLeft),1,1,1,linenum) |
||
776 | end |
||
777 | if spellMiddle then |
||
778 | linenum=linenum+1 |
||
779 | HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTONMIDDLE..":",1,1,0,linenum) |
||
780 | HealBot_Action_Tooltip_SetLineRight(HealBot_Action_Tooltip_SpellSummary(spellMiddle),1,1,1,linenum) |
||
781 | end |
||
782 | if spellRight then |
||
783 | linenum=linenum+1 |
||
784 | HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTONRIGHT..":",1,1,0,linenum) |
||
785 | HealBot_Action_Tooltip_SetLineRight(HealBot_Action_Tooltip_SpellSummary(spellRight),1,1,1,linenum) |
||
786 | end |
||
787 | if spellButton4 then |
||
788 | linenum=linenum+1 |
||
789 | HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTON4..":",1,1,0,linenum) |
||
790 | HealBot_Action_Tooltip_SetLineRight(HealBot_Action_Tooltip_SpellSummary(spellButton4),1,1,1,linenum) |
||
791 | end |
||
792 | if spellButton5 then |
||
793 | linenum=linenum+1 |
||
794 | HealBot_Action_Tooltip_SetLineLeft(HEALBOT_OPTIONS_BUTTON5..":",1,1,0,linenum) |
||
795 | HealBot_Action_Tooltip_SetLineRight(HealBot_Action_Tooltip_SpellSummary(spellButton5),1,1,1,linenum) |
||
796 | end |
||
797 | end |
||
798 | if HealBot_Config.Tooltip_Recommend==1 then |
||
799 | local Instant_check=0; |
||
800 | if HealBot_Config.Tooltip_ShowSpellDetail==1 then linenum=linenum+1; end |
||
801 | linenum=linenum+1 |
||
802 | HealBot_Action_Tooltip_SetLineLeft(HEALBOT_TOOLTIP_RECOMMENDTEXT,0.8,0.8,0,linenum) |
||
803 | Instant_check=0; |
||
804 | Instant_check,linenum=HealBot_Action_Tooltip_CheckForInstant(unit,spellLeft,"upd",linenum,Instant_check); |
||
805 | Instant_check,linenum=HealBot_Action_Tooltip_CheckForInstant(unit,spellMiddle,"upd",linenum,Instant_check); |
||
806 | Instant_check,linenum=HealBot_Action_Tooltip_CheckForInstant(unit,spellRight,"upd",linenum,Instant_check); |
||
807 | Instant_check,linenum=HealBot_Action_Tooltip_CheckForInstant(unit,spellButton4,"upd",linenum,Instant_check); |
||
808 | Instant_check,linenum=HealBot_Action_Tooltip_CheckForInstant(unit,spellButton5,"upd",linenum,Instant_check); |
||
809 | if Instant_check==0 then |
||
810 | linenum=linenum+1 |
||
811 | HealBot_Action_Tooltip_SetLineLeft(" None",0.4,0.4,0.4,linenum) |
||
812 | end |
||
813 | end |
||
814 | |||
815 | local height = 20 |
||
816 | local width = 0 |
||
817 | for i = 1, linenum do |
||
818 | local txtL = getglobal("HealBot_TooltipTextL" .. i) |
||
819 | local txtR = getglobal("HealBot_TooltipTextR" .. i) |
||
820 | height = height + txtL:GetHeight() + 2 |
||
821 | if (txtL:GetWidth() + txtR:GetWidth() + 25 > width) then |
||
822 | width = txtL:GetWidth() + txtR:GetWidth() + 25 |
||
823 | end |
||
824 | end |
||
825 | HealBot_Tooltip:SetWidth(width) |
||
826 | HealBot_Tooltip:SetHeight(height) |
||
827 | HealBot_Tooltip:ClearAllPoints(); |
||
828 | if HealBot_Config.TooltipPos>1 then |
||
829 | if HealBot_Config.TooltipPos==2 then |
||
830 | HealBot_Tooltip:SetPoint("TOPRIGHT","HealBot_Action","TOPLEFT",0,0); |
||
831 | elseif HealBot_Config.TooltipPos==3 then |
||
832 | HealBot_Tooltip:SetPoint("TOPLEFT","HealBot_Action","TOPRIGHT",0,0); |
||
833 | elseif HealBot_Config.TooltipPos==4 then |
||
834 | HealBot_Tooltip:SetPoint("BOTTOM","HealBot_Action","TOP",0,0); |
||
835 | else |
||
836 | HealBot_Tooltip:SetPoint("TOP","HealBot_Action","BOTTOM",0,0); |
||
837 | end |
||
838 | else |
||
839 | HealBot_Tooltip:SetPoint("BOTTOMRIGHT","WorldFrame","BOTTOMRIGHT",-105,105); |
||
840 | end |
||
841 | HealBot_Tooltip:Show(); |
||
842 | end |
||
843 | |||
844 | function HealBot_Action_Tooltip_SpellInfo(spell,linenum) |
||
845 | local text |
||
846 | if HealBot_Spells[spell] then |
||
847 | if HealBot_Spells[spell].HealsDur>0 then |
||
848 | linenum=linenum+1 |
||
849 | HealBot_Action_Tooltip_SetLineLeft(HEALBOT_WORDS_CAST..": "..HealBot_Spells[spell].CastTime.." "..HEALBOT_WORDS_SEC..".",0.8,0.8,0.8,linenum) |
||
850 | HealBot_Action_Tooltip_SetLineRight("Mana: "..HealBot_Spells[spell].Mana,0.5,0.5,1,linenum) |
||
851 | if HealBot_Spells[spell].HealsMax>0 then |
||
852 | local Heals = HEALBOT_HEAL.." " |
||
853 | if HealBot_Spells[spell].Shield then |
||
854 | Heals = HEALBOT_TOOLTIP_SHIELD.." " |
||
855 | end |
||
856 | if HealBot_Spells[spell].HealsMin<HealBot_Spells[spell].HealsMax then |
||
857 | 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) |
||
858 | else |
||
859 | text=Heals..format("%d", HealBot_Spells[spell].HealsMax + HealBot_Spells[spell].RealHealing) |
||
860 | end |
||
861 | linenum=linenum+1 |
||
862 | HealBot_Action_Tooltip_SetLineLeft(text,1,1,1,linenum) |
||
863 | end |
||
864 | if HealBot_Spells[spell].HealsExt>0 then |
||
865 | text=HEALBOT_HEAL.." "..HealBot_Spells[spell].HealsDur.." "..HEALBOT_WORDS_OVER.." "..HealBot_Spells[spell].Duration-HealBot_Spells[spell].CastTime.." sec." |
||
866 | linenum=linenum+1 |
||
867 | HealBot_Action_Tooltip_SetLineLeft(text,1,1,1,linenum) |
||
868 | end |
||
869 | if not HealBot_Spells[spell].Shield then |
||
870 | text=HEALBOT_TOOLTIP_ITEMBONUS.." +"..HealBot_GetBonus().." | "..HEALBOT_TOOLTIP_ACTUALBONUS.." +"..HealBot_Spells[spell].RealHealing.." " |
||
871 | linenum=linenum+1 |
||
872 | HealBot_Action_Tooltip_SetLineLeft(text,0.8,0.8,0.8,linenum) |
||
873 | end |
||
874 | end |
||
875 | end |
||
876 | return linenum |
||
877 | end |
||
878 | |||
879 | function HealBot_Action_Tooltip_SpellSummary(spell) |
||
880 | local ret_val = " "; |
||
881 | if HealBot_Spells[spell] then |
||
882 | if HealBot_Spells[spell].HealsDur>0 then |
||
883 | if HealBot_Spells[spell].HealsMax>0 then |
||
884 | local Heals = " "..HEALBOT_HEAL.." "; |
||
885 | if HealBot_Spells[spell].Shield then |
||
886 | Heals = " "..HEALBOT_TOOLTIP_SHIELD.." "; |
||
887 | end |
||
888 | if HealBot_Spells[spell].HealsMin<HealBot_Spells[spell].HealsMax then |
||
889 | ret_val=ret_val..Heals..format("%d", ((HealBot_Spells[spell].HealsMin+HealBot_Spells[spell].HealsMax)/2) + HealBot_Spells[spell].RealHealing); |
||
890 | else |
||
891 | ret_val=ret_val..Heals..format("%d", HealBot_Spells[spell].HealsMax + HealBot_Spells[spell].RealHealing); |
||
892 | end |
||
893 | end |
||
894 | if HealBot_Spells[spell].HealsExt>0 then |
||
895 | ret_val=ret_val.." HoT "..HealBot_Spells[spell].HealsDur; |
||
896 | end |
||
897 | ret_val=ret_val.." "..HEALBOT_WORDS_FOR.." "..HealBot_Spells[spell].Mana.." Mana"; |
||
898 | end |
||
899 | end |
||
900 | if string.len(ret_val)<5 then ret_val = " - "..spell; end |
||
901 | return ret_val |
||
902 | end |
||
903 | |||
904 | function HealBot_Action_Tooltip_CheckForInstant(unit,spell,upd,linenum,check) |
||
905 | if HealBot_Spells[spell] then |
||
906 | if HealBot_Spells[spell].CastTime == 0 then |
||
907 | if HealBot_UnitAffected(unit,HealBot_Spells[spell].Buff) then return check,linenum end; |
||
908 | if HealBot_UnitAffected(unit,HealBot_Spells[spell].Debuff) then return check,linenum end; |
||
909 | if upd=="upd" then |
||
910 | linenum=linenum+1 |
||
911 | HealBot_Action_Tooltip_SetLineLeft(" "..spell,1,1,1,linenum) |
||
912 | end |
||
913 | else |
||
914 | return check,linenum; |
||
915 | end |
||
916 | else |
||
917 | return check,linenum |
||
918 | end |
||
919 | return check+1,linenum; |
||
920 | end |
||
921 | |||
922 | function HealBot_Action_Tooltip_SetLineLeft(Text,R,G,B,linenum) |
||
923 | local txtL = getglobal("HealBot_TooltipTextL" .. linenum) |
||
924 | txtL:SetTextColor(R,G,B) |
||
925 | txtL:SetText(Text) |
||
926 | txtL:Show() |
||
927 | end |
||
928 | |||
929 | function HealBot_Action_Tooltip_SetLineRight(Text,R,G,B,linenum) |
||
930 | local txtR = getglobal("HealBot_TooltipTextR" .. linenum) |
||
931 | txtR:SetTextColor(R,G,B) |
||
932 | txtR:SetText(Text) |
||
933 | txtR:Show() |
||
934 | end |
||
935 | |||
936 | function HealBot_Action_Tooltip_ClearLines() |
||
937 | for j=1,30 do |
||
938 | local txtL = getglobal("HealBot_TooltipTextL" .. j) |
||
939 | local txtR = getglobal("HealBot_TooltipTextR" .. j) |
||
940 | txtL:SetText(" ") |
||
941 | txtR:SetText(" ") |
||
942 | txtL:Hide() |
||
943 | txtR:Hide() |
||
944 | end |
||
945 | end |
||
946 | |||
947 | function HealBot_Action_ShowTooltip(this) |
||
948 | if HealBot_Config.ShowTooltip==0 then return end |
||
949 | if not this.unit then return end; |
||
950 | if not this:IsEnabled() then return end; |
||
951 | -- GameTooltip_SetDefaultAnchor(HealBot_Tooltip,this); |
||
952 | |||
953 | |||
954 | HealBot_Action_TooltipUnit = this.unit; |
||
955 | HealBot_Action_RefreshTooltip(this.unit); |
||
956 | end |
||
957 | |||
958 | function HealBot_Action_HideTooltip(this) |
||
959 | if HealBot_Config.ShowTooltip==0 then return end |
||
960 | HealBot_Tooltip:Hide(); |
||
961 | HealBot_Action_TooltipUnit = nil; |
||
962 | end |
||
963 | |||
964 | function HealBot_Action_Refresh(unit) |
||
965 | if (UnitIsDeadOrGhost("player")) or (UnitOnTaxi("player")) then |
||
966 | if HealBot_Config.AutoClose==1 and HealBot_Config.ActionVisible~=0 then |
||
967 | HideUIPanel(HealBot_Action); |
||
968 | else |
||
969 | HealBot_Action_RefreshButtons(unit); |
||
970 | end |
||
971 | return; |
||
972 | end |
||
973 | HealBot_Action_RefreshButtons(unit); |
||
974 | if not HealBot_IsFighting then |
||
975 | if (HealBot_Action_MustHealSome()) then |
||
976 | ShowUIPanel(HealBot_Action); |
||
977 | elseif HealBot_AbortButton==0 then |
||
978 | ShowUIPanel(HealBot_Action); |
||
979 | elseif (not HealBot_Action_ShouldHealSome()) then |
||
980 | if HealBot_AbortButton==1 and HealBot_Config.AutoClose==1 and HealBot_Config.ActionVisible~=0 then |
||
981 | HideUIPanel(HealBot_Action); |
||
982 | end |
||
983 | end |
||
984 | end |
||
985 | end |
||
986 | |||
987 | function HealBot_Action_SpellPattern(button) |
||
988 | local combos = HealBot_Config.KeyCombo[UnitClass("player")] |
||
989 | if not combos then return nil end |
||
990 | local press = button; |
||
991 | if IsAltKeyDown() then press = "Alt"..press end |
||
992 | if IsControlKeyDown() then press = "Ctrl"..press end |
||
993 | if IsShiftKeyDown() then press = "Shift"..press end |
||
994 | return combos[press] |
||
995 | end |
||
996 | |||
997 | function HealBot_Decode_Button(button) |
||
998 | if button=="RightButton" then |
||
999 | button="Right"; |
||
1000 | elseif button=="MiddleButton" then |
||
1001 | button="Middle"; |
||
1002 | elseif button=="Button4" then |
||
1003 | button="Button4"; |
||
1004 | elseif button=="Button5" then |
||
1005 | button="Button5"; |
||
1006 | else |
||
1007 | button="Left"; |
||
1008 | end |
||
1009 | return button |
||
1010 | end |
||
1011 | |||
1012 | -------------------------------------------------------------------------------------------------- |
||
1013 | -- Widget_OnFoo functions |
||
1014 | -------------------------------------------------------------------------------------------------- |
||
1015 | |||
1016 | function HealBot_Action_HealUnit_OnLoad(this) |
||
1017 | this:RegisterForClicks("LeftButtonUp", "RightButtonUp", "MiddleButtonUp", "Button4Up", "Button5Up"); |
||
1018 | end |
||
1019 | |||
1020 | function HealBot_Action_HealUnit_OnEnter(this) |
||
1021 | HealBot_Action_ShowTooltip(this); |
||
1022 | end |
||
1023 | |||
1024 | function HealBot_Action_HealUnit_OnLeave(this) |
||
1025 | HealBot_Action_HideTooltip(this); |
||
1026 | end |
||
1027 | |||
1028 | function HealBot_Action_HealUnit_OnClick(this,button) |
||
1029 | local decode_button = HealBot_Decode_Button(button); |
||
1030 | HealBot_HealUnit(this.unit,HealBot_Action_SpellPattern(decode_button)); |
||
1031 | end |
||
1032 | |||
1033 | function HealBot_Action_HealUnitCheck_OnClick(this) |
||
1034 | if not this.unit then return end |
||
1035 | if this:GetChecked() then |
||
1036 | table.insert(HealBot_Action_HealTarget,this.unit) |
||
1037 | else |
||
1038 | for i=1,table.getn(HealBot_Action_HealTarget) do |
||
1039 | if HealBot_Action_HealTarget[i]==this.unit then |
||
1040 | table.remove(HealBot_Action_HealTarget,i); |
||
1041 | break; |
||
1042 | end |
||
1043 | end |
||
1044 | end |
||
1045 | HealBot_Action_PartyChanged(); |
||
1046 | end |
||
1047 | |||
1048 | function HealBot_Action_OptionsButton_OnClick(this) |
||
1049 | HealBot_TogglePanel(HealBot_Options); |
||
1050 | end |
||
1051 | |||
1052 | function HealBot_Action_AbortButton_OnClick(this) |
||
1053 | SpellStopCasting(); |
||
1054 | end |
||
1055 | |||
1056 | local HealBot_CT_RA_UpdateMTs_Old; |
||
1057 | function HealBot_CT_RA_UpdateMTs() |
||
1058 | local value = HealBot_CT_RA_UpdateMTs_Old(); |
||
1059 | return value; |
||
1060 | end |
||
1061 | |||
1062 | function HealBot_CT_RaidAssist_DEAD() |
||
1063 | -- if (type(CT_RA_MemberFrame_OnClick)=="function") then |
||
1064 | -- HealBot_CT_RA_CustomOnClickFunction_Old = CT_RA_CustomOnClickFunction; |
||
1065 | -- CT_RA_CustomOnClickFunction = HealBot_CT_RA_CustomOnClickFunction; |
||
1066 | -- end |
||
1067 | -- if (type(CT_RA_UpdateMTs)=="function") then |
||
1068 | -- HealBot_CT_RA_UpdateMTs_Old = CT_RA_UpdateMTs; |
||
1069 | -- CT_RA_UpdateMTs = HealBot_CT_RA_UpdateMTs; |
||
1070 | -- end |
||
1071 | end |
||
1072 | |||
1073 | -------------------------------------------------------------------------------------------------- |
||
1074 | -- Frame_OnFoo functions |
||
1075 | -------------------------------------------------------------------------------------------------- |
||
1076 | |||
1077 | function HealBot_Action_OnLoad(this) |
||
1078 | -- HealBot_CT_RaidAssist(); |
||
1079 | end |
||
1080 | |||
1081 | function HealBot_Action_OnShow(this) |
||
1082 | if HealBot_Config.PanelSounds==1 then |
||
1083 | PlaySound("igAbilityOpen"); |
||
1084 | end |
||
1085 | HealBot_Config.ActionVisible = 1 |
||
1086 | HealBot_Action:SetBackdropColor( |
||
1087 | HealBot_Config.backcolr[HealBot_Config.Current_Skin], |
||
1088 | HealBot_Config.backcolg[HealBot_Config.Current_Skin], |
||
1089 | HealBot_Config.backcolb[HealBot_Config.Current_Skin], |
||
1090 | HealBot_Config.backcola[HealBot_Config.Current_Skin]); |
||
1091 | HealBot_Action:SetBackdropBorderColor( |
||
1092 | HealBot_Config.borcolr[HealBot_Config.Current_Skin], |
||
1093 | HealBot_Config.borcolg[HealBot_Config.Current_Skin], |
||
1094 | HealBot_Config.borcolb[HealBot_Config.Current_Skin], |
||
1095 | HealBot_Config.borcola[HealBot_Config.Current_Skin]); |
||
1096 | end |
||
1097 | |||
1098 | function HealBot_Action_OnHide(this) |
||
1099 | HealBot_StopMoving(this); |
||
1100 | HealBot_Config.ActionVisible = 0 |
||
1101 | end |
||
1102 | |||
1103 | function HealBot_Action_OnMouseDown(this,button) |
||
1104 | if button~="RightButton" then |
||
1105 | if HealBot_Config.ActionLocked==0 then |
||
1106 | HealBot_StartMoving(this); |
||
1107 | end |
||
1108 | end |
||
1109 | end |
||
1110 | |||
1111 | function HealBot_Action_OnMouseUp(this,button) |
||
1112 | if button~="RightButton" then |
||
1113 | HealBot_StopMoving(this); |
||
1114 | elseif not HealBot_IsFighting then |
||
1115 | HealBot_Action_OptionsButton_OnClick(); |
||
1116 | end |
||
1117 | end |
||
1118 | |||
1119 | function HealBot_Action_OnClick(this,button) |
||
1120 | -- HealBot_Action_AddDebug("OnClick("..button..")"); |
||
1121 | end |
||
1122 | |||
1123 | function HealBot_Action_OnDragStart(this,button) |
||
1124 | if HealBot_Config.ActionLocked==0 then |
||
1125 | HealBot_StartMoving(this); |
||
1126 | end |
||
1127 | end |
||
1128 | |||
1129 | function HealBot_Action_OnDragStop(this) |
||
1130 | HealBot_StopMoving(this); |
||
1131 | end |
||
1132 | |||
1133 | -- http://www.flexbarforums.com/viewtopic.php?t=66 |
||
1134 | function HealBot_Action_OnKey(this,key,state) |
||
1135 | local command = GetBindingAction(key); |
||
1136 | if command then |
||
1137 | DEFAULT_CHAT_FRAME:AddMessage(key.." "..state.." "..(command or "nil")); |
||
1138 | keystate = state |
||
1139 | RunBinding(command,keystate) |
||
1140 | end |
||
1141 | DEFAULT_CHAT_FRAME:AddMessage("HealBot_Action_OnKey - "..key); |
||
1142 | if key=="SHIFT" or key=="CTRL" or key=="ALT" then |
||
1143 | DEFAULT_CHAT_FRAME:AddMessage((IsShiftKeyDown() or 0).." "..(IsControlKeyDown() or 0).." "..(IsAltKeyDown() or 0)); |
||
1144 | HealBot_Action_Refresh(); |
||
1145 | end |
||
1146 | end |