Luck

From Terraria Wiki
Jump to navigation Jump to search
Desktop versionConsole versionMobile version
Desktop/Console/Mobile-Only Content: This information applies only to the Desktop, Console, and Mobile versions of Terraria.
For the Lucky modifier, see Modifiers.

Luck is a hidden statistic that influences the random nature of various activities in Terraria. There are various ways to increase and decrease this statistic, such as buff potions and Torch placement. Players can estimate their luck value by speaking to the Wizard.

Luck influences many of Terraria's randomly-chosen items and events, such as the chances of item drops, rare enemy and critter spawns, certain town NPCs' first appearances, or the Traveling Merchant's inventory items.

Influences

Luck is impacted by Ladybugs, certain types of Torches, the Lucky buff, Lantern Nights, Garden Gnomes, Galaxy Pearls, certain accessories, and coins thrown into Shimmer.

With all positive effects, it is possible to reach a maximum luck value of 1.73, although with no benefit beyond a value of 1. The only factor with a negative effect on luck is from Ladybug luck, making it possible to reach a minimum luck value of −0.4.

Influence Possible values
LadybugLadybugs +0.4
...
−0.4
TorchTorchTorchTorches +0.2
+0.1
0
Luck PotionLuck Potions +0.3
+0.2
+0.1
0
Lantern NightLantern Nights +0.3
0
Garden GnomeGarden Gnomes +0.2
0
Galaxy PearlGalaxy Pearl +0.03
0
AccessoriesAccessoriesAccessories +0.1
+0.05
0
CoinsCoinsCoinsCoinsCoins +0.2
...
0

Ladybugs

The player's interactions with LadybugLadybugs, Gold LadybugGold Ladybugs, and town NPCs have a certain influence on their luck. The following is a simplified summary; see the Technical details section for a more detailed and accurate explanation.

  • Touching a Ladybug grants Ladybug +0.2 / Gold Ladybug +0.4 Ladybug luck that decreases linearly to 0 over the course of Ladybug 12 / Gold Ladybug 24 minutes.
  • Killing a Ladybug at a close distance or consuming one as bait during fishing causes Ladybug −0.2 / Gold Ladybug −0.4 Ladybug luck that increases linearly to 0 over the course of Ladybug 3 / Gold Ladybug 6 minutes.
  • Killing any town NPC other than the Guide and the Clothier causes −0.067 Ladybug luck that increases linearly to 0 over the course of 1 minute.
  • Killing the Guide causes +0.067 Ladybug luck (unless the player already has negative Ladybug luck) that decreases linearly to 0 over the course of 4 minutes.

It can be seen that, overall, positive Ladybug luck lasts four times as long as negative Ladybug luck. Ladybug luck is reset to 0 as soon as the player leaves the world.

Technical details

By default, the player has "neutral Ladybug luck", which means that Ladybug luck contributes a value of 0 to the player's overall luck. The player can have "good Ladybug luck", in which case the Ladybug luck value is positive, or "bad Ladybug luck", in which case the Ladybug luck value is negative. The Ladybug luck value is added to the player's overall luck. Both "good" and "bad Ladybug luck" are caused by certain actions by the player, are temporary, and have a set duration, and once it elapses, the player has "neutral Ladybug luck" again.

The Ladybug luck value depends on the remaining duration of "good" or "bad Ladybug luck", calculated with the following formula:[1]

,

where is 720 if the player has "good Ladybug luck" and −180 if the player has "bad Ladybug luck".

For example, if the player has 4 minutes of "bad Ladybug luck" remaining, their Ladybug luck value is −0.267. If they have 42 seconds of "good Ladybug luck" remaining, their Ladybug luck value is +0.01167.

There are five events that cause the player to receive a specific duration of "good" or "bad Ladybug luck":

  • If the player touches a naturally spawned Ladybug (i.e. one that has not been released by a player), then they will receive "good Ladybug luck" for Ladybug 12 / Gold Ladybug 24 minutes.[2]
    • "Touching" refers to an overlap of hitboxes here. If the player's hitbox somehow happens to be so large that its center is at least 30 pixels (1.875 tiles) away from the center of the Ladybug's hitbox, then the duration of the "good Ladybug luck" is reduced based on the distance, according to the following formula: (doubled for Gold Ladybugs). However, this effect is minuscule and can most often be disregarded.
  • If the player consumes a Ladybug as bait during fishing, they will receive "bad Ladybug luck" for Ladybug 3 / Gold Ladybug 6 minutes.[3]
  • If the player kills a Ladybug at a close distance, they will receive "bad Ladybug luck".[3] The duration depends on the distance:
    • If the player is less than 6.25 tiles away, then the "bad Ladybug luck" will last Ladybug 3 / Gold Ladybug 6 minutes.
    • If the player is between 6.25 and 25 tiles away, the duration depends on the distance, according to the following formula: (doubled for Gold Ladybugs). For example, at a distance of 10 tiles (160 pixels), the "bad Ladybug luck" will last Ladybug 1 minute 48 seconds / Gold Ladybug 3 minutes 26 seconds. At a distance of 24.5 tiles (392 pixels), the "bad Ladybug luck" will last Ladybug 3.6 / Gold Ladybug 7.2 seconds.
    • If the player is 25 tiles or more away from the Ladybug when it is killed, they will not receive "bad Ladybug luck".
  • If the player kills the Guide and they do not have "bad Ladybug luck", they will receive "good Ladybug luck" for 4 minutes.[4]

