mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
OpsGroup
This commit is contained in:
parent
f578fcfdc7
commit
5cf4833455
@ -2017,7 +2017,8 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Clear all tasks.
|
-- 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?
|
-- Respawn?
|
||||||
if routeto then
|
if routeto then
|
||||||
|
|||||||
@ -675,8 +675,18 @@ function NAVYGROUP:onafterTurnIntoWind(From, Event, To, IntoWind)
|
|||||||
IntoWind.Coordinate=self:GetCoordinate()
|
IntoWind.Coordinate=self:GetCoordinate()
|
||||||
|
|
||||||
self.intowind=IntoWind
|
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)
|
local distance=UTILS.NMToMeters(1000)
|
||||||
|
|
||||||
@ -685,8 +695,8 @@ function NAVYGROUP:onafterTurnIntoWind(From, Event, To, IntoWind)
|
|||||||
local coord=self:GetCoordinate()
|
local coord=self:GetCoordinate()
|
||||||
local Coord=coord:Translate(distance, IntoWind.Heading)
|
local Coord=coord:Translate(distance, IntoWind.Heading)
|
||||||
|
|
||||||
wp[1]=coord:WaypointNaval(IntoWind.Speed)
|
wp[1]=coord:WaypointNaval(UTILS.KnotsToKmph(speed))
|
||||||
wp[2]=Coord:WaypointNaval(IntoWind.Speed)
|
wp[2]=Coord:WaypointNaval(UTILS.KnotsToKmph(speed))
|
||||||
|
|
||||||
self:Route(wp)
|
self:Route(wp)
|
||||||
|
|
||||||
@ -921,7 +931,7 @@ end
|
|||||||
--- Add an a waypoint to the route.
|
--- Add an a waypoint to the route.
|
||||||
-- @param #NAVYGROUP self
|
-- @param #NAVYGROUP self
|
||||||
-- @param Core.Point#COORDINATE coordinate The coordinate of the waypoint. Use COORDINATE:SetAltitude(altitude) to define the altitude.
|
-- @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 #number wpnumber Waypoint number. Default at the end.
|
||||||
-- @param #boolean updateroute If true or nil, call UpdateRoute. If false, no call.
|
-- @param #boolean updateroute If true or nil, call UpdateRoute. If false, no call.
|
||||||
-- @return #number Waypoint index.
|
-- @return #number Waypoint index.
|
||||||
@ -935,7 +945,7 @@ function NAVYGROUP:AddWaypoint(coordinate, speed, wpnumber, updateroute)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Speed in knots.
|
-- Speed in knots.
|
||||||
speed=speed or self.speedmax*0.7
|
speed=speed or self:GetSpeedCruise()
|
||||||
|
|
||||||
-- Speed at waypoint.
|
-- Speed at waypoint.
|
||||||
local speedkmh=UTILS.KnotsToKmph(speed)
|
local speedkmh=UTILS.KnotsToKmph(speed)
|
||||||
|
|||||||
@ -2156,30 +2156,36 @@ end
|
|||||||
--- Route group along waypoints.
|
--- Route group along waypoints.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @param #table waypoints Table of waypoints.
|
-- @param #table waypoints Table of waypoints.
|
||||||
|
-- @default
|
||||||
-- @return #OPSGROUP self
|
-- @return #OPSGROUP self
|
||||||
function OPSGROUP:Route(waypoints)
|
function OPSGROUP:Route(waypoints, delay)
|
||||||
|
|
||||||
if self:IsAlive() then
|
if delay and delay>0 then
|
||||||
|
self:ScheduleOnce(delay, OPSGROUP.Route, self, waypoints)
|
||||||
-- 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
|
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
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user