diff --git a/Moose Development/Moose/Ops/ArmyGroup.lua b/Moose Development/Moose/Ops/ArmyGroup.lua index 74004faaa..a08bd3a43 100644 --- a/Moose Development/Moose/Ops/ArmyGroup.lua +++ b/Moose Development/Moose/Ops/ArmyGroup.lua @@ -100,6 +100,7 @@ function ARMYGROUP:New(group) -- Defaults self:SetDefaultROE() self:SetDefaultAlarmstate() + self:SetDefaultEPLRS(self.isEPLRS) self:SetDetection() self:SetPatrolAdInfinitum(false) self:SetRetreatZones() @@ -532,6 +533,7 @@ function ARMYGROUP:onafterSpawned(From, Event, To) text=text..string.format("Speed cruise = %.1f Knots\n", UTILS.KmphToKnots(self.speedCruise)) text=text..string.format("Weight = %.1f kg\n", self:GetWeightTotal()) text=text..string.format("Cargo bay = %.1f kg\n", self:GetFreeCargobay()) + text=text..string.format("Has EPLRS = %s\n", tostring(self.isEPLRS)) text=text..string.format("Elements = %d\n", #self.elements) text=text..string.format("Waypoints = %d\n", #self.waypoints) text=text..string.format("Radio = %.1f MHz %s %s\n", self.radio.Freq, UTILS.GetModulationName(self.radio.Modu), tostring(self.radio.On)) @@ -557,6 +559,9 @@ function ARMYGROUP:onafterSpawned(From, Event, To) -- Set default Alarm State. self:SwitchAlarmstate(self.option.Alarm) + -- Set default EPLRS. + self:SwitchEPLRS(self.option.EPLRS) + -- Set TACAN to default. self:_SwitchTACAN() diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index 5ebec3140..4f19064fa 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -131,6 +131,7 @@ -- @field #number optionROT ROT. -- @field #number optionAlarm Alarm state. -- @field #number optionFormation Formation. +-- @field #boolean optionEPLRS EPLRS datalink. -- @field #number optionCM Counter measures. -- @field #number optionRTBammo RTB on out-of-ammo. -- @field #number optionRTBfuel RTB on out-of-fuel. @@ -1805,6 +1806,21 @@ function AUFTRAG:SetAlarmstate(Alarmstate) return self end +--- Set EPLRS datalink setting for this mission. +-- @param #AUFTRAG self +-- @param #boolean OnOffSwitch If `true` or `nil`, EPLRS is on. If `false`, EPLRS is off. +-- @return #AUFTRAG self +function AUFTRAG:SetEPLRS(OnOffSwitch) + + if OnOffSwitch==nil then + self.optionEPLRS=true + else + self.optionEPLRS=OnOffSwitch + end + + return self +end + --- Set formation for this mission. -- @param #AUFTRAG self -- @param #number Formation Formation. diff --git a/Moose Development/Moose/Ops/Commander.lua b/Moose Development/Moose/Ops/Commander.lua index e0ce6daab..23e2bbb66 100644 --- a/Moose Development/Moose/Ops/Commander.lua +++ b/Moose Development/Moose/Ops/Commander.lua @@ -48,9 +48,9 @@ COMMANDER.version="0.1.0" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO: Improve legion selection. Mostly done! --- TODO: Allow multiple Legions for one mission. --- TODO: Add ops transports. -- TODO: Find solution for missions, which require a transport. This is not as easy as it sounds since the selected mission assets restrict the possible transport assets. +-- TODO: Add ops transports. +-- DONE: Allow multiple Legions for one mission. -- NOGO: Maybe it's possible to preselect the assets for the mission. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -183,6 +183,18 @@ function COMMANDER:AddAirwing(Airwing) return self end +--- Add an BRIGADE to the commander. +-- @param #COMMANDER self +-- @param Ops.Brigade#BRIGADE Briagde The brigade to add. +-- @return #COMMANDER self +function COMMANDER:AddBrigade(Brigade) + + -- Add legion. + self:AddLegion(Brigade) + + return self +end + --- Add a LEGION to the commander. -- @param #COMMANDER self -- @param Ops.Legion#LEGION Legion The legion to add. diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index d9738ae11..b71e5e711 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -215,13 +215,14 @@ function FLIGHTGROUP:New(group) self.lid=string.format("FLIGHTGROUP %s | ", self.groupname) -- Defaults + self:SetDefaultROE() + self:SetDefaultROT() + self:SetDefaultEPLRS(self.isEPLRS) + self:SetDetection() self:SetFuelLowThreshold() self:SetFuelLowRTB() self:SetFuelCriticalThreshold() - self:SetFuelCriticalRTB() - self:SetDefaultROE() - self:SetDefaultROT() - self:SetDetection() + self:SetFuelCriticalRTB() -- Holding flag. self.flaghold=USERFLAG:New(string.format("%s_FlagHold", self.groupname)) @@ -1580,7 +1581,8 @@ function FLIGHTGROUP:onafterSpawned(From, Event, To) text=text..string.format("Tanker type = %s\n", tostring(self.tankertype)) text=text..string.format("Refuel type = %s\n", tostring(self.refueltype)) text=text..string.format("AI = %s\n", tostring(self.isAI)) - text=text..string.format("Helicopter = %s\n", tostring(self.group:IsHelicopter())) + text=text..string.format("Has EPLRS = %s\n", tostring(self.isEPLRS)) + text=text..string.format("Helicopter = %s\n", tostring(self.isHelo)) text=text..string.format("Elements = %d\n", #self.elements) text=text..string.format("Waypoints = %d\n", #self.waypoints) text=text..string.format("Radio = %.1f MHz %s %s\n", self.radio.Freq, UTILS.GetModulationName(self.radio.Modu), tostring(self.radio.On)) @@ -1611,6 +1613,9 @@ function FLIGHTGROUP:onafterSpawned(From, Event, To) -- Set ROT. self:SwitchROT(self.option.ROT) + -- Set default EPLRS. + self:SwitchEPLRS(self.option.EPLRS) + -- Set Formation self:SwitchFormation(self.option.Formation) diff --git a/Moose Development/Moose/Ops/NavyGroup.lua b/Moose Development/Moose/Ops/NavyGroup.lua index 12e58abdb..af093826d 100644 --- a/Moose Development/Moose/Ops/NavyGroup.lua +++ b/Moose Development/Moose/Ops/NavyGroup.lua @@ -121,9 +121,10 @@ function NAVYGROUP:New(group) self.lid=string.format("NAVYGROUP %s | ", self.groupname) -- Defaults - self:SetDetection() self:SetDefaultROE() self:SetDefaultAlarmstate() + self:SetDefaultEPLRS(self.isEPLRS) + self:SetDetection() self:SetPatrolAdInfinitum(true) self:SetPathfinding(false) @@ -654,7 +655,9 @@ function NAVYGROUP:onafterSpawned(From, Event, To) text=text..string.format("Speed max = %.1f Knots\n", UTILS.KmphToKnots(self.speedMax)) text=text..string.format("Speed cruise = %.1f Knots\n", UTILS.KmphToKnots(self.speedCruise)) text=text..string.format("Weight = %.1f kg\n", self:GetWeightTotal()) - text=text..string.format("Cargo bay = %.1f kg\n", self:GetFreeCargobay()) + text=text..string.format("Cargo bay = %.1f kg\n", self:GetFreeCargobay()) + text=text..string.format("Has EPLRS = %s\n", tostring(self.isEPLRS)) + text=text..string.format("Is Submarine = %s\n", tostring(self.isSubmarine)) text=text..string.format("Elements = %d\n", #self.elements) text=text..string.format("Waypoints = %d\n", #self.waypoints) text=text..string.format("Radio = %.1f MHz %s %s\n", self.radio.Freq, UTILS.GetModulationName(self.radio.Modu), tostring(self.radio.On)) @@ -680,6 +683,9 @@ function NAVYGROUP:onafterSpawned(From, Event, To) -- Set default Alarm State. self:SwitchAlarmstate(self.option.Alarm) + -- Set default EPLRS. + self:SwitchEPLRS(self.option.EPLRS) + -- Set TACAN beacon. self:_SwitchTACAN() diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index e8e51836f..f1815e991 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -97,7 +97,7 @@ -- @field #OPSGROUP.Beacon iclsDefault Default ICLS settings. -- -- @field #OPSGROUP.Option option Current optional settings. --- @field #OPSGROUP.Option optionDefault Default option settings. +-- @field #OPSGROUP.Option optionDefault Default option settings. -- -- @field #OPSGROUP.Callsign callsign Current callsign settings. -- @field #OPSGROUP.Callsign callsignDefault Default callsign settings. @@ -297,11 +297,6 @@ OPSGROUP.TaskType={ -- @field Core.UserFlag#USERFLAG stopflag If flag is set to 1 (=true), the task is stopped. -- @field #number backupROE Rules of engagement that are restored once the task is over. ---- Enroute task. --- @type OPSGROUP.EnrouteTask --- @field DCS#Task DCStask DCS task structure table. --- @field #number WaypointIndex Waypoint number at which the enroute task is added. - --- Beacon data. -- @type OPSGROUP.Beacon -- @field #number Channel Channel. @@ -550,6 +545,12 @@ function OPSGROUP:New(group) -- Set type name. self.actype=masterunit:GetTypeName() + -- Is this a submarine. + self.isSubmarine=masterunit:HasAttribute("Submarines") + + -- Has this a datalink? + self.isEPLRS=masterunit:HasAttribute("Datalink") + if self:IsFlightgroup() then self.rangemax=self.descriptors.range and self.descriptors.range*1000 or 500*1000 @@ -4041,6 +4042,10 @@ function OPSGROUP:onafterMissionDone(From, Event, To, Mission) if Mission.optionAlarm then self:SwitchAlarmstate() end + -- Alarm state to default. + if Mission.optionEPLRS then + self:SwitchEPLRS() + end -- Formation to default. if Mission.optionFormation then self:SwitchFormation() @@ -4225,10 +4230,14 @@ function OPSGROUP:RouteToMission(mission, delay) if mission.optionROT then self:SwitchROT(mission.optionROT) end - -- Alarm state. + -- Alarm state if mission.optionAlarm then self:SwitchAlarmstate(mission.optionAlarm) end + -- EPLRS + if mission.optionEPLRS then + self:SwitchEPLRS(mission.optionEPLRS) + end -- Formation if mission.optionFormation and self:IsFlightgroup() then self:SwitchFormation(mission.optionFormation) @@ -8710,6 +8719,65 @@ function OPSGROUP:GetAlarmstate() return self.option.Alarm or self.optionDefault.Alarm end +--- Set the default Alarm State for the group. This is the state gets when the group is spawned or to which it defaults back after a mission. +-- @param #OPSGROUP self +-- @param #boolean OnOffSwitch If `true`, EPLRS is on by default. If `false` default EPLRS setting is off. If `nil`, default is on if group has EPLRS and off if it does not have a datalink. +-- @return #OPSGROUP self +function OPSGROUP:SetDefaultEPLRS(OnOffSwitch) + + if OnOffSwitch==nil then + self.optionDefault.EPLRS=self.isEPLRS + else + self.optionDefault.EPLRS=OnOffSwitch + end + + return self +end + +--- Switch EPLRS datalink on or off. +-- @param #OPSGROUP self +-- @param #boolean OnOffSwitch If `true` or `nil`, switch EPLRS on. If `false` EPLRS switched off. +-- @return #OPSGROUP self +function OPSGROUP:SwitchEPLRS(OnOffSwitch) + + if self:IsAlive() or self:IsInUtero() then + + if OnOffSwitch==nil then + + self.option.EPLRS=self.optionDefault.EPLRS + + else + + self.option.EPLRS=OnOffSwitch + + end + + if self:IsInUtero() then + self:T2(self.lid..string.format("Setting current EPLRS=%s when GROUP is SPAWNED", tostring(self.option.EPLRS))) + else + + self.group:CommandEPLRS(self.option.EPLRS) + self:T(self.lid..string.format("Setting current EPLRS=%s", tostring(self.option.EPLRS))) + + end + else + self:E(self.lid.."WARNING: Cannot switch Alarm State! Group is not alive") + end + + return self +end + +--- Get current EPLRS state. +-- @param #OPSGROUP self +-- @return #boolean If `true`, EPLRS is on. +function OPSGROUP:GetEPLRS() + return self.option.EPLRS or self.optionDefault.EPLRS +end + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- SETTINGS FUNCTIONS +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + --- Set default TACAN parameters. -- @param #OPSGROUP self -- @param #number Channel TACAN channel. Default is 74.