Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ setFireFlyChance()

static void Terraria.NPC.setFireFlyChance ( )
inlinestatic

Definition at line 90049 of file NPC.cs.

90050 {
90051 if (Main.rand == null)
90052 {
90053 Main.rand = new UnifiedRandom((int)DateTime.Now.Ticks);
90054 }
90055 if (WorldGen.genRand.Next(9) == 0)
90056 {
90057 fireFlyChance = Main.rand.Next(5, 10);
90058 fireFlyFriendly = Main.rand.Next(1, 4);
90059 fireFlyMultiple = Main.rand.Next(3, 8);
90060 }
90061 else if (WorldGen.genRand.Next(3) == 0)
90062 {
90063 fireFlyChance = 999999;
90064 fireFlyFriendly = 999999;
90065 fireFlyMultiple = 999999;
90066 }
90067 else
90068 {
90069 fireFlyChance = Main.rand.Next(10, 60);
90070 fireFlyFriendly = Main.rand.Next(2, 15);
90071 fireFlyMultiple = Main.rand.Next(6, 30);
90072 }
90073 if (Main.rand.Next(3) == 0)
90074 {
90075 butterflyChance = 999999;
90076 stinkBugChance = Main.rand.Next(1, 14);
90077 if (WorldGen.genRand.Next(5) == 0)
90078 {
90079 stinkBugChance = 999999;
90080 }
90081 }
90082 else
90083 {
90084 stinkBugChance = 999999;
90085 butterflyChance = Main.rand.Next(1, 21);
90086 if (WorldGen.genRand.Next(5) == 0)
90087 {
90088 butterflyChance = 999999;
90089 }
90090 }
90091 if (Main.tenthAnniversaryWorld)
90092 {
90093 fireFlyChance = Math.Max(1, (int)((float)fireFlyChance * 0.5f));
90094 butterflyChance = Math.Max(1, (int)((float)butterflyChance * 0.5f));
90095 }
90096 }
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static int stinkBugChance
Definition NPC.cs:147
static int butterflyChance
Definition NPC.cs:145
static int fireFlyChance
Definition NPC.cs:141
static int fireFlyFriendly
Definition NPC.cs:139
static int fireFlyMultiple
Definition NPC.cs:143
static DateTime Now
Definition DateTime.cs:103

References Terraria.WorldGen.genRand, System.Math.Max(), System.DateTime.Now, Terraria.Main.rand, and Terraria.Main.tenthAnniversaryWorld.

Referenced by Terraria.IO.WorldFile.LoadWorld(), and Terraria.Main.UpdateTime_StartNight().