--[[ Defines some ai primitives for npc's ]] print("Update from basenpc.lua!") local log = nrequire("log.lua") local reg = nrequire("sh_npcsystem.lua") local npc = {} npc.Name = "NPC Base" --At this point we are the prototype table local num_npcs = 0 function npc:Spawn() num_npcs = num_npcs + 1 local e = ents.Create("art_npc") local metas = {} setmetatable(self,{ __index = function(self,key) return e[key] end, __newindex = function(self,key,value) e[key] = value end, __metatable = function(self) return getmetatable(e) end, }) if self.Pos then e:SetPos(self.Pos) else log.warn("NPC created without a position, this might be a bug!") end if self.Name then e:SetName(self.Name) else e:SetName(string.format("npc_%d",num_npcs)) end if self.Ang then e:SetAngles(self.Ang) end e:Spawn() self.Entity = e end npc.Model = "models/editor/playerstart.mdl" function npc:edit_hud() return { {"string","Model",self.Model}, {"vector3","Start pos",self.Pos}, {"string","Name",self.Name} } end reg.RegisterNPC(npc) return npc