Fix case where there could be no intercept due to too low speed of chaser.

This commit is contained in:
Nikolai V Chr 2019-04-14 09:17:24 +02:00
parent 41493d4f97
commit 350a6cabd0

View File

@ -17,7 +17,6 @@
# request a BRAA, then it will receive it.
var damage_prop = props.globals.getNode("/carrier/sunk");
var prop_watch = {
"MiG-15bis": [0,1,2],
"MiG-21bis": [0,1,2],
"MiG-21MF-75": [0,1,2],
"QF-4E": [0,1,2],
@ -447,7 +446,12 @@ var get_intercept = func(bearing, dist_m, runnerHeading, runnerSpeed, chaserSpee
}
var t1 = (-b+math.sqrt(b*b-4*a*c))/(2*a);
var t2 = (-b-math.sqrt(b*b-4*a*c))/(2*a);
if (t1 < 0 and t2 < 0) {
# intercept not possible
return nil;
}
var timeToIntercept = 0;
if (t1 > 0 and t2 > 0) {
timeToIntercept = math.min(t1, t2);