NPC spawning

From Terraria Wiki
(Redirected from NPC Spawning)
Jump to: navigation, search

In Terraria, enemies, critters, and other NPCs will spawn off-screen and enter the screen area based on their AI. The rate at which enemies are spawned, the maximum number of enemies, and the type of enemies spawned are all dependent on the time of day, biome, the tile type of the ground, and other factors.

Spawn Rates[edit | edit source]

Basics[edit | edit source]

The game determines new enemy spawns every tick.[1] There are two variables it takes into consideration when doing so: spawn rate and max spawns, with the spawn rate limiting the chance of an enemy spawning at the tick, and the max spawns limiting the number of enemies that are active at a time.[2]

The default spawn rate, for instance, is 1/600. This means that each tick, there is a chance of 1/600 that an enemy is spawned. Since there are 60 ticks in 1 second, the chance each second is 1/10; hence with a spawn rate of 1/600, an enemy is spawned, on average, every 10 seconds.

The default max spawns, for instance, is 5. This means that a new enemy can only be spawned if the sum of the NPC slots of all current active enemies is lower than 5. All enemies occupy 1 NPC slot by default; see the following table for a list of all enemies with a higher or lower number of NPC slots. Active enemies exclude, for example, body and tail parts of worms, because a Giant Worm, which has 6–8 segments (i.e. individual enemies), would otherwise occupy a disproportional number of NPC slots. Town NPCs are not considered active NPCs for the purposes of NPC spawning. See the following table for a list of enemies that are not considered active.

 NPCs with non-default NPC slots 
