-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcountArsonists.lua
49 lines (42 loc) · 1.43 KB
/
countArsonists.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
-- init
aura_env.npcMatches = {}
-- trigger: UNIT_THREAT_LIST_UPDATE, PLAYER_REGEN_ENABLED
function(event, unit)
if event == "UNIT_THREAT_LIST_UPDATE" then
local unitGuid = UnitGUID(unit)
if unitGuid ~= nil then
local npcId = select(6, strsplit("-", unitGuid))
npcId = tonumber(npcId)
if npcId == aura_env.config.npcId then
if UnitThreatSituation("player", unit) ~= nil then
aura_env.npcMatches[unitGuid] = true
else
-- Player is no longer on this unit's threat table (i.e.,
-- the unit died, the unit reset, or player dropped combat).
aura_env.npcMatches[unitGuid] = nil
end
end
end
local count = 0
for _,_ in pairs(aura_env.npcMatches) do
count = count + 1
end
aura_env.numNpcMatches = count
return count ~= 0
elseif event == "PLAYER_REGEN_ENABLED" then
-- The player is no longer in combat. Clear the set of NPC matches,
-- in case the 'UNIT_THREAT_LIST_UPDATE' event does not fire for all
-- units (e.g., if the unit died while their nameplate wasn't visible
-- on the player's screen).
aura_env.npcMatches = {}
return false
end
end
-- untrigger
function(event)
return true
end
-- stacks
function()
return aura_env.numNpcMatches
end