From cb43f9c3928d630dd4645ff7e68bfafe5b82dff9 Mon Sep 17 00:00:00 2001 From: Frank Date: Sat, 5 Nov 2022 23:48:42 +0100 Subject: [PATCH 1/7] CHIEF - cleaned up resources --- Moose Development/Moose/Ops/Chief.lua | 48 ++++++++++----------- Moose Development/Moose/Ops/Legion.lua | 7 ++- Moose Development/Moose/Utilities/Utils.lua | 12 ++++-- 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/Moose Development/Moose/Ops/Chief.lua b/Moose Development/Moose/Ops/Chief.lua index b83e3c352..4443531a8 100644 --- a/Moose Development/Moose/Ops/Chief.lua +++ b/Moose Development/Moose/Ops/Chief.lua @@ -188,7 +188,7 @@ -- --- Create a resource list of mission types and required assets for the case that the zone is OCCUPIED. -- -- -- -- Here, we create an enhanced CAS mission and employ at least on and at most two asset groups. --- local ResourceOccupied=myChief:CreateResource(AUFTRAG.Type.CASENHANCED, 1, 2) +-- local ResourceOccupied, resourceCAS=myChief:CreateResource(AUFTRAG.Type.CASENHANCED, 1, 2) -- -- We also add ARTY missions with at least one and at most two assets. We additionally require these to be MLRS groups (and not howitzers). -- myChief:AddToResource(ResourceOccupied, AUFTRAG.Type.ARTY, 1, 2, nil, "MLRS") -- -- Add at least one RECON mission that uses UAV type assets. @@ -199,12 +199,15 @@ -- --- Create a resource list of mission types and required assets for the case that the zone is EMPTY. -- -- -- -- Here, we create an ONGUARD mission and employ at least on and at most five infantry assets. --- local ResourceEmpty=myChief:CreateResource(AUFTRAG.Type.ONGUARD, 1, 5, GROUP.Attribute.GROUND_INFANTRY) +-- local ResourceEmpty, resourceInf=myChief:CreateResource(AUFTRAG.Type.ONGUARD, 1, 5, GROUP.Attribute.GROUND_INFANTRY) -- -- Additionally, we send up to three tank groups. -- myChief:AddToResource(ResourceEmpty, AUFTRAG.Type.ONGUARD, 1, 3, GROUP.Attribute.GROUND_TANK) -- -- Finally, we send two groups that patrol the zone. -- myChief:AddToResource(ResourceEmpty, AUFTRAG.Type.PATROLZONE, 2) -- +-- -- Add a transport to the infantry resource. We want at least one and up to two transport helicopters. +-- myChief:AddTransportToResource(resourceInf, 1, 2, GROUP.Attribute.AIR_TRANSPORTHELO) +-- -- -- Add stratetic zone with customized reaction. -- myChief:AddStrategicZone(myOpsZone, nil , 2, ResourceOccupied, ResourceEmpty) -- @@ -315,12 +318,10 @@ CHIEF.Strategy = { -- @field #number Nmax Max number of assets. -- @field #table Attributes Generalized attribute, e.g. `{GROUP.Attribute.GROUND_INFANTRY}`. -- @field #table Properties Properties ([DCS attributes](https://wiki.hoggitworld.com/view/DCS_enum_attributes)), e.g. `"Attack helicopters"` or `"Mobile AAA"`. +-- @field #table Categories Categories Group categories. -- @field Ops.Auftrag#AUFTRAG mission Attached mission. -- @field #number carrierNmin Min number of assets. -- @field #number carrierNmax Max number of assets. --- @field #table cargoCategories Group categories. --- @field #table cargoAttributes Generalized attribute, e.g. `{GROUP.Attribute.GROUND_INFANTRY}`. --- @field #table cargoProperties Properties ([DCS attributes](https://wiki.hoggitworld.com/view/DCS_enum_attributes)), e.g. `"Attack helicopters"` or `"Mobile AAA"`. -- @field #table carrierCategories Group categories. -- @field #table carrierAttributes Generalized attribute, e.g. `{GROUP.Attribute.GROUND_INFANTRY}`. -- @field #table carrierProperties Properties ([DCS attributes](https://wiki.hoggitworld.com/view/DCS_enum_attributes)), e.g. `"Attack helicopters"` or `"Mobile AAA"`. @@ -328,12 +329,13 @@ CHIEF.Strategy = { --- CHIEF class version. -- @field #string version -CHIEF.version="0.5.1" +CHIEF.version="0.5.2" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- TODO: Event when asset groups die. -- TODO: PLAYERTASK integration. -- DONE: Let user specify amount of resources. -- DONE: Tactical overview. @@ -751,13 +753,14 @@ end -- @param #number Nmax Max number of requried assets. Default 1. -- @param #table Attributes Generalized attribute(s). Default `nil`. -- @param #table Properties DCS attribute(s). Default `nil`. +-- @param #table Categories Group categories. -- @return #CHIEF.Resources The newly created resource list table. -- @return #CHIEF.Resource The resource object that was added. -function CHIEF:CreateResource(MissionType, Nmin, Nmax, Attributes, Properties) +function CHIEF:CreateResource(MissionType, Nmin, Nmax, Attributes, Properties, Categories) local resources={} - local resource=self:AddToResource(resources, MissionType, Nmin, Nmax, Attributes, Properties) + local resource=self:AddToResource(resources, MissionType, Nmin, Nmax, Attributes, Properties, Categories) return resources, resource end @@ -770,21 +773,20 @@ end -- @param #number Nmax Max number of requried assets. Default equal `Nmin`. -- @param #table Attributes Generalized attribute(s). -- @param #table Properties DCS attribute(s). Default `nil`. +-- @param #table Categories Group categories. -- @return #CHIEF.Resource Resource table. -function CHIEF:AddToResource(Resource, MissionType, Nmin, Nmax, Attributes, Properties) +function CHIEF:AddToResource(Resource, MissionType, Nmin, Nmax, Attributes, Properties, Categories) -- Create new resource table. local resource={} --#CHIEF.Resource resource.MissionType=MissionType resource.Nmin=Nmin or 1 resource.Nmax=Nmax or Nmin - resource.Attributes=UTILS.EnsureTable(Attributes) - resource.Properties=UTILS.EnsureTable(Properties) + resource.Attributes=UTILS.EnsureTable(Attributes, true) + resource.Properties=UTILS.EnsureTable(Properties, true) + resource.Categories=UTILS.EnsureTable(Categories, true) -- Transport carrier parameters. - resource.cargoAttributes=nil - resource.cargoProperties=nil - resource.cargoCategories=nil resource.carrierNmin=nil resource.carrierNmax=nil resource.carrierAttributes=nil @@ -810,20 +812,14 @@ end --- Define which assets will be transported and define the number and attributes/properties of the cargo carrier assets. -- @param #CHIEF self -- @param #CHIEF.Resource Resource Resource table. --- @param #table CargoAttributes Generalized attribute(s) of the cargo assets. --- @param #table CargoProperties DCS attribute(s) of the cargo assets. --- @param #table CargoCategories Group categories of the cargo assets. -- @param #number Nmin Min number of required assets. Default 1. -- @param #number Nmax Max number of requried assets. Default is equal to `Nmin`. -- @param #table CarrierAttributes Generalized attribute(s) of the carrier assets. -- @param #table CarrierProperties DCS attribute(s) of the carrier assets. -- @param #table CarrierCategories Group categories of the carrier assets. -- @return #CHIEF self -function CHIEF:AddTransportToResource(Resource, CargoAttributes, CargoProperties, CargoCategories, Nmin, Nmax, CarrierAttributes, CarrierProperties, CarrierCategories) +function CHIEF:AddTransportToResource(Resource, Nmin, Nmax, CarrierAttributes, CarrierProperties, CarrierCategories) - Resource.cargoCategories=CargoCategories - Resource.cargoAttributes=CargoAttributes - Resource.cargoProperties=CargoProperties Resource.carrierNmin=Nmin or 1 Resource.carrierNmax=Nmax or Nmin Resource.carrierCategories=CarrierCategories @@ -1277,7 +1273,7 @@ function CHIEF:AddStrategicZone(OpsZone, Priority, Importance, ResourceOccupied, local resourceEmpty, resourceInfantry=self:CreateResource(AUFTRAG.Type.ONGUARD, 1, 3, GROUP.Attribute.GROUND_INFANTRY) self:AddToResource(resourceEmpty, AUFTRAG.Type.ONGUARD, 0, 1, GROUP.Attribute.GROUND_TANK) self:AddToResource(resourceEmpty, AUFTRAG.Type.ONGUARD, 0, 1, GROUP.Attribute.GROUND_IFV) - self:AddTransportToResource(resourceInfantry, GROUP.Attribute.GROUND_INFANTRY, nil, nil, 0, 1, {GROUP.Attribute.AIR_TRANSPORTHELO, GROUP.Attribute.GROUND_APC}) + self:AddTransportToResource(resourceInfantry, 0, 1, {GROUP.Attribute.AIR_TRANSPORTHELO, GROUP.Attribute.GROUND_APC}) stratzone.resourceEmpty=resourceEmpty end @@ -1613,7 +1609,7 @@ end -- @param #CHIEF self -- @return #CHIEF self function CHIEF:AllowGroundTransport() - env.warning("WARNING: CHIEF:AllowGroundTransport() is depricated and will be removed in the future!") + env.warning("WARNING: CHIEF:AllowGroundTransport() is deprecated and will be removed in the future!") self.TransportCategories = {Group.Category.GROUND, Group.Category.HELICOPTER} return self end @@ -1622,7 +1618,7 @@ end -- @param #CHIEF self -- @return #CHIEF self function CHIEF:ForbidGroundTransport() - env.warning("WARNING: CHIEF:ForbidGroundTransport() is depricated and will be removed in the future!") + env.warning("WARNING: CHIEF:ForbidGroundTransport() is deprecated and will be removed in the future!") self.TransportCategories = {Group.Category.HELICOPTER} return self end @@ -2559,7 +2555,7 @@ function CHIEF:CheckOpsZoneQueue() if (not resource.mission) or resource.mission:IsOver() then -- Debug info. - self:T2(self.lid..string.format("Zone \"%s\" is empty ==> Recruiting for mission type %s: Nmin=%d, Nmax=%d", zoneName, missionType, resource.Nmin, resource.Nmax)) + self:T2(self.lid..string.format("Zone \"%s\" is empty ==> Recruiting for mission type %s: Nmin=%d, Nmax=%d", zoneName, missionType, resource.Nmin, resource.Nmax)) -- Recruit assets. local recruited=self:RecruitAssetsForZone(stratzone, resource) @@ -2969,7 +2965,7 @@ function CHIEF:RecruitAssetsForZone(StratZone, Resource) if Resource.carrierNmin and Resource.carrierNmax and Resource.carrierNmax>0 then -- Filter only those assets that shall be transported. - local cargoassets=CHIEF._FilterAssets(assets, Resource.cargoCategories, Resource.cargoAttributes, Resource.cargoProperties) + local cargoassets=CHIEF._FilterAssets(assets, Resource.Categories, Resource.Attributes, Resource.Properties) if #cargoassets>0 then diff --git a/Moose Development/Moose/Ops/Legion.lua b/Moose Development/Moose/Ops/Legion.lua index d2e0574e9..06905c225 100644 --- a/Moose Development/Moose/Ops/Legion.lua +++ b/Moose Development/Moose/Ops/Legion.lua @@ -2640,9 +2640,12 @@ end -- @param #number NcarriersMax Max number of carrier assets. -- @param Core.Zone#ZONE DeployZone Deploy zone. -- @param Core.Zone#ZONE DisembarkZone (Optional) Disembark zone. +-- @param #table Categories Group categories. +-- @param #table Attributes Generalizes group attributes. +-- @param #table Properties DCS attributes. -- @return #boolean If `true`, enough assets could be recruited and an OPSTRANSPORT object was created. -- @return Ops.OpsTransport#OPSTRANSPORT Transport The transport. -function LEGION:AssignAssetsForTransport(Legions, CargoAssets, NcarriersMin, NcarriersMax, DeployZone, DisembarkZone, Categories, Attributes) +function LEGION:AssignAssetsForTransport(Legions, CargoAssets, NcarriersMin, NcarriersMax, DeployZone, DisembarkZone, Categories, Attributes, Properties) -- Is an escort requested in the first place? if NcarriersMin and NcarriersMax and (NcarriersMin>0 or NcarriersMax>0) then @@ -2682,7 +2685,7 @@ function LEGION:AssignAssetsForTransport(Legions, CargoAssets, NcarriersMin, Nca -- Recruit assets and legions. local TransportAvail, CarrierAssets, CarrierLegions= - LEGION.RecruitCohortAssets(Cohorts, AUFTRAG.Type.OPSTRANSPORT, nil, NcarriersMin, NcarriersMax, TargetVec2, nil, nil, nil, CargoWeight, TotalWeight, Categories, Attributes) + LEGION.RecruitCohortAssets(Cohorts, AUFTRAG.Type.OPSTRANSPORT, nil, NcarriersMin, NcarriersMax, TargetVec2, nil, nil, nil, CargoWeight, TotalWeight, Categories, Attributes, Properties) if TransportAvail then diff --git a/Moose Development/Moose/Utilities/Utils.lua b/Moose Development/Moose/Utilities/Utils.lua index 214bf8a69..704eca831 100644 --- a/Moose Development/Moose/Utilities/Utils.lua +++ b/Moose Development/Moose/Utilities/Utils.lua @@ -2019,15 +2019,21 @@ end --- Ensure the passed object is a table. -- @param #table Object The object that should be a table. --- @return #table The object that is a table. Note that if the Object is `#nil` initially, and empty table `{}` is returned. -function UTILS.EnsureTable(Object) +-- @param #boolean ReturnNil If `true`, return `#nil` if `Object` is nil. Otherwise an empty table `{}` is returned. +-- @return #table The object that now certainly *is* a table. +function UTILS.EnsureTable(Object, ReturnNil) if Object then if type(Object)~="table" then Object={Object} end else - Object={} + if ReturnNil then + return nil + else + Object={} + end + end return Object From 254d43fef1d56222690db1892dd45c07665efc53 Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 6 Nov 2022 12:17:07 +0100 Subject: [PATCH 2/7] AIRWING/WAREHOUSE - Improved parking spot check if explicitly given for an airwing or squadron - Improved parking check if airstart is requested. --- .../Moose/Functional/Warehouse.lua | 58 +++++++++++++++---- Moose Development/Moose/Ops/AirWing.lua | 2 +- 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/Moose Development/Moose/Functional/Warehouse.lua b/Moose Development/Moose/Functional/Warehouse.lua index 26cef4db9..6283a28b3 100644 --- a/Moose Development/Moose/Functional/Warehouse.lua +++ b/Moose Development/Moose/Functional/Warehouse.lua @@ -5810,6 +5810,7 @@ function WAREHOUSE:_SpawnAssetRequest(Request) -- Now we try to find all parking spots for all cargo groups in advance. Due to the for loop, the parking spots do not get updated while spawning. local Parking={} if Request.cargocategory==Group.Category.AIRPLANE or Request.cargocategory==Group.Category.HELICOPTER then + --TODO: Check for airstart. Should be a request property. Parking=self:_FindParkingForAssets(self.airbase, cargoassets) or {} end @@ -6069,7 +6070,9 @@ function WAREHOUSE:_SpawnAssetAircraft(alias, asset, request, parking, uncontrol end if self.Debug then - coord:MarkToAll(string.format("Spawnplace unit %s terminal %d.", unit.name, terminal)) + local text=string.format("Spawnplace unit %s terminal %d.", unit.name, terminal) + coord:MarkToAll(text) + env.info(text) end unit.x=coord.x @@ -7374,6 +7377,7 @@ function WAREHOUSE:_CheckRequestNow(request) local _transports local _assetattribute local _assetcategory + local _assetairstart=false -- Check if at least one (cargo) asset is available. if _nassets>0 then @@ -7381,21 +7385,28 @@ function WAREHOUSE:_CheckRequestNow(request) -- Get the attibute of the requested asset. _assetattribute=_assets[1].attribute _assetcategory=_assets[1].category + _assetairstart=_assets[1].takeoffType and _assets[1].takeoffType==COORDINATE.WaypointType.TurningPoint or false -- Check available parking for air asset units. if _assetcategory==Group.Category.AIRPLANE or _assetcategory==Group.Category.HELICOPTER then if self.airbase and self.airbase:GetCoalition()==self:GetCoalition() then - if self:IsRunwayOperational() then + if self:IsRunwayOperational() or _assetairstart then - local Parking=self:_FindParkingForAssets(self.airbase,_assets) - - --if Parking==nil and not (self.category==Airbase.Category.HELIPAD) then - if Parking==nil then - local text=string.format("Warehouse %s: Request denied! Not enough free parking spots for all requested assets at the moment.", self.alias) - self:_InfoMessage(text, 5) - return false + if _assetairstart then + -- Airstart no need to check parking + else + + -- Check parking. + local Parking=self:_FindParkingForAssets(self.airbase,_assets) + + -- No parking? + if Parking==nil then + local text=string.format("Warehouse %s: Request denied! Not enough free parking spots for all requested assets at the moment.", self.alias) + self:_InfoMessage(text, 5) + return false + end end else @@ -7986,9 +7997,36 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets) local gotit=false for _,_parkingspot in pairs(parkingdata) do local parkingspot=_parkingspot --Wrapper.Airbase#AIRBASE.ParkingSpot + + -- Parking valid? + local valid=true + + if asset.parkingIDs then + -- If asset has assigned parking spots, we take these no matter what. + valid=self:_CheckParkingAsset(parkingspot, asset) + else + + -- Valid terminal type depending on attribute. + local validTerminal=AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype) + + -- Valid parking list. + local validParking=self:_CheckParkingValid(parkingspot) + + -- Black and white list. + local validBWlist=airbase:_CheckParkingLists(parkingspot.TerminalID) + + -- Debug info. + --env.info(string.format("FF validTerminal = %s", tostring(validTerminal))) + --env.info(string.format("FF validParking = %s", tostring(validParking))) + --env.info(string.format("FF validBWlist = %s", tostring(validBWlist))) + + -- Check if all are true + valid=validTerminal and validParking and validBWlist + end + -- Check correct terminal type for asset. We don't want helos in shelters etc. - if AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype) and self:_CheckParkingValid(parkingspot) and self:_CheckParkingAsset(parkingspot, asset) and airbase:_CheckParkingLists(parkingspot.TerminalID) then + if valid then -- Coordinate of the parking spot. local _spot=parkingspot.Coordinate -- Core.Point#COORDINATE diff --git a/Moose Development/Moose/Ops/AirWing.lua b/Moose Development/Moose/Ops/AirWing.lua index 0dae8cb06..fe0d22de5 100644 --- a/Moose Development/Moose/Ops/AirWing.lua +++ b/Moose Development/Moose/Ops/AirWing.lua @@ -863,7 +863,7 @@ function AIRWING:SetAirboss(airboss) return self end ---- Set takeoff type. All assets of this squadron will be spawned with cold (default) or hot engines. +--- Set takeoff type. All assets of this airwing will be spawned with this takeoff type. -- Spawning on runways is not supported. -- @param #AIRWING self -- @param #string TakeoffType Take off type: "Cold" (default) or "Hot" with engines on or "Air" for spawning in air. From b63be6dd28e26d125087d87c15b26a7e547e3683 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Mon, 7 Nov 2022 17:39:11 +0100 Subject: [PATCH 3/7] #PLAYERTASK * Fix #1826 CTLD/CSAR closing immediately --- Moose Development/Moose/Ops/PlayerTask.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Moose Development/Moose/Ops/PlayerTask.lua b/Moose Development/Moose/Ops/PlayerTask.lua index e98bcf67b..3bb7927f4 100644 --- a/Moose Development/Moose/Ops/PlayerTask.lua +++ b/Moose Development/Moose/Ops/PlayerTask.lua @@ -21,7 +21,7 @@ -- === -- @module Ops.PlayerTask -- @image OPS_PlayerTask.jpg --- @date Last Update October 2022 +-- @date Last Update November 2022 do @@ -95,7 +95,7 @@ PLAYERTASK = { --- PLAYERTASK class version. -- @field #string version -PLAYERTASK.version="0.1.9" +PLAYERTASK.version="0.1.10" --- Generic task condition. -- @type PLAYERTASK.Condition @@ -654,11 +654,14 @@ function PLAYERTASK:onafterStatus(From, Event, To) -- Check Target status local targetdead = false - if self.Target:IsDead() or self.Target:IsDestroyed() or self.Target:CountTargets() == 0 then - targetdead = true - self:__Success(-2) - status = "Success" - return self + + if self.Type ~= AUFTRAG.Type.CTLD and self.Type ~= AUFTRAG.Type.CSAR then + if self.Target:IsDead() or self.Target:IsDestroyed() or self.Target:CountTargets() == 0 then + targetdead = true + self:__Success(-2) + status = "Success" + return self + end end if status == "Executing" then From 8ed30da47308ef775b984701c1f31f89002d4315 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 8 Nov 2022 15:43:14 +0100 Subject: [PATCH 4/7] * POINT/PLAYERTASK * Added option to get BR/BRA with add'l magnetic heading --- Moose Development/Moose/Ops/PlayerTask.lua | 31 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/Moose Development/Moose/Ops/PlayerTask.lua b/Moose Development/Moose/Ops/PlayerTask.lua index 3bb7927f4..69327de47 100644 --- a/Moose Development/Moose/Ops/PlayerTask.lua +++ b/Moose Development/Moose/Ops/PlayerTask.lua @@ -922,6 +922,7 @@ do -- @field Ops.PlayerRecce#PLAYERRECCE PlayerRecce -- @field #number Coalition -- @field Core.Menu#MENU_MISSION MenuParent +-- @field #boolean ShowMagnetic Also show magnetic angles -- @extends Core.Fsm#FSM --- @@ -1234,6 +1235,7 @@ PLAYERTASKCONTROLLER = { PlayerRecce = nil, Coalition = nil, MenuParent = nil, + ShowMagnetic = true, } --- @@ -1400,7 +1402,7 @@ PLAYERTASKCONTROLLER.Messages = { --- PLAYERTASK class version. -- @field #string version -PLAYERTASKCONTROLLER.version="0.1.45" +PLAYERTASKCONTROLLER.version="0.1.46" --- Create and run a new TASKCONTROLLER instance. -- @param #PLAYERTASKCONTROLLER self @@ -1456,6 +1458,8 @@ function PLAYERTASKCONTROLLER:New(Name, Coalition, Type, ClientFilter) self.CallsignTranslations = nil self.noflaresmokemenu = false + + self.ShowMagnetic = true if ClientFilter then self.ClientSet = SET_CLIENT:New():FilterCoalitions(string.lower(self.CoalitionName)):FilterActive(true):FilterPrefixes(ClientFilter):FilterStart() @@ -2016,6 +2020,20 @@ function PLAYERTASKCONTROLLER:SwitchUseGroupNames(OnOff) return self end +--- [User] Switch showing additional magnetic angles +-- @param #PLAYERTASKCONTROLLER self +-- @param #boolean OnOff If true, set to on (default), if nil or false, set to off +-- @return #PLAYERTASKCONTROLLER self +function PLAYERTASKCONTROLLER:SwitchMagenticAngles(OnOff) + self:T(self.lid.."SwitchMagenticAngles") + if OnOff then + self.ShowMagnetic = true + else + self.ShowMagnetic = false + end + return self +end + --- [Internal] Get task types for the menu -- @param #PLAYERTASKCONTROLLER self -- @return #table TaskTypes @@ -2681,9 +2699,9 @@ function PLAYERTASKCONTROLLER:_FlashInfo() local Coordinate = task.Target:GetCoordinate() local CoordText = "" if self.Type ~= PLAYERTASKCONTROLLER.Type.A2A then - CoordText = Coordinate:ToStringA2G(_client) + CoordText = Coordinate:ToStringA2G(_client, nil, self.ShowMagnetic) else - CoordText = Coordinate:ToStringA2A(_client) + CoordText = Coordinate:ToStringA2A(_client, nil, self.ShowMagnetic) end local targettxt = self.gettext:GetEntry("TARGET",self.locale) local text = "Target: "..CoordText @@ -2716,9 +2734,9 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Group, Client, Task) local Coordinate = task.Target:GetCoordinate() local CoordText = "" if self.Type ~= PLAYERTASKCONTROLLER.Type.A2A then - CoordText = Coordinate:ToStringA2G(Client) + CoordText = Coordinate:ToStringA2G(Client,nil,self.ShowMagnetic) else - CoordText = Coordinate:ToStringA2A(Client) + CoordText = Coordinate:ToStringA2A(Client,nil,self.ShowMagnetic) end -- Threat Level local ThreatLevel = task.Target:GetThreatLevelMax() @@ -2822,6 +2840,9 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Group, Client, Task) if string.find(CoordText," BR, ") then CoordText = string.gsub(CoordText," BR, "," Bee, Arr, ") end + if self.ShowMagnetic then + text=string.gsub(text,"°M|","° magnetic, ") + end local ThreatLocaleTextTTS = self.gettext:GetEntry("THREATTEXTTTS",self.locale) local ttstext = string.format(ThreatLocaleTextTTS,self.MenuName or self.Name,ttsplayername,ttstaskname,ThreatLevelText, targets, CoordText) -- POINTERTARGETLASINGTTS = ". Pointer over target and lasing." From e348bbc3440c1d26b6140b06027300e165b8debd Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 8 Nov 2022 17:24:32 +0100 Subject: [PATCH 5/7] #AWACS * Minor Enhancements --- Moose Development/Moose/Ops/Awacs.lua | 111 +++----------------------- 1 file changed, 13 insertions(+), 98 deletions(-) diff --git a/Moose Development/Moose/Ops/Awacs.lua b/Moose Development/Moose/Ops/Awacs.lua index 14ccb5922..565fa451a 100644 --- a/Moose Development/Moose/Ops/Awacs.lua +++ b/Moose Development/Moose/Ops/Awacs.lua @@ -17,7 +17,7 @@ -- === -- -- ### Author: **applevangelist** --- @date Last Update September 2022 +-- @date Last Update November 2022 -- @module Ops.AWACS -- @image OPS_AWACS.jpg @@ -497,7 +497,7 @@ do -- @field #AWACS AWACS = { ClassName = "AWACS", -- #string - version = "0.2.46", -- #string + version = "0.2.47", -- #string lid = "", -- #string coalition = coalition.side.BLUE, -- #number coalitiontxt = "blue", -- #string @@ -1980,22 +1980,16 @@ function AWACS:_MessageVector(GID,Tag,Coordinate,Angels) local group = managedgroup.Group local groupposition = group:GetCoordinate() - --local BRtext = Coordinate:ToStringBR(groupposition) local BRtext,BRtextTTS = self:_ToStringBR(groupposition,Coordinate) local vector = self.gettext:GetEntry("VECTORTO",self.locale) local vectortts = self.gettext:GetEntry("VECTORTOTTS",self.locale) local angelstxt = self.gettext:GetEntry("ANGELS",self.locale) - --local text = string.format("%s, %s. Vector%s %s",tocallsign, self.callsigntxt,Tag,BRtextTTS) - --local textScreen = string.format("%s, %s, Vector%s %s",tocallsign, self.callsigntxt,Tag,BRtext) - local text = string.format(vectortts,tocallsign, self.callsigntxt,Tag,BRtextTTS) local textScreen = string.format(vector,tocallsign, self.callsigntxt,Tag,BRtext) if Angels then - --text = text .. ". Angels "..tostring(Angels).."." - --textScreen = textScreen .. ". Angels "..tostring(Angels).."." text = text .. angelstxt ..tostring(Angels).."." textScreen = textScreen ..angelstxt..tostring(Angels).."." end @@ -2215,7 +2209,7 @@ end -- @param #AWACS self -- @param Wrapper.Group#GROUP Group Group to use -- @param #number GID GID to use --- @param #booean IsPlayer Check in player if true +-- @param #boolean IsPlayer Check in player if true -- @return #string Callsign function AWACS:_GetCallSign(Group,GID, IsPlayer) self:T(self.lid.."_GetCallSign - GID "..tostring(GID)) @@ -2326,14 +2320,13 @@ function AWACS:_CleanUpContacts() self.Contacts:ForEach( function (Contact) local contact = Contact -- #AWACS.ManagedContact - if not contact.Contact.group:IsAlive() or contact.Target:IsDead() then + if not contact.Contact.group:IsAlive() or contact.Target:IsDead() or contact.Target:IsDestroyed() or contact.Target:CountTargets() == 0 then deadcontacts:Push(contact,contact.CID) self:T("DEAD contact CID="..contact.CID) end end ) - - --local aliveclusters = FIFO:New() + -- announce VANISHED if deadcontacts:Count() > 0 and (not self.NoGroupTags) then @@ -2460,16 +2453,12 @@ function AWACS:_TargetSelectionProcess(Untargeted) self:T(self.lid..string.format("Looking at group %s type %s",contactname,typename)) local contactcoord = contact.Cluster.coordinate or contact.Contact.position or contact.Contact.group:GetCoordinate() local contactvec2 = contactcoord:GetVec2() - -- self:T({contactcoord:ToStringMGRS()}) - -- self:T({contactvec2}) -- Bucket 0 - NOT in Rejection Zone :) if self.RejectZone then local isinrejzone = self.RejectZone:IsVec2InZone(contactvec2) - --local distance = self.OpsZone:Get2DDistance(contactcoord) if isinrejzone then self:T(self.lid.."Across Border = YES - ignore") - --targettable:Push(contact,distance) checked = true end end @@ -2517,7 +2506,6 @@ function AWACS:_TargetSelectionProcess(Untargeted) if (AOdist2 < 75) or (aspect == "Hot") then local text = string.format("In AO(Adj) dist = %d(%d) NM",AOdist,AOdist2) self:T(self.lid..text) - --if sizing > 2 then distance = math.floor(distance / sizing)+1 end targettable:Push(contact,distance) checked = true end @@ -2602,7 +2590,7 @@ function AWACS:_CreatePicture(AO,Callsign,GID,MaxEntries,IsGeneral) local contact = fifo:Pull() -- #AWACS.ManagedContact self:T({contact}) if contact and contact.Contact.group and contact.Contact.group:IsAlive() then - --local coordinate = contact.Contact.group:GetCoordinate() + local coordinate = contact.Cluster.coordinate or contact.Contact.position or contact.Contact.group:GetCoordinate() -- Core.Point#COORDINATE if not coordinate then self:E(self.lid.."NO Coordinate for this cluster! CID="..contact.CID) @@ -2633,9 +2621,7 @@ function AWACS:_CreatePicture(AO,Callsign,GID,MaxEntries,IsGeneral) local alt = contact.Contact.group:GetAltitude() or 8000 alt = UTILS.Round(UTILS.MetersToFeet(alt)/1000,0) -- Alpha Group. Bulls eye 0 2 1, 16 miles, 25 thousand. - --text = text .. " "..refBRAATTS.." miles, "..alt.." thousand." -- Alpha Group. Bulls eye 0 2 1, 16 miles, 25 thousand. text = string.format("%s %s %s, %d %s.",text,refBRAATTS,milestxt,alt,thsdtxt) - --textScreen = textScreen .. " "..refBRAA.." miles, "..alt.." thousand." -- Alpha Group, Bullseye 021, 16 miles, 25 thousand, textScreen = string.format("%s %s %s, %d %s.",textScreen,refBRAA,milestxt,alt,thsdtxt) else -- pilot reference @@ -2705,7 +2691,6 @@ function AWACS:_CreateBogeyDope(Callsign,GID) local groupcoord = group:GetCoordinate() local fifo = self.ContactsAO -- Utilities.FiFo#FIFO - --local maxentries = self.maxspeakentries local maxentries = 1 local counter = 0 @@ -2745,7 +2730,6 @@ function AWACS:_Picture(Group,IsGeneral) local textScreen = text local general = IsGeneral local GID, Outcome, gcallsign = self:_GetManagedGrpID(Group) - --local gcallsign = "" if general then local allst = self.gettext:GetEntry("ALLSTATIONS",self.locale) @@ -2772,7 +2756,6 @@ function AWACS:_Picture(Group,IsGeneral) -- get clusters from Intel local contactstable = self.Contacts:GetDataTable() - --local clustertable = self.intel:GetClusterTable() or {} -- sort into buckets for _,_contact in pairs(contactstable) do @@ -2824,15 +2807,11 @@ function AWACS:_Picture(Group,IsGeneral) local grptxt = self.gettext:GetEntry("GROUP",self.locale) local groupstxt = self.gettext:GetEntry("GROUPMULTI",self.locale) if clustersAO == 1 then - --text = text .. "One group. " text = string.format("%s%s %s. ",text,onetxt,grptxt) - --textScreen = textScreen .. "One group.\n" textScreen = string.format("%s%s %s.\n",textScreen,onetxt,grptxt) else text = string.format("%s%d %s. ",text,clustersAO,groupstxt) - --text = text .. clustersAO .. " groups. " textScreen = string.format("%s%d %s.\n",textScreen,clustersAO,groupstxt) - --textScreen = textScreen .. clustersAO .. " groups.\n" end self:_NewRadioEntry(text,textScreen,GID,Outcome,true,true,false) @@ -2917,28 +2896,15 @@ function AWACS:_BogeyDope(Group) if contactsAO > 0 then local dope = self.gettext:GetEntry("DOPE",self.locale) text = string.format(dope,self:_GetCallSign(Group,GID) or "Ghost 1", self.callsigntxt) - --[[ - if contactsAO == 1 then - text = text .. "One group. " - textScreen = text .. "\n" - else - text = text .. contactsAO .. " groups. " - textScreen = textScreen .. contactsAO .. " groups.\n" - end - --]] local onetxt = self.gettext:GetEntry("ONE",self.locale) local grptxt = self.gettext:GetEntry("GROUP",self.locale) local groupstxt = self.gettext:GetEntry("GROUPMULTI",self.locale) if contactsAO == 1 then - --text = text .. "One group. " text = string.format("%s%s %s. ",text,onetxt,grptxt) - --textScreen = textScreen .. "One group.\n" textScreen = string.format("%s%s %s.\n",textScreen,onetxt,grptxt) else text = string.format("%s%d %s. ",text,contactsAO,groupstxt) - --text = text .. clustersAO .. " groups. " textScreen = string.format("%s%d %s.\n",textScreen,contactsAO,groupstxt) - --textScreen = textScreen .. clustersAO .. " groups.\n" end self:_NewRadioEntry(text,textScreen,GID,Outcome,true,true,false,true) @@ -2949,7 +2915,6 @@ function AWACS:_BogeyDope(Group) elseif self.AwacsFG then -- no, unknown - --text = string.format("%s. %s. Negative. You are not checked in.",self:_GetCallSign(Group,GID) or "Ghost 1", self.callsigntxt) local nocheckin = self.gettext:GetEntry("NOTCHECKEDIN",self.locale) text = string.format(nocheckin,self:_GetCallSign(Group,GID) or "Ghost 1", self.callsigntxt) self:_NewRadioEntry(text,text,GID,Outcome,true,true,false) @@ -3248,7 +3213,6 @@ function AWACS:_Unable(Group) if managedtask.Status == AWACS.TaskStatus.REQUESTED then -- ok let's commit this one managedtask = self.ManagedTasks:PullByID(currtaskid) - --managedtask.AssignedGroupID = 0 managedtask.IsUnassigned = true managedtask.Status = AWACS.TaskStatus.FAILED self.ManagedTasks:Push(managedtask,currtaskid) @@ -3284,7 +3248,6 @@ end -- @return #AWACS self function AWACS:_TaskAbort(Group) self:T(self.lid.."_TaskAbort") - --local GID, Outcome = self:_GetManagedGrpID(Group) local Outcome,GID = self:_GetGIDFromGroupOrName(Group) local text = "" if Outcome then @@ -3300,7 +3263,6 @@ function AWACS:_TaskAbort(Group) -- ok let's un-commit this one managedtask = self.ManagedTasks:PullByID(currtaskid) managedtask.Status = AWACS.TaskStatus.FAILED - --managedtask.AssignedGroupID = 0 managedtask.IsUnassigned = true self.ManagedTasks:Push(managedtask,currtaskid) -- unlink group @@ -3431,8 +3393,7 @@ function AWACS:_CheckIn(Group) local alphacheckbulls = self:_ToStringBULLS(Group:GetCoordinate()) local alphacheckbullstts = self:_ToStringBULLS(Group:GetCoordinate(),false,true) - - --self.ManagedGrps[self.ManagedGrpID]=managedgroup + local alpha = self.gettext:GetEntry("ALPHACHECK",self.locale) text = string.format("%s. %s. %s. %s",managedgroup.CallSign,self.callsigntxt,alpha,alphacheckbulls) textTTS = text @@ -3555,11 +3516,9 @@ function AWACS:_CheckOut(Group,GID,dead) local Angels = managedgroup.AnchorStackAngels -- remove menus if managedgroup.IsPlayer then - -- DONE Move to FIFO if self.clientmenus:HasUniqueID(managedgroup.GroupName) then local menus = self.clientmenus:PullByID(managedgroup.GroupName) --#AWACS.MenuStructure menus.basemenu:Remove() - --self.clientmenus[AnchorAssigned.GroupName] = nil end end -- delete open tasks @@ -3591,7 +3550,6 @@ function AWACS:_SetClientMenus() self:T(self.lid.."_SetClientMenus") local clientset = self.clientset -- Core.Set#SET_CLIENT local aliveset = clientset:GetSetObjects() or {}-- #table of #CLIENT objects - --local clientmenus = {} local clientcount = 0 local clientcheckedin = 0 for _,_group in pairs(aliveset) do @@ -3603,7 +3561,6 @@ function AWACS:_SetClientMenus() cgrpname = cgrp:GetName() self:T(cgrpname) end - --cgrpname = string.match(cgrpname,"([%a%s]+)#") if self.MenuStrict then -- check if pilot has checked in if cgrp and cgrp:IsAlive() then @@ -3612,9 +3569,7 @@ function AWACS:_SetClientMenus() if checkedin then -- full menu minus checkin clientcheckedin = clientcheckedin + 1 - --self.clientmenus:Flush() local hasclientmenu = self.clientmenus:ReadByID(cgrpname) -- #AWACS.MenuStructure - --self:T({hasclientmenu}) local basemenu = hasclientmenu.basemenu -- Core.Menu#MENU_GROUP if hasclientmenu and (not hasclientmenu.menuset) then @@ -3622,7 +3577,6 @@ function AWACS:_SetClientMenus() self:T(self.lid.."Setting Menus for "..cgrpname) basemenu:RemoveSubMenus() - --basemenu:Refresh() local bogeydope = MENU_GROUP_COMMAND:New(cgrp,"Bogey Dope",basemenu,self._BogeyDope,self,cgrp) local picture = MENU_GROUP_COMMAND:New(cgrp,"Picture",basemenu,self._Picture,self,cgrp) local declare = MENU_GROUP_COMMAND:New(cgrp,"Declare",basemenu,self._Declare,self,cgrp) @@ -3665,10 +3619,8 @@ function AWACS:_SetClientMenus() elseif not self.clientmenus:HasUniqueID(cgrpname) then -- check in only local basemenu = MENU_GROUP:New(cgrp,self.Name,nil) - --basemenu:RemoveSubMenus() local checkin = MENU_GROUP_COMMAND:New(cgrp,"Check In",basemenu,self._CheckIn,self,cgrp) checkin:SetTag(cgrp:GetName()) - --basemenu:Set() basemenu:Refresh() local menus = { -- #AWACS.MenuStructure groupname = cgrpname, @@ -3682,8 +3634,6 @@ function AWACS:_SetClientMenus() else if cgrp and cgrp:IsAlive() and not self.clientmenus:HasUniqueID(cgrpname) then local basemenu = MENU_GROUP:New(cgrp,self.Name,nil) - --basemenu:RemoveSubMenus() - --basemenu:Refresh() local picture = MENU_GROUP_COMMAND:New(cgrp,"Picture",basemenu,self._Picture,self,cgrp) local bogeydope = MENU_GROUP_COMMAND:New(cgrp,"Bogey Dope",basemenu,self._BogeyDope,self,cgrp) local declare = MENU_GROUP_COMMAND:New(cgrp,"Declare",basemenu,self._Declare,self,cgrp) @@ -3885,7 +3835,6 @@ function AWACS:_CreateAnchorStack() AnchorStackOne.StationName = newname --push to AnchorStacks if self.debug then - --self.AnchorStacks:Flush() AnchorStackOne.StationZone:DrawZone(self.coalition,{0,0,1},1,{0,0,1},0.2,5,true) local stationtag = string.format("Station: %s\nCoordinate: %s",newname,self.StationZone:GetCoordinate():ToStringLLDDM()) AnchorStackOne.AnchorMarker=MARKER:New(AnchorStackOne.StationZone:GetCoordinate(),stationtag):ToCoalition(self.coalition) @@ -4023,7 +3972,6 @@ function AWACS:_StartIntel(awacs) acceptzoneset:AddZone(self.BorderZone) end - --self.AwacsInZone intel:SetAcceptZones(acceptzoneset) if self.NoHelos then @@ -4475,8 +4423,8 @@ function AWACS:_CheckTaskQueue() end elseif entry.IsPlayerTask then -- Player task - -- TODO - if entry.Target:IsDead() or entry.Target:IsDestroyed() then + -- DONE + if entry.Target:IsDead() or entry.Target:IsDestroyed() or entry.Target:CountTargets() == 0 then -- success! entry.Status = AWACS.TaskStatus.SUCCESS elseif entry.Target:IsAlive() then @@ -4593,7 +4541,7 @@ function AWACS:_CheckTaskQueue() end -- target dead or out of bounds? - if entry.Target:IsDead() or entry.Target:IsDestroyed() then + if entry.Target:IsDead() or entry.Target:IsDestroyed() or entry.Target:CountTargets() == 0 then -- success! entry.Status = AWACS.TaskStatus.SUCCESS elseif entry.Target:IsAlive() then @@ -4819,7 +4767,6 @@ function AWACS:AddCAPAirWing(AirWing,Zone) AnchorStackOne.StationName = newname --push to AnchorStacks if self.debug then - --self.AnchorStacks:Flush() AnchorStackOne.StationZone:DrawZone(self.coalition,{0,0,1},1,{0,0,1},0.2,5,true) local stationtag = string.format("Station: %s\nCoordinate: %s",newname,self.StationZone:GetCoordinate():ToStringLLDDM()) AnchorStackOne.AnchorMarker=MARKER:New(AnchorStackOne.StationZone:GetCoordinate(),stationtag):ToCoalition(self.coalition) @@ -4914,24 +4861,16 @@ function AWACS:_AnnounceContact(Contact,IsNew,Group,IsBogeyDope,Tag,IsPopup,Repo local popup = self.gettext:GetEntry("POPUP",self.locale) if IsNew and self.PlayerGuidance then - --BRAText = BRAText .. " New group." BRAText = string.format("%s %s.",BRAText,newgrp) - --TextScreen = TextScreen .. " New group." TextScreen = string.format("%s %s.",TextScreen,newgrp) elseif IsPopup then - --BRAText = BRAText .. " Pop-up group." BRAText = string.format("%s %s %s.",BRAText,popup,grptxt) - --TextScreen = TextScreen .. " Pop-up group." TextScreen = string.format("%s %s %s.",TextScreen,popup,grptxt) elseif IsBogeyDope and Tag and Tag ~= "" then - --BRAText = BRAText .. " "..Tag.." group." BRAText = string.format("%s %s %s.",BRAText,Tag,grptxt) - --TextScreen = TextScreen .. " "..Tag.." group." TextScreen = string.format("%s %s %s.",TextScreen,Tag,grptxt) else - --BRAText = BRAText .. " Group." BRAText = string.format("%s %s.",BRAText,GRPtxt) - --TextScreen = TextScreen .. " Group." TextScreen = string.format("%s %s.",TextScreen,GRPtxt) end @@ -5205,7 +5144,6 @@ function AWACS:_CheckAICAPOnStation() local OpsGroup = self:_GetAliveOpsGroupFromTable(OpsGroups) -- Ops.OpsGroup#OPSGROUP if OpsGroup then local OpsName = OpsGroup:GetName() or "Unknown" - --local OpsCallSign = OpsGroup:GetCallsignName() or "Unknown" local found,GID,OpsCallSign = self:_GetGIDFromGroupOrName(OpsGroup) report:Add(string.format("Mission FG %s",OpsName)) report:Add(string.format("Callsign %s",OpsCallSign)) @@ -5485,7 +5423,7 @@ function AWACS:_AssignPilotToTarget(Pilots,Targets) -- BASE:I("AUFTRAG Condition Succes Eval Running") local success = true local target = target -- Ops.Target#TARGET - if target:IsDestroyed() then return true end + if target:IsDestroyed() or target:IsDead() or target:CountTargets() == 0 then return true end local tgtcoord = target:GetCoordinate() local tgtvec2 = nil if tgtcoord then @@ -5496,7 +5434,6 @@ function AWACS:_AssignPilotToTarget(Pilots,Targets) if tgtvec2 then zones:ForEachZone( function(zone) - -- BASE:I("AUFTRAG Condition Succes ZONE Eval Running") if zone:IsVec2InZone(tgtvec2) then success = false end @@ -5504,7 +5441,6 @@ function AWACS:_AssignPilotToTarget(Pilots,Targets) ) rzones:ForEachZone( function(zone) - -- BASE:I("AUFTRAG Condition Succes REJECT ZONE Eval Running") if zone:IsVec2InZone(tgtvec2) then success = true end @@ -5603,7 +5539,6 @@ function AWACS:onafterStart(From, Event, To) self.ControlZone = ZONE_RADIUS:New(controlzonename,self.OpsZone:GetVec2(),UTILS.NMToMeters(self.ControlZoneRadius)) if self.debug then self.ControlZone:DrawZone(self.coalition,{0,1,0},1,{1,0,0},0.05,3,true) - --MARKER:New(self.ControlZone:GetCoordinate(),"Radar Zone"):ToAll() self.OpsZone:DrawZone(self.coalition,{1,0,0},1,{1,0,0},0.2,5,true) local AOCoordString = self.AOCoordinate:ToStringLLDDM() local Rocktag = string.format("FEZ: %s\nBulls Coordinate: %s",self.AOName,AOCoordString) @@ -5658,7 +5593,6 @@ function AWACS:onafterStart(From, Event, To) return self end - --self.AwacsFG:SetSRS(self.PathToSRS,self.Gender,self.Culture,self.Voice,self.Port,self.PathToGoogleKey,"AWACS",self.Volume) self.callsigntxt = string.format("%s",self.CallSignClear[self.CallSign]) self:__CheckRadioQueue(-10) @@ -5717,17 +5651,14 @@ function AWACS:onafterStart(From, Event, To) -- Event functions function MarkerOps:OnAfterMarkAdded(From,Event,To,Text,Keywords,Coord) - --local m = MESSAGE:New(string.format("AWACS %s Mark Added.", self.Tag),10,"Info",true):ToAllIf(self.debug) Handler(Keywords,Coord,Text) end function MarkerOps:OnAfterMarkChanged(From,Event,To,Text,Keywords,Coord) - --BASE:I(string.format("%s Mark Changed.", self.Tag)) Handler(Keywords,Coord,Text) end function MarkerOps:OnAfterMarkDeleted(From,Event,To) - --BASE:I(string.format("%s Mark Deleted.", self.Tag)) end self.MarkerOps = MarkerOps @@ -5788,7 +5719,6 @@ function AWACS:_CheckAwacsStatus() local sunrise = self.gettext:GetEntry("SUNRISE",self.locale) local text = string.format(sunrise,self.callsigntxt,self.callsigntxt) self:_NewRadioEntry(text,text,0,false,false,false,false,true) - --self.AwacsFG:RadioTransmission(text,1,false) self:T(self.lid..text) self.sunrisedone = true end @@ -5925,13 +5855,10 @@ function AWACS:_CheckAwacsStatus() local ESTOSLeft = UTILS.Round((((self.EscortsTimeOnStation+self.ShiftChangeTime)*3600) - ESmissiontime),0) -- seconds ESTOSLeft = UTILS.Round(ESTOSLeft/60,0) -- minutes local ChangeTime = UTILS.Round(((self.ShiftChangeTime * 3600)/60),0) - --local Changedue = "No" - - --report:Add("====================") + report:Add("ESCORTS REPLACEMENT:") report:Add(string.format("Auftrag Status: %s",esstatus)) report:Add(string.format("TOS Left: %d min",ESTOSLeft)) - --report:Add(string.format("Needs ShiftChange: %s",Changedue)) local OpsGroups = ESmission:GetOpsGroups() local OpsGroup = self:_GetAliveOpsGroupFromTable(OpsGroups) -- Ops.OpsGroup#OPSGROUP @@ -6016,17 +5943,13 @@ function AWACS:onafterStatus(From, Event, To) self:_CheckMerges() - if self.debug then - --local outcome, targets = self:_TargetSelectionProcess() -- TODO for debug ATM - end - local outcome, targets = self:_TargetSelectionProcess(true) self:_CheckTaskQueue() local AI, Humans = self:_GetIdlePilots() -- assign Pilot if there are targets and available Pilots, prefer Humans to AI - -- TODO - Implemented AI First, Humans laters - need to work out how to loop the targets to assign a pilot + -- DONE - Implemented AI First, Humans laters - need to work out how to loop the targets to assign a pilot if outcome and #Humans > 0 and self.PlayerCapAssigment then -- add a task for AI self:_AssignPilotToTarget(Humans,targets) @@ -6163,7 +6086,6 @@ function AWACS:onafterAssignedAnchor(From, Event, To, GID, Anchor, AnchorStackNo local isAI = managedgroup.IsAI local Group = managedgroup.Group local CallSign = managedgroup.CallSign or "Ghost 1" - --local AnchorName = Anchor.StationZone:GetName() or "unknown" local AnchorName = Anchor.StationName or "unknown" local AnchorCoordTxt = Anchor.StationZoneCoordinateText or "unknown" local Angels = AnchorAngels or 25 @@ -6345,7 +6267,6 @@ end -- @return #AWACS self function AWACS:onafterLostContact(From,Event,To,Contact) self:T({From, Event, To, Contact}) - --self:_CleanUpContacts() return self end @@ -6359,7 +6280,6 @@ end -- @return #AWACS self function AWACS:onafterLostCluster(From,Event,To,Cluster,Mission) self:T({From, Event, To}) - --self:_CleanUpContacts() return self end @@ -6396,10 +6316,8 @@ function AWACS:onafterCheckRadioQueue(From,Event,To) if self.PathToGoogleKey then local gtext = RadioEntry.TextTTS gtext = string.format("%s",gtext) - --self.AwacsFG:RadioTransmission(gtext,1,false) self.AwacsSRS:PlayTextExt(gtext,nil,self.MultiFrequency,self.MultiModulation,self.Gender,self.Culture,self.Voice,self.Volume,"AWACS") else - --self.AwacsFG:RadioTransmission(RadioEntry.TextTTS,1,false) self.AwacsSRS:PlayTextExt(RadioEntry.TextTTS,nil,self.MultiFrequency,self.MultiModulation,self.Gender,self.Culture,self.Voice,self.Volume,"AWACS") end self:T(RadioEntry.TextTTS) @@ -6647,9 +6565,6 @@ function AWACS:onafterReAnchor(From, Event, To, GID) local lastknown = UTILS.DeepCopy(managedgroup.LastKnownPosition) local brtext = self:_ToStringBULLS(lastknown) local brtexttts = self:_ToStringBULLS(lastknown,false,true) - --if self.PathToGoogleKey then - --brtexttts = self:_ToStringBULLS(lastknown,true) - --end text = text .. " "..brtexttts.." "..milestxt.."." textScreen = textScreen .. " "..brtext.." "..milestxt.."." From 0e78be86e48e4066dba8db74b169d1c756cfc44e Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 8 Nov 2022 20:29:51 +0100 Subject: [PATCH 6/7] CHIEF - Added resource.carrierProperties for LEGION.AssignAssetsForTransport - Ensure table for carrier categories, attributes and properties --- Moose Development/Moose/Ops/Chief.lua | 13 +++++++------ Moose Development/Moose/Ops/Legion.lua | 7 +++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Moose Development/Moose/Ops/Chief.lua b/Moose Development/Moose/Ops/Chief.lua index 4443531a8..fe60fed48 100644 --- a/Moose Development/Moose/Ops/Chief.lua +++ b/Moose Development/Moose/Ops/Chief.lua @@ -188,6 +188,7 @@ -- --- Create a resource list of mission types and required assets for the case that the zone is OCCUPIED. -- -- -- -- Here, we create an enhanced CAS mission and employ at least on and at most two asset groups. +-- -- NOTE that two objects are returned, the resource list (ResourceOccupied) and the first resource of that list (resourceCAS). -- local ResourceOccupied, resourceCAS=myChief:CreateResource(AUFTRAG.Type.CASENHANCED, 1, 2) -- -- We also add ARTY missions with at least one and at most two assets. We additionally require these to be MLRS groups (and not howitzers). -- myChief:AddToResource(ResourceOccupied, AUFTRAG.Type.ARTY, 1, 2, nil, "MLRS") @@ -197,7 +198,7 @@ -- myChief:AddToResource(ResourceOccupied, AUFTRAG.Type.BOMBCARPET, 1, 2) -- -- --- Create a resource list of mission types and required assets for the case that the zone is EMPTY. --- -- +-- -- NOTE that two objects are returned, the resource list (ResourceEmpty) and the first resource of that list (resourceInf). -- -- Here, we create an ONGUARD mission and employ at least on and at most five infantry assets. -- local ResourceEmpty, resourceInf=myChief:CreateResource(AUFTRAG.Type.ONGUARD, 1, 5, GROUP.Attribute.GROUND_INFANTRY) -- -- Additionally, we send up to three tank groups. @@ -329,7 +330,7 @@ CHIEF.Strategy = { --- CHIEF class version. -- @field #string version -CHIEF.version="0.5.2" +CHIEF.version="0.5.3" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -822,9 +823,9 @@ function CHIEF:AddTransportToResource(Resource, Nmin, Nmax, CarrierAttributes, C Resource.carrierNmin=Nmin or 1 Resource.carrierNmax=Nmax or Nmin - Resource.carrierCategories=CarrierCategories - Resource.carrierAttributes=CarrierAttributes - Resource.carrierProperties=CarrierProperties + Resource.carrierCategories=UTILS.EnsureTable(CarrierCategories, true) + Resource.carrierAttributes=UTILS.EnsureTable(CarrierAttributes, true) + Resource.carrierProperties=UTILS.EnsureTable(CarrierProperties, true) return self end @@ -2971,7 +2972,7 @@ function CHIEF:RecruitAssetsForZone(StratZone, Resource) -- Recruit transport carrier assets. recruited, transport=LEGION.AssignAssetsForTransport(self.commander, self.commander.legions, cargoassets, - Resource.carrierNmin, Resource.carrierNmax, TargetZone, nil, Resource.carrierCategories, Resource.carrierAttributes) + Resource.carrierNmin, Resource.carrierNmax, TargetZone, nil, Resource.carrierCategories, Resource.carrierAttributes, Resource.carrierProperties) end diff --git a/Moose Development/Moose/Ops/Legion.lua b/Moose Development/Moose/Ops/Legion.lua index 06905c225..80fdf1e9e 100644 --- a/Moose Development/Moose/Ops/Legion.lua +++ b/Moose Development/Moose/Ops/Legion.lua @@ -2649,7 +2649,7 @@ function LEGION:AssignAssetsForTransport(Legions, CargoAssets, NcarriersMin, Nca -- Is an escort requested in the first place? if NcarriersMin and NcarriersMax and (NcarriersMin>0 or NcarriersMax>0) then - + -- Cohorts. local Cohorts={} for _,_legion in pairs(Legions) do @@ -2688,7 +2688,7 @@ function LEGION:AssignAssetsForTransport(Legions, CargoAssets, NcarriersMin, Nca LEGION.RecruitCohortAssets(Cohorts, AUFTRAG.Type.OPSTRANSPORT, nil, NcarriersMin, NcarriersMax, TargetVec2, nil, nil, nil, CargoWeight, TotalWeight, Categories, Attributes, Properties) if TransportAvail then - + -- Create and OPSTRANSPORT assignment. local Transport=OPSTRANSPORT:New(nil, nil, DeployZone) if DisembarkZone then @@ -2735,6 +2735,9 @@ function LEGION:AssignAssetsForTransport(Legions, CargoAssets, NcarriersMin, Nca -- Got transport. return true, Transport else + -- Debug info. + self:T(self.lid..string.format("Transport assets could not be allocated ==> Unrecruiting assets")) + -- Uncrecruit transport assets. LEGION.UnRecruitAssets(CarrierAssets) return false, nil From a4b536234776e8a327f8c55b8c24dba04a392c0d Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 8 Nov 2022 22:01:44 +0100 Subject: [PATCH 7/7] Update Cohort.lua - Added functions to get and set attributes - Added function to get category and properties --- Moose Development/Moose/Ops/Cohort.lua | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Moose Development/Moose/Ops/Cohort.lua b/Moose Development/Moose/Ops/Cohort.lua index 4c059b639..9b748e992 100644 --- a/Moose Development/Moose/Ops/Cohort.lua +++ b/Moose Development/Moose/Ops/Cohort.lua @@ -504,6 +504,37 @@ function COHORT:SetCallsign(Callsign, Index) return self end +--- Set generalized attribute. +-- @param #COHORT self +-- @param #string Attribute Generalized attribute, e.g. `GROUP.Attribute.Ground_Infantry`. +-- @return #COHORT self +function COHORT:SetAttribute(Attribute) + self.attribute=Attribute + return self +end + +--- Get generalized attribute. +-- @param #COHORT self +-- @return #string Generalized attribute, e.g. `GROUP.Attribute.Ground_Infantry`. +function COHORT:GetAttribute() + return self.attribute +end + +--- Get group category. +-- @param #COHORT self +-- @return #string Group category +function COHORT:GetCategory() + return self.category +end + +--- Get properties, *i.e.* DCS attributes. +-- @param #COHORT self +-- @return #table Properties table. +function COHORT:GetProperties() + return self.properties +end + + --- Set modex. -- @param #COHORT self -- @param #number Modex A number like 100.