TFL38’s NPC Spawner
(Is it the most optimized and most effective? Not sure, but it worked for my own uses and I figured that I’d make it publicly available too)
Not enough thrill and life in your maps? You want to find monsters hiding in every corner? You want to find some allies? Well I got you covered here!
This addon will spawn NPCs where ever is out of a player’s possible visible view, like behind a wall for example.
AS LONG AS THE MAP EITHER HAS A NAVMESH OR IS FULLY AI NODED!
It does not spawn NPCs by default as to make it so most maps do not use it (for possible server reasons). In order to make your map spawn NPCs. Go to your addons folder in the Garry’s Mod directory:
Create a folder, name it whatever you want.
Inside the folder, create a folder named "lua".
Inside THAT folder, create another folder but named: "tfl38_npcspawner_map".
And inside that folder, create a txt file, name it after the map you’re targetting ("gm_construct" for example).
set its file type from .txt to .lua
If you want NPCs that’s shared across maps except ones that have a lua file for them. Inside where you’d put the map lua files, create a folder named "shared". and inside it create a lua file named "map_shared".
What the directories should look like:
garrysmod/addons/YOURMODNAME/lua/tfl38_npcspawner_map/MAPNAME.lua
garrysmod/addons/YOURMODNAME/lua/tfl38_npcspawner_map/shared/map_shared.lua
Information regarding what to put inside is here:
Link to documentation[drive.google.com]
npcspawner_maxdistance 2000
npcspawner_maxnpcs 50
npcspawner_mindistance 100
npcspawner_rate 0.5 (the rate to spawn the npcs)
npcspawner_refresh (This’ll reload whatever variables you have set for the map. So you do not have to change map whenever you change the values and configuration for the map.)
It is compatible with ulx as well, with it being admin only by default.
ulx npcspawner_distance 100 2000
ulx npcspawner_maxnpcs 50
ulx npcspawner_rate 0.5
ulx npcspawner_refresh