Enemy detection now works as it should.
Taracque [05-20-11 - 22:29]
Enemy detection now works as it should.
diff --git a/Elementarist.lua b/Elementarist.lua
index c4ef3b5..e323533 100755
--- a/Elementarist.lua
+++ b/Elementarist.lua
@@ -140,9 +140,9 @@ Elementarist.events = {}
function Elementarist:Debug(statictxt,msg)
if (Elementarist.DebugMode) then
if (msg) then
- DEFAULT_CHAT_FRAME:AddMessage("ELEDBG: ".. statictxt .. " : " .. msg)
+ ChatFrame4:AddMessage("ELEDBG: ".. statictxt .. " : " .. msg)
else
- DEFAULT_CHAT_FRAME:AddMessage("ELEDBG: ".. statictxt .. " : " .. "<nil>")
+ ChatFrame4:AddMessage("ELEDBG: ".. statictxt .. " : " .. "<nil>")
end
end
end
@@ -286,12 +286,11 @@ function Elementarist:RemoveFromTables(guid)
if (Elementarist.person["friend"][guid]) and (Elementarist.person["friend"][guid] ~= 0) then
Elementarist.person["friend"][guid] = 0
Elementarist.person["friendCount"] = Elementarist.person["friendCount"] - 1
- Elementarist:Debug('Enemy died:', Elementarist.person["foeCount"])
end
if (Elementarist.person["foe"][guid]) and (Elementarist.person["foe"][guid] ~= 0) then
Elementarist.person["foe"][guid] = 0
Elementarist.person["foeCount"] = Elementarist.person["foeCount"] - 1
- Elementarist:Debug('Friend died:', Elementarist.person["friendCount"])
+ Elementarist:Debug('Enemy died:', Elementarist.person["foeCount"] .. " " .. guid)
end
if (Elementarist.debuffCooldowns[guid]) then
table.remove(Elementarist.debuffCooldowns, guid)
@@ -306,20 +305,22 @@ end
function Elementarist:PurgePersonTable()
for i,v in pairs(Elementarist.person["foe"]) do
- if (GetTime()-v > 2) then
+ if ( ( GetTime() - Elementarist.person["foe"][i] ) > 2) then
-- no activity from that unit in last 2 seconds, remove it
if ( Elementarist.person["foe"][i] ~= 0) then
Elementarist.person["foe"][i] = 0 -- mark as inactive
Elementarist.person["foeCount"] = Elementarist.person["foeCount"] - 1
+ Elementarist:Debug('Enemy removed:', Elementarist.person["foeCount"])
end
end
end
for i,v in pairs(Elementarist.person["friend"]) do
- if (GetTime()-v > 2) then
+ if ( ( GetTime() - Elementarist.person["friend"][i] ) > 2) then
-- no activity from that unit in last 2 seconds, remove it
if ( Elementarist.person["friend"][i] ~= 0 ) then
Elementarist.person["friend"][i] = 0 -- mark as inactive
Elementarist.person["friendCount"] = Elementarist.person["friendCount"] - 1
+ Elementarist:Debug('Friend removed:', Elementarist.person["friendCount"])
end
end
end
@@ -331,27 +332,29 @@ function Elementarist:CountPerson(time, event, sguid, sname, sflags, dguid, dnam
local stype = (tonumber(sguid:sub(5,5), 16)) % 8
local dtype = (tonumber(dguid:sub(5,5), 16)) % 8
if Elementarist.HostileFilter[suffix] then
- if (bit.band(sflags, COMBATLOG_OBJECT_REACTION_HOSTILE) == COMBATLOG_OBJECT_REACTION_HOSTILE) and (bit.band(sflags, COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) == COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) and ((dtype==0) or (dtype==3)) then
+ if (bit.band(dflags, COMBATLOG_OBJECT_REACTION_HOSTILE) == COMBATLOG_OBJECT_REACTION_HOSTILE) and (bit.band(dflags, COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) == COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) and ((dtype==0) or (dtype==3)) then
if ((not Elementarist.person["foe"][dguid]) or (Elementarist.person["foe"][dguid]==0)) then
Elementarist.person["foeCount"] = Elementarist.person["foeCount"] + 1
+ Elementarist:Debug('Enemy added', Elementarist.person["foeCount"] .. " " .. dguid .. " " .. dflags)
end
- Elementarist.person["foe"][dguid] = time
- elseif (bit.band(dflags, COMBATLOG_OBJECT_REACTION_HOSTILE) == COMBATLOG_OBJECT_REACTION_HOSTILE) and (bit.band(dflags, COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) == COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) and ((stype==0) or (stype==3)) then
+ Elementarist.person["foe"][dguid] = GetTime()
+ elseif (bit.band(sflags, COMBATLOG_OBJECT_REACTION_HOSTILE) == COMBATLOG_OBJECT_REACTION_HOSTILE) and (bit.band(sflags, COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) == COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) and ((stype==0) or (stype==3)) then
if ((not Elementarist.person["foe"][sguid]) or (Elementarist.person["foe"][sguid]==0)) then
Elementarist.person["foeCount"] = Elementarist.person["foeCount"] + 1
+ Elementarist:Debug('Enemy added', Elementarist.person["foeCount"] .. " " .. sguid)
end
- Elementarist.person["foe"][sguid] = time
+ Elementarist.person["foe"][sguid] = GetTime()
end
- if (bit.band(sflags, COMBATLOG_OBJECT_REACTION_FRIENDLY) == COMBATLOG_OBJECT_REACTION_FRIENDLY) and ((dtype==0) or (dtype==3)) then
+ if (bit.band(dflags, COMBATLOG_OBJECT_REACTION_FRIENDLY) == COMBATLOG_OBJECT_REACTION_FRIENDLY) and ((dtype==0) or (dtype==3)) then
if ((not Elementarist.person["friend"][dguid]) or (Elementarist.person["friend"][dguid]==0)) then
Elementarist.person["friendCount"] = Elementarist.person["friendCount"] + 1
end
- Elementarist.person["friend"][dguid] = time
- elseif (bit.band(dflags, COMBATLOG_OBJECT_REACTION_FRIENDLY) == COMBATLOG_OBJECT_REACTION_FRIENDLY) and ((stype==0) or (stype==3)) then
+ Elementarist.person["friend"][dguid] = GetTime()
+ elseif (bit.band(sflags, COMBATLOG_OBJECT_REACTION_FRIENDLY) == COMBATLOG_OBJECT_REACTION_FRIENDLY) and ((stype==0) or (stype==3)) then
if ((not Elementarist.person["friend"][sguid]) or (Elementarist.person["friend"][sguid]==0)) then
Elementarist.person["friendCount"] = Elementarist.person["friendCount"] + 1
end
- Elementarist.person["friend"][sguid] = time
+ Elementarist.person["friend"][sguid] = GetTime()
end
end
if (Elementarist.lastPersonTablePurged < (GetTime() - 3)) and (Elementarist.person["foeCount"]>0) then
@@ -423,7 +426,7 @@ function Elementarist.events.COMBAT_LOG_EVENT_UNFILTERED(timestamp, event, hideC
end
else
-- if unit died, remove if from friend and foe tables
- if (event=="UNIT_DESTROYED") or (event=="UNIT_DESTROYED") then
+ if (event=="UNIT_DIED") or (event=="UNIT_DESTROYED") then
Elementarist:RemoveFromTables(dstGUID);
end
-- count enemies if player in combat