I started working on what I call turret roles – basically a turret’s automatic behavior. Prior to these changes turrets took their parent’s (either ship or station) target, if the parent didn’t have a target, turrets took as their target the parent’s attacker if any. This was way too dumb though, the goal is for AI in this project to be somewhat self sufficient, allowing the player to focus on combat or other tasks – there are so many that a good amount of automation is needed. Besides in the game’s universe these are space ships, crewed by sentient beings and sophisticated AI – they should make somewhat logical choices
Here’s a brief overview of the roles:
Point Defense role – get nearest missile or torpedo that is targeting the parent – otherwise use the defense role for target selection.
Defense role – get nearest ship that is targeting the parent – otherwise use the Parent’s Target role for target selection.
Parent’s Target role – same target as the parent – otherwise (if parent doesn’t have a target) nearest target regardless if it is targeting the ship or not.
Offense role – using the turret’s priority targeting list find the nearest target.
I hope what I accomplished in these roles is a fairly simple system, yet one that gives a good degree of control over the turret. Some of these roles fall back on other roles that are somewhat related – if no missiles, then look for an attacker, if no attacker, then look if parent has a target. Also the Offense role mentions a target priority list, prior to these changes only ships had a priority list of targets, now turrets have this as well. Basically some turrets may work best against some types of targets, for example a slow moving heavy turret shouldn’t try to hit fast moving fighters, instead it should try to target a frigate or bigger ship first.
These roles will be specified in the turret’s xml file, so ships can be fine tuned to their roles on the turret level. For example a corvette may have a light turret for missile defense – giving it more of an edge versus ships with missiles. Or a frigate has a heavy turret for offense making it an assault frigate. These roles can be changed in game by the player – per individual turret. If about to assault a station with torpedoes, setting a turret or two to point defense might be a wise choice.
Having turret roles also allows for the expansion of ship roles – for example a ship that ‘s set to defensive could have its turrets set to point defense, a ship that’s set to aggressive could have its turrets sent to offense.