Instead of a button to scan and then another to heal, you can make casting the heal do the scan. This is a very simplified way to do it with CTRA:
Code:
oldHealRange_UseAction = UseAction
UseAction = function(v1,v2,v3)
local i,name
local function findbutton(name)
local i,found
for i=1,40 do
if getglobal("CT_RAMember"..i.."Name"):GetText()==name then
found = i
end
end
return found or ""
end
oldHealRange_UseAction(v1,v2,v3)
if SpellIsTargeting() then
for i=1,40 do
name = UnitName("raid"..i)
button = getglobal("CT_RAMember"..findbutton(name))
if name and button then
if SpellCanTargetUnit("raid"..i) then
button:SetAlpha(1) -- visually mark them as in range
else
button:SetAlpha(.5) -- visually mark them out of range
end
end
end
end
end
What it does is hook UseAction and after a UseAction it checks if you are in spell targeting mode. If you are, then it scans the raid to see who is in range of the spell and then darkens their button if they are out of range (SetAlpha(.5)) and lightens it if they are in range (SetAlpha(1)).
Alternately, you can have it periodically check while in spell targeting mode. In the XML:
Code:
<Frame name="HealRange_Update" hidden="true">
<Scripts>
<OnUpdate>
HealRange_Update_OnUpdate()
</OnUpdate>
</Scripts>
</Frame>
In the lua:
Code:
local timer
oldHealRange_UseAction = UseAction
UseAction = function(v1,v2,v3)
local i,name
local function findbutton(name)
local i,found
for i=1,40 do
if getglobal("CT_RAMember"..i.."Name"):GetText()==name then
found = i
end
end
return found or ""
end
oldHealRange_UseAction(v1,v2,v3)
if SpellIsTargeting() then
timer = 2 -- do an immediate scan (timer>1)
HealRange_Update:Show() -- start OnUpdates
end
end
function HealRange_Update_OnUpdate()
timer = timer + arg1
if timer > 1 then
timer = 0
if SpellIsTargeting() then
for i=1,40 do
name = UnitName("raid"..i)
button = getglobal("CT_RAMember"..findbutton(name))
if name and button then
if SpellCanTargetUnit("raid"..i) then
button:SetAlpha(1) -- visually mark them as in range
else
button:SetAlpha(.5) -- visually mark them out of range
end
end
end
else
HealRange_Update:Hide() -- stop OnUpdates
end
end
end
You would probably want to tweak the findbutton() function since it's likely that the name isn't wiped when someone is moved to a different raid button. Something like:
Code:
local function findbutton(name)
local i,found,button
for i=1,40 do
button = getglobal("CT_RAMember"..i.."Name")
if button:IsVisible() and button:GetText()==name then
found = i
end
end
return found or ""
end
And the SetAlpha probably isn't the best solution as a visual indicator if they're in range. You could make 40 frames each anchored to the TOPLEFT and BOTTOMRIGHT of the CT_RAMember1-40 buttons. (Doesn't need to be a part of CTRA either) And then hide or show or set colors or whatever if they're in range or out.
Probably more that would need doing but it's a start.