diff options
Diffstat (limited to 'gamemode/npcsystem/sh_humannpc.lua')
| -rw-r--r-- | gamemode/npcsystem/sh_humannpc.lua | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/gamemode/npcsystem/sh_humannpc.lua b/gamemode/npcsystem/sh_humannpc.lua new file mode 100644 index 0000000..b4a2b15 --- /dev/null +++ b/gamemode/npcsystem/sh_humannpc.lua @@ -0,0 +1,67 @@ +local reg = nrequire("sh_npcsystem.lua") +local log = nrequire("log.lua") + + +local base1 = nrequire("sh_talkablenpc.lua") +local base2 = nrequire("sh_movingnpc.lua") + +local human_models = {} +for i = 1,7 do + human_models[#human_models + 1] = string.format("models/Humans/Group01/Female_0%d.mdl",i) +end +for i = 1,9 do + human_models[#human_models + 1] = string.format("models/Humans/Group01/Male_0%d.mdl",i) +end + +local npc = {} +setmetatable(npc,{__index = function(self,key) + if key == "Model" then + return human_models[math.random(#human_models)] + else + return base1.key or base2.key + end +end}) + +npc.Name = "Human NPC Base" + +npc.canlearn = true + +--things that npcs can learn +local learnable = { + action = { + "name", -- Name of the action + "preconditions", --Things that must be true before we can do an action + "postconditions", --Things that must be true after we do an ation + }, + event = { + "name", -- The name of the event + "time", -- When the event happened + "who", --Who was involved in the event ? + "where", --Where did this event take place ? + }, + entity = { --NOT the same as source engine entities + "name", --The name of this person + "relations", --Things about this person + }, + thing = { + "name", -- The name of the thing + "location", -- Where is this thing? + "size", --How big is this thing? + }, +} +for k,v in pairs(learnable) do + npc["known_" .. k .. "s"] = {} + local capt = k:gsub("^%l", string.upper) + npc["Teach" .. capt] = function(self,tbl) + if self.canlearn == false then return end + for i,j in pairs(v) do + if tbl[j] == nil then + log.error(string.format("Tried to teach %s about %s %q without field %q",self.Name, k, tbl.Name, j)) + end + end + local kt = self["known_" .. k .. "s"] + kt[#kt + 1] = tbl + end +end + +reg.RegisterNPC(npc, "Human NPC Base") |
