Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CalculateHP(t)
- incomingheals = UnitGetIncomingHeals(t) and UnitGetIncomingHeals(t) or 0
- local PercentWithIncoming = 100 * ( UnitHealth(t) + incomingheals ) / UnitHealthMax(t)
- local ActualWithIncoming = ( UnitHealthMax(t) - ( UnitHealth(t) + incomingheals ) )
- return PercentWithIncoming, ActualWithIncoming
- end
- function CanHeal(t)
- if UnitInRange(t)
- --Missing LOS Check
- and UnitCanCooperate("player",t)
- and not UnitIsCharmed(t)
- and not UnitIsDeadOrGhost(t)
- and UnitIsConnected(t)
- and UnitDebuffID(t,104451) == nil -- Ice Tomb
- and UnitDebuffID(t,76577) == nil -- Smoke Bomb
- then return true else return false end
- end
- function HealingEngine(MO, LOWHP, ACTUALHP)
- R_Tanks = { }
- local MouseoverCheck = MO or false
- local ActualHP = ACTUALHP or false
- local LowHPTarget = LOWHP or 80
- lowhpmembers = 0
- members = { { Unit = "player", HP = CalculateHP("player"), GUID = UnitGUID("player"), AHP = select(2, CalculateHP("player")) } }
- -- Check if the Player is apart of the Custom Table
- for i=1, #R_CustomT do
- if UnitGUID("player") == R_CustomT[i].GUID then
- R_CustomT[i].Unit = "player"
- R_CustomT[i].HP = CalculateHP("player")
- R_CustomT[i].AHP = select(2, CalculateHP("player"))
- end
- end
- if IsInRaid() then
- group = "raid"
- elseif IsInGroup() then
- group = "party"
- end
- for i = 1, GetNumGroupMembers() do
- local member, memberhp = group..i, CalculateHP(group..i)
- -- Checking all Party/Raid Members for Range/Health
- if CanHeal(member) then
- -- Checking if Member has threat
- if UnitThreatSituation(member) == 3 then memberhp = memberhp - 3 end
- -- Checking if Member has Beacon on them
- if UnitBuffID(member, 53563) then memberhp = memberhp + 3 end
- -- Searing Plasma Check
- if UnitDebuffID(member, 109379) then memberhp = memberhp - 9 end
- -- Checking if Member is a tank
- if UnitGroupRolesAssigned(member) == "TANK" then
- memberhp = memberhp - 1
- table.insert(R_Tanks, { Unit = member, HP = memberhp, AHP = select(2, CalculateHP(member)) } )
- end
- -- If they are in the Custom Table add their info in
- for i=1, #R_CustomT do
- if UnitGUID(member) == R_CustomT[i].GUID then
- R_CustomT[i].Unit = member
- R_CustomT[i].HP = memberhp
- R_CustomT[i].AHP = select(2, CalculateHP(member))
- end
- end
- table.insert( members,{ Unit = group..i, HP = memberhp, GUID = UnitGUID(group..i), AHP = select(2, CalculateHP(group..i)) } )
- end
- -- Checking Pets in the group
- if CanHeal(group..i.."pet") then
- local memberpet, memberpethp = nil, nil
- if UnitAffectingCombat("player") then
- memberpet = group..i.."pet"
- memberpethp = CalculateHP(group..i.."pet") * 2
- else
- memberpet = group..i.."pet"
- memberpethp = CalculateHP(group..i.."pet")
- end
- -- Checking if Pet is apart of the CustomTable
- for i=1, #R_CustomT do
- if UnitGUID(memberpet) == R_CustomT[i].GUID then
- R_CustomT[i].Unit = memberpet
- R_CustomT[i].HP = memberpethp
- R_CustomT[i].AHP = select(2, CalculateHP(memberpet))
- end
- end
- table.insert(members, { Unit = memberpet, HP = memberpethp, GUID = UnitGUID(memberpet), AHP = select(2, CalculateHP(memberpet)) } )
- end
- end
- -- So if we pass that ActualHP is true, then we will sort by most health missing. If not, we sort by lowest % of health.
- if not ActualHP then
- table.sort(members, function(x,y) return x.HP < y.HP end)
- if #R_Tanks > 0 then
- table.sort(R_Tanks, function(x,y) return x.HP < y.HP end)
- end
- elseif ActualHP then
- table.sort(members, function(x,y) return x.AHP > y.AHP end)
- if #R_Tanks > 0 then
- table.sort(R_Tanks, function(x,y) return x.AHP > y.AHP end)
- end
- end
- -- Setting Low HP Members variable for AoE Healing
- for i=1,#members do
- if members[i].HP < LowHPTarget then
- lowhpmembers = lowhpmembers + 1
- end
- end
- -- Checking Priority Targeting
- if CanHeal("target") then
- table.sort(members, function(x) return UnitIsUnit("target",x.Unit) end)
- elseif CanHeal("mouseover") and GetMouseFocus() ~= WorldFrame and MouseoverCheck then
- table.sort(members, function(x) return UnitIsUnit("mouseover",x.Unit) end)
- end
- end
- function CheckDistance(unit1,unit2)
- local x1,y1 = GetPlayerMapPosition(unit1)
- local x2,y2 = GetPlayerMapPosition(unit2)
- return sqrt( (x1-x2)^2 + (y1-y2)^2 )
- end
- function UnitsClose(t, percent)
- local PercentToHeal = percent or 85
- local n = 0
- if distance and distance[1] then
- for i=1,#members do
- local x = CheckDistance(t,members[i].Unit)
- if x ~= 0 and x < distance[1] and members[i].HP < PercentToHeal then n = n + 1 end
- end
- end
- return n
- end
- function GetDistance()
- local playerx,playery = GetPlayerMapPosition("player")
- if GetCurrentMapAreaID() ~= xrnMap or GetCurrentMapDungeonLevel() ~= xrnDung then
- xrnMap,xrnDung = GetCurrentMapAreaID(), GetCurrentMapDungeonLevel()
- mp, distance = {}, {}
- end
- if #members > 1 and #distance < 10 and playerx ~= 0 and playery ~= 0 then
- for i=1,#members do
- if CheckInteractDistance(members[i].Unit,2) then
- mp[members[i].Unit] = {GetPlayerMapPosition(members[i].Unit)}
- elseif UnitInRange(members[i].Unit) and mp[members[i].Unit] then
- table.insert(distance,sqrt((mp[members[i].Unit][1] - playerx)^2 + (mp[members[i].Unit][2] - playery)^2))
- table.sort(distance)
- mp[members[i].Unit] = nil
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement