So I am working on adding entities in a game I am working on, I am wondering what the best way to structure enemy AI would be.
I have an entity Object with all of the usual functions built, and currently I am controlling what the entity does with two functions
entity.prototype.runMeleeAI = function(){
//makes the enemy make melee attacks
}
entity.prototype.runRangedAI = function(){
//makes the enemy make ranged attacks
}
I switch between which one of the functions runs with a property from whatever type of entity it is, so for example
const entityTypes = {
"slime":{
"AiType": "ranged"
}}
However, I am wondering how I should manage it if I want an entity to have an AI that is different from those two types, should I just create a new function, eg
entity.prototype.runDashAi = function(){
//do stuff
}
entity.prototype.runBossAI = function(){
//do stuff
}
Then if I wanted a special AI for an entity I could set it to be one of those
Or is there a better way to structure this? I want to have lots of different AI types that will only be used for one type of entity
Should I write the AI functions in separate files and then pass them on the entity object? or is there an entire way to do this i am not thinking of