diff --git a/Moose Development/Moose/Modules.lua b/Moose Development/Moose/Modules.lua index 8118a3db0..3b5e08a74 100644 --- a/Moose Development/Moose/Modules.lua +++ b/Moose Development/Moose/Modules.lua @@ -97,6 +97,8 @@ __Moose.Include( 'Scripts/Moose/Ops/CSAR.lua' ) __Moose.Include( 'Scripts/Moose/Ops/CTLD.lua' ) __Moose.Include( 'Scripts/Moose/Ops/OpsZone.lua' ) __Moose.Include( 'Scripts/Moose/Ops/Chief.lua' ) +__Moose.Include( 'Scripts/Moose/Ops/Flotilla.lua' ) +__Moose.Include( 'Scripts/Moose/Ops/Fleet.lua' ) __Moose.Include( 'Scripts/Moose/AI/AI_Balancer.lua' ) __Moose.Include( 'Scripts/Moose/AI/AI_Air.lua' ) diff --git a/Moose Development/Moose/Ops/Brigade.lua b/Moose Development/Moose/Ops/Brigade.lua index 5fef5ac3d..b8e5d1c49 100644 --- a/Moose Development/Moose/Ops/Brigade.lua +++ b/Moose Development/Moose/Ops/Brigade.lua @@ -18,7 +18,7 @@ -- -- === -- @module Ops.Brigade --- @image OPS_Brigade.png +-- @image OPS_Brigade_.png --- BRIGADE class. diff --git a/Moose Development/Moose/Ops/Fleet.lua b/Moose Development/Moose/Ops/Fleet.lua new file mode 100644 index 000000000..e07d0d807 --- /dev/null +++ b/Moose Development/Moose/Ops/Fleet.lua @@ -0,0 +1,386 @@ +--- **Ops** - Fleet Warehouse. +-- +-- **Main Features:** +-- +-- * Manage flotillas +-- * Carry out ARTY and PATROLZONE missions (AUFTRAG) +-- +-- === +-- +-- ## Example Missions: +-- +-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/OPS%20-%20Fleet). +-- +-- === +-- +-- ### Author: **funkyfranky** +-- +-- === +-- @module Ops.Fleet +-- @image OPS_Fleet.png + + +--- FLEET class. +-- @type FLEET +-- @field #string ClassName Name of the class. +-- @field #number verbose Verbosity of output. +-- @field Core.Set#SET_ZONE retreatZones Retreat zone set. +-- @extends Ops.Legion#LEGION + +--- *I am not afraid of an Army of lions lead by a sheep; I am afraid of sheep lead by a lion* -- Alexander the Great +-- +-- === +-- +-- # The FLEET Concept +-- +-- A FLEET consists of one or multiple FLOTILLAs. These flotillas "live" in a WAREHOUSE that has a phyiscal struction (STATIC or UNIT) and can be captured or destroyed. +-- +-- +-- @field #FLEET +FLEET = { + ClassName = "FLEET", + verbose = 0, + rearmingZones = {}, + refuellingZones = {}, +} + +--- Supply Zone. +-- @type FLEET.SupplyZone +-- @field Core.Zone#ZONE zone The zone. +-- @field Ops.Auftrag#AUFTRAG mission Mission assigned to supply ammo or fuel. +-- @field #boolean markerOn If `true`, marker is on. +-- @field Wrapper.Marker#MARKER marker F10 marker. + +--- FLEET class version. +-- @field #string version +FLEET.version="0.0.1" + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- ToDo list +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +-- TODO: . +-- DONE: Add weapon range. + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- Constructor +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +--- Create a new FLEET class object. +-- @param #FLEET self +-- @param #string WarehouseName Name of the warehouse STATIC or UNIT object representing the warehouse. +-- @param #string FleetName Name of the fleet. +-- @return #FLEET self +function FLEET:New(WarehouseName, FleetName) + + -- Inherit everything from LEGION class. + local self=BASE:Inherit(self, LEGION:New(WarehouseName, FleetName)) -- #FLEET + + -- Nil check. + if not self then + BASE:E(string.format("ERROR: Could not find warehouse %s!", WarehouseName)) + return nil + end + + -- Set some string id for output to DCS.log file. + self.lid=string.format("FLEET %s | ", self.alias) + + -- Defaults + self:SetRetreatZones() + + -- Add FSM transitions. + -- From State --> Event --> To State + self:AddTransition("*", "NavyOnMission", "*") -- An NAVYGROUP was send on a Mission (AUFTRAG). + + ------------------------ + --- Pseudo Functions --- + ------------------------ + + --- Triggers the FSM event "Start". Starts the FLEET. Initializes parameters and starts event handlers. + -- @function [parent=#FLEET] Start + -- @param #FLEET self + + --- Triggers the FSM event "Start" after a delay. Starts the FLEET. Initializes parameters and starts event handlers. + -- @function [parent=#FLEET] __Start + -- @param #FLEET self + -- @param #number delay Delay in seconds. + + + --- Triggers the FSM event "Stop". Stops the FLEET and all its event handlers. + -- @param #FLEET self + + --- Triggers the FSM event "Stop" after a delay. Stops the FLEET and all its event handlers. + -- @function [parent=#FLEET] __Stop + -- @param #FLEET self + -- @param #number delay Delay in seconds. + + + --- Triggers the FSM event "NavyOnMission". + -- @function [parent=#FLEET] NavyOnMission + -- @param #FLEET self + -- @param Ops.NavyGroup#NAVYGROUP ArmyGroup The NAVYGROUP on mission. + -- @param Ops.Auftrag#AUFTRAG Mission The mission. + + --- Triggers the FSM event "NavyOnMission" after a delay. + -- @function [parent=#FLEET] __NavyOnMission + -- @param #FLEET self + -- @param #number delay Delay in seconds. + -- @param Ops.NavyGroup#NAVYGROUP ArmyGroup The NAVYGROUP on mission. + -- @param Ops.Auftrag#AUFTRAG Mission The mission. + + --- On after "NavyOnMission" event. + -- @function [parent=#FLEET] OnAfterNavyOnMission + -- @param #FLEET self + -- @param #string From From state. + -- @param #string Event Event. + -- @param #string To To state. + -- @param Ops.NavyGroup#NAVYGROUP NavyGroup The NAVYGROUP on mission. + -- @param Ops.Auftrag#AUFTRAG Mission The mission. + + return self +end + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- User Functions +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +--- Add a flotilla to the fleet. +-- @param #FLEET self +-- @param Ops.Flotilla#FLOTILLA Flotilla The flotilla object. +-- @return #FLEET self +function FLEET:AddFlotilla(Flotilla) + + -- Add flotilla to fleet. + table.insert(self.cohorts, Flotilla) + + -- Add assets to flotilla. + self:AddAssetToFlotilla(Flotilla, Flotilla.Ngroups) + + -- Set fleet of flotilla. + Flotilla:SetFleet(self) + + -- Start flotilla. + if Flotilla:IsStopped() then + Flotilla:Start() + end + + return self +end + +--- Add asset group(s) to flotilla. +-- @param #FLEET self +-- @param Ops.Flotilla#FLOTILLA Flotilla The flotilla object. +-- @param #number Nassets Number of asset groups to add. +-- @return #FLEET self +function FLEET:AddAssetToFlotilla(Flotilla, Nassets) + + if Flotilla then + + -- Get the template group of the flotilla. + local Group=GROUP:FindByName(Flotilla.templatename) + + if Group then + + -- Debug text. + local text=string.format("Adding asset %s to flotilla %s", Group:GetName(), Flotilla.name) + self:T(self.lid..text) + + -- Add assets to airwing warehouse. + self:AddAsset(Group, Nassets, nil, nil, nil, nil, Flotilla.skill, Flotilla.livery, Flotilla.name) + + else + self:E(self.lid.."ERROR: Group does not exist!") + end + + else + self:E(self.lid.."ERROR: Flotilla does not exit!") + end + + return self +end + +--- Define a set of retreat zones. +-- @param #FLEET self +-- @param Core.Set#SET_ZONE RetreatZoneSet Set of retreat zones. +-- @return #FLEET self +function FLEET:SetRetreatZones(RetreatZoneSet) + self.retreatZones=RetreatZoneSet or SET_ZONE:New() + return self +end + +--- Add a retreat zone. +-- @param #FLEET self +-- @param Core.Zone#ZONE RetreatZone Retreat zone. +-- @return #FLEET self +function FLEET:AddRetreatZone(RetreatZone) + self.retreatZones:AddZone(RetreatZone) + return self +end + +--- Get retreat zones. +-- @param #FLEET self +-- @return Core.Set#SET_ZONE Set of retreat zones. +function FLEET:GetRetreatZones() + return self.retreatZones +end + +--- Get flotilla by name. +-- @param #FLEET self +-- @param #string FlotillaName Name of the flotilla. +-- @return Ops.Flotilla#FLOTILLA The Flotilla object. +function FLEET:GetFlotilla(FlotillaName) + local flotilla=self:_GetCohort(FlotillaName) + return flotilla +end + +--- Get flotilla of an asset. +-- @param #FLEET self +-- @param Functional.Warehouse#WAREHOUSE.Assetitem Asset The flotilla asset. +-- @return Ops.Flotilla#FLOTILLA The flotilla object. +function FLEET:GetFlotillaOfAsset(Asset) + local flotilla=self:GetFlotilla(Asset.squadname) + return flotilla +end + +--- Remove asset from flotilla. +-- @param #FLEET self +-- @param Functional.Warehouse#WAREHOUSE.Assetitem Asset The flotilla asset. +function FLEET:RemoveAssetFromFlotilla(Asset) + local flotilla=self:GetFlotillaOfAsset(Asset) + if flotilla then + flotilla:DelAsset(Asset) + end +end + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- FSM Functions +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +--- Start FLEET FSM. +-- @param #FLEET self +function FLEET:onafterStart(From, Event, To) + + -- Start parent Warehouse. + self:GetParent(self, FLEET).onafterStart(self, From, Event, To) + + -- Info. + self:I(self.lid..string.format("Starting FLEET v%s", FLEET.version)) + +end + +--- Update status. +-- @param #FLEET self +function FLEET:onafterStatus(From, Event, To) + + -- Status of parent Warehouse. + self:GetParent(self).onafterStatus(self, From, Event, To) + + -- FSM state. + local fsmstate=self:GetState() + + ---------------- + -- Transport --- + ---------------- + + self:CheckTransportQueue() + + -------------- + -- Mission --- + -------------- + + -- Check if any missions should be cancelled. + self:CheckMissionQueue() + + ----------- + -- Info --- + ----------- + + -- General info: + if self.verbose>=1 then + + -- Count missions not over yet. + local Nmissions=self:CountMissionsInQueue() + + -- Asset count. + local Npq, Np, Nq=self:CountAssetsOnMission() + + -- Asset string. + local assets=string.format("%d [OnMission: Total=%d, Active=%d, Queued=%d]", self:CountAssets(), Npq, Np, Nq) + + -- Output. + local text=string.format("%s: Missions=%d, Flotillas=%d, Assets=%s", fsmstate, Nmissions, #self.cohorts, assets) + self:I(self.lid..text) + end + + ------------------ + -- Mission Info -- + ------------------ + if self.verbose>=2 then + local text=string.format("Missions Total=%d:", #self.missionqueue) + for i,_mission in pairs(self.missionqueue) do + local mission=_mission --Ops.Auftrag#AUFTRAG + + local prio=string.format("%d/%s", mission.prio, tostring(mission.importance)) ; if mission.urgent then prio=prio.." (!)" end + local assets=string.format("%d/%d", mission:CountOpsGroups(), mission.Nassets or 0) + local target=string.format("%d/%d Damage=%.1f", mission:CountMissionTargets(), mission:GetTargetInitialNumber(), mission:GetTargetDamage()) + + text=text..string.format("\n[%d] %s %s: Status=%s, Prio=%s, Assets=%s, Targets=%s", i, mission.name, mission.type, mission.status, prio, assets, target) + end + self:I(self.lid..text) + end + + -------------------- + -- Transport Info -- + -------------------- + if self.verbose>=2 then + local text=string.format("Transports Total=%d:", #self.transportqueue) + for i,_transport in pairs(self.transportqueue) do + local transport=_transport --Ops.OpsTransport#OPSTRANSPORT + + local prio=string.format("%d/%s", transport.prio, tostring(transport.importance)) ; if transport.urgent then prio=prio.." (!)" end + local carriers=string.format("Ncargo=%d/%d, Ncarriers=%d", transport.Ncargo, transport.Ndelivered, transport.Ncarrier) + + text=text..string.format("\n[%d] UID=%d: Status=%s, Prio=%s, Cargo: %s", i, transport.uid, transport:GetState(), prio, carriers) + end + self:I(self.lid..text) + end + + ------------------- + -- Flotilla Info -- + ------------------- + if self.verbose>=3 then + local text="Flotillas:" + for i,_flotilla in pairs(self.cohorts) do + local flotilla=_flotilla --Ops.Flotilla#FLOTILLA + + local callsign=flotilla.callsignName and UTILS.GetCallsignName(flotilla.callsignName) or "N/A" + local modex=flotilla.modex and flotilla.modex or -1 + local skill=flotilla.skill and tostring(flotilla.skill) or "N/A" + + -- Flotilla text. + text=text..string.format("\n* %s %s: %s*%d/%d, Callsign=%s, Modex=%d, Skill=%s", flotilla.name, flotilla:GetState(), flotilla.aircrafttype, flotilla:CountAssets(true), #flotilla.assets, callsign, modex, skill) + end + self:I(self.lid..text) + end + +end + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- FSM Functions +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +--- On after "NavyOnMission". +-- @param #FLEET self +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +-- @param Ops.ArmyGroup#ARMYGROUP ArmyGroup Ops army group on mission. +-- @param Ops.Auftrag#AUFTRAG Mission The requested mission. +function FLEET:onafterNavyOnMission(From, Event, To, NavyGroup, Mission) + -- Debug info. + self:T(self.lid..string.format("Group %s on %s mission %s", NavyGroup:GetName(), Mission:GetType(), Mission:GetName())) +end + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/Moose Development/Moose/Ops/Flotilla.lua b/Moose Development/Moose/Ops/Flotilla.lua new file mode 100644 index 000000000..44c41606c --- /dev/null +++ b/Moose Development/Moose/Ops/Flotilla.lua @@ -0,0 +1,203 @@ +--- **Ops** - Flotilla is a small naval group belonging to a fleet. +-- +-- **Main Features:** +-- +-- * Set parameters like livery, skill valid for all flotilla members. +-- * Define mission types, this flotilla can perform (see Ops.Auftrag#AUFTRAG). +-- * Pause/unpause flotilla operations. +-- +-- === +-- +-- ### Author: **funkyfranky** +-- +-- === +-- @module Ops.Flotilla +-- @image OPS_Flotilla.png + + +--- FLOTILLA class. +-- @type FLOTILLA +-- @field #string ClassName Name of the class. +-- @field #number verbose Verbosity level. +-- @field Ops.OpsGroup#OPSGROUP.WeaponData weaponData Weapon data table with key=BitType. +-- @extends Ops.Cohort#COHORT + +--- *Some cool cohort quote* -- Known Author +-- +-- === +-- +-- # The FLOTILLA Concept +-- +-- A FLOTILLA is essential part of a FLEET. +-- +-- +-- +-- @field #FLOTILLA +FLOTILLA = { + ClassName = "FLOTILLA", + verbose = 0, + weaponData = {}, +} + +--- FLOTILLA class version. +-- @field #string version +FLOTILLA.version="0.0.1" + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- TODO list +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +-- TODO: Add weapon data. + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- Constructor +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +--- Create a new FLOTILLA object and start the FSM. +-- @param #FLOTILLA self +-- @param #string TemplateGroupName Name of the template group. +-- @param #number Ngroups Number of asset groups of this flotilla. Default 3. +-- @param #string FlotillaName Name of the flotilla, e.g. "VFA-37". +-- @return #FLOTILLA self +function FLOTILLA:New(TemplateGroupName, Ngroups, FlotillaName) + + -- Inherit everything from COHORT class. + local self=BASE:Inherit(self, COHORT:New(TemplateGroupName, Ngroups, FlotillaName)) -- #FLOTILLA + + + return self +end + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- User functions +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + -- TODO: Flotilla specific user functions. + +--- Set fleet of this flotilla. +-- @param #FLOTILLA self +-- @param Ops.Fleet#FLEET Fleet The fleet. +-- @return #FLOTILLA self +function FLOTILLA:SetFleet(Fleet) + self.legion=Fleet + return self +end + +--- Get fleet of this flotilla. +-- @param #FLOTILLA self +-- @return Ops.Fleet#FLEET The fleet. +function FLOTILLA:GetFleet() + return self.legion +end + +--- Add a weapon range for ARTY auftrag. +-- @param #FLOTILLA self +-- @param #number RangeMin Minimum range in nautical miles. Default 0 NM. +-- @param #number RangeMax Maximum range in nautical miles. Default 10 NM. +-- @param #number BitType Bit mask of weapon type for which the given min/max ranges apply. Default is `ENUMS.WeaponFlag.Auto`, i.e. for all weapon types. +-- @return #FLOTILLA self +function FLOTILLA:AddWeaponRange(RangeMin, RangeMax, BitType) + + RangeMin=UTILS.NMToMeters(RangeMin or 0) + RangeMax=UTILS.NMToMeters(RangeMax or 10) + + local weapon={} --Ops.OpsGroup#OPSGROUP.WeaponData + + weapon.BitType=BitType or ENUMS.WeaponFlag.Auto + weapon.RangeMax=RangeMax + weapon.RangeMin=RangeMin + + self.weaponData=self.weaponData or {} + self.weaponData[tostring(weapon.BitType)]=weapon + + -- Debug info. + self:T(self.lid..string.format("Adding weapon data: Bit=%s, Rmin=%d m, Rmax=%d m", tostring(weapon.BitType), weapon.RangeMin, weapon.RangeMax)) + + if self.verbose>=2 then + local text="Weapon data:" + for _,_weapondata in pairs(self.weaponData) do + local weapondata=_weapondata + text=text..string.format("\n- Bit=%s, Rmin=%d m, Rmax=%d m", tostring(weapondata.BitType), weapondata.RangeMin, weapondata.RangeMax) + end + self:I(self.lid..text) + end + + return self +end + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- Start & Status +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +--- On after Start event. Starts the FLIGHTGROUP FSM and event handlers. +-- @param #FLOTILLA self +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +function FLOTILLA:onafterStart(From, Event, To) + + -- Short info. + local text=string.format("Starting %s v%s %s", self.ClassName, self.version, self.name) + self:I(self.lid..text) + + -- Start the status monitoring. + self:__Status(-1) +end + +--- On after "Status" event. +-- @param #FLOTILLA self +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +function FLOTILLA:onafterStatus(From, Event, To) + + if self.verbose>=1 then + + -- FSM state. + local fsmstate=self:GetState() + + local callsign=self.callsignName and UTILS.GetCallsignName(self.callsignName) or "N/A" + local modex=self.modex and self.modex or -1 + local skill=self.skill and tostring(self.skill) or "N/A" + + local NassetsTot=#self.assets + local NassetsInS=self:CountAssets(true) + local NassetsQP=0 ; local NassetsP=0 ; local NassetsQ=0 + if self.legion then + NassetsQP, NassetsP, NassetsQ=self.legion:CountAssetsOnMission(nil, self) + end + + -- Short info. + local text=string.format("%s [Type=%s, Call=%s, Modex=%d, Skill=%s]: Assets Total=%d, Stock=%d, Mission=%d [Active=%d, Queue=%d]", + fsmstate, self.aircrafttype, callsign, modex, skill, NassetsTot, NassetsInS, NassetsQP, NassetsP, NassetsQ) + self:T(self.lid..text) + + -- Weapon data info. + if self.verbose>=3 and self.weaponData then + local text="Weapon Data:" + for bit,_weapondata in pairs(self.weaponData) do + local weapondata=_weapondata --Ops.OpsGroup#OPSGROUP.WeaponData + text=text..string.format("\n- Bit=%s: Rmin=%.1f km, Rmax=%.1f km", bit, weapondata.RangeMin/1000, weapondata.RangeMax/1000) + end + self:I(self.lid..text) + end + + -- Check if group has detected any units. + self:_CheckAssetStatus() + + end + + if not self:IsStopped() then + self:__Status(-60) + end +end + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- Misc Functions +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +-- TODO: Misc functions. + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/Moose Development/Moose/Ops/Legion.lua b/Moose Development/Moose/Ops/Legion.lua index 132994e20..5cae17ab1 100644 --- a/Moose Development/Moose/Ops/Legion.lua +++ b/Moose Development/Moose/Ops/Legion.lua @@ -540,6 +540,13 @@ function LEGION:IsAirwing() return is end +--- Check if the FLEET class is calling. +-- @param #LEGION self +-- @return #boolean If true, this is a FLEET. +function LEGION:IsFleet() + local is=self.ClassName==FLEET.ClassName + return is +end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Start & Status @@ -1568,6 +1575,14 @@ function LEGION:_CreateFlightGroup(asset) opsgroup=ARMYGROUP:New(asset.spawngroupname) + elseif self:IsFleet() then + + --- + -- NAVYGROUP + --- + + opsgroup=NAVYGROUP:New(asset.spawngroupname) + else self:E(self.lid.."ERROR: not airwing or brigade!") end diff --git a/Moose Development/Moose/Ops/NavyGroup.lua b/Moose Development/Moose/Ops/NavyGroup.lua index b3226c04e..0e8dfd4b3 100644 --- a/Moose Development/Moose/Ops/NavyGroup.lua +++ b/Moose Development/Moose/Ops/NavyGroup.lua @@ -1506,6 +1506,67 @@ function NAVYGROUP:onafterDisengage(From, Event, To) self:_CheckGroupDone(1) end +--- On after "RTZ" event. +-- @param #NAVYGROUP self +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +-- @param Core.Zone#ZONE Zone The zone to return to. +-- @param #number Formation Formation of the group. +function NAVYGROUP:onafterRTZ(From, Event, To, Zone, Formation) + + -- Zone. + local zone=Zone or self.homezone + + if zone then + + if self:IsInZone(zone) then + self:Returned() + else + + -- Debug info. + self:T(self.lid..string.format("RTZ to Zone %s", zone:GetName())) + + local Coordinate=zone:GetRandomCoordinate() + + -- ID of current waypoint. + local uid=self:GetWaypointCurrentUID() + + -- Add waypoint after current. + local wp=self:AddWaypoint(Coordinate, nil, uid, Formation, true) + + -- Set if we want to resume route after reaching the detour waypoint. + wp.detour=0 + + end + + else + self:T(self.lid.."ERROR: No RTZ zone given!") + end + +end + + +--- On after "Returned" event. +-- @param #NAVYGROUP self +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +function NAVYGROUP:onafterReturned(From, Event, To) + + -- Debug info. + self:T(self.lid..string.format("Group returned")) + + if self.legion then + -- Debug info. + self:T(self.lid..string.format("Adding group back to warehouse stock")) + + -- Add asset back in 10 seconds. + self.legion:__AddAsset(10, self.group, 1) + end + +end + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Routing diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index 0ec1e2b9f..c714332a6 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -136,12 +136,10 @@ -- -- @extends Core.Fsm#FSM ---- *A small group of determined and like-minded people can change the course of history.* --- Mahatma Gandhi +--- *A small group of determined and like-minded people can change the course of history* -- Mahatma Gandhi -- -- === -- --- ![Banner Image](..\Presentations\OPS\OpsGroup\_Main.png) --- -- # The OPSGROUP Concept -- -- The OPSGROUP class contains common functions used by other classes such as FLIGHTGROUP, NAVYGROUP and ARMYGROUP. @@ -9081,7 +9079,11 @@ function OPSGROUP:_CheckGroupDone(delay) if self.legion then self:T(self.lid..string.format("Passed final WP, adinfinitum=FALSE, LEGION set ==> RTZ")) - self:RTZ(self.legion.spawnzone) + if self.isArmygroup then + self:RTZ(self.legion.spawnzone) + elseif self.isNavygroup then + self:RTZ(self.legion.portzone) + end else diff --git a/Moose Setup/Moose.files b/Moose Setup/Moose.files index 0cfda0dcf..33a49c594 100644 --- a/Moose Setup/Moose.files +++ b/Moose Setup/Moose.files @@ -84,9 +84,11 @@ Ops/NavyGroup.lua Ops/Cohort.lua Ops/Squadron.lua Ops/Platoon.lua +Ops/Flotilla.lua Ops/Legion.lua Ops/AirWing.lua Ops/Brigade.lua +Ops/Fleet.lua Ops/Intelligence.lua Ops/Commander.lua Ops/Chief.lua