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:
[code]local headcrab = ents.Create("npc_headcrab")
self.Entity = headcrab[/code]
Or instead of doing a custom SNPC, you could do:
[lua]function MakeHeadcrab(pos)
local npc = ents.Create("npc_headcrab")
npc:SetPos(pos)
hook.Add("ScaleNPCDamage",function(vic,hit,dmg)
if vic == npc then
-- Do stuff here
end
end)
npc:Activate()
npc:Spawn()
end[/lua]
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..
[lua]
local sexyheadcrab = ents.Create("npc_headcrab")
local metatable = sexyheadcrab:GetTable()
function metatable:OnTakeDamage(dmg)
-- Do awesome stuff here
end
[/lua]
:eng101:
[editline]10:49PM[/editline]
It's probably one of the least messy things you can actually do.
[QUOTE=Gbps;16637588][lua]
local sexyheadcrab = ents.Create("npc_headcrab")
local metatable = sexyheadcrab:GetTable()
function metatable:OnTakeDamage(dmg)
-- Do awesome stuff here
end
[/lua]
:eng101:
[editline]10:49PM[/editline]
It's probably one of the least messy things you can actually do.[/QUOTE]
Couldn't you just set the entity base to npc_headcrab?
Nay, npc_headcrab is not a scripted entity. :(
Sorry, you need to Log In to post a reply to this thread.