Ovale Spell Priority

Ovale Spell Priority

6M Downloads

[Suggestion] Alternative way to determine nearby enemies

sirTribble opened this issue ยท 3 comments

commented

As i understand (may be it was changed) the addon scan for enemies using combat log (entering combat or affecting directly in combat) and store data of them in table.

but there is some common situation when enemies not actively at combat with you but still affecting combat (usually bosses phases) as well as at this moment you cannot check how many enemies in range of given spell or at given distance.

here is custom condition i use to solve this issue, may be you will incorporate them in to ovale main.
and pls be aware that this code may be not well optimized or written since my coding skill are very-very low.
In short it scans nearby nameplates that affecting combat and not friendly to player and checks range or distance

do
local function AnyInCombatinDistance(positionalParams, namedParams, atTime)
local range = positionalParams[1]
local target = namedParams.target or "player"
local size = 60
local enemies = 0
range = range or INFINITY
for i=1,size do
local name = "nameplate"..i
local incombat = API_UnitAffectingCombat(name)
local reaction = UnitReaction(target,name)
local value = (LibRangeCheck and LibRangeCheck:GetRange(name)) or 0
if API_UnitExists(name) and incombat and (reaction <= 4) and (value <= range) then enemies = enemies + 1 end
end
return ReturnConstant(enemies)
end
ovaleCondition:registerCondition("anyincombatindistance", false, AnyInCombatinDistance)
ovaleCondition:registerCondition("icd", false, AnyInCombatinDistance)
end

do
local function AnyInCombatinRange(positionalParams, namedParams, atTime)
local spellId = positionalParams[1]
local target = namedParams.target or "player"
local size = 60
local enemies = 0
local spellname = GetSpellInfo(spellId)
for i=1,size do
local name = "nameplate"..i
local incombat = API_UnitAffectingCombat(name)
local reaction = UnitReaction(target,name)
local boolean = true and OvaleSpells:IsSpellInRange(spellId, name) or false
if API_UnitExists(name) and incombat and (reaction <= 4) and boolean then enemies = enemies + 1 end
end
return ReturnConstant(enemies)
end
ovaleCondition:registerCondition("anyincombatindrange", false, AnyInCombatinRange)
ovaleCondition:registerCondition("icr", false, AnyInCombatinRange)
end

commented

That is an interesting idea with regards to a better Enemies() script condition. I think I will implement this independently, but I like the concept. Doing this requires that enemy nameplates be active, but I feel that it's pretty common.

commented

absolutely. fill free to use concept however you want. in addition it can also check (with coord api) for enemies around the target for more precise targets count, but unfortunately will work only in open word (due to legion changes), anyway some casual rdd players will be very grateful :)
wonna see how this can be implemented in style. :)

commented

Looking at this some more, there doesn't seem to be a more efficient way to check for the number of enemies nearby or within range of a spell. I will implement something like this but with a throttle on the number of times the nameplate loop can be run within a certain period of time.