A Brief Exposé on SMBO Enemy AI:Simply put, Super Mario Bros. Online’s enemies are all basically the same, and conform to a strict set of rules as to when and how they move.
We’ll start with the basics, the most pressing matter being when enemies are allowed to chase you without you first striking them. This is rather simple, if your level is four levels or more above the enemy’s level, it will not attack you. All enemies that have no set level (all bosses and midbosses, DE Koopas, MK-PVP Goombas, and select Shy Guys, Pipe-Dwelling Lakitus, and Blue Paratroopas) will always auto-attack, regardless of your level or stats. On the flip side, a select few enemies will never attack first, these including Goombas, level 2 Koopa Troopas, Drillbit Crabs, most Pipe-Dwelling Lakitus, and the like.
No enemy will start to chase you, regardless of level, unless you pass within its range of sight. Each enemy has a set value for this stat, and there is no way to determine it within the game. Note, however, that this value is the absolute distance between your tile and the enemy’s, calculated by the formula √(H
2 + V
2), where H and V are the horizontal and vertical distance between you and the enemy, respectively. So for a range of 5 (a fairly typical value for later enemies), an enemy that can attack first will start chasing you once you touch any of the tiles with red borders below (you can determine which these are by imagining a circle with radius 5 tiles, and seeing which tiles' central points are inside or on the border of the circle).
Note that special attack range is calculated in the same manner (I think, I’ll test that when I get a chance).
Now then, for the finer points of enemy patterns. Much like
the red ghost in Pac-man, if an enemy has begun to chase you, it will always try to get as close to you as possible with each step it takes. Therefore, it will always move in the direction in which it is farthest from you. For example, if you are situated three tiles to the left and four down from an enemy, your total distance is √(3
2 + 4
2) = 5. Moving to the right or up would obviously increase the enemy’s distance from you, so it will not consider those options in most cases. Moving to the left would make the distance become √(2
2 + 4
2) = √20, and moving down would make it √(3
2 + 3
2) = √18. Therefore, it would be slightly preferable for the enemy to move down, as √18 is slightly shorter a distance than √20. Note that if two options are equally viable (e.g. up or left if you are three tiles up and to the left of the enemy), it will randomly choose between them, and if one of two favorable options is blocked, it will choose the other (e.g. it would go to the left in the first scenario). Now, if there is no way for the enemy to get any closer to you (e.g. there is some object obstructing a direct path between you and the enemy), rather than staying in one place forever, it may occasionally move in a random direction. In most cases, though, its best option after that is to return to the spot it was in, so this rarely makes a large difference.
Here are some sample situations, with the enemy paths marked clearly.
In this situation, the enemy can choose either down or right at each spot marked in yellow (including its original location), then it has only one option from each other spot.
In this fairly common (and rather annoying) situation, the enemy will continue to move down until it is one tile above and to the left of the player, where it will randomly choose to move right or down. If you are traveling somewhere with a much higher-leveled player and an enemy is attracted to you, try to create this type of situation, and have the higher-leveled player stand at or before the enemy’s two-choice intersection, so he can dispatch of the enemy most easily.
In this situation, it would still be of interest to the enemy to move to the right after its second move, but the wall prevents it from doing so, so it goes up a tile instead. A similar choice is made at the next stop, and it continues straight afterward.
This type of tactic is your best bet when fighting boss battles that include normal-enemy minions. In this setup, there is no way for the enemy to escape, for if it moves up or down, its best move from there is to move back to where it was. As far as I’m aware, the player is completely safe in this situation (leaving him free to pummel the enemy with special attacks or ranged weapons if he so desires). However, were there only one blocking tile rather than three, if the enemy were to randomly move up or down, it would start moving to the right after that, so make sure that you trap enemies behind sufficiently wide platforms to cover your needs.
So that’s about all there is to know about enemy AI; I’ll try to add at least the bosses’ sight range values to the SMBO guide at some point in the near future.
Please leave your questions and comments here!