@name 3 Closest Enemy Targets NPC Filter
@inputs Pl:array Pass:entity PlayerKill
#@outputs Threat1 Threat2 Threat3 Threat4 Threat5 Threat6 Threat7
#@outputs C1:entity C2:entity C3:entity Count C11 C21 C31 
@outputs Tar:array

Range = 100000
if(duped()){reset()}
#Steam = entity():owner():steamID()
#if (Steam!="STEAM_0:1:8017844" & Steam!="STEAM_0:1:20368596" & Steam!="STEAM_0:1:16471737") {selfDestruct()}
interval(findUpdateRate()*5)
if (!PlayerKill) {
#Priority List
NPC = "npc_"
P1 = "strider"
P2 = "combinegunship"
P3 = "helichopter"
P4 = "antlionguard"
P5 = "sniper"
P6 = "hunter"
P7 = NPC
#Friend List
F1 = "alyx"
F2 = "barney"
F3 = "citizen"
F4 = "eli"
F5 = "dog"
F6 = "magnusson"
F7 = "mossman"
F8 = "turret_floor"
F9 = "vortigaunt"
F0 = "kleiner"
F11 = "monk"
F12 = "prop_vehicle_airboat"
F13 = "rollermine"


findInSphere(Pass:pos(),Range)
findSortByDistance(Pass:pos())

findIncludeClass(NPC)	 
findExcludeClass(NPC + F1)
findExcludeClass(NPC + F2)
findExcludeClass(NPC + F3)
findExcludeClass(NPC + F4)
findExcludeClass(NPC + F5)
findExcludeClass(NPC + F6)
findExcludeClass(NPC + F7)
findExcludeClass(NPC + F8)
findExcludeClass(NPC + F9)
findExcludeClass(NPC + F0)
findExcludeClass(NPC + F11)
findExcludeClass(F12)
findExcludeClass(NPC + F13)
findExcludeClass(NPC+P1)
findExcludeClass(NPC+P2)
findExcludeClass(NPC+P3)
findExcludeClass(NPC+P5)
#Exclude objects in these spheres
setColor(0,255,255)
#Closest Targets C1 is closest C3 is 3rd closest
C1a = findResult(1)
C2a = findResult(2)
C3a = findResult(3)
C11 = C1a:id()
C21 = C2a:id()
C31 = C3a:id()
if (C31==0 & C21!=0) {C31 = C21} 
if (C31==0 & C21==0 & C11!=0) {C31 = C11 C21 = C11}
C1 = entity(C11)
C2 = entity(C21)
C3 = entity(C31)
Tar:setEntity(1,C1)
Tar:setEntity(2,C2)
Tar:setEntity(3,C3)
} else {Tar=Pl:clone()}