NPC NPC Slots
Hornet 5.png Big Stingy Hornet 1.21
Hornet 5.png Little Stingy Hornet 0.87
Hornet 4.png Big Spikey Hornet 1.16
Hornet 4.png Little Spikey Hornet 0.78
Hornet 3.png Big Leafy Hornet 1.1
Hornet 3.png Little Leafy Hornet 0.92
Hornet 2.png Big Honey Hornet 1.15
Hornet 2.png Little Honey Hornet 0.8
Hornet 1.png Big Fatty Hornet 1.25
Hornet 1.png Little Fatty Hornet 0.85
Raincoat Zombie.png Big Raincoat Zombie 1.1
Raincoat Zombie.png Small Raincoat Zombie 0.9
Pantless Skeleton.png Big Pantless Skeleton 1.15
Pantless Skeleton.png Small Pantless Skeleton 0.85
Misassembled Skeleton.png Big Misassembled Skeleton 1.13
Misassembled Skeleton.png Small Misassembled Skeleton 0.87
Headache Skeleton.png Big Headache Skeleton 1.07
Headache Skeleton.png Small Headache Skeleton 0.93
Skeleton.png Big Skeleton 1.1
Skeleton.png Small Skeleton 0.9
Female Zombie.png Big Female Zombie 1.05
Female Zombie.png Small Female Zombie 0.87
Demon Eye.png Demon Eye (Variant 2) 1.15
Purple Eye.png Purple Eye (Variant 2) 1.1
Green Eye.png Green Eye (Variant 2) 0.85
Dilated Eye.png Dialated Eye (Variant 2) 0.9
Sleepy Eye.png Sleepy Eye (Variant 2) 1.1
Cataract Eye.png Cataract Eye (Variant 2) 1.15
Twiggy Zombie.png Big Twiggy Zombie 1.08
Twiggy Zombie.png Small Twiggy Zombie 0.92
Swamp Zombie.png Big Swamp Zombie 1.13
Swamp Zombie.png Small Swamp Zombie 0.87
Slimed Zombie.png Big Slimed Zombie 1.11
Slimed Zombie.png Small Slimed Zombie 0.89
Pincushion Zombie.png Big Pincushion Zombie 1.13
Pincushion Zombie.png Small Pincushion Zombie 0.93
Bald Zombie.png Big Bald Zombie 1.15
Bald Zombie.png Small Bald Zombie 0.85
Zombie.png Big Zombie 1.1
Zombie.png Small Zombie 0.9
Crimslime.png Big Crimslime 1.15
Crimslime.png Little Crimslime 0.85
Crimera.png Big Crimera 1.15
Crimera.png Little Crimera 0.85
Moss Hornet.png Giant Moss Hornet 1.8
Moss Hornet.png Big Moss Hornet 1.65
Moss Hornet.png Little Moss Hornet 1.35
Moss Hornet.png Tiny Moss Hornet 1.2
Hornet.png Big Stinger 1.2
Hornet.png Little Stinger 0.85
Armored Skeleton.png Heavy Skeleton 2
Angry Bones 1.png Big Boned 2
Eater of Souls.png Big Eater 1.15
Eater of Souls.png Little Eater 0.85
Eye of Cthulhu.png Eye of Cthulhu 5
Devourer Head.png Devourer Head 3.5
Eater of Worlds Head.png Eater of Worlds Head 5
Mother Slime.png Mother Slime 2
Fire Imp.png Fire Imp 3
Dark Caster.png Dark Caster 2
Cursed Skull.png Cursed Skull 0.75
Skeletron Head.png Skeletron Head 6
Bone Serpent Head.png Bone Serpent Head 6
Cave Bat.png Cave Bat 0.5
Jungle Bat.png Jungle Bat 0.5
Piranha.png Piranha 0.5
Hellbat.png Hellbat 0.5
Demon.png Demon 2
Voodoo Demon.png Voodoo Demon 2
Spike Ball.png Spike Ball 0.3
Dungeon Slime.png Dungeon Slime 2
Blazing Wheel.png Blazing Wheel 0.3
Bird (NPC).png Bird 0.4
Wyvern Head.png Wyvern Head 5
Giant Bat.png Giant Bat 0.5
World Feeder Head.png World Feeder Head 3.5
Angler Fish.png Angler Fish 0.5
Wall of Flesh.png Wall of Flesh 10
Retinazer.png Retinazer 5
Spazmatism.png Spazmatism 5
Skeletron Prime.png Skeletron Prime 6
The Destroyer Head.png The Destroyer Head 5
The Destroyer Body.png The Destroyer Body 5
The Destroyer Tail.png The Destroyer Tail 5
Ice Bat.png Ice Bat 0.5
Lava Bat.png Lava Bat 0.5
Giant Flying Fox.png Giant Flying Fox 0.5
Giant Tortoise.png Giant Tortoise 2
Ice Tortoise.png Ice Tortoise 1.5
Red Devil.png Red Devil 2
Arapaima.png Arapaima 0.5
Vampire Bat.png Vampire Bat 2
Vampire.png Vampire 2
Black Recluse (ground).png Black Recluse 0.5
Wall Creeper (ground).png Wall Creeper 0.5
Wall Creeper.png Wall Creeper (On Wall) 0.5
Moss Hornet.png Moss Hornet 1.5
Queen Bee.png Queen Bee 7
Flying Snake.png Flying Snake 0.5
Jungle Creeper (ground).png Jungle Creeper 0.75
Jungle Creeper.png Jungle Creeper (On Wall) 0.75
Black Recluse.png Black Recluse (On Wall) 0.5
Blood Feeder.png Blood Feeder 0.5
Parrot.png Parrot 0.5
Fungo Fish.png Fungo Fish 0.3
Anomura Fungus.png Anomura Fungus 0.3
Mushi Ladybug.png Mushi Ladybug 0.3
Fungi Bulb.png Fungi Bulb 0.3
Giant Fungi Bulb.png Giant Fungi Bulb 0.3
Fungi Spore.png Fungi Spore 0
Plantera (First form).gif Plantera 16
Spore.png Spore 0
Brain of Cthulhu.png Brain of Cthulhu 6
Ragged Caster 1.png Ragged Caster 2
Ragged Caster 2.png Open Coat Ragged Caster 2
Necromancer 1.png Necromancer 2
Necromancer 2.png Armored Necromancer 2
Diabolist 1.png Red Diabolist 2
Diabolist 2.png White Diabolist 2
Giant Cursed Skull.png Giant Cursed Skull 0.75
Blue Jay.png Blue Jay 0.4
Cardinal.png Cardinal 0.4
Mouse (NPC).png Mouse 0.25
Hoppin' Jack.png Hoppin' Jack 0.3
Scarecrow 1.png Scarecrow 0.5
Scarecrow 2.png Scarecrow (Variant 2) 0.5
Scarecrow 3.png Scarecrow (Variant 3) 0.5
Scarecrow 4.png Scarecrow (Variant 4) 0.5
Scarecrow 5.png Scarecrow (Variant 5) 0.5
Scarecrow.png Scarecrow (Variant 6) 0.5
Scarecrow 7.png Scarecrow (Variant 7) 0.5
Scarecrow 8.png Scarecrow (Variant 8) 0.5
Scarecrow 9.png Scarecrow (Variant 9) 0.5
Scarecrow 10.png Scarecrow (Variant 10) 0.5
Pumpking Hand.png Pumpking Blade 0
Zombie Elf.png Zombie Elf 0.5
Zombie Elf Beard.png Beard Zombie Elf 0.5
Zombie Elf Girl.png Girl Zombie Elf 0.5
Yeti.png Yeti 2
Everscream.png Everscream 3
Ice Queen.png Ice Queen 5
Santa-NK1.png Santa-NK1 4
Elf Copter.png Elf Copter 1.5
Nutcracker.png Nutcracker 1.5
Nutcracker 2.png Spinning Nutcracker 1.5
Krampus.png Krampus 1.75
Flocko.png Flocko 2
Firefly (NPC).png Firefly 0.2
Monarch Butterfly.png Ulysses Butterfly.png Tree Nymph Butterfly.png Butterfly 0.25
Worm (NPC).png Worm 0.1
Lightning Bug (NPC).png Lightning Bug 0.2
Snail (NPC).png Snail 0.5
Glowing Snail (NPC).png Glowing Snail 0.5
Duke Fishron.png Duke Fishron 10
Truffle Worm (NPC).png Truffle Worm 0.15
Truffle Worm2 (NPC).png Truffle Worm 0.15
Grasshopper (NPC).png Grasshopper 0.1
Blue Cultist Archer.png Blue Cultist Archer 0
White Cultist Archer.png White Cultist Archer 0
Bubble Shield.png Bubble Shield 0
Gray Grunt.png Gray Grunt 0.75
Martian Drone.png Martian Drone 1.5
Gigazapper.png Gigazapper 0.5
Scutlix Gunner.png Scutlix Gunner 0.5
Scutlix (creature).png Scutlix 0.5
Martian Saucer.png Martian Saucer 0
Martian Saucer Core.png Martian Saucer Core 6
Moon Lord's Head.gif Moon Lord's Head 6
Moon Lord's Hand.gif Moon Lord's Hand 6
Moon Lord's Core.gif Moon Lord's Core 6
Martian Probe.png Martian Probe 0
True Eye of Cthulhu.png True Eye of Cthulhu 0
Moon Leech Clot.png Moon Leech Clot 0
Star Cell.png Star Cell 2
Flow Invader.png Flow Invader 3
Flow Invader.png Stardust Jellyfish Small 3
Twinkle Popper.png Twinkle Popper 3
Twinkle.png Twinkle 0.5
Crawltipede (Head).png Solar Crawltipede Head 2
Crawltipede (Body).png Solar Crawltipede Body 0
Crawltipede (Tail).png Solar Crawltipede Tail 0
Sroller.png Sroller 2
Nebula Floater.png Nebula Floater 3
Vortex Pillar.png Vortex Pillar 0
Predictor.png Predictor 2
Alien Hornet.png Alien Hornet 0.5
Vortexian.png Vortexian 2
Mysterious Tablet Animated.gif Mysterious Tablet 0
CultistAnimation.gif Lunatic Devote 0
Lunatic Cultist.png Lunatic Cultist 10
Ancient Cultist.png Lunatic Cultist 0
Gold Bird.png Gold Bird 0.4
Gold Butterfly.png Gold Butterfly 0.25
Gold Grasshopper (NPC).png Gold Grasshopper 0.1
Gold Mouse (NPC).png Gold Mouse 0.25
Gold Worm (NPC).png Gold Worm 0.1
Skeleton Merchant.png Skeleton Merchant 7
Phantasm Dragon (Head).png Phantasm Dragon Head 5
Fritz.png Fritz 0.5
Shadowflame Apparation.png Shadowflame Apparation 0.1
Mothron Egg.png Mothron Egg 0
Baby Mothron.png Baby Mothron 0.1
Granite Elemental.png Granite Elemental 0.5
Enchanted Nightcrawler (NPC).png Enchanted Nightcrawler 0.1
Grubby (NPC).png Grubby 0.1
Sluggy (NPC).png Sluggy 0.1
Buggy (NPC).png Buggy 0.1
Stardust Pillar.png Stardust Pillar 0
Nebula Pillar.png Nebula Pillar 0
Antlion Charger.png Antlion Charger 0.8
Antlion Swarmer.png Antlion Swarmer 0.8
Dune Splicer (Head).png Dune Splicer Head 5
Dune Splicer (Body).png Dune Splicer Body 0
Dune Splicer (Tail).png Dune Splicer Tail 0
Tomb Crawler (Head).png Tomb Crawler Head 4
 NPCs that are never considered active 


Natural spawn rates[edit | edit source]

Key
1/x: spawn rate
y: max spawns

Spawn rate and max spawns have set values, which are different depending on the environment. They are formally defined for the environments mentioned in the following tables. Some events employ separate mechanisms to control spawn rates; bosses usually occupy enough NPC slots to block most other spawns.

Pre-Hardmode Natural Spawn Rates
Biome/Event/
Boss Fight
Surface Underground Cavern Underworld
Day Night Blood Moon[3]
Forest, Desert,
Snow biome[4]
1/600
5
1/360
6
1/108
10
1/300
8
1/240
9
1/600
10
Jungle 1/240
7
1/144
9
1/60
15
1/120
12
1/96
13
n/a
Corruption/
Crimson
1/390
6
1/234
7
1/70
13
1/195
10
1/156
11
n/a
Dungeon n/an/an/a1/120
13
1/96
15
n/a
Meteorite 1/240
5
1/144
6
1/60
11
1/120
8
1/96
9
n/a
SandstormDesktop VersionConsole Version 1/540
6
1/324
7
1/97
12
n/an/an/a
Underground DesertDesktop VersionConsole VersionMobile Version 1/180
10
1/108
12
1/60
15
1/90
15
1/72
15
n/a
Goblin Army 1/20
10 + 1.5 per player
n/a n/a n/a
Wall of Flesh fight n/a n/a n/a n/a n/a 1/1800
3
Hallow
(if artificially created)
1/600
5
1/360
6
1/108
10
1/300
8
1/156
11
n/a
Hardmode Natural Spawn Rates
Biome/Event/
Boss Fight
Surface Underground Cavern Underworld
Day Night Blood Moon[3]
Forest, Desert,
Snow biome[4]
1/540
6
1/324
7
1/97
12
1/243
10
1/216
11
1/540
12
Jungle 1/216
9
1/129
10
1/60
15
1/97
15
1/86
15
n/a
Corruption/
Crimson
1/351
7
1/210
9
1/63
15
1/157
13
1/140
14
n/a
Dungeon n/an/an/a1/97
15
1/86
15
n/a
Meteorite 1/216
6
1/129
7
1/60
13
1/97
11
1/86
12
n/a
SandstormDesktop VersionConsole Version 1/216
9
1/129
10
1/60
15
n/an/an/a
Underground DesertDesktop VersionConsole VersionMobile Version 1/108
12
1/64
14
1/60
15
1/60
15
1/60
15
n/a
Goblin Army, Frost Legion,
Pirate Invasion, Martian MadnessDesktop VersionConsole VersionMobile Version,
Lunar EventsDesktop VersionConsole VersionMobile Version
1/20
10 + 1.5 per player
n/a n/a n/a
Wall of Flesh fight n/a n/a n/a n/a n/a 1/1620
3
Hallow 1/540
6
1/324
7
1/97
12
1/243
10
1/140
14
n/a

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.

