Immunity frames

From Calamity Mod Wiki
Jump to: navigation, search

Immunity frames, also called invincibility frames, invulnerability frames, and frequently shortened to iframes or i-frames, are a core game mechanic of Terraria which provide a window of time where the player or an NPC is immune to damage from one or all sources.

Many items in both the base game and the Calamity Mod have special interactions with immunity frames, whether it is an accessory which provides extra immunity frames to the player when attacked (e.g. Deific Amulet) or a weapon which can strike NPCs far more quickly than is normally possible (e.g. The Empyrean).

Player Immunity Frames[edit | edit source]

There are different ways to augment player immunity frames. Additionally, in Revengeance Mode, player immunity frames are capped at 120, or 2 seconds.

Cross Necklace Inheritance[edit | edit source]

The Cross Necklace accessory doubles the player's immunity frames. The Calamity Mod adds two accessories that grant this effect. The immunity frame doubling effect cannot stack with itself, so equipping more than one of these accessories provides no further benefit.

  • Adding Immunity Frames[edit | edit source]

    There are several events and effects that directly set or add to a player's immuneTime instead of multiplying. Effects which add immunity frames will stack with the Cross Necklace or other accessories which inherit that effect.

    A table of all items that use this code, along with the corresponding immuneTime values is below:

     
    [link]Click here to reveal this content. (there may be a slight delay)[/link]
    This table requires JavaScript to be enabled and site tooltips to be turned on to be displayed.
    You can also view the data on another page.

    Ignoring NPC Immunity Frames[edit | edit source]

    Terraria provides three mechanisms by which projectiles may ignore, bypass or reduce NPC immunity frames.

    usesLocalNPCImmunity[edit | edit source]

    If a projectile sets usesLocalNPCImmunity to true, its interaction with immunity frames fundamentally changes. When the projectile strikes an NPC, instead of setting the NPC's npc.immune, it sets up a timer on the projectile which stops that specific projectile from striking any NPC for a certain number of frames. Once the timer is up, the projectile can strike NPCs again.

    The length of the timer is determined by the variable localNPCHitCooldown. Since Terraria runs at 60 frames per second (FPS), a value of 60 for localNPCHitCooldown would limit the projectile to striking once per second. However, the timer only applies to the specific projectile which started it. Any other projectiles - even piercing ones - can still hit the NPC while the timer is running, which is what gives the impression that the projectile "ignores iframes".

    localNPCHitCooldown also has two special values, -2 and -1. In both of these cases, no internal timer is set. Instead, the NPC that was struck by the projectile becomes permanently immune to that specific projectile forever. This means that the NPC can only be hit by a projectile with negative localNPCHitCooldown once, no matter how long the projectile lasts. When localNPCHitCooldown is set to -1, the projectile sets npc.immune to zero on hit, ensuring that it always hits no matter what. This also lends credence to the phrase "ignores iframes", because the projectile literally ignores the immunity frames of the NPC it is hitting.

    Summary of the behavior of localNPCHitCooldown values:

    • -2: The NPC's immunity frames are unaffected by the projectile. If the NPC has immunity frames, the projectile does not strike. Otherwise, the NPC is struck and does not receive any immunity frames. The projectile will never hit this NPC again.
    • -1: The projectile explicitly removes the NPC's immunity frames on contact. It always hits. The projectile will never hit this NPC again. An example of localNPCHitCooldown -1 is Luminite Bullets.
    • 0: Behaves effectively the same way as -2, except that the projectile can immediately strike the NPC again on the next frame. The NPC gets no immunity frames if struck, but the projectile won't remove immunity frames if the NPC already has some.
    • 1: Behaves almost the same as 0. The difference is that because the NPC's npc.immune is set to 1, it is immune to all other basic piercing or -2 localNPCHitCooldown projectiles which would strike it this frame.
    • 2+: The projectile can only strike any NPC once per this many frames.

    A table of all items with projectiles that use this code, along with the corresponding localNPCHitCooldown values is below:

    • Additionally, the explosions created by the Chaotic Puffer also set usesLocalNPCImmunity to true, with localNPCHitCooldown set to 1.
     
    [link]Click here to reveal this content. (there may be a slight delay)[/link]
    This table requires JavaScript to be enabled and site tooltips to be turned on to be displayed.
    You can also view the data on another page.

    usesIDStaticNPCImmunity[edit | edit source]

    If a projectile sets usesIDStaticNPCImmunity to true and idStaticNPCHitCooldown to a value, its interaction with immunity frames is fundamentally changed. Much like usesLocalNPCImmunity, a timer is set when the projectile strikes an NPC. However, this type of internal timer blocks out all projectiles of the same type from the same player. This means that after any instance of a usesIDStaticNPCImmunity projectile hits an enemy, the NPC is immune to all projectiles of that type from the player who struck them for a given time. All projectiles which use usesIDStaticNPCImmunity explicitly remove immunity frames from any NPCs they strike, like projectiles which set localNPCHitCooldown to -1.

    A table of all items with projectiles that use this code, along with the corresponding idStaticNPCHitCooldown values is below:

     
    [link]Click here to reveal this content. (there may be a slight delay)[/link]
    This table requires JavaScript to be enabled and site tooltips to be turned on to be displayed.
    You can also view the data on another page.

    npc.immune[edit | edit source]

    Projectiles which set npc.immune to a value upon striking an NPC simply change the number of immunity frames the NPC receives. Like a typical piercing projectile, the NPC will not be able to be struck by any piercing projectiles for that many frames. Normal piercing projectiles set npc.immune to 10, so typically projectiles which change this behavior set npc.immune to a lower value such as 4. This behavior is often called "partially ignoring iframes", because it removes or ignores some of the NPC's immunity frames, but not all of them.

    A table of all items with projectiles that use this code, along with the corresponding npc.immune values is below:

     
    [link]Click here to reveal this content. (there may be a slight delay)[/link]
    This table requires JavaScript to be enabled and site tooltips to be turned on to be displayed.
    You can also view the data on another page.