Updated approach speed logic to prevent airplanes to fly beyond the hold position.

This commit is contained in:
FlightControl 2019-04-09 17:45:29 +02:00
parent 5e67861ea9
commit bf449492b5
2 changed files with 17 additions and 12 deletions

View File

@ -306,8 +306,8 @@ function AI_ESCORT:Menus()
-- self:MenuScanForTargets( 100, 60 )
self:MenuJoinUp()
self:MenuFormationTrail( 0, 50, 100 )
self:MenuFormationStack( 0, 0, 100, 100 )
self:MenuFormationTrail( 50, 100, 50 )
self:MenuFormationStack( 50, 100, 50, 50 )
self:MenuFormationLeftLine( 0, 0, 100, 100 )
self:MenuFormationRightLine( 0, 0, 100, 100 )
self:MenuFormationLeftWing( 0, 50, 0, 100, 100 )

View File

@ -963,15 +963,11 @@ end
--- @param #AI_FORMATION self
function AI_FORMATION:onenterFollowing( FollowGroupSet ) --R2.1
self:F( )
self:T( { self.FollowUnit.UnitName, self.FollowUnit:IsAlive() } )
if self.FollowUnit:IsAlive() then
local ClientUnit = self.FollowUnit
self:T( {ClientUnit.UnitName } )
local CT1, CT2, CV1, CV2
CT1 = ClientUnit:GetState( self, "CT1" )
@ -1038,7 +1034,7 @@ function AI_FORMATION:onenterFollowing( FollowGroupSet ) --R2.1
local Alpha_R = ( Alpha_T < 0 ) and Alpha_T + 2 * math.pi or Alpha_T
local Position = math.cos( Alpha_R )
local GD = ( ( GDv.x )^2 + ( GDv.z )^2 ) ^ 0.5
local Distance = GD * Position + - CS * 0.3
local Distance = GD * Position + - CS * 0.5
-- Calculate the group direction vector
local GV = { x = GV2.x - CV2.x, y = GV2.y - CV2.y, z = GV2.z - CV2.z }
@ -1056,7 +1052,7 @@ function AI_FORMATION:onenterFollowing( FollowGroupSet ) --R2.1
-- Now we calculate the intersecting vector between the circle around CV2 with radius FollowDistance and GH2.
-- From the GeoGebra model: CVI = (x(CV2) + FollowDistance cos(alpha), y(GH2) + FollowDistance sin(alpha), z(CV2))
local CVI = { x = CV2.x + CS * 10 * math.sin(Ca),
y = GH2.y - ( Distance + FollowFormation.x ) / 10, -- + FollowFormation.y,
y = GH2.y + ( Distance + FollowFormation.x ) / 10, -- + FollowFormation.y,
z = CV2.z + CS * 10 * math.cos(Ca),
}
@ -1087,13 +1083,22 @@ function AI_FORMATION:onenterFollowing( FollowGroupSet ) --R2.1
local Time = 60
local Time = 120
local Speed = - ( Distance + FollowFormation.x ) / Time
local GS = Speed + CS
if Speed < 0 then
Speed = 0
if Distance > -4000 then
Speed = - ( Distance + FollowFormation.x ) / 90
end
if Distance > -1500 then
Speed = - ( Distance + FollowFormation.x ) / 20
end
local GS = Speed + CS
self:F( { Distance = Distance, Speed = Speed, CS = CS, GS = GS } )
-- Now route the escort to the desired point with the desired speed.
FollowGroup:RouteToVec3( GDV_Formation, GS ) -- DCS models speed in Mps (Miles per second)