Hi,
I'm also currently coding a SAM system, with great difficulties too.
High speed missiles have hard time hitting targets, unless you give them even higher speed so that they can point at target, shoot and be directly on target, in which case they have a chance to hit.
In the range you are talking about (Mach 2-3), missiles misse very often.
At lower speed, everything is fine, provided you give them correct parameters :
AFAIK, maxSpeed has no effect on the missile behaviour, it is just a reminder in the config.cpp.
Flight profile will be determined by :
thrust
thrustTime
initSpeed (I'm having issues with initSpeed on missiles)
sideAirFriction
The BIS commented config give a formula to calculate the correct thrust value when you know the maxSpeed and thrustTime :
thrust=maxSpeed*0.7*thrustTime
I couldn't get any correct result with this formula, which seems very strange to me, bc thrust is proportionnal to thrustTime, the more time, the more thrust you give, the more the missile accelerate, and result are wrong.
I got better results with this formula :
thrust=maxSpeed*1.125/thrustTime
You'll have to take initSpeed in consideration for a correct use, which would theorically give :
thrust=(maxSpeed - initSpeed)*1.125/thrustTime
I couldn't have initSpeed set correctly for missiles, so I could not confirm that.
With that, the missile accelerate up to maxSpeed, then engine stop, and it decelerate at a rate depending on sideAirFriction (sideAirFriction of around 0.01 seems correct for me).
The second issue is the flight path calculation, which makes the missile miss often.
The 2 parameters I found had big impact on it are
maneuvrability
simulationStep
Missiles at around Mach 1/Mach 2 require maneuvrability to be raised up to 30-50, so that they can turn sharply enough to catch the target in case the target changes its trajectory at the end of the missile flight path. But, from what I've understood, simulationStep describe the time between 2 path calculation by the game, so if you give the missile big maneuvrability while keeping normal simulationStep, there is not enough calculation, and it "overcalculate" lead angle. The missile then makes big turn (a bit like "turn left!"..."oops, too much left, turn right!"..."oops, too much right, turn left!") and completely miss the target. So you need to lower simulationStep so that calculation are made often enough. For a maneuvrability of 25, I found a simulationStep of 0.001 to be correct, the missile will begin with big turns, but then will go straight at target. This creates a minimal range, at which you can't hit target anymore. Real missiles have minimal range of engagement too, so that's not a big deal.
But, and you have encountered the problem, when raising the speed, raising maneuvrability and lowering simulationStep doesn't work anymore, if you raise maneuvrability enough for the missile to catch target, the missile goes completely wrong when fired.
So you need to keep maneuvrability to around 40, and the missile will always near miss.
So you need some proximity fuze.
AFAIK, there is no way of retrieving the target of a locked ammunition. I tried to use "nearestObject" all along the missile flight path to catch air units along the trajectory, but "nearestObject" requires exact class name, no meta-class (like "Air" or "Helicopter") works. Perhaps the class "All" works.
I don't see any correct way to do it IN AN ADDON. It is very feasible in a mission, but addons has no knowing of installed units in missions.
Perhaps the missile has a "knowsAbout" list (that would be weird :wow: ), or... well, I don't know.
DKM team is currently working on a proximity fuze to update their 2S6, and I bet they have found the solution
BTW, how do you detonate a flying missile?
Whis'