It isn't the interception bug I've been hoping to solve, but I came across it while investigating how missiles work.
CMissile.cpp line 1037:
// If this is a tracking missile, change direction to face the target
if (m_pDesc->IsTrackingTime(iTick)
&& m_pTarget)
{
// Get the position and velocity of the target
CVector vTarget = m_pTarget->GetPos() - GetPos();
CVector vTargetVel = m_pTarget->GetVel() - GetVel();
// Figure out which direction to move in
int iFireAngle;
Metric rCurrentSpeed = GetVel().Length();
Metric rTimeToIntercept = CalcInterceptTime(vTarget, vTargetVel, rCurrentSpeed);
if (rTimeToIntercept > 0.0)
{
CVector vInterceptPoint = vTarget + vTargetVel * rTimeToIntercept;
iFireAngle = VectorToPolar(vInterceptPoint, NULL);
}
The problem is this line:CVector vTargetVel = m_pTarget->GetVel() - GetVel();
The missile is trying to figure out what its velocity (in the system reference frame) should be in order to intercept the target. So it should use the target's velocity in the system reference frame, rather than the target's velocity relative to its own current velocity, to calculate the intercept time.
This causes tracking missiles to take curved paths to the target, even when it's not accelerating. (I assumed it was supposed to work this way, but apparently it isn't.) It also may explain why some tracking fragments, such as from the TM7, will fail to seek the target if they start out facing the wrong way, but would be capable of turning around and intercepting it.
Need to investigate.
Try just deleting - GetVel()
from that line.
@NMS: You're right! Unlike firing a weapon, we're not adding to the velocity of the platform. Thus, we use the system-relative velocity.
Thank you!