Which value should I use here with SetEnemy to make the NPC attack players of a certain team?

My code:


function PLUGIN:SpawnManhack(pos, client)

	local hack = ents.Create("npc_manhack")
	
	if (client:Team() == FACTION_CP) or (client:Team() == FACTION_OW) then
		hack:AddRelationship("player D_LI")
	end
	
	hack:SetPos(pos)
	hack:Spawn()
	hack:Activate()
	hack:SetEnemy(player.Team(FACTION_CITIZEN))
end


I recognize “hack:SetEnemy(player.Team(FACTION_CITIZEN))” is incorrect - as it returns Team as a nil value - but I’m not sure what function to add in there to make it attack players of the Citizen team while leaving players on the CP and OW team alone. When I run the function the manhack spawns where it’s supposed to, but leaves players of every faction alone, not just CP or OW.

Any pointers?

Bump. I’ve been dicking around with commands off the wiki but nothing seems to quite like it.

I believe that NPC:SetEnemy only works with one player object, a way that you could use this is to find the nearest player of that team to the NPC and to set that player as the enemy, however that would be quite inefficient.

Really? Damn, that sucks. I could try that, yeah - or I could try setting the relationship to D_HT of all FACTION_CITIZEN players, but I’m worried that might conflict with the D_LI to CP or OW teams.