Is NPC spawning a yes/no thing?

I’ve been looking at documentation, and it appears that monsters can be placed with a spawn chance, but I don’t see anything about NPCs being placed with a chance. I see NPC classes placed (so you can randomize what you get), but no spawn chances. Is this correct, or is it a case of ‘no one tried it previously’?
Just curious, as adding NPC spawn chance to something like sealed houses would be interesting. Bash your way into the boarded up building and SURPRISE! INSTANT BANDIT!

I’m pretty sure place_npcs take a chance parameter, same as the other place_ invocations. Try it and tell us the results.

Initial test, set bandits to spawn in refugee center. Set % of 90, 50, 25, 10. Three attempts, in all three all the bandits spawned. Second test put % to 10 for all, bandits spawned every time. Was basing my % off the evac shelter basement, which has a 40% zombie spawn and you almost never see it.
This could be where I was putting the entries in the JSON. I’ll test again later. It definitely took the “chance” field without spitting an error back, so it recognizes it in conjunction with the NPC, but questionable as to if it applies it.

Well, found an answer, but as it’s from 2019 I don’t know how current it is. The pull request below was the one that introduced the Bone Seer into the game, and in it someone explicitly states that chance does not work on place_npcs. Looks like the main way to get an NPC ‘random encounter’ is via nested mapgens, which I have to look up more details on.
Still kinda weird, as it takes the parameter and doesn’t spit errors back, but I know next to nothing about C++ so…

OK, going to leave this here for anyone else who has the same question I did. Working off Brigitte the Bone Seer, it’s fairly simple to add in a chance of an NPC spawning to a given map. First step is to create a nested mapgen entry, like so:
[
{
“type”: “mapgen”,
“method”: “json”,
“nested_mapgen_id”: “bandit_spawn”,
“object”: { “mapgensize”: [ 1, 1 ], “place_npcs”: [ { “class”: “bandit”, “x”: 0, “y”: 0 } ] }
}
]

That’s exactly the same as Brigitte’s, so it’s only an NPC spawn - it doesn’t force anything else to spawn with her. If you want examples of how to spawn NPCs with specific map functions, you can check the city_npc.json in the Nested folder under mapgen.

To place the NPC is almost as simple. You make a “place_nested” entry like so:

"place_nested": [ { "chunks": [ [ "bandit_spawn", 80 ], [ "null", 20 ] ], "x": 49, "y": 19 },

Again, this was copied from Brigitte. The 80 after the “bandit_spawn” is the chance the nested mapgen chunk will spawn, the “null” is the chance it won’t.
If you want to place multiples, you just make separate “chunks” entries, like so:
“place_nested”: [ { “chunks”: [ [ “bandit_spawn”, 80 ], [ “null”, 20 ] ], “x”: 49, “y”: 19 },
{ “chunks”: [ [ “bandit_spawn”, 50 ], [ “null”, 50 ] ], “x”: 48, “y”: 18 },
{ “chunks”: [ [ “bandit_spawn”, 25 ], [ “null”, 75 ] ], “x”: 47, “y”: 17 },
{ “chunks”: [ [ “bandit_spawn”, 10 ], [ “null”, 90 ] ], “x”: 46, “y”: 16 }

In this case, what I did was torture the poor Broker at the refugee center by giving bandits a chance to spawn right next to him. He didn’t appreciate it. The format of multiple nested chunks was taken from the lab JSON entries, if you need a reference.
I’m sure the folks who are more experienced with either JSON or mapgens and nested mapgens would be able to tell you more and better info on this, but I’ve tested this and it does work.

1 Like

Would there be some kind of narrative for them being inside or just as any other survivor looting and plundering? Would be funny to pop open a survivor boarded house and a Bandit charges you and gets stuck in a bear trap or trips a mine lol

“Our defense is unassailable! Watch as I demonstrate -” explosion

My opinion, both are valid. It’d make sense for bandit/raider types to have a fortified pepper house to work from when they’re in town, but the random raider type in the back bedroom acting as zombie bait is fun as well." Help, there’s a maniac! “ glass shatters Zombie Brute:" Surprise, mother****er! "

1 Like

Are you actually making this a thing, because it sounds like a gas to me when I see a boarded up building.

I’d like to suggest some things if you feel like a few ideas.

I personally would love to be killed by some bum with a shotgun who lives in a random subway tile.

Maybe there is a tent and fire pit there too. Maybe what I’m describing and you’re describing are two different things… :thinking: