I've been trying to work out SNPCs for the past day and found myself using a npc_base that seems to be common.
(Used by this: [URL]http://www.garrysmod.org/downloads/?a=view&id=120296[/URL])
The problem is that my NPC doesn't perform the action dictated which is swing and it simply stands still and continues with the hit.
here is my [B]npc_gm_zombie [/B]code, If you can assist I would be extremely thankful.
[lua]
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')
ENT.AnimScale = 3
ENT.Damage = 75
function ENT:Initialize()
self:SetModel("models/Zombie/Classic.mdl")
self:SetHullType(HULL_HUMAN)
self:SetHullSizeNormal()
self:SetSolid(SOLID_BBOX)
self:SetMoveType(MOVETYPE_STEP)
self:CapabilitiesAdd( CAP_MOVE_GROUND | CAP_ANIMATEDFACE | CAP_TURN_HEAD | CAP_WEAPON_MELEE_ATTACK1 | CAP_INNATE_MELEE_ATTACK1)
self:SetMaxYawSpeed(5000)
self:SetHealth(10000)
end
function ENT:SpawnFunction( ply, tr )
if (!tr.Hit) then return end
local SpawnPos = tr.HitPos + tr.HitNormal * 20
local ent = ents.Create( "npc_gm_zombie" )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
return ent
end
function ENT:SelectSchedule()
local schdChase = ai_schedule.New("Zombie Chase")
schdChase:AddTask("FindEnemy",{Class = "player", Radius = 3000})
schdChase:EngTask("TASK_GET_PATH_TO_ENEMY", 0)
schdChase:EngTask("TASK_RUN_PATH_TIMED", 0.1)
schdChase:EngTask("TASK_WAIT", 0.1)
local close = false
for k,v in pairs(ents.FindInSphere(self:GetPos(),100)) do
if v:IsPlayer() and v:Alive() then
close = true
break
end
end
if close then
schdChase:EngTask("TASK_STOP_MOVING", 0)
schdChase:EngTask("TASK_FACE_ENEMY", 0)
schdChase:AddTask("PlaySequence", {Name = "swing", Speed = 1})
end
self:StartSchedule(schdChase)
end
[/lua]
[B]*EDIT[/B] - Sorry for bothering people, I fixed it by going into source SDK and checking the sequence names and applying properly.
Sorry, you need to Log In to post a reply to this thread.