OXP NPC Combat AI
NPC combat AI is activated when the
performAttack AI command is called. The behaviour of the AI then depends on the weapons available to it, and the accuracy parameter of the ship.
performAttack is called, the AI goes to
BEHAVIOUR_ATTACK_TARGET. This has the sole purpose of choosing a real attack routine. At this point, the AI will check the temperature of each of its weapons. Weapons below 25% heat will be considered "ready". If there are no weapons below 25% heat, any weapons below the safety cutout of 85% will be considered "ready". If all weapons are overheated, then the ship will run away. Lasers on subentities will be counted as forward lasers for this calculation.
Ships with plasma turrets will ignore the plasma turrets in their attack calculations if they have a forward laser, and just use them defensively. If they do not have a forward laser, they will act as if a plasma turret is their forward weapon, and therefore aggressively close to turret range.
If more than one laser mount is "ready", then ships close to their target will preferentially use the aft laser, or the side lasers if the aft laser is unavailable. Ships far from their target will preferentially use the forward laser, or the side lasers if the forward laser is unavailable.
Ships whose forward weapon is the omnidirectional Thargoid Laser ignore all of this, and use a special Thargoid attack routine designed to optimise the usefulness of their omnidirectional laser. (The
accuracy variable does affect their skill and fire rate with this attack)
The accuracy parameter has the following effects:
- Ships with a higher accuracy will aim for a point closer to the centre of their target
- Ships with a higher accuracy will open fire less often when their shot will miss their target
- Ships with a higher accuracy will open fire at long range more often (though above an accuracy of -3 this will barely be noticeable)
Bad AIs (-5 <= accuracy < 0)
Bad AIs, corresponding approximately to new Harmless pilots, suffer the following penalties:
- Ignore laser overheating on their front laser - they will just accept "pulse mode". They will pay attention to laser temperature on their other laser mounts, and will consider front laser temperature when selecting a new attack pattern.
- When fleeing, will flee in a highly predictable straight line
- Additional aim penalty applied when using the aft laser
- Additional severe aim penalty applied when using side lasers. If they hit anything with these it was entirely through luck.
- Will often attempt to overfly their target to get on its 'six', ignoring opportunities to just shoot their target.
- When using aft laser, or fleeing, will not consider the possibility that their flight vector intersects another object
These penalties are sufficiently severe that you should in general force mission ships to have an accuracy >= 0
Normal AIs (0 <= accuracy < +5)
Normal AIs, still corresponding to a Harmless pilot, but one with either some natural talent or a few kills worth of experience, do not have the above penalties. In addition:
- If their ship does not have a
missile_load_timespecified in shipdata.plist, a load time of 2 seconds will be used to prevent wasting missiles against ECM systems. Missiles will also not be fired within two seconds of detecting an ECM pulse.
- Aim penalties for non-forward lasers are mostly removed. A small aim penalty with side lasers remains.
- Some attempts to dodge while fleeing will be made.
Skilled AIs (+5 <= accuracy <= 10)
Skilled AIs range, depending on the
accuracy level and the equipment on their ship, from Mostly Harmless up to a decent Competent at accuracy 10. Skilled AIs must be explicitly specified in shipdata or by script. All skilled AIs get the following benefits:
- If their target is not targeting them back (i.e. it is distracted by someone else) they will slow down so that they can shoot for longer.
- If they are hit, they will make an immediate sharp turn as evasive action, and then reconsider their attack method.
- Larger attempts to dodge while fleeing will be made
Skilled AIs should in general be used sparingly. With accuracy 10, even three stock Sidewinders can be a significant challenge in a laser dogfight for an iron-ass Cobra III.
Additional benefits are received at the following thresholds.
Accuracy >= +6
- Even larger attempts to dodge while fleeing, including making many sharp unpredictable turns at close range to make it difficult for an enemy to stay on their 'six'.
- Will maintain high speed on a forward laser attack run even if taking heavy fire
Accuracy >= +6.5
- Enables close-range low-speed dogfighting tactics to effectively get on a target's 'six', or to stand and fight against a similarly manoeuvrable ship it can't flee. (In general, ships with an aft laser will just use that instead of dogfighting)
Accuracy >= +7.5
- A significant boost to aim accuracy, substantially reducing the number of shots which miss, especially with fore and aft lasers, and reduces oscillation about a target.
Accuracy >= +8.5
- Sniper attack mode. If the ship has a forward laser with a longer range than a pulse laser, and is currently within weapon range but outside pulse laser range, it will slow right down to make sniping attacks. In practice, due to the small difference between pulse laser range and beam laser range, this is only really effective with a military laser. On the other hand, it is extremely dangerous with a military laser.
Accuracy >= +9
- Evasive manoeuvres in combat will pre-emptively dodge out of sight, even if not yet under fire.
the problem is... the AI's chase, aim-and-fire, and dogfight subroutines. To clarify, this is about the movement and aim-and-fire programming, and the fact that AI groups observably just "sit around" in a dogfight unless engaged -- and they are easily dodged even in a straight line chase -- and this can not be solved by weapon strength or ship armor/energy or speed) Next game, approach and watch a dogfight from a distance. Being in the dogfight, chasing and being chased (by one at a time) and dodging fire is one thing -- but observe the same scene from a distance and you'll see what I mean. The evasive maneuvers of a ship that knows you're chasing it are fine. The sitting duck model of everyone else in the "dogfight" (in name only) is not fine. (NPC flight routines upgrades? (2022)