Damage

From Terraria Wiki
Jump to navigation Jump to search

Damage is the number of health points subtracted from an entity's current health. It can be inflicted by a multitude of entities, most prominently weapons, enemies, and NPCs (and all related projectiles). Furthermore, it can be caused by environmental hazards (such as thorny bushes, traps, or lava) and game mechanics (such as fall damage, drowning, or debuffs). Damage can generally only be inflicted on entities with a health statistic, i.e., players, most enemies, and NPCs. Most damage sources additionally inflict knockback on the damaged entity.

When an entity receives damage, several calculations increasing or decreasing the amount of damage (depending on several factors; see below) are performed before the actual damage is applied to the entity. Therefore, the damage statistic of any damaging entity is usually only the average damage it inflicts. Most hits' damage deviates from this average number.

Damage inflicted by player-wielded weapons is categorized into four different types: melee, ranged, magic, and summon. Accessories, buffs, and other damage-boosting or damage-decreasing effects often only affect one of these damage types. A few weapons as well as all other damaging entities are not categorized into any of the four types.

Damage types

Melee

Melee weapons are used in close- to medium-ranged combat. Their defining trait is the fact that they do not consume ammunition or mana upon use. They are roughly categorized into swords, spears, flails, boomerangs, and yoyos. There are several other melee weapons not fitting any of these types.

In total, there are currently 190 unique melee weapons.

Ranged

Ranged weapons are used in long-ranged combat. Their defining trait is the requirement of ammunition in order for the weapon to operate. They are roughly categorized into bows, repeaters, guns, and launchers. All consumable weapons are classified as ranged weapons as well. Although boomerangs are thrown, Terraria classifies them as melee weapons.

In total, there are currently 115 unique ranged weapons.

Magic

Magic weapons are used in medium- to long-ranged combat. Their defining trait is the consumption of mana upon every use. Due to their unusual and unique forms of attack, the majority of magic weapons can hardly be categorized into distinct types.

In total, there are currently 77 unique magic weapons.

Summon

Summoning weapons include summon staffs and whips. Using a summon staff spawns a secondary character which will aid the player in battle by automatically attacking enemies. The summoned character is either mobile, i.e. following the player around (minion), or stationary, i.e. remaining at the location it was summoned at (sentry). Whips are close- to mid-range weapons which boost minion damage on hit enemies as well as marking them, making minions focus on those enemies.

Mounts that do damage, like the Slime Mount, deal summon damage.

In total, there are currently 47 unique summon weapons, 9 of which are whips.

Invincibility frames and piercing

Player invincibility

After being damaged, the player gets a period of time called an "invincibility frame" during which they cannot be damaged again. By default this is 2/3 of a second (40 ticks[1]), but various equipment can extend this:

  • Use of a Cross Necklace or any of its upgrades will add another 2/3 of a second (40 ticks) after receiving any attack. (The Cross Necklace does not stack with its upgrades.)
  • If a Black Belt (or its upgrade the Master Ninja Gear, but the two do not stack) is worn, a successful dodge (10% chance) will trigger an invincibility frame and add another 2/3 seconds (40 ticks) to it. It also prevents damage from the attack. If combined with the Cross Necklace, this extends the invincibility to a full 2 seconds (120 ticks).
  • Hallowed armor similarly provides the Holy Protection buff; this is triggered by attacking an enemy, and when active, the next time the player would have taken damage, they instead get 2 seconds (120 ticks) of invincibility. This also stacks with the effects of the Cross Necklace and Black Belt, potentially granting 3 and 1/3 seconds (200 ticks) of invincibility.
  • Taking damage in PvP or from one's own weapon will only grant 8 ticks of invincibility.

Piercing attacks against enemies

Enemies get a similar but more limited effect from "piercing" and continuous attacks: Any damage source that can strike an enemy, and then remain able to cause damage afterwards.

When an enemy is hit by a piercing projectile (a weapon, projectile, or minion that can hit multiple times), the game has to use what is called immunity frames to prevent the enemy from taking damage from the projectile repeatedly every single frame, which could otherwise be as many as 60x hits a second. After hit, the enemy becomes temporarily immune to being hit again, though this duration is almost always measured in fractions of a second, which is more than enough for most projectiles to move through the enemy and be on their way. Particularly slow projectiles may still hit a target multiple times, but their immune frames prevent them from hitting every single frame, so this is within expected behavior. The amount of immune time inflicted by a projectile can be adjusted to make it hit more or less frequently. Immune frame time does not apply to non-piercing attacks (regular bullets, for instance, which only hit once).[2]

After being struck by such an attack, the enemy cannot take damage from another such attack for a brief period, usually 1/6 of a second (10 ticks[1]). Thus, when in lava or when pierced by a persistent weapon such as a Vilethorn, they can take damage at most 6 times a second. However, for multi-segmented enemies (usually worm types), this resistance applies to each segment separately, so such attacks can still strike multiple segments of a single enemy. (Note that worm-type enemies are immune to lava in any case.)

Global Immunity

By default, all piercing weapons in the game inflict what is called "Global Immunity" when hitting enemies. These enemies become invulnerable to ALL sources of piercing damage, including other types of attacks, for the duration of that period. This period is typically a default of 10 frames (1/6th of a second), but can be changed to allow faster or slower hitting. This was the original implementation of Terraria's immune frame system, though developers are shifting away from it over time. An unfortunate consequence of global immunity is that it "blocks" the player from doing damage with different types of damage sources. Unless manually set otherwise, all piercing projectiles in the game, especially older ones, use the global immunity system. Many Global Immunity projectiles were balanced around this limitation, doing more damage than they might otherwise if they were not.

Static Immunity

Some piercing projectiles have been changed to use "Static" immunity. This form of immunity will still induce immune time, but this immune time will ONLY block damage from that specific TYPE projectile. Though repeated hits from the same type of piercing projectile during the immunity period will not be able to land, hits from any other type of piercing projectile WILL be able to deal damage. Similar to Global, Static immunity time duration can be changed as needed. Though Static projectiles will not interfere with other sources of damage, there are still scenarios where firing multiple projectiles of the same type will be counter productive. For example, putting Jester Arrows (which inflict Static Immunity) on Tsunami will result in only one of the piercing arrows hitting, because the enemy will be temporarily immune to Jester Arrows as the other arrows pass through. Most projectiles that use Static are balanced around this.

Local Immunity

Finally, the third type of piercing projectile behavior is called "Local". It will still induce immune time, but this immune time will only apply to the exact specific projectile which did the damage. This means that if you have two of the same type of Summon minion using local immunity, EACH minion will operate on its own independent immune timer, and they will not conflict with each other at all, nor will they block damage from any other sort of piercing damage. Local projectiles will never interfere with the player's ability to land hits with other projectiles, nor will firing large quantities of a local projectile be inefficient or fail to land hits. However, because the system was not usable for majority of the game's history, almost all piercing weapons were not balanced around it.

Peculiarities

On the Old-gen console version Old-gen console version and Nintendo 3DSNintendo 3DS version versionVerify, this also applies to almost any missile, beam, or other projectile that continues to exist after striking an enemy. This can sharply limit the effects of other piercing weapons used against the same target, as well as weapons that fire multiple piercing projectiles such as the Poison Staff. Most minions are considered to have piercing attacks, which can also hinder the efficiency of piercing weapons used alongside them. This problem is remarkably present with the Spider Staff and the Stardust Dragon Staff.

On the Desktop version Desktop version, Console version Console version, and Mobile version Mobile version, summons do not hinder other piercing weapons, but piercing weapons may still hinder the effectiveness of summons.

A few advanced weapons have special behavior:

Calculations

The damage that a player-wielded weapon deals upon hit is determined cumulatively[3]:

  • Step 1: Calculate the damage boost from the weapon's modifier. The result is rounded to the nearest integer.
Weapon damage = round[Base damage × (1 + Weapon modifier boost)]
  • Step 2: Calculate the damage boost separately for each damage type (from armor, accessories, modifiers from items, buffs, etc.). For ranged weapons, the damage boost calculated here does not include boosts that affect a specific ammo type (see "Step 2" for details).
