diff options
Diffstat (limited to 'gamemode/core')
| -rw-r--r-- | gamemode/core/npc/sv_huntingspawner.lua | 8 | ||||
| -rw-r--r-- | gamemode/core/npc/sv_npcsystem.lua | 33 | ||||
| -rw-r--r-- | gamemode/core/npc/sv_shop.lua | 7 |
3 files changed, 42 insertions, 6 deletions
diff --git a/gamemode/core/npc/sv_huntingspawner.lua b/gamemode/core/npc/sv_huntingspawner.lua index 153b961..0fe4aa0 100644 --- a/gamemode/core/npc/sv_huntingspawner.lua +++ b/gamemode/core/npc/sv_huntingspawner.lua @@ -1,3 +1,7 @@ +---Lets huntable monsters drop loot! +-- Register what monsters drop what loot +--@module sv_huntingspawner.lua + --[[ This file spawns the huntable npc's in their zones. ]] @@ -95,6 +99,10 @@ hook.Add("Tick","occasionally_spawn_monsters",function() end) local external_drops = {} +---Register a monster's loot. +-- Register a table of loot to probability of dropping to a monster. Will warn if you try to register the same monster twice. An npc can define it's own drops, but if you're using npcs from elsewhere, use this function to tell the gamemode what to drop on each npc's death. +--@tparam string npcname The name of the npc to give loot to +--@tparam table tbl The table of {"item\_name"=number\_drop_chance}, drop chance should be in the range 0 < x <= 100. 100 is always drop, 0 is never drop. function o.RegisterDrops(npcname,tbl) if not external_drops[npcname] == nil then MsgC(Color(255,255,0),"WARNING: Tried to register 2 drop tables for " .. npcname) diff --git a/gamemode/core/npc/sv_npcsystem.lua b/gamemode/core/npc/sv_npcsystem.lua index d5182d7..0ed21d2 100644 --- a/gamemode/core/npc/sv_npcsystem.lua +++ b/gamemode/core/npc/sv_npcsystem.lua @@ -1,8 +1,16 @@ +---Various functions for npcs. +-- Helps you spawn monsters, townies, and shopkeepers +--@module sv_npcsystem.lua + local f = nrequire("concommands.lua") local n = {} local npcs = {} --Master table of npcs local autocompletef +---Registers an NPC. +-- Adds an npc to the global table. NPC's should have unique .Name fields, if they don't, this function will error. +--@see npc +--@tparam table npc The npc's table. function n.RegisterNPC(npc) assert(npc ~= nil, "Attempted to register a nil npc") assert(npc.Name ~= nil, "Attempted to register an npc without a name") @@ -10,6 +18,10 @@ function n.RegisterNPC(npc) autocompletef = f.AutocompleteFunction(npcs) end +---Creates an NPC. +-- Creates an npc, by name +--@tparam string npcname The npc's name +--@tparam vector3 pos The position to spawn the npc function n.CreateNPCByName(npcname, pos) assert(npcs[npcname],string.format("No npc named %q, valid names are:\n%s",npcname,table.concat(table.GetKeys(npcs),"\n"))) --print("Createing a ", npcname, " at ", pos) @@ -26,7 +38,10 @@ function n.CreateNPCByName(npcname, pos) return npc end ---Creates a shop npc with this tbl +---Creats a shop npc. +-- Creates a shop npc from a shop npc table +--@see shopnpctbl +--@tparam table npc The shop npc's table. function n.CreateShop(npc) --print("Createing shop npc") local npcent = ents.Create("npc_shop") @@ -37,7 +52,10 @@ function n.CreateShop(npc) --print("Called spawn") end ---Creates a townie npc with this tbl +---Creates a townie. +-- Creates a new townie that wanders around his areas of intrest +--@see townienpctbl +--@tparam table npc The townie npc's table. function n.CreateTownie(tbl) local npcent = ents.Create("npc_townie") for k, v in pairs(tbl) do @@ -46,7 +64,10 @@ function n.CreateTownie(tbl) npcent:Spawn() end ---Creates a new navigation node for npc's +---Create an area of intrest. +-- Creates an point that you can use in a townie's locations of intrest. +--@see navnodetbl +--@tparam table tbl The table for the nav node function n.CreateNavNode(tbl) local nodeent = ents.Create("info_townienode") assert(tbl ~= nil, "Tried to create a nil navnode") @@ -99,6 +120,9 @@ hook.Add("InitPostEntity", "artery_spawnmapnpcs", function() loadMap() end) +---Reloads the entities on the map +-- Removes and then reload all of the entities on the level  +--@concommand artery_reloadmap concommand.Add("artery_reloadmap", function(ply,cmd,args) if not ply:IsAdmin() then return end for k, v in pairs(removeents) do @@ -112,6 +136,9 @@ concommand.Add("artery_reloadmap", function(ply,cmd,args) loadMap() end) +---Create a new npc +-- Creates a new npc a the point the player is looking  +--@concommand artery_makenpc <npc_name> concommand.Add("artery_makenpc", function(ply, cmd, args) if not ply:IsAdmin() then return end local na = args[1] diff --git a/gamemode/core/npc/sv_shop.lua b/gamemode/core/npc/sv_shop.lua index 50b6ac8..ffebce8 100644 --- a/gamemode/core/npc/sv_shop.lua +++ b/gamemode/core/npc/sv_shop.lua @@ -1,6 +1,5 @@ ---[[ - Create a shop npc -]] +---Some more logic related to shop npc's +--@module sv_shop.lua local itm = nrequire("core/inventory/item.lua") @@ -24,6 +23,8 @@ function shop.OpenShop(tbl, ply) net.Send(ply) end +---Literally the same thing as sv_npcsystem +--@todo Remove this? or the other? function shop.CreateShop(npc) print("Createing shop npc") local npcent = ents.Create("npc_shop") |
