Headcrab SNPC

What I need is a way to spawn an npc_headcrab (or any other regular npc) with different/modifiable properties. For instance an npc_headcrab_fire…

Basically I want to have an entity that derives from the normal headcrab… Any clues of how to do it?

edit : For instance I’d like to be able to use ENT:OnTakeDamage() on my npc.

You mean just make a custom entity that creates a headcrab npc on start? Like, in the init, you would just use ents.Create(“npc_headcrab”).

Well I actually have something like that but I’m not sure how I could use OnTakeDamage() and other entity hooks on the spawned headcrab…

I’m not too experienced with custom entities, but maybe you could do something like:

local headcrab = ents.Create("npc_headcrab")
self.Entity = headcrab

Or instead of doing a custom SNPC, you could do:

[lua]function MakeHeadcrab(pos)
local npc = ents.Create(“npc_headcrab”)

	if vic == npc then
		-- Do stuff here



Just an idea.

Yeah but then I plan on doing a ton of these NPCs so it’s either that or possibly the NPC Meta table (?)… But I’m afraid it could get messy…

local sexyheadcrab = ents.Create(“npc_headcrab”)
local metatable = sexyheadcrab:GetTable()
function metatable:OnTakeDamage(dmg)
– Do awesome stuff here



It’s probably one of the least messy things you can actually do.

Couldn’t you just set the entity base to npc_headcrab?

Nay, npc_headcrab is not a scripted entity. :frowning: