Question [Question] Can "swarm spawning" exceed the upper limit of spawn rate and max spawn?

Thiner

Terrarian
This question may or may not be answer by myself. I am curious about that but find it difficult to find the specific code that refers to this form of spawning.

"When attacking enemies for too long, there is a chance that more of the same enemy will spawn close by and join the fight (e.g. attacking 1 Umbrella Slime causes more to spawn and attack.)" - By Terraria Wiki [Expert mode]

Well, I don't know the official name of such spawning, so I just take it "swarm spawning". I don't even know whether it really exists...

For reference, as far as my interpretation for the code, the slime rain spawning is independent of normal spawning. It only have a max spawn limit of 15(of course for all active NPCs) and note that 15 is always applied whatever biome or other condition it is. And in one frame slime spawning and normal spawning can happen together.

I want to know the mechanics of "swarm spawning". Hope you guys can help me.
 
I think this is a bit of bull:red:.

I also read about it and tried it with a wooden sword. First a Demon Eye, I whacked it around like a cat with a ball for ages and no other Demon Eyes spawned. 4 zombies then spawned and I poked them with my wood for ages but no more spawned. In Expert Mode.

Yeah, might be a wiki fail.
 
Yeah, might be a wiki fail.
Does sound suspiciously like a case of spurious rumour and confirmation bias. I've had small groups of Antlion Chargers suddenly gang up on me (nromal mode), but just attribute it to the emergent interaction of their AI and the layout of the underground desert.
max spawn limit of 15
Note that during my fairly extensive spawn mechanics testing (last year), I repeatedly got up to 16 mobs spawning (note that I'm not the best at counting and some mobs are hard to pint down, but I was fairly sure). Made me think there is some code interpretation error (e.g. >15 rather than >= 15) or unforeseen eventuality when it executes.
 
I call on wiki bull:red:.

Not only the matter at hand could simply be the result of RNG (as I see no mention of it on the official changelog), finding the code related to it would be next to impossible with how huge and messed up the spawning codes are.
 
I repeatedly got up to 16 mobs spawning

Most bats are half an enemy. There are many many type of enemies/or friendly NPCs which are counted more than 1 or less than 1, one extreme example being the Pumpking that is counted as 0.

By the way In Slime Rain every slime that can occur in the event, whether or not spawn in the specific process of 'slime rain spawn' are counted as 0.65 times what they should be without the slime rain.


Tedious expression without an auxiliary variable ..
I just introduce another property that an NPC has: npcSlots (well the source code says so)
When counting active NPCs the npcSlots are added into calculation, not merely 1. Most Bats and spider-cave spiders have a npcSlots of 0.5 (so you can accumulate 30 of them in a room. So do many other monsters), most mushroom-themed enemies being 0.3, the Skeleton Merchant 7, the Pumpking 0, and many others, although most enemies are 1.
In slime rain event any event slime will have their npcSlots multiplied by 0.65 before adding into total NPC numbers.

Well, I carefully looked at what you said and the code, and it is that when activeNPC < maxSpawn it can process natural spawn. So maybe it can make a flaw that it spawn an Wyvern whose npcSlots is 5 when the activeNPC is 14 currently... But I didn't notice other logical failures in the code. You may need to say the question in detail.
[DOUBLEPOST=1438178139,1438176664][/DOUBLEPOST]Well, the critical edit on the problem occurred in http://terraria.wiki.gg/index.php?title=Expert_mode&diff=462348&oldid=460800
And if someone can contact @16439aaron we can learn more about his experiment details.
 
Yeah, I don't recall this ever being mentioned in the changelogs anywhere. It sounds like a confluence of RNG (remark about the mob spawn) and unawareness (light levels/time: sounds like his fight took place in the late evening or early morning when light levels aren't very distinct AND he wasn't really paying attention to actual elapse time. When you have heighten senses from an adrenaline rush, like not wanting to die, perceived time-passage can be slow.)

More than likely, this is an over eager player who doesn't believe in the scientific method. "Hey, this happened to me once. It must be true and happen ALL the time." Yeah, no. This sounds like typical Terraria RNG/Spawn behavior, really. The only thing that would concern me is the "regardless of light levels" remark, but that can be chalked up to not having the in-game time being displayed for whatever reason (no accessory, turned off, in menu/inventory, etc.) or not paying attention to it.
 
NPCs which are counted more than 1 or less than 1
Yes, I was aware of this at the time (for at least part of the time). So when I used spawn surfaces (in my carefully controlled area) to spawn just one mob type, it was clearest. e.g. day time with artificial block types = (green) slimes only. But they tended to synchronise up atop each other, so... Ebonstone (pre-hard-mode) = Eater of Souls only (16 shown below):
Terraria 2014-09-16 22-29-42-083.jpg
Full test setup> Terraria 2014-09-16 22-29-42-82.jpg
Diceman observed getting well over 15 glowing snails in his farm, and looking in the code (the easy bit that made sense to me) of course they have an "NPCslots" weighting of 0.5. Truffle worms only took up 0.15! (I wonder if that is still the case? Or overhauled with their mob vulnerability and spawn rate?) And on the topic of wild spawning, you can totally block spawns on surfaces with a perfect 45 degree slope, falling to the right (as I posted here).
In Slime Rain every slime that can occur in the event, whether or not spawn in the specific process of 'slime rain spawn' are counted as 0.65 times what they should be without the slime rain.
Cool, I'd noticed they seemed to be accumulating to a greater degree when I was (trying) to test things in my experiment world (but not paying much attention). In my actual playthrough I tried taking a battle potion to boost the raining slimes (in need of gel) but it almost seemed like I purely increased the number of zombies and such (it had gotten late). Less than anecdotal, I know, but you think maybe slime fall rate unaffected by spawn rate buffs, etc?
 
If the enemy counter is right, I've gotten up to 29 mobs in my ocean coin farm. Not sure what multiplier arapaimas have though...
zCGiE0k.png


I seem to max out at 20-22 in the day time though

Edit: I went to a non expert world that had almost the same set-up and got the same numbers.
 
Last edited:
Truffle worms only took up 0.15! (I wonder if that is still the case? Or overhauled with their mob vulnerability and spawn rate?)

They still only take up 0.15 slots.

In my actual playthrough I tried taking a battle potion to boost the raining slimes (in need of gel) but it almost seemed like I purely increased the number of zombies and such (it had gotten late). Less than anecdotal, I know, but you think maybe slime fall rate unaffected by spawn rate buffs, etc?

Looks like the slime rain spawns are processed independently of other spawns, and so ignores battle potions, water candles, etc. The best thing to do for slime rain spawns is to have as few enemies of any type on screen as possible, since the slimes spawn significantly slower the more enemies there are. (From a 1 in 45 chance if no enemies are present to a 1 in 495 chance if 15 enemies are present, and a flat 0% spawn chance if there are more than 15 enemies.)

EDIT: @Bahamut2001, Arapaima take up 0.5 slots each.
 
Arapaima take up 0.5 slots each.
Hence why jungle biome ocean farms have been so popular for key (mold) farming - doubles the potential output compared to wiehgt 1 mobs. :)

