Aggro
Aggro, short for aggression or aggravation, is an invisible statistic that determines which player enemies will prioritize as a target. Outside of multiplayer, aggro has little effect.
All enemies target the player based on criteria set in their AI. While some kinds of enemies may only target the player if they are in water, for example, most will constantly try to find the closest target. Armor and other items that "increase/decrease enemy targeting" cause enemies to consider a player to be closer or farther away than they actually are. Enemies generally do not have a maximum range, and will always target the player if no other targets are available, regardless of distance or aggro.
If the Eternia Crystal(Desktop, Console and Mobile versions) is present, the Old One's Army will target it, but can also target the player depending on their distance and aggro.
Impact
Aggro primarily influences which player is targeted by most kinds of enemies in multiplayer.[1] A secondary effect of aggro is whether or not most kinds of enemies chase the player they are targeting (in both multiplayer and singleplayer).
Target selection
Most enemies prioritize to attack the player they are closest to. They calculate the distance between themselves and every living player in the world and pick the one with the smallest distance as their target. In this calculation, each player's aggro statistic is subtracted from the distance:
[math]\displaystyle{ \text{distance} = \text{distance}_\text{real} - \text{aggro} + g }[/math]
In this formula, [math]\displaystyle{ \text{distance}_\text{real} }[/math] is the actual taxicab distance between the center of the enemy's hitbox and the center of the player's hitbox, measured in pixels. The constant [math]\displaystyle{ g }[/math] is normally 0 and has no effect; it is 1000 if the player in question has the Royal Gel equipped and the enemy is one of the slimes affected by it.
If there is only one living player in the world (e.g. in singleplayer or if all other players in multiplayer are dead), then these distance calculations are irrelevant. All enemies will target the only present player in this case.
Example
Consider a Skeleton with a player on either side of it, all lined up so that their vertical distances are zero, as shown in the image to the right. Assuming that both players have an aggro value of 0 (the standard case), the Skeleton will target the left player, as the taxicab distance between them of 128 pixels (or 8 tiles) is smaller than the taxicab distance to the other player (160 pixels, or 10 tiles). When the player on the right increases their aggro value to 100, the distance formula looks as follows:
[math]\displaystyle{ \text{distance} = 160 - 100 + 0 }[/math]
The Skeleton now considers this player to be only [math]\displaystyle{ 160 - 100 = 60 }[/math] pixels away. Since this is less than the 128 pixels to the player on the left, the Skeleton will target the player on the right instead.
Old One's Army
Enemies in the Old One's Army(Desktop, Console and Mobile versions) use a slightly different method.[2] When calculating the distances to the living players in the world, these enemies[a] disregard any player that is more than 200 pixels (12.5 tiles) away from them. Aggro is not accounted for yet in that calculation:
[math]\displaystyle{ \text{distance} = \text{distance}_\text{real} }[/math]
Then, the remaining players in the 200-pixel radius ([math]\displaystyle{ \text{distance} \le 200 }[/math]) are considered as targets, using the usual formula that does include aggro:
[math]\displaystyle{ \text{distance} = \text{distance}_\text{real} - \text{aggro} }[/math]
In both formulas, [math]\displaystyle{ \text{distance}_\text{real} }[/math] is the actual Euclidean distance (not taxicab like before!) between the center of the enemy's hitbox and the center of the player's hitbox, measured in pixels.
Finally, an Old One's Army enemy calculates the Euclidean distance between the center of its hitbox and the center of the Eternia Crystal's hitbox. Whichever is closest (Eternia Crystal or closest player, with distance adjusted for aggro) will be targeted, barring the chance that the enemy is currently "ghosted".
Target chasing
Most Fighter AI enemies and those with similar behavior usually endeavor to face the player they are targeting as they move forward (left or right) to chase them. This behavior is suspended if the targeted player has negative aggro and is not using any items. For instance, Skeletons will walk by the player and continue in their current direction, when they would normally switch direction to keep facing the player.
Notably, the player's aggro statistic only needs to be negative for this mechanic to become active. The specific value does not matter as long as it is below 0, unlike in the target selection process above.
Nonetheless, the impact of this mechanic is rather small due to the many constraints:
- Only the regular movement of chasing the player is affected. Other attacks outside of that (like the Giant Tortoise's leap or generally any projectile being fired) will still be carried out as normal.
- Even some parts of enemies' normal movement remain unaffected – Fighter AI enemies will still jump if the player jumps next to them, for example.
- Enemies with no concept of "facing left or right" are unaffected by this, as are all bosses.
- Examples include enemies that can rotate 360 degrees to chase the player (e.g. Spider AI enemies on walls or Jellyfish AI enemies in water), stationary enemies (e.g. Caster AI enemies or the Tesla Turret), or burrowing Worm AI enemies.
- While the targeted player is using an item, i.e. for the duration of the item animation, the normal behavior is restored and enemies chase the player again.
In addition, this behavior is always active for slimes affected by the Royal Gel if they are targeting a player who has it equipped, regardless of aggro or item usage.
Gear
The following items reduce or increase the player's aggro statistic. Lower values mean that the player is considered to be further away from enemies than they actually are, while higher values mean that the player is considered to be closer to enemies than they actually are.
Item | Aggro change |
---|---|
![]() |
+250 |
![]() |
+250 |
![]() |
+250 |
![]() |
+250 |
![]() |
+400 |
![]() |
+250 |
![]() |
+300 |
![]() |
+300 |
![]() |
+300 |
![]() |
−400 |
![]() |
+400 |
![]() |
−400 |
![]() |
+400 |
![]() |
+400 |
![]() |
−400 |
![]() |
−400 |
All of the items above stack with each other.
The Invisibility buff from the Invisibility Potion does not. Any aggro above −750 (or −250) at this point is removed by the buff and the player's aggro stat is set to −750 (or −250). If the player's aggro is already lower than −750 (or −250) at this point, then the Invisibility buff does not change it.[3] (See below for examples.)
Item | Aggro |
---|---|
![]() |
−750 (while not using an item) |
−250 (while using an item) |
Lastly, aggro reduction from the stealth modes of the following three items is applied.[b] Only one out of these three stealth modes can be active at a time; the Psycho Knife's takes precedence.
Item | Aggro change |
---|---|
![]() |
−750 (in stealth mode) |
![]() |
−750 (in stealth mode) |
![]() |
−1200 (in stealth mode) |
Examples
- Combining the Putrid Scent (−400 aggro) with the Invisibility Potion (−750 aggro while not using an item) does not grant −1,150 aggro, because the Invisibility Potion resets any aggro above −750. This combination only grants the −750 aggro from the potion.
- Adding a full set of Shroomite armor (−750 aggro in stealth mode) does stack to −1500, though, because the Shroomite armor is evaluated last.
- The combination of Arcane Flower (−400 aggro), Recon Scope (−400 aggro), and Stalker's Quiver (−400 aggro) causes the Invisibility Potion to have no effect on aggro, as these three accessories grant a combined −1,200 aggro, which is lower than the threshold of the Invisibility Potion. The combined aggro reduction stays in effect, but the Invisibility Potion does not contribute its −750 (or −250) aggro.
- An aggro increase of +900 from a full set of Solar Flare armor is completely nullified by the Invisibility Potion, which resets aggro to −750.
Notes
- Positive aggro values (compared to the standard aggro value of 0) have no effect whatsoever in singleplayer.
- Vortex armor provides the single largest aggro reduction available in the game.
- The lowest attainable aggro is −2800, resulting from a combination of the Putrid Scent, the Arcane Flower, the Recon Scope, the Stalker's Quiver, and the Vortex armor in stealth mode.
- The Invisibility Potion would not contribute any more aggro reduction due to its unique, non-stacking nature.
- The highest attainable aggro is 2200, resulting from a combination of Solar Flare Helmet and Leggings, Beetle Shell, Flesh Knuckles, Berserker's Glove, and the Hero Shield.
- An enemy that becomes inflicted with the Confused debuff will face the opposite of its current direction. Usually this means that it faces away from its target, but if it is currently not chasing its target (as described above), then the Confused debuff might actually make it face towards its target again.
History
- Desktop 1.4.0.1: The Stardust Guardian now targets the closest enemy; it no longer diverts aggro, and its actions can no longer be influenced by the player.
- Desktop 1.3.4: NPCs can now be targeted.
- Desktop 1.3.0.1:
- Slimes no longer target the player if the player has Royal Gel equipped.
- Introduced the Stardust Guardian, which can divert aggro away from the player.
- Desktop-Release: Introduced.
- Console 1.0.933.1: Made changes from Console 1.0.750.0. (
)
- Console 1.0.750.0: (
)
- Slimes no longer target the player if the player has Royal Gel equipped.
- Introduced the Stardust Guardian, which can divert aggro away from the player.
- Console-Release: Introduced.
- Switch 1.0.711.6: Introduced.
- Mobile-Release: Introduced.
- 3DS-Release: Introduced.
References
- ↑ Information taken from the
Desktop 1.4.4.9 source code, methods
TargetClosest()
inTerraria.NPC.cs
,TryTrackingTarget()
inTerraria.NPC.cs
, andSetTargetTrackingValues()
inTerraria.NPC.cs
. - ↑ Information taken from the
Desktop 1.4.4.9 source code, method
TargetClosestOldOnesInvasion()
inTerraria.Utilities.NPCUtils.cs
. - ↑ Information taken from the
Desktop 1.4.4.9 source code, method
Update()
inTerraria.Player.cs
.
- ↑ Except for Betsy. She always considers all players in the world for targeting, regardless of their distance from her.
Information taken from theDesktop 1.4.4.9 source code, method
TargetClosestBetsy()
inTerraria.Utilities.NPCUtils.cs
. - ↑ Stealth mode additionally prevents enemies with Fighter AI and Flying AI from firing projectiles at the player. This mechanic is unrelated to aggro.