SNPCs - In settles the frustration

I’m on the last leg of my patience in trying to get my SNPC to function properly with what we’re given on the wiki, and I have no idea how to give it a relationship or get it to do anything on condition. Basically, I need help in trying to get the SNPC to detect some enemies specified within a table, and then run to them and (my stuff goes here).

The current init code looks like this:


 AddCSLuaFile( "cl_init.lua" ) 
 AddCSLuaFile( "shared.lua" ) 
   
 include('shared.lua') 
 
ENT.Spawn = {"devinrpg/people/footman/spawn.wav"}

ENT.InRange = {"devinrpg/people/footman/attack1.wav",
"devinrpg/people/footman/attack2.wav",
"devinrpg/people/footman/attack3.wav"}

ENT.PlateHigh = {"devinrpg/chop20_plate_1.wav",
"devinrpg/chop20_plate_2.wav",
"devinrpg/chop20_plate_3.wav"}

ENT.PlateLow = {"devinrpg/chop5_plate_1.wav",
"devinrpg/chop5_plate_2.wav"}

ENT.ClothHigh = {"devinrpg/chop20_1.wav",
"devinrpg/chop20_2.wav",
"devinrpg/chop20_3.wav"}

ENT.ClothLow = {"devinrpg/chop5_1.wav",
"devinrpg/chop5_2.wav",
"devinrpg/chop5_3.wav"}

ENT.Death = {"devinrpg/people/player/death2.wav"}

ENT.Enemies = {"npc_zombie",
			  "npc_fastzombie"} 

ENT.ChatterTime = 0


 local schdChase = ai_schedule.New( "AIFighter Chase" )
 	 

   schdChase:EngTask( "TASK_GET_PATH_TO_RANDOM_NODE", 128 )
   schdChase:EngTask( "TASK_WALK_PATH", 0 )
   schdChase:EngTask( "TASK_WAIT_FOR_MOVEMENT", 0 )
   schdChase:EngTask( "TASK_GET_PATH_TO_RANGE_ENEMY_LKP_LOS", 0 )
   schdChase:EngTask( "TASK_RUN_PATH", 0 )
   schdChase:EngTask( "TASK_WAIT_FOR_MOVEMENT", 0 )
 
 
	


 function ENT:SpawnFunction( ply, tr )

	if ( !tr.Hit ) then return end
	
	local SpawnPos = tr.HitPos + tr.HitNormal * 20
	
	local ent = ents.Create( "npc_footman" )
	ent:SetPos( SpawnPos )
	ent:Spawn()
	ent:Activate()
	
	return ent
	
end

function ENT:Pat()
	self:TaskComplete()
	self:StartSchedule(SchPat)
end

function ENT:Initialize() 

	self:EmitSound(Sound("devinrpg/people/footman/spawn.wav"),100,100)
   
 	self:SetModel( "models/devin/gabe_snpc.mdl" ) 
 	 
 	self:SetHullType( HULL_HUMAN ); 
 	self:SetHullSizeNormal(); 
 	 
 	self:SetSolid( SOLID_BBOX )  
 	self:SetMoveType( MOVETYPE_STEP ) 
 	 
 	self:CapabilitiesAdd( CAP_MOVE_GROUND | CAP_OPEN_DOORS | CAP_ANIMATEDFACE | CAP_TURN_HEAD | CAP_USE_SHOT_REGULATOR | CAP_AIM_GUN ) 
 	 
 	self:SetMaxYawSpeed( 5000 )
	
	self.MaxHealth = 200
	self.Damage = 0
	self.CurrentArmor = 400
	self.Level = 1
	self:SetNWInt("npchealth",self.MaxHealth)
	
	local sequence = self:LookupSequence("walk_panicked_all")
	self:SetSequence(sequence)
	self:SetPlaybackRate(2.0)

 end 
 
 function ENT:Think()
 
local targets = ents.FindInSphere(self.Entity:GetPos(),512)
for _,v in pairs(targets) do
	if v:GetClass() == "npc_zombie" then
	self:SetEnemy(v,true)
	self:Chatter()
		
			end
		end
	end
	
function ENT:Chatter()
if CurTime() > self.ChatterTime then
	self.ChatterTime = CurTime() + math.random(4,6)
	self:EmitSound(table.Random((self.InRange)),100,100)
end
end


 function ENT:OnTakeDamage(dmg) 
  
local DamageResistance = ( (self.CurrentArmor) / ( (self.CurrentArmor) +(400)+(85) * (self.Level)) )

self.LastAttacker = dmg:GetAttacker()
self.Damage = self.Damage + ( (  dmg:GetDamage() ) - ( dmg:GetDamage() / 100) * ( DamageResistance * 100 ) )
self:SetNWInt("npchealth",self.MaxHealth - self.Damage)

if  dmg:GetDamage() > 20 and ( DamageResistance * 100 ) > .3 then 
	self:EmitSound(table.Random((self.PlateHigh)),100,100)
end

if  dmg:GetDamage() > 0 and dmg:GetDamage() < 25 and ( DamageResistance * 100 ) > .3 then 
	self:EmitSound(table.Random((self.PlateLow)),100,100)
end

if  dmg:GetDamage() > 20 and ( DamageResistance * 100 ) < .3 then 
	self:EmitSound(table.Random((self.ClothHigh)),100,100)
end

if  dmg:GetDamage() > 0 and dmg:GetDamage() < 25 and ( DamageResistance * 100 ) < .3 then 
	self:EmitSound(table.Random((self.ClothLow)),100,100)
end

if  dmg:GetDamage() > 1 then 
	self:AddEntityRelationship( dmg:GetAttacker(), 1, 10 )
end

	
	if self.Damage >= self.MaxHealth then
	self:DoDeath()
		end
end
   
function ENT:DoDeath(dmginfo)

	self:EmitSound(table.Random((self.Death)),100,100)
			
	local ragdoll = ents.Create("prop_ragdoll")
	ragdoll:SetKeyValue("angles", self:GetAngles().p + math.random(-3,3).." "..self:GetAngles().y +  math.random(-3,3).." "..self:GetAngles().r + math.random(-3,3))
	ragdoll:SetPos(self:GetPos())
	ragdoll:SetModel(self:GetModel())
	ragdoll:Spawn()
	ragdoll:Activate()
	ragdoll:Fire("kill",1,10)
	ragdoll:SetCollisionGroup( COLLISION_GROUP_WEAPON )
	
	for i=1,128 do
		local bone = ragdoll:GetPhysicsObjectNum( i )
		if ValidEntity( bone ) then
			local bonepos, boneang = ragdoll:GetBonePosition( ragdoll:TranslatePhysBoneToBone( i ) )
			bone:SetPos( bonepos )
			bone:SetAngle( boneang )
		end
	end
			
	local phys = ragdoll:GetPhysicsObject()
	if phys:IsValid() then
		phys:SetMass(50)
		local fnum = 900
		phys:ApplyForceCenter((ragdoll:GetPos()-self:GetPos())*math.random(50,200))
	end
			
	self:SetSchedule( SCHED_FALL_TO_GROUND )
	self:Remove()
end
  
   
   
 /*--------------------------------------------------------- 
    Name: SelectSchedule 
 //-------------------------------------------------------*/ 
 function ENT:SelectSchedule() 
   
 	self:StartSchedule( schdChase ) //run the schedule we created earlier 
   
 end

I know it has something to do with the schedules, but any attempts at putting anything through them spits out odd errors.

This SNPC is part of an upcoming combat system that I plan to work on more intensely when my PC is fixed.

[lua] [ /lua] pls