Was getting annoyed by NPCs not spawning in my rooms, so I started looking into the code to see what the actual requirements were. Noticed what appears to be a bug which would prevent spawning.
Have everyone else's NPCs not been spawning or respawning since 1.0.2 came out as well? In the source code, it looks like numRoomTiles would never be going above 1 due to being repeatedly reset to 0. Since it's required to be 60 or above for a room to be considered valid for town NPC spawning, that would seem to indicate that NPC spawning is broken. (It would explain why nobody's respawned on the multiplayer server I play on, and why the guide hasn't respawned in my singleplayer game, or spawned in my new rooms in singleplayer, although I had wondered if they were too small - which is why I looked for the code handling it.
Other room needs:
public static bool RoomNeeds(int npcType)
{
if (((houseTile[15] && (houseTile[14] || houseTile[0x12])) && (((houseTile[4] || houseTile[0x21]) || (houseTile[0x22] || houseTile[0x23])) || ((houseTile[0x24] || houseTile[0x2a]) || houseTile[0x31]))) && ((houseTile[10] || houseTile[11]) || houseTile[0x13]))
{
canSpawn = true;
}
else
{
canSpawn = false;
}
return canSpawn;
}
Translation:
Valid rooms must have:
- A wooden chair
- A table or work bench
- a torch, candle, copper chandelier, silver chandelier, gold chandelier, chain lantern, or water candle
- a wooden door, or an apparently undefined item whose createTile is 11, or a wood platform (apparently you don't need doors at all, you can have a platform instead - at least according to the code)
Those numbers are:
15: Wooden Chair
14: Table
0x12: work bench
4: Torch
0x21: Candle
0x22: Copper Chandelier
0x23: Silver Chandelier
0x24: Gold Chandelier
0x2a: Chain Lantern
0x31: Water Candle
10: Wooden Door
11: (Does not exist!)
0x13: Wood Platform
So, some interesting observations from that:
You don't actually need a table, a workbench will suffice.
The table/workbench and chair don't need to be near each other.
You don't need a door, either, if you have wood platform(s). Or so the code says - I haven't tried it, since nobody's spawning :3. I'm curious how it would handle determining which room a platform would count as being in if there are rooms stacked on top of each other, or if they count as being part of multiple rooms (Could be the case).
Nobody seems to spawn, the code for counting the number of tiles in the room looks broken, it keeps resetting the count as it goes from tile to tile.