I may be misunderstanding what the current code does here, but I'm sure it could be improved.
As best I can tell, weapon range for projectile weapons is set based primarily on their muzzle velocity and accuracy, producing a formula that takes target area as a parameter and makes some plausible assumptions about target acceleration, etc. The number that comes out of this in my experience is almost always far less than the range you would actually want to open fire at. Ignore-range fire partially works around this, but is a pretty crude fix, especially as used by the AI (which tends to waste all its rounds and/or lag you to death trying to match laser fire from 1Mm).
I suggest any or all of the following as fixes (and there may be better ones, these are just my ideas):
- Module design should include two range 'multipliers'. "Consider actual weapon range to be 3x calculated range for any given target, and activate AI ignore-range fire only if within 20x calculated range". Possibly also an acceptable hit % modifier ('I require 20% chance of hitting, or 1%....') Possibly also control over whether radiators should be factored into target size?
- Dynamic calculation of base firing range. This should take into account (and I don't think it does, currently) the relative velocity of the two ships and maybe the acceleration of the target. My gun drones have a calculated range against a capitol ship of maybe 20Km, and that doesn't seem to change except based on cross-section. That might be appropriate if it's a gunship running broadside at 600mG acceleration, but if they're shooting at a laser star with 10mG maximum acceleration facing me nose-on, and they're directly closing at 5 Km/s, the effective range is more like 500Km. This doesn't matter much for railguns, but for chemguns closing speed can often be several times muzzle velocity.
Please oh please yes. Especially the last thing. Conventional guns always wait much too long to start shooting when the relative velocity is much greater than the muzzle velocity. Range should never be an absolute distance, but always a time-to-target. That controls how much dispersion the bullets have when they arrive, and also how much time the target has to dodge. The game is obviously already calculating time-to-target, because it aims the guns before the target is in range.
I agree that the module designer should have two parameters, but I disagree as to what these parameters would be.
I want a "minimum hit percentage", which would define the time-to-target as a function of weapon dispersion velocity (spread) and target cross sectional area. That is, "if the target doesn't try to dodge, what fraction of bullets will hit?"
I also want a "target acceleration", which would define time-to-target as a function of target cross sectional area alone. This one says, "if the target dodges with this acceleration, will the bullets arrive before it can get out of the way, assuming it is circular so the cross sectional area defines its diameter?"
The lesser of the time-to-targets as calculated from each of these parameters would be the TTT used to decide when to start shooting. That's essentially what the current range calculation does, except it assumes relative velocity is zero, and it doesn't let you change the parameters.
For guns that fire payloads, there should be a third option to override with a fixed time-to-target independent of cross-section or spread. That allows you to set missile-projectors to start shooting as soon as the missile burn time will guarantee a hit.