Freelancer-Sirius-Revival / FLSR

The main mod files of Freelancer: Sirius Revival for the game "Freelancer".
https://fl-sr.eu
4 stars 2 forks source link

Battleship turrets choose the closest enemy instead of enemy capital ships as their target #823

Open Caenen opened 1 month ago

Caenen commented 1 month ago

In the event yesterday, the NPC battleships got into a situation where they wildly shot their main guns at player fighters rather than the enemy cruiser or battleship. That makes the AI quite cheesable since a single fighter can distract the capital ships by being their closest target while another player on a battleship or cruiser has free reign to mop them up.

After some digging, I found that all battleships spawns are set to use the li_cruiser_default pilot, which, through several levels of inheritance, is practically identical to a gunboat job.

attack_preference = GUNBOAT, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = FIGHTER, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = TRANSPORT, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = WEAPONS_PLATFORM, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = FREIGHTER, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = CRUISER, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = CAPITAL, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = SOLAR, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = ANYTHING, 5000, GUNS | GUIDED | UNGUIDED

This makes the ships focus on less valuable and more agile targets than they probably should be going for with their main guns. The remaining defense auto-turrets will shoot at closeby fighters either way if the primary target isn't in their range. In regards to players, what matters in this case is Freighters being lower prio than Fighters.

Suggested attack preference for battleships specifically should probably include Cruisers>Battleships>Gunboats>Freighters>Fighters, or Battleships>Cruisers.

I have not yet tested or taken a deep dive into the other unique NPC ship types and how their AI may produce more odd and exploitable situations like this. Nomad capital ships are not quite as cheesable in this regard because their BEAM weaponry is very threatening to fighters if they are very close as well, but I suspect they would benefit from such an adjustment as well.

erikroe commented 1 month ago

If you are talking about SOLAR battleships (and not freely moving): Solars cannot be given explicit attack preferences.

If you are about moving NPCs: You did read the files wrong. First: In the LI Fleet encounter the Liberty Battleships both use job_battleship and thus their attack order is:

attack_preference = CAPITAL, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = CRUISER, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = GUNBOAT, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = FREIGHTER, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = WEAPONS_PLATFORM, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = SOLAR, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = FIGHTER, 2000, GUNS | GUIDED| UNGUIDED
attack_preference = TRANSPORT, 2000, GUNS | GUIDED | UNGUIDED
attack_preference = ANYTHING, 2000, GUNS | GUIDED | UNGUIDED

Second, li_cruiser explicitely has set

attack_preference = CAPITAL, 5000, UNGUIDED
attack_preference = SOLAR, 5000, UNGUIDED
attack_preference = WEAPONS_PLATFORM, UNGUIDED
attack_preference = CRUISER, 5000, UNGUIDED
attack_preference = GUNBOAT, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = FREIGHTER, 5000, GUNS | GUIDED | UNGUIDED
attack_preference = FIGHTER, 2000, GUNS | GUIDED| UNGUIDED
attack_preference = TRANSPORT, 2000, GUNS | GUIDED | UNGUIDED
attack_preference = ANYTHING, 2000, GUNS | GUIDED | UNGUIDED
Caenen commented 1 month ago

Then I'll do some more testing to see if I can reproduce the result witnessed yesterday. The fleet-spawned battleship completely ignored the player Li Battleship in front if it, if fighters were closer to it. I'll create a recording.

erikroe commented 1 month ago

It can be that NPC guns, once they selected an enemy, follow it until it is destroyed or out of range again.

Caenen commented 1 month ago

It seems that NPC guns (or at least auto-turrets) dynamically select whatever is closest within their respective gun "vision cone": As long as the target is within their gun range and angle it will turn the gun/turret toward them and try to fire, but this is measured edge-to-edge, so for large ships the turrets not mounted at the outermost point towards you start shooting a little ahead of time. It doesnt matter which target comes in first, nor does reputation seem to play a role or anything.

Attack preference seems to primarily affect the movement of the ship (what target it is chasing) and possibly also who their missiles are targeting (if it's any more analogue to player targeting, which seems to check out in my test). Obviously for battleships this is the least obvious, and leaves them open to be cheesed by drawing their fire as a closer, nimble target from all guns that can 'see' you at the respective angle. Fighters will always just try to chase you down, firing at other nearby targets if they come into their weapon cone but for them that is perfectly fine.

Cannot be fixed with attack preferences, i dont suspect we have another lever to change this either. I suppose this little trick will just be a viable cheese against NPC capships then, just like travelling backwards in engine kill.

You may close this issue unless you have another idea how to solve this unwanted behaviour.

erikroe commented 1 month ago

for large ships the turrets not mounted at the outermost point towards you start shooting a little ahead of time

This is because NPCs calculate your speed and may shoot ahead if your current relative speed makes you already a possible target when their projected target-circle would hit. Also they have a small tolerance of 110% distance usually to start shooting at you (see pilots population).

Attack preference seems to primarily affect the movement of the ship

No, I did test those especially with Nomad Battleships for the current job_battleship and they do also count for the guns especially when to begin attacking you. If I was a Fighter, they ignored me entirely until coming close enough.

I cannot think of any way to make specific guns target specific ships only. Afaik Freelancer simply is not build for this at all. All you can do is to separate guns by their type (gun, missile, torpedo) to target specific ships. That's it.