NPC Spawn

I need a more effective way to make my NPCs spawn. This is what I have found.
[lua]function SetupNPCSpawnGrid()

if GetGlobalBool("SpawnedSpawners") == false then
	gridTable = {}
	gridTable[1] = Vector(-1000,1000,50)
	gridTable[2] = Vector(0,2000,50)
	gridTable[3] = Vector(-1000,0,50)
	gridTable[4] = Vector(0,0,50)
	gridTable[5] = Vector(1000,0,50)
	gridTable[6] = Vector(-1000,-1000,50)
	gridTable[7] = Vector(0,-1000,50)
	gridTable[8] = Vector(1000,-1000,50)
	gridTable[9] = Vector(-2000,2000,50)
	gridTable[10] = Vector(0,2000,50)
	gridTable[11] = Vector(-2000,0,50)
	gridTable[12] = Vector(2000,0,50)
	gridTable[13] = Vector(0,-2000,50)
	gridTable[14] = Vector(2000,-2000,50)
	for i = 1, table.Count(gridTable) do
		NPCSpawner = ents.Create("NPC_Spawner")
		if util.IsInWorld(gridTable*) then
			NPCSpawner:SetName("Spawner" .. i)


My problem is that I can’t make it universal for any map.

'Tis the problem with absolute positioning: a vector in one map certainly won’t come close to the same vector in another map. The origin of one map could be inside the world or not. Your method may be “effective” or whatnot, but it’s impossible to universalize it.

However, if you really wanted to use absolute positions, you could do something like this:

[lua]local gridTable = {
[“gm_construct”] = { Vector(0,0,1), Vector(1,0,0) },
[“gm_flatgrass”] = { Vector(0,1,0), Vector(1,1,1) },

And then access the vectors you want with


I don’t know what purpose these NPC’s have, but maybe you can find the info_player_spawn entities and spawn them there?

Or make sure that every map you use is edited to have the spawn locations in them as entities, e.g: info_scaryzombie_spawn…

Use Enteros’ way though…