Cmdr James wrote:Guys, I have made a small modification to the code used for the missile interception logic. It is now, normally much more likely to strike a target, as it will predict the target location based upon its current velocity. I guess it might be better to add some damping due to the imperfect ability to read a target velocity?
There is one bug in the prediction code. For a long time I use missiles to shoot away incoming hardheads. I have a special set with an accuracy of 8 and very often they start flying the wrong way. Today I looked a bit deeper in it. For 90% of the time of the incoming missile, my fired missile even stayed behind me and did not fly towards the incoming one. Setting accuracy to zero fixed the problem.
Looking at your code, I see that it assumes the missile is in pursuit of the target and heads not for the missile itself but for a position in front of the target, based on the travel time. But with a head-on approach towards a fast flying ship, it can happen that it calculates an interception point that even lies further away than the current distance. I have not tested this, but it should also mean that when you inject towards an incoming missile, that missile might get confused.
(EDIT: I just tested it with a missile with accuracy=8 that was fired at me:
player.ship.heading.dot(player.ship.target.heading)= 0.9703339338302612
The value near 1 means the missile was fleeing from me when I injected toward it
)
I suggest adding a line that calculates the dot product between own and target forward_vector. And only use your accuracy code when in persuit.
Code: Select all
inPursuit = (dot_product([target forwardVector], v_forward) > 0.0f);
With this addition, my missiles now hit the incoming ones from the air when a high accuracy was defined. Before it only worked correct when defining a low accuracy what seemed a bit strange.
Browsing through some missile containing oxps I could only find one using the accuracy setting and that was the abs missile from nukes.oxp. For any other missiles without an accuracy setting, this effect will be not present.