Merge pull request #1668 from FlightControl-Master/FF/Ops

OPS
This commit is contained in:
Frank 2021-12-17 13:29:08 +01:00 committed by GitHub
commit d1d43c38cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 98 additions and 47 deletions

View File

@ -103,7 +103,8 @@ function ARMYGROUP:New(group)
-- Defaults -- Defaults
self:SetDefaultROE() self:SetDefaultROE()
self:SetDefaultAlarmstate() self:SetDefaultAlarmstate()
self:SetDefaultEPLRS(self.isEPLRS) self:SetDefaultEPLRS(self.isEPLRS)
self:SetDefaultEmission()
self:SetDetection() self:SetDetection()
self:SetPatrolAdInfinitum(false) self:SetPatrolAdInfinitum(false)
self:SetRetreatZones() self:SetRetreatZones()
@ -1726,7 +1727,7 @@ function ARMYGROUP:SwitchFormation(Formation, Permanently, NoRouteUpdate)
self.option.Formation=Formation or "Off road" self.option.Formation=Formation or "Off road"
if self:IsInUtero() then 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 else
-- Update route with the new formation. -- Update route with the new formation.
@ -1736,7 +1737,7 @@ function ARMYGROUP:SwitchFormation(Formation, Permanently, NoRouteUpdate)
end end
-- Debug info. -- 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 end

View File

@ -4245,13 +4245,7 @@ function AUFTRAG:_TargetFromObject(Object)
self.engageTarget=TARGET:New(Object) self.engageTarget=TARGET:New(Object)
end end
if self.type == AUFTRAG.Type.ALERT5 then
self.alert5Target = self.engageTarget
end
else else
-- Target was already specified elsewhere. -- Target was already specified elsewhere.
@ -4379,10 +4373,10 @@ function AUFTRAG:GetTargetCoordinate()
local coord=self.engageTarget:GetCoordinate() local coord=self.engageTarget:GetCoordinate()
return coord return coord
elseif self.alert5Target then elseif self.type==AUFTRAG.Type.ALERT5 then
local coord=self.alert5Target:GetCoordinate() -- For example, COMMANDER will not assign a coordiante. This will be done later, when the mission is assigned to an airwing.
return coord return nil
else else
self:T(self.lid.."ERROR: Cannot get target coordinate!") self:T(self.lid.."ERROR: Cannot get target coordinate!")

View File

