Invincibility frame

From Terraria Wiki
(Redirected from Invincibility frames)
Jump to navigation Jump to search

An invincibility frame (also known as immune frame, immunity frame, or invulnerability frame, sometimes abbreviated to iframe or i-frame) is a brief period of time during which an entity cannot take any damage. It is usually granted immediately after taking damage.

Player invincibility

The player gets an invincibility frame after taking damage from any source. The length of the invincibility frame varies depending on the circumstances; certain items will also provide invincibility frames when their effects are triggered. See below for details.

Invincibility groups

Some groups of damage sources inflict separate "types" of invincibility frames. These different types of invincibility frames will not interfere with each other. The vast majority of damage sources are in the same group ("Group 4" below), but there are three other groups:

Group 1 ((Desktop, Console and Mobile versions) only)
Damage inflicted by darkness in a Constant world[1], and damage inflicted by these tiles:[2]
Group 2
All damage inflicted by these bosses:[3]
Group 3 ((Desktop, Console and Mobile versions) only)
Damage inflicted by lavalava.[4]
Group 4
All other damage.

For example, (on (Desktop, Console and Mobile versions)) if the player takes damage from a Spike ("Group 1" above), they will not take any damage from e.g. touching a Rolling Cactus (also "Group 1") for the duration of the invincibility frame, but they will still take damage from e.g. an enemy ("Group 4") during this time.

Invincibility frame length

Taking damage usually grants the player an invincibility frame of 0.67 seconds by default. This duration is halved if the amount of damage taken is 1, and is even lower in PvP. The Cross Necklace and its upgrades increase the length of the invincibility frame[a]. Various other effects also grant an invincibility frame, such as respawning, dodging, parrying, or dealing damage with a mount. See the following table for details.

Source Default[b] Cross Necklace[c]
Default invincibility frames
when taking damage[5]
0.67 seconds 1.33 seconds
If the damage taken is 1[5] 0.33 seconds 0.67 seconds
PvP damage[d] 0.13 seconds n/a
Respawning after dying in PvP[6] 5 seconds n/a
Respawning after dying
outside of PvP[6]
3 seconds n/a
When entering a world, or being
teleported back to spawn point
(e.g. via Magic Mirror)[6]
1 second n/a
Holy Protection Holy Protection(Desktop, Console and Mobile versions)[7] 1.33 seconds[e] 2 seconds[e]
Shadow Dodge Shadow Dodge(Old-gen console and 3DS versions)
Black Belt Black Belt(and its upgrades)[8]
Brain of Confusion Brain of Confusion(Dodge effect)[9]
Brand of the Inferno Brand of the Inferno(Desktop, Console and Mobile versions)(shield parry)[10] 0.5 seconds 1 second
Sergeant United Shield Sergeant United Shield(Desktop, Console and Mobile versions)(shield parry)
Strange Brew Strange Brew(Desktop, Console and Mobile versions)[11] Provide invincibility frames at
different chances when used:[e]

11%: 4 seconds
20%: 2 seconds
30%: 1 second
39%: None

n/a
Companion Cube Companion Cube(Desktop, Console and Mobile versions)(stab)[12] None n/a
Slime Mount Slime Mount(Desktop, Console, Old-gen console and Mobile versions)(on hit)[13] 0.1 seconds n/a
Winged Slime Mount Winged Slime Mount(Desktop, Console and Mobile versions)(on hit)
Unicorn Mount Unicorn Mount(Desktop, Console and Mobile versions)(on hit)[14]
Painted Horse Mount Painted Horse Mount(Desktop, Console and Mobile versions)(on hit)
Majestic Horse Mount Majestic Horse Mount(Desktop, Console and Mobile versions)(on hit)
Dark Horse Mount Dark Horse Mount(Desktop, Console and Mobile versions)(on hit)
Goat Mount Goat Mount(Desktop, Console and Mobile versions)(on hit)
Pirate Ship Mount Pirate Ship Mount(Desktop, Console and Mobile versions)(on hit)
Tree Mount Tree Mount(Desktop, Console and Mobile versions)(on hit)
Basilisk Mount Basilisk Mount(Desktop, Console and Mobile versions)(on hit)
Lawn Mower Lawn Mower(Desktop, Console and Mobile versions)[15]
Golf Cart Golf Cart(Desktop, Console and Mobile versions)(on hit) 0.2 seconds n/a
Shield of Cthulhu Shield of Cthulhu(Desktop, Console and Mobile versions)(dash hit)[16] 0.07 seconds n/a
Solar Flare armor Solar Flare armor(Desktop, Console and Mobile versions)(dash hit)

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 invincibility frames to prevent the enemy from taking damage from the projectile repeatedly every single frame, which could otherwise be as many as 60 hits per 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 invincibility 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. invincibility frame does not apply to non-piercing attacks (regular bullets, for instance, which only hit once).[17]

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[18]). 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 ticks[18] (0.17 seconds), but can be changed to allow faster or slower hitting. This was the original implementation of Terraria's invincibility 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.