Damage boost = [(Head + Chest + Legs + Set bonus) + (Accessories boost + Accessory modifiers boost) + Buff boost]×100%
  • Step 3: Apply the damage boost to damage, calculated with the following formula:
Final damage = Weapon damage × (1 + Damage boost)
  • For ranged weapons, the damage is calculated with the following formula. The "ammo type boost" includes boosts from the Magic Quiver and its upgrades, and the different headpieces of the Shroomite armor.
Final damage = Weapon damage × (1 + Ranged damage boost) × (1 + Ammo type boost) + Ammo's damage × (1 + Ranged damage boost)
Final damage = [Final damage + 2 (from Molten Quiver)] × 1.2 (from Archery buff)

For example, the damage of a Godly Meowmere with Turtle Armor, Menacing Warrior Emblem, Menacing Avenger Emblem, Menacing Destroyer Emblem, Menacing Mechanical Glove and Menacing Celestial Stone equipped, Well Fed active is calculated as follow:

  • Weapon damage = 200 × (1 + 15%) = 230
  • Damage boost = [(6+8+0+0) + (15+12+10+12+10+4+4+4+4+4) + (5)]×100% = 98%
  • Final damage = 230 × (1+98%) = 455

Damage done to an enemy is depending on the enemies defense and whether there is a related banner nearby.

EnemyDamageReduction = ⌈EnemyDefense/2⌉

So,

DamageDealtToEnemy = FinalDamage − EnemyDamageReduction without a banner;
And DamageDealtToEnemy = 1.5 × FinalDamage-EnemyDamageReduction with a banner in normal mode,
Or DamageDealtToEnemy = 2 × FinalDamage-EnemyDamageReduction with a banner in Expert Mode,

Damage dealt is always at least 1.

In addition the outgoing damage is modified by a random factor, 0.85~1.15, (but some types of damage, like the Slime Mount, will not be affected by this). The damage is rounded to the nearest whole number. So you can compute the minimal and maximal damage dealt to an enemy with your weapon:

MinDamage = round(FinalDamage × 0.85 − EnemyDamageReduction)
MaxDamage = round(FinalDamage × 1.15 − EnemyDamageReduction)

At critical hits you are dealing double damage

CriticalMinDamage = MinDamage × 2
CriticalMaxDamage = MaxDamage × 2

To calculate the damage per second, see also Use time.


Note: The actual calculations for the damage can be inconsistent, for example: A Bee Keeper (30) or Nimbus Rod (30) should mathematically do the following damage:

Min: 30*0.85 = 25.5
Max: 30*1.15 = 34.5

Rounded:

Min: 25.5 => 26 or 25.5 => 25
Max: 34.5 => 35 34.5 => 34

However, they both do between 26-34 damage, an entire difference of 8 from the original sum. That means:

Min value is rounded UP.
Max value is rounded DOWN.

This method is in itself very smart, because the average damage does not shift up or down. But if one was to apply this expression to a Tungsten Shortsword (10) you get the following results:

Min: 10*0.85 = 8.5
Max: 10*1.15 = 11.5

Rounded:

Min: 8.5 => 26 or 8.5 => 25
Max: 11.5 => 35 11.5 => 34

But it does between 8-12 damage, which is an entire difference of 4. That means:

Min value is rounded DOWN.
Max value is rounded UP.

Even with the Tungsten Shortsword the theoretical average damage does not shift, but the methodology is inconsistent and not comprehensible. For one damage value the min value is rounded down for the other the max value. This inconsistency, however, is very niche and doesn't seem to have a significant impact on gameplay.

One noticeable thing of these discrepancies is that their differences are a multiple of 4.

References

  1. 1.0 1.1 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.
  2. Terraria: Labor of Love is Out Now! September 28, 2022
  3. Information taken from the Desktop version Desktop 1.4.3.6 source code, methods GetWeaponDamage() in Terraria.Player.cs and PickAmmo() in Terraria.Player.cs. There may be inaccuracies, as the current Desktop version Desktop version is 1.4.4.9.