mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
OPS
- FSM pseudo function cleanup - Fixed bug when mission is cancelled
This commit is contained in:
parent
a8a8dcff3f
commit
f0167b3e88
@ -410,7 +410,7 @@ do -- FSM
|
|||||||
Transition.To = To
|
Transition.To = To
|
||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
self:T3( Transition )
|
--self:T3( Transition )
|
||||||
|
|
||||||
self._Transitions[Transition] = Transition
|
self._Transitions[Transition] = Transition
|
||||||
self:_eventmap( self.Events, Transition )
|
self:_eventmap( self.Events, Transition )
|
||||||
@ -432,7 +432,7 @@ do -- FSM
|
|||||||
-- @param #table ReturnEvents A table indicating for which returned events of the SubFSM which Event must be triggered in the FSM.
|
-- @param #table ReturnEvents A table indicating for which returned events of the SubFSM which Event must be triggered in the FSM.
|
||||||
-- @return Core.Fsm#FSM_PROCESS The SubFSM.
|
-- @return Core.Fsm#FSM_PROCESS The SubFSM.
|
||||||
function FSM:AddProcess( From, Event, Process, ReturnEvents )
|
function FSM:AddProcess( From, Event, Process, ReturnEvents )
|
||||||
self:T3( { From, Event } )
|
--self:T3( { From, Event } )
|
||||||
|
|
||||||
local Sub = {}
|
local Sub = {}
|
||||||
Sub.From = From
|
Sub.From = From
|
||||||
@ -533,7 +533,7 @@ do -- FSM
|
|||||||
Process._Scores[State].ScoreText = ScoreText
|
Process._Scores[State].ScoreText = ScoreText
|
||||||
Process._Scores[State].Score = Score
|
Process._Scores[State].Score = Score
|
||||||
|
|
||||||
self:T3( Process._Scores )
|
--self:T3( Process._Scores )
|
||||||
|
|
||||||
return Process
|
return Process
|
||||||
end
|
end
|
||||||
@ -576,7 +576,7 @@ do -- FSM
|
|||||||
self[__Event] = self[__Event] or self:_delayed_transition(Event)
|
self[__Event] = self[__Event] or self:_delayed_transition(Event)
|
||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
self:T3( "Added methods: " .. Event .. ", " .. __Event )
|
--self:T3( "Added methods: " .. Event .. ", " .. __Event )
|
||||||
|
|
||||||
Events[Event] = self.Events[Event] or { map = {} }
|
Events[Event] = self.Events[Event] or { map = {} }
|
||||||
self:_add_to_map( Events[Event].map, EventStructure )
|
self:_add_to_map( Events[Event].map, EventStructure )
|
||||||
@ -791,7 +791,7 @@ do -- FSM
|
|||||||
return function( self, DelaySeconds, ... )
|
return function( self, DelaySeconds, ... )
|
||||||
|
|
||||||
-- Debug.
|
-- Debug.
|
||||||
self:T2( "Delayed Event: " .. EventName )
|
self:T3( "Delayed Event: " .. EventName )
|
||||||
|
|
||||||
local CallID = 0
|
local CallID = 0
|
||||||
if DelaySeconds ~= nil then
|
if DelaySeconds ~= nil then
|
||||||
@ -809,23 +809,23 @@ do -- FSM
|
|||||||
self._EventSchedules[EventName] = CallID
|
self._EventSchedules[EventName] = CallID
|
||||||
|
|
||||||
-- Debug output.
|
-- Debug output.
|
||||||
self:T2(string.format("NEGATIVE Event %s delayed by %.1f sec SCHEDULED with CallID=%s", EventName, DelaySeconds, tostring(CallID)))
|
self:T2(string.format("NEGATIVE Event %s delayed by %.3f sec SCHEDULED with CallID=%s", EventName, DelaySeconds, tostring(CallID)))
|
||||||
else
|
else
|
||||||
self:T2(string.format("NEGATIVE Event %s delayed by %.1f sec CANCELLED as we already have such an event in the queue.", EventName, DelaySeconds))
|
self:T2(string.format("NEGATIVE Event %s delayed by %.3f sec CANCELLED as we already have such an event in the queue.", EventName, DelaySeconds))
|
||||||
-- reschedule
|
-- reschedule
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
||||||
CallID = self.CallScheduler:Schedule( self, self._handler, { EventName, ... }, DelaySeconds or 1, nil, nil, nil, 4, true )
|
CallID = self.CallScheduler:Schedule( self, self._handler, { EventName, ... }, DelaySeconds or 1, nil, nil, nil, 4, true )
|
||||||
|
|
||||||
self:T2(string.format("Event %s delayed by %.1f sec SCHEDULED with CallID=%s", EventName, DelaySeconds, tostring(CallID)))
|
self:T2(string.format("Event %s delayed by %.3f sec SCHEDULED with CallID=%s", EventName, DelaySeconds, tostring(CallID)))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error( "FSM: An asynchronous event trigger requires a DelaySeconds parameter!!! This can be positive or negative! Sorry, but will not process this." )
|
error( "FSM: An asynchronous event trigger requires a DelaySeconds parameter!!! This can be positive or negative! Sorry, but will not process this." )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Debug.
|
-- Debug.
|
||||||
self:T3( { CallID = CallID } )
|
--self:T3( { CallID = CallID } )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -846,7 +846,7 @@ do -- FSM
|
|||||||
function FSM:_gosub( ParentFrom, ParentEvent )
|
function FSM:_gosub( ParentFrom, ParentEvent )
|
||||||
local fsmtable = {}
|
local fsmtable = {}
|
||||||
if self.subs[ParentFrom] and self.subs[ParentFrom][ParentEvent] then
|
if self.subs[ParentFrom] and self.subs[ParentFrom][ParentEvent] then
|
||||||
self:T3( { ParentFrom, ParentEvent, self.subs[ParentFrom], self.subs[ParentFrom][ParentEvent] } )
|
--self:T3( { ParentFrom, ParentEvent, self.subs[ParentFrom], self.subs[ParentFrom][ParentEvent] } )
|
||||||
return self.subs[ParentFrom][ParentEvent]
|
return self.subs[ParentFrom][ParentEvent]
|
||||||
else
|
else
|
||||||
return {}
|
return {}
|
||||||
@ -893,7 +893,7 @@ do -- FSM
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:T3( { Map, Event } )
|
--self:T3( { Map, Event } )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get current state.
|
--- Get current state.
|
||||||
@ -1150,7 +1150,7 @@ do -- FSM_PROCESS
|
|||||||
-- @param #FSM_PROCESS self
|
-- @param #FSM_PROCESS self
|
||||||
-- @return #FSM_PROCESS
|
-- @return #FSM_PROCESS
|
||||||
function FSM_PROCESS:Copy( Controllable, Task )
|
function FSM_PROCESS:Copy( Controllable, Task )
|
||||||
self:T3( { self:GetClassNameAndID() } )
|
--self:T3( { self:GetClassNameAndID() } )
|
||||||
|
|
||||||
|
|
||||||
local NewFsm = self:New( Controllable, Task ) -- Core.Fsm#FSM_PROCESS
|
local NewFsm = self:New( Controllable, Task ) -- Core.Fsm#FSM_PROCESS
|
||||||
@ -1176,13 +1176,13 @@ do -- FSM_PROCESS
|
|||||||
|
|
||||||
-- Copy End States
|
-- Copy End States
|
||||||
for EndStateID, EndState in pairs( self:GetEndStates() ) do
|
for EndStateID, EndState in pairs( self:GetEndStates() ) do
|
||||||
self:T3( EndState )
|
--self:T3( EndState )
|
||||||
NewFsm:AddEndState( EndState )
|
NewFsm:AddEndState( EndState )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Copy the score tables
|
-- Copy the score tables
|
||||||
for ScoreID, Score in pairs( self:GetScores() ) do
|
for ScoreID, Score in pairs( self:GetScores() ) do
|
||||||
self:T3( Score )
|
--self:T3( Score )
|
||||||
NewFsm:AddScore( ScoreID, Score.ScoreText, Score.Score )
|
NewFsm:AddScore( ScoreID, Score.ScoreText, Score.Score )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -94,7 +94,7 @@
|
|||||||
--
|
--
|
||||||
-- Once you created an AUFTRAG you can add it to the AIRWING with the :AddMission(mission) function.
|
-- Once you created an AUFTRAG you can add it to the AIRWING with the :AddMission(mission) function.
|
||||||
--
|
--
|
||||||
-- This mission will be put into the AIRWING queue. Once the mission start time is reached and all resources (airframes and pylons) are available, the mission is started.
|
-- This mission will be put into the AIRWING queue. Once the mission start time is reached and all resources (airframes and payloads) are available, the mission is started.
|
||||||
-- If the mission stop time is over (and the mission is not finished), it will be cancelled and removed from the queue. This applies also to mission that were not even
|
-- If the mission stop time is over (and the mission is not finished), it will be cancelled and removed from the queue. This applies also to mission that were not even
|
||||||
-- started.
|
-- started.
|
||||||
--
|
--
|
||||||
@ -116,7 +116,6 @@ AIRWING = {
|
|||||||
pointsCAP = {},
|
pointsCAP = {},
|
||||||
pointsTANKER = {},
|
pointsTANKER = {},
|
||||||
pointsAWACS = {},
|
pointsAWACS = {},
|
||||||
wingcommander = nil,
|
|
||||||
markpoints = false,
|
markpoints = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +143,7 @@ AIRWING = {
|
|||||||
|
|
||||||
--- AIRWING class version.
|
--- AIRWING class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
AIRWING.version="0.8.0"
|
AIRWING.version="0.9.0"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- ToDo list
|
-- ToDo list
|
||||||
@ -184,12 +183,7 @@ function AIRWING:New(warehousename, airwingname)
|
|||||||
-- Set some string id for output to DCS.log file.
|
-- Set some string id for output to DCS.log file.
|
||||||
self.lid=string.format("AIRWING %s | ", self.alias)
|
self.lid=string.format("AIRWING %s | ", self.alias)
|
||||||
|
|
||||||
-- Add FSM transitions.
|
|
||||||
-- From State --> Event --> To State
|
|
||||||
self:AddTransition("*", "SquadronAssetReturned", "*") -- Flight was spawned with a mission.
|
|
||||||
|
|
||||||
-- Defaults:
|
-- Defaults:
|
||||||
--self:SetVerbosity(0)
|
|
||||||
self.nflightsCAP=0
|
self.nflightsCAP=0
|
||||||
self.nflightsAWACS=0
|
self.nflightsAWACS=0
|
||||||
self.nflightsTANKERboom=0
|
self.nflightsTANKERboom=0
|
||||||
@ -198,6 +192,10 @@ function AIRWING:New(warehousename, airwingname)
|
|||||||
self.nflightsRescueHelo=0
|
self.nflightsRescueHelo=0
|
||||||
self.markpoints=false
|
self.markpoints=false
|
||||||
|
|
||||||
|
-- Add FSM transitions.
|
||||||
|
-- From State --> Event --> To State
|
||||||
|
self:AddTransition("*", "FlightOnMission", "*") -- A FLIGHTGROUP was send on a Mission (AUFTRAG).
|
||||||
|
|
||||||
------------------------
|
------------------------
|
||||||
--- Pseudo Functions ---
|
--- Pseudo Functions ---
|
||||||
------------------------
|
------------------------
|
||||||
@ -211,6 +209,7 @@ function AIRWING:New(warehousename, airwingname)
|
|||||||
-- @param #AIRWING self
|
-- @param #AIRWING self
|
||||||
-- @param #number delay Delay in seconds.
|
-- @param #number delay Delay in seconds.
|
||||||
|
|
||||||
|
|
||||||
--- Triggers the FSM event "Stop". Stops the AIRWING and all its event handlers.
|
--- Triggers the FSM event "Stop". Stops the AIRWING and all its event handlers.
|
||||||
-- @param #AIRWING self
|
-- @param #AIRWING self
|
||||||
|
|
||||||
@ -219,23 +218,28 @@ function AIRWING:New(warehousename, airwingname)
|
|||||||
-- @param #AIRWING self
|
-- @param #AIRWING self
|
||||||
-- @param #number delay Delay in seconds.
|
-- @param #number delay Delay in seconds.
|
||||||
|
|
||||||
--- On after "FlightOnMission" event. Triggered when an asset group starts a mission.
|
|
||||||
-- @function [parent=#AIRWING] OnAfterFlightOnMission
|
|
||||||
-- @param #AIRWING self
|
|
||||||
-- @param #string From The From state
|
|
||||||
-- @param #string Event The Event called
|
|
||||||
-- @param #string To The To state
|
|
||||||
-- @param Ops.FlightGroup#FLIGHTGROUP Flightgroup The Flightgroup on mission
|
|
||||||
-- @param Ops.Auftrag#AUFTRAG Mission The Auftrag of the Flightgroup
|
|
||||||
|
|
||||||
--- On after "AssetReturned" event. Triggered when an asset group returned to its airwing.
|
--- Triggers the FSM event "FlightOnMission".
|
||||||
-- @function [parent=#AIRWING] OnAfterAssetReturned
|
-- @function [parent=#AIRWING] FlightOnMission
|
||||||
-- @param #AIRWING self
|
-- @param #AIRWING self
|
||||||
-- @param #string From From state.
|
-- @param Ops.FlightGroup#FLIGHTGROUP FlightGroup The FLIGHTGROUP on mission.
|
||||||
-- @param #string Event Event.
|
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
||||||
-- @param #string To To state.
|
|
||||||
-- @param Ops.Squadron#SQUADRON Squadron The asset squadron.
|
--- Triggers the FSM event "FlightOnMission" after a delay.
|
||||||
-- @param Functional.Warehouse#WAREHOUSE.Assetitem Asset The asset that returned.
|
-- @function [parent=#AIRWING] __FlightOnMission
|
||||||
|
-- @param #AIRWING self
|
||||||
|
-- @param #number delay Delay in seconds.
|
||||||
|
-- @param Ops.FlightGroup#FLIGHTGROUP FlightGroup The FLIGHTGROUP on mission.
|
||||||
|
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
||||||
|
|
||||||
|
--- On after "FlightOnMission" event.
|
||||||
|
-- @function [parent=#AIRWING] OnAfterFlightOnMission
|
||||||
|
-- @param #AIRWING self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param Ops.FlightGroup#FLIGHTGROUP FlightGroup The FLIGHTGROUP on mission.
|
||||||
|
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -1092,16 +1096,16 @@ end
|
|||||||
-- FSM Events
|
-- FSM Events
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- On after "SquadAssetReturned" event. Triggered when an asset group returned to its airwing.
|
--- On after "FlightOnMission".
|
||||||
-- @param #AIRWING self
|
-- @param #AIRWING self
|
||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param Ops.Squadron#SQUADRON Squadron The asset squadron.
|
-- @param Ops.FlightGroup#FLIGHTGROUP ArmyGroup Ops army group on mission.
|
||||||
-- @param Functional.Warehouse#WAREHOUSE.Assetitem Asset The asset that returned.
|
-- @param Ops.Auftrag#AUFTRAG Mission The requested mission.
|
||||||
function AIRWING:onafterSquadAssetReturned(From, Event, To, Squadron, Asset)
|
function AIRWING:onafterFlightOnMission(From, Event, To, FlightGroup, Mission)
|
||||||
-- Debug message.
|
-- Debug info.
|
||||||
self:T(self.lid..string.format("Asset %s from squadron %s returned! asset.assignment=\"%s\"", Asset.spawngroupname, Squadron.name, tostring(Asset.assignment)))
|
self:T(self.lid..string.format("Group %s on %s mission %s", FlightGroup:GetName(), Mission:GetType(), Mission:GetName()))
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -513,7 +513,6 @@ function AUFTRAG:New(Type)
|
|||||||
self.status=AUFTRAG.Status.PLANNED
|
self.status=AUFTRAG.Status.PLANNED
|
||||||
|
|
||||||
-- Defaults
|
-- Defaults
|
||||||
--self:SetVerbosity(0)
|
|
||||||
self:SetName()
|
self:SetName()
|
||||||
self:SetPriority()
|
self:SetPriority()
|
||||||
self:SetTime()
|
self:SetTime()
|
||||||
@ -2552,10 +2551,13 @@ end
|
|||||||
-- @return #AUFTRAG self
|
-- @return #AUFTRAG self
|
||||||
function AUFTRAG:SetGroupStatus(opsgroup, status)
|
function AUFTRAG:SetGroupStatus(opsgroup, status)
|
||||||
|
|
||||||
-- Debug info.
|
-- Current status.
|
||||||
self:T(self.lid..string.format("Setting OPSGROUP %s to status %s", opsgroup and opsgroup.groupname or "nil", tostring(status)))
|
local oldstatus=self:GetGroupStatus(opsgroup)
|
||||||
|
|
||||||
if self:GetGroupStatus(opsgroup)==AUFTRAG.GroupStatus.CANCELLED and status==AUFTRAG.GroupStatus.DONE then
|
-- Debug info.
|
||||||
|
self:T(self.lid..string.format("Setting OPSGROUP %s to status %s-->%s", opsgroup and opsgroup.groupname or "nil", tostring(oldstatus), tostring(status)))
|
||||||
|
|
||||||
|
if oldstatus==AUFTRAG.GroupStatus.CANCELLED and status==AUFTRAG.GroupStatus.DONE then
|
||||||
-- Do not overwrite a CANCELLED status with a DONE status.
|
-- Do not overwrite a CANCELLED status with a DONE status.
|
||||||
else
|
else
|
||||||
local groupdata=self:GetGroupData(opsgroup)
|
local groupdata=self:GetGroupData(opsgroup)
|
||||||
@ -2566,12 +2568,18 @@ function AUFTRAG:SetGroupStatus(opsgroup, status)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Check if mission is NOT over.
|
||||||
|
local isNotOver=self:IsNotOver()
|
||||||
|
|
||||||
|
-- Check if all assigned groups are done.
|
||||||
|
local groupsDone=self:CheckGroupsDone()
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T2(self.lid..string.format("Setting flight %s status to %s. IsNotOver=%s CheckGroupsDone=%s", opsgroup.groupname, self:GetGroupStatus(opsgroup), tostring(self:IsNotOver()), tostring(self:CheckGroupsDone())))
|
self:T2(self.lid..string.format("Setting OPSGROUP %s status to %s. IsNotOver=%s CheckGroupsDone=%s", opsgroup.groupname, self:GetGroupStatus(opsgroup), tostring(self:IsNotOver()), tostring(self:CheckGroupsDone())))
|
||||||
|
|
||||||
-- Check if ALL flights are done with their mission.
|
-- Check if ALL flights are done with their mission.
|
||||||
if self:IsNotOver() and self:CheckGroupsDone() then
|
if isNotOver and groupsDone then
|
||||||
self:T3(self.lid.."All flights done ==> mission DONE!")
|
self:T3(self.lid.."All assigned OPSGROUPs done ==> mission DONE!")
|
||||||
self:Done()
|
self:Done()
|
||||||
else
|
else
|
||||||
self:T3(self.lid.."Mission NOT DONE yet!")
|
self:T3(self.lid.."Mission NOT DONE yet!")
|
||||||
@ -2747,6 +2755,7 @@ function AUFTRAG:CheckGroupsDone()
|
|||||||
if groupdata then
|
if groupdata then
|
||||||
if not (groupdata.status==AUFTRAG.GroupStatus.DONE or groupdata.status==AUFTRAG.GroupStatus.CANCELLED) then
|
if not (groupdata.status==AUFTRAG.GroupStatus.DONE or groupdata.status==AUFTRAG.GroupStatus.CANCELLED) then
|
||||||
-- At least this flight is not DONE or CANCELLED.
|
-- At least this flight is not DONE or CANCELLED.
|
||||||
|
self:T(self.lid..string.format("CheckGroupsDone: OPSGROUP %s is not DONE or CANCELLED but in state %s. Mission NOT DONE!", groupdata.opsgroup.groupname, groupdata.status))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2758,6 +2767,7 @@ function AUFTRAG:CheckGroupsDone()
|
|||||||
local status=self:GetLegionStatus(legion)
|
local status=self:GetLegionStatus(legion)
|
||||||
if not status==AUFTRAG.Status.CANCELLED then
|
if not status==AUFTRAG.Status.CANCELLED then
|
||||||
-- At least one LEGION has not CANCELLED.
|
-- At least one LEGION has not CANCELLED.
|
||||||
|
self:T(self.lid..string.format("CheckGroupsDone: LEGION %s is not CANCELLED but in state %s. Mission NOT DONE!", legion.alias, status))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2765,6 +2775,7 @@ function AUFTRAG:CheckGroupsDone()
|
|||||||
-- Check commander status.
|
-- Check commander status.
|
||||||
if self.commander then
|
if self.commander then
|
||||||
if not self.statusCommander==AUFTRAG.Status.CANCELLED then
|
if not self.statusCommander==AUFTRAG.Status.CANCELLED then
|
||||||
|
self:T(self.lid..string.format("CheckGroupsDone: COMMANDER is not CANCELLED but in state %s. Mission NOT DONE!", self.statusCommander))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2772,18 +2783,21 @@ function AUFTRAG:CheckGroupsDone()
|
|||||||
-- Check chief status.
|
-- Check chief status.
|
||||||
if self.chief then
|
if self.chief then
|
||||||
if not self.statusChief==AUFTRAG.Status.CANCELLED then
|
if not self.statusChief==AUFTRAG.Status.CANCELLED then
|
||||||
|
self:T(self.lid..string.format("CheckGroupsDone: CHIEF is not CANCELLED but in state %s. Mission NOT DONE!", self.statusChief))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- These are early stages, where we might not even have a opsgroup defined to be checked. If there were any groups, we checked above.
|
-- These are early stages, where we might not even have a opsgroup defined to be checked. If there were any groups, we checked above.
|
||||||
if self:IsPlanned() or self:IsQueued() or self:IsRequested() then
|
if self:IsPlanned() or self:IsQueued() or self:IsRequested() then
|
||||||
|
self:T(self.lid..string.format("CheckGroupsDone: Mission is still in state %s [FSM=%s] (PLANNED or QUEUED or REQUESTED). Mission NOT DONE!", self.status, self:GetState()))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- It could be that all flights were destroyed on the way to the mission execution waypoint.
|
-- It could be that all flights were destroyed on the way to the mission execution waypoint.
|
||||||
-- TODO: would be better to check if everybody is dead by now.
|
-- TODO: would be better to check if everybody is dead by now.
|
||||||
if self:IsStarted() and self:CountOpsGroups()==0 then
|
if self:IsStarted() and self:CountOpsGroups()==0 then
|
||||||
|
self:T(self.lid..string.format("CheckGroupsDone: Mission is STARTED state %s [FSM=%s] but count of alive OPSGROUP is zero. Mission DONE!", self.status, self:GetState()))
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -36,13 +36,13 @@ BRIGADE = {
|
|||||||
|
|
||||||
--- BRIGADE class version.
|
--- BRIGADE class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
BRIGADE.version="0.0.1"
|
BRIGADE.version="0.1.0"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- ToDo list
|
-- ToDo list
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- TODO: Add weapon range.
|
-- DONE: Add weapon range.
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Constructor
|
-- Constructor
|
||||||
@ -68,8 +68,53 @@ function BRIGADE:New(WarehouseName, BrigadeName)
|
|||||||
self.lid=string.format("BRIGADE %s | ", self.alias)
|
self.lid=string.format("BRIGADE %s | ", self.alias)
|
||||||
|
|
||||||
-- Add FSM transitions.
|
-- Add FSM transitions.
|
||||||
-- From State --> Event --> To State
|
-- From State --> Event --> To State
|
||||||
self:AddTransition("*", "PlatoonAssetReturned", "*") -- An asset returned (from a mission) to the Brigade warehouse.
|
self:AddTransition("*", "ArmyOnMission", "*") -- An ARMYGROUP was send on a Mission (AUFTRAG).
|
||||||
|
|
||||||
|
------------------------
|
||||||
|
--- Pseudo Functions ---
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
--- Triggers the FSM event "Start". Starts the BRIGADE. Initializes parameters and starts event handlers.
|
||||||
|
-- @function [parent=#BRIGADE] Start
|
||||||
|
-- @param #BRIGADE self
|
||||||
|
|
||||||
|
--- Triggers the FSM event "Start" after a delay. Starts the BRIGADE. Initializes parameters and starts event handlers.
|
||||||
|
-- @function [parent=#BRIGADE] __Start
|
||||||
|
-- @param #BRIGADE self
|
||||||
|
-- @param #number delay Delay in seconds.
|
||||||
|
|
||||||
|
|
||||||
|
--- Triggers the FSM event "Stop". Stops the BRIGADE and all its event handlers.
|
||||||
|
-- @param #BRIGADE self
|
||||||
|
|
||||||
|
--- Triggers the FSM event "Stop" after a delay. Stops the BRIGADE and all its event handlers.
|
||||||
|
-- @function [parent=#BRIGADE] __Stop
|
||||||
|
-- @param #BRIGADE self
|
||||||
|
-- @param #number delay Delay in seconds.
|
||||||
|
|
||||||
|
|
||||||
|
--- Triggers the FSM event "ArmyOnMission".
|
||||||
|
-- @function [parent=#BRIGADE] ArmyOnMission
|
||||||
|
-- @param #BRIGADE self
|
||||||
|
-- @param Ops.ArmyGroup#ARMYGROUP ArmyGroup The ARMYGROUP on mission.
|
||||||
|
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
||||||
|
|
||||||
|
--- Triggers the FSM event "ArmyOnMission" after a delay.
|
||||||
|
-- @function [parent=#BRIGADE] __ArmyOnMission
|
||||||
|
-- @param #BRIGADE self
|
||||||
|
-- @param #number delay Delay in seconds.
|
||||||
|
-- @param Ops.ArmyGroup#ARMYGROUP ArmyGroup The ARMYGROUP on mission.
|
||||||
|
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
||||||
|
|
||||||
|
--- On after "ArmyOnMission" event.
|
||||||
|
-- @function [parent=#BRIGADE] OnAfterArmyOnMission
|
||||||
|
-- @param #BRIGADE self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param Ops.ArmyGroup#ARMYGROUP ArmyGroup The ARMYGROUP on mission.
|
||||||
|
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -285,14 +330,8 @@ end
|
|||||||
-- @param Ops.ArmyGroup#ARMYGROUP ArmyGroup Ops army group on mission.
|
-- @param Ops.ArmyGroup#ARMYGROUP ArmyGroup Ops army group on mission.
|
||||||
-- @param Ops.Auftrag#AUFTRAG Mission The requested mission.
|
-- @param Ops.Auftrag#AUFTRAG Mission The requested mission.
|
||||||
function BRIGADE:onafterArmyOnMission(From, Event, To, ArmyGroup, Mission)
|
function BRIGADE:onafterArmyOnMission(From, Event, To, ArmyGroup, Mission)
|
||||||
local armygroup=ArmyGroup --Ops.ArmyGroup#ARMYGROUP
|
|
||||||
local mission=Mission --Ops.Auftrag#AUFTRAG
|
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T(self.lid..string.format("Group %s on %s mission %s", armygroup:GetName(), mission:GetType(), mission:GetName()))
|
self:T(self.lid..string.format("Group %s on %s mission %s", ArmyGroup:GetName(), Mission:GetType(), Mission:GetName()))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -152,6 +152,7 @@ function COHORT:New(TemplateGroupName, Ngroups, CohortName)
|
|||||||
-- @param #COHORT self
|
-- @param #COHORT self
|
||||||
-- @param #number delay Delay in seconds.
|
-- @param #number delay Delay in seconds.
|
||||||
|
|
||||||
|
|
||||||
--- Triggers the FSM event "Stop". Stops the COHORT and all its event handlers.
|
--- Triggers the FSM event "Stop". Stops the COHORT and all its event handlers.
|
||||||
-- @param #COHORT self
|
-- @param #COHORT self
|
||||||
|
|
||||||
@ -160,6 +161,7 @@ function COHORT:New(TemplateGroupName, Ngroups, CohortName)
|
|||||||
-- @param #COHORT self
|
-- @param #COHORT self
|
||||||
-- @param #number delay Delay in seconds.
|
-- @param #number delay Delay in seconds.
|
||||||
|
|
||||||
|
|
||||||
--- Triggers the FSM event "Status".
|
--- Triggers the FSM event "Status".
|
||||||
-- @function [parent=#COHORT] Status
|
-- @function [parent=#COHORT] Status
|
||||||
-- @param #COHORT self
|
-- @param #COHORT self
|
||||||
|
|||||||
@ -222,7 +222,8 @@ function INTEL:New(DetectionSet, Coalition, Alias)
|
|||||||
-- Add FSM transitions.
|
-- Add FSM transitions.
|
||||||
-- From State --> Event --> To State
|
-- From State --> Event --> To State
|
||||||
self:AddTransition("Stopped", "Start", "Running") -- Start FSM.
|
self:AddTransition("Stopped", "Start", "Running") -- Start FSM.
|
||||||
self:AddTransition("*", "Status", "*") -- INTEL status update
|
self:AddTransition("*", "Status", "*") -- INTEL status update.
|
||||||
|
self:AddTransition("*", "Stop", "Stopped") -- Stop FSM.
|
||||||
|
|
||||||
self:AddTransition("*", "Detect", "*") -- Start detection run. Not implemented yet!
|
self:AddTransition("*", "Detect", "*") -- Start detection run. Not implemented yet!
|
||||||
|
|
||||||
@ -231,7 +232,7 @@ function INTEL:New(DetectionSet, Coalition, Alias)
|
|||||||
|
|
||||||
self:AddTransition("*", "NewCluster", "*") -- New cluster has been detected.
|
self:AddTransition("*", "NewCluster", "*") -- New cluster has been detected.
|
||||||
self:AddTransition("*", "LostCluster", "*") -- Cluster could not be detected any more.
|
self:AddTransition("*", "LostCluster", "*") -- Cluster could not be detected any more.
|
||||||
self:AddTransition("*", "Stop", "Stopped")
|
|
||||||
|
|
||||||
-- Defaults
|
-- Defaults
|
||||||
self:SetForgetTime()
|
self:SetForgetTime()
|
||||||
|
|||||||
@ -42,14 +42,15 @@ LEGION = {
|
|||||||
|
|
||||||
--- LEGION class version.
|
--- LEGION class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
LEGION.version="0.0.1"
|
LEGION.version="0.1.0"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- ToDo list
|
-- ToDo list
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- TODO: A lot.
|
-- TODO: Create FLOTILLA class.
|
||||||
-- TODO: Make general so it can be inherited by AIRWING and BRIGADE classes.
|
-- TODO: OPS transport.
|
||||||
|
-- DONE: Make general so it can be inherited by AIRWING and BRIGADE classes.
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Constructor
|
-- Constructor
|
||||||
@ -74,22 +75,19 @@ function LEGION:New(WarehouseName, LegionName)
|
|||||||
-- Set some string id for output to DCS.log file.
|
-- Set some string id for output to DCS.log file.
|
||||||
self.lid=string.format("LEGION %s | ", self.alias)
|
self.lid=string.format("LEGION %s | ", self.alias)
|
||||||
|
|
||||||
-- Add FSM transitions.
|
|
||||||
-- From State --> Event --> To State
|
|
||||||
self:AddTransition("*", "MissionRequest", "*") -- Add a (mission) request to the warehouse.
|
|
||||||
self:AddTransition("*", "MissionCancel", "*") -- Cancel mission.
|
|
||||||
|
|
||||||
self:AddTransition("*", "TransportRequest", "*") -- Add a (mission) request to the warehouse.
|
|
||||||
|
|
||||||
self:AddTransition("*", "OpsOnMission", "*") -- An OPSGROUP was send on a Mission (AUFTRAG).
|
|
||||||
self:AddTransition("*", "FlightOnMission", "*") -- An OPSGROUP was send on a Mission (AUFTRAG).
|
|
||||||
self:AddTransition("*", "ArmyOnMission", "*") -- An OPSGROUP was send on a Mission (AUFTRAG).
|
|
||||||
self:AddTransition("*", "NavyOnMission", "*") -- An OPSGROUP was send on a Mission (AUFTRAG).
|
|
||||||
|
|
||||||
self:AddTransition("*", "AssetReturned", "*") -- An asset returned (from a mission) to the Legion warehouse.
|
|
||||||
|
|
||||||
-- Defaults:
|
-- Defaults:
|
||||||
-- TODO
|
-- TODO: What?
|
||||||
|
|
||||||
|
-- Add FSM transitions.
|
||||||
|
-- From State --> Event --> To State
|
||||||
|
self:AddTransition("*", "MissionRequest", "*") -- Add a (mission) request to the warehouse.
|
||||||
|
self:AddTransition("*", "MissionCancel", "*") -- Cancel mission.
|
||||||
|
|
||||||
|
self:AddTransition("*", "TransportRequest", "*") -- Add a (mission) request to the warehouse.
|
||||||
|
|
||||||
|
self:AddTransition("*", "OpsOnMission", "*") -- An OPSGROUP was send on a Mission (AUFTRAG).
|
||||||
|
|
||||||
|
self:AddTransition("*", "LegionAssetReturned", "*") -- An asset returned (from a mission) to the Legion warehouse.
|
||||||
|
|
||||||
------------------------
|
------------------------
|
||||||
--- Pseudo Functions ---
|
--- Pseudo Functions ---
|
||||||
@ -133,6 +131,92 @@ function LEGION:New(WarehouseName, LegionName)
|
|||||||
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
||||||
|
|
||||||
|
|
||||||
|
--- Triggers the FSM event "MissionRequest".
|
||||||
|
-- @function [parent=#LEGION] MissionRequest
|
||||||
|
-- @param #LEGION self
|
||||||
|
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
||||||
|
|
||||||
|
--- Triggers the FSM event "MissionRequest" after a delay.
|
||||||
|
-- @function [parent=#LEGION] __MissionRequest
|
||||||
|
-- @param #LEGION self
|
||||||
|
-- @param #number delay Delay in seconds.
|
||||||
|
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
||||||
|
|
||||||
|
--- On after "MissionRequest" event.
|
||||||
|
-- @function [parent=#LEGION] OnAfterMissionRequest
|
||||||
|
-- @param #LEGION self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
||||||
|
|
||||||
|
|
||||||
|
--- Triggers the FSM event "TransportRequest".
|
||||||
|
-- @function [parent=#LEGION] TransportRequest
|
||||||
|
-- @param #LEGION self
|
||||||
|
-- @param Ops.OpsTransport#OPSTRANSPORT Transport The transport.
|
||||||
|
|
||||||
|
--- Triggers the FSM event "TransportRequest" after a delay.
|
||||||
|
-- @function [parent=#LEGION] __TransportRequest
|
||||||
|
-- @param #LEGION self
|
||||||
|
-- @param #number delay Delay in seconds.
|
||||||
|
-- @param Ops.OpsTransport#OPSTRANSPORT Transport The transport.
|
||||||
|
|
||||||
|
--- On after "TransportRequest" event.
|
||||||
|
-- @function [parent=#LEGION] OnAfterTransportRequest
|
||||||
|
-- @param #LEGION self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param Ops.OpsTransport#OPSTRANSPORT Transport The transport.
|
||||||
|
|
||||||
|
|
||||||
|
--- Triggers the FSM event "OpsOnMission".
|
||||||
|
-- @function [parent=#LEGION] OpsOnMission
|
||||||
|
-- @param #LEGION self
|
||||||
|
-- @param Ops.OpsGroup#OPSGROUP OpsGroup The OPS group on mission.
|
||||||
|
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
||||||
|
|
||||||
|
--- Triggers the FSM event "OpsOnMission" after a delay.
|
||||||
|
-- @function [parent=#LEGION] __OpsOnMission
|
||||||
|
-- @param #LEGION self
|
||||||
|
-- @param #number delay Delay in seconds.
|
||||||
|
-- @param Ops.OpsGroup#OPSGROUP OpsGroup The OPS group on mission.
|
||||||
|
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
||||||
|
|
||||||
|
--- On after "OpsOnMission" event.
|
||||||
|
-- @function [parent=#LEGION] OnAfterOpsOnMission
|
||||||
|
-- @param #LEGION self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param Ops.OpsGroup#OPSGROUP OpsGroup The OPS group on mission.
|
||||||
|
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
||||||
|
|
||||||
|
|
||||||
|
--- Triggers the FSM event "LegionAssetReturned".
|
||||||
|
-- @function [parent=#LEGION] LegionAssetReturned
|
||||||
|
-- @param #LEGION self
|
||||||
|
-- @param Ops.Cohort#COHORT Cohort The cohort the asset belongs to.
|
||||||
|
-- @param Functional.Warehouse#WAREHOUSE.Assetitem Asset The asset that returned.
|
||||||
|
|
||||||
|
--- Triggers the FSM event "LegionAssetReturned" after a delay.
|
||||||
|
-- @function [parent=#LEGION] __LegionAssetReturned
|
||||||
|
-- @param #LEGION self
|
||||||
|
-- @param #number delay Delay in seconds.
|
||||||
|
-- @param Ops.Cohort#COHORT Cohort The cohort the asset belongs to.
|
||||||
|
-- @param Functional.Warehouse#WAREHOUSE.Assetitem Asset The asset that returned.
|
||||||
|
|
||||||
|
--- On after "LegionAssetReturned" event. Triggered when an asset group returned to its Legion.
|
||||||
|
-- @function [parent=#LEGION] OnAfterLegionAssetReturned
|
||||||
|
-- @param #LEGION self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param Ops.Cohort#COHORT Cohort The cohort the asset belongs to.
|
||||||
|
-- @param Functional.Warehouse#WAREHOUSE.Assetitem Asset The asset that returned.
|
||||||
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -773,8 +857,8 @@ function LEGION:onafterMissionCancel(From, Event, To, Mission)
|
|||||||
-- Set status to cancelled.
|
-- Set status to cancelled.
|
||||||
Mission:SetLegionStatus(self, AUFTRAG.Status.CANCELLED)
|
Mission:SetLegionStatus(self, AUFTRAG.Status.CANCELLED)
|
||||||
|
|
||||||
for _,_asset in pairs(Mission.assets) do
|
for i=#Mission.assets, 1, -1 do
|
||||||
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
local asset=Mission.assets[i] --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
|
|
||||||
-- Asset should belong to this legion.
|
-- Asset should belong to this legion.
|
||||||
if asset.wid==self.uid then
|
if asset.wid==self.uid then
|
||||||
@ -909,21 +993,21 @@ function LEGION:onafterNewAsset(From, Event, To, asset, assignment)
|
|||||||
---
|
---
|
||||||
|
|
||||||
-- Trigger event.
|
-- Trigger event.
|
||||||
self:AssetReturned(cohort, asset)
|
self:LegionAssetReturned(cohort, asset)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On after "AssetReturned" event. Triggered when an asset group returned to its legion.
|
--- On after "LegionAssetReturned" event. Triggered when an asset group returned to its legion.
|
||||||
-- @param #LEGION self
|
-- @param #LEGION self
|
||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param Ops.Cohort#COHORT Cohort The cohort the asset belongs to.
|
-- @param Ops.Cohort#COHORT Cohort The cohort the asset belongs to.
|
||||||
-- @param Functional.Warehouse#WAREHOUSE.Assetitem Asset The asset that returned.
|
-- @param Functional.Warehouse#WAREHOUSE.Assetitem Asset The asset that returned.
|
||||||
function LEGION:onafterAssetReturned(From, Event, To, Cohort, Asset)
|
function LEGION:onafterLegionAssetReturned(From, Event, To, Cohort, Asset)
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
self:T(self.lid..string.format("Asset %s from Cohort %s returned! asset.assignment=\"%s\"", Asset.spawngroupname, Cohort.name, tostring(Asset.assignment)))
|
self:T(self.lid..string.format("Asset %s from Cohort %s returned! asset.assignment=\"%s\"", Asset.spawngroupname, Cohort.name, tostring(Asset.assignment)))
|
||||||
|
|
||||||
@ -945,13 +1029,6 @@ function LEGION:onafterAssetReturned(From, Event, To, Cohort, Asset)
|
|||||||
-- Set timestamp.
|
-- Set timestamp.
|
||||||
Asset.Treturned=timer.getAbsTime()
|
Asset.Treturned=timer.getAbsTime()
|
||||||
|
|
||||||
if self:IsAirwing() then
|
|
||||||
-- Trigger airwing/squadron event.
|
|
||||||
self:SquadronAssetReturned(Cohort, Asset)
|
|
||||||
elseif self:IsBrigade() then
|
|
||||||
-- Trigger brigade/platoon event.
|
|
||||||
self:PlatoonAssetReturned(Cohort, Asset)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -1366,7 +1443,7 @@ function LEGION:CountPayloadsInStock(MissionTypes, UnitTypes, Payloads)
|
|||||||
|
|
||||||
local n=0
|
local n=0
|
||||||
for _,_payload in pairs(self.payloads or {}) do
|
for _,_payload in pairs(self.payloads or {}) do
|
||||||
local payload=_payload --#LEGION.Payload
|
local payload=_payload --Ops.Airwing#AIRWING.Payload
|
||||||
|
|
||||||
for _,MissionType in pairs(MissionTypes) do
|
for _,MissionType in pairs(MissionTypes) do
|
||||||
|
|
||||||
@ -1451,7 +1528,7 @@ function LEGION:CountAssetsWithPayloadsInStock(Payloads, MissionTypes, Attribute
|
|||||||
local cohort=_cohort --Ops.Cohort#COHORT
|
local cohort=_cohort --Ops.Cohort#COHORT
|
||||||
if Npayloads[cohort.aircrafttype]==nil then
|
if Npayloads[cohort.aircrafttype]==nil then
|
||||||
Npayloads[cohort.aircrafttype]=self:CountPayloadsInStock(MissionTypes, cohort.aircrafttype, Payloads)
|
Npayloads[cohort.aircrafttype]=self:CountPayloadsInStock(MissionTypes, cohort.aircrafttype, Payloads)
|
||||||
env.info(string.format("FF got Npayloads=%d for type=%s",Npayloads[cohort.aircrafttype], cohort.aircrafttype))
|
self:T3(self.lid..string.format("Got Npayloads=%d for type=%s",Npayloads[cohort.aircrafttype], cohort.aircrafttype))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1467,9 +1544,6 @@ function LEGION:CountAssetsWithPayloadsInStock(Payloads, MissionTypes, Attribute
|
|||||||
-- Only the smaller number of assets or paylods is really available.
|
-- Only the smaller number of assets or paylods is really available.
|
||||||
local m=math.min(n, p)
|
local m=math.min(n, p)
|
||||||
|
|
||||||
env.info("FF n="..n)
|
|
||||||
env.info("FF p="..p)
|
|
||||||
|
|
||||||
-- Add up what we have. Could also be zero.
|
-- Add up what we have. Could also be zero.
|
||||||
N=N+m
|
N=N+m
|
||||||
|
|
||||||
@ -1707,7 +1781,7 @@ end
|
|||||||
|
|
||||||
--- Get payload performance for a given type of misson type.
|
--- Get payload performance for a given type of misson type.
|
||||||
-- @param #LEGION self
|
-- @param #LEGION self
|
||||||
-- @param #LEGION.Payload Payload The payload table.
|
-- @param Ops.Airwing#AIRWING.Payload Payload The payload table.
|
||||||
-- @param #string MissionType Type of mission.
|
-- @param #string MissionType Type of mission.
|
||||||
-- @return #number Performance or -1.
|
-- @return #number Performance or -1.
|
||||||
function LEGION:GetPayloadPeformance(Payload, MissionType)
|
function LEGION:GetPayloadPeformance(Payload, MissionType)
|
||||||
@ -1730,7 +1804,7 @@ end
|
|||||||
|
|
||||||
--- Get mission types a payload can perform.
|
--- Get mission types a payload can perform.
|
||||||
-- @param #LEGION self
|
-- @param #LEGION self
|
||||||
-- @param #LEGION.Payload Payload The payload table.
|
-- @param Ops.Airwing#AIRWING.Payload Payload The payload table.
|
||||||
-- @return #table Mission types.
|
-- @return #table Mission types.
|
||||||
function LEGION:GetPayloadMissionTypes(Payload)
|
function LEGION:GetPayloadMissionTypes(Payload)
|
||||||
|
|
||||||
|
|||||||
@ -232,6 +232,8 @@ function OPSTRANSPORT:New(GroupSet, Pickupzone, Deployzone)
|
|||||||
self:AddTransition("*", "DeadCarrierGroup", "*")
|
self:AddTransition("*", "DeadCarrierGroup", "*")
|
||||||
self:AddTransition("*", "DeadCarrierAll", "*")
|
self:AddTransition("*", "DeadCarrierAll", "*")
|
||||||
|
|
||||||
|
--TODO: Psydofunctions
|
||||||
|
|
||||||
-- Call status update.
|
-- Call status update.
|
||||||
self:__Status(-1)
|
self:__Status(-1)
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ PLATOON = {
|
|||||||
|
|
||||||
--- PLATOON class version.
|
--- PLATOON class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
PLATOON.version="0.0.1"
|
PLATOON.version="0.1.0"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@ -170,7 +170,7 @@ function PLATOON:onafterStatus(From, Event, To)
|
|||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
|
|
||||||
-- Weapon data info.
|
-- Weapon data info.
|
||||||
if self.weaponData then
|
if self.verbose>=3 and self.weaponData then
|
||||||
local text="Weapon Data:"
|
local text="Weapon Data:"
|
||||||
for bit,_weapondata in pairs(self.weaponData) do
|
for bit,_weapondata in pairs(self.weaponData) do
|
||||||
local weapondata=_weapondata --Ops.OpsGroup#OPSGROUP.WeaponData
|
local weapondata=_weapondata --Ops.OpsGroup#OPSGROUP.WeaponData
|
||||||
|
|||||||
@ -103,9 +103,6 @@ function SQUADRON:New(TemplateGroupName, Ngroups, SquadronName)
|
|||||||
-- Everyone can ORBIT.
|
-- Everyone can ORBIT.
|
||||||
self:AddMissionCapability(AUFTRAG.Type.ORBIT)
|
self:AddMissionCapability(AUFTRAG.Type.ORBIT)
|
||||||
|
|
||||||
-- Aircraft type.
|
|
||||||
self.aircrafttype=self.templategroup:GetTypeName()
|
|
||||||
|
|
||||||
-- Refueling system.
|
-- Refueling system.
|
||||||
self.refuelSystem=select(2, self.templategroup:GetUnit(1):IsRefuelable())
|
self.refuelSystem=select(2, self.templategroup:GetUnit(1):IsRefuelable())
|
||||||
self.tankerSystem=select(2, self.templategroup:GetUnit(1):IsTanker())
|
self.tankerSystem=select(2, self.templategroup:GetUnit(1):IsTanker())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user