Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] Alternative way to determine nearby enemies #829

Open
sirTribble opened this issue Jan 25, 2021 · 3 comments
Open

[Suggestion] Alternative way to determine nearby enemies #829

sirTribble opened this issue Jan 25, 2021 · 3 comments

Comments

@sirTribble
Copy link

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

@johnnylam88
Copy link
Contributor

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.

@sirTribble
Copy link
Author

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. :)

@johnnylam88
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants