aboutsummaryrefslogtreecommitdiff
path: root/gamemode/npcsystem
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2019-05-04 16:05:01 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2019-05-04 16:05:01 -0400
commit100342bdd0a979f283f90875663784f20282dd5e (patch)
tree8188ab5f9dd979d552df3d41fb31b1166b01d150 /gamemode/npcsystem
parentfaa8312074e6ea8a96efd70d6188ef592f81e579 (diff)
downloadartery-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')
-rw-r--r--gamemode/npcsystem/sh_basenpc.lua50
-rw-r--r--gamemode/npcsystem/sh_humannpc.lua4
-rw-r--r--gamemode/npcsystem/sh_movingnpc.lua9
-rw-r--r--gamemode/npcsystem/sh_shop.lua2
-rw-r--r--gamemode/npcsystem/sh_talkablenpc.lua5
-rw-r--r--gamemode/npcsystem/sh_townie.lua2
6 files changed, 53 insertions, 19 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)
diff --git a/gamemode/npcsystem/sh_humannpc.lua b/gamemode/npcsystem/sh_humannpc.lua
index b4a2b15..5cd31f8 100644
--- a/gamemode/npcsystem/sh_humannpc.lua
+++ b/gamemode/npcsystem/sh_humannpc.lua
@@ -18,7 +18,7 @@ setmetatable(npc,{__index = function(self,key)
if key == "Model" then
return human_models[math.random(#human_models)]
else
- return base1.key or base2.key
+ return base1[key] or base2[key]
end
end})
@@ -65,3 +65,5 @@ for k,v in pairs(learnable) do
end
reg.RegisterNPC(npc, "Human NPC Base")
+
+return npc
diff --git a/gamemode/npcsystem/sh_movingnpc.lua b/gamemode/npcsystem/sh_movingnpc.lua
index 21f302e..22ddad1 100644
--- a/gamemode/npcsystem/sh_movingnpc.lua
+++ b/gamemode/npcsystem/sh_movingnpc.lua
@@ -1,16 +1,19 @@
local reg = nrequire("sh_npcsystem.lua")
local base = nrequire("sh_basenpc.lua")
-local nextbot = scripted_ents.Get("base_nextbot")
+local nextbot = nil --Nextbots aren't registered until after this script is run,
+--So we need the hacks below to get a "real" nextbot.
local npc = {}
npc.Name = "Walkable NPC Base"
setmetatable(npc,{__index = function(self,key)
- return self[key] or base[key] or nextbot[key]
+ if nextbot == nil then nextbot = scripted_ents.Get("base_nextbot") end
+ return base[key] or nextbot[key]
end})
function npc:Initalize()
+ if nextbot == nil then nextbot = scripted_ents.Get("base_nextbot") end
if base.Initalize then base.Initalize(self) end
if nextbot.Initalize then nextbot.Initalize(self) end
print("After initalizeing walkable, self.loco is", self.loco)
@@ -20,3 +23,5 @@ function npc:Face(ang_or_vec)
print("trying to face:",ang_or_vec,type(ang_or_vec))
end
reg.RegisterNPC(npc)
+
+return npc
diff --git a/gamemode/npcsystem/sh_shop.lua b/gamemode/npcsystem/sh_shop.lua
index c2b291d..31423b6 100644
--- a/gamemode/npcsystem/sh_shop.lua
+++ b/gamemode/npcsystem/sh_shop.lua
@@ -1,3 +1,5 @@
+print("No longer Hello from sh_shop.lua!")
+
local reg = nrequire("sh_npcsystem.lua")
local base = nrequire("sh_talkablenpc.lua")
diff --git a/gamemode/npcsystem/sh_talkablenpc.lua b/gamemode/npcsystem/sh_talkablenpc.lua
index 9e1cfb9..85c5aaa 100644
--- a/gamemode/npcsystem/sh_talkablenpc.lua
+++ b/gamemode/npcsystem/sh_talkablenpc.lua
@@ -9,6 +9,11 @@ setmetatable(npc,{__index = base})
npc.Name = "Talkable NPC Base"
+--Get the dialog for a particular player
+function npc.getDialogFor(ply)
+
+end
+
reg.RegisterNPC(npc)
return npc
diff --git a/gamemode/npcsystem/sh_townie.lua b/gamemode/npcsystem/sh_townie.lua
index 3b693c5..6f93c99 100644
--- a/gamemode/npcsystem/sh_townie.lua
+++ b/gamemode/npcsystem/sh_townie.lua
@@ -1,7 +1,7 @@
local reg = nrequire("sh_npcsystem.lua")
local base1 = nrequire("sh_talkablenpc.lua")
-local base2 = nrequire("sh_moveingnpc.lua")
+local base2 = nrequire("sh_movingnpc.lua")
local npc = {}
local npc_m = {__index = function(self,key)