Hi everyone

Im looking for any advice, pseudo code, theory, macro-micro ideas when it comes to building an AI. I've made AI before in my game Swordlord, but the AI I am working on now is much more complex. In swordlord, the AI really was in only 2 states, randomly moving around and attacking. But in my new game, the AI will be doing this, as well as pathfinding/attacking/making decisions/animating etc.

Im building an AI that can pathfind around the level using A*, and when it gets into it's attack range, it will attack its target. This sounds easy, but it really isnt, especially because I have so many things going on in an AI. If the AI sees an enemy/player, it can pathfind to the player. But what if the player is not there at the end of the path? So the AI will do something else, a search or whatever. What if the AI sees a player thats not close to any nodes? Then the AI must go of into a manual movement outside of the pathfinding. I can already see the branching of the AI being very big in scope.

When you make your AI, do you do everything in one loop/while? Currently I have a separate pathing bot that just handles pathfinding. Do I integrate decision making into this bot? Or do I attach a secondary entity to this bot that handles decision making, and let the pathfind bot just handle movement?

Where should I fit in animation, animation blending and attacking? Should I have pathfinding/animation/decisions/state machines in one entity?

I like the idea of having two entities, one handling pathfinding, while the other handles animation and AI. But this also means they have to constantly communicate with each other. Ive done this on a smaller scale, but I can see if I want to expand the AI, I will be doing alot of hacks. On the other hand, doing everything in one loop/or working in state machines is easy, but that may require alot of duplicate code, ie state_1=pathfinding while attacking, state_2=pathfinding to retreat etc etc.