If the player receives "good Ladybug luck" while they have "bad Ladybug luck", the duration of the "bad Ladybug luck" is canceled immediately and they are granted the full duration of the "good Ladybug luck" (and vice versa), with the exception of killing the Guide (which only grants "good Ladybug luck" if the player does not already have "bad Ladybug luck"). If the player receives "good Ladybug luck" while they already have "good Ladybug luck", then the durations will not be added. Instead, whichever of the two durations is greater will continue to be counted down. The same applies to "bad Ladybug luck".

This reveals that the maximum duration of "good Ladybug luck" is 24 minutes (granted by touching a Gold Ladybug), which results in an initial Ladybug luck value of , and that the maximum duration of "bad Ladybug luck" is 6 minutes (caused by consuming a Gold Ladybug as bait or killing one at very close range), which results in an initial Ladybug luck value of . Of course, both of these values are merely momentary. After half a minute (assuming no new Ladybug luck is received in the meantime), both values will have already changed to +0.39167 and −0.367, respectively.

Torches

By placing or holding Torches in the correct locations, players can increase their luck:

  • Placed Torches on the Surface and in Space are ignored. This means that in these layers, only held Torches will affect luck.
  • Torch luck does not apply in the Dungeon or Jungle Temple.
  • In the Underground and below, each type of Torch present in a 81×81-tile rectangle centered on the player (and also any Torch they are holding) will increase or reduce Torch luck, with the total value limited to a maximum of 0.2 and a minimum of 0.
  • With some exceptions, biome Torches give good luck in their own biome, while giving a luck penalty in any other location.
  • Ordinary Torches give a penalty most places that a biome Torch would be available, and especially the Snow biome. Bone Torches give a bonus in biomes without their own biome Torch (and also the Ocean).
  • Colored, Ultrabright, Demon and Aether Torches, along with other light sources such as Candles, have no effect.
  • The good luck, and luck penalty, are independently limited to a maximum of 0.2 for good luck and 0.3 for the luck penalties. Thus, multiple Torches of a given type will have no increased benefit, and one or more incorrect Torches will completely negate the benefits of Torch luck.
  • No matter what penalties accumulate, Torch luck overall cannot go below 0 – it can either provide a bonus to luck, or nothing at all.
Torch Beneficial locations Increased Torch luck Reduced Torch luck
Ice TorchIce Torch Snow biome, Underground Snow 0.2 0.2
Desert TorchDesert Torch Desert, Underground Desert 0.2 0.2
Jungle TorchJungle Torch Jungle, Underground Jungle 0.2 0.2
Hallowed TorchHallowed Torch Hallow, Underground Hallow 0.2 0.2
Corrupt TorchCorrupt Torch Corruption, Underground Corruption 0.2 0.2
Crimson TorchCrimson Torch Crimson, Underground Crimson 0.2 0.2
Cursed TorchCursed Torch Corruption, Underground Corruption 0.2 0
Ichor TorchIchor Torch Crimson, Underground Crimson 0.2 0
Coral TorchCoral Torch Oceans 0.2 0 or 0.2 (see notes)
Mushroom TorchMushroom Torch Glowing Mushroom biomes 0.2 0.2
Bone TorchBone Torch Anywhere outside the Snow biome, Desert, Jungle,
Corruption, Crimson, Hallow, Dungeon or Jungle Temple
0.1 0
TorchTorch None 0 0, 0.1 or 0.3 (see notes)

Notes

To maximize luck, players should try to use biome Torches underground in their respective biomes, and avoid using the Torches for the wrong biome. They should also avoid using ordinary Torches in any biome which has its own Torch. Bone Torches are useful for biome borders, to avoid standing in one biome with the other biome's Torches in range. On the surface and in Space, players can boost their luck by holding the proper Torch; clearly this will not help with fishing or anything else that requires a non-Torch tool. Combat can still be affected defensively and by way of indirect attacks, e.g. minions, sentries, and armor effects.

