From ab13b5f198ba58253bc91580464c6ddb6e9a6645 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 10 Nov 2022 00:36:02 +0100 Subject: [PATCH 01/14] Update Intelligence.lua - Added check for filter categories. --- Moose Development/Moose/Ops/Intelligence.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Moose Development/Moose/Ops/Intelligence.lua b/Moose Development/Moose/Ops/Intelligence.lua index fe92965cb..0f71a234e 100644 --- a/Moose Development/Moose/Ops/Intelligence.lua +++ b/Moose Development/Moose/Ops/Intelligence.lua @@ -159,7 +159,7 @@ INTEL.Ctype={ --- INTEL class version. -- @field #string version -INTEL.version="0.3.4" +INTEL.version="0.3.5" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- ToDo list @@ -815,8 +815,8 @@ function INTEL:UpdateIntel() end end - -- Filter unit categories. - if #self.filterCategory>0 then + -- Filter unit categories. Added check that we have a UNIT and not a STATIC object because :GetUnitCategory() is only available for units. + if #self.filterCategory>0 and unit:IsInstanceOf("UNIT") then local unitcategory=unit:GetUnitCategory() local keepit=false for _,filtercategory in pairs(self.filterCategory) do @@ -1077,11 +1077,13 @@ function INTEL:GetDetectedUnits(Unit, DetectedUnits, RecceDetecting, DetectVisua RecceDetecting[name]=reccename self:T(string.format("Unit %s detect by %s", name, reccename)) else - local static=STATIC:FindByName(name, false) - if static then - --env.info("FF found static "..name) - DetectedUnits[name]=static - RecceDetecting[name]=reccename + if self.detectStatics then + local static=STATIC:FindByName(name, false) + if static then + --env.info("FF found static "..name) + DetectedUnits[name]=static + RecceDetecting[name]=reccename + end end end From a0ad5292b97b751d4a72ee81d46657844a238283 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Thu, 10 Nov 2022 12:18:18 +0100 Subject: [PATCH 02/14] #AWACS * SRS output for "ShowTask" * Some minor bug fixing --- Moose Development/Moose/Ops/Awacs.lua | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/Moose Development/Moose/Ops/Awacs.lua b/Moose Development/Moose/Ops/Awacs.lua index 565fa451a..92e5c2eaf 100644 --- a/Moose Development/Moose/Ops/Awacs.lua +++ b/Moose Development/Moose/Ops/Awacs.lua @@ -497,7 +497,7 @@ do -- @field #AWACS AWACS = { ClassName = "AWACS", -- #string - version = "0.2.47", -- #string + version = "0.2.49", -- #string lid = "", -- #string coalition = coalition.side.BLUE, -- #number coalitiontxt = "blue", -- #string @@ -2153,7 +2153,8 @@ function AWACS:_ToStringBULLS( Coordinate, ssml, TTS ) local Distance = UTILS.Round( UTILS.MetersToNM( Distance ), 0 ) if ssml then return string.format("%s %03d, %d",bullseyename,Bearing,Distance) - elseif TTS then + end + if TTS then Bearing = self:_ToStringBullsTTS(Bearing) local zero = self.gettext:GetEntry("ZERO",self.locale) local BearingTTS = string.gsub(Bearing,"0",zero) @@ -3320,6 +3321,7 @@ function AWACS:_Showtask(Group) local targetstatus = currenttask.Target:GetState() local ToDo = currenttask.ToDo local description = currenttask.ScreenText + local descTTS = currenttask.ScreenText local callsign = Callsign if self.debug then @@ -3338,17 +3340,23 @@ function AWACS:_Showtask(Group) local targetpos = currenttask.Target:GetCoordinate() if pposition and targetpos then local alti = currenttask.Cluster.altitude or currenttask.Contact.altitude or currenttask.Contact.group:GetAltitude() - local direction = self:_ToStringBRA(pposition,targetpos,alti) + local direction, direcTTS = self:_ToStringBRA(pposition,targetpos,alti) description = description .. "\nBRA "..direction + descTTS = descTTS ..";BRA "..direcTTS end elseif currenttask.ToDo == AWACS.TaskDescription.ANCHOR or currenttask.ToDo == AWACS.TaskDescription.REANCHOR then local targetpos = currenttask.Target:GetCoordinate() - local direction = self:_ToStringBR(pposition,targetpos) + local direction, direcTTS = self:_ToStringBR(pposition,targetpos) description = description .. "\nBR "..direction + descTTS = descTTS .. ";BR "..direcTTS end local statustxt = self.gettext:GetEntry("STATUS",self.locale) - MESSAGE:New(string.format("%s\n%s %s",description,statustxt,status),30,"AWACS",true):ToGroup(Group) - + --MESSAGE:New(string.format("%s\n%s %s",description,statustxt,status),30,"AWACS",true):ToGroup(Group) + local text = string.format("%s\n%s %s",description,statustxt,status) + local ttstext = string.format("%s. %s. %s",managedgroup.CallSign,self.callsigntxt,descTTS) + ttstext = string.gsub(ttstext,"\\n",";") + ttstext = string.gsub(ttstext,"VID","V I D") + self:_NewRadioEntry(ttstext,text,GID,true,true,false,false,true) end end end @@ -3393,11 +3401,10 @@ function AWACS:_CheckIn(Group) local alphacheckbulls = self:_ToStringBULLS(Group:GetCoordinate()) local alphacheckbullstts = self:_ToStringBULLS(Group:GetCoordinate(),false,true) - local alpha = self.gettext:GetEntry("ALPHACHECK",self.locale) text = string.format("%s. %s. %s. %s",managedgroup.CallSign,self.callsigntxt,alpha,alphacheckbulls) - textTTS = text - + textTTS = string.format("%s. %s. %s. %s",managedgroup.CallSign,self.callsigntxt,alpha,alphacheckbullstts) + self:__CheckedIn(1,managedgroup.GID) if self.PlayerStationName then From 27598406d1c6ac761cef4ff41bdd9917208f61ab Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Thu, 10 Nov 2022 17:11:29 +0100 Subject: [PATCH 03/14] #AMMOTRUCK * Initial Release --- .../Moose/Functional/AmmoTruck.lua | 792 ++++++++++++++++++ Moose Development/Moose/Modules.lua | 1 + Moose Setup/Moose.files | 1 + 3 files changed, 794 insertions(+) create mode 100644 Moose Development/Moose/Functional/AmmoTruck.lua diff --git a/Moose Development/Moose/Functional/AmmoTruck.lua b/Moose Development/Moose/Functional/AmmoTruck.lua new file mode 100644 index 000000000..ddfb25a21 --- /dev/null +++ b/Moose Development/Moose/Functional/AmmoTruck.lua @@ -0,0 +1,792 @@ +--- **Functional** -- Send a truck to supply artillery groups. +-- +-- === +-- +-- **AMMOTRUCK** - Send a truck to supply artillery groups. +-- +-- === +-- +-- ## Missions: +-- +-- ### [tbd](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/tbd) +-- +-- === +-- +-- ### Author : **applevangelist ** +-- +-- @module Functional.AmmoTruck +-- @image Functional.AmmoTruck.jpg +-- +-- Date: Nov 2022 + +------------------------------------------------------------------------- +--- **AMMOTRUCK** class, extends Core.FSM#FSM +-- @type AMMOTRUCK +-- @field #string ClassName Class Name +-- @field #string lid Lid for log entries +-- @field #string version Version string +-- @field #string alias Alias name +-- @field #boolean debug Debug flag +-- @field #table trucklist List of (alive) #AMMOTRUCK.data trucks +-- @field #table targetlist List of (alive) #AMMOTRUCK.data artillery +-- @field #number coalition Coalition this is for +-- @field Core.Set#SET_GROUP truckset SET of trucks +-- @field Core.Set#SET_GROUP targetset SET of artillery +-- @field #table remunitionqueue List of (alive) #AMMOTRUCK.data artillery to be reloaded +-- @field #table waitingtargets List of (alive) #AMMOTRUCK.data artillery waiting +-- @field #number ammothreshold Threshold (min) ammo before sending a truck +-- @field #number remunidist Max distance trucks will go +-- @field #number monitor Monitor interval in seconds +-- @field #number unloadtime Unload time in seconds +-- @field #number waitingtime Max waiting time in seconds +-- @field #boolean routeonroad Route truck on road if true (default) +-- @extends Core.FSM#FSM + +--- *Amateurs talk about tactics, but professionals study logistics.* - Gen. Robert H. Barrow, USMC +-- +-- Simple Class to re-arm your artillery with trucks. +-- +-- #AMMOTRUCK +-- +-- * Controls a SET\_GROUP of trucks which will re-arm a SET\_GROUP of artillery groups when they run out of ammunition. +-- +-- ## 1 The AMMOTRUCK concept +-- +-- A SET\_GROUP of trucks which will re-arm a SET\_GROUP of artillery groups when they run out of ammunition. They will be based on a +-- homebase and drive from there to the artillery groups and then back home. +-- Trucks are the **only known in-game mechanic** to re-arm artillery and other units in DCS. Working units are e.g.: M-939 (blue), Ural-375 and ZIL-135 (both red). +-- +-- ## 2 Set-up +-- +-- Define a set of trucks and a set of artillery: +-- +-- local truckset = SET_GROUP:New():FilterCoalitions("blue"):FilterActive(true):FilterCategoryGround():FilterPrefixes("Ammo Truck"):FilterStart() +-- local ariset = SET_GROUP:New():FilterCoalitions("blue"):FilterActive(true):FilterCategoryGround():FilterPrefixes("Artillery"):FilterStart() +-- +-- Create an AMMOTRUCK object to take care of the artillery using the trucks, with a homezone: +-- +-- local ammotruck = AMMOTRUCK:New(truckset,ariset,coalition.side.BLUE,"Logistics",ZONE:FindByName("HomeZone") +-- +-- ## 2 Options and their default values +-- +-- ammotruck.ammothreshold = 5 -- send a truck when down to this many rounds +-- ammotruck.remunidist = 20000 -- 20km - send trucks max this far from home +-- ammotruck.unloadtime = 600 -- 10 minutes - min time to unload ammunition +-- ammotruck.waitingtime = 1800 -- 30 mintes - wait max this long until remunition is done +-- ammotruck.monitor = -60 - 1 minute - AMMOTRUCK checks on things every 1 minute +-- ammotruck.routeonroad = true - Trucks will **try** to drive on roads +-- ammotruck.usearmygroup = false - if true, will make use of ARMYGROUP in the background (if used in DEV branch) +-- +-- ## 3 FSM Events to shape mission +-- +-- Truck has been sent off: +-- +-- function ammotruck:OnAfterRouteTruck(From, Event, To, Truckdata, Aridata) +-- ... +-- end +-- +-- Truck has arrived: +-- +-- function ammotruck:OnAfterTruckArrived(From, Event, To, Truckdata) +-- ... +-- end +-- +-- Truck is unloading: +-- +-- function ammotruck:OnAfterTruckUnloading(From, Event, To, Truckdata) +-- ... +-- end +-- +-- Truck is returning home: +-- +-- function ammotruck:OnAfterTruckReturning(From, Event, To, Truckdata) +-- ... +-- end +-- +-- Truck is arrived at home: +-- +-- function ammotruck:OnAfterTruckHome(From, Event, To, Truckdata) +-- ... +-- end +-- +-- @field #AMMOTRUCK +AMMOTRUCK = { + ClassName = "AMMOTRUCK", + lid = "", + version = "0.0.10", + alias = "", + debug = false, + trucklist = {}, + targetlist = {}, + coalition = nil, + truckset = nil, + targetset = nil, + remunitionqueue = {}, + waitingtargets = {}, + ammothreshold = 5, + remunidist = 20000, + monitor = -60, + unloadtime = 600, + waitingtime = 1800, + routeonroad = true +} + +--- +-- @type AMMOTRUCK.State +AMMOTRUCK.State = { + IDLE = "idle", + DRIVING = "driving", + ARRIVED = "arrived", + UNLOADING = "unloading", + RETURNING = "returning", + WAITING = "waiting", + RELOADING = "reloading", + OUTOFAMMO = "outofammo", + REQUESTED = "requested", +} + +--- +--@type AMMOTRUCK.data +--@field Wrapper.Group#GROUP group +--@field #string name +--@field #AMMOTRUCK.State statusquo +--@field #number timestamp +--@field #number ammo +--@field Core.Point#COORDINATE coordinate +--@field #string targetname +--@field Wrapper.Group#GROUP targetgroup +--@field Core.Point#COORDINATE targetcoordinate + +--- +-- @param #AMMOTRUCK self +-- @param Core.Set#SET_GROUP Truckset Set of truck groups +-- @param Core.Set#SET_GROUP Targetset Set of artillery groups +-- @param #number Coalition Coalition +-- @param #string Alias Alias Name +-- @param Core.Zone#ZONE Homezone Home, return zone for trucks +-- @return #AMMOTRUCK self +-- @usage +-- Define a set of trucks and a set of artillery: +-- local truckset = SET_GROUP:New():FilterCoalitions("blue"):FilterActive(true):FilterCategoryGround():FilterPrefixes("Ammo Truck"):FilterStart() +-- local ariset = SET_GROUP:New():FilterCoalitions("blue"):FilterActive(true):FilterCategoryGround():FilterPrefixes("Artillery"):FilterStart() +-- +-- Create an AMMOTRUCK object to take care of the artillery using the trucks, with a homezone: +-- local ammotruck = AMMOTRUCK:New(truckset,ariset,coalition.side.BLUE,"Logistics",ZONE:FindByName("HomeZone") +function AMMOTRUCK:New(Truckset,Targetset,Coalition,Alias,Homezone) + + -- Inherit everything from BASE class. + local self=BASE:Inherit(self, FSM:New()) -- #AMMOTRUCK + + self.truckset = Truckset -- Core.Set#SET_GROUP + self.targetset = Targetset -- Core.Set#SET_GROUP + self.coalition = Coalition -- #number + self.alias = Alias -- #string + self.debug = false + self.remunitionqueue = {} + self.trucklist = {} + self.targetlist = {} + self.ammothreshold = 5 + self.remunidist = 20000 + self.homezone = Homezone -- Core.Zone#ZONE + self.waitingtime = 1800 + self.usearmygroup = false + self.hasarmygroup = false + + -- Log id. + self.lid=string.format("AMMOTRUCK %s | %s | ", self.version, self.alias) + + self:SetStartState("Stopped") + self:AddTransition("Stopped", "Start", "Running") + self:AddTransition("*", "Monitor", "*") + self:AddTransition("*", "RouteTruck", "*") + self:AddTransition("*", "TruckArrived", "*") + self:AddTransition("*", "TruckUnloading", "*") + self:AddTransition("*", "TruckReturning", "*") + self:AddTransition("*", "TruckHome", "*") + self:AddTransition("*", "Stop", "Stopped") + + self:__Start(math.random(5,10)) + + self:I(self.lid .. "Started") + + ------------------------ + --- Pseudo Functions --- + ------------------------ + + --- Triggers the FSM event "Stop". Stops the AMMOTRUCK and all its event handlers. + -- @function [parent=#AMMOTRUCK] Stop + -- @param #AMMOTRUCK self + + --- Triggers the FSM event "Stop" after a delay. Stops the AMMOTRUCK and all its event handlers. + -- @function [parent=#AMMOTRUCK] __Stop + -- @param #AMMOTRUCK self + -- @param #number delay Delay in seconds. + + --- On after "RouteTruck" event. + -- @function [parent=#AMMOTRUCK] OnAfterRouteTruck + -- @param #AMMOTRUCK self + -- @param #string From From state. + -- @param #string Event Event. + -- @param #string To To state. + -- @param #AMMOTRUCK.data Truck + -- @param #AMMOTRUCK.data Artillery + + --- On after "TruckUnloading" event. + -- @function [parent=#AMMOTRUCK] OnAfterTruckUnloading + -- @param #AMMOTRUCK self + -- @param #string From From state. + -- @param #string Event Event. + -- @param #string To To state. + -- @param #AMMOTRUCK.data Truck + + --- On after "TruckReturning" event. + -- @function [parent=#AMMOTRUCK] OnAfterTruckReturning + -- @param #AMMOTRUCK self + -- @param #string From From state. + -- @param #string Event Event. + -- @param #string To To state. + -- @param #AMMOTRUCK.data Truck + + --- On after "RouteTruck" event. + -- @function [parent=#AMMOTRUCK] OnAfterRouteTruck + -- @param #AMMOTRUCK self + -- @param #string From From state. + -- @param #string Event Event. + -- @param #string To To state. + -- @param #AMMOTRUCK.data Truck + + --- On after "TruckHome" event. + -- @function [parent=#AMMOTRUCK] OnAfterTruckHome + -- @param #AMMOTRUCK self + -- @param #string From From state. + -- @param #string Event Event. + -- @param #string To To state. + -- @param #AMMOTRUCK.data Truck + + return self +end + +--- +-- @param #AMMOTRUCK self +-- @param #table dataset table of #AMMOTRUCK.data entries +-- @return #AMMOTRUCK self +function AMMOTRUCK:CheckDrivingTrucks(dataset) + self:T(self.lid .. " CheckDrivingTrucks") + local data = dataset + for _,_data in pairs (data) do + local truck = _data -- #AMMOTRUCK.data + -- see if we arrived at destination + local coord = truck.group:GetCoordinate() + local tgtcoord = truck.targetcoordinate + local dist = coord:Get2DDistance(tgtcoord) + if dist <= 150 then + -- arrived + truck.statusquo = AMMOTRUCK.State.ARRIVED + truck.timestamp = timer.getAbsTime() + truck.coordinate = coord + self:__TruckArrived(1,truck) + end + -- still driving? + local Tnow = timer.getAbsTime() + if Tnow - truck.timestamp > 30 then + local group = truck.group + if self.usearmygroup then + group = truck.group:GetGroup() + end + local currspeed = group:GetVelocityKMH() + if truck.lastspeed then + if truck.lastspeed == 0 and currspeed == 0 then + self:T(truck.group:GetName().." Is not moving!") + -- try and move it + truck.timestamp = timer.getAbsTime() + if self.routeonroad then + group:RouteGroundOnRoad(truck.targetcoordinate,30,2,"Vee") + else + group:RouteGroundTo(truck.targetcoordinate,30,"Vee",2) + end + end + truck.lastspeed = currspeed + else + truck.lastspeed = currspeed + truck.timestamp = timer.getAbsTime() + end + self:I({truck=truck.group:GetName(),currspeed=currspeed,lastspeed=truck.lastspeed}) + end + end + return self +end + +--- +-- @param #AMMOTRUCK self +-- @param Wrapper.Group#GROUP Group +-- @return #AMMOTRUCK self +function AMMOTRUCK:GetAmmoStatus(Group) + local ammotot, shells, rockets, bombs, missiles, narti = Group:GetAmmunition() + return rockets+missiles+narti +end + +--- +-- @param #AMMOTRUCK self +-- @param #table dataset table of #AMMOTRUCK.data entries +-- @return #AMMOTRUCK self +function AMMOTRUCK:CheckWaitingTargets(dataset) + self:T(self.lid .. " CheckWaitingTargets") + local data = dataset + for _,_data in pairs (data) do + local truck = _data -- #AMMOTRUCK.data + -- see how long we're waiting - maybe ammo truck is dead? + local Tnow = timer.getAbsTime() + local Tdiff = Tnow - truck.timestamp + if Tdiff > self.waitingtime then + local hasammo = self:GetAmmoStatus(truck.group) + if hasammo <= self.ammothreshold then + truck.statusquo = AMMOTRUCK.State.OUTOFAMMO + else + truck.statusquo = AMMOTRUCK.State.IDLE + end + end + end + return self +end + +--- +-- @param #AMMOTRUCK self +-- @param #table dataset table of #AMMOTRUCK.data entries +-- @return #AMMOTRUCK self +function AMMOTRUCK:CheckReturningTrucks(dataset) + self:T(self.lid .. " CheckReturningTrucks") + local data = dataset + local tgtcoord = self.homezone:GetCoordinate() + local radius = self.homezone:GetRadius() + for _,_data in pairs (data) do + local truck = _data -- #AMMOTRUCK.data + -- see if we arrived at destination + local coord = truck.group:GetCoordinate() + local dist = coord:Get2DDistance(tgtcoord) + self:T({name=truck.name,radius=radius,distance=dist}) + if dist <= radius then + -- arrived + truck.statusquo = AMMOTRUCK.State.IDLE + truck.timestamp = timer.getAbsTime() + truck.coordinate = coord + self:__TruckHome(1,truck) + end + end + return self +end + +--- +-- @param #AMMOTRUCK self +-- @param #string name Artillery group name to find +-- @return #AMMOTRUCK.data Data +function AMMOTRUCK:FindTarget(name) + self:T(self.lid .. " FindTarget") + local data = nil + local dataset = self.targetlist + for _,_entry in pairs(dataset) do + local entry = _entry -- #AMMOTRUCK.data + if entry.name == name then + data = entry + break + end + end + return data +end + +--- +-- @param #AMMOTRUCK self +-- @param #string name Truck group name to find +-- @return #AMMOTRUCK.data Data +function AMMOTRUCK:FindTruck(name) + self:T(self.lid .. " FindTruck") + local data = nil + local dataset = self.trucklist + for _,_entry in pairs(dataset) do + local entry = _entry -- #AMMOTRUCK.data + if entry.name == name then + data = entry + break + end + end + return data +end + +--- +-- @param #AMMOTRUCK self +-- @param #table dataset table of #AMMOTRUCK.data entries +-- @return #AMMOTRUCK self +function AMMOTRUCK:CheckArrivedTrucks(dataset) + self:T(self.lid .. " CheckArrivedTrucks") + local data = dataset + for _,_data in pairs (data) do + -- set to unloading + local truck = _data -- #AMMOTRUCK.data + truck.statusquo = AMMOTRUCK.State.UNLOADING + truck.timestamp = timer.getAbsTime() + self:__TruckUnloading(2,truck) + -- set target to reloading + local aridata = self:FindTarget(truck.targetname) -- #AMMOTRUCK.data + if aridata then + aridata.statusquo = AMMOTRUCK.State.RELOADING + aridata.timestamp = timer.getAbsTime() + end + end + return self +end + +--- +-- @param #AMMOTRUCK self +-- @param #table dataset table of #AMMOTRUCK.data entries +-- @return #AMMOTRUCK self +function AMMOTRUCK:CheckUnloadingTrucks(dataset) + self:T(self.lid .. " CheckUnloadingTrucks") + local data = dataset + for _,_data in pairs (data) do + -- check timestamp + local truck = _data -- #AMMOTRUCK.data + local Tnow = timer.getAbsTime() + local Tpassed = Tnow - truck.timestamp + local hasammo = self:GetAmmoStatus(truck.targetgroup) + if Tpassed > self.unloadtime and hasammo > self.ammothreshold then + truck.statusquo = AMMOTRUCK.State.RETURNING + truck.timestamp = timer.getAbsTime() + self:__TruckReturning(2,truck) + -- set target to reloaded + local aridata = self:FindTarget(truck.targetname) -- #AMMOTRUCK.data + if aridata then + aridata.statusquo = AMMOTRUCK.State.IDLE + aridata.timestamp = timer.getAbsTime() + end + end + end + return self +end + +--- +-- @param #AMMOTRUCK self +-- @return #AMMOTRUCK self +function AMMOTRUCK:CheckTargetsAlive() + self:T(self.lid .. " CheckTargetsAlive") + local arilist = self.targetlist + for _,_ari in pairs(arilist) do + local ari = _ari -- #AMMOTRUCK.data + if ari.group and ari.group:IsAlive() then + -- everything fine + else + -- ari dead + self.targetlist[ari.name] = nil + end + end + -- new arrivals? + local aritable = self.targetset:GetSetObjects() --#table + for _,_ari in pairs(aritable) do + local ari = _ari -- Wrapper.Group#GROUP + if ari and ari:IsAlive() and not self.targetlist[ari:GetName()] then + local name = ari:GetName() + local newari = {} -- #AMMOTRUCK.data + newari.name = name + newari.group = ari + newari.statusquo = AMMOTRUCK.State.IDLE + newari.timestamp = timer.getAbsTime() + newari.coordinate = ari:GetCoordinate() + local hasammo = self:GetAmmoStatus(ari) + --newari.ammo = ari:GetAmmunition() + newari.ammo = hasammo + self.targetlist[name] = newari + end + end + return self +end + +--- +-- @param #AMMOTRUCK self +-- @return #AMMOTRUCK self +function AMMOTRUCK:CheckTrucksAlive() + self:T(self.lid .. " CheckTrucksAlive") + local trucklist = self.trucklist + for _,_truck in pairs(trucklist) do + local truck = _truck -- #AMMOTRUCK.data + if truck.group and truck.group:IsAlive() then + -- everything fine + else + -- truck dead + local tgtname = truck.targetname + local targetdata = self:FindTarget(tgtname) -- #AMMOTRUCK.data + if targetdata then + if targetdata.statusquo ~= AMMOTRUCK.State.IDLE then + targetdata.statusquo = AMMOTRUCK.State.IDLE + end + end + self.trucklist[truck.name] = nil + end + end + -- new arrivals? + local trucktable = self.truckset:GetSetObjects() --#table + for _,_truck in pairs(trucktable) do + local truck = _truck -- Wrapper.Group#GROUP + if truck and truck:IsAlive() and not self.trucklist[truck:GetName()] then + local name = truck:GetName() + local newtruck = {} -- #AMMOTRUCK.data + newtruck.name = name + newtruck.group = truck + if self.hasarmygroup then + -- is (not) already ARMYGROUP? + if truck.ClassName and truck.ClassName == "GROUP" then + local trucker = ARMYGROUP:New(truck) + trucker:Activate() + newtruck.group = trucker + end + end + newtruck.statusquo = AMMOTRUCK.State.IDLE + newtruck.timestamp = timer.getAbsTime() + newtruck.coordinate = truck:GetCoordinate() + self.trucklist[name] = newtruck + end + end + return self +end + +--- +-- @param #AMMOTRUCK self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #AMMOTRUCK self +function AMMOTRUCK:onafterStart(From, Event, To) + self:T({From, Event, To}) + if ARMYGROUP and self.usearmygroup then + self.hasarmygroup = true + else + self.hasarmygroup = false + end + if self.debug then + BASE:TraceOn() + BASE:TraceClass("AMMOTRUCK") + end + self:CheckTargetsAlive() + self:CheckTrucksAlive() + self:__Monitor(-30) + return self +end + +--- +-- @param #AMMOTRUCK self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #AMMOTRUCK self +function AMMOTRUCK:onafterMonitor(From, Event, To) + self:T({From, Event, To}) + self:CheckTargetsAlive() + self:CheckTrucksAlive() + -- update ammo state + local remunition = false + local remunitionqueue = {} + local waitingtargets = {} + for _,_ari in pairs(self.targetlist) do + local data = _ari -- #AMMOTRUCK.data + if data.group and data.group:IsAlive() then + data.ammo = self:GetAmmoStatus(data.group) + data.timestamp = timer.getAbsTime() + local text = string.format("Ari %s | Ammo %d | State %s",data.name,data.ammo,data.statusquo) + self:T(text) + if data.ammo <= self.ammothreshold and (data.statusquo == AMMOTRUCK.State.IDLE or data.statusquo == AMMOTRUCK.State.OUTOFAMMO) then + -- add to remu queue + data.statusquo = AMMOTRUCK.State.OUTOFAMMO + remunitionqueue[#remunitionqueue+1] = data + remunition = true + elseif data.statusquo == AMMOTRUCK.State.WAITING then + waitingtargets[#waitingtargets+1] = data + end + else + self.targetlist[data.name] = nil + end + end + -- sort trucks in buckets + local idletrucks = {} + local drivingtrucks = {} + local unloadingtrucks = {} + local arrivedtrucks = {} + local returningtrucks = {} + local found = false + for _,_truckdata in pairs(self.trucklist) do + local data = _truckdata -- #AMMOTRUCK.data + if data.group and data.group:IsAlive() then + -- check state + local text = string.format("Truck %s | State %s",data.name,data.statusquo) + self:T(text) + if data.statusquo == AMMOTRUCK.State.IDLE then + idletrucks[#idletrucks+1] = data + found = true + elseif data.statusquo == AMMOTRUCK.State.DRIVING then + drivingtrucks[#drivingtrucks+1] = data + elseif data.statusquo == AMMOTRUCK.State.ARRIVED then + arrivedtrucks[#arrivedtrucks+1] = data + elseif data.statusquo == AMMOTRUCK.State.UNLOADING then + unloadingtrucks[#unloadingtrucks+1] = data + elseif data.statusquo == AMMOTRUCK.State.RETURNING then + returningtrucks[#returningtrucks+1] = data + idletrucks[#idletrucks+1] = data + found = true + end + else + self.truckset[data.name] = nil + end + end + -- see if we can/need route one + local n=0 + if found and remunition then + -- match + local match = false + for _,_truckdata in pairs(idletrucks) do + local truckdata = _truckdata -- #AMMOTRUCK.data + local truckcoord = truckdata.group:GetCoordinate() -- Core.Point#COORDINATE + for _,_aridata in pairs(remunitionqueue) do + local aridata = _aridata -- #AMMOTRUCK.data + local aricoord = aridata.coordinate + local distance = truckcoord:Get2DDistance(aricoord) + if distance <= self.remunidist and aridata.statusquo == AMMOTRUCK.State.OUTOFAMMO and n <= #idletrucks then + n = n + 1 + aridata.statusquo = AMMOTRUCK.State.REQUESTED + self:__RouteTruck(n*5,truckdata,aridata) + break + end + end + end + end + + -- check driving trucks + if #drivingtrucks > 0 then + self:CheckDrivingTrucks(drivingtrucks) + end + + -- check arrived trucks + if #arrivedtrucks > 0 then + self:CheckArrivedTrucks(arrivedtrucks) + end + + -- check unloading trucks + if #unloadingtrucks > 0 then + self:CheckUnloadingTrucks(unloadingtrucks) + end + + -- check returningtrucks trucks + if #returningtrucks > 0 then + self:CheckReturningTrucks(returningtrucks) + end + + -- check waiting targets + if #waitingtargets > 0 then + self:CheckWaitingTargets(waitingtargets) + end + + self:__Monitor(self.monitor) + return self +end + +--- +-- @param #AMMOTRUCK self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @param #AMMOTRUCK.data Truckdata +-- @param #AMMOTRUCK.data Aridata +-- @return #AMMOTRUCK self +function AMMOTRUCK:onafterRouteTruck(From, Event, To, Truckdata, Aridata) + self:T({From, Event, To, Truckdata.name, Aridata.name}) + local truckdata = Truckdata -- #AMMOTRUCK.data + local aridata = Aridata -- #AMMOTRUCK.data + local tgtgrp = aridata.group + local tgtzone = ZONE_GROUP:New(aridata.name,tgtgrp,30) + local tgtcoord = tgtzone:GetRandomCoordinate(15) + if self.hasarmygroup then + local mission = AUFTRAG:NewONGUARD(tgtcoord) + local oldmission = truckdata.group:GetMissionCurrent() + if oldmission then oldmission:Cancel() end + mission:SetTime(5) + mission:SetTeleport(false) + truckdata.group:AddMission(mission) + elseif self.routeonroad then + truckdata.group:RouteGroundOnRoad(tgtcoord,30) + else + truckdata.group:RouteGroundTo(tgtcoord,30) + end + truckdata.statusquo = AMMOTRUCK.State.DRIVING + truckdata.targetgroup = tgtgrp + truckdata.targetname = aridata.name + truckdata.targetcoordinate = tgtcoord + aridata.statusquo = AMMOTRUCK.State.WAITING + aridata.timestamp = timer.getAbsTime() + return self +end + +--- +-- @param #AMMOTRUCK self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @param #AMMOTRUCK.data Truckdata +-- @return #AMMOTRUCK self + function AMMOTRUCK:onafterTruckUnloading(From, Event, To, Truckdata) + local m = MESSAGE:New("Truck "..Truckdata.name.." unloading!",15,"AmmoTruck"):ToCoalitionIf(self.coalition,self.debug) + local truck = Truckdata -- Functional.AmmoTruck#AMMOTRUCK.data + local coord = truck.group:GetCoordinate() + local heading = truck.group:GetHeading() + heading = heading < 180 and (360-heading) or (heading - 180) + local cid = self.coalition == coalition.side.BLUE and country.id.USA or country.id.RUSSIA + cid = self.coalition == coalition.side.NEUTRAL and country.id.UN_PEACEKEEPERS or cid + + local ammo = {} + for i=1,5 do + ammo[i] = SPAWNSTATIC:NewFromType("ammo_cargo","Cargos",cid) + :InitCoordinate(coord:Translate((15+((i-1)*4)),heading)) + :Spawn(0,"AmmoCrate-"..math.random(1,10000)) + end + + local function destroyammo(ammo) + for _,_crate in pairs(ammo) do + _crate:Destroy(false) + end + end + + local scheduler = SCHEDULER:New(nil,destroyammo,{ammo},self.waitingtime) + end + +--- +-- @param #AMMOTRUCK self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @param #AMMOTRUCK.data Truck +-- @return #AMMOTRUCK self +function AMMOTRUCK:onafterTruckReturning(From, Event, To, Truck) + self:T({From, Event, To, Truck.name}) + -- route home + local truckdata = Truck -- #AMMOTRUCK.data + local tgtzone = self.homezone + local tgtcoord = tgtzone:GetRandomCoordinate() + if self.hasarmygroup then + local mission = AUFTRAG:NewONGUARD(tgtcoord) + local oldmission = truckdata.group:GetMissionCurrent() + if oldmission then oldmission:Cancel() end + mission:SetTime(5) + mission:SetTeleport(false) + truckdata.group:AddMission(mission) + elseif self.routeonroad then + truckdata.group:RouteGroundOnRoad(tgtcoord,30,1,"Cone") + else + truckdata.group:RouteGroundTo(tgtcoord,30,"Cone",1) + end + return self +end + +--- +-- @param #AMMOTRUCK self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #AMMOTRUCK self +function AMMOTRUCK:onafterStop(From, Event, To) + self:T({From, Event, To}) + return self +end diff --git a/Moose Development/Moose/Modules.lua b/Moose Development/Moose/Modules.lua index d9decff69..ce170be0f 100644 --- a/Moose Development/Moose/Modules.lua +++ b/Moose Development/Moose/Modules.lua @@ -54,6 +54,7 @@ __Moose.Include( 'Scripts/Moose/Cargo/CargoCrate.lua' ) __Moose.Include( 'Scripts/Moose/Cargo/CargoGroup.lua' ) __Moose.Include( 'Scripts/Moose/Functional/AICSAR.lua' ) +__Moose.Include( 'Scripts/Moose/Functional/AmmoTruck.lua' ) __Moose.Include( 'Scripts/Moose/Functional/Artillery.lua' ) __Moose.Include( 'Scripts/Moose/Functional/ATC_Ground.lua' ) __Moose.Include( 'Scripts/Moose/Functional/Autolase.lua' ) diff --git a/Moose Setup/Moose.files b/Moose Setup/Moose.files index 1a123ec76..ae26fe81f 100644 --- a/Moose Setup/Moose.files +++ b/Moose Setup/Moose.files @@ -74,6 +74,7 @@ Functional/Mantis.lua Functional/Shorad.lua Functional/Autolase.lua Functional/AICSAR.lua +Functional/AmmoTruck.lua Ops/Airboss.lua Ops/RecoveryTanker.lua From 41a928b775a29112b2d0b139c7f3d210c28ba987 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Thu, 10 Nov 2022 17:29:19 +0100 Subject: [PATCH 04/14] #Docu fixes --- Moose Development/Moose/Functional/AICSAR.lua | 4 +++- Moose Development/Moose/Functional/AmmoTruck.lua | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/Functional/AICSAR.lua b/Moose Development/Moose/Functional/AICSAR.lua index 922ae567e..698bbb18a 100644 --- a/Moose Development/Moose/Functional/AICSAR.lua +++ b/Moose Development/Moose/Functional/AICSAR.lua @@ -1,6 +1,8 @@ --- **Functional** - AI CSAR system +-- +-- === -- --- ## Main Features: +-- ## Features: -- -- * Send out helicopters to downed pilots -- * Rescues players and AI alike diff --git a/Moose Development/Moose/Functional/AmmoTruck.lua b/Moose Development/Moose/Functional/AmmoTruck.lua index ddfb25a21..fc3828f82 100644 --- a/Moose Development/Moose/Functional/AmmoTruck.lua +++ b/Moose Development/Moose/Functional/AmmoTruck.lua @@ -12,10 +12,10 @@ -- -- === -- --- ### Author : **applevangelist ** +-- ### Author : **applevangelist** -- -- @module Functional.AmmoTruck --- @image Functional.AmmoTruck.jpg +-- @image Artillery.JPG -- -- Date: Nov 2022 From c38cb046cd8af3df536e3a8cdde0697c6dd1d1ea Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Thu, 10 Nov 2022 17:53:29 +0100 Subject: [PATCH 05/14] #AMMOTRUCK * Added demo mission link --- Moose Development/Moose/Functional/AmmoTruck.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Functional/AmmoTruck.lua b/Moose Development/Moose/Functional/AmmoTruck.lua index fc3828f82..e33ae8a52 100644 --- a/Moose Development/Moose/Functional/AmmoTruck.lua +++ b/Moose Development/Moose/Functional/AmmoTruck.lua @@ -8,7 +8,7 @@ -- -- ## Missions: -- --- ### [tbd](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/tbd) +-- ### [AmmoTruck](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/AMT%20-%20AmmoTruck/AmmoTruck%20100%20-%20NTTR%20-%20Basic) -- -- === -- @@ -42,7 +42,7 @@ -- @field #boolean routeonroad Route truck on road if true (default) -- @extends Core.FSM#FSM ---- *Amateurs talk about tactics, but professionals study logistics.* - Gen. Robert H. Barrow, USMC +--- *Amateurs talk about tactics, but professionals study logistics.* - General Robert H Barrow, USMC -- -- Simple Class to re-arm your artillery with trucks. -- From 08c7409627323baa66c3bc3c6cf46eaf41eec0f9 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Fri, 11 Nov 2022 09:22:39 +0100 Subject: [PATCH 06/14] Docu Headlines --- Moose Development/Moose/AI/AI_A2A_Cap.lua | 2 +- Moose Development/Moose/AI/AI_A2A_Dispatcher.lua | 2 +- Moose Development/Moose/AI/AI_A2A_Gci.lua | 2 +- Moose Development/Moose/AI/AI_A2A_Patrol.lua | 2 +- Moose Development/Moose/AI/AI_Cargo_Dispatcher_Ship.lua | 2 +- Moose Development/Moose/Actions/Act_Account.lua | 2 +- Moose Development/Moose/Cargo/CargoCrate.lua | 2 +- Moose Development/Moose/Cargo/CargoGroup.lua | 2 +- Moose Development/Moose/Cargo/CargoSlingload.lua | 2 +- Moose Development/Moose/Cargo/CargoUnit.lua | 2 +- Moose Development/Moose/Core/MarkerOps_Base.lua | 2 +- Moose Development/Moose/Core/Settings.lua | 2 +- Moose Development/Moose/Core/TextAndSound.lua | 2 +- Moose Development/Moose/DCS.lua | 2 +- Moose Development/Moose/Functional/AICSAR.lua | 2 +- Moose Development/Moose/Functional/Mantis.lua | 2 +- Moose Development/Moose/Functional/Scoring.lua | 2 +- Moose Development/Moose/Functional/Shorad.lua | 2 +- Moose Development/Moose/Functional/ZoneGoalCoalition.lua | 2 +- Moose Development/Moose/Ops/Awacs.lua | 6 ++++-- Moose Development/Moose/Ops/PlayerTask.lua | 2 +- Moose Development/Moose/Utilities/Templates.lua | 2 +- 22 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Moose Development/Moose/AI/AI_A2A_Cap.lua b/Moose Development/Moose/AI/AI_A2A_Cap.lua index b51bca705..61b82e19e 100644 --- a/Moose Development/Moose/AI/AI_A2A_Cap.lua +++ b/Moose Development/Moose/AI/AI_A2A_Cap.lua @@ -1,4 +1,4 @@ ---- **AI** - (R2.2) - Models the process of Combat Air Patrol (CAP) for airplanes. +--- **AI** - Models the process of Combat Air Patrol (CAP) for airplanes. -- -- This is a class used in the @{AI.AI_A2A_Dispatcher}. -- diff --git a/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua b/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua index 9b497ac76..889ebe631 100644 --- a/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua +++ b/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua @@ -1,4 +1,4 @@ ---- **AI** - (R2.2) - Manages the process of an automatic A2A defense system based on an EWR network targets and coordinating CAP and GCI. +--- **AI** - Manages the process of an automatic A2A defense system based on an EWR network targets and coordinating CAP and GCI. -- -- === -- diff --git a/Moose Development/Moose/AI/AI_A2A_Gci.lua b/Moose Development/Moose/AI/AI_A2A_Gci.lua index 8f553935e..567ff55c2 100644 --- a/Moose Development/Moose/AI/AI_A2A_Gci.lua +++ b/Moose Development/Moose/AI/AI_A2A_Gci.lua @@ -1,4 +1,4 @@ ---- **AI** - (R2.2) - Models the process of Ground Controlled Interception (GCI) for airplanes. +--- **AI** - Models the process of Ground Controlled Interception (GCI) for airplanes. -- -- This is a class used in the @{AI.AI_A2A_Dispatcher}. -- diff --git a/Moose Development/Moose/AI/AI_A2A_Patrol.lua b/Moose Development/Moose/AI/AI_A2A_Patrol.lua index aa297b017..07fdd43c1 100644 --- a/Moose Development/Moose/AI/AI_A2A_Patrol.lua +++ b/Moose Development/Moose/AI/AI_A2A_Patrol.lua @@ -1,4 +1,4 @@ ---- **AI** - (R2.2) - Models the process of air patrol of airplanes. +--- **AI** - Models the process of air patrol of airplanes. -- -- === -- diff --git a/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Ship.lua b/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Ship.lua index 103b39f26..205e5fec3 100644 --- a/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Ship.lua +++ b/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Ship.lua @@ -1,4 +1,4 @@ ---- **AI** - (2.5.1) - Models the intelligent transportation of infantry and other cargo using Ships +--- **AI** - (2.5.1) - Models the intelligent transportation of infantry and other cargo using Ships. -- -- ## Features: -- diff --git a/Moose Development/Moose/Actions/Act_Account.lua b/Moose Development/Moose/Actions/Act_Account.lua index fe79bbbb7..ef2e6d15d 100644 --- a/Moose Development/Moose/Actions/Act_Account.lua +++ b/Moose Development/Moose/Actions/Act_Account.lua @@ -1,4 +1,4 @@ ---- **Actions** - ACT_ACCOUNT_ classes **account for** (detect, count & report) various DCS events occurring on @{Wrapper.Unit}s. +--- **Actions** - ACT_ACCOUNT_ classes **account for** (detect, count & report) various DCS events occurring on UNITs. -- -- ![Banner Image](..\Presentations\ACT_ACCOUNT\Dia1.JPG) -- diff --git a/Moose Development/Moose/Cargo/CargoCrate.lua b/Moose Development/Moose/Cargo/CargoCrate.lua index b1b74c500..81bc7ca6a 100644 --- a/Moose Development/Moose/Cargo/CargoCrate.lua +++ b/Moose Development/Moose/Cargo/CargoCrate.lua @@ -1,4 +1,4 @@ ---- **Cargo** - Management of single cargo crates, which are based on a @{Wrapper.Static} object. +--- **Cargo** - Management of single cargo crates, which are based on a STATIC object. -- -- === -- diff --git a/Moose Development/Moose/Cargo/CargoGroup.lua b/Moose Development/Moose/Cargo/CargoGroup.lua index 1369464f3..deb46b7d1 100644 --- a/Moose Development/Moose/Cargo/CargoGroup.lua +++ b/Moose Development/Moose/Cargo/CargoGroup.lua @@ -1,4 +1,4 @@ ---- **Cargo** - Management of grouped cargo logistics, which are based on a @{Wrapper.Group} object. +--- **Cargo** - Management of grouped cargo logistics, which are based on a GROUP object. -- -- === -- diff --git a/Moose Development/Moose/Cargo/CargoSlingload.lua b/Moose Development/Moose/Cargo/CargoSlingload.lua index 3e11b6afc..ba3d8bb0b 100644 --- a/Moose Development/Moose/Cargo/CargoSlingload.lua +++ b/Moose Development/Moose/Cargo/CargoSlingload.lua @@ -1,4 +1,4 @@ ---- **Cargo** - Management of single cargo crates, which are based on a @{Wrapper.Static} object. The cargo can only be slingloaded. +--- **Cargo** - Management of single cargo crates, which are based on a STATIC object. The cargo can only be slingloaded. -- -- === -- diff --git a/Moose Development/Moose/Cargo/CargoUnit.lua b/Moose Development/Moose/Cargo/CargoUnit.lua index 92baf40a4..6c5c5ffd6 100644 --- a/Moose Development/Moose/Cargo/CargoUnit.lua +++ b/Moose Development/Moose/Cargo/CargoUnit.lua @@ -1,4 +1,4 @@ ---- **Cargo** - Management of single cargo logistics, which are based on a @{Wrapper.Unit} object. +--- **Cargo** - Management of single cargo logistics, which are based on a UNIT object. -- -- === -- diff --git a/Moose Development/Moose/Core/MarkerOps_Base.lua b/Moose Development/Moose/Core/MarkerOps_Base.lua index 12095c5d9..5e5aa273f 100644 --- a/Moose Development/Moose/Core/MarkerOps_Base.lua +++ b/Moose Development/Moose/Core/MarkerOps_Base.lua @@ -1,4 +1,4 @@ ---- **Core** - MarkerOps_Base. +--- **Core** - Tap into markers added to the F10 map by users. -- -- **Main Features:** -- diff --git a/Moose Development/Moose/Core/Settings.lua b/Moose Development/Moose/Core/Settings.lua index 8dd213952..eeaa3db81 100644 --- a/Moose Development/Moose/Core/Settings.lua +++ b/Moose Development/Moose/Core/Settings.lua @@ -1,4 +1,4 @@ ---- **Core** - Manages various settings for running missions, consumed by moose classes and provides a menu system for players to tweak settings in running missions. +--- **Core** - Manages various settings for missions, providing a menu for players to tweak settings in running missions. -- -- === -- diff --git a/Moose Development/Moose/Core/TextAndSound.lua b/Moose Development/Moose/Core/TextAndSound.lua index f56015fe2..71e1c35f8 100644 --- a/Moose Development/Moose/Core/TextAndSound.lua +++ b/Moose Development/Moose/Core/TextAndSound.lua @@ -1,4 +1,4 @@ ---- **Core** - TEXTANDSOUND (MOOSE gettext) system +--- **Core** - A Moose GetText system. -- -- === -- diff --git a/Moose Development/Moose/DCS.lua b/Moose Development/Moose/DCS.lua index b791abd27..95fc6e24d 100644 --- a/Moose Development/Moose/DCS.lua +++ b/Moose Development/Moose/DCS.lua @@ -1,4 +1,4 @@ ---- **DCS API** Prototypes +--- **DCS API** Prototypes. -- -- See the [Simulator Scripting Engine Documentation](https://wiki.hoggitworld.com/view/Simulator_Scripting_Engine_Documentation) on Hoggit for further explanation and examples. -- diff --git a/Moose Development/Moose/Functional/AICSAR.lua b/Moose Development/Moose/Functional/AICSAR.lua index 698bbb18a..5db982982 100644 --- a/Moose Development/Moose/Functional/AICSAR.lua +++ b/Moose Development/Moose/Functional/AICSAR.lua @@ -1,4 +1,4 @@ ---- **Functional** - AI CSAR system +--- **Functional** - AI CSAR system. -- -- === -- diff --git a/Moose Development/Moose/Functional/Mantis.lua b/Moose Development/Moose/Functional/Mantis.lua index 5c45cb4d9..3f6f7b008 100644 --- a/Moose Development/Moose/Functional/Mantis.lua +++ b/Moose Development/Moose/Functional/Mantis.lua @@ -1,4 +1,4 @@ ---- **Functional** - Modular, Automatic and Network capable Targeting and Interception System for Air Defenses +--- **Functional** - Modular, Automatic and Network capable Targeting and Interception System for Air Defenses. -- -- === -- diff --git a/Moose Development/Moose/Functional/Scoring.lua b/Moose Development/Moose/Functional/Scoring.lua index 2a7ef471a..24085edf3 100644 --- a/Moose Development/Moose/Functional/Scoring.lua +++ b/Moose Development/Moose/Functional/Scoring.lua @@ -1,4 +1,4 @@ ---- **Functional** - Administer the scoring of player achievements, and create a CSV file logging the scoring events for use at team or squadron websites. +--- **Functional** - Administer the scoring of player achievements, file and log the scoring events for use at websites. -- -- === -- diff --git a/Moose Development/Moose/Functional/Shorad.lua b/Moose Development/Moose/Functional/Shorad.lua index 75bdee82f..e08f7fa29 100644 --- a/Moose Development/Moose/Functional/Shorad.lua +++ b/Moose Development/Moose/Functional/Shorad.lua @@ -1,4 +1,4 @@ ---- **Functional** - Short Range Air Defense System +--- **Functional** - Short Range Air Defense System. -- -- === -- diff --git a/Moose Development/Moose/Functional/ZoneGoalCoalition.lua b/Moose Development/Moose/Functional/ZoneGoalCoalition.lua index 2656f5706..1f5da5440 100644 --- a/Moose Development/Moose/Functional/ZoneGoalCoalition.lua +++ b/Moose Development/Moose/Functional/ZoneGoalCoalition.lua @@ -1,4 +1,4 @@ ---- **Functional (WIP)** - Base class that models processes to achieve goals involving a Zone for a Coalition. +--- **Functional (WIP)** - Base class modeling processes to achieve goals involving coalition zones. -- -- === -- diff --git a/Moose Development/Moose/Ops/Awacs.lua b/Moose Development/Moose/Ops/Awacs.lua index 92e5c2eaf..12ff9b59b 100644 --- a/Moose Development/Moose/Ops/Awacs.lua +++ b/Moose Development/Moose/Ops/Awacs.lua @@ -1,8 +1,10 @@ ---- **Ops** - AWACS +--- **Ops** - MOOSE AI AWACS Operations using text-to-speech. -- -- === -- --- **AWACS** - MOOSE AI AWACS Operations using text-to-speech. +-- ## AWACS +-- +-- * MOOSE AI AWACS Operations using text-to-speech. -- -- === -- diff --git a/Moose Development/Moose/Ops/PlayerTask.lua b/Moose Development/Moose/Ops/PlayerTask.lua index 69327de47..828d38eee 100644 --- a/Moose Development/Moose/Ops/PlayerTask.lua +++ b/Moose Development/Moose/Ops/PlayerTask.lua @@ -1,4 +1,4 @@ ----- **Ops** - PlayerTask (mission) for Players. +--- **Ops** - PlayerTask (mission) for Players. -- -- ## Main Features: -- diff --git a/Moose Development/Moose/Utilities/Templates.lua b/Moose Development/Moose/Utilities/Templates.lua index 182925689..d13e888b8 100644 --- a/Moose Development/Moose/Utilities/Templates.lua +++ b/Moose Development/Moose/Utilities/Templates.lua @@ -1,4 +1,4 @@ ---- **Utils** Templates +--- **Utils** Templates. -- -- DCS unit templates -- From b9a7fc940987a3ab379d1fe1e3bdcf15ec7ff3d8 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Fri, 11 Nov 2022 10:00:13 +0100 Subject: [PATCH 07/14] #AUFTRAG * Corrected speed setting in NewHover --- Moose Development/Moose/Ops/Auftrag.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index e49dc25c4..d007aa28a 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -1007,10 +1007,10 @@ function AUFTRAG:NewHOVER(Coordinate, Altitude, Time, Speed, MissionAlt) mission.hoverSpeed = 0.1 -- the DCS Task itself will shortly be build with this so MPS mission.hoverTime = Time or 300 - mission.missionSpeed = UTILS.KnotsToMps(Speed or 150) - + self:SetMissionSpeed(Speed or 150) + self:SetMissionAltitude(MissionAlt or 1000) + -- Mission options: - mission.missionAltitude=mission.MissionAlt or UTILS.FeetToMeters(1000) mission.missionFraction=0.9 mission.optionROE=ENUMS.ROE.ReturnFire mission.optionROT=ENUMS.ROT.PassiveDefense From 2a567c9f74a0db7d7935ca9e2312ad9527108f58 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Fri, 11 Nov 2022 11:40:22 +0100 Subject: [PATCH 08/14] Docu Headlines part II --- Moose Development/Moose/AI/AI_A2G_Dispatcher.lua | 2 +- Moose Development/Moose/AI/AI_Air_Dispatcher.lua | 2 +- Moose Development/Moose/AI/AI_Cargo_Dispatcher_Helicopter.lua | 2 +- Moose Development/Moose/AI/AI_Cargo_Dispatcher_Ship.lua | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Moose Development/Moose/AI/AI_A2G_Dispatcher.lua b/Moose Development/Moose/AI/AI_A2G_Dispatcher.lua index 25ebaf022..ea2b975e2 100644 --- a/Moose Development/Moose/AI/AI_A2G_Dispatcher.lua +++ b/Moose Development/Moose/AI/AI_A2G_Dispatcher.lua @@ -1,4 +1,4 @@ ---- **AI** - Create an automated A2G defense system based on a detection network of reconnaissance vehicles and air units, coordinating SEAD, BAI and CAS operations. +--- **AI** - Create an automated A2G defense system with reconnaissance units, coordinating SEAD, BAI and CAS operations. -- -- === -- diff --git a/Moose Development/Moose/AI/AI_Air_Dispatcher.lua b/Moose Development/Moose/AI/AI_Air_Dispatcher.lua index 5634a4f7a..c63e007d7 100644 --- a/Moose Development/Moose/AI/AI_Air_Dispatcher.lua +++ b/Moose Development/Moose/AI/AI_Air_Dispatcher.lua @@ -1,4 +1,4 @@ ---- **AI** - Create an automated AIR defense system based on a detection network of reconnaissance vehicles and air units, coordinating SEAD, BAI and CAP operations. +--- **AI** - Create an automated AIR defense system with reconnaissance units, coordinating SEAD, BAI and CAP operations. -- -- === -- diff --git a/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Helicopter.lua b/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Helicopter.lua index 96cafa944..33e6ca0d1 100644 --- a/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Helicopter.lua +++ b/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Helicopter.lua @@ -1,4 +1,4 @@ ---- **AI** - (2.4) - Models the intelligent transportation of infantry and other cargo using Helicopters. +--- **AI** - Models the intelligent transportation of infantry and other cargo using Helicopters. -- -- ## Features: -- diff --git a/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Ship.lua b/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Ship.lua index 205e5fec3..36604f30b 100644 --- a/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Ship.lua +++ b/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Ship.lua @@ -1,4 +1,4 @@ ---- **AI** - (2.5.1) - Models the intelligent transportation of infantry and other cargo using Ships. +--- **AI** - Models the intelligent transportation of infantry and other cargo using Ships. -- -- ## Features: -- From 09b86d6fdf73da7573331207d30eca052decb8c8 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Fri, 11 Nov 2022 15:40:03 +0100 Subject: [PATCH 09/14] #OPSGROUP * Fix for NewHover --- Moose Development/Moose/Ops/OpsGroup.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index 05d6c6b10..7656d769b 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -4305,8 +4305,9 @@ function OPSGROUP:_UpdateTask(Task, Mission) --self:I({Task.dcstask.params}) local alt = Task.dcstask.params.hoverAltitude local time =Task.dcstask.params.hoverTime - local Speed=UTILS.MpsToKnots(Task.dcstask.params.missionSpeed) or UTILS.KmphToKnots(self.speedCruise) - local CruiseAlt = UTILS.FeetToMeters(Task.dcstask.params.missionAltitude) + local mSpeed = Task.dcstask.params.missionSpeed or self.speedCruise or 150 + local Speed = UTILS.KmphToKnots(mSpeed) + local CruiseAlt = UTILS.FeetToMeters(Task.dcstask.params.missionAltitude or 1000) local helo = self:GetGroup() helo:SetSpeed(0.01,true) helo:SetAltitude(alt,true,"BARO") From 911f4523a161fca7aac29d38722b558c137417b8 Mon Sep 17 00:00:00 2001 From: Rolln Date: Fri, 11 Nov 2022 12:01:32 -0700 Subject: [PATCH 10/14] F10 Marker text fix (#1840) --- Moose Development/Moose/Ops/PlayerTask.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moose Development/Moose/Ops/PlayerTask.lua b/Moose Development/Moose/Ops/PlayerTask.lua index 828d38eee..2a1ec75d2 100644 --- a/Moose Development/Moose/Ops/PlayerTask.lua +++ b/Moose Development/Moose/Ops/PlayerTask.lua @@ -506,7 +506,7 @@ function PLAYERTASK:MarkTargetOnF10Map(Text,Coalition,ReadOnly) self.TargetMarker:Remove() end local text = Text or "Target of "..self.lid - self.TargetMarker = MARKER:New(coordinate,"Target of "..self.lid) + self.TargetMarker = MARKER:New(coordinate,text) if ReadOnly then self.TargetMarker:ReadOnly() end From 2664c36a149879f0f9bcf1907a8b2586db587c38 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Sun, 13 Nov 2022 13:37:55 +0100 Subject: [PATCH 11/14] #CTLD * Change call order to move troops, vehicle on `onafter..` internally * added pseudo-function for "OnBefore..." --- Moose Development/Moose/Ops/CTLD.lua | 151 +++++++++++++++++++++++---- 1 file changed, 132 insertions(+), 19 deletions(-) diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index bb5a86982..0a7c38665 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -583,6 +583,7 @@ do -- @field #number verbose Verbosity level. -- @field #string lid Class id string for output to DCS log file. -- @field #number coalition Coalition side number, e.g. `coalition.side.RED`. +-- @field #boolean debug -- @extends Core.Fsm#FSM --- *Combat Troop & Logistics Deployment (CTLD): Everyone wants to be a POG, until there\'s POG stuff to be done.* (Mil Saying) @@ -1072,12 +1073,12 @@ CTLD.UnitTypes = { --Actually it's longer, but the center coord is off-center of the model. ["UH-60L"] = {type="UH-60L", crates=true, troops=true, cratelimit = 2, trooplimit = 20, length = 16, cargoweightlimit = 3500}, -- 4t cargo, 20 (unsec) seats ["AH-64D_BLK_II"] = {type="AH-64D_BLK_II", crates=false, troops=true, cratelimit = 0, trooplimit = 2, length = 17, cargoweightlimit = 200}, -- 2 ppl **outside** the helo - ["Bronco-OV-10A"] = {type="Bronco-OV-10A", crates= false, troops=true, cratelimit = 0, trooplimit = 5, length = 13, cargoweightlimit = 1450}, + ["Bronco-OV-10A"] = {type="Bronco-OV-10A", crates= false, troops=true, cratelimit = 0, trooplimit = 5, length = 13, cargoweightlimit = 1450}, } --- CTLD class version. -- @field #string version -CTLD.version="1.0.18" +CTLD.version="1.0.19" --- Instantiate a new CTLD. -- @param #CTLD self @@ -1312,6 +1313,92 @@ function CTLD:New(Coalition, Prefixes, Alias) -- @param #CTLD self -- @param #number delay Delay in seconds. + --- FSM Function OnBeforeTroopsPickedUp. + -- @function [parent=#CTLD] OnBeforeTroopsPickedUp + -- @param #CTLD self + -- @param #string From State. + -- @param #string Event Trigger. + -- @param #string To State. + -- @param Wrapper.Group#GROUP Group Group Object. + -- @param Wrapper.Unit#UNIT Unit Unit Object. + -- @param #CTLD_CARGO Cargo Cargo troops. + -- @return #CTLD self + + --- FSM Function OnBeforeTroopsExtracted. + -- @function [parent=#CTLD] OnBeforeTroopsExtracted + -- @param #CTLD self + -- @param #string From State. + -- @param #string Event Trigger. + -- @param #string To State. + -- @param Wrapper.Group#GROUP Group Group Object. + -- @param Wrapper.Unit#UNIT Unit Unit Object. + -- @param #CTLD_CARGO Cargo Cargo troops. + -- @return #CTLD self + + --- FSM Function OnBeforeCratesPickedUp. + -- @function [parent=#CTLD] OnBeforeCratesPickedUp + -- @param #CTLD self + -- @param #string From State . + -- @param #string Event Trigger. + -- @param #string To State. + -- @param Wrapper.Group#GROUP Group Group Object. + -- @param Wrapper.Unit#UNIT Unit Unit Object. + -- @param #CTLD_CARGO Cargo Cargo crate. + -- @return #CTLD self + + --- FSM Function OnBeforeTroopsDeployed. + -- @function [parent=#CTLD] OnBeforeTroopsDeployed + -- @param #CTLD self + -- @param #string From State. + -- @param #string Event Trigger. + -- @param #string To State. + -- @param Wrapper.Group#GROUP Group Group Object. + -- @param Wrapper.Unit#UNIT Unit Unit Object. + -- @param Wrapper.Group#GROUP Troops Troops #GROUP Object. + -- @return #CTLD self + + --- FSM Function OnBeforeCratesDropped. + -- @function [parent=#CTLD] OnBeforeCratesDropped + -- @param #CTLD self + -- @param #string From State. + -- @param #string Event Trigger. + -- @param #string To State. + -- @param Wrapper.Group#GROUP Group Group Object. + -- @param Wrapper.Unit#UNIT Unit Unit Object. + -- @param #table Cargotable Table of #CTLD_CARGO objects dropped. + -- @return #CTLD self + + --- FSM Function OnBeforeCratesBuild. + -- @function [parent=#CTLD] OnBeforeCratesBuild + -- @param #CTLD self + -- @param #string From State. + -- @param #string Event Trigger. + -- @param #string To State. + -- @param Wrapper.Group#GROUP Group Group Object. + -- @param Wrapper.Unit#UNIT Unit Unit Object. + -- @param Wrapper.Group#GROUP Vehicle The #GROUP object of the vehicle or FOB build. + -- @return #CTLD self + + --- FSM Function OnBeforeCratesRepaired. + -- @function [parent=#CTLD] OnBeforeCratesRepaired + -- @param #CTLD self + -- @param #string From State. + -- @param #string Event Trigger. + -- @param #string To State. + -- @param Wrapper.Group#GROUP Group Group Object. + -- @param Wrapper.Unit#UNIT Unit Unit Object. + -- @param Wrapper.Group#GROUP Vehicle The #GROUP object of the vehicle or FOB repaired. + -- @return #CTLD self + + --- FSM Function OnBeforeTroopsRTB. + -- @function [parent=#CTLD] OnBeforeTroopsRTB + -- @param #CTLD self + -- @param #string From State. + -- @param #string Event Trigger. + -- @param #string To State. + -- @param Wrapper.Group#GROUP Group Group Object. + -- @param Wrapper.Unit#UNIT Unit Unit Object. + --- FSM Function OnAfterTroopsPickedUp. -- @function [parent=#CTLD] OnAfterTroopsPickedUp -- @param #CTLD self @@ -2590,9 +2677,7 @@ function CTLD:_UnloadTroops(Group, Unit) :InitRandomizeUnits(true,20,2) :InitDelayOff() :SpawnFromVec2(randomcoord) - if self.movetroopstowpzone and type ~= CTLD_CARGO.Enum.ENGINEERS then - self:_MoveGroupToZone(self.DroppedTroops[self.TroopCounter]) - end + self:__TroopsDeployed(1, Group, Unit, self.DroppedTroops[self.TroopCounter],type) end -- template loop cargo:SetWasDropped(true) -- engineering group? @@ -2604,7 +2689,6 @@ function CTLD:_UnloadTroops(Group, Unit) else self:_SendMessage(string.format("Dropped Troops %s into action!",name), 10, false, Group) end - self:__TroopsDeployed(1, Group, Unit, self.DroppedTroops[self.TroopCounter]) end -- if type end end -- cargotable loop else -- droppingatbase @@ -2958,9 +3042,6 @@ function CTLD:_BuildObjectFromCrates(Group,Unit,Build,Repair,RepairLocation) :InitDelayOff() :SpawnFromVec2(randomcoord) end - if self.movetroopstowpzone and canmove then - self:_MoveGroupToZone(self.DroppedTroops[self.TroopCounter]) - end if Repair then self:__CratesRepaired(1,Group,Unit,self.DroppedTroops[self.TroopCounter]) else @@ -3428,11 +3509,11 @@ function CTLD:AddCTLDZone(Name, Type, Color, Active, HasBeacon, Shiplength, Ship end if Type == CTLD.CargoZoneType.SHIP then - local Ship = UNIT:FindByName(Name) - if not Ship then - self:E(self.lid.."**** Ship does not exist: "..Name) - return self - end + local Ship = UNIT:FindByName(Name) + if not Ship then + self:E(self.lid.."**** Ship does not exist: "..Name) + return self + end end local ctldzone = {} -- #CTLD.CargoZone @@ -3696,7 +3777,7 @@ function CTLD:IsUnitInZone(Unit,Zonetype) zonecoord = ZoneUNIT:GetCoordinate() zoneradius = czone.shiplength zonewidth = czone.shipwidth - zone = ZONE_UNIT:New( ZoneUNIT:GetName(), ZoneUNIT, zoneradius/2) + zone = ZONE_UNIT:New( ZoneUNIT:GetName(), ZoneUNIT, zoneradius/2) elseif ZONE:FindByName(zonename) then zone = ZONE:FindByName(zonename) self:T("Checking Zone: "..zonename) @@ -4215,7 +4296,7 @@ end self.EngineersInField[self.Engineers] = CTLD_ENGINEERING:New(name, grpname) end if self.eventoninject then - self:__TroopsDeployed(1,nil,nil,self.DroppedTroops[self.TroopCounter]) + self:__TroopsDeployed(1,nil,nil,self.DroppedTroops[self.TroopCounter],type) end end -- if type end return self @@ -4282,9 +4363,6 @@ end :InitDelayOff() :SpawnFromVec2(randomcoord) end - if self.movetroopstowpzone and canmove then - self:_MoveGroupToZone(self.DroppedTroops[self.TroopCounter]) - end if self.eventoninject then self:__CratesBuild(1,nil,nil,self.DroppedTroops[self.TroopCounter]) end @@ -4491,6 +4569,24 @@ end return self end + --- (Internal) FSM Function onafterTroopsDeployed. + -- @param #CTLD self + -- @param #string From State. + -- @param #string Event Trigger. + -- @param #string To State. + -- @param Wrapper.Group#GROUP Group Group Object. + -- @param Wrapper.Unit#UNIT Unit Unit Object. + -- @param Wrapper.Group#GROUP Troops Troops #GROUP Object. + -- @param #CTLD.CargoZoneType Type Type of Cargo deployed + -- @return #CTLD self + function CTLD:onafterTroopsDeployed(From, Event, To, Group, Unit, Troops, Type) + self:T({From, Event, To}) + if self.movetroopstowpzone and Type ~= CTLD_CARGO.Enum.ENGINEERS then + self:_MoveGroupToZone(Troops) + end + return self + end + --- (Internal) FSM Function onbeforeCratesDropped. -- @param #CTLD self -- @param #string From State. @@ -4540,6 +4636,23 @@ end return self end + --- (Internal) FSM Function onafterCratesBuild. + -- @param #CTLD self + -- @param #string From State. + -- @param #string Event Trigger. + -- @param #string To State. + -- @param Wrapper.Group#GROUP Group Group Object. + -- @param Wrapper.Unit#UNIT Unit Unit Object. + -- @param Wrapper.Group#GROUP Vehicle The #GROUP object of the vehicle or FOB build. + -- @return #CTLD self + function CTLD:onafterCratesBuild(From, Event, To, Group, Unit, Vehicle) + self:T({From, Event, To}) + if self.movetroopstowpzone then + self:_MoveGroupToZone(Vehicle) + end + return self + end + --- (Internal) FSM Function onbeforeTroopsRTB. -- @param #CTLD self -- @param #string From State. From 243ac3027fac4618f4f7997a5c5622f24af7b1f3 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Mon, 14 Nov 2022 17:38:07 +0100 Subject: [PATCH 12/14] #PLAYERTASK * Added a couple of QOL functions for internal INTEL object --- Moose Development/Moose/Ops/PlayerTask.lua | 60 ++++++++++++++++++---- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/Moose Development/Moose/Ops/PlayerTask.lua b/Moose Development/Moose/Ops/PlayerTask.lua index 2a1ec75d2..897f40f71 100644 --- a/Moose Development/Moose/Ops/PlayerTask.lua +++ b/Moose Development/Moose/Ops/PlayerTask.lua @@ -506,7 +506,7 @@ function PLAYERTASK:MarkTargetOnF10Map(Text,Coalition,ReadOnly) self.TargetMarker:Remove() end local text = Text or "Target of "..self.lid - self.TargetMarker = MARKER:New(coordinate,text) + self.TargetMarker = MARKER:New(coordinate,"Target of "..self.lid) if ReadOnly then self.TargetMarker:ReadOnly() end @@ -1402,7 +1402,7 @@ PLAYERTASKCONTROLLER.Messages = { --- PLAYERTASK class version. -- @field #string version -PLAYERTASKCONTROLLER.version="0.1.46" +PLAYERTASKCONTROLLER.version="0.1.47" --- Create and run a new TASKCONTROLLER instance. -- @param #PLAYERTASKCONTROLLER self @@ -2573,7 +2573,7 @@ function PLAYERTASKCONTROLLER:_AddTask(Target) task:_SetController(self) self.TaskQueue:Push(task) - self:__TaskAdded(-1,task) + self:__TaskAdded(10,task) return self end @@ -2607,7 +2607,7 @@ function PLAYERTASKCONTROLLER:AddPlayerTaskToQueue(PlayerTask) PlayerTask:_SetController(self) PlayerTask:SetCoalition(self.Coalition) self.TaskQueue:Push(PlayerTask) - self:__TaskAdded(-1,PlayerTask) + self:__TaskAdded(10,PlayerTask) else self:E(self.lid.."***** NO valid PAYERTASK object sent!") end @@ -3255,7 +3255,21 @@ function PLAYERTASKCONTROLLER:AddAgent(Recce) if self.Intel then self.Intel:AddAgent(Recce) else - self:E(self.lid.."NO detection has been set up (yet)!") + self:E(self.lid.."*****NO detection has been set up (yet)!") + end + return self +end + +--- [User] Set up detection of STATIC objects. You need to set up detection with @{#PLAYERTASKCONTROLLER.SetupIntel}() **before** using this. +-- @param #PLAYERTASKCONTROLLER self +-- @param #boolean OnOff Set to `true`for on and `false`for off. +-- @return #PLAYERTASKCONTROLLER self +function PLAYERTASKCONTROLLER:SwitchDetectStatics(OnOff) + self:T(self.lid.."SwitchDetectStatics") + if self.Intel then + self.Intel:SetDetectStatics(OnOff) + else + self:E(self.lid.."***** NO detection has been set up (yet)!") end return self end @@ -3269,7 +3283,21 @@ function PLAYERTASKCONTROLLER:AddAcceptZone(AcceptZone) if self.Intel then self.Intel:AddAcceptZone(AcceptZone) else - self:E(self.lid.."NO detection has been set up (yet)!") + self:E(self.lid.."*****NO detection has been set up (yet)!") + end + return self +end + +--- [User] Add accept SET_ZONE to INTEL detection. You need to set up detection with @{#PLAYERTASKCONTROLLER.SetupIntel}() **before** using this. +-- @param #PLAYERTASKCONTROLLER self +-- @param Core.Set#SET_ZONE AcceptZoneSet Add a SET_ZONE to the accept zone set. +-- @return #PLAYERTASKCONTROLLER self +function PLAYERTASKCONTROLLER:AddAcceptZoneSet(AcceptZoneSet) + self:T(self.lid.."AddAcceptZoneSet") + if self.Intel then + self.Intel.acceptzoneset:AddSet(AcceptZoneSet) + else + self:E(self.lid.."*****NO detection has been set up (yet)!") end return self end @@ -3283,7 +3311,21 @@ function PLAYERTASKCONTROLLER:AddRejectZone(RejectZone) if self.Intel then self.Intel:AddRejectZone(RejectZone) else - self:E(self.lid.."NO detection has been set up (yet)!") + self:E(self.lid.."*****NO detection has been set up (yet)!") + end + return self +end + +--- [User] Add reject SET_ZONE to INTEL detection. You need to set up detection with @{#PLAYERTASKCONTROLLER.SetupIntel}() **before** using this. +-- @param #PLAYERTASKCONTROLLER self +-- @param Core.Set#SET_ZONE RejectZoneSet Add a zone to the reject zone set. +-- @return #PLAYERTASKCONTROLLER self +function PLAYERTASKCONTROLLER:AddRejectZone(RejectZoneSet) + self:T(self.lid.."AddRejectZoneSet") + if self.Intel then + self.Intel.rejectzoneset:AddSet(RejectZoneSet) + else + self:E(self.lid.."*****NO detection has been set up (yet)!") end return self end @@ -3297,7 +3339,7 @@ function PLAYERTASKCONTROLLER:RemoveAcceptZone(AcceptZone) if self.Intel then self.Intel:RemoveAcceptZone(AcceptZone) else - self:E(self.lid.."NO detection has been set up (yet)!") + self:E(self.lid.."*****NO detection has been set up (yet)!") end return self end @@ -3311,7 +3353,7 @@ function PLAYERTASKCONTROLLER:RemoveRejectZone(RejectZone) if self.Intel then self.Intel:RemoveRejectZone(RejectZone) else - self:E(self.lid.."NO detection has been set up (yet)!") + self:E(self.lid.."*****NO detection has been set up (yet)!") end return self end From 2acb8415397eb3f78630f5c3c644643b1bc0f6d1 Mon Sep 17 00:00:00 2001 From: Thomas <72444570+Applevangelist@users.noreply.github.com> Date: Tue, 15 Nov 2022 15:59:03 +0100 Subject: [PATCH 13/14] Update PlayerTask.lua Feature added #1841 `PLAYERTASKCONTROLLER:SetInfoShowsCoordinate(OnOff,LLDDM)` --- Moose Development/Moose/Ops/PlayerTask.lua | 46 ++++++++++++++++++---- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/Moose Development/Moose/Ops/PlayerTask.lua b/Moose Development/Moose/Ops/PlayerTask.lua index 13dde2c8f..986e78c0e 100644 --- a/Moose Development/Moose/Ops/PlayerTask.lua +++ b/Moose Development/Moose/Ops/PlayerTask.lua @@ -506,7 +506,7 @@ function PLAYERTASK:MarkTargetOnF10Map(Text,Coalition,ReadOnly) self.TargetMarker:Remove() end local text = Text or "Target of "..self.lid - self.TargetMarker = MARKER:New(coordinate,"Target of "..self.lid) + self.TargetMarker = MARKER:New(coordinate,text) if ReadOnly then self.TargetMarker:ReadOnly() end @@ -567,7 +567,7 @@ function PLAYERTASK:IlluminateTarget(Power,Height) if self.Target then local coordinate = self.Target:GetAverageCoordinate() if coordinate then - local bcoord = COORDINATE:NewFromVec2( coordinate:GetVec2(), Height ) + local bcoord = COORDINATE:NewFromVec2( coordinate:GetVec2(), Height ) bcoord:IlluminationBomb(Power) end end @@ -923,6 +923,8 @@ do -- @field #number Coalition -- @field Core.Menu#MENU_MISSION MenuParent -- @field #boolean ShowMagnetic Also show magnetic angles +-- @field #boolean InfoHasCoordinate +-- @field #boolean InfoHasLLDDM -- @extends Core.Fsm#FSM --- @@ -1108,6 +1110,7 @@ do -- FLASHMENU = "Flash Directions Switch", -- BRIEFING = "Briefing", -- TARGETLOCATION ="Target location", +-- COORDINATE = "Coordinate", -- }, -- -- e.g. @@ -1236,6 +1239,8 @@ PLAYERTASKCONTROLLER = { Coalition = nil, MenuParent = nil, ShowMagnetic = true, + InfoHasLLDDM = false, + InfoHasCoordinate = false, } --- @@ -1333,6 +1338,7 @@ PLAYERTASKCONTROLLER.Messages = { FLASHMENU = "Flash Directions Switch", BRIEFING = "Briefing", TARGETLOCATION ="Target location", + COORDINATE = "Coordinate", }, DE = { TASKABORT = "Auftrag abgebrochen!", @@ -1396,13 +1402,14 @@ PLAYERTASKCONTROLLER.Messages = { FLASHOFF = "%s - Richtungsangaben einblenden ist AUS!", FLASHMENU = "Richtungsangaben Schalter", BRIEFING = "Briefing", - TARGETLOCATION ="Zielkoordinate", + TARGETLOCATION ="Zielposition", + COORDINATE = "Koordinate", }, } --- PLAYERTASK class version. -- @field #string version -PLAYERTASKCONTROLLER.version="0.1.47" +PLAYERTASKCONTROLLER.version="0.1.48" --- Create and run a new TASKCONTROLLER instance. -- @param #PLAYERTASKCONTROLLER self @@ -1638,6 +1645,18 @@ function PLAYERTASKCONTROLLER:SetEnableSmokeFlareTask() return self end +--- [User] Show info text on screen with a coordinate info in any case (OFF by default) +-- @param #PLAYERTASKCONTROLLER self +-- @param #boolean OnOff Switch on = true or off = false +-- @param #boolean LLDDM Show LLDDM = true or LLDMS = false +-- @return #PLAYERTASKCONTROLLER self +function PLAYERTASKCONTROLLER:SetInfoShowsCoordinate(OnOff,LLDDM) + self:T(self.lid.."SetInfoShowsCoordinate") + self.InfoHasCoordinate = OnOff + self.InfoHasLLDDM = LLDDM + return self +end + --- [User] Set callsign options for TTS output. See @{Wrapper.Group#GROUP.GetCustomCallSign}() on how to set customized callsigns. -- @param #PLAYERTASKCONTROLLER self -- @param #boolean ShortCallsign If true, only call out the major flight number @@ -2733,6 +2752,7 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Group, Client, Task) local ttstaskname = string.format(ttsname,task.TTSType,task.PlayerTaskNr) local Coordinate = task.Target:GetCoordinate() local CoordText = "" + local CoordTextLLDM = nil if self.Type ~= PLAYERTASKCONTROLLER.Type.A2A then CoordText = Coordinate:ToStringA2G(Client,nil,self.ShowMagnetic) else @@ -2827,15 +2847,25 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Group, Client, Task) else local keine = self.gettext:GetEntry("NONE",self.locale) clienttxt = clienttxt .. keine - end - - -- Task Report + end text = text .. clienttxt + textTTS = textTTS .. clienttxt + -- Task Report + if self.InfoHasCoordinate then + if self.InfoHasLLDDM then + CoordTextLLDM = Coordinate:ToStringLLDDM() + else + CoordTextLLDM = Coordinate:ToStringLLDMS() + end + -- TARGETLOCATION + local locatxt = self.gettext:GetEntry("COORDINATE",self.locale) + text = string.format("%s\n%s: %s",text,locatxt,CoordTextLLDM) + end if task:HasFreetext() and not ( task.Type == AUFTRAG.Type.CTLD or task.Type == AUFTRAG.Type.CSAR) then local brieftxt = self.gettext:GetEntry("BRIEFING",self.locale) text = text .. string.format("\n%s: ",brieftxt)..task:GetFreetext() end - textTTS = textTTS .. clienttxt + if self.UseSRS then if string.find(CoordText," BR, ") then CoordText = string.gsub(CoordText," BR, "," Bee, Arr, ") From f86db5f134cde0475192ecd9560eab97f2623fcc Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 15 Nov 2022 17:56:29 +0100 Subject: [PATCH 14/14] #PLAYERTASK * Verbose to false * Verbose add message for marker ops showing coordinate as per _SETTINGS --- Moose Development/Moose/Ops/PlayerTask.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Moose Development/Moose/Ops/PlayerTask.lua b/Moose Development/Moose/Ops/PlayerTask.lua index 986e78c0e..a36ab6e8c 100644 --- a/Moose Development/Moose/Ops/PlayerTask.lua +++ b/Moose Development/Moose/Ops/PlayerTask.lua @@ -567,7 +567,7 @@ function PLAYERTASK:IlluminateTarget(Power,Height) if self.Target then local coordinate = self.Target:GetAverageCoordinate() if coordinate then - local bcoord = COORDINATE:NewFromVec2( coordinate:GetVec2(), Height ) + local bcoord = COORDINATE:NewFromVec2( coordinate:GetVec2(), Height ) bcoord:IlluminationBomb(Power) end end @@ -1206,7 +1206,7 @@ do -- @field #PLAYERTASKCONTROLLER PLAYERTASKCONTROLLER = { ClassName = "PLAYERTASKCONTROLLER", - verbose = true, + verbose = false, lid = nil, TargetQueue = nil, ClientSet = nil, @@ -1409,7 +1409,7 @@ PLAYERTASKCONTROLLER.Messages = { --- PLAYERTASK class version. -- @field #string version -PLAYERTASKCONTROLLER.version="0.1.48" +PLAYERTASKCONTROLLER.version="0.1.49" --- Create and run a new TASKCONTROLLER instance. -- @param #PLAYERTASKCONTROLLER self @@ -1807,7 +1807,7 @@ function PLAYERTASKCONTROLLER:EnableMarkerOps(Tag) local function Handler(Keywords,Coord,Text) if self.verbose then - local m = MESSAGE:New(string.format("Target added from marker at: %s", Coord:ToStringLLDMS()),15,"INFO"):ToAll() + local m = MESSAGE:New(string.format("Target added from marker at: %s", Coord:ToStringA2G(nil, nil, self.ShowMagnetic)),15,"INFO"):ToAll() end self:AddTarget(Coord) end @@ -1968,6 +1968,9 @@ function PLAYERTASKCONTROLLER:_EventHandler(EventData) --local text = string.format("%s, %s, switch to %s for task assignment!",EventData.IniPlayerName,self.MenuName or self.Name,freqtext) local text = string.format(switchtext,playername,self.MenuName or self.Name,freqtext) self.SRSQueue:NewTransmission(text,nil,self.SRS,timer.getAbsTime()+60,2,{EventData.IniGroup},text,30,self.BCFrequency,self.BCModulation) + if EventData.IniUnitName then + self:_BuildMenus(CLIENT:FindByName(EventData.IniUnitName)) + end end end return self