AI

From Terraria Wiki
Jump to navigation Jump to search
Information.svg
Note: In the Terraria Wiki, the term "NPCs" generally refers to Town NPCs; however, for the purpose of this article, it also encompasses enemies and critters.

AI (artificial intelligence) is the behavioral pattern exhibited by an NPC. For instance, the Caster AI will always warp, shoot three times, pause for three seconds, and then warp again. Knowing the AI an enemy uses can provide an advantage in combat, as it offers an idea of how the enemy will attack and react in given scenarios.

In addition, additional AI is added for certain NPCs, such as the non-aggressive mode of surface slimes, the Eater of Souls' circling around the player, the Wandering Eye's acceleration, or the ranged attack of some Fighter AI enemies.

Most AIs are not given names in the game code, so they are given names here to assist in identifying them across the wiki. They are mainly given based on observed behavior (such as Flying AI), NPC groups (such as Slime AI), or the first NPC to implement the AI (such as Demon Eye AI).

Types

There are 130 different AI types:

ID Name Description NPCs
0 No AI Does not move.
1 Slime AI Hops in one direction, slides on slopes, floats in water, follows player if damaged or during nighttime. Grasshoppers, on the other hand, flee from nearby players.
2 Demon Eye AI Flies, follows player, bounces off walls in an arc.
3 Fighter AI Will walk, jump over holes, follow player. It will try to line up vertically first. If it fails to reach its target, it will back up a bit, then re-attempt. It is the most common AI in Terraria.
  • 4 Eye of Cthulhu AI Alternates between trying to stay above the player and summoning Servants of Cthulhu, and charging at the player occasionally. Spins when at low health, and begins exclusively charging at the player. Always looks at player.
    5 Flying AI Flies, looks at player, follows player.
    6 Worm AI Burrows in ground (and/or air), passes through blocks, follows player. Truffle Worm instead flees from players.
    7 Passive AI Walks semi-randomly, jumps over holes.
    As of the 1.3 update, all Town NPCs talk to each other and the player, and each Town NPC has a different weapon to defend themselves when an enemy is nearby.
  • 8 Caster AI Casts spells at player, stays stationary, warps after three casts, warps if falling. It stops casting spells if damaged, then warps if left alone.
    9 Spell AI Travels in a direct line towards player, going through blocks. Used by casters.
    10 Cursed Skull AI Tries to drift towards or around player, often stays a little bit out of reach once having touched the player.
    11 Head AI Tries to stay above player, spins and moves towards player occasionally, enrages during the daytime.
    12 Skeletron Hand AI Follows the Skeletron head, flails, waves, and attempts to damage player.
    13 Plant AI Extends on a vine towards player, looks at player. Dies if not rooted to a block.
    14 Bat AI Spasmodically flies towards player.
    15 King Slime AI Hops towards the player and releases Blue Slimes when damaged. (Desktop, Console and Mobile versions) Teleports to the player when the player is out of reach; releases Spiked Slimes when damaged in Expert Mode.
    16 Swimming AI Swims back and forth and moves towards the player if they are in water, except for Goldfish, Gold Goldfish and Pupfish.
    17 Vulture AI Stands still until player gets within five blocks of AI or it is damaged. AI then acts similarly to the Flying AI.
    18 Jellyfish AI Floats back and forth, swims towards player in small bursts if player is in water.
    19 Antlion AI Looks at player, climbs overlapping blocks, shoots falling sand at nearby players.
    20 Spike Ball AI Swings in a circle from a pivot point on a chain.
    21 Blazing Wheel AI Moves along walls, floors and closed doors.
    22 Hovering AI Similar to the Fighter AI, floats over the ground instead of jumping.
    23 Flying Weapon AI Does not adhere to gravity or tile collisions. Spins several times, then heads straight towards the player. Any damage cancels its attack and forces it to spin again.
    24 Bird AI Stands still until player gets nearby, then flies away. Avoids walls and obstacles and changes direction if one is in the way.
    25 Mimic AI Stands still until player approaches or attacks, then leaps towards them with varying heights.
    26 Unicorn AI Slowly gains speed while moving, jumps over obstacles.
    27 Wall of Flesh AI Wall of Flesh Mouth with Wall image attached. Traverses the world horizontally. Also spawns with two Wall of Flesh Eyes which share its health.
    28 Wall of Flesh Eye AI Bound to an entity, watches player, and shoots projectiles. The more damaged it is, the more it shoots.
    29 The Hungry AI Similar to the Plant AI, but attached to an entity.
    30 Retinazer AI Alternates between attempting to stay diagonally above player while shooting projectiles slowly, and attempting to stay beside player and shooting projectiles very rapidly.
    31 Spazmatism AI Alternates between shooting projectiles and staying beside player, and charging toward player.
    32 Skeletron Prime Head AI Same as Head AI.
    33 Prime Saw AI Occasionally charges at the player, heads directly towards player when enraged.
    34 Prime Vice AI Occasionally charges at the player, rapidly charges when enraged.
    35 Prime Cannon AI Fires bombs upwards, aims directly at player when enraged.
    36 Prime Laser AI Fires projectiles at player, shoots very rapidly when enraged.
    37 The Destroyer AI Similar to Worm AI except it will shoot projectiles from the body and tail and is unable to "fly" in air. It will also release Probes.
    38 Snowman AI Jumps and runs towards the player, similar to Fighter AI.
    39 Tortoise AI Crawls a bit, then leaps towards player. Will indefinitely leap towards the player in water.
    40 Spider AI Capable of climbing background walls as well as through platforms. Used only when crawling on a wall. Without a wall listed enemies seamlessly transform into their walking variants, which use Fighter AI.
    41 Herpling AI Jumps high and attempts to land on the player. It can strafe to the sides in midair.
    42 Lost Girl AI Turns into a Nymph when taking damage, when being caused to move, or when a player comes too close.
    43 Queen Bee AI Alternates between attempting to stay above player while firing projectiles downwards or spawning bees, and charging back and forth very rapidly.
    44 Flying Fish AI Flies straight towards player.
    45 Golem Body AI Jumps towards player every few seconds, shoots lasers.
    46 Golem Head AI Bound to an entity.
    47 Golem Fist AI Flies towards player, returns when hit.
    48 Free Golem Head AI Attempts to fly back and forth, shoots projectiles at player.
    49 Angry Nimbus AI Attempts to stay directly above the player, and fires projectiles downwards.
    50 Spore AI Drifts downwards while following player, destroyed on contact.
    51 Plantera AI Clings to nearby blocks, chases player, fires projectiles and spiky balls that bounce around.
    52 Plantera's Hook AI Moves forward briefly before latching onto a block.
    53 Plantera's Tentacle AI Acts very similar to the Plant AI, only bound to a certain entity.
    54 Brain of Cthulhu AI Does not adhere to gravity or tile collisions, and teleports occasionally in first form. Once all Creepers are killed, it will begin rapidly teleporting and moving towards the player.
    55 Creeper AI Circles around an entity, charging at player.
    56 Dungeon Spirit AI Moves directly towards player, gaining momentum. Emits blue-ish particles.
    57 Mourning Wood AI Moves towards player, stops, and fires projectiles straight at the player.
    58 Pumpking AI Very similar to the Head AI. Spawns with two Pumpking Scythes.
    59 Pumpking Scythe AI Very similar to the Skeletron Hand AI.
    60 Ice Queen AI Flies around, shooting a barrage of ice-based projectiles.
    61 Santa-NK1 AI Moves across the ground, stops moving, and launches many different types of projectiles.
    62 Elf Copter AI Attempts to fly around the player, shooting bullets rapidly if they are in sight.
    63 Flocko AI Flies towards the player at high speed.
    64 Firefly AI Flies slowly in any direction and occasionally glows.
    65 Butterfly AI Flies slowly in any direction.
    66 Passive Worm AI Moves along the ground, pause for a bit, then continue moving. Will avoid walls and moves in the other direction if it has hit one.
    67 Snail AI Acts similarly to the Passive Worm AI, but climbs up walls instead of moving away. It can move on ceilings, but might fall off while doing so.
    68 Duck AI Swims on water and walks on land. Will fly away when a player is nearby, but only while swimming. Lands after flying for a while.
    69 Duke Fishron AI Rams player multiple times before summoning entities. In second form, it flies in circles and summons entities.
    70 Detonating Bubble AI Flies through the air, chases player, and disappears after a period of time. Explodes and deals damage if it succeeds in reaching player.
    71 Sharkron AI Follows an arcing path, dies when it touches a wall or player.
    72 Bubble Shield AI (Desktop, Console and Mobile versions) Created by the Martian Officer, absorbs all damage dealt to the officer.
    73 Tesla Turret AI (Desktop, Console and Mobile versions) Built by Martian Engineers on the ground.
    74 Corite AI (Desktop, Console and Mobile versions) Travels through blocks, charges at the player.
    • Corite(Desktop, Console and Mobile versions)
    • Martian Drone(Desktop, Console and Mobile versions)
    75 Rider AI (Desktop, Console and Mobile versions) Has a Rider and a corresponding mount, if one is destroyed the other keeps attacking.
    76 Martian Saucer AI (Desktop, Console and Mobile versions) Flies around the player, fires a Death Ray straight down, can only be damaged if all four turrets have been destroyed.
    77 Moon Lord Core AI (Desktop, Console and Mobile versions) Positions behind the player, invulnerable until the Moon Lord's head and hands are defeated.
    78 Moon Lord Hand AI (Desktop, Console and Mobile versions) Flees to the left and right of the player, opens and closes, fires Phantasmal Spheres, Phantasmal Eyes, and Phantasmal Bolts. Spawns True Eye of Cthulhu when health is depleted.
    79 Moon Lord Head AI (Desktop, Console and Mobile versions) Flies above the player, shoots a Phantasmal Deathray and then some Phantasmal Bolts, spawns True Eye of Cthulhu when defeated.
    • Moon Lord(Desktop, Console and Mobile versions)
    80 Martian Probe AI (Desktop, Console and Mobile versions) Floats at a constant height, turns red and files away if the player gets near it, triggers the Martian Madness event if it gets off screen.
    81 True Eye of Cthulhu AI (Desktop, Console and Mobile versions) Flies around the Moon Lord, shoots Phantasmal Sphere, Phantasmal Deathray, Phantasmal Eye and Phantasmal Bolts at the player.
    82 Moon Leech Clot AI (Desktop, Console and Mobile versions) Travels from the player to the Moon Lord's head, heals part of the Moon Lord for 1000 HP if it reaches the mouth.
    83 Lunatic Devotee AI Never moves, causes the Lunatic Cultist to spawn when all are killed.
    84 Lunatic Cultist AI (Desktop, Console and Mobile versions) Teleports around the player, fires shadow fireballs, ice mist, fireballs and lighting orbs. Creates duplicates of itself and summons Phantasm Dragons and Ancient Visions, triggers Lunar events when defeated.
    85 Star Cell/Brain Suckler AI (Desktop, Console and Mobile versions) Flies around the player, slowly floats towards them. Usually sticks to the player.
    86 Ancient Vision AI (Desktop, Console and Mobile versions) Flies around the player, does not adhere to gravity or tile collisions.
    87 Biome Mimic AI (Desktop, Console and Mobile versions) Passive until approached by the player. Attacks by jumping, dashing rapidly, and jumping into the air and slamming down on the player, ignoring block collision. Periodically "shuts" and becomes immune to damage and reflects projectiles in Expert Mode.
    88 Mothron AI (Desktop, Console and Mobile versions) Flies through blocks, lunges at the player, occasionally lays a Mothron Egg.
    • Mothron(Desktop, Console and Mobile versions)
    89 Mothron Egg AI (Desktop, Console and Mobile versions) Does not move, spawns Baby Mothrons after a while.
    90 Baby Mothron AI (Desktop, Console and Mobile versions) Spawns from Mothron Eggs, flies, lunges at the player.
    91 Granite Elemental AI (Desktop, Console and Mobile versions) Floats towards the player. Drops to the ground when hurt in Expert mode.
    92 Target Dummy AI (Desktop, Console and Mobile versions) Stationary, recoils when damaged.
    93 Flying Dutchman AI (Desktop, Console and Mobile versions) Floats about the player, is defeated when all 4 cannons are destroyed.
    94 Celestial Pillar AI (Desktop, Console and Mobile versions) Bobs up and down in place, can only be damaged when 100 of its event enemies are defeated. Triggers Moon Lord to spawn when all 4 are defeated.
    95 Mini Star Cell AI (Desktop, Console and Mobile versions) Remains stationary, eventually grows into a full sized Star Cell.
    96 Flow Invader AI (Desktop, Console and Mobile versions) Floats around the player, summons 3 orbiting minions, fires projectiles at the player.
    97 Nebula Floater AI (Desktop, Console and Mobile versions) Floats around the player, summons 3 orbiting minions, charges at the player and fires laser while teleporting.
    98 Unknown If the player is far, rolls quickly towards it, else approaches slowly before shooting Solar Flares. n/a
    99 Solar Fragment AI (Desktop, Console and Mobile versions) Spawned from the top of the Solar Pillar. Shot upward on spawn and gradually falls down to the ground, destroyed on contact with blocks or the player.
    100 Ancient Light AI (Desktop, Console and Mobile versions) Fired in spreads of five by the Lunatic Cultist.
    101 Ancient Doom AI (Desktop, Console and Mobile versions) Spawned from Lunatic Cultist in Expert Mode, fires 4 projectiles in a "+" shape when defeated/summoned.
    102 Sand Elemental AI (Desktop, Console and Mobile versions) Floats around, moving towards the player, and occasionally spawns three 'sandnados'. Gets faster the more it is damaged.
    103 Sand Shark AI (Desktop, Console and Mobile versions) Hides under sand (and its variants), occasionally dashes at the player. If in water, it acts similar to Swimming AI, except it always targets the player regardless if they're in water or not.
    104 Unknown An NPC with this AI immediately despawns. Unimplemented NPC (547)
    105 Eternia Crystal AI (Desktop, Console and Mobile versions) Stays still, targeted by Old One's Army monsters, ends the Old One's Army event if health reaches 0.
    106 Mysterious Portal AI (Desktop, Console and Mobile versions) Spawns Etherian enemies.
    107 Attacker AI (Desktop, Console and Mobile versions) Moves towards the Eternia Crystal to attack it, and floats through blocks if it cannot reach the crystal.
    108 Flying Attacker AI (Desktop, Console and Mobile versions) Flies above the Eternia Crystal, pauses, and then dives for it. The cycle then repeats.
    109 Dark Mage AI (Desktop, Console and Mobile versions) Slowly moves towards the Eternia Crystal. Occasionally summons multiple Old One's Skeletons around it and heals enemies.
    • Dark Mage(Desktop, Console and Mobile versions)
    110 Betsy AI (Desktop, Console and Mobile versions) AI behaves similarly to the Duke Fishron AI. Shoots fireballs and rarely sweeps over the crystal with Flame Breath.
    • Betsy(Desktop, Console and Mobile versions)
    111 Etherian Lightning Bug AI (Desktop, Console and Mobile versions) AI behaves similarly to the Hovering AI. Shoots lightning below it repeatedly.
    112 Fairy AI (Desktop, Console and Mobile versions) Moves towards the player, floats around them if no treasure is nearby, moves towards nearby treasure if detected, then waits for the player to go near it, despawns when on top of treasure.
    113 Windy Balloon AI (Desktop, Console and Mobile versions) Spawns attached to an entity, floats up and down along with attached entity, rapidly flies up if attached entity dies, dies if it hits a block.
    114 Dragonfly AI (Desktop, Console and Mobile versions) Flies in bursts in random directions, flies away at fast speeds if a player approaches.
    115 Ladybug AI (Desktop, Console and Mobile versions) Alternates between flying slowly in any direction and walking back and forth on the ground.
    • Gold Ladybug(Desktop, Console and Mobile versions)
    • Ladybug(Desktop, Console and Mobile versions)
    • Stinkbug(Desktop, Console and Mobile versions)
    116 Water Strider AI (Desktop, Console and Mobile versions) Glides on water and hops on land.
    117 Dreadnautilus AI (Desktop, Console and Mobile versions) Cycles between firing blood projectiles at the player, charging and spinning around the player, and summoning Blood Squids.
    118 Seahorse AI (Desktop, Console and Mobile versions) Swims in bursts in random directions.
    119 Angry Dandelion AI (Desktop, Console and Mobile versions) Does not move, shoots projectiles at nearby players, but only in the wind’s direction.
    120 Empress of Light AI (Desktop, Console and Mobile versions) Hovers slightly above the player, cycles between several projectile attacks and charging the player. Disappears and reappears at half health, and starts cycling through attacks faster. Enrages during the daytime.
    121 Queen Slime AI (Desktop, Console and Mobile versions) Cycles between performing hops, leaping towards the player to pound them, and firing Regal Gel. Grows wings at half health, and begins flying towards the player's position, firing Regal Gel and attempting to pound the player when above them. Spawns Crystal Slimes, Heavenly Slimes, and Bouncy Slimes when damaged.
    122 Pirate's Curse AI (Desktop, Console and Mobile versions) Floats towards the player, passes through blocks.
    123 Deerclops AI (Desktop, Console and Mobile versions) Walks towards the player, jumping over gaps, summons ice spikes if the player is close to it, flings debris if otherwise, and roars occasionally. Will not despawn if the player dies until 1 in-game day passes. Periodically summons Shadow Hands in Expert Mode.
    • Deerclops(Desktop, Console and Mobile versions)
    124 DeerclopsLeg AI (Desktop, Console and Mobile versions) Was previously used by the unused DeerclopsLeg NPC. Would despawn instantly unless tied to an active Deerclops, where it would snap to the Deerclops' feet and bob up and down while moving. The AI code remains in the game despite the NPC having been removed. n/a
    124 Old Shaking Chest AI (Desktop, Console and Mobile versions) Dummy, unused. Its internal name is ElderSlimeChest but the Old Shaking Chest uses Slime AI. n/a
    125 Clumsy Balloon Slime AI (Desktop, Console and Mobile versions) Similar to Windy Balloon AI.
    n/a Lepus AI (3DS version) Jumps similarly to King Slime, generates entities while on the ground. n/a
    n/a Ocram AI (Old-gen console and 3DS versions) Flies around, spawns minions, shoots lasers, and charges at the player. n/a
    n/a Turkor the Ungrateful AI (3DS version) Body does not move; heads lunge at the player. Occasionally spawns more heads.

    History

    This section lists changes to the IDs of the AI types. For changes to the behavior of NPCs of a certain AI, see the History section of those NPCs' pages.
    • Desktop 1.4.4:
      • Added AI type 125.
      • Changed the internal name of AI type 124 from AI_124_DeerclopsLeg to AI_124_ElderSlimeChest. The old AI code is still present, but can no longer be assigned to an NPC.