For optimal dps I need a way to check if enemy's are around me.
I know onya made a way to get player positions, is it possible to get enemy positions?
This could allow for much smarter aoe rotations.
Target Finder
Code:
hrtargethealth = Nova_Spell[PQ_HolyRadiance].targetHealth
hrsecondaryhealth = Nova_Spell[PQ_HolyRadiance].targetHealth
hrrange = 10
hrsecondarytargets = Nova_Spell[PQ_HolyRadiance].targetNumber
if not onyainit then
function onyaGetPlayerMapPosition(unit)
local x,y = GetPlayerMapPosition(unit)
return x,y
end
function NewScaleFactor(unit1,dist)
local x1,y1 = onyaGetPlayerMapPosition(unit1)
local x2,y2 = onyaGetPlayerMapPosition("player")
local xx= x1 - x2
local yy = y1 -y2
sft = tostring (dist/sqrt(((xx) * (xx)) + (((yy) * 0.6666666666666) ^ 2)))
return sft
end
function DistanceBetweenUnits(unit1,unit2)
if unit2 == unit1 then return 0 end
local x1,y1 = onyaGetPlayerMapPosition(unit1)
local x2,y2 = onyaGetPlayerMapPosition(unit2)
if x1 == 0 and y1 == 0 and x2 ==0 and y2 == 0 then return 0 end
return (sqrt((((x2 - x1) * sf) ^ 2) + (((y2 - y1) * sf / 1.5) ^ 2)))
end
function IsInRange(u1,u2)
local range = DistanceBetweenUnits(member[u1].name,member[u2].name)
if range <= hrrange then
return true
end
end
function getDefHealth(unit)
return (100 - member[unit].health)
end
function sortDefHealth(aUnit, anotherUnit)
return getDefHealth(aUnit) > getDefHealth(anotherUnit)
end
function findGoodTarget()
if table.maxn(hrtargets) ~=0 and table.maxn(hrsecondary) >= hrsecondarytargets then
table.sort(hrtargets, sortDefHealth)
table.sort(hrsecondary, sortDefHealth)
for x = 1, table.maxn(hrtargets) do
local inrangecount = 0
for y = 1, table.maxn(hrsecondary) do
if IsInRange(hrtargets[x],hrsecondary[y]) then inrangecount = inrangecount + 1 end
if inrangecount == hrsecondarytargets then return member[hrtargets[x]].name end
end
end
end
end
onyainit = true
end
local currentmap = GetMapInfo()
local currentlevel = tostring(GetCurrentMapDungeonLevel()) or "0"
local grp = "party"
local mems = GetNumPartyMembers()
if GetNumRaidMembers() > 0 then
grp = "raid"
mems = GetNumRaidMembers()
end
if (sfm ~= currentmap) or (sfl ~= currentlevel) then
sf = 6000
sfm = currentmap
sfl = currentlevel
end
for mmm = 1, mems do
local checktarget = grp..tostring(mmm)
local range = DistanceBetweenUnits("player",checktarget)
if (range > 28) and (CheckInteractDistance(checktarget,1)) then
sf = NewScaleFactor(checktarget,28)
end
if (range > 11.11) and (CheckInteractDistance(checktarget,2)) then
sf = NewScaleFactor(checktarget,11.11)
end
if (range > 9.9) and (CheckInteractDistance(checktarget,3)) then
sf = NewScaleFactor(checktarget,9.9)
end
if (range > 40) and (UnitInRange(checktarget)) then
sf = NewScaleFactor(checktarget,40)
end
end
hrtargets = {}
hrsecondary = {}
member = {}
for i = 0, mems, 1 do
member[i] = {}
if i==0 then member[i].name = "player" else member[i].name = grp..tostring(i) end
local memberin = UnitGetIncomingHeals(member[i].name) or 0
member[i].health= 100 * (UnitHealth(member[i].name)+ memberin ) / UnitHealthMax(member[i].name)
if not UnitIsDeadOrGhost(member[i].name) then
if member[i].health < hrtargethealth
and not (UnitBuffID(member[i].name, 82327))
and IsSpellInRange("Holy Radiance", member[i].name)
then table.insert(hrtargets,i) end
if member[i].health < hrsecondaryhealth then table.insert(hrsecondary,i) end
end
end
HR
Code:
if Nova_Spell[PQ_HolyRadiance].check then
local _, _, _, cost = GetSpellInfo(82327)
local mana = UnitPower("player")
local spell = UnitCastingInfo("player")
if mana > cost and spell ~= GetSpellInfo(82327) then
local HRtarget = findGoodTarget()
if HRtarget ~= nil then
PQR_CustomTarget = HRtarget
return true
end
end
end
I want to be able to keep censure up on three targets at all times.
Is there a way to track a different targets debuff, I know you can track the current targets debuffs.
edit:
Why is Avoid fragmentation like this?
Code:
local tentacledeath = select(7,UnitDebuffID("player",109597))
if tentacledeath and tentacledeath - GetTime() < 0.7 then
RunMacroText("/click ExtraActionButton1")
end
Shouldn't it be like this?
Code:
Actions: /click ExtraActionButton1
Target: target
Spell ID: 0
local shrapnel, _, _, _, _, _, shrapnelEndTime = UnitDebuffID("player", 109957)
if shrapnel then
local finishTime = shrapnelEndTime - GetTime()
if finishTime < 1 then
return true
end
end