If the Torch God's Favor is toggled on, ordinary Torches are automatically converted to the proper type when held and/or placed in the Hallow, Corruption, Crimson, Jungle, Desert and Snow biomes. Bone Torches, Demon Torches and Aether Torches can also be automatically placed in the Dungeon, Underworld or Aether respectively, but those still have no effect on luck there. (Bone Torches would give a bonus in the Underworld.)

Luck Potions

The Lucky buff increases luck based on how much time there is left:

Time Luck increase
More than 10 minutes left +0.3
More than 5 minutes left +0.2
5 minutes or less +0.1

The values do not stack, so using a Greater Luck Potion (which lasts for 15 minutes) will yield 5 minutes of +0.3 luck, then 5 minutes of +0.2 luck, and finally 5 minutes of +0.1 luck. The only difference between the Luck Potions is the duration of the effect.

Lantern Nights

A Lantern Night event increases luck by a flat value of +0.3. This is active everywhere in the world, even underground. However, a Lantern Night will never start if there is a Blood Moon, Pumpkin Moon, Frost Moon, or any other invasion event active, if any boss is alive, or if the Moon Lord is being summoned.

Garden Gnomes

If there is a Garden Gnome within a rectangular area of 170×125[5] tiles centered on the player, their luck will be increased by a flat value of +0.2. This effect does not stack with multiple gnomes.

Galaxy Pearl

Consuming a Galaxy Pearl will permanently increase the player's luck by +0.03.

Accessories

Certain accessories increase the wearer's luck when equipped, as well as the luck of all members of the same team that are within 50 tiles.[6]

Item Luck
Lucky Horseshoe Lucky Horseshoe +0.05
Obsidian Horseshoe Obsidian Horseshoe
Blue Horseshoe Balloon Blue Horseshoe Balloon
White Horseshoe Balloon White Horseshoe Balloon
Yellow Horseshoe Balloon Yellow Horseshoe Balloon
Green Horseshoe Balloon Green Horseshoe Balloon
Amber Horseshoe Balloon Amber Horseshoe Balloon
Pink Horseshoe Balloon Pink Horseshoe Balloon
Bundle of Horseshoe Balloons Bundle of Horseshoe Balloons
Lucky Coin Lucky Coin +0.05
Coin Ring Coin Ring
Greedy Ring Greedy Ring
Total possible value +0.1

Accessories in the same row cannot be stacked.

Coins

Coin Coin luck counter
Copper CoinCopper Coin (1) 1
Silver CoinSilver Coin (1) 100
Gold CoinGold Coin (1) 10,000
Platinum CoinPlatinum Coin (1) 1,000,000

Throwing coins into Shimmer will consume them and increase the "coin luck counter" of all players within a radius of 62.5 tiles by a certain amount[7], depending on the type of coin and stack size: 1 Copper Coin increases the coin luck counter by 1.[8]

The coin luck counter will decrease by 0.01% each tick[9], and it will immediately be set to 0 if it drops below 0.25[10] (most likely because this function, being an exponential degradation function, would otherwise be incapable of reaching zero). The player's remaining coin luck counter grants them a luck boost as displayed in the table below.[11]

Remaining coin luck counter (X) Luck
X > 249,000 +0.2
24,900 < X ≤ 249,000 +0.175
2490 < X ≤ 24,900 +0.15
249 < X ≤ 2490 +0.125
24.9 < X ≤ 249 +0.1
2.49 < X ≤ 24.9 +0.075
0.25 ≤ X ≤ 2.49 +0.05

The coin luck counter can never exceed 1,000,000[7], hence consuming 1 Platinum Coin fully charges it. This grants the maximum luck boost of +0.2 for 3 minutes 51 seconds.

Impact

Luck has a significant impact on multiple random chances throughout the game. Whenever a random chance is rolled in one of the ways listed below, an additional modifier is applied to the chance that the roll has a positive result:[12]

  • If the player's luck is greater than 0, then there is a (luck * 100)% chance that the chance is increased.
    • The exact increase is itself randomized: if the base chance is 1 in X, the chance will become 1 in Y, where Y is a uniformly-distributed random number between X/2 and X-1 (inclusive). Therefore, an event occuring with a base chance of 1 in n will, on average, become .
  • If the player's luck is less than 0, then there is a (|luck| * 100)% chance that the chance is decreased.
    • Similarly to the above, the decrease is randomized: if the base chance is 1 in X, the chance will become 1 in Y, where Y is a random number between X and X*2-1 (inclusive). Therefore, an event occuring with a base chance of 1 in n will, on average, become .
  • If the player's luck is 0, the chance will be the base value.

