Yet Unknown Information

rubeszilla

Terrarian
Oi!

So we know that fireflies spawn rate increases on a new moon but what causes those days when you have a massive butterfly population? Is there an environmental cause or is it RNG? What are the odds if it is RNG? (And I'm not just talking about the NPC effect, we all know they increase critter populations).

Answers! I want answers!
 
Last edited:
It's pretty much entirely RNG.

There doesn't seem to be anything that indicates the moon phase has anything to do with the spawn rates of fireflies, lightning bugs, or butterflies.

Butterflies have a 2/3 chance of having an almost nonexistent chance to spawn (1/999999). For the other 1/3 chance, the spawn chance will range from 1/1 to 1/24, chosen randomly.

There's a 1/9 chance of a relatively high spawn rate for fireflies and lightning bugs. If that doesn't happen, there's a 1/3 chance for an almost nonexistent chance for them to spawn (1/999999). And if that doesn't happen, the values are set to still allow them to spawn, but at a relatively low rate. These values are set once each day (looks like it happens at 7:30PM).

The part I haven't quite figured out yet is why there seem to be two different chance values for fireflies/lightning bugs, each used once in two different places that appear to do about the same thing (possibly one when in range of friendly NPCs and one not?) -- but I haven't established how these differ or why.
 
Ah thanks for that. I was sure the Fireflies came out more on the New Moon but not so sure now :)

Are you looking at the code?

I just realized it would be easy to do some experimenting with the moon phases and see if there's any correlation, so I will try it.
 
Are you looking at the code?

Yep. The part that sets the probabilities is isolated and fairly straightforward, but the part that uses the probabilities is far more complicated -- a maze of if () { else if() { else if() { ... } ... } ... } logic that winds its way through all possible conditions. All checks for moon phase look to be down stream from test cases that can cause fireflies and lightning bugs to spawn, so it doesn't look like that can influence the chances at all.
 
The part I haven't quite figured out yet is why there seem to be two different chance values for fireflies/lightning bugs, each used once in two different places that appear to do about the same thing (possibly one when in range of friendly NPCs and one not?) -- but I haven't established how these differ or why.

Yes, NPCs definitely have an influence on critters. Sure there's no moon in there? Ah well, I believe you but I'll still do some experiments in the name of science :)
 
Yes, NPCs definitely have an influence on critters. Sure there's no moon in there? Ah well, I believe you but I'll still do some experiments in the name of science :)

The first reference to the moon phase comes after the first opportunity to spawn fireflies or lightning bugs, and is specific to wraiths. The second reference to the moon phase comes immediately after the second chance to spawn fireflies or lightning bugs and influences the spawning of demon eyes (which are known to be more common during a new moon). Without stepping through all the outer test cases, the variable names (fireFlyChance and fireFlyFriendly) lead me to think the difference is whether friendly NPCs are close. On the 1/9 chance, fireFlyChance can range from 5-9 and fireFlyFriendly can range from 1-3. On the 1/3 default chance, fireFlyChance can range from 10-59, and fireFlyFriendly can range from 6-29. Since the lower numbers translate to higher spawn rates and the critters definitely seem to spawn in greater quantities around the friendly NPCs, I'm pretty confident my educated guess holds water. :D

(Edit: Minor tweak. The 1/3 chance is when firefly/lightning bug spawning is suppressed, revised to "default" to describe the path taken when the other two options aren't selected first.)
 
Last edited:
The first reference to the moon phase comes after the first opportunity to spawn fireflies or lightning bugs, and is specific to wraiths. The second reference to the moon phase comes immediately after the second chance to spawn fireflies or lightning bugs and influences the spawning of demon eyes (which are known to be more common during a new moon). Without stepping through all the outer test cases, the variable names (fireFlyChance and fireFlyFriendly) lead me to think the difference is whether friendly NPCs are close. On the 1/9 chance, fireFlyChance can range from 5-9 and fireFlyFriendly can range from 1-3. On the 1/3 chance, fireFlyChance can range from 10-59, and fireFlyFriendly can range from 6-29. Since the lower numbers translate to higher spawn rates and the critters definitely seem to spawn in greater quantities around the friendly NPCs, I'm pretty confident my educated guess holds water. :D
Where do you have the source code from? I´m interested to take a look at it
 
Where do you have the source code from? I´m interested to take a look at it

It's a violation of forum rules to redistribute code, but it can be obtained with the proper tools for the job. While I'm not aware of any rules against discussion of those tools, I have my own self-enforced policy of not providing more specific information, sorry. The code isn't exactly easy to read for numerous reasons and doesn't make for good casual inspection. It's also getting off topic from the original subject.
 
Back
Top Bottom