@ -1752,12 +1752,12 @@ function CHIEF:CheckOpsZoneQueue()
self:T3(self.lid..string.format("Zone is empty ==> Recruit Patrol zone infantry assets")) self:T3(self.lid..string.format("Zone is empty ==> Recruit Patrol zone infantry assets"))
-- Recruit ground assets that -- 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 recruitedI=self:RecruitAssetsForZone(stratzone, AUFTRAG.Type.ONGUARD, 1, 3, {Group.Category.GROUND}, {GROUP.Attribute.GROUND_INFANTRY})
local recruited1=self:RecruitAssetsForZone(stratzone, AUFTRAG.Type.ARMOREDGUARD, 1, 1, {Group.Category.GROUND}, {GROUP.Attribute.GROUND_TANK}) local recruitedT=self:RecruitAssetsForZone(stratzone, AUFTRAG.Type.ARMOREDGUARD, 1, 1, {Group.Category.GROUND}, {GROUP.Attribute.GROUND_TANK})
-- Debug info. -- 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 infantry assets=%s", tostring(recruitedI)))
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 armored assets=%s", tostring(recruitedT)))
end end
else else
@ -2198,10 +2198,13 @@ function CHIEF:RecruitAssetsForZone(StratZone, MissionType, NassetsMin, NassetsM
if recruited then 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 if MissionType==AUFTRAG.Type.PATROLZONE or MissionType==AUFTRAG.Type.ONGUARD then
-- Debug messgage. -- 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 recruitedTrans=true
local transport=nil 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. -- 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. -- TODO: Check if ground transport is possible. For example, by trying land.getPathOnRoad or something.
local Categories={self.TransportCategories} local Categories=self.TransportCategories
--local Categories={Group.Category.HELICOPTER, Group.Category.GROUND}
-- Recruit transport assets for infantry. -- Recruit transport assets for infantry.
recruitedTrans, transport=LEGION.AssignAssetsForTransport(self.commander, self.commander.legions, assets, 1, 1, StratZone.opszone.zone, nil, Categories) 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) self:MissionAssign(mission, legions)
-- Attach mission to ops zone. -- Attach mission to ops zone.
-- TODO: Need a better way! StratZone.opszone:_AddMission(self.coalition, MissionType, mission)
--StratZone.missionPatrol=mission
StratZone.opszone:_AddMission(self.coalition,MissionType,mission)
return true return true
else else
@ -2281,9 +2281,7 @@ function CHIEF:RecruitAssetsForZone(StratZone, MissionType, NassetsMin, NassetsM
self:MissionAssign(mission, legions) self:MissionAssign(mission, legions)
-- Attach mission to ops zone. -- Attach mission to ops zone.
-- TODO: Need a better way! StratZone.opszone:_AddMission(self.coalition, MissionType, mission)
--StratZone.missionCAS=mission
StratZone.opszone:_AddMission(self.coalition,MissionType,mission)
return true return true
elseif MissionType==AUFTRAG.Type.ARTY then elseif MissionType==AUFTRAG.Type.ARTY then
@ -2303,9 +2301,7 @@ function CHIEF:RecruitAssetsForZone(StratZone, MissionType, NassetsMin, NassetsM
self:MissionAssign(mission, legions) self:MissionAssign(mission, legions)
-- Attach mission to ops zone. -- Attach mission to ops zone.
-- TODO: Need a better way! StratZone.opszone:_AddMission(self.coalition, MissionType, mission)
--StratZone.missionARTY=mission
StratZone.opszone:_AddMission(self.coalition,MissionType,mission)
return true return true
elseif MissionType==AUFTRAG.Type.ARMOREDGUARD then elseif MissionType==AUFTRAG.Type.ARMOREDGUARD then
@ -2324,15 +2320,16 @@ function CHIEF:RecruitAssetsForZone(StratZone, MissionType, NassetsMin, NassetsM
self:MissionAssign(mission, legions) self:MissionAssign(mission, legions)
-- Attach mission to ops zone. -- Attach mission to ops zone.
-- TODO: Need a better way! StratZone.opszone:_AddMission(self.coalition, MissionType, mission)
--StratZone.missionARTY=mission
StratZone.opszone:_AddMission(self.coalition,MissionType,mission)
return true return true
end end
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 return false
end end

View File

@ -134,6 +134,7 @@ function NAVYGROUP:New(group)
self:SetDefaultROE() self:SetDefaultROE()
self:SetDefaultAlarmstate() self:SetDefaultAlarmstate()
self:SetDefaultEPLRS(self.isEPLRS) self:SetDefaultEPLRS(self.isEPLRS)
self:SetDefaultEmission()
self:SetDetection() self:SetDetection()
self:SetPatrolAdInfinitum(true) self:SetPatrolAdInfinitum(true)
self:SetPathfinding(false) self:SetPathfinding(false)

View File

@ -334,6 +334,7 @@ OPSGROUP.TaskType={
-- @field #number Formation Formation. -- @field #number Formation Formation.
-- @field #boolean EPLRS data link. -- @field #boolean EPLRS data link.
-- @field #boolean Disperse Disperse under fire. -- @field #boolean Disperse Disperse under fire.
-- @field #boolen Emission Emission on/off.
--- Weapon range data. --- Weapon range data.
-- @type OPSGROUP.WeaponData -- @type OPSGROUP.WeaponData
@ -3638,7 +3639,7 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
--- ---
-- Just stay put and wait until something happens. -- Just stay put and wait until something happens.
elseif Task.dcstask.id==AUFTRAG.SpecialTask.ALERT5 then elseif Task.dcstask.id==AUFTRAG.SpecialTask.ALERT5 then
--- ---
@ -3924,9 +3925,9 @@ function OPSGROUP:AddMission(Mission)
table.insert(self.missionqueue, Mission) table.insert(self.missionqueue, Mission)
-- ad infinitum? -- ad infinitum?
self.adinfinitum = Mission.DCStask.params.adinfinitum and Mission.DCStask.params.adinfinitum or false self.adinfinitum = Mission.DCStask.params.adinfinitum and Mission.DCStask.params.adinfinitum or false
-- Info text. -- Info text.
local text=string.format("Added %s mission %s starting at %s, stopping at %s", 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") 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 if Task then
self:RemoveTask(Task) self:RemoveTask(Task)
end end
-- Take care of a paused mission. -- Take care of a paused mission.
if self.missionpaused and self.missionpaused.auftragsnummer==Mission.auftragsnummer then if self.missionpaused and self.missionpaused.auftragsnummer==Mission.auftragsnummer then
self.missionpaused=nil self.missionpaused=nil
@ -4221,14 +4222,14 @@ function OPSGROUP:onafterMissionStart(From, Event, To, Mission)
-- Route group to mission zone. -- Route group to mission zone.
if self.speedMax>3.6 then if self.speedMax>3.6 then
self:RouteToMission(Mission, 3) self:RouteToMission(Mission, 3)
else else
--- ---
-- IMMOBILE Group -- IMMOBILE Group
--- ---
env.info("FF Immobile GROUP") env.info("FF Immobile GROUP")
-- Add waypoint task. UpdateRoute is called inside. -- Add waypoint task. UpdateRoute is called inside.
@ -4239,7 +4240,7 @@ function OPSGROUP:onafterMissionStart(From, Event, To, Mission)
-- Set waypoint task. -- Set waypoint task.
Mission:SetGroupWaypointTask(self, Task) Mission:SetGroupWaypointTask(self, Task)
-- Execute task. This calls mission execute. -- Execute task. This calls mission execute.
self:__TaskExecute(3, Task) self:__TaskExecute(3, Task)
end end
@ -4542,7 +4543,7 @@ function OPSGROUP:RouteToMission(mission, delay)
end end
-- Get ingress waypoint. -- 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 or mission.type.FUELSUPPLY then
local zone=mission.engageTarget:GetObject() --Core.Zone#ZONE local zone=mission.engageTarget:GetObject() --Core.Zone#ZONE
waypointcoord=zone:GetRandomCoordinate(nil , nil, surfacetypes) waypointcoord=zone:GetRandomCoordinate(nil , nil, surfacetypes)
@ -4551,7 +4552,7 @@ function OPSGROUP:RouteToMission(mission, delay)
else else
waypointcoord=mission:GetMissionWaypointCoord(self.group, randomradius, surfacetypes) waypointcoord=mission:GetMissionWaypointCoord(self.group, randomradius, surfacetypes)
end end
local armorwaypointcoord = nil local armorwaypointcoord = nil
if mission.type==AUFTRAG.Type.ARMORATTACK then if mission.type==AUFTRAG.Type.ARMORATTACK then
local target=mission.engageTarget:GetObject() -- Wrapper.Positionable#POSITIONABLE local target=mission.engageTarget:GetObject() -- Wrapper.Positionable#POSITIONABLE
@ -4561,7 +4562,7 @@ function OPSGROUP:RouteToMission(mission, delay)
-- Ingress - add formation to this one -- Ingress - add formation to this one
armorwaypointcoord = zone:GetRandomCoordinate(1000, 500, surfacetypes) -- Core.Point#COORDINATE armorwaypointcoord = zone:GetRandomCoordinate(1000, 500, surfacetypes) -- Core.Point#COORDINATE
end end
-- Add enroute tasks. -- Add enroute tasks.
for _,task in pairs(mission.enrouteTasks) do for _,task in pairs(mission.enrouteTasks) do
self:AddTaskEnroute(task) self:AddTaskEnroute(task)
@ -9288,7 +9289,7 @@ function OPSGROUP._PassingWaypoint(opsgroup, uid)
if (opsgroup:IsNavygroup() or opsgroup:IsArmygroup()) and opsgroup.currentwp==#opsgroup.waypoints then if (opsgroup:IsNavygroup() or opsgroup:IsArmygroup()) and opsgroup.currentwp==#opsgroup.waypoints then
--TODO: not sure if this works with FLIGHTGROUPS --TODO: not sure if this works with FLIGHTGROUPS
-- Removing this for now. -- Removing this for now.
opsgroup:Cruise() opsgroup:Cruise()
end end
@ -9501,7 +9502,7 @@ function OPSGROUP:SwitchROE(roe)
if self:IsInUtero() then if self:IsInUtero() then
self:T2(self.lid..string.format("Setting current ROE=%d when GROUP is SPAWNED", self.option.ROE)) self:T2(self.lid..string.format("Setting current ROE=%d when GROUP is SPAWNED", self.option.ROE))
else else
self.group:OptionROE(self.option.ROE) 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))) 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 return self.option.Alarm or self.optionDefault.Alarm
end 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 #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. -- @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 -- @return #OPSGROUP self
@ -9693,7 +9694,7 @@ function OPSGROUP:SwitchEPLRS(OnOffSwitch)
end end
else 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 end
return self return self
@ -9706,6 +9707,61 @@ function OPSGROUP:GetEPLRS()
return self.option.EPLRS or self.optionDefault.EPLRS return self.option.EPLRS or self.optionDefault.EPLRS
end 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 -- SETTINGS FUNCTIONS
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@ -10134,7 +10190,7 @@ function OPSGROUP:SwitchFormation(Formation)
self.option.Formation=Formation self.option.Formation=Formation
-- Debug info. -- 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 end
@ -11157,6 +11213,8 @@ function OPSGROUP:_AddElementByName(unitname)
element.category=unit:GetUnitCategory() element.category=unit:GetUnitCategory()
element.categoryname=unit:GetCategoryName() element.categoryname=unit:GetCategoryName()
element.typename=unit:GetTypeName() element.typename=unit:GetTypeName()
--self:I({desc=element.descriptors}) --self:I({desc=element.descriptors})
-- Ammo. -- Ammo.