Additionally, the spawn rate will be modified by the number of active enemies in the area. The fewer active enemies there are, the faster new ones will spawn:

  • If the sum of the NPC slots of all active enemies is lower than 20% of max spawns, the denominator of the spawn rate will be multiplied by 0.6.
  • If the sum of the NPC slots of all active enemies is lower than 40% and greater or equal 20% of max spawns, the denominator of the spawn rate will be multiplied by 0.7.
  • If the sum of the NPC slots of all active enemies is lower than 60% and greater or equal 40% of max spawns, the denominator of the spawn rate will be multiplied by 0.8.
  • If the sum of the NPC slots of all active enemies is lower than 80% and greater or equal 60% of max spawns, the denominator of the spawn rate will be multiplied by 0.9.

(Note that all products are rounded down to the nearest integer.)

Examples:

Spawn rate Max spawns NPC slots sum Altered spawn rate
1/600 6 0.8
(13.3% of max spawns)
1/360
1/173 15 10
(66.7% of max spawns)
1/155
1/430 12 10
(83.3% of max spawns)
1/430

Manual alteration of spawn rates[edit | edit source]

Certain items can be used to change the spawn rate and max spawns when used or placed, as per the following table. All effects are multiplicative rather than additive.

Item Spawn rate factor[5] Effective spawn rate Max spawns
Water CandleWater Candle(also if held in hotbar) 1/0.75 +33% +50%
Battle PotionBattle Potion 1/0.5 +100% +100%
Calming PotionCalming Potion 1/1.3 -23% -30%
SunflowerSunflower 1/1.2 -17% (Desktop VersionConsole VersionMobile Version only) -20%
Peace CandlePeace CandleDesktop VersionConsole VersionMobile Version(also if held in hotbar) 1/1.3 -23% -30%