On the Old-gen console version Old-gen console version and Nintendo 3DSNintendo 3DS version versionVerify, global immunity applies to almost all piercing projectiles. 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.

Static Immunity

Some piercing projectiles have been changed to use "Static" immunity. This form of immunity will still induce invincibility frames, but this invincibility frame will only block damage from that specific projectile type (i.e. projectiles with the same ID). 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, firing Jester's Arrows (which inflict Static Immunity) with Tsunami will result in only one of the arrows hitting, because the enemy will be temporarily immune to Jester's Arrows after one of the arrows hit it, letting 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 invincibility frames, but this invincibility frame will only apply to the exact specific projectile which did the damage. This means that if two minions of the same type are 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 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:

Invincibility between non-player entities

Non-player entities will also get invincibility frames after taking contact damage. This invincibility frame does not interfere with invincibility frames from piercing attacks. The length of the invincibility is 0.33 seconds for the Eternia Crystal(Desktop, Console and Mobile versions), and 0.5 seconds for all other entities, including critters, town NPCs, and enemies.[19]

Only a few methods can grant this kind of invincibility frame, including:

  • Critters and town NPCs taking contact damage from enemies.
  • (Desktop, Console and Mobile versions) Eternia Crystal taking damage from enemies.
  • (Desktop, Console and Mobile versions) Bees attacking enemies.

History

  • Desktop 1.4.1.2: Damage from lava now has its own group of invincibility, separate from all other damage sources.
  • Desktop 1.3.0.5: Damaging tiles (Thorny bushes, Spikes, and Wooden Spikes) now have their own group of invincibility, separate from all other damage sources.

References

  1. Information taken from the Desktop version Desktop 1.4.4.9 source code, method Update() in Terraria.GameContent.DontStarveDarknessDamageDealer.cs.
  2. Information taken from the Desktop version Desktop 1.4.4.9 source code, method ApplyTouchDamage() in Terraria.Player.cs.
  3. Information taken from the Desktop version Desktop 1.4.4.9 source code, method Update_NPCCollision() in Terraria.Player.cs.
  4. Information taken from the Desktop version Desktop 1.4.4.9 source code, method Update() in Terraria.Player.cs.
  5. 5.0 5.1 Information taken from the Desktop version Desktop 1.4.4.9 source code, method Hurt() in Terraria.Player.cs.
  6. 6.0 6.1 6.2 Information taken from the Desktop version Desktop 1.4.4.9 source code, method Spawn() in Terraria.Player.cs.
  7. Information taken from the Desktop version Desktop 1.4.4.9 source code, method ShadowDodge() in Terraria.Player.cs.
  8. Information taken from the Desktop version Desktop 1.4.4.9 source code, method NinjaDodge() in Terraria.Player.cs.
  9. Information taken from the Desktop version Desktop 1.4.4.9 source code, method BrainOfConfusionDodge() in Terraria.Player.cs.
  10. Information taken from the Desktop version Desktop 1.4.4.9 source code, method Update_NPCCollision() in Terraria.Player.cs.
  11. Information taken from the Desktop version Desktop 1.4.4.9 source code, method ApplyLifeAndOrMana() in Terraria.Player.cs.
  12. Information taken from the Desktop version Desktop 1.4.4.9 source code, method AI_067_FreakingPirates() in Terraria.Projectile.cs.
  13. Information taken from the Desktop version Desktop 1.4.4.9 source code, method JumpMovement() in Terraria.Player.cs.
  14. Information taken from the Desktop version Desktop 1.4.4.9 source code, method HorizontalMovement() in Terraria.Player.cs.
  15. Information taken from the Desktop version Desktop 1.4.4.9 source code, method MowTheLawn() in Terraria.Player.cs.
  16. Information taken from the Desktop version Desktop 1.4.4.9 source code, method DashMovement() in Terraria.Player.cs.
  17. Terraria: Labor of Love is Out Now! September 28, 2022
  18. 18.0 18.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.
  19. Information taken from the Desktop version Desktop 1.4.4.9 source code, method BeHurtByOtherNPC() in Terraria.NPC.cs.
  1. The Cross Necklace and its upgrades do not stack with each other.
  2. Invincibility frames provided by default.
  3. Invincibility frames provided if the Cross Necklace or its upgrades is equipped. "n/a" means not affected by Cross Necklace.
  4. Includes both damage from another player and self-induced damage, e.g. explosives and (Old-gen console and 3DS versions) Exploding Bullets.
  5. 5.0 5.1 5.2 Provide all types of invincibility frames. Information taken from the Desktop version Desktop 1.4.4.9 source code, method SetImmuneTimeForAllTypes() in Terraria.Player.cs.