Zombie and Table Question

I’m trying to edit the original half life 2 zombie or npc_zombie.
I cannot seem to find the lua file for that zombie, is it not there because it is directly ported?
If so will I have to recreate the hl2 zombie in lua.

Also I’m trying to make a table that calls entities from the values,

function randomitem() 
local myTable = {"Apple", "Bannana", "Orange", "Nothing"}
 print( myTable[ math.random( #myTable ) ] )
concommand.Add("randomitem", randomitem)

At the moment this table when I type randomitem prints either apple banana orange or nothing.
Instead of printing the random value i want it to spawn the entity,
that i have already made like the Apple Entity etc.

If anything is unclear I will reiterate,
Thanks in advance.

local ent = ents.Create(myTable[ math.random( #myTable ) ])
ent:SetPos(tr.HitPos) – or set this to where ever you want it spawned really

Untested but can’t see any faults really.

Thank you!
How would i get the position of self, self being the spawner of the entity, and make it so it spawns at that position.
ent:SetPos(self.HitPos) or something?

self isn’t defined in your code. Use this:

concommand.Add("randomitem", function(ply)
    local myTable = {"npc_zombie", "npc_1", "npc_2"}
    local ent = ents.Create(table.Random(myTable))

[editline]28th January 2011[/editline]

And npc_zombie is written in C++, thats why you cant find its lua file. Don’t even try to create a zombie SNPC, not trying to be offensive, but you need to be way more experienced than you are now. There are allot of other ways to control AI, tho way harder, but possible.

Of course im not offended lol.
But the reason I was trying to edit the zombie was really only for a ondeath function and not AI.

hook.Add("OnNPCKilled", "Zombie_Death", function(npc, inf, att)
    if npc:GetClass() == "npc_zombie" then
    //On zombie death code.

That seems to work but when I want to edit the recently dead zombie as in, Get the Position Of The Recently Dead Zombie, What do I refer the entity as.
Do i say self.getpos again or is it ent.getpos?

self does not exist. OnNPCKilled is called 1 frame before an NPC is killed. After an NPC is killed a ragdoll is created in its place with the same property’s, but the npc gets removed. Self does not exist, npc:GetPos().

And what exactly are you trying to accomplish? What are you trying to code?