This question is less about AI and more about the code structure for approaching AI. I understand FSMs and use it heavily for structuring my AI code in my top down ARPG. But I also want unique behaviours for each enemy. Coding those individual states is not the problem. You have to code individual FSM classes for each enemy type. That means a considerable amount of duplicate code.
Ex: Enemy A and enemy B will both initially chase the player. But enemy A will transition to a charging attack when the player gets too close but enemy B should do a ranged attack. This means I need two chase states that do the same thing but the need to transition to different states. Surely there is a better way.
I've tried modularizing it by making attacks a separate thing/class and making each enemy have a list of attacks it chooses from. But then there is another problem. If I want an enemy to transition to X state after performing Y attack, it isn't possible easily.
I feel like I'm missing something here. Where should the line for the generic AI FSM code be drawn and what parts should made nodular for each enemy AI? Should I even bother to do so? I am sorely tempted to just duplicate the code and leave it be.
Also, all of these is based on my experience with Unity. I'm not sure how other engines handle AI code structure. Maybe you can help me out with your perspective.