Spawning Npcs into the map, through a timer then setting states on the npcs. [Help please!]
3 replies, posted
Hey, i got the npc to spawn and stuff. But the NPC will not set his health, i have no clue why.
I've tried many things.
Attempt #1
[code]
local npc = ents.Create("npc_zombie")
npc:SetNWInt("level", 255) // because the lolz and testing reasons...
npc:Fire("hp", 45*npc:GetNWInt("level"), 0)
npc:SetPos(Vector(0,0,0))
npc:Spawn()
npc:Activate()
[/code]
Attempt #2
[code]
local npc = ents.Create("npc_zombie")
npc:SetNWInt("level", 255) // because the lolz and testing reasons...
npc:Fire("health", 45*npc:GetNWInt("level"), 0)
npc:SetPos(Vector(0,0,0))
npc:Spawn()
npc:Activate()
[/code]
Attempt 3#
[code]
local npc = ents.Create("npc_zombie")
npc:SetNWInt("level", 255) // because the lolz and testing reasons...
npc:SetHealth(45*npc:GetNWInt("level"))
npc:SetPos(Vector(0,0,0))
npc:Spawn()
npc:Activate()
[/code]
Attempt 4#
[code]
local npc = ents.Create("npc_zombie")
npc:SetNWInt("level", 255) // because the lolz and testing reasons...
npc:SetHealth(200)
npc:SetPos(Vector(0,0,0))
npc:Spawn()
npc:Activate()
[/code]
I have no clue why its causing problems.
What i am thinking the npc, will have to be in its own npc code example:
[code]
Class = "npc_zombiehp500",
Model = "models/zombie_classic.mdl",
Health = "500",
KeyValues = {},
Category = "Zombies GRAHHHH!!!" }
[/code]
Which that system will suck... Also if i do that, what keyvalues should i put for zombies?
Thanks, hope you can help!
Try setting the health after you spawn it. IIRC spawning an entity will reset its health to default
I have a few examples on spawning enemies on map start and respawning on death or timer:
With respawn
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/entities/enemy_spawner.lua.html[/url]
One time spawn
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/entities/spawn_entities_on_map_start.lua.html[/url]
And yes, as code_gs says, SetHealth when it spawned.
Thank you everyone responding, i'm going to try your suggestions. Also, would i have permission Acecool, of using your code not entirely but, just to get an idea whats going on. Of course in my way coding it.
Sorry, you need to Log In to post a reply to this thread.