Luck

Luck is a statistic that influences the random nature of various activities in Terraria. There are various ways to increase and decrease this statistic, ranging from Buff potions to Torch placement. Players can gauge what their luck value is by speaking to the Wizard.

For many random chances in the game, the chance is represented in the code in a 1/x format. When this is combined with luck, there are two possibilities for players with non-zero luck:
 * If the player's luck is > 0, there is a luck/1 chance that 1/x will become 1/(x/2); i.e. the rate doubles.
 * If the player's luck is < 0, there is a -luck/1 chance that 1/x will become 1/(x*2); i.e. the rate halves.

Players can max out their luck at 1, but their luck cannot go below -0.7. Each tick a player's luck is normalized to this range, so bad luck is slightly harder to achieve than good luck.

Influence
Luck is impacted by Ladybugs, the placement of Torches, Lucky (buff), Lantern Nights, and Garden Gnomes.

Ladybug Luck
(Maximum: +0.2 / Minimum: -0.2)

The player has a ladybug luck timer which always decreases to 0. It relates to interactions with, as well as a few other NPCs.
 * If the player touches a ladybug that has been released by a player (intersecting hitboxes), then they will receive "good ladybug luck" for 12 minutes. This is doubled for golden ladybugs.
 * If the player touches the ladybug from more than 30 pixels away, it is possible that the number will be slightly reduced, but the difference is barely noticeable.
 * If a player kills a ladybug, they will receive "bad ladybug luck" for 3 minutes. This is doubled to 6 minutes if the ladybug was golden.
 * Regardless of whether it is golden or not, there is also an increased chance of rain for the next 30 seconds.
 * If the player kills the Guide, their "good ladybug luck" is active for the next 12 minutes. Conversely, killing any other Town NPC (except for the Clothier) will activate bad ladybug luck for the next 3 minutes.
 * There is no counter stopping players from swapping their luck back and forth, so as long as the player releases and touches a ladybug after killing one, their luck will become good again.

Torch Luck
(Maximum: +0.2 / Minimum: -0.4)

By placing Torches in the correct locations, Players can increase their luck. With a few exceptions, torches placed in the preferred biome will yield the positive score, and if placed in any other location, will yield a negative score.

Torch luck seems to probe for torches in a box of ~42 tiles around the player, not including the tiles the player occupies.

Note that holding a torch in the correct biome also counts as being near it, so players can increase their luck by just holding a correct torch, even if surrounded by incorrect ones.

Torch Luck does not apply in the Dungeon or Lihzahrd Temple.


 * Torches do not yield luck bonuses, and instead will increase negative score by +0.5 if placed in the Desert, Corruption, Crimson, or Hallow. If placed in the Snow biome they increase negative score by 2.
 * Coral Torches will have a score of -1 if not placed in water.
 * More than one of the same type of torch does not affect the score.

After tallying up all torch types around the player, the Torch Luck is determined.
 * If the positive score is ≥ 1, torch luck increases by 1. If otherwise > 0, increase by 0.5.
 * If the negative score is > 0, decrease torch luck by 0.5. If otherwise ≥ 1, decrease by 1, and if ≥ 2, decrease by -2.

Therefore, to maximize luck, players should try to use biome torches whenever possible, as well as avoid using said biome torches in the wrong biomes. If the player is out of said torches, they should aim to use Bone Torches or any torch not listed above (e.g. Ultrabright Torches, Gem Torches) to avoid bad luck. Above all, players should avoid using regular Torches in the Snow biome as that reduces luck the most.

Luck Potions
(Maximum: +0.3 / Minimum: 0)

The Lucky (buff) increases luck based on how much time there is left. The values do not stack, so using a will yield +0.3 luck for 5 minutes, then +0.2 luck for 2 minutes, and finally +0.1 luck for 3 minutes.

Lantern Nights
(Maximum: +0.3 / Minimum: 0)

Lantern Nights increase luck by a flat rate of 0.3. This is active everywhere in the world, even underground. However, they will not start if there is a Blood Moon, Pumpkin Moon, Frost Moon, any boss or invasion active, or if Moon Lord is being summoned.

Garden Gnomes
(Maximum: +0.2 / Minimum: 0)

If the player has a garden gnome nearby, luck will be increased by a flat rate of 0.2. The range is estimated to be similar to that of Banners and Campfires.

Final Calculation
The formula used by the game is below:

Each frame, luck is reset to 0, and then 20% of the ladybug luck is added to 20% of the torch luck. Then the luck potion value is added, and if there is a lantern night, add 0.3 and if there is a Garden Gnome, add 0.2.

Impact
Luck affects the following items. In most cases, the player performing the roll influences the luck, however there are some cases (such as shaking trees) that use the closest player's luck.


 * All material drop rates, such as Ichor.
 * All unique item drop rates, such as the Ancient Horn or Slimy Saddle.
 * Chances of items appearing in the Travelling Merchant and Skeleton Merchant inventory.
 * The player with the highest luck will be chosen to influence the inventory.
 * Chances of Coin Portals appearing from Pots.
 * Chances of Gold Critters replacing a regular critter spawn.
 * Chances of spawning a Dungeon Spirit.
 * Chances of enemies dropping Hearts and Mana Stars.
 * Chances of some event enemies dropping more than one heart (Zombie Elf, Scarecrow, Hellhound, Poltergeist).
 * Chances of Food dropping from enemies.
 * Chances of the Bound Wizard and Bound Goblin appearing underground.
 * Chances of Enchanted Nightcrawlers spawning during meteor shower.
 * Chances of a Hardmode Dungeon enemy spawning on the wrong wall type (e.g. Skeleton Commando spawning on Slab Wall).
 * Chances of a Dungeon Slime spawning.
 * Chances of Fairies spawning underground.
 * Chances of Gnomes spawning while the Player in a Living Tree or in front of "unsafe" Dirt Wall.
 * Chances of Biome Mimics spawning.
 * Chances of Doctor Bones spawning.
 * Chances of Ice Golem spawning.
 * Chances of Pinky spawning in place of a Blue Slime.
 * Damage calculations in many situations are influenced by luck; positive luck will be favorable to the player.
 * For players with > 0 luck, a second damage number is generated. The damage of the greater of the two numbers is dealt. Similarly, for players with < 0 luck, the lower of the two generated damage numbers is dealt.
 * Luck affects PvP the same way it affects regular enemies.
 * Players with high luck have better coin drop rates.
 * A list of boss drops that do not scale with luck is listed below:

Wizard
The Wizard will give the player a general idea of where their luck value is.


 * If Luck is ≥ 0.75
 * You are overflowing with a blessing of stupendous prosperity!!
 * Excessive health and happiness gush from your very being! You are a Godsend!!


 * If Luck is ≥ 0.5
 * Have you a garden of four-leaf clovers? You are bursting with essences of great fortune!
 * Serendipity smiles upon you! It is likely you shall find profit in all things!


 * If Luck is ≥ 0.25
 * You are giving off a positive energy, like something grand could occur at any moment.
 * There are vibes of good fortune emanating from you, as though your wishes could possibly come true.


 * If Luck is ≥ 0
 * I sense a speck of good karma about you, but I could be mistaken.
 * There's something unusually warm about you. I'm not sure how to place it, but keep walking in that direction.


 * If Luck is < 0
 * The air feels dull and gloomy where you step. Be wary of ill feelings.
 * Is something bothering you? Something doesn't feel quite right about you.


 * If Luck is < -.2
 * Negative energy is seeping from your pores. I wouldn't take any chances today.
 * Unfortunate omens hang over your head. You DID forward that letter, right?


 * If Luck is < -.4
 * I feel a terrible fate surrounding you! You should just stay in bed today!
 * What manner of salt did you spill to receive such misfortune!?


 * If Luck is < -.6
 * Stay away! You are dragging a behemoth of woeful bad luck in your wake! I want nothing of it!!
 * Did you smash every mirror in WorldName!? You hapless fool, you are cursed beyond help!!