Spawn behavior with random NPCs

An issue I’ve just ran into, is that while trying to wait out meth withdrawl in a prepper basement by reading books, multiple times now I’ve been ambushed by random NPCs demanding for me to drop my weapon, and demanding I leave.

One of the times I did, I noticed it was not only one hostile NPC, but two! The heck? I’m running some mods, but none of which affect NPCs, the only pertinent game settings I’m using is random+static NPCs.

I thought they couldn’t spawn within your reality bubble? This seems odd to me, how can I even counter this?

Technically, the basement (overmap tiles in general) contains a smaller internal grid 2x2 submaps. The map will scroll when you cross from one of those submaps to the adjacent one (walking past the middle of your basement in either axis). That would be enough to load the adjacent row/column of overmap tiles so that the NPC could be active.

For two NPCs, you can wait long enough in the same place for multiple to spawn off-map, and then scroll the map according to the first paragraph.

Technically, you could avoid NPCs becoming active if you stayed in one 12x12 corner of your basement, assuming there isn’t anything in the code that allows NPCs to spawn directly in the basement floor.

They only spawn in the bubble.

They’re mostly old code, in need of a total rework.

I thought they were spawning out of the bubble, since they don’t appear to move until you see them.