Water and Peace Candles cancel each other out, even though they do not alter spawn rates by the same absolute values. If both are active (e.g. a Peace Candle is held while a Water Candle is placed nearby), none is applied.

There is one exception to this: Water Candles placed (explicitly not held) in Space always increase spawn rates, regardless of nearby Peace Candles. Their effectiveness depends on nearby Peace Candles, however:

Item Spawn rate factor[5] Effective spawn rate Max spawns
Water CandleWater Candleplaced in Space
(with no Peace Candle held or placed nearby)
1/0.375 +167% +50%
Water CandleWater Candleplaced in Space
(with a Peace Candle held or placed nearby)
1/0.5 +100% +50%

Up to this point, spawn rates cannot be increased to fractions greater than 1/60 and max spawns cannot be increased to values greater than 15. Both will be cut off there. The spawn rates and max spawns of the invasion events listed in the tables above are exempt from this.

Effect of Town NPCs on spawn rates[edit | edit source]

The presence of nearby town NPCs generally reduces spawn rates and max spawns. This effect is adjusted in the Underworld.

Anywhere in the world above the Underworld
Number of
nearby town NPCs
Spawn rate factor[5] Effective spawn rate Max spawns
1 1/1.5 -33% -13%
2 1/(9/7) -22% -27%
≥3 n/a n/a -40%
In the Underworld
Number of
nearby town NPCs
Spawn rate factor[5] Effective spawn rate Max spawns
1 1/(50/41) -18% -5%
2 1/(15/11) -27% -10%
≥3 1/1.8 -44% -17%

When 3 or more town NPCs, or the Skeleton Merchant are present nearby, no enemies will spawn. This is only valid for areas outside of the Underworld and only for normal worlds – in Expert modeDesktop VersionConsole VersionMobile Version, there is still a 1/30 chance an enemy may spawn that tick. Events and bosses (and their servants) will bypass this restriction.

