@name 3 Closest Enemy Targets
@inputs On Players:array EntID
#@outputs Threat1 Threat2 Threat3 Threat4 Threat5 Threat6 Threat7
@outputs C1:entity C2:entity C3:entity Count C11 C21 C31
@persist Threat1 Threat2 Threat3 Threat4 Threat5 Threat6 Threat7
@persist Tick
interval(50)
#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"



findInSphere(entity(EntID):pos(),10000)
findSortByDistance(entity(EntID):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)
#Exclude objects in these spheres
Count = Players:count()
SafeZone = 1000
if (Count>0) {findClipFromSphere(entity(Players:number(1)):pos(),SafeZone)}
if (Count>1) {findClipFromSphere(entity(Players:number(2)):pos(),SafeZone)}
if (Count>2) {findClipFromSphere(entity(Players:number(3)):pos(),SafeZone)}
if (Count>3) {findClipFromSphere(entity(Players:number(4)):pos(),SafeZone)}
if (Count>4) {findClipFromSphere(entity(Players:number(5)):pos(),SafeZone)}
if (Count>5) {findClipFromSphere(entity(Players:number(6)):pos(),SafeZone)}
if (Count>6) {findClipFromSphere(entity(Players:number(7)):pos(),SafeZone)}
if (Count>7) {findClipFromSphere(entity(Players:number(8)):pos(),SafeZone)}
setColor(0,255,255)
Tick += 1
if (Tick==1) {Threat1 = findByClass(NPC + P1)} 
if (Tick==2) {Threat2 = findByClass(NPC + P1)} 
if (Tick==3) {Threat3 = findByClass(NPC + P3)} 
if (Tick==4) {Threat4 = findByClass(NPC + P4)} 
if (Tick==5) {Threat5 = findByClass(NPC + P5)} 
if (Tick==6) {Threat6 = findByClass(NPC + P6)} 
if (Tick==7) {Threat7 = findByClass(NPC)}
if (Tick==7) {Tick = 0}
#Closest Targets C1 is closest C3 is 3rd closest
C1 = findResult(1)
C2 = findResult(2)
C3 = findResult(3)
C11 = C1:id()
C21 = C2:id()
C31 = C3:id()
if (C31==0 & C21!=0) {C31 = C21} 
if (C31==0 & C21==0 & C11!=0) {C31 = C11 C21 = C11}