For example, if the base probability of an event is 10%, then:

  • If the player's luck is 1.0, there is a 100% chance that the probability will become something between 1 in 5 and 1 in 9, leading to an average final probability of approximately 14.91%[13].
  • If the player's luck is 0.5, there is a 50% chance that the probability is increased, leading to an average final probability of approximately 12.46%[14].
  • If the player's luck is 0.0, the final probability is equal to the base probability, 10%.
  • If the player's luck is -0.2, there is a 20% chance that the probability will become something between 1 in 10 and 1 in 19, leading to an average final probability of approximately 9.44%[15].
  • If the player's luck is -0.4, there is a 40% chance that the probability will be decreased, leading to an average final probability of approximately 8.88%[16].

As an example, for a drop that has a chance of 2% on killing an enemy, if that enemy is killed 1000 times, one would expect 20 of that drop:

  • After killing a Ladybug, one would instead get 18 (rounding down) of that drop. If it took an hour to farm for this drop, it now would take an additional 7 minutes. Note that the negative Ladybug luck would wear out by then.
  • In an Underground Jungle biome with a single Jungle Torch, a Garden Gnome, with 5 minutes of the Lucky buff remaining, on a Lantern Night, one would get 28 of that drop. If it took an hour to farm for this drop, it now would take approximately 17 fewer minutes.

Item drops

With a few exceptions, almost all drop rates of items are affected by luck. The luck of the player closest to the defeated enemy is used for the calculation.

  • Another exception is the Feather dropping from Harpies, which always has a 50*1/2 (50%) chance unaffected by luck.[18]
  • Players with high luck have better coin drop rates in the same way as damage, for around a 15% increase/decrease at maximum/minimum luck.
  • Only enemy drops are affected by luck. The drop rates of items from grab bags like crates or Oysters are unaffected.

NPC spawning

There are several NPC spawn rates that are affected by the player's luck:

Other mechanics

  • The chance of Coin Portals appearing from Pots is affected by the luck of the player closest to the broken Pot.[20]
  • The player with the highest luck will influence the chances of items being available for sale in the Traveling Merchant's inventory.[21]
  • While fishing, positive luck gives a (100 * luck)% chance of silently multiplying fishing power by a random number between 110% and 140%.[22]
    • Inversely, negative luck gives a (-100 * luck)% chance of silently multiplying fishing power by a random number between 60% and 90%.
    • Actual fishing rewards are not influenced by luck beyond fishing power.
  • Damage calculations in many situations are influenced by luck; positive luck will be favorable to the player. Projectiles are influenced by luck, as is enemy melee damage (e.g. touching a Zombie). Player weapons also take luck into account.
    • The following steps are taken to incorporate luck into a player's damage:[23]
      • The initial damage value is generated.
      • The game checks if the player has > 0 luck, and if so, generates a random number from 0.0 to 1.0. If the random number is less than the player's luck, a second damage value is generated, and the higher of the two numbers is dealt.
      • If the player has < 0 luck, a random number is generated from 0.0 to 1.0. If the random number is less than the absolute value of the player's luck, a second damage value is generated, and the lower of the two numbers is dealt.
    • This is up to a 5% increase/decrease in average damage before defense.
    • Luck affects PvP the same way it affects regular enemies.
    • Thorns Potion, Turtle armor set bonus, Brand of the Inferno and Sergeant United Shield parry damage are all affected inversely by luck. Positive luck values have a chance to decrease potential incoming damage, which would decrease reflected damage caused by thorns effect or parrying.

Not affected by luck

A list of mechanics which are not affected by luck (including points made above):

  • Fishing catches (beyond fishing power effects) or Angler rewards.
  • Loot from any grab bags item such as crates or Oysters.
  • For any boss or enemy drop which is guaranteed to choose one item from a list, the choice is unaffected.
  • Some boss drops listed above.
  • Feathers have a fixed 50*1/2 (50%) drop chance from Harpies.
  • Any "dodging" mechanic from armor, accessories, etc.
  • Ammo conservation rates.
  • Event occurrences (Luck is itself affected by Lantern Nights as above).
  • Health and mana recovery.
  • Buff or debuff effects, other than thorns.
  • Other things related to random chances.

Wizard luck status

The Wizard will occasionally give the player a general idea of what their luck value is, in place of his regular dialogue.

