r/Terraria•
Darentei

Questions about advanced NPC spawning mechanics

I have some questions regarding NPC spawning mechanics that are a little more specific than what I could look up on the wiki.

Several sources state different specifications for the size of the spawn box. While I've determined that the wiki states the correct numbers, I assume people state wrong numbers for various reasons, one of which could be that they added the player's size to the measurements. The first question relates to this. In what way is the player centered on the box?

The character size is an uneven number of blocks high, so it wouldn't be able to stand on a flat surface and be exactly in the right spot. The reason I didn't go with the obvious answer and simply hook myself exactly in the middle is that the code might interpret your position in whole numbers, so it might make a difference with precise building.

My own attempt at an answer to this question came when I was experimenting with biomes, and how many blocks you must walk to leave them. I noticed that the distance required when moving vertically was the same in either direction. This led me to the conclusion that for the purpose of detecting if your current position is within a biome box (or rather, if enough blocks are counted on screen) is based on the position of your feet, or the bottom third of your character. So while the middle (or your torso) would be the logical conclusion, the feet had some significance too, and so I place both in the center 2x2 area, with my head sticking up.

The next question is mostly some extra clarification about spawning basics. From what I can tell, assuming you clear out the entire spawnable area, it is best to build as little as possible inside it to achieve the maximum spawn rate, as any surface in the safe area could cancel a spawn check, since it checks downwards and it only checks for the safe area in the end. To be more exact, assuming I build a 1-block wide wall at the inner edge of the safe area, I would only really have to knock out the bottom floor to get it back up, since it will just re-check a position of a solid block filled it.

So from what I can understand, it won't really affect the spawn rate if you build more floors, as long as there are no floors in the safe area. Is this correct? And is there perhaps a way to make the game skip past blocks when trying to spawn?

Also, bats. Damn them, they're hard to control in the manner I want to. I need to know more about them. Do they also spawn on on a surface? You can't... hoik them, right?

One more spawn related thing. I briefly tried to wall off a majority of the spawnable area around me, thinking I could get mobs to spawn in specific spot. It didn't seem to work, although the wiki implies the game will keep re-checking for a place to spawn. I missed a major thing when I did it, namely that the game can pick a spot that's initially in the safe area, and that's probably what cut the spawn rate so low. If I did it again, but walled off the safe area this time, would it work? And does it matter that I use walls, and not blocks? From what I can tell, it shouldn't.

Feel free to provide as much information as you can. I think I had another question, but I forgot it. It's fun trying to digest these things.

Posted Sep 16, 2015, 9:57 PM UTC

310
seriouslees•

Monsters can't spawn in front of player placed background "Walls". But if you're blocking off an area to prevent spawns, I'd use blocks instead. Much easier to see if you missed a tile, and with blocks, you don't even need to fill in every square since all mobs need a 2x3 block free area minimum to spawn in.

2
DarenteiOP•

I used walls because I got 4 for 1. Placing walls also has smart cursor, but if you skip some, I guess blocks are faster. Really though, all mobs? Even bats, and what about critters like worms? I've been wanting to know more about sizes.

Anyway, I'm aware that I can block areas with walls or blocks. What I am asking is if it takes away from the spawn rate, or if it allows me to concentrate the spawn area to a place I choose. And also if it matters if I use walls or blocks.

1
seriouslees•

So long as none of the walls are above your spawn surface, I don't see why it would lower the spawn rate. Even still, it shouldn't lower the "rate" of spawn, AFAIK. You can certainly use them to direct spawn areas, but I don't see it done often. Most players use lava to block spawns and force a spawn point. Mobs can't spawn over even thin layers of lava.

1
DarenteiOP•

Well, that answers one question I think... So you're saying that a layer of lava essentially prevents every empty tile directly above from being chosen for spawning?

I'll pull some wiki quotes to make sure I get it right:

If the picked tile is a solid block, it will try another one. If the picked tile has a wall that blocks monsters from spawning, it will also try another tile.

Alright, so blocks or walls will just redirect the spawn attempt, meaning spawn rate remains unaffected. As I understand, lava has this effect on all empty tiles directly above it?

Once an empty tile is found, it moves down until it finds the ground.

If there is enough space for a monster to be spawned at this location, this will be the tile it chooses.

The chosen tile is then checked to make sure it is not within the "safe" area around the player.

This is where I assume the attempt ends. And in order to force a spawn point, you would then have to make all tiles in the safe area force a re-check. And apparently I can use lava for this.

Sounds about right?

1
seriouslees•

Yep, sounds right AFAIK. You can see it in effect in many of the old 1.2 Moon Event farms. Players would often stand on platforms up over the spawn distance from the ground (36ish tiles? Something like that), create a small spawn surface down there, and flood the sides all the way out past the spawn range with lava. This forced all spawns to happen directly below them, so that their farm could direct attacks to that area.

1
DarenteiOP•

Can you elaborate on this 2x3 area? The game only picks one tile, and then moves down, so this must be the feet. Let's say it picks a block in the X column (L & R = empty tiles1):

LXR
LXR
LXR

Would the monster be more likely to occupy the L tiles or the R tiles, or is there an equal chance of either? Also, must the solid block underneath be unhammered? What about blocks under L or R (and what about walls behind)? Can they be whatever?

If I am able to determine in every tile that could initiate a spawn, but doesn't have an eligible block below, I could do some precision wall or lava placement and make the game recheck those areas instead.

(Separate reply for attention)

1
seriouslees•

I'm not actually sure how that part works. I'd assume if the block it picks was X, it would check to see if there's room on one side, then if not, check the other side. I've never needed to force spawns onto a single spot like that.

1
DarenteiOP•

Yeah that's understandable, I'm going a bit deep here. I'm going to assume it follows housing rules in regards to fitting the spawn.

1
DarenteiOP•

And I suppose I'll add any thing I gather on the wiki.

1