Great info on the slimes too! Thanks (Will avoid battle potions and maybe stay near home next time). Do you think they spawn in free space, like harpies? And then just fall to the ground? (No complicated reverse trajectories going on, back calculated from a free surface, or whatever.)
 
Do you think they spawn in free space, like harpies?

They spawn 900~1800 pixels above you and their horizontal distance from you is less than 1920 pixels. And sound like they only spawn in Surface, not in Space. They nearly always spawn in the air where the space is at least 7*7. (Well it don't have mechanics like normal spawn which can endure 50 failures. It just skips if failure occurs.)
 
Do you think they spawn in free space, like harpies? And then just fall to the ground?

Pretty much, although not quite like harpies, I suppose. Algorithm is as follows:

Choose an x value somewhere within maxScreenWidth of the player. (Usually 1920 units for most people, I think.) Choose a y value somewhere within 0.75 * maxScreenHeight above the player and 1.5 * maxScreenHeight above the player. (maxScreenHeight is 1080 units for most people.)

The point is valid if it is (1) not in the horizontal dead zone on either side of the map, (2) Above level depth and below 30% of the distance from the top of the world to level depth, (3) there are no solid tiles in a 7x7 box centered 2 tiles above the point and (4) the point has no player-placed background wall.

If the point is valid, spawn a slime there. If the point is not valid, no further attempt is made to spawn a slime. The slimes can be different types, depending on RNG and expert mode. This runs once per tick for each active player before all other spawning, as long as the Slime Rain event is active.

EDIT: Looks like @Thiner got to it before me!
 
Choose an x value somewhere within maxScreenWidth of the player. (Usually 1920 units for most people, I think.) Choose a y value somewhere within 0.75 * maxScreenHeight above the player and 1.5 * maxScreenHeight above the player. (maxScreenHeight is 1080 units for most people.)

the maxScreenH is a constant of 1200 whereas the maxScreenW is a constant of 1920 as far as I see.....
 
Wow, competitive code reading! Good job.

A totally separate spawning algorithm then, how novel. So seeing as the range is further out, you could easily block all regular spawns while allowing slime rain to fall. Sounds like most effective way would be to have a long lava pit, at the surface, position player a fair height above that and then all the slimes would simply fall into it and die... Too good to be true, surely? Although no huge advantage to be had, I suppose and you can't force slime rain to happen (right?).
 
I suppose and you can't force slime rain to happen
It occur randomly currently in 1.3. And as it don't have much value except for some free Pinkies and one King Slime (or zero), it is unlikely that there will be an item to summon a slime rain before an update that add more stuff into slime rain.
A lava roof obvious becomes the best way to farm slime rain.. although since you get a slime statue all the things that the slime rain can give you is some money, some free pink gel, and maybe a King Slime Treasure Bag.. Not much stuff.
 
Back
Top Bottom