NPC see check

How to check if NPC can see it’s enemy or if enemy see NPC?

Give one of your npcs a weapon if the npc kills the other one it means it saw it.

You can probably use a trace.

Trace from the NPC’s view to the target NPC

Like this?

local pos = self:GetPos()
local ang = (self.Enemy:GetPos() - self:GetPos()):Angle()
local tracedata = {}
tracedata.start = pos
tracedata.endpos = pos+(ang*5000)
tracedata.filter = self
local trace = util.TraceLine(tracedata)
if trace.HitNonWorld then
	target = trace.Entity
	if(target == self.Enemy) then
		self.Sees = 1
		self.Sees = 0

It hardly work because TARGETED message pop-ups randomly.

EDIT2: solved by: tracedata.endpos = self.Enemy:GetPos()

Something like this should work
function CanNPCSeeEntity(npc, target)
local dir = (target:GetPos() - npc:GetPos()):Normalize()
local tr = util.TraceLine({start = npc:GetPos(), endpos = npc:GetPos() + dir * 16384, filter = npc})
return dir:Dot(npc:GetAimVector()) >= 0.5 and tr.Entity == target