Making NPC's and where to put them?

I am trying to do some stuff with npc’s but am a bit lost on the wiki.
so far i have been able to use this to spawn an npc where i am looking at and have it hate me.
[lua]
function testnpc ( ply,cmd )
local tr = ply:GetEyeTrace(1000)
local ant = ents.Create(“npc_antlion”)
ant:SetPos(tr.HitPos + Vector(0,0,5))
ant:AddEntityRelationship(player.GetByID(1), 1, 100 )
ant:Spawn()
Msg("antlion spawned.
")
end
[/lua]
But that is as far as i can get with making npc’s.
How do i set up npc schedule’s, and how would i be able to make a npc from scratch?
Is it possible to make my own entity that is an npc ?
Sorry for the dumb questions, its the first time i am playing around with npc’s, and don’t know where to go from here.