diff --git a/Moose Development/Moose/Ops/ArmyGroup.lua b/Moose Development/Moose/Ops/ArmyGroup.lua index 825c3fb7f..5eb53c664 100644 --- a/Moose Development/Moose/Ops/ArmyGroup.lua +++ b/Moose Development/Moose/Ops/ArmyGroup.lua @@ -103,7 +103,8 @@ function ARMYGROUP:New(group) -- Defaults self:SetDefaultROE() self:SetDefaultAlarmstate() - self:SetDefaultEPLRS(self.isEPLRS) + self:SetDefaultEPLRS(self.isEPLRS) + self:SetDefaultEmission() self:SetDetection() self:SetPatrolAdInfinitum(false) self:SetRetreatZones() @@ -1726,7 +1727,7 @@ function ARMYGROUP:SwitchFormation(Formation, Permanently, NoRouteUpdate) self.option.Formation=Formation or "Off road" if self:IsInUtero() then - self:T(self.lid..string.format("Will switch formation to %s (permanently=%s) when group is spawned", self.option.Formation, tostring(Permanently))) + self:T(self.lid..string.format("Will switch formation to %s (permanently=%s) when group is spawned", tostring(self.option.Formation), tostring(Permanently))) else -- Update route with the new formation. @@ -1736,7 +1737,7 @@ function ARMYGROUP:SwitchFormation(Formation, Permanently, NoRouteUpdate) end -- Debug info. - self:T(self.lid..string.format("Switching formation to %s (permanently=%s)", self.option.Formation, tostring(Permanently))) + self:T(self.lid..string.format("Switching formation to %s (permanently=%s)", tostring(self.option.Formation), tostring(Permanently))) end diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index ba8a375b3..e09404c29 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -4245,13 +4245,7 @@ function AUFTRAG:_TargetFromObject(Object) self.engageTarget=TARGET:New(Object) end - - if self.type == AUFTRAG.Type.ALERT5 then - self.alert5Target = self.engageTarget - - end - else -- Target was already specified elsewhere. @@ -4379,10 +4373,10 @@ function AUFTRAG:GetTargetCoordinate() local coord=self.engageTarget:GetCoordinate() return coord - elseif self.alert5Target then + elseif self.type==AUFTRAG.Type.ALERT5 then - local coord=self.alert5Target:GetCoordinate() - return coord + -- For example, COMMANDER will not assign a coordiante. This will be done later, when the mission is assigned to an airwing. + return nil else self:T(self.lid.."ERROR: Cannot get target coordinate!") diff --git a/Moose Development/Moose/Ops/Chief.lua b/Moose Development/Moose/Ops/Chief.lua index 8a0ede2be..266107f3f 100644 --- a/Moose Development/Moose/Ops/Chief.lua +++ b/Moose Development/Moose/Ops/Chief.lua @@ -1752,12 +1752,12 @@ function CHIEF:CheckOpsZoneQueue() self:T3(self.lid..string.format("Zone is empty ==> Recruit Patrol zone infantry assets")) -- Recruit ground assets that - local recruited=self:RecruitAssetsForZone(stratzone, AUFTRAG.Type.ONGUARD, 1, 3, {Group.Category.GROUND}, {GROUP.Attribute.GROUND_INFANTRY, GROUP.Attribute.GROUND_TANK}) - local recruited1=self:RecruitAssetsForZone(stratzone, AUFTRAG.Type.ARMOREDGUARD, 1, 1, {Group.Category.GROUND}, {GROUP.Attribute.GROUND_TANK}) + local recruitedI=self:RecruitAssetsForZone(stratzone, AUFTRAG.Type.ONGUARD, 1, 3, {Group.Category.GROUND}, {GROUP.Attribute.GROUND_INFANTRY}) + local recruitedT=self:RecruitAssetsForZone(stratzone, AUFTRAG.Type.ARMOREDGUARD, 1, 1, {Group.Category.GROUND}, {GROUP.Attribute.GROUND_TANK}) -- Debug info. - self:T(self.lid..string.format("Zone is empty ==> Recruit Patrol zone infantry assets=%s", tostring(recruited))) - self:T(self.lid..string.format("Zone is empty ==> Recruit Patrol zone armored assets=%s", tostring(recruited1))) + self:T(self.lid..string.format("Zone is empty ==> Recruit Patrol zone infantry assets=%s", tostring(recruitedI))) + self:T(self.lid..string.format("Zone is empty ==> Recruit Patrol zone armored assets=%s", tostring(recruitedT))) end else @@ -2198,10 +2198,13 @@ function CHIEF:RecruitAssetsForZone(StratZone, MissionType, NassetsMin, NassetsM if recruited then + -- Debug messgage. + self:T2(self.lid..string.format("Recruited %d assets for %s mission STRATEGIC zone %s", #assets, MissionType, tostring(StratZone.opszone.zoneName))) + if MissionType==AUFTRAG.Type.PATROLZONE or MissionType==AUFTRAG.Type.ONGUARD then -- Debug messgage. - self:T2(self.lid..string.format("Recruited %d assets from for PATROL mission", #assets)) + self:T2(self.lid..string.format("Recruited %d assets for PATROL mission", #assets)) local recruitedTrans=true local transport=nil @@ -2209,8 +2212,7 @@ function CHIEF:RecruitAssetsForZone(StratZone, MissionType, NassetsMin, NassetsM -- Categories. Currently only helicopters are allowed due to problems with ground transports (might get stuck, might not be a land connection. -- TODO: Check if ground transport is possible. For example, by trying land.getPathOnRoad or something. - local Categories={self.TransportCategories} - --local Categories={Group.Category.HELICOPTER, Group.Category.GROUND} + local Categories=self.TransportCategories -- Recruit transport assets for infantry. recruitedTrans, transport=LEGION.AssignAssetsForTransport(self.commander, self.commander.legions, assets, 1, 1, StratZone.opszone.zone, nil, Categories) @@ -2242,9 +2244,7 @@ function CHIEF:RecruitAssetsForZone(StratZone, MissionType, NassetsMin, NassetsM self:MissionAssign(mission, legions) -- Attach mission to ops zone. - -- TODO: Need a better way! - --StratZone.missionPatrol=mission - StratZone.opszone:_AddMission(self.coalition,MissionType,mission) + StratZone.opszone:_AddMission(self.coalition, MissionType, mission) return true else @@ -2281,9 +2281,7 @@ function CHIEF:RecruitAssetsForZone(StratZone, MissionType, NassetsMin, NassetsM self:MissionAssign(mission, legions) -- Attach mission to ops zone. - -- TODO: Need a better way! - --StratZone.missionCAS=mission - StratZone.opszone:_AddMission(self.coalition,MissionType,mission) + StratZone.opszone:_AddMission(self.coalition, MissionType, mission) return true elseif MissionType==AUFTRAG.Type.ARTY then @@ -2303,9 +2301,7 @@ function CHIEF:RecruitAssetsForZone(StratZone, MissionType, NassetsMin, NassetsM self:MissionAssign(mission, legions) -- Attach mission to ops zone. - -- TODO: Need a better way! - --StratZone.missionARTY=mission - StratZone.opszone:_AddMission(self.coalition,MissionType,mission) + StratZone.opszone:_AddMission(self.coalition, MissionType, mission) return true elseif MissionType==AUFTRAG.Type.ARMOREDGUARD then @@ -2324,15 +2320,16 @@ function CHIEF:RecruitAssetsForZone(StratZone, MissionType, NassetsMin, NassetsM self:MissionAssign(mission, legions) -- Attach mission to ops zone. - -- TODO: Need a better way! - --StratZone.missionARTY=mission - StratZone.opszone:_AddMission(self.coalition,MissionType,mission) + StratZone.opszone:_AddMission(self.coalition, MissionType, mission) return true end end + -- Debug messgage. + self:T2(self.lid..string.format("Could NOT recruit assets for %s mission of STRATEGIC zone %s", MissionType, tostring(StratZone.opszone.zoneName))) + return false end diff --git a/Moose Development/Moose/Ops/NavyGroup.lua b/Moose Development/Moose/Ops/NavyGroup.lua index e34549feb..a46183e47 100644 --- a/Moose Development/Moose/Ops/NavyGroup.lua +++ b/Moose Development/Moose/Ops/NavyGroup.lua @@ -134,6 +134,7 @@ function NAVYGROUP:New(group) self:SetDefaultROE() self:SetDefaultAlarmstate() self:SetDefaultEPLRS(self.isEPLRS) + self:SetDefaultEmission() self:SetDetection() self:SetPatrolAdInfinitum(true) self:SetPathfinding(false) diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index 250a45fec..6975f91f8 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -334,6 +334,7 @@ OPSGROUP.TaskType={ -- @field #number Formation Formation. -- @field #boolean EPLRS data link. -- @field #boolean Disperse Disperse under fire. +-- @field #boolen Emission Emission on/off. --- Weapon range data. -- @type OPSGROUP.WeaponData @@ -3638,7 +3639,7 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task) --- -- Just stay put and wait until something happens. - + elseif Task.dcstask.id==AUFTRAG.SpecialTask.ALERT5 then --- @@ -3924,9 +3925,9 @@ function OPSGROUP:AddMission(Mission) table.insert(self.missionqueue, Mission) -- ad infinitum? - + self.adinfinitum = Mission.DCStask.params.adinfinitum and Mission.DCStask.params.adinfinitum or false - + -- Info text. local text=string.format("Added %s mission %s starting at %s, stopping at %s", tostring(Mission.type), tostring(Mission.name), UTILS.SecondsToClock(Mission.Tstart, true), Mission.Tstop and UTILS.SecondsToClock(Mission.Tstop, true) or "INF") @@ -3952,7 +3953,7 @@ function OPSGROUP:RemoveMission(Mission) if Task then self:RemoveTask(Task) end - + -- Take care of a paused mission. if self.missionpaused and self.missionpaused.auftragsnummer==Mission.auftragsnummer then self.missionpaused=nil @@ -4221,14 +4222,14 @@ function OPSGROUP:onafterMissionStart(From, Event, To, Mission) -- Route group to mission zone. if self.speedMax>3.6 then - + self:RouteToMission(Mission, 3) - + else --- -- IMMOBILE Group --- - + env.info("FF Immobile GROUP") -- Add waypoint task. UpdateRoute is called inside. @@ -4239,7 +4240,7 @@ function OPSGROUP:onafterMissionStart(From, Event, To, Mission) -- Set waypoint task. Mission:SetGroupWaypointTask(self, Task) - -- Execute task. This calls mission execute. + -- Execute task. This calls mission execute. self:__TaskExecute(3, Task) end @@ -4542,7 +4543,7 @@ function OPSGROUP:RouteToMission(mission, delay) end -- Get ingress waypoint. - if mission.type==AUFTRAG.Type.PATROLZONE or mission.type==AUFTRAG.Type.BARRAGE or mission.type==AUFTRAG.Type.AMMOSUPPLY + if mission.type==AUFTRAG.Type.PATROLZONE or mission.type==AUFTRAG.Type.BARRAGE or mission.type==AUFTRAG.Type.AMMOSUPPLY or mission.type.FUELSUPPLY then local zone=mission.engageTarget:GetObject() --Core.Zone#ZONE waypointcoord=zone:GetRandomCoordinate(nil , nil, surfacetypes) @@ -4551,7 +4552,7 @@ function OPSGROUP:RouteToMission(mission, delay) else waypointcoord=mission:GetMissionWaypointCoord(self.group, randomradius, surfacetypes) end - + local armorwaypointcoord = nil if mission.type==AUFTRAG.Type.ARMORATTACK then local target=mission.engageTarget:GetObject() -- Wrapper.Positionable#POSITIONABLE @@ -4561,7 +4562,7 @@ function OPSGROUP:RouteToMission(mission, delay) -- Ingress - add formation to this one armorwaypointcoord = zone:GetRandomCoordinate(1000, 500, surfacetypes) -- Core.Point#COORDINATE end - + -- Add enroute tasks. for _,task in pairs(mission.enrouteTasks) do self:AddTaskEnroute(task) @@ -9288,7 +9289,7 @@ function OPSGROUP._PassingWaypoint(opsgroup, uid) if (opsgroup:IsNavygroup() or opsgroup:IsArmygroup()) and opsgroup.currentwp==#opsgroup.waypoints then --TODO: not sure if this works with FLIGHTGROUPS - + -- Removing this for now. opsgroup:Cruise() end @@ -9501,7 +9502,7 @@ function OPSGROUP:SwitchROE(roe) if self:IsInUtero() then self:T2(self.lid..string.format("Setting current ROE=%d when GROUP is SPAWNED", self.option.ROE)) else - + self.group:OptionROE(self.option.ROE) self:T(self.lid..string.format("Setting current ROE=%d (%s)", self.option.ROE, self:_GetROEName(self.option.ROE))) @@ -9651,7 +9652,7 @@ 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. +--- Set the default EPLRS for the group. -- @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 @@ -9693,7 +9694,7 @@ function OPSGROUP:SwitchEPLRS(OnOffSwitch) end else - self:T(self.lid.."WARNING: Cannot switch Alarm State! Group is not alive") + self:E(self.lid.."WARNING: Cannot switch EPLRS! Group is not alive") end return self @@ -9706,6 +9707,61 @@ function OPSGROUP:GetEPLRS() return self.option.EPLRS or self.optionDefault.EPLRS end +--- Set the default EPLRS for the group. +-- @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:SetDefaultEmission(OnOffSwitch) + + if OnOffSwitch==nil then + self.optionDefault.Emission=true + else + self.optionDefault.EPLRS=OnOffSwitch + end + + return self +end + +--- Switch emission on or off. +-- @param #OPSGROUP self +-- @param #boolean OnOffSwitch If `true` or `nil`, switch emission on. If `false` emission switched off. +-- @return #OPSGROUP self +function OPSGROUP:SwitchEmission(OnOffSwitch) + + if self:IsAlive() or self:IsInUtero() then + + if OnOffSwitch==nil then + + self.option.Emission=self.optionDefault.Emission + + else + + self.option.Emission=OnOffSwitch + + end + + if self:IsInUtero() then + self:T2(self.lid..string.format("Setting current EMISSION=%s when GROUP is SPAWNED", tostring(self.option.Emission))) + else + + self.group:EnableEmission(self.option.Emission) + self:T(self.lid..string.format("Setting current EMISSION=%s", tostring(self.option.Emission))) + + end + else + self:E(self.lid.."WARNING: Cannot switch Emission! Group is not alive") + end + + return self +end + +--- Get current emission state. +-- @param #OPSGROUP self +-- @return #boolean If `true`, emission is on. +function OPSGROUP:GetEmission() + return self.option.Emission or self.optionDefault.Emission +end + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- SETTINGS FUNCTIONS ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -10134,7 +10190,7 @@ function OPSGROUP:SwitchFormation(Formation) self.option.Formation=Formation -- Debug info. - self:T(self.lid..string.format("Switching formation to %d", self.option.Formation)) + self:T(self.lid..string.format("Switching formation to %s", tostring(self.option.Formation))) end @@ -11157,6 +11213,8 @@ function OPSGROUP:_AddElementByName(unitname) element.category=unit:GetUnitCategory() element.categoryname=unit:GetCategoryName() element.typename=unit:GetTypeName() + + --self:I({desc=element.descriptors}) -- Ammo.