How does confusion affect enemy AI?

So, there are a few weapons in Terraria that give the enemies confusion. if the player gets confusion, then their controls are inverted. I'm wondering how the confusion works for the enemy's AI since they don't have button controls.


As per the Terraria wiki, the Confused status effect causes mobs to move away from the player instead of towards them, and mobs with ranged attacks will be unable to shoot those attacks. Note that a vast majority (about 70%) of mobs are immune to the Confused debuff - it's mostly mobs that have either the slime or fighter AI that are affected.