Spawning Basics[edit | edit source]

Each player in the game will spawn their own enemies. If two players are in the same area, monsters will appear twice as fast as they would with only one player. Max Spawns rule are still used, which means that even if 2 players are in the same spot, you cannot gather 30 normal monsters near the spot. (Don't forget, the bats count as 1/2, and some special enemies count as 2 or more.)

Choosing a spot to spawn the enemy[edit | edit source]

Spawn area illustration

Verify When the game decides to spawn an enemy, it will first choose a random tile within a rectangle around the player (specifically, the tile containing the top left corner of the player's hitbox). The maximum distance from the player it can choose from is 84 tiles west, 83 east, 46 up, and 45 down. If the picked tile is a solid block, it will try another one. Tiles that are actuated out do not count as solid. If the picked tile has a player-placed wall that blocks enemies from spawning, it will also try another tile.

Once an empty tile is found, it moves down until it finds the ground. (Note that this tile can be more than 45 tiles below from the player. If it finally is outside the "Active Rectangle" it will be instantly despawned, anyway.) If there is enough space for an enemy 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 and many other flying enemies 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. It cannot be within 62 tiles east or west, or 34 tiles up or down. Also, the chosen tile space must be completely outside 2088 × 1172 pixel rectangles centered on the center of each player's hitbox. (If the player is not riding a mount, the top edge of this is 34 + 3/16 tiles above the top left corner tile mentioned above, meaning that NPCs can spawn on ground exactly 35 tiles above a player standing on half blocks, but not a player standing on full blocks.)

Using certain items causes monsters to spawn further out than normal. Equipping a Rifle Scope or Sniper Scope does so only when the player has a compatible gun selected, whether or not the player is zoomed out.

Items Spawn range Safe range
Horizontal Vertical Horizontal Vertical
Normal 84 46 62 34
Rifle Scope or Sniper Scope 114 62 92 50
Binoculars 124 68 102 56
Sniper Rifle 124 68 102 56
Sniper Rifle with Rifle Scope or Sniper Scope 132 72 110 60

Note : If using the Depth Meter, Compass, or similar, each tile is equal to 2 feet, so double all measurements to get distances in feet

On the Mobile version Mobile version, the no-spawn area around the player is 68 by 48 tiles, and the spawn area is 112 by 62 tiles. In addition, enemies cannot spawn closer than 34 tiles to the sides and 24 tiles up and down. They also cannot spawn farther than 56 tiles to the sides and 31 tiles up and down.

Choosing a type of enemy to spawn[edit | edit source]

The type of enemy spawned will depend on many factors including, but not limited to:

Notes[edit | edit source]

  • When standing on the left or right edge of the world, the enemies can spawn on screen, as long they are at least 62 tiles from the player. The screen is around 85 blocks wide, so in this case the enemies can spawn in the farthest quarter of the screen. (This may not necessarily be the case, some players have larger screens, as high as 120 blocks wide).
  • Equipping Binoculars does make the active rectangle bigger.

History[edit | edit source]

  • Desktop 1.2.4: Fixed bug where spawn rates would increase underground when a moon event is happening.
  • Desktop 1.2.3: Fixed bug where spawn rates were higher than intended everywhere rather than when below the middle of dirt layer.

References[edit | edit source]

  1. A tick is a time unit countable by the software. Most of Terraria's updating logic happens every tick. A tick has the length of 1/60th of a second, hence there are 60 ticks in a second and 3600 ticks in a minute.
  2. Information taken from the Desktop version Desktop 1.3.5.3 source code, function SpawnNPC() in Terraria.NPC.cs.
  3. 3.0 3.1 Blood Moons only affect the spawn rates above the surface.
  4. 4.0 4.1 Weather additionally affects spawn rates and max spawns in the Snow biome.
  5. 5.0 5.1 5.2 5.3 The product of the denominators is rounded down to the nearest integer.