Quantcast

Friend and foe detection rewriten, hopefully works much better now.

Taracque [05-19-11 - 22:56]
Friend and foe detection rewriten, hopefully works much better now.
Filename
Elementarist.lua
diff --git a/Elementarist.lua b/Elementarist.lua
index 4a0d233..c4ef3b5 100755
--- a/Elementarist.lua
+++ b/Elementarist.lua
@@ -331,23 +331,23 @@ 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_AFFILIATION_MASK) < 8) and ((dtype==0) or (dtype==3)) 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 ((not Elementarist.person["foe"][dguid]) or (Elementarist.person["foe"][dguid]==0)) then
 				Elementarist.person["foeCount"] = Elementarist.person["foeCount"] + 1
 			end
 			Elementarist.person["foe"][dguid] = time
-    	elseif (bit.band(dflags, COMBATLOG_OBJECT_AFFILIATION_MASK) < 8) and ((stype==0) or (stype==3)) then
+    	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
 			if ((not Elementarist.person["foe"][sguid]) or (Elementarist.person["foe"][sguid]==0)) then
 				Elementarist.person["foeCount"] = Elementarist.person["foeCount"] + 1
 			end
 			Elementarist.person["foe"][sguid] = time
 		end
-		if (bit.band(sflags, COMBATLOG_OBJECT_AFFILIATION_MASK) >= 8) and ((dtype==0) or (dtype==3)) then
+		if (bit.band(sflags, 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_AFFILIATION_MASK) >= 8) and ((stype==0) or (stype==3)) then
+    	elseif (bit.band(dflags, 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