diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2019-05-04 16:05:01 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2019-05-04 16:05:01 -0400 |
| commit | 100342bdd0a979f283f90875663784f20282dd5e (patch) | |
| tree | 8188ab5f9dd979d552df3d41fb31b1166b01d150 /gamemode/npcsystem/sh_basenpc.lua | |
| parent | faa8312074e6ea8a96efd70d6188ef592f81e579 (diff) | |
| download | artery-100342bdd0a979f283f90875663784f20282dd5e.tar.gz artery-100342bdd0a979f283f90875663784f20282dd5e.tar.bz2 artery-100342bdd0a979f283f90875663784f20282dd5e.zip | |
Started on the NPC overhual
Added some bits to start on the npcs overhaul
Diffstat (limited to 'gamemode/npcsystem/sh_basenpc.lua')
| -rw-r--r-- | gamemode/npcsystem/sh_basenpc.lua | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/gamemode/npcsystem/sh_basenpc.lua b/gamemode/npcsystem/sh_basenpc.lua index b3e7e49..32c203a 100644 --- a/gamemode/npcsystem/sh_basenpc.lua +++ b/gamemode/npcsystem/sh_basenpc.lua @@ -1,6 +1,7 @@ --[[ Defines some ai primitives for npc's ]] +print("Update from basenpc.lua!") local log = nrequire("log.lua") local reg = nrequire("sh_npcsystem.lua") @@ -8,25 +9,44 @@ 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 - if self.Model then self:SetModel(self.Model) - else log.error("NPC created without model, this might be a bug!") end - - if self.Pos then self:SetPos(self.Pos) - else log.error("NPC created without a position, this might be a bug!") end - - self.talking = false - - if self.Name then self:SetName(self.Name) - else log.error("NPC created without a name! They won't be able to open doors!") end - - if self.Ang then self:SetAngles(self.Ang) end - if self.OnSpawn then self.OnSpawn(self) end +npc.Model = "models/editor/playerstart.mdl" - self.Entity = e - e:Spawn() +function npc:edit_hud() + return { + {"string","Model",self.Model}, + {"vector3","Start pos",self.Pos}, + {"string","Name",self.Name} + } end reg.RegisterNPC(npc) |
