turret prop shooter

Using lua im trying to spwan a turret that shoots props and not players.

this is what i have so far. I got it to not shoot players but it still wont shoot props.
[lua]
function Add_NPC_Boat(pl, command, args) --Add_NPC_Boat
local tr = pl:GetEyeTrace() – tr now contains a trace object
local ent = ents.Create(“npc_turret_floor”) – This creates our npc entity
ent:SetPos(tr.HitPos) – This positions the npc at the place our trace hit.
ent:Spawn() – This method spawns the npc into the world
ent:AddRelationship(“player D_LI 999”) --stops turret from shooting players
ent:SetNWInt(“PropHealth”, 10) --Gamemode stuff
ent:Activate() --idk if this is needed

for k, v in pairs(ents.GetAll()) do
	if v:IsValid() and !v:IsWorld() and !v:IsPlayer() then
		if tostring(v:GetClass()) == "prop_physics" then
			print("added a turret")
			ent:SetEnemy( v )
			ent:SetTarget( v )
			ent:AddEntityRelationship(v, D_HT, 999)                       --make turret hate the prop
			print(ent:Disposition(v))
		end
	end
end

end
[/lua]

I don’t think that’s possible since a prop is not derived from NPC or Player.

Maybe adding an entity or something of such to it. Not sure, I’m purely guessing, sorry.

I have it somewhat figured out any ideas?

[lua]

– npc Boat Functions --------------------------------

function NPC_Boat_Aim()
for k, v in pairs(ents.GetAll()) do
if v:IsValid() and !v:IsWorld() and !v:IsPlayer() then
if tostring(v:GetClass()) == “npc_turret_floor” then
local turret = v
local bull = turret:GetNetworkedEntity(“target”)
------------------------------
------------------------------
if bull:GetNetworkedEntity(“shoot”) then
local X = math.random(-30,30)
local Y = math.random(-30,30)
local Pos = bull:GetNetworkedEntity(“shoot”):LocalToWorld( bull:GetNetworkedEntity(“shoot”):OBBCenter( ) )
bullpos = Vector(Pos.x + X,Pos.y + Y, Pos.z) – I had to do this so at least some of the bullseyes could be seen by the enemy
bull:SetPos(bullpos)
bull:SetPos(bull:GetNetworkedEntity(“shoot”):GetPos( ))
else
for k, v in pairs(ents.GetAll()) do
if v:IsValid() and !v:IsWorld() and !v:IsPlayer() then
if tostring(v:GetClass()) == “prop_physics” then
local X = math.random(-30,30)
local Y = math.random(-30,30)
local Pos = v:LocalToWorld( v:OBBCenter( ) )
bullpos = Vector(Pos.x + X,Pos.y + Y, Pos.z) – I had to do this so at least some of the bullseyes could be seen by the enemy
bull:SetPos(bullpos)
bull:SetNetworkedEntity(“shoot”, v)
end
end
end
end
end
end
end
end
function Add_NPC_Boat(pl, command, args) --Add_NPC_Boat
local tr = pl:GetEyeTrace() – tr now contains a trace object
local ent = ents.Create(“npc_turret_floor”) – This creates our npc entity
ent:SetPos(tr.HitPos) – This positions the npc at the place our trace hit.
ent:Spawn() – This method spawns the npc into the world
–ent:Give(“weapon_pistol”) – This method gives the npc a pistol
–ent:Give(“item_ammo_pistol”) --Crashes the game
–ent:GiveAmmo(9999, “Pistol”) --Crashes the game
–ent:SetTarget( )
ent:AddRelationship(“player D_LI 999”)
ent:SetNWInt(“PropHealth”, 10)
ent:Activate()

local bull = ents.Create("npc_bullseye")
bull:SetKeyValue("health","9999")
bull:SetNotSolid( true )
local X = math.random(-30,30)
local Y = math.random(-30,30)
for k, v in pairs(ents.GetAll()) do
	if v:IsValid() and !v:IsWorld() and !v:IsPlayer() then
		if tostring(v:GetClass()) == "prop_physics" then
			local Pos = v:LocalToWorld( v:OBBCenter( ) )
			bullpos = Vector(Pos.x + X,Pos.y + Y, Pos.z) -- I had to do this so at least some of the bullseyes could be seen by the enemy
			bull:SetPos(bullpos)
			bull:SetNetworkedEntity("shoot", v)
		end
	end
end
ent:SetNetworkedEntity("target", bull)
bull:Spawn()
ent:SetEnemy( bull )
ent:SetTarget( bull )
ent:AddEntityRelationship(bull, D_HT, 999)
--print("GetEnemy()- "..tostring(ent:GetEnemy()))

//local a = bit.bor( CAP_AIM_GUN, CAP_WEAPON_RANGE_ATTACK2, CAP_USE_WEAPONS )
//ent:CapabilitiesAdd( a )
NPC_Present = NPC_Present + 1

end
concommand.Add( “Add_NPC_Boat”, Add_NPC_Boat )
[/lua]

This works better and is less lines

[lua]

– npc Boat Functions --------------------------------

function NPC_Boat_Aim()
for k, v in pairs(ents.GetAll()) do
if v:IsValid() and !v:IsWorld() and !v:IsPlayer() then
if tostring(v:GetClass()) == “npc_bullseye” then
v:Remove()
end
end
end
local NumberA = 0
while(NumberA <= 2) do
for k, v in pairs(ents.GetAll()) do
if v:IsValid() and !v:IsWorld() and !v:IsPlayer() then
if tostring(v:GetClass()) == “prop_physics” then
–Creat_bull(v)
local bull = ents.Create(“npc_bullseye”)
local X = math.random(-30,30)
local Y = math.random(-30,30)
local Pos = v:LocalToWorld( v:OBBCenter( ) )
bullpos = Vector(Pos.x + X,Pos.y + Y, Pos.z) – I had to do this so at least some of the bullseyes could be seen by the enemy
bull:SetParent(v)
bull:SetPos(bullpos)
bull:SetKeyValue(“health”,“9999”)
bull:SetKeyValue(“minangle”,“360”)
bull:SetKeyValue(“spawnflags”,“516”)
bull:SetNotSolid( true )
bull:Spawn()
bull:Activate()
end
end
end
NumberA = NumberA + 1
end
end
function Add_NPC_Boat(pl, command, args) --Add_NPC_Boat
local tr = pl:GetEyeTrace() – tr now contains a trace object
local ent = ents.Create(“npc_turret_floor”) – This creates our npc entity
ent:SetPos(tr.HitPos) – This positions the npc at the place our trace hit.
ent:SetCurrentWeaponProficiency( WEAPON_PROFICIENCY_VERY_GOOD )
ent:Spawn() – This method spawns the npc into the world
–ent:Give(“weapon_pistol”) – This method gives the npc a pistol
–ent:Give(“item_ammo_pistol”) --Crashes the game
–ent:GiveAmmo(9999, “Pistol”) --Crashes the game
–ent:SetTarget( )
ent:AddRelationship(“player D_LI 999”)
ent:SetNWInt(“PropHealth”, 1000)
ent:SetNWInt(“type”, 1)
ent:Activate()
ent:AddRelationship(“npc_bullseye D_HT 999”)
NPC_Present = NPC_Present + 1
NPC_Boat_Aim()
end
concommand.Add( “Add_NPC_Boat”, Add_NPC_Boat )
[/lua]