mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Ops
This commit is contained in:
parent
b13ddc958b
commit
46e73a108f
@ -5161,7 +5161,7 @@ function WAREHOUSE:onafterAssetSpawned(From, Event, To, group, asset, request)
|
||||
local assetitem=_asset --#WAREHOUSE.Assetitem
|
||||
|
||||
-- Debug info.
|
||||
self:T2(self.lid..string.format("Asset %s spawned %s as %s", assetitem.templatename, tostring(assetitem.spawned), tostring(assetitem.spawngroupname)))
|
||||
self:I(self.lid..string.format("Asset %s spawned %s as %s", assetitem.templatename, tostring(assetitem.spawned), tostring(assetitem.spawngroupname)))
|
||||
|
||||
if assetitem.spawned then
|
||||
n=n+1
|
||||
|
||||
@ -1056,6 +1056,7 @@ function AUFTRAG:NewESCORT(EscortGroup, OffsetVector, EngageMaxDistance, TargetT
|
||||
-- Mission options:
|
||||
mission.missionTask=ENUMS.MissionTask.ESCORT
|
||||
mission.missionFraction=0.1
|
||||
mission.missionAltitude=1000
|
||||
mission.optionROE=ENUMS.ROE.OpenFire -- TODO: what's the best ROE here? Make dependent on ESCORT or FOLLOW!
|
||||
mission.optionROT=ENUMS.ROT.PassiveDefense
|
||||
|
||||
@ -1893,6 +1894,18 @@ end
|
||||
-- Asset Data
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Get all OPS groups.
|
||||
-- @param #AUFTRAG self
|
||||
-- @return #table Table of Ops.OpsGroup#OPSGROUP or {}.
|
||||
function AUFTRAG:GetOpsGroups()
|
||||
local opsgroups={}
|
||||
for _,_groupdata in pairs(self.groupdata or {}) do
|
||||
local groupdata=_groupdata --#AUFTRAG.GroupData
|
||||
table.insert(opsgroups, groupdata.opsgroup)
|
||||
end
|
||||
return opsgroups
|
||||
end
|
||||
|
||||
--- Get asset data table.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param #string AssetName Name of the asset.
|
||||
|
||||
@ -744,7 +744,7 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
|
||||
end
|
||||
|
||||
-- Element status.
|
||||
if self.verbose>1 then
|
||||
if self.verbose>1 or true then
|
||||
local text="Elements:"
|
||||
for i,_element in pairs(self.elements) do
|
||||
local element=_element --#FLIGHTGROUP.Element
|
||||
@ -757,7 +757,7 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
|
||||
local parking=element.parking and tostring(element.parking.TerminalID) or "X"
|
||||
|
||||
-- Check if element is not dead and we missed an event.
|
||||
if life<0 and element.status~=OPSGROUP.ElementStatus.DEAD and element.status~=OPSGROUP.ElementStatus.INUTERO then
|
||||
if life<=0 and element.status~=OPSGROUP.ElementStatus.DEAD and element.status~=OPSGROUP.ElementStatus.INUTERO then
|
||||
self:ElementDead(element)
|
||||
end
|
||||
|
||||
@ -980,6 +980,10 @@ function FLIGHTGROUP:OnEventBirth(EventData)
|
||||
self.homebase=self.homebase or EventData.Place
|
||||
end
|
||||
|
||||
if self.homebase and not self.destbase then
|
||||
self.destbase=self.homebase
|
||||
end
|
||||
|
||||
-- Get element.
|
||||
local element=self:GetElementByName(unitname)
|
||||
|
||||
@ -989,7 +993,7 @@ function FLIGHTGROUP:OnEventBirth(EventData)
|
||||
end
|
||||
|
||||
-- Set element to spawned state.
|
||||
self:T3(self.lid..string.format("EVENT: Element %s born ==> spawned", element.name))
|
||||
self:I(self.lid..string.format("EVENT: Element %s born at airbase %s==> spawned", element.name, self.homebase and self.homebase:GetName() or "unknown"))
|
||||
self:ElementSpawned(element)
|
||||
|
||||
end
|
||||
@ -1108,7 +1112,7 @@ function FLIGHTGROUP:OnEventEngineShutdown(EventData)
|
||||
|
||||
if element.unit and element.unit:IsAlive() then
|
||||
|
||||
local airbase=element.unit:GetCoordinate():GetClosestAirbase()
|
||||
local airbase=self:GetClosestAirbase() --element.unit:GetCoordinate():GetClosestAirbase()
|
||||
local parking=self:GetParkingSpot(element, 10, airbase)
|
||||
|
||||
if airbase and parking then
|
||||
@ -1455,7 +1459,7 @@ end
|
||||
function FLIGHTGROUP:onafterParking(From, Event, To)
|
||||
self:I(self.lid..string.format("Flight is parking"))
|
||||
|
||||
local airbase=self.group:GetCoordinate():GetClosestAirbase()
|
||||
local airbase=self:GetClosestAirbase() --self.group:GetCoordinate():GetClosestAirbase()
|
||||
|
||||
local airbasename=airbase:GetName() or "unknown"
|
||||
|
||||
@ -1496,7 +1500,7 @@ function FLIGHTGROUP:onafterTaxiing(From, Event, To)
|
||||
self.Tparking=nil
|
||||
|
||||
-- TODO: need a better check for the airbase.
|
||||
local airbase=self.group:GetCoordinate():GetClosestAirbase(nil, self.group:GetCoalition())
|
||||
local airbase=self:GetClosestAirbase() --self.group:GetCoordinate():GetClosestAirbase(nil, self.group:GetCoalition())
|
||||
|
||||
if self.flightcontrol and airbase and self.flightcontrol.airbasename==airbase:GetName() then
|
||||
|
||||
@ -1540,7 +1544,10 @@ end
|
||||
function FLIGHTGROUP:onafterAirborne(From, Event, To)
|
||||
self:I(self.lid..string.format("Flight airborne"))
|
||||
|
||||
if not self.ai then
|
||||
if self.ai then
|
||||
self:_CheckGroupDone(1)
|
||||
else
|
||||
--if not self.ai then
|
||||
self:_UpdateMenu()
|
||||
end
|
||||
end
|
||||
@ -1599,7 +1606,7 @@ end
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
function FLIGHTGROUP:onafterFlightDead(From, Event, To)
|
||||
function FLIGHTGROUP:onafterDead(From, Event, To)
|
||||
self:I(self.lid..string.format("Flight dead!"))
|
||||
|
||||
-- Delete waypoints so they are re-initialized at the next spawn.
|
||||
@ -1617,7 +1624,7 @@ function FLIGHTGROUP:onafterFlightDead(From, Event, To)
|
||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||
|
||||
self:MissionCancel(mission)
|
||||
mission:FlightDead(self)
|
||||
mission:GroupDead(self)
|
||||
|
||||
end
|
||||
|
||||
@ -1639,7 +1646,7 @@ function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n)
|
||||
local allowed=true
|
||||
local trepeat=nil
|
||||
|
||||
if self:IsAlive() and (self:IsAirborne() or self:IsWaiting() or self:IsInbound() or self:IsHolding()) then
|
||||
if self:IsAlive() then -- and (self:IsAirborne() or self:IsWaiting() or self:IsInbound() or self:IsHolding()) then
|
||||
-- Alive & Airborne ==> Update route possible.
|
||||
self:T3(self.lid.."Update route possible. Group is ALIVE and AIRBORNE or WAITING or INBOUND or HOLDING")
|
||||
elseif self:IsDead() then
|
||||
@ -1648,7 +1655,7 @@ function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n)
|
||||
allowed=false
|
||||
else
|
||||
-- Not airborne yet. Try again in 1 sec.
|
||||
self:T3(self.lid.."FF update route denied ==> checking back in 5 sec")
|
||||
self:I(self.lid.."FF update route denied ==> checking back in 5 sec")
|
||||
trepeat=-5
|
||||
allowed=false
|
||||
end
|
||||
@ -1726,7 +1733,7 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
||||
-- Debug info.
|
||||
local hb=self.homebase and self.homebase:GetName() or "unknown"
|
||||
local db=self.destbase and self.destbase:GetName() or "unknown"
|
||||
self:T(self.lid..string.format("Updating route for WP #%d-%d homebase=%s destination=%s", n, #wp, hb, db))
|
||||
self:I(self.lid..string.format("Updating route for WP #%d-%d homebase=%s destination=%s", n, #wp, hb, db))
|
||||
|
||||
|
||||
if #wp>1 then
|
||||
@ -1740,7 +1747,10 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
||||
-- No waypoints left
|
||||
---
|
||||
|
||||
if self:IsAirborne() then
|
||||
env.info("FF no waypoints left ==> CheckGroupDone")
|
||||
self:_CheckGroupDone()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -2674,7 +2684,13 @@ function FLIGHTGROUP:GetHomebaseFromWaypoints()
|
||||
or wp.action==COORDINATE.WaypointAction.FromRunway then
|
||||
|
||||
-- Get airbase ID depending on airbase category.
|
||||
local airbaseID=wp.airdromeId or wp.helipadId
|
||||
local airbaseID=nil
|
||||
|
||||
if wp.airdromeId then
|
||||
airbaseID=wp.airdromeId
|
||||
else
|
||||
airbaseID=-wp.helipadId
|
||||
end
|
||||
|
||||
local airbase=AIRBASE:FindByID(airbaseID)
|
||||
|
||||
@ -2978,8 +2994,8 @@ function FLIGHTGROUP:InitWaypoints(waypoints)
|
||||
self.waypoints=waypoints or UTILS.DeepCopy(self.waypoints0)
|
||||
|
||||
-- Get home and destination airbases from waypoints.
|
||||
self.homebase=self:GetHomebaseFromWaypoints()
|
||||
self.destbase=self:GetDestinationFromWaypoints()
|
||||
self.homebase=self.homebase or self:GetHomebaseFromWaypoints()
|
||||
self.destbase=self.destbase or self:GetDestinationFromWaypoints()
|
||||
|
||||
-- Remove the landing waypoint. We use RTB for that. It makes adding new waypoints easier as we do not have to check if the last waypoint is the landing waypoint.
|
||||
if self.destbase then
|
||||
@ -2989,7 +3005,7 @@ function FLIGHTGROUP:InitWaypoints(waypoints)
|
||||
end
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Initializing %d waypoints. Homebase %s ==> %s Destination", #self.waypoints, self.homebase and self.homebase:GetName() or "unknown", self.destbase and self.destbase:GetName() or "uknown"))
|
||||
self:I(self.lid..string.format("Initializing %d waypoints. Homebase %s ==> %s Destination", #self.waypoints, self.homebase and self.homebase:GetName() or "unknown", self.destbase and self.destbase:GetName() or "uknown"))
|
||||
|
||||
-- Update route.
|
||||
if #self.waypoints>0 then
|
||||
@ -3001,7 +3017,7 @@ function FLIGHTGROUP:InitWaypoints(waypoints)
|
||||
|
||||
-- Update route (when airborne).
|
||||
--self:_CheckGroupDone(1)
|
||||
self:__UpdateRoute(-1)
|
||||
--self:__UpdateRoute(-1)
|
||||
end
|
||||
|
||||
return self
|
||||
@ -3062,8 +3078,8 @@ function FLIGHTGROUP:AddWaypoint(coordinate, wpnumber, speed, updateroute)
|
||||
|
||||
-- Update route.
|
||||
if updateroute==nil or updateroute==true then
|
||||
self:_CheckGroupDone(1)
|
||||
--self:__UpdateRoute(-1)
|
||||
--self:_CheckGroupDone(1)
|
||||
self:__UpdateRoute(-1)
|
||||
end
|
||||
|
||||
return wpnumber
|
||||
@ -3234,7 +3250,7 @@ function FLIGHTGROUP:GetParkingSpot(element, maxdist, airbase)
|
||||
|
||||
local coord=element.unit:GetCoordinate()
|
||||
|
||||
airbase=airbase or coord:GetClosestAirbase(nil, self:GetCoalition())
|
||||
airbase=airbase or self:GetClosestAirbase() --coord:GetClosestAirbase(nil, self:GetCoalition())
|
||||
|
||||
-- TODO: replace by airbase.parking if AIRBASE is updated.
|
||||
local parking=airbase:GetParkingSpotsTable()
|
||||
@ -3280,6 +3296,19 @@ function FLIGHTGROUP:GetParkingTime()
|
||||
return -1
|
||||
end
|
||||
|
||||
--- Search unoccupied parking spots at the airbase for all flight elements.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @return Wrapper.Airbase#AIRBASE Closest airbase
|
||||
function FLIGHTGROUP:GetClosestAirbase()
|
||||
|
||||
local group=self.group --Wrapper.Group#GROUP
|
||||
|
||||
local coord=group:GetCoordinate()
|
||||
local coalition=self:GetCoalition()
|
||||
|
||||
return coord:GetClosestAirbase(nil, coalition)
|
||||
end
|
||||
|
||||
--- Search unoccupied parking spots at the airbase for all flight elements.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param Wrapper.Airbase#AIRBASE airbase The airbase where we search for parking spots.
|
||||
@ -3563,8 +3592,6 @@ end
|
||||
-- OPTION FUNCTIONS
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
--- Set default TACAN parameters. AA TACANs are always on "Y" band.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param #number Channel TACAN channel.
|
||||
|
||||
@ -1776,7 +1776,7 @@ end
|
||||
-- @param #number N Total number of waypoints.
|
||||
function OPSGROUP:onafterPassingWaypoint(From, Event, To, n, N)
|
||||
local text=string.format("Group passed waypoint %d/%d", n, N)
|
||||
self:T(self.lid..text)
|
||||
self:I(self.lid..text)
|
||||
MESSAGE:New(text, 30, "DEBUG"):ToAllIf(self.Debug)
|
||||
|
||||
-- Get all waypoint tasks.
|
||||
|
||||
@ -508,7 +508,7 @@ function AIRBASE:GetID(unique)
|
||||
]]
|
||||
|
||||
if AirbaseName==self.AirbaseName then
|
||||
if airbaseCategory==Airbase.Category.SHIP then
|
||||
if airbaseCategory==Airbase.Category.SHIP or airbaseCategory==Airbase.Category.HELIPAD then
|
||||
-- Ships get a negative sign as their unit number might be the same as the ID of another airbase.
|
||||
return unique and -airbaseID or airbaseID
|
||||
else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user