This content is transcluded from Wizard.

  • 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.75 and ≥ 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.5 and ≥ 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.25 and > 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 Wizard does not use any of these quotes if luck is 0.)
    If luck is < 0 and ≥ −0.14
    • "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 < −0.14 and ≥ −0.28
    • "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 < −0.28 and ≥ −0.42
    • "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 < −0.42 (impossible to access)
    • "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!!"
  • Trivia

    • When introduced, mismatched Torches could result in a negative Torch luck value, reducing the final luck score. This was removed shortly after, in 1.4.0.3, after a Reddit post criticizing the mechanic garnered attention, causing a large community backlash. This change caused the Wizard's messages below −0.42 luck to become impossible to see in-game.

    History

    • Desktop 1.4.4:
      • Having the Lucky Horseshoe or one of its derivatives equipped now grants +0.05 luck.
      • Having the Lucky Coin or one of its derivatives equipped now grants +0.05 luck.
      • Added coin luck.
    • Desktop 1.4.0.3: Negative luck influence from Torches capped at a minimum of 0. Incorrect Torches can still remove positive luck influence from Torches.

    References

    1. Information taken from the Desktop version Desktop 1.4.2.3 source code, methods GetLadyBugLuck() in Terraria.Player.cs and RecalculateLuck() in Terraria.Player.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.
    2. Information taken from the Desktop version Desktop 1.4.2.3 source code, method LadyBugLuck() in Terraria.NPC.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.
    3. 3.0 3.1 Information taken from the Desktop version Desktop 1.4.2.3 source code, method LadyBugKilled() in Terraria.NPC.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.
    4. 4.0 4.1 Information taken from the Desktop version Desktop 1.4.2.3 source code, method NPCLuck() in Terraria.NPC.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.
    5. Information taken from the Desktop version Desktop 1.4.3.6 source code, method ScanAndExportToMain() in Terraria.SceneMetrics.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.
    6. Information taken from the Desktop version Desktop 1.4.4.9 source code, methods UpdateEquips() in Terraria.Player.cs and RefreshInfoAccsFromTeamPlayers() in Terraria.Player.cs.
    7. 7.0 7.1 Information taken from the Desktop version Desktop 1.4.4.7 source code, method AddCoinLuck() in Terraria.Player.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.
    8. Information taken from the Desktop version Desktop 1.4.4.7 source code, method GetShimmered() in Terraria.Item.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.
    9. 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.
    10. Information taken from the Desktop version Desktop 1.4.4.7 source code, method UpdateCoinLuck() in Terraria.Player.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.
    11. Information taken from the Desktop version Desktop 1.4.4.7 source code, method CalculateCoinLuck() in Terraria.Player.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.
    12. Information taken from the Desktop version Desktop 1.4.0.3 source code, method RollLuck() in Terraria.Player.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.
    13. (1/5 + 1/6 + 1/7 + 1/8 + 1/9) / 5 * 1.0 + 1/10 * (1 - 1.0) ≈ 0.149127
    14. (1/5 + 1/6 + 1/7 + 1/8 + 1/9) / 5 * 0.5 + 1/10 * (1 - 0.5) ≈ 0.124563
    15. (1/10 + 1/11 + 1/12 + 1/13 + 1/14 + 1/15 + 1/16 + 1/17 + 1/18 + 1/19) / 10 * 0.2 + 1/10 * (1 - 0.2) ≈ 0.094375
    16. (1/10 + 1/11 + 1/12 + 1/13 + 1/14 + 1/15 + 1/16 + 1/17 + 1/18 + 1/19) / 10 * 0.4 + 1/10 * (1 - 0.4) ≈ 0.088751
    17. Information taken from the Desktop version Desktop 1.4.3.6 source code, several methods in Terraria.GameContent.ItemDropRules.ItemDropDatabase.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.
    18. Information taken from the Desktop version Desktop 1.4.2.3 source code, method RegisterMiscDrops() in Terraria.GameContent.ItemDropRules.ItemDropDatabase.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.
    19. Information taken from the Desktop version Desktop 1.4.4.7 source code, method SpawnNPC() in Terraria.NPC.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.
    20. Information taken from the Desktop version Desktop 1.4.2.3 source code, method CheckPot() in Terraria.WorldGen.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.
    21. Information taken from the Desktop version Desktop 1.4.2.3 source code, method SetupTravelShop() in Terraria.Chest.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.
    22. Information taken from the Desktop version Desktop 1.4.0.3 source code, method FishingCheck() in Terraria.Projectile.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.
    23. Information taken from the Desktop version Desktop 1.4.0.2 source code, method damageVar() in Terraria.Main.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.