This crops up a lot, so I’ve been looking at it today.
Essentially the problem (correct me if I’m wrong) is that ships only re-choose which enemy ship to head towards if the enemy ship is destroyed or otherwise leaves the battle. This allows for a few sneaky ‘lure’ and ‘decoy’ tactics as well as being quite unrealistic.
Looking at the AI code, a few things crop up:
- Indeed, this is a bug of sorts. To cut a long story short, the ai checks where to go every 2 seconds (actually slower, but call it 2 seconds) , but if the current target is still valid, it shortcuts out of that
- Fixing that is trivial, encouraging a genuine reassessment of targets every 2 seconds instead works just fine but…
- it turns out when you do that, it becomes clear a LOT of the time the targets being chosen are really bad. lots of cruisers keep trying to catch fighters…
The code that works out which ship to move towards is possibly in need of changes. Right now, it evaluates all ships that it is allowed to engage (ie: there is an ‘attack’ order, regardless of priority, for that class of ship), and weights all of them based on their priority and their range. (if none are found, it will go after ships its not supposed to).
Enemy fighter 1 is at range 30 and target priority for fighters is 10%. What the code does is take 1-10% = 90% and adds 0.9 * 30 to the range, and ‘scores’ that target at 30+27 = 57
Enemy cruiser 2 is at range 500 and target priority for cruisers is 100%. so the code gives us 1-1 = 0% and ‘scores’ that target at 500.
The ship thus chases around after the fighter right under it’s feet, rather than taking the sensible route of moving to engage the high priority (100%!) cruiser.
Clearly this sucks
So here is what I propose trying (I’ll probably set up a beta testing group of people for it).
The AI looks at the highest priority ship class according to it’s orders, if one is higher than the others. For example cruisers…
It then tries to find a cruiser, anywhere on the map, and picks the nearest one to engage.
If it fails to find one, it then moves to the second priority…
and then the third priority
If all priorities are the same, the largest (cruiser,then frigate,then fighter) gets checked first.
This is only for MOVEMENT, so the gunners on the ship will still let rip at nearby fighters on frigates en-route to their new target, which also, thanks to finding the above bug, will be re-evaluated more often (maybe not every 2 seconds though, perhaps a separate counter, at 10 seconds).