diff --git a/Moose Development/Moose/Ops/AirWing.lua b/Moose Development/Moose/Ops/AirWing.lua index 169cd0bce..f61bf12d8 100644 --- a/Moose Development/Moose/Ops/AirWing.lua +++ b/Moose Development/Moose/Ops/AirWing.lua @@ -557,17 +557,8 @@ end -- @param #string SquadronName Name of the squadron, e.g. "VFA-37". -- @return Ops.Squadron#SQUADRON The squadron object. function AIRWING:GetSquadron(SquadronName) - - for _,_squadron in pairs(self.cohorts) do - local squadron=_squadron --Ops.Squadron#SQUADRON - - if squadron.name==SquadronName then - return squadron - end - - end - - return nil + local squad=self:_GetCohort(SquadronName) + return squad end --- Get squadron of an asset. diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index 2699cb668..8a6ba8098 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -454,12 +454,12 @@ AUFTRAG.version="0.7.1" -- TODO list ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- DONE: Option to assign a specific payload for the mission (requires an AIRWING). -- TODO: Mission success options damaged, destroyed. --- TODO: Recon mission. What input? Set of coordinates? --- NOPE: Clone mission. How? Deepcopy? ==> Create a new auftrag. -- TODO: F10 marker to create new missions. -- TODO: Add recovery tanker mission for boat ops. +-- DONE: Option to assign a specific payload for the mission (requires an AIRWING). +-- NOPE: Clone mission. How? Deepcopy? ==> Create a new auftrag. +-- DONE: Recon mission. What input? Set of coordinates? -- DONE: Option to assign mission to specific squadrons (requires an AIRWING). -- DONE: Add mission start conditions. -- DONE: Add rescue helo mission for boat ops. @@ -1877,6 +1877,21 @@ function AUFTRAG:AddConditionPush(ConditionFunction, ...) return self end +--- Assign a legion cohort to the mission. Only these cohorts will be considered for the job. +-- @param #AUFTRAG self +-- @param Ops.Cohort#COHORT Cohort The cohort. +-- @return #AUFTRAG self +function AUFTRAG:_AssignCohort(Cohort) + + self.squadrons=self.squadrons or {} + + self:T3(self.lid..string.format("Assigning cohort %s", tostring(Cohort.name))) + table.insert(self.squadrons, Cohort) + + + return self +end + --- Assign airwing squadron(s) to the mission. Only these squads will be considered for the job. -- @param #AUFTRAG self @@ -1887,9 +1902,8 @@ function AUFTRAG:AssignSquadrons(Squadrons) for _,_squad in pairs(Squadrons) do local squadron=_squad --Ops.Squadron#SQUADRON self:I(self.lid..string.format("Assigning squadron %s", tostring(squadron.name))) + self:_AssignCohort(squadron) end - - self.squadrons=Squadrons return self end diff --git a/Moose Development/Moose/Ops/Brigade.lua b/Moose Development/Moose/Ops/Brigade.lua index 5a6c96c09..d12483cf6 100644 --- a/Moose Development/Moose/Ops/Brigade.lua +++ b/Moose Development/Moose/Ops/Brigade.lua @@ -142,9 +142,7 @@ end -- @param #string PlatoonName Name of the platoon. -- @return Ops.Platoon#PLATOON The Platoon object. function BRIGADE:GetPlatoon(PlatoonName) - local platoon=self:_GetCohort(PlatoonName) - return platoon end @@ -152,7 +150,7 @@ end -- @param #BRIGADE self -- @param Ops.Warehouse#WAREHOUSE.Assetitem Asset The platoon asset. -- @return Ops.Platoon#PLATOON The platoon object. -function BRIGADE:GetSquadronOfAsset(Asset) +function BRIGADE:GetPlatoonOfAsset(Asset) local platoon=self:GetPlatoon(Asset.squadname) return platoon end @@ -160,8 +158,8 @@ end --- Remove asset from squadron. -- @param #BRIGADE self -- @param #BRIGADE.SquadronAsset Asset The squad asset. -function BRIGADE:RemoveAssetFromSquadron(Asset) - local squad=self:GetSquadronOfAsset(Asset) +function BRIGADE:RemoveAssetFromPlatoon(Asset) + local squad=self:GetPlatoonOfAsset(Asset) if squad then squad:DelAsset(Asset) end diff --git a/Moose Development/Moose/Ops/Cohort.lua b/Moose Development/Moose/Ops/Cohort.lua index 3b88595b1..e6e04cc93 100644 --- a/Moose Development/Moose/Ops/Cohort.lua +++ b/Moose Development/Moose/Ops/Cohort.lua @@ -2,10 +2,10 @@ -- -- **Main Features:** -- --- * Set parameters like livery, skill valid for all platoon members. +-- * Set parameters like livery, skill valid for all cohort members. -- * Define modex and callsigns. --- * Define mission types, this platoon can perform (see Ops.Auftrag#AUFTRAG). --- * Pause/unpause platoon operations. +-- * Define mission types, this cohort can perform (see Ops.Auftrag#AUFTRAG). +-- * Pause/unpause cohort operations. -- -- === -- @@ -19,21 +19,21 @@ -- @field #string ClassName Name of the class. -- @field #number verbose Verbosity level. -- @field #string lid Class id string for output to DCS log file. --- @field #string name Name of the platoon. +-- @field #string name Name of the cohort. -- @field #string templatename Name of the template group. --- @field #string aircrafttype Type of the airframe the platoon is using. +-- @field #string aircrafttype Type of the units the cohort is using. -- @field Wrapper.Group#GROUP templategroup Template group. -- @field #table assets Cohort assets. --- @field #table missiontypes Capabilities (mission types and performances) of the platoon. +-- @field #table missiontypes Capabilities (mission types and performances) of the cohort. -- @field #number maintenancetime Time in seconds needed for maintenance of a returned flight. -- @field #number repairtime Time in seconds for each --- @field #string livery Livery of the platoon. --- @field #number skill Skill of platoon members. +-- @field #string livery Livery of the cohort. +-- @field #number skill Skill of cohort members. -- @field Ops.Legion#LEGION legion The LEGION object the cohort belongs to. --- @field #number Ngroups Number of asset flight groups this platoon has. +-- @field #number Ngroups Number of asset OPS groups this cohort has. -- @field #number engageRange Mission range in meters. --- @field #string attribute Generalized attribute of the platoon template group. --- @field #table tacanChannel List of TACAN channels available to the platoon. +-- @field #string attribute Generalized attribute of the cohort template group. +-- @field #table tacanChannel List of TACAN channels available to the cohort. -- @field #number radioFreq Radio frequency in MHz the cohort uses. -- @field #number radioModu Radio modulation the cohort uses. -- @field #table tacanChannel List of TACAN channels available to the cohort. @@ -72,7 +72,7 @@ COHORT = { --- COHORT class version. -- @field #string version -COHORT.version="0.0.1" +COHORT.version="0.0.2" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -88,8 +88,8 @@ COHORT.version="0.0.1" --- Create a new COHORT object and start the FSM. -- @param #COHORT self -- @param #string TemplateGroupName Name of the template group. --- @param #number Ngroups Number of asset groups of this platoon. Default 3. --- @param #string CohortName Name of the platoon, e.g. "VFA-37". +-- @param #number Ngroups Number of asset groups of this Cohort. Default 3. +-- @param #string CohortName Name of the cohort. -- @return #COHORT self function COHORT:New(TemplateGroupName, Ngroups, CohortName) @@ -133,10 +133,10 @@ function COHORT:New(TemplateGroupName, Ngroups, CohortName) self:AddTransition("Stopped", "Start", "OnDuty") -- Start FSM. self:AddTransition("*", "Status", "*") -- Status update. - self:AddTransition("OnDuty", "Pause", "Paused") -- Pause platoon. - self:AddTransition("Paused", "Unpause", "OnDuty") -- Unpause platoon. + self:AddTransition("OnDuty", "Pause", "Paused") -- Pause cohort. + self:AddTransition("Paused", "Unpause", "OnDuty") -- Unpause cohort. - self:AddTransition("*", "Stop", "Stopped") -- Stop platoon. + self:AddTransition("*", "Stop", "Stopped") -- Stop cohort. ------------------------ @@ -176,7 +176,7 @@ end -- User functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---- Set livery painted on all platoon aircraft. +--- Set livery painted on all cohort units. -- Note that the livery name in general is different from the name shown in the mission editor. -- -- Valid names are the names of the **livery directories**. Check out the folder in your DCS installation for: @@ -196,10 +196,10 @@ function COHORT:SetLivery(LiveryName) return self end ---- Set skill level of all platoon team members. +--- Set skill level of all cohort team members. -- @param #COHORT self -- @param #string Skill Skill of all flights. --- @usage myplatoon:SetSkill(AI.Skill.EXCELLENT) +-- @usage mycohort:SetSkill(AI.Skill.EXCELLENT) -- @return #COHORT self function COHORT:SetSkill(Skill) self.skill=Skill @@ -230,7 +230,6 @@ end -- @param #COHORT self -- @param #number Frequency Radio frequency in MHz. Default 251 MHz. -- @param #number Modulation Radio modulation. Default 0=AM. --- @usage myplatoon:SetSkill(AI.Skill.EXCELLENT) -- @return #COHORT self function COHORT:SetRadio(Frequency, Modulation) self.radioFreq=Frequency or 251 @@ -249,7 +248,7 @@ function COHORT:SetGrouping(nunits) return self end ---- Set mission types this platoon is able to perform. +--- Set mission types this cohort is able to perform. -- @param #COHORT self -- @param #table MissionTypes Table of mission types. Can also be passed as a #string if only one type. -- @param #number Performance Performance describing how good this mission can be performed. Higher is better. Default 50. Max 100. @@ -286,7 +285,7 @@ function COHORT:AddMissionCapability(MissionTypes, Performance) return self end ---- Get mission types this platoon is able to perform. +--- Get mission types this cohort is able to perform. -- @param #COHORT self -- @return #table Table of mission types. Could be empty {}. function COHORT:GetMissionTypes() @@ -301,7 +300,7 @@ function COHORT:GetMissionTypes() return missiontypes end ---- Get mission capabilities of this platoon. +--- Get mission capabilities of this cohort. -- @param #COHORT self -- @return #table Table of mission capabilities. function COHORT:GetMissionCapabilities() @@ -324,7 +323,7 @@ function COHORT:GetMissionPeformance(MissionType) return -1 end ---- Set max mission range. Only missions in a circle of this radius around the platoon airbase are executed. +--- Set max mission range. Only missions in a circle of this radius around the cohort base are executed. -- @param #COHORT self -- @param #number Range Range in NM. Default 100 NM. -- @return #COHORT self @@ -409,9 +408,9 @@ function COHORT:DelGroup(GroupName) return self end ---- Get name of the platoon +--- Get name of the cohort. -- @param #COHORT self --- @return #string Name of the platoon. +-- @return #string Name of the cohort. function COHORT:GetName() return self.name end @@ -485,7 +484,7 @@ function COHORT:GetModex(Asset) end ---- Add TACAN channels to the platoon. Note that channels can only range from 1 to 126. +--- Add TACAN channels to the cohort. Note that channels can only range from 1 to 126. -- @param #COHORT self -- @param #number ChannelMin Channel. -- @param #number ChannelMax Channel. @@ -542,21 +541,21 @@ function COHORT:ReturnTacan(channel) self.tacanChannel[channel]=true end ---- Check if platoon is "OnDuty". +--- Check if cohort is "OnDuty". -- @param #COHORT self -- @return #boolean If true, squdron is in state "OnDuty". function COHORT:IsOnDuty() return self:Is("OnDuty") end ---- Check if platoon is "Stopped". +--- Check if cohort is "Stopped". -- @param #COHORT self -- @return #boolean If true, squdron is in state "Stopped". function COHORT:IsStopped() return self:Is("Stopped") end ---- Check if platoon is "Paused". +--- Check if cohort is "Paused". -- @param #COHORT self -- @return #boolean If true, squdron is in state "Paused". function COHORT:IsPaused() @@ -700,7 +699,7 @@ end -- Misc Functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---- Check if there is a platoon that can execute a given mission. +--- Check if there is a cohort that can execute a given mission. -- We check the mission type, the refuelling system, engagement range -- @param #COHORT self -- @param Ops.Auftrag#AUFTRAG Mission The mission. @@ -968,7 +967,7 @@ function COHORT:CheckMissionCapability(MissionTypes, Capabilities) return false end ---- Check if the platoon attribute matches the given attribute(s). +--- Check if the cohort attribute matches the given attribute(s). -- @param #COHORT self -- @param #table Attributes The requested attributes. See `WAREHOUSE.Attribute` enum. Can also be passed as a single attribute `#string`. -- @return #boolean If true, the cohort has the requested attribute. diff --git a/Moose Development/Moose/Ops/Legion.lua b/Moose Development/Moose/Ops/Legion.lua index b7f31dfbb..c626d1829 100644 --- a/Moose Development/Moose/Ops/Legion.lua +++ b/Moose Development/Moose/Ops/Legion.lua @@ -183,7 +183,7 @@ end --- Get cohort of an asset. -- @param #LEGION self --- @param Functional.Warehouse#WAREHOUSE.Assetitem Asset The squadron asset. +-- @param Functional.Warehouse#WAREHOUSE.Assetitem Asset The asset. -- @return Ops.Cohort#COHORT The Cohort object. function LEGION:_GetCohortOfAsset(Asset) local cohort=self:_GetCohort(Asset.squadname) @@ -392,8 +392,8 @@ function LEGION:CalculateAssetMissionScore(asset, Mission, includePayload) end -- Add mission performance to score. - local squad=self:_GetCohortOfAsset(asset) - local missionperformance=squad:GetMissionPeformance(Mission.type) + local cohort=self:_GetCohortOfAsset(asset) + local missionperformance=cohort:GetMissionPeformance(Mission.type) score=score+missionperformance -- Add payload performance to score. @@ -685,14 +685,14 @@ function LEGION:onafterNewAsset(From, Event, To, asset, assignment) -- Set spawn group name. This has to include "AID-" for warehouse. asset.spawngroupname=string.format("%s_AID-%d", cohort.name, asset.uid) - -- Add asset to squadron. + -- Add asset to cohort. cohort:AddAsset(asset) -- TODO --asset.terminalType=AIRBASE.TerminalType.OpenBig else - --env.info("FF squad asset returned") + --env.info("FF cohort asset returned") self:AssetReturned(cohort, asset) end @@ -730,8 +730,10 @@ function LEGION:onafterAssetReturned(From, Event, To, Cohort, Asset) 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 @@ -751,10 +753,10 @@ function LEGION:onafterAssetSpawned(From, Event, To, group, asset, request) -- Call parent warehouse function first. self:GetParent(self, LEGION).onafterAssetSpawned(self, From, Event, To, group, asset, request) - -- Get the SQUADRON of the asset. + -- Get the COHORT of the asset. local cohort=self:_GetCohortOfAsset(asset) - -- Check if we have a squadron or if this was some other request. + -- Check if we have a cohort or if this was some other request. if cohort then -- Create a flight group. @@ -774,7 +776,7 @@ function LEGION:onafterAssetSpawned(From, Event, To, group, asset, request) asset.Treturned=nil --- - -- Squadron + -- Cohort --- -- Get TACAN channel. @@ -857,7 +859,7 @@ function LEGION:onafterAssetDead(From, Event, To, asset, request) -- Remove asset from squadron same end ---- On after "Destroyed" event. Remove assets from cohorts. Stop squadrons. +--- On after "Destroyed" event. Remove assets from cohorts. Stop cohorts. -- @param #LEGION self -- @param #string From From state. -- @param #string Event Event. @@ -959,10 +961,10 @@ function LEGION:_CreateFlightGroup(asset) self:E(self.lid.."ERROR: not airwing or brigade!") end - -- Set airwing. + -- Set legion. flightgroup:_SetLegion(self) - -- Set squadron. + -- Set cohort. flightgroup.cohort=self:_GetCohortOfAsset(asset) -- Set home base. @@ -1153,9 +1155,9 @@ function LEGION:CountAssets(InStock, MissionTypes, Attributes) local N=0 - for _,_squad in pairs(self.cohorts) do - local squad=_squad --Ops.Squadron#SQUADRON - N=N+squad:CountAssets(InStock, MissionTypes, Attributes) + for _,_cohort in pairs(self.cohorts) do + local cohort=_cohort --Ops.Cohort#COHORT + N=N+cohort:CountAssets(InStock, MissionTypes, Attributes) end return N @@ -1164,11 +1166,11 @@ end --- Count assets on mission. -- @param #LEGION self -- @param #table MissionTypes Types on mission to be checked. Default all. --- @param Ops.Squadron#SQUADRON Squadron Only count assets of this squadron. Default count assets of all squadrons. +-- @param Ops.Cohort#COHORT Cohort Only count assets of this cohort. Default count assets of all cohorts. -- @return #number Number of pending and queued assets. -- @return #number Number of pending assets. -- @return #number Number of queued assets. -function LEGION:CountAssetsOnMission(MissionTypes, Squadron) +function LEGION:CountAssetsOnMission(MissionTypes, Cohort) local Nq=0 local Np=0 @@ -1182,7 +1184,7 @@ function LEGION:CountAssetsOnMission(MissionTypes, Squadron) for _,_asset in pairs(mission.assets or {}) do local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem - if Squadron==nil or Squadron.name==asset.squadname then + if Cohort==nil or Cohort.name==asset.squadname then local request, isqueued=self:GetRequestByID(mission.requestID) @@ -1232,28 +1234,28 @@ end --- Get the aircraft types of this airwing. -- @param #LEGION self -- @param #boolean onlyactive Count only the active ones. --- @param #table squadrons Table of squadrons. Default all. +-- @param #table cohorts Table of cohorts. Default all. -- @return #table Table of unit types. -function LEGION:GetAircraftTypes(onlyactive, squadrons) +function LEGION:GetAircraftTypes(onlyactive, cohorts) -- Get all unit types that can do the job. local unittypes={} - -- Loop over all squadrons. - for _,_squadron in pairs(squadrons or self.cohorts) do - local squadron=_squadron --Ops.Squadron#SQUADRON + -- Loop over all cohorts. + for _,_cohort in pairs(cohorts or self.cohorts) do + local cohort=_cohort --Ops.Cohort#COHORT - if (not onlyactive) or squadron:IsOnDuty() then + if (not onlyactive) or cohort:IsOnDuty() then local gotit=false for _,unittype in pairs(unittypes) do - if squadron.aircrafttype==unittype then + if cohort.aircrafttype==unittype then gotit=true break end end if not gotit then - table.insert(unittypes, squadron.aircrafttype) + table.insert(unittypes, cohort.aircrafttype) end end @@ -1274,10 +1276,10 @@ function LEGION:CanMission(Mission) local Assets={} -- Squadrons for the job. If user assigned to mission or simply all. - local squadrons=Mission.squadrons or self.cohorts + local cohorts=Mission.squadrons or self.cohorts -- Get aircraft unit types for the job. - local unittypes=self:GetAircraftTypes(true, squadrons) + local unittypes=self:GetAircraftTypes(true, cohorts) -- Count all payloads in stock. if self:IsAirwing() then @@ -1289,18 +1291,18 @@ function LEGION:CanMission(Mission) end end - for squadname,_squadron in pairs(squadrons) do - local squadron=_squadron --Ops.Cohort#COHORT + for cohortname,_cohort in pairs(cohorts) do + local cohort=_cohort --Ops.Cohort#COHORT -- Check if this squadron can. - local can=squadron:CanMission(Mission) + local can=cohort:CanMission(Mission) if can then -- Number of payloads available. - local Npayloads=self:IsAirwing() and self:CountPayloadsInStock(Mission.type, squadron.aircrafttype, Mission.payloads) or 999 + local Npayloads=self:IsAirwing() and self:CountPayloadsInStock(Mission.type, cohort.aircrafttype, Mission.payloads) or 999 - local assets=squadron:RecruitAssets(Mission, Npayloads) + local assets=cohort:RecruitAssets(Mission, Npayloads) -- Total number. for _,asset in pairs(assets) do @@ -1308,7 +1310,7 @@ function LEGION:CanMission(Mission) end -- Debug output. - local text=string.format("Mission=%s, squadron=%s, payloads=%d, can=%s, assets=%d. Found %d/%d", Mission.type, squadron.name, Npayloads, tostring(can), #assets, #Assets, Mission.nassets) + local text=string.format("Mission=%s, cohort=%s, payloads=%d, can=%s, assets=%d. Found %d/%d", Mission.type, cohort.name, Npayloads, tostring(can), #assets, #Assets, Mission.nassets) self:T(self.lid..text) end diff --git a/Moose Development/Moose/Ops/Squadron.lua b/Moose Development/Moose/Ops/Squadron.lua index a86d91f43..9aaba294b 100644 --- a/Moose Development/Moose/Ops/Squadron.lua +++ b/Moose Development/Moose/Ops/Squadron.lua @@ -80,7 +80,7 @@ SQUADRON.version="0.8.0" -- TODO list ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- TODO: Parking spots for squadrons? +-- DONE: Parking spots for squadrons? -- DONE: Engage radius. -- DONE: Modex. -- DONE: Call signs.