aboutsummaryrefslogtreecommitdiff
path: root/gamemode/npcsystem/sh_basenpc.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2018-11-03 18:23:45 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2018-11-03 18:23:45 -0400
commit28affa22541b9ef251707793f6b1c1a26d663592 (patch)
tree622754894d75c74dc5e8516ccf184ad4bf328fef /gamemode/npcsystem/sh_basenpc.lua
parentc639e7c7c6ab1595fdce39f56312e3d6a886bbe8 (diff)
downloadartery-28affa22541b9ef251707793f6b1c1a26d663592.tar.gz
artery-28affa22541b9ef251707793f6b1c1a26d663592.tar.bz2
artery-28affa22541b9ef251707793f6b1c1a26d663592.zip
Started on new npc system
Started work on the new npc system
Diffstat (limited to 'gamemode/npcsystem/sh_basenpc.lua')
-rw-r--r--gamemode/npcsystem/sh_basenpc.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/gamemode/npcsystem/sh_basenpc.lua b/gamemode/npcsystem/sh_basenpc.lua
new file mode 100644
index 0000000..b3e7e49
--- /dev/null
+++ b/gamemode/npcsystem/sh_basenpc.lua
@@ -0,0 +1,34 @@
+--[[
+ Defines some ai primitives for npc's
+]]
+local log = nrequire("log.lua")
+local reg = nrequire("sh_npcsystem.lua")
+
+local npc = {}
+
+npc.Name = "NPC Base"
+
+function npc:Spawn()
+ local e = ents.Create("art_npc")
+
+ 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
+
+ self.Entity = e
+ e:Spawn()
+end
+
+reg.RegisterNPC(npc)
+
+return npc