This commit is contained in:
Frank 2020-07-10 14:16:41 +02:00
parent f578fcfdc7
commit 5cf4833455
3 changed files with 44 additions and 27 deletions

View File

@ -2017,7 +2017,8 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
end
-- Clear all tasks.
self:ClearTasks()
-- Warning, looks like this can make DCS CRASH! Had this after calling RTB once passed the final waypoint.
--self:ClearTasks()
-- Respawn?
if routeto then

View File

@ -675,8 +675,18 @@ function NAVYGROUP:onafterTurnIntoWind(From, Event, To, IntoWind)
IntoWind.Coordinate=self:GetCoordinate()
self.intowind=IntoWind
-- Wind speed in m/s.
local _,vwind=self:GetWind()
-- Convert to knots.
vwind=UTILS.MpsToKnots(vwind)
self:I(self.lid..string.format("Steaming into wind: Heading=%03d Speed=%.1f knots, Tstart=%d Tstop=%d", IntoWind.Heading, IntoWind.Speed, IntoWind.Tstart, IntoWind.Tstop))
-- Speed of carrier in m/s but at least 2 knots.
local speed=math.max(IntoWind.Speed-vwind, 2)
-- Debug info.
self:I(self.lid..string.format("Steaming into wind: Heading=%03d Speed=%.1f Vwind=%.1f Vtot=%.1f knots, Tstart=%d Tstop=%d", IntoWind.Heading, speed, vwind, speed+vwind, IntoWind.Tstart, IntoWind.Tstop))
local distance=UTILS.NMToMeters(1000)
@ -685,8 +695,8 @@ function NAVYGROUP:onafterTurnIntoWind(From, Event, To, IntoWind)
local coord=self:GetCoordinate()
local Coord=coord:Translate(distance, IntoWind.Heading)
wp[1]=coord:WaypointNaval(IntoWind.Speed)
wp[2]=Coord:WaypointNaval(IntoWind.Speed)
wp[1]=coord:WaypointNaval(UTILS.KnotsToKmph(speed))
wp[2]=Coord:WaypointNaval(UTILS.KnotsToKmph(speed))
self:Route(wp)
@ -921,7 +931,7 @@ end
--- Add an a waypoint to the route.
-- @param #NAVYGROUP self
-- @param Core.Point#COORDINATE coordinate The coordinate of the waypoint. Use COORDINATE:SetAltitude(altitude) to define the altitude.
-- @param #number speed Speed in knots. Default is 70% of max speed.
-- @param #number speed Speed in knots. Default is default cruise speed or 70% of max speed.
-- @param #number wpnumber Waypoint number. Default at the end.
-- @param #boolean updateroute If true or nil, call UpdateRoute. If false, no call.
-- @return #number Waypoint index.
@ -935,7 +945,7 @@ function NAVYGROUP:AddWaypoint(coordinate, speed, wpnumber, updateroute)
end
-- Speed in knots.
speed=speed or self.speedmax*0.7
speed=speed or self:GetSpeedCruise()
-- Speed at waypoint.
local speedkmh=UTILS.KnotsToKmph(speed)

View File

@ -2156,30 +2156,36 @@ end
--- Route group along waypoints.
-- @param #OPSGROUP self
-- @param #table waypoints Table of waypoints.
-- @default
-- @return #OPSGROUP self
function OPSGROUP:Route(waypoints)
function OPSGROUP:Route(waypoints, delay)
if self:IsAlive() then
-- DCS task combo.
local Tasks={}
-- Route (Mission) task.
local TaskRoute=self.group:TaskRoute(waypoints)
table.insert(Tasks, TaskRoute)
-- TaskCombo of enroute and mission tasks.
local TaskCombo=self.group:TaskCombo(Tasks)
-- Set tasks.
if #Tasks>1 then
self:SetTask(TaskCombo)
else
self:SetTask(TaskRoute)
end
if delay and delay>0 then
self:ScheduleOnce(delay, OPSGROUP.Route, self, waypoints)
else
self:E(self.lid.."ERROR: Group is not alive! Cannot route group.")
if self:IsAlive() then
-- DCS task combo.
local Tasks={}
-- Route (Mission) task.
local TaskRoute=self.group:TaskRoute(waypoints)
table.insert(Tasks, TaskRoute)
-- TaskCombo of enroute and mission tasks.
local TaskCombo=self.group:TaskCombo(Tasks)
-- Set tasks.
if #Tasks>1 then
self:SetTask(TaskCombo)
else
self:SetTask(TaskRoute)
end
else
self:E(self.lid.."ERROR: Group is not alive! Cannot route group.")
end
end
return self