For my personal project, I have been trying to develop a Generic AI Controller that could handle NPC tasks
I started by developing a Melee only AI, to which I then added Ranged and other NPC capabilities.
Problems needed to be solved:
AI needed to evaluate its environment and keep "ideal attack range".
This was solved by utilizing the EQS system within Unreal Engine to develop a set of queries that would score the environment based on ideal distance from target. AI character can be setup to have both melee and ranged capabilities, or to have completely custom attacks and attack range.
For example:
a Mage will attempt to keep distance of around 6 meters from you and cast spells, if you get within melee range, they may cast a spell or they may melee attack you based on their personality.
a Warrior can have range capabilities, but by default will try to fight you within melee range, each AI character has customization Attack Range, Aggro Range, and Melee Range as well ability set, meaning that each individual warrior could be setup with different attacks, abilities. or it could be randomized to vary enemy encounters perhaps based on game difficulty)
(Behavioural Tree)
To do:
-AI Swapping weapons (allowing AI to search its own equipment to pick a weapon better suiter for the combat situation, such as bow if enemy is in range and such)
-Fleeing and Looking for Help (while there is a retreat capability, it is only triggered during specific game events, ideally the AI will size up the target and decide whether to call for help, attack, or flee)
-Using World for tactical positioning during combat (the AI currently just tries to keep at ideal attack distance within line of sight of target, rather than finding best tactical position. The EQS query currently used could be adjusted to score the environmental sections based on distance to cover)