mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-19 13:46:08 +00:00
Ops
This commit is contained in:
@@ -4250,11 +4250,10 @@ function WAREHOUSE:onafterRequest(From, Event, To, Request)
|
|||||||
-- Get stock item.
|
-- Get stock item.
|
||||||
local _assetitem=_assetstock[i] --#WAREHOUSE.Assetitem
|
local _assetitem=_assetstock[i] --#WAREHOUSE.Assetitem
|
||||||
|
|
||||||
-- Create an alias name with the UIDs for the sending warehouse, asset and request.
|
-- Spawn group name
|
||||||
--local _alias=self:_alias(_assetitem.unittype, self.uid, _assetitem.uid, Request.uid)
|
|
||||||
|
|
||||||
local _alias=_assetitem.spawngroupname
|
local _alias=_assetitem.spawngroupname
|
||||||
|
|
||||||
|
-- Set Request ID.
|
||||||
_assetitem.rid=Request.uid
|
_assetitem.rid=Request.uid
|
||||||
|
|
||||||
-- Asset is transport.
|
-- Asset is transport.
|
||||||
@@ -5374,11 +5373,11 @@ function WAREHOUSE:_SpawnAssetRequest(Request)
|
|||||||
-- Set asset status to not spawned until we capture its birth event.
|
-- Set asset status to not spawned until we capture its birth event.
|
||||||
asset.spawned=false
|
asset.spawned=false
|
||||||
asset.iscargo=true
|
asset.iscargo=true
|
||||||
|
|
||||||
|
-- Set request ID.
|
||||||
asset.rid=Request.uid
|
asset.rid=Request.uid
|
||||||
|
|
||||||
-- Alias of the group.
|
-- Spawn group name.
|
||||||
--local _alias=self:_Alias(asset, Request)
|
|
||||||
|
|
||||||
local _alias=asset.spawngroupname
|
local _alias=asset.spawngroupname
|
||||||
|
|
||||||
-- Spawn an asset group.
|
-- Spawn an asset group.
|
||||||
@@ -7594,25 +7593,32 @@ end
|
|||||||
-- @return #boolean True if group is transport, false if group is cargo and nil otherwise.
|
-- @return #boolean True if group is transport, false if group is cargo and nil otherwise.
|
||||||
function WAREHOUSE:_GroupIsTransport(group, request)
|
function WAREHOUSE:_GroupIsTransport(group, request)
|
||||||
|
|
||||||
-- Name of the group under question.
|
local asset=self:FindAssetInDB(group)
|
||||||
local groupname=self:_GetNameWithOut(group)
|
|
||||||
|
|
||||||
if request.transportgroupset then
|
if asset and asset.iscargo~=nil then
|
||||||
local transporters=request.transportgroupset:GetSetObjects()
|
return not asset.iscargo
|
||||||
|
else
|
||||||
|
|
||||||
for _,transport in pairs(transporters) do
|
-- Name of the group under question.
|
||||||
if transport:GetName()==groupname then
|
local groupname=self:_GetNameWithOut(group)
|
||||||
return true
|
|
||||||
|
if request.transportgroupset then
|
||||||
|
local transporters=request.transportgroupset:GetSetObjects()
|
||||||
|
|
||||||
|
for _,transport in pairs(transporters) do
|
||||||
|
if transport:GetName()==groupname then
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if request.cargogroupset then
|
if request.cargogroupset then
|
||||||
local cargos=request.cargogroupset:GetSetObjects()
|
local cargos=request.cargogroupset:GetSetObjects()
|
||||||
|
|
||||||
for _,cargo in pairs(cargos) do
|
for _,cargo in pairs(cargos) do
|
||||||
if self:_GetNameWithOut(cargo)==groupname then
|
if self:_GetNameWithOut(cargo)==groupname then
|
||||||
return false
|
return false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -7621,35 +7627,12 @@ function WAREHOUSE:_GroupIsTransport(group, request)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Creates a unique name for spawned assets. From the group name the original warehouse, global asset and the request can be derived.
|
|
||||||
-- @param #WAREHOUSE self
|
|
||||||
-- @param #WAREHOUSE.Assetitem _assetitem Asset for which the name is created.
|
|
||||||
-- @param #WAREHOUSE.Queueitem _queueitem (Optional) Request specific name.
|
|
||||||
-- @return #string Alias name "UnitType\_WID-%d\_AID-%d\_RID-%d"
|
|
||||||
function WAREHOUSE:_Alias(_assetitem,_queueitem)
|
|
||||||
return self:_alias(_assetitem.unittype, self.uid, _assetitem.uid,_queueitem.uid)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Creates a unique name for spawned assets. From the group name the original warehouse, global asset and the request can be derived.
|
|
||||||
-- @param #WAREHOUSE self
|
|
||||||
-- @param #string unittype Type of unit.
|
|
||||||
-- @param #number wid Warehouse id.
|
|
||||||
-- @param #number aid Asset item id.
|
|
||||||
-- @param #number qid Queue/request item id.
|
|
||||||
-- @return #string Alias name "UnitType\_WID-%d\_AID-%d\_RID-%d"
|
|
||||||
function WAREHOUSE:_alias(unittype, wid, aid, qid)
|
|
||||||
local _alias=string.format("%s_WID-%d_AID-%d", unittype, wid, aid)
|
|
||||||
if qid then
|
|
||||||
_alias=_alias..string.format("_RID-%d", qid)
|
|
||||||
end
|
|
||||||
return _alias
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Get group name without any spawn or cargo suffix #CARGO etc.
|
--- Get group name without any spawn or cargo suffix #CARGO etc.
|
||||||
-- @param #WAREHOUSE self
|
-- @param #WAREHOUSE self
|
||||||
-- @param Wrapper.Group#GROUP group The group from which the info is gathered.
|
-- @param Wrapper.Group#GROUP group The group from which the info is gathered.
|
||||||
-- @return #string Name of the object without trailing #...
|
-- @return #string Name of the object without trailing #...
|
||||||
function WAREHOUSE:_GetNameWithOut(group)
|
function WAREHOUSE:_GetNameWithOut(group)
|
||||||
|
|
||||||
if group then
|
if group then
|
||||||
local name
|
local name
|
||||||
if type(group)=="string" then
|
if type(group)=="string" then
|
||||||
@@ -7657,18 +7640,23 @@ function WAREHOUSE:_GetNameWithOut(group)
|
|||||||
else
|
else
|
||||||
name=group:GetName()
|
name=group:GetName()
|
||||||
end
|
end
|
||||||
local namewithout=UTILS.Split(name, "#")[1]
|
|
||||||
|
local namewithout=UTILS.Split(name, "#CARGO")[1]
|
||||||
|
|
||||||
if namewithout then
|
if namewithout then
|
||||||
return namewithout
|
return namewithout
|
||||||
else
|
else
|
||||||
return name
|
return name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if type(group)=="string" then
|
if type(group)=="string" then
|
||||||
return group
|
return group
|
||||||
else
|
else
|
||||||
return group:GetName()
|
return group:GetName()
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -131,8 +131,7 @@ function AIRWING:New(warehousename, airwingname)
|
|||||||
-- Add FSM transitions.
|
-- Add FSM transitions.
|
||||||
-- From State --> Event --> To State
|
-- From State --> Event --> To State
|
||||||
self:AddTransition("*", "MissionRequest", "*") -- Add a (mission) request to the warehouse.
|
self:AddTransition("*", "MissionRequest", "*") -- Add a (mission) request to the warehouse.
|
||||||
self:AddTransition("*", "MissionDone", "*") -- Mission is over.
|
self:AddTransition("*", "MissionCancel", "*") -- Cancel mission.
|
||||||
self:AddTransition("*", "MissionCancel", "*") -- Mission is over.
|
|
||||||
|
|
||||||
------------------------
|
------------------------
|
||||||
--- Pseudo Functions ---
|
--- Pseudo Functions ---
|
||||||
@@ -224,6 +223,11 @@ function AIRWING:NewPayload(Unit, MissionTypes, Npayloads, Unlimited)
|
|||||||
Unit=Unit:GetUnit(1)
|
Unit=Unit:GetUnit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Ensure Missiontypes is a table.
|
||||||
|
if MissionTypes and type(MissionTypes)~="table" then
|
||||||
|
MissionTypes={MissionTypes}
|
||||||
|
end
|
||||||
|
|
||||||
if Unit then
|
if Unit then
|
||||||
|
|
||||||
local payload={} --#AIRWING.Payload
|
local payload={} --#AIRWING.Payload
|
||||||
@@ -512,6 +516,13 @@ function AIRWING:onafterStatus(From, Event, To)
|
|||||||
|
|
||||||
text=text..string.format("\n -[%d] %s*%d: spawned=%s, mission=%s%s", j, typename, asset.nunits, spawned, tostring(self:IsAssetOnMission(asset)), missiontext)
|
text=text..string.format("\n -[%d] %s*%d: spawned=%s, mission=%s%s", j, typename, asset.nunits, spawned, tostring(self:IsAssetOnMission(asset)), missiontext)
|
||||||
|
|
||||||
|
local payload=asset.payload
|
||||||
|
if payload then
|
||||||
|
text=text.." payload "..table.concat(payload.missiontypes, ", ")
|
||||||
|
else
|
||||||
|
text=text.." NO payload!"
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
@@ -798,6 +809,10 @@ function AIRWING:onafterNewAsset(From, Event, To, asset, assignment)
|
|||||||
-- Call parent warehouse function first.
|
-- Call parent warehouse function first.
|
||||||
self:GetParent(self).onafterNewAsset(self, From, Event, To, asset, assignment)
|
self:GetParent(self).onafterNewAsset(self, From, Event, To, asset, assignment)
|
||||||
|
|
||||||
|
-- Debug text.
|
||||||
|
local text=string.format("New asset %s with assignment %s and request assignment %s", asset.spawngroupname, tostring(asset.assignment), tostring(assignment))
|
||||||
|
self:I(self.lid..text)
|
||||||
|
|
||||||
-- Get squadron.
|
-- Get squadron.
|
||||||
local squad=self:GetSquadron(asset.assignment)
|
local squad=self:GetSquadron(asset.assignment)
|
||||||
|
|
||||||
@@ -815,14 +830,21 @@ function AIRWING:onafterNewAsset(From, Event, To, asset, assignment)
|
|||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
self:I(self.lid..string.format("Asset %s from squadron %s returned! asset.assignment=\"%s\", assignment=\"%s\"", asset.spawngroupname, squad.name, tostring(asset.assignment), tostring(assignment)))
|
||||||
|
self:ReturnPayloadFromAsset(asset)
|
||||||
|
|
||||||
|
-- Mission might already be removed from the queue!
|
||||||
|
--[[
|
||||||
local mission=self:GetMissionByID(assignment)
|
local mission=self:GetMissionByID(assignment)
|
||||||
|
|
||||||
if mission then
|
if mission then
|
||||||
local text=string.format("Asset %s returned from %s mission %s", asset.spawngroupname, mission.type, mission.name)
|
local text=string.format("Asset %s returned from %s mission %s", asset.spawngroupname, mission.type, mission.name)
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
|
self:ReturnPayloadFromAsset(asset)
|
||||||
else
|
else
|
||||||
self:E(self.lid.."ERROR: new asset not beloning to any s")
|
self:E(self.lid..string.format("ERROR: asset %s from squadron %s returned but could not find its mission! asset.assignment=\"%s\", assignment=\"%s\"", asset.spawngroupname, squad.name, tostring(asset.assignment), tostring(assignment)))
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1189,7 +1211,10 @@ function AIRWING:CanMission(MissionType, Nassets)
|
|||||||
-- Now clear all reserved payloads.
|
-- Now clear all reserved payloads.
|
||||||
for _,_asset in pairs(Assets) do
|
for _,_asset in pairs(Assets) do
|
||||||
local asset=_asset --#AIRWING.SquadronAsset
|
local asset=_asset --#AIRWING.SquadronAsset
|
||||||
self:ReturnPayloadFromAsset(asset)
|
-- Only unspawned payloads are returned.
|
||||||
|
if not asset.spawned then
|
||||||
|
self:ReturnPayloadFromAsset(asset)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return Can, Assets
|
return Can, Assets
|
||||||
|
|||||||
@@ -703,6 +703,12 @@ end
|
|||||||
-- @param #string status New status.
|
-- @param #string status New status.
|
||||||
function AUFTRAG:SetFlightStatus(flightgroup, status)
|
function AUFTRAG:SetFlightStatus(flightgroup, status)
|
||||||
self.flightdata[flightgroup.groupname].status=status
|
self.flightdata[flightgroup.groupname].status=status
|
||||||
|
|
||||||
|
-- Check if ALL flights are done with their mission.
|
||||||
|
if self:IsNotOver() and self:CheckFlightsDone() then
|
||||||
|
self:Done()
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get flightgroup mission status.
|
--- Get flightgroup mission status.
|
||||||
@@ -907,7 +913,7 @@ end
|
|||||||
--- Add asset to mission.
|
--- Add asset to mission.
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @param Ops.AirWing#AIRWING.SquadronAsset Asset The asset to be added to the mission.
|
-- @param Ops.AirWing#AIRWING.SquadronAsset Asset The asset to be added to the mission.
|
||||||
-- @return #AIRWING self
|
-- @return #AUFTRAG self
|
||||||
function AUFTRAG:AddAsset(Asset)
|
function AUFTRAG:AddAsset(Asset)
|
||||||
|
|
||||||
self.assets=self.assets or {}
|
self.assets=self.assets or {}
|
||||||
@@ -920,7 +926,7 @@ end
|
|||||||
--- Delete asset from mission.
|
--- Delete asset from mission.
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @param Ops.AirWing#AIRWING.SquadronAsset Asset The asset to be removed.
|
-- @param Ops.AirWing#AIRWING.SquadronAsset Asset The asset to be removed.
|
||||||
-- @return #AIRWING self
|
-- @return #AUFTRAG self
|
||||||
function AUFTRAG:DelAsset(Asset)
|
function AUFTRAG:DelAsset(Asset)
|
||||||
|
|
||||||
for i,_asset in pairs(self.assets or {}) do
|
for i,_asset in pairs(self.assets or {}) do
|
||||||
@@ -928,10 +934,12 @@ function AUFTRAG:DelAsset(Asset)
|
|||||||
|
|
||||||
if asset.uid==Asset.uid then
|
if asset.uid==Asset.uid then
|
||||||
table.remove(self.assets, i)
|
table.remove(self.assets, i)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -1006,6 +1014,19 @@ function AUFTRAG:GetTargetCoordinate()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get coordinate of target. First unit/group of the set is used.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @return #string
|
||||||
|
function AUFTRAG:GetMissionTypesText(MissionTypes)
|
||||||
|
|
||||||
|
local text=""
|
||||||
|
for _,missiontype in pairs(MissionTypes) do
|
||||||
|
text=text..string.format("%s, ", missiontype)
|
||||||
|
end
|
||||||
|
|
||||||
|
return text
|
||||||
|
end
|
||||||
|
|
||||||
--- Get DCS task table for the given mission.
|
--- Get DCS task table for the given mission.
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @return DCS#Task The DCS task table. If multiple tasks are necessary, this is returned as a combo task.
|
-- @return DCS#Task The DCS task table. If multiple tasks are necessary, this is returned as a combo task.
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
-- @field #boolean fuelcritical Fuel critical switch.
|
-- @field #boolean fuelcritical Fuel critical switch.
|
||||||
-- @field #number fuelcriticalthresh Critical fuel threshold in percent.
|
-- @field #number fuelcriticalthresh Critical fuel threshold in percent.
|
||||||
-- @field #boolean fuelcriticalrtb RTB on critical fuel switch.
|
-- @field #boolean fuelcriticalrtb RTB on critical fuel switch.
|
||||||
|
-- @field #boolean passedfinalwp Group has passed the final waypoint.
|
||||||
-- @field Ops.Airwing#AIRWING airwing The airwing the flight group belongs to.
|
-- @field Ops.Airwing#AIRWING airwing The airwing the flight group belongs to.
|
||||||
-- @field Ops.FlightControl#FLIGHTCONTROL flightcontrol The flightcontrol handling this group.
|
-- @field Ops.FlightControl#FLIGHTCONTROL flightcontrol The flightcontrol handling this group.
|
||||||
-- @field Core.UserFlag#USERFLAG flaghold Flag for holding.
|
-- @field Core.UserFlag#USERFLAG flaghold Flag for holding.
|
||||||
@@ -1265,7 +1266,7 @@ function FLIGHTGROUP:onafterFlightStatus(From, Event, To)
|
|||||||
local nTaskTot, nTaskSched, nTaskWP=self:CountRemainingTasks()
|
local nTaskTot, nTaskSched, nTaskWP=self:CountRemainingTasks()
|
||||||
|
|
||||||
-- Short info.
|
-- Short info.
|
||||||
local text=string.format("Flight status %s [%d/%d]. Tasks=%d (%d,%d) Current=%d. Waypoint=%d/%d. Detected=%d. Destination=%s, FC=%s",
|
local text=string.format("Status %s [%d/%d]: Tasks=%d (%d,%d) Current=%d. Waypoint=%d/%d. Detected=%d. Destination=%s, FC=%s",
|
||||||
fsmstate, #self.elements, #self.elements, nTaskTot, nTaskSched, nTaskWP, self.taskcurrent, self.currentwp or 0, self.waypoints and #self.waypoints or 0,
|
fsmstate, #self.elements, #self.elements, nTaskTot, nTaskSched, nTaskWP, self.taskcurrent, self.currentwp or 0, self.waypoints and #self.waypoints or 0,
|
||||||
self.detectedunits:Count(), self.destbase and self.destbase:GetName() or "unknown", self.flightcontrol and self.flightcontrol.airbasename or "none")
|
self.detectedunits:Count(), self.destbase and self.destbase:GetName() or "unknown", self.flightcontrol and self.flightcontrol.airbasename or "none")
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
@@ -2215,7 +2216,6 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
|||||||
MESSAGE:New(text, 10):ToAllIf(false)
|
MESSAGE:New(text, 10):ToAllIf(false)
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
|
|
||||||
|
|
||||||
-- Update waypoint tasks, i.e. inject WP tasks into waypoint table.
|
-- Update waypoint tasks, i.e. inject WP tasks into waypoint table.
|
||||||
self:_UpdateWaypointTasks()
|
self:_UpdateWaypointTasks()
|
||||||
|
|
||||||
@@ -2270,22 +2270,25 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
|||||||
-- No waypoints left
|
-- No waypoints left
|
||||||
---
|
---
|
||||||
|
|
||||||
self:E(self.lid.."WARNING: No waypoints left. Dunno what to do!")
|
if self.passedfinalwp then
|
||||||
|
|
||||||
--[[
|
self:I(self.lid.."UpdateRoute: Passed Final WP ==> RTB/RTZ/Wait!")
|
||||||
|
|
||||||
-- Send flight to destination. NOTE that if there are still remaining tasks, the RTB call is delayed by 10 sec until all tasks are done.
|
-- Send flight to destination. NOTE that if there are still remaining tasks, the RTB call is delayed by 10 sec until all tasks are done.
|
||||||
if self.destbase then
|
if self.destbase then
|
||||||
self:__RTB(-1, self.destbase)
|
self:I(self.lid.."UpdateRoute: Passed Final WP ==> RTB!")
|
||||||
elseif self.destzone then
|
self:__RTB(-1, self.destbase)
|
||||||
self:__RTZ(-1, self.destzone)
|
elseif self.destzone then
|
||||||
|
self:I(self.lid.."UpdateRoute: Passed Final WP ==> RTZ!")
|
||||||
|
self:__RTZ(-1, self.destzone)
|
||||||
|
else
|
||||||
|
self:I(self.lid.."UpdateRoute: Passed Final WP ==> Wait!")
|
||||||
|
self:__Wait(-1)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
self:__Wait(-1)
|
self:E(self.lid.."WARNING: No waypoints left. Dunno what to do!")
|
||||||
self:E(self.lid.."ERROR: Reached final waypoint but no destination set! Don't know what to do?!")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -2298,6 +2301,8 @@ end
|
|||||||
-- @param #table Template The template used to respawn the group.
|
-- @param #table Template The template used to respawn the group.
|
||||||
function FLIGHTGROUP:onafterRespawn(From, Event, To, Template)
|
function FLIGHTGROUP:onafterRespawn(From, Event, To, Template)
|
||||||
|
|
||||||
|
self:I(self.lid.."Respawning group!")
|
||||||
|
|
||||||
local template=UTILS.DeepCopy(Template or self.template)
|
local template=UTILS.DeepCopy(Template or self.template)
|
||||||
|
|
||||||
if self.group and self.group:InAir() then
|
if self.group and self.group:InAir() then
|
||||||
@@ -2320,14 +2325,12 @@ function FLIGHTGROUP:onafterPassingWaypoint(From, Event, To, n, N)
|
|||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
MESSAGE:New(text, 30, "DEBUG"):ToAllIf(self.Debug)
|
MESSAGE:New(text, 30, "DEBUG"):ToAllIf(self.Debug)
|
||||||
|
|
||||||
if true then
|
|
||||||
|
|
||||||
-- Get all waypoint tasks.
|
-- Get all waypoint tasks.
|
||||||
local tasks=self:GetTasksWaypoint(n)
|
local tasks=self:GetTasksWaypoint(n)
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
local text=string.format("WP %d/%d tasks:", n, N)
|
local text=string.format("WP %d/%d tasks:", n, N)
|
||||||
if tasks then
|
if #tasks>0 then
|
||||||
for i,_task in pairs(tasks) do
|
for i,_task in pairs(tasks) do
|
||||||
local task=_task --#FLIGHTGROUP.Task
|
local task=_task --#FLIGHTGROUP.Task
|
||||||
text=text..string.format("\n[%d] %s", i, task.description)
|
text=text..string.format("\n[%d] %s", i, task.description)
|
||||||
@@ -2365,28 +2368,27 @@ function FLIGHTGROUP:onafterPassingWaypoint(From, Event, To, n, N)
|
|||||||
self:PushTask(self.group:TaskCombo(taskswp))
|
self:PushTask(self.group:TaskCombo(taskswp))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Final AIR waypoint reached?
|
-- Final AIR waypoint reached?
|
||||||
if n==N then
|
if n==N then
|
||||||
|
|
||||||
--TODO: Find better way to RTB!
|
--TODO: Find better way to RTB!
|
||||||
self:I(self.lid.."FF group passed final waypoint!")
|
self:I(self.lid.."FF group passed final waypoint!")
|
||||||
|
|
||||||
--[[
|
self.passedfinalwp=true
|
||||||
|
|
||||||
|
if #taskswp==0 then
|
||||||
|
|
||||||
|
if self.destbase then
|
||||||
|
self:__RTB(-1, self.destbase)
|
||||||
|
elseif self.destzone then
|
||||||
|
self:__RTZ(-1, self.destzone)
|
||||||
|
else
|
||||||
|
self:__Wait(-1)
|
||||||
|
self:E(self.lid.."ERROR: Reached final waypoint but no destination set! Don't know what to do?!")
|
||||||
|
end
|
||||||
|
|
||||||
-- Send flight to destination. NOTE that if there are still remaining tasks, the RTB call is delayed by 10 sec until all tasks are done.
|
|
||||||
if self.destbase then
|
|
||||||
self:__RTB(-1, self.destbase)
|
|
||||||
elseif self.destzone then
|
|
||||||
self:__RTZ(-1, self.destzone)
|
|
||||||
else
|
|
||||||
self:__Wait(-1)
|
|
||||||
self:E(self.lid.."ERROR: Reached final waypoint but no destination set! Don't know what to do?!")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -2481,6 +2483,8 @@ end
|
|||||||
-- @param #number SpeedLand Landing speed in knots. Default 170 kts.
|
-- @param #number SpeedLand Landing speed in knots. Default 170 kts.
|
||||||
function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, SpeedLand)
|
function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, SpeedLand)
|
||||||
|
|
||||||
|
self:I(self.lid..string.format("RTB: event=%s: %s --> %s", Event, From, To))
|
||||||
|
|
||||||
-- Defaults:
|
-- Defaults:
|
||||||
SpeedTo=SpeedTo or 350
|
SpeedTo=SpeedTo or 350
|
||||||
SpeedHold=SpeedHold or 250
|
SpeedHold=SpeedHold or 250
|
||||||
@@ -2559,10 +2563,13 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
|
|||||||
if fc or world.event.S_EVENT_KILL then
|
if fc or world.event.S_EVENT_KILL then
|
||||||
|
|
||||||
-- Just route the group. Respawn will happen when going from holding to final.
|
-- Just route the group. Respawn will happen when going from holding to final.
|
||||||
|
env.info("FF route (not repawn)")
|
||||||
self:Route(wp, 1)
|
self:Route(wp, 1)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
env.info("FF respawn (not route)")
|
||||||
|
|
||||||
-- Get group template.
|
-- Get group template.
|
||||||
local Template=self.group:GetTemplate()
|
local Template=self.group:GetTemplate()
|
||||||
|
|
||||||
@@ -3958,6 +3965,13 @@ function FLIGHTGROUP:InitWaypoints(waypoints)
|
|||||||
|
|
||||||
-- Update route.
|
-- Update route.
|
||||||
if #self.waypoints>0 then
|
if #self.waypoints>0 then
|
||||||
|
|
||||||
|
-- Check if only 1 wp?
|
||||||
|
if #self.waypoints==1 then
|
||||||
|
self.passedfinalwp=true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Update route (when airborne).
|
||||||
self:__UpdateRoute(-1)
|
self:__UpdateRoute(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3977,6 +3991,10 @@ function FLIGHTGROUP:AddWaypointAir(coordinate, wpnumber, speed, updateroute)
|
|||||||
--TODO: by default add after last AIR waypoint! Last WP could be landing...
|
--TODO: by default add after last AIR waypoint! Last WP could be landing...
|
||||||
wpnumber=wpnumber or #self.waypoints+1
|
wpnumber=wpnumber or #self.waypoints+1
|
||||||
|
|
||||||
|
if wpnumber>self.currentwp then
|
||||||
|
self.passedfinalwp=false
|
||||||
|
end
|
||||||
|
|
||||||
-- Speed in knots.
|
-- Speed in knots.
|
||||||
speed=speed or 350
|
speed=speed or 350
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user