NPC spawning
In Terraria, monsters will spawn off camera and pursue the player based on their AI. The rate at which monsters are spawned, the maximum number of monsters, and the type of monster spawned are all dependent on the time of day, biome, the tile type of the ground, and other factors.
Contents |
[edit] Spawn Rates
There is a 1 in "Spawn rate" chance a monster will spawn every game tick. There are 60 ticks per second, so a spawn rate of 600 means, approximately, a 10% chance of at least one enemy spawning per second, and a spawn rate of 100 means a 45% chance of at least one enemy spawning per second.
When the game is determining the maximum number of enemies in the area, the "Max Spawns" is used. Some enemies count towards this limit more than others. Most bats are considered half an enemy, and teleporting casters typically count as 3. Bosses count as 5. In general, large or special monsters count for more than one spawn.
The minimum (fastest) spawn rate under normal conditions is 60, and the maximum spawns is 15. The modifiers from Water Candle and Battle Potion are set before these limits are checked. Goblin Sieges are a special case, they ignore any modifiers or limits to the spawning rates or number of spawns (including water candles/ battle potions).
| Biome | Spawn rate | Max Spawns | HM Spawn Rate | HM Max Spawns |
|---|---|---|---|---|
| Surface (day) | 600 | 5 | 540 | 6 |
| Surface (night) | 360 | 6 | 324 | 7 |
| Surface (Blood Moon) | 108 | 11 | 97 | 14 |
| Underground (dirt layer) | 300 | 8 | 243 | 10 |
| Cavern (stone layer) | 240 | 9 | 216 | 11 |
| The Underworld | 600 | 10 | 162 | 15 |
| Jungle (day) | 240 | 7 | 216 | 9 |
| Jungle (night) | 144 | 9 | 129 | 11 |
| Jungle (Blood Moon) | 60 | 15 | 60 | 15 |
| Jungle (dirt layer) | 120 | 12 | 97 | 15 |
| Jungle (stone layer) | 96 | 14 | 86 | 15 |
| Corruption (day) | 390 | 6 | 351 | 7 |
| Corruption (night) | 234 | 8 | 210 | 10 |
| Corruption (Blood Moon) | 70 | 15 | 63 | 15 |
| Corruption (dirt layer) | 195 | 11 | 157 | 14 |
| Corruption (stone layer) | 156 | 12 | 86 | 15 |
| Hallow (day) | 600 | 5 | 540 | 6 |
| Hallow (night) | 360 | 6 | 324 | 7 |
| Hallow (Blood Moon) | 108 | 11 | 97 | 14 |
| Hallow (dirt layer) | 300 | 8 | 243 | 10 |
| Hallow (stone layer) | 165 | 12 | 140 | 14 |
| Meteorite (day) | 240 | 5 | 216 | 6 |
| Meteorite (night) | 144 | 7 | 129 | 8 |
| Meteorite (Blood Moon) | 60 | 12 | 60 | 15 |
| Dungeon (dirt layer) | 120 | 14 | 97 | 15 |
| Dungeon (stone layer) | 96 | 15 | 86 | 15 |
| Goblin Siege | 20 | 10 + 1.5 per player | 20 | 10 + 1.5 per player |
Additionally, the spawn rate will be modified by the number of active monsters in the area. The less monsters there are, the faster they will spawn. If there are less than 20% of the maximum number of spawns, the spawn rate will be multiplied by 0.6. If less than 40% the spawn rate is *0.7, 60% is *0.8 and 80% is *0.9. The spawn rate is sped up even more if below a certain depth or in a corrupted biome.
The presence of friendly NPCs greatly reduces the rate at which enemies spawn, and also reduces the maximum enemies as well. When 3 or more NPCs are present, no enemies will spawn. Special events such as Goblin Siege and Bloodmoon bypass this reduction.
Some biomes will override each other when determining the spawn rate. Corruption, Dungeon, Meteor and Jungle are all mutually exclusive spawn rates. Dungeon has the highest priority, then jungle, corruption, and finally meteor. For example, if a meteor hits the jungle, it will use jungle spawn rates.
[edit] Spawning Basics
Each player in game will spawn their own monsters. If two players are in the same area, monsters will appear twice as fast as they would with only one player.
[edit] Choosing a spot to spawn the monster
When the game decides to spawn a monster, it will first choose a random tile within a rectangle around the player. The maximum distance from the player it can choose from is 73 tiles to the left or right, and 45 tiles up or down. If the picked tile is 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.
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 exception to this is when the player is in an area where Harpies can be spawned. In this case the game does not attempt to find a ground tile.
The chosen tile is then checked to make sure it is not within the "safe" area around the player. Monsters cannot spawn less than 54 tiles away left or right, or 33 tiles up or down.
[edit] Choosing a type of monster to spawn
The type of monster spawned will depend on many factors including, but not limited to:
- Time of day
- Depth
- Relative X location on the map
- Current Zone (Corruption, Meteor, Jungle, etc...)
- Ground Tile Type
- Special events (Blood Moon, Goblin Invasion)
- Randomness
Certain events, such as Goblin Invasion can override or change certain rules about spawning. For example, Goblin spawning will not be stopped by walls that normally prevent spawning.
| Game mechanics |
|---|
| Attack Speed • Breath meter • Buffs • By hand • Consumable • Crafting station • Critical hit • Damage types • Data IDs Day and night cycle • Death • Debuffs • Defense • Difficulty • Environment • Fall Damage • Game controls • Ghost • Health • Inventory Knockback • Lighting mode • Mana • Map Size • Modifier • Moon phase • Music • NPC drops • NPC Spawning • Placement Player stats • Rarity • Shoot speed • Spawn • Storage items • Use time • Value |