From 422e1118574f38e04ff9e29e18058bc557d9a482 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 30 Apr 2020 01:42:38 +0200 Subject: [PATCH] Ops --- .../Moose/Functional/Warehouse.lua | 5 +- Moose Development/Moose/Ops/AirWing.lua | 72 ++++----- Moose Development/Moose/Ops/Auftrag.lua | 55 +++---- Moose Development/Moose/Ops/FlightGroup.lua | 139 +++++++++--------- Moose Development/Moose/Ops/Intelligence.lua | 3 +- Moose Development/Moose/Ops/Squadron.lua | 2 +- Moose Development/Moose/Ops/WingCommander.lua | 2 +- Moose Development/Moose/Utilities/Enums.lua | 56 ++++++- Moose Development/Moose/Utilities/Utils.lua | 31 ++-- .../Moose/Wrapper/Controllable.lua | 2 +- 10 files changed, 224 insertions(+), 143 deletions(-) diff --git a/Moose Development/Moose/Functional/Warehouse.lua b/Moose Development/Moose/Functional/Warehouse.lua index 3ee8c9216..4e3d70898 100644 --- a/Moose Development/Moose/Functional/Warehouse.lua +++ b/Moose Development/Moose/Functional/Warehouse.lua @@ -6133,10 +6133,11 @@ function WAREHOUSE:_OnEventBirth(EventData) end else - --self:T3({wid=wid, uid=self.uid, match=(wid==self.uid), tw=type(wid), tu=type(self.uid)}) + -- No request?! + self:E(self.lid..string.format("ERROR: Could not get request when asset spawned! FF investigate! Unit name=%s asset spawed=%s", EventData.IniUnitName, tostring(asset.spawned))) end else - self:E(self.lid..string.format("ERROR: Could not get request when asset spawned! FF investigate!")) + -- Born unit does not belong to this warehouse. end end diff --git a/Moose Development/Moose/Ops/AirWing.lua b/Moose Development/Moose/Ops/AirWing.lua index efafd3329..ab51ec4db 100644 --- a/Moose Development/Moose/Ops/AirWing.lua +++ b/Moose Development/Moose/Ops/AirWing.lua @@ -44,7 +44,7 @@ -- -- === -- --- ![Banner Image](..\Presentations\CarrierAirWing\AIRWING_Main.jpg) +-- ![Banner Image](..\Presentations\AirWing\AIRWING_Main.jpg) -- -- # The AIRWING Concept -- @@ -93,7 +93,7 @@ AIRWING = { --- AIRWING class version. -- @field #string version -AIRWING.version="0.1.7" +AIRWING.version="0.2.0" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- ToDo list @@ -322,15 +322,20 @@ end -- @return #AIRWING.Payload Payload table or *nil*. function AIRWING:FetchPayloadFromStock(UnitType, MissionType) + -- Quick check if we have any payloads. if not self.payloads or #self.payloads==0 then self:I(self.lid.."WARNING: No payloads in stock!") return nil end - self:I(self.lid..string.format("Looking for payload for unit type=%s and mission type=%s", UnitType, MissionType)) - for i,_payload in pairs(self.payloads) do - local payload=_payload --#AIRWING.Payload - self:I(self.lid..string.format("[%d] Payload type=%s navail=%d unlimited=%s", i, payload.aircrafttype, payload.navail, tostring(payload.unlimited))) + -- Debug. + if self.Debug then + self:I(self.lid..string.format("Looking for payload for unit type=%s and mission type=%s", UnitType, MissionType)) + for i,_payload in pairs(self.payloads) do + local payload=_payload --#AIRWING.Payload + local performance=self:GetPayloadPeformance(payload, MissionType) + self:I(self.lid..string.format("[%d] Payload type=%s navail=%d unlimited=%s", i, payload.aircrafttype, payload.navail, tostring(payload.unlimited))) + end end --- Sort payload wrt the following criteria: @@ -340,56 +345,57 @@ function AIRWING:FetchPayloadFromStock(UnitType, MissionType) local function sortpayloads(a,b) local pA=a --#AIRWING.Payload local pB=b --#AIRWING.Payload - if a and b then --TODO: Strangely, I had the case that a or b were nil even though the self.payloads table was looking okay. Very strange! + if a and b then -- I had the case that a or b were nil even though the self.payloads table was looking okay. Very strange! Seems to be solved by pre-selecting valid payloads. local performanceA=self:GetPayloadPeformance(a, MissionType) local performanceB=self:GetPayloadPeformance(b, MissionType) return (performanceA>performanceB) or (performanceA==performanceB and a.unlimited==true) or (performanceA==performanceB and a.unlimited==true and b.unlimited==true and a.navail>b.navail) elseif not a then - env.info("FF ERROR in sortpayloads: a is nil") + self:I(self.lid..string.format("FF ERROR in sortpayloads: a is nil")) return false elseif not b then - env.info("FF ERROR in sortpayloads: b is nil") + self:I(self.lid..string.format("FF ERROR in sortpayloads: b is nil")) return true else - env.info("FF ERROR in sortpayloads: a and b are nil") + self:I(self.lid..string.format("FF ERROR in sortpayloads: a and b are nil")) return false end end - table.sort(self.payloads, sortpayloads) + -- Pre-selection: filter out only those payloads that are valid for the airframe and mission type and are available. + local payloads={} + for _,_payload in pairs(self.payloads) do + local payload=_payload --#AIRWING.Payload + if payload.aircrafttype==UnitType and self:CheckMissionCapability(MissionType, payload.capabilities) and payload.navail>0 then + table.insert(payloads, payload) + end + end + + -- Debug. if self.Debug then - env.info("FF Sorted payloads for mission type X and aircraft type=Y:") + self:I(self.lid..string.format("FF Sorted payloads for mission type X and aircraft type=Y:")) for _,_payload in ipairs(self.payloads) do local payload=_payload --#AIRWING.Payload if payload.aircrafttype==UnitType and self:CheckMissionCapability(MissionType, payload.capabilities) then local performace=self:GetPayloadPeformance(payload, MissionType) - self:I(string.format("FF %s payload for %s: avail=%d performace=%d", MissionType, payload.aircrafttype, payload.navail, performace)) + self:I(self.lid..string.format("FF %s payload for %s: avail=%d performace=%d", MissionType, payload.aircrafttype, payload.navail, performace)) end end end - for _,_payload in ipairs(self.payloads) do - local payload=_payload --#AIRWING.Payload - - - -- Check right type, mission and available. - if payload.aircrafttype==UnitType and payload.navail>0 and self:CheckMissionCapability(MissionType, payload.capabilities) then - - -- Consume if not unlimited. - if not payload.unlimited then - payload.navail=payload.navail-1 - end - - self:T(string.format("FETCHING %s payload for %s: avail=%d performance=%d", MissionType, payload.aircrafttype, payload.navail, self:GetPayloadPeformance(payload, MissionType))) - - -- Return a copy of the table. - return payload - end - + -- Cases: + if #payloads==0 then + -- No payload available. + self:T(self.lid.."Warning could not find a payload for airframe X mission type Y!") + return nil + elseif #payloads==1 then + -- Only one payload anyway. + return payloads[1] + else + -- Sort payloads. + table.sort(payloads, sortpayloads) + return payloads[1] end - self:T(self.lid.."Warning could not find a payload for airframe X mission type Y!") - return nil end --- Return payload from asset back to stock. diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index ac1d62f34..fb660f99a 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -326,7 +326,7 @@ AUFTRAG.TargetType={ --- AUFTRAG class version. -- @field #string version -AUFTRAG.version="0.2.1" +AUFTRAG.version="0.2.3" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -348,8 +348,8 @@ AUFTRAG.version="0.2.1" -- DONE: Evaluate mission result ==> SUCCESS/FAILURE -- DONE: NewAUTO() NewA2G NewA2A -- DONE: Transport mission. --- TODO: Recon mission. --- TODO: Set mission coalition, e.g. for F10 markers. +-- TODO: Recon mission. What input? Set of coordinates? +-- TODO: Set mission coalition, e.g. for F10 markers. Could be derived from target if target has a coalition. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Constructor @@ -429,27 +429,6 @@ end -- Create Missions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---- Create a RESCUE HELO mission. --- @param #AUFTRAG self --- @param Wrapper.Unit#UNIT Carrier The carrier unit. --- @return #AUFTRAG self -function AUFTRAG:NewRESCUEHELO(Carrier) - - local mission=AUFTRAG:New(AUFTRAG.Type.RESCUEHELO) - - mission:_TargetFromObject(Carrier) - - -- Mission options: - mission.missionTask=ENUMS.MissionTask.NOTHING - mission.missionFraction=0.5 - mission.optionROE=ENUMS.ROE.WeaponHold - mission.optionROT=ENUMS.ROT.NoReaction - - mission.DCStask=mission:GetDCSMissionTask() - - return mission -end - --- Create an ANTI-SHIP mission. -- @param #AUFTRAG self -- @param Wrapper.Positionable#POSITIONABLE Target The target to attack. Can be passed as a @{Wrapper.Group#GROUP} or @{Wrapper.Unit#UNIT} object. @@ -478,7 +457,7 @@ function AUFTRAG:NewANTISHIP(Target, Altitude) return mission end ---- Create an ORBIT mission. +--- Create an ORBIT mission, which can be either a circular orbit or a race-track pattern. -- @param #AUFTRAG self -- @param Core.Point#COORDINATE Coordinate Where to orbit. -- @param #number Altitude Orbit altitude in feet. Default is y component of `Coordinate`. @@ -504,8 +483,10 @@ function AUFTRAG:NewORBIT(Coordinate, Altitude, Speed, Heading, Leg) if Heading and Leg then self.orbitHeading=Heading - self.orbitLeg=Leg + self.orbitLeg=UTILS.NMToMeters(Leg) self.orbitRaceTrack=Coordinate:Translate(self.orbitLeg, self.orbitHeading, true) + Coordinate:MarkToAll("Orbit RT 1 ") + self.orbitRaceTrack:MarkToAll("Orbit RT 2") end @@ -992,6 +973,28 @@ function AUFTRAG:NewESCORT(EscortGroup, OffsetVector, EngageMaxDistance, TargetT return mission end +--- Create a RESCUE HELO mission. +-- @param #AUFTRAG self +-- @param Wrapper.Unit#UNIT Carrier The carrier unit. +-- @return #AUFTRAG self +function AUFTRAG:NewRESCUEHELO(Carrier) + + local mission=AUFTRAG:New(AUFTRAG.Type.RESCUEHELO) + + mission:_TargetFromObject(Carrier) + + -- Mission options: + mission.missionTask=ENUMS.MissionTask.NOTHING + mission.missionFraction=0.5 + mission.optionROE=ENUMS.ROE.WeaponHold + mission.optionROT=ENUMS.ROT.NoReaction + + mission.DCStask=mission:GetDCSMissionTask() + + return mission +end + + --- Create a TROOP TRANSPORT mission. -- @param #AUFTRAG self -- @param Core.Set#SET_GROUP TransportGroupSet The set group(s) to be transported. diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index ce0fcf5f8..b9917b826 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -104,7 +104,7 @@ -- -- === -- --- ![Banner Image](..\Presentations\CarrierAirWing\FLIGHTGROUP_Main.jpg) +-- ![Banner Image](..\Presentations\FlightGroup\FLIGHTGROUP_Main.jpg) -- -- # The FLIGHTGROUP Concept -- @@ -374,7 +374,7 @@ FLIGHTGROUP.ROT={ --- FLIGHTGROUP class version. -- @field #string version -FLIGHTGROUP.version="0.3.9" +FLIGHTGROUP.version="0.4.0" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -683,8 +683,8 @@ function FLIGHTGROUP:AddTaskWaypoint(task, waypointindex, description, prio, dur self:T3({newtask=newtask}) -- Update route. - self:_CheckFlightDone(1) - --self:__UpdateRoute(-1) + --self:_CheckFlightDone(1) + self:__UpdateRoute(-1) return newtask end @@ -1157,16 +1157,23 @@ end -- @return #FLIGHTGROUP self function FLIGHTGROUP:Activate(delay) - if self:IsAlive()==false then - if delay then + if delay and delay>0 then self:T2(self.lid..string.format("Activating late activated group in %d seconds", delay)) - self:ScheduleOnce(delay, FLIGHTGROUP.Activate, self) - else + self:ScheduleOnce(delay, FLIGHTGROUP.Activate, self) + else + + if self:IsAlive()==false then + self:T(self.lid.."Activating late activated group") self.group:Activate() + self.isLateActivated=false + + elseif self:IsAlive()==true then + self:E(self.lid.."WARNING: Activating group that is already activated") + else + self:E(self.lid.."ERROR: Activating group that is does not exist!") end - else - self:E(self.lid..string.format("ERROR: Cannot activate group as IsAlive()==%s", tostring(self:IsAlive()))) + end return self @@ -1178,19 +1185,26 @@ end -- @return #FLIGHTGROUP self function FLIGHTGROUP:StartUncontrolled(delay) - if self:IsAlive() then - --TODO: check Alive==true and Alive==false ==> Activate first - self:I(self.lid.."Starting uncontrolled group") - self.group:StartUncontrolled(delay) + if delay and delay>0 then + self:T2(self.lid..string.format("Starting uncontrolled group in %d seconds", delay)) + self:ScheduleOnce(delay, FLIGHTGROUP.StartUncontrolled, self) else - self:E(self.lid.."ERROR: Could not start uncontrolled group as it is NOT alive (yet)!") - self.group:StartUncontrolled(delay) + + if self:IsAlive() then + --TODO: check Alive==true and Alive==false ==> Activate first + self:I(self.lid.."Starting uncontrolled group") + self.group:StartUncontrolled(delay) + self.isUncontrolled=true + else + self:E(self.lid.."ERROR: Could not start uncontrolled group as it is NOT alive!") + end + end return self end ---- Set DCS task. +--- Set DCS task. Enroute tasks are injected automatically. -- @param #FLIGHTGROUP self -- @param #table DCSTask DCS task structure. -- @return #FLIGHTGROUP self @@ -1221,7 +1235,7 @@ function FLIGHTGROUP:SetTask(DCSTask) end end - -- Set task + -- Set task. self.group:SetTask(DCSTask) -- Debug info. @@ -1233,6 +1247,7 @@ function FLIGHTGROUP:SetTask(DCSTask) end self:I(self.lid..text) end + return self end @@ -1241,16 +1256,22 @@ end -- @param #table DCSTask DCS task structure. -- @return #FLIGHTGROUP self function FLIGHTGROUP:PushTask(DCSTask) + if self:IsAlive() then - self.group:PushTask(DCSTask, 1) + + -- Push task. + self.group:PushTask(DCSTask) + + -- Debug info. local text=string.format("PUSHING Task %s", tostring(DCSTask.id)) if tostring(DCSTask.id)=="ComboTask" then for i,task in pairs(DCSTask.params.tasks) do text=text..string.format("\n[%d] %s", i, tostring(task.id)) end end - self:I(self.lid..text) + self:I(self.lid..text) end + return self end @@ -2769,7 +2790,10 @@ function FLIGHTGROUP:_CheckFlightDone(delay) end + -- Number of tasks remaining. local nTasks=self:CountRemainingTasks() + + -- Number of mission remaining. local nMissions=self:CountRemainingMissison() -- Final waypoint passed? @@ -3227,7 +3251,7 @@ function FLIGHTGROUP:onafterHolding(From, Event, To) end ---- On after "Engage" event. Order to engage a set of units. +--- On after "EngageTargets" event. Order to engage a set of units. -- @param #FLIGHTGROUP self -- @param #string From From state. -- @param #string Event Event. @@ -3249,8 +3273,7 @@ function FLIGHTGROUP:onafterEngageTargets(From, Event, To, TargetUnitSet) --TODO needs a task function that calls EngageDone or so event and updates the route again. -- Lets try if pushtask actually leaves the remaining tasks untouched. - -- TODO: the problem is if UpdateRoute is called because it would destroy this task! - self:PushTask(DCSTask) + self:SetTask(DCSTask) end @@ -3798,18 +3821,18 @@ end function FLIGHTGROUP:onbeforeMissionStart(From, Event, To, Mission) -- Debug info. - self:T(self.lid..string.format("Starting mission %s, FSM=%s, LateActivated=%s, UnControlled=%s", tostring(Mission.name), self:GetState(), tostring(self:IsLateActivated()), tostring(self:IsUncontrolled()))) + self:I(self.lid..string.format("Starting mission %s, FSM=%s, LateActivated=%s, UnControlled=%s", tostring(Mission.name), self:GetState(), tostring(self:IsLateActivated()), tostring(self:IsUncontrolled()))) -- Delay for route to mission. Group needs to be activated and controlled. - local delay=0 + local delay=1 -- Check if group is spawned. if self:IsInUtero() then -- Activate group if it is late activated. if self:IsLateActivated() then - self:Activate() - delay=delay+2 + self:Activate(delay) + delay=delay+1 end end @@ -3818,8 +3841,8 @@ function FLIGHTGROUP:onbeforeMissionStart(From, Event, To, Mission) if self:IsParking() and self:IsUncontrolled() then self:StartUncontrolled(delay) else - env.info("FF hallo!") - self:StartUncontrolled(5) + --env.info("FF hallo!") + --self:StartUncontrolled(5) end return true @@ -3833,6 +3856,7 @@ end -- @param Ops.Auftrag#AUFTRAG Mission The mission table. function FLIGHTGROUP:onafterMissionStart(From, Event, To, Mission) + -- Debug output. local text=string.format("Starting %s Mission %s, target %s", Mission.type, tostring(Mission.name), Mission:GetTargetName()) self:T(self.lid..text) MESSAGE:New(text, 30, self.groupname):ToAllIf(true) @@ -3847,7 +3871,8 @@ function FLIGHTGROUP:onafterMissionStart(From, Event, To, Mission) Mission:Started() -- Route flight to mission zone. - self:RouteToMission(Mission, 5) + self:RouteToMission(Mission, 3) + end --- On after "MissionExecute" event. Mission execution began. @@ -4179,6 +4204,7 @@ end -- @return #FLIGHTGROUP self function FLIGHTGROUP:_InitGroup() + -- First check if group was already initialized. if self.groupinitialized then self:E(self.lid.."WARNING: Group was already initialized!") return @@ -4190,6 +4216,12 @@ function FLIGHTGROUP:_InitGroup() -- Helo group. self.ishelo=self.group:IsHelicopter() + -- Is (template) group uncontrolled. + self.isUncontrolled=self.template.uncontrolled + + -- Is (template) group late activated. + self.isLateActivated=self.template.lateActivation + -- Max speed in km/h. self.speedmax=self.group:GetSpeedMax() @@ -4201,7 +4233,7 @@ function FLIGHTGROUP:_InitGroup() -- Initial fuel mass. -- TODO: this is a unit property! - self.fuelmass=0 --self.template.pylons.fuel + self.fuelmass=0 self.traveldist=0 self.traveltime=timer.getAbsTime() @@ -4218,11 +4250,10 @@ function FLIGHTGROUP:_InitGroup() self.radioModuDefault=self.radioModu end + -- Get first unit. This is used to extract other parameters. local unit=self.group:GetUnit(1) if unit then - - --local nunits=self.group:GetUnits() self.rangemax=unit:GetRange() @@ -4254,7 +4285,7 @@ function FLIGHTGROUP:_InitGroup() text=text..string.format("Helicopter = %s\n", tostring(self.group:IsHelicopter())) text=text..string.format("Elements = %d\n", #self.elements) text=text..string.format("Waypoints = %d\n", #self.waypoints) - text=text..string.format("Radio = %.1f%d %s\n", self.radioFreq, self.radioModu, tostring(self.radioOn)) + text=text..string.format("Radio = %.1f MHz %s %s\n", self.radioFreq, UTILS.GetModulationName(self.radioModu), tostring(self.radioOn)) text=text..string.format("FSM state = %s\n", self:GetState()) text=text..string.format("Is alive = %s\n", tostring(self.group:IsAlive())) text=text..string.format("LateActivate = %s\n", tostring(self:IsLateActivated())) @@ -4597,44 +4628,18 @@ function FLIGHTGROUP:IsLandingAirbase(wp) end ---- Check if this group is "late activated" and needs to be "activated" to appear in the mission. +--- Check if this group is currently "late activated" and needs to be "activated" to appear in the mission. -- @param #FLIGHTGROUP self -- @return #boolean Hot start? function FLIGHTGROUP:IsLateActivated() - - local template=_DATABASE:GetGroupTemplate(self.groupname) - - if template then - - if template.lateActivation==true then - return true - else - return false - end - - end - - return nil + return self.isLateActivated end ---- Check if this group is "uncontrolled" and needs to be "started" to begin its route. +--- Check if this group is currently "uncontrolled" and needs to be "started" to begin its route. -- @param #FLIGHTGROUP self -- @return #boolean Hot start? function FLIGHTGROUP:IsUncontrolled() - - local template=_DATABASE:GetGroupTemplate(self.groupname) - - if template then - - if template.uncontrolled==true then - return true - else - return false - end - - end - - return nil + return self.isUncontrolled end --- Check if task description is unique. @@ -4808,7 +4813,7 @@ function FLIGHTGROUP:InitWaypoints(waypoints) self.homebase=self:GetHomebaseFromWaypoints() self.destbase=self:GetDestinationFromWaypoints() - -- Remove the landing waypoint. We use RTB for that. + -- Remove the landing waypoint. We use RTB for that. It makes adding new waypoints easier as we do not have to check if the last waypoint is the landing waypoint. if self.destbase then table.remove(self.waypoints, #self.waypoints) else @@ -4827,8 +4832,8 @@ function FLIGHTGROUP:InitWaypoints(waypoints) end -- Update route (when airborne). - self:_CheckFlightDone(1) - --self:__UpdateRoute(-1) + --self:_CheckFlightDone(1) + self:__UpdateRoute(-1) end return self diff --git a/Moose Development/Moose/Ops/Intelligence.lua b/Moose Development/Moose/Ops/Intelligence.lua index 3a3d4b5d2..2b0591d0d 100644 --- a/Moose Development/Moose/Ops/Intelligence.lua +++ b/Moose Development/Moose/Ops/Intelligence.lua @@ -27,7 +27,7 @@ -- @field #number dTforget Time interval in seconds before a known contact which is not detected any more is forgotten. -- @extends Core.Fsm#FSM ---- Be surprised! +--- Top Secret! -- -- === -- @@ -172,7 +172,6 @@ function INTEL:New(DetectionSet, Coalition) end self.Debug=true - return self end diff --git a/Moose Development/Moose/Ops/Squadron.lua b/Moose Development/Moose/Ops/Squadron.lua index d034a1f33..bf6868fcd 100644 --- a/Moose Development/Moose/Ops/Squadron.lua +++ b/Moose Development/Moose/Ops/Squadron.lua @@ -48,7 +48,7 @@ -- -- === -- --- ![Banner Image](..\Presentations\CarrierAirWing\SQUADRON_Main.jpg) +-- ![Banner Image](..\Presentations\Squadron\SQUADRON_Main.jpg) -- -- # The SQUADRON Concept -- diff --git a/Moose Development/Moose/Ops/WingCommander.lua b/Moose Development/Moose/Ops/WingCommander.lua index 877dc36fa..0cee6f8ec 100644 --- a/Moose Development/Moose/Ops/WingCommander.lua +++ b/Moose Development/Moose/Ops/WingCommander.lua @@ -28,7 +28,7 @@ -- -- === -- --- ![Banner Image](..\Presentations\CarrierAirWing\WINGCOMMANDER_Main.jpg) +-- ![Banner Image](..\Presentations\WingCommander\WINGCOMMANDER_Main.jpg) -- -- # The WINGCOMMANDER Concept -- diff --git a/Moose Development/Moose/Utilities/Enums.lua b/Moose Development/Moose/Utilities/Enums.lua index f47e66b94..c3a459dd2 100644 --- a/Moose Development/Moose/Utilities/Enums.lua +++ b/Moose Development/Moose/Utilities/Enums.lua @@ -160,4 +160,58 @@ ENUMS.MissionTask={ RUNWAYATTACK="Runway Attack", SEAD="SEAD", TRANSPORT="Transport", -} \ No newline at end of file +} + +--- Formations (new). See the [Formations](https://wiki.hoggitworld.com/view/DCS_enum_formation) on hoggit wiki. +-- @type ENUMS.Formation +ENUMS.Formation={} +ENUMS.Formation.FixedWing={} +ENUMS.Formation.FixedWing.LineAbreast={} +ENUMS.Formation.FixedWing.LineAbreast.Close = 65537 +ENUMS.Formation.FixedWing.LineAbreast.Open = 65538 +ENUMS.Formation.FixedWing.LineAbreast.Group = 65539 +ENUMS.Formation.FixedWing.Trail={} +ENUMS.Formation.FixedWing.Trail.Close = 131073 +ENUMS.Formation.FixedWing.Trail.Open = 131074 +ENUMS.Formation.FixedWing.Trail.Group = 131075 +ENUMS.Formation.RotaryWing={} +ENUMS.Formation.RotaryWing.Column={} +ENUMS.Formation.RotaryWing.Column.D70=720896 +ENUMS.Formation.RotaryWing.Wedge={} +ENUMS.Formation.RotaryWing.Wedge.D70=8 +ENUMS.Formation.RotaryWing.FrontRight={} +ENUMS.Formation.RotaryWing.FrontRight.D300=655361 +ENUMS.Formation.RotaryWing.FrontRight.D600=655362 +ENUMS.Formation.RotaryWing.FrontLeft={} +ENUMS.Formation.RotaryWing.FrontLeft.D300=655617 +ENUMS.Formation.RotaryWing.FrontLeft.D600=655618 +ENUMS.Formation.RotaryWing.EchelonRight={} +ENUMS.Formation.RotaryWing.EchelonRight.D70 =589825 +ENUMS.Formation.RotaryWing.EchelonRight.D300=589826 +ENUMS.Formation.RotaryWing.EchelonRight.D600=589827 +ENUMS.Formation.RotaryWing.EchelonLeft={} +ENUMS.Formation.RotaryWing.EchelonLeft.D70 =590081 +ENUMS.Formation.RotaryWing.EchelonLeft.D300=590082 +ENUMS.Formation.RotaryWing.EchelonLeft.D600=590083 + +--- Formations (old). The old format is a simplified version of the new formation enums, which allow more sophisticated settings. +-- See the [Formations](https://wiki.hoggitworld.com/view/DCS_enum_formation) on hoggit wiki. +-- @type ENUMS.FormationOld +ENUMS.FormationOld={} +ENUMS.FormationOld.FixedWing={} +ENUMS.FormationOld.FixedWing.LineAbreast=1 +ENUMS.FormationOld.FixedWing.Trail=2 +ENUMS.FormationOld.FixedWing.Wedge=3 +ENUMS.FormationOld.FixedWing.EchelonRight=4 +ENUMS.FormationOld.FixedWing.EchelonLeft=5 +ENUMS.FormationOld.FixedWing.FingerFour=6 +ENUMS.FormationOld.FixedWing.SpreadFour=7 +ENUMS.FormationOld.FixedWing.BomberElement=12 +ENUMS.FormationOld.FixedWing.BomberElementHeight=13 +ENUMS.FormationOld.FixedWing.FighterVic=14 +ENUMS.FormationOld={} +ENUMS.FormationOld.RotaryWing={} +ENUMS.FormationOld.RotaryWing.Wedge=8 +ENUMS.FormationOld.RotaryWing.Echelon=9 +ENUMS.FormationOld.RotaryWing.Front=10 +ENUMS.FormationOld.RotaryWing.Column=11 \ No newline at end of file diff --git a/Moose Development/Moose/Utilities/Utils.lua b/Moose Development/Moose/Utilities/Utils.lua index 2980550b9..a1dafea6c 100644 --- a/Moose Development/Moose/Utilities/Utils.lua +++ b/Moose Development/Moose/Utilities/Utils.lua @@ -1,5 +1,4 @@ ---- This module contains derived utilities taken from the MIST framework, --- which are excellent tools to be reused in an OO environment!. +--- This module contains derived utilities taken from the MIST framework, which are excellent tools to be reused in an OO environment. -- -- ### Authors: -- @@ -116,6 +115,7 @@ CALLSIGN={ --- Utilities static class. -- @type UTILS +-- @field #number _MarkID Marker index counter. Running number when marker is added. UTILS = { _MarkID = 1 } @@ -183,7 +183,9 @@ UTILS.IsInstanceOf = function( object, className ) end ---from http://lua-users.org/wiki/CopyTable +--- Deep copy a table. See http://lua-users.org/wiki/CopyTable +-- @param #table object The input table. +-- @return #table Copy of the input table. UTILS.DeepCopy = function(object) local lookup_table = {} local function _copy(object) @@ -204,7 +206,8 @@ UTILS.DeepCopy = function(object) end --- porting in Slmod's serialize_slmod2 +--- Porting in Slmod's serialize_slmod2. +-- @param #table tbl Input table. UTILS.OneLineSerialize = function( tbl ) -- serialization of a table all on a single line, no comments, made to replace old get_table_string function lookup_table = {} @@ -340,18 +343,30 @@ UTILS.MiphToMps = function( miph ) return miph * 0.44704 end +--- Convert meters per second to miles per hour. +-- @param #number mps Speed in m/s. +-- @return #number Speed in miles per hour. UTILS.MpsToMiph = function( mps ) return mps / 0.44704 end +--- Convert meters per second to knots. +-- @param #number knots Speed in m/s. +-- @return #number Speed in knots. UTILS.MpsToKnots = function( mps ) return mps * 1.94384 --3600 / 1852 end +--- Convert knots to meters per second. +-- @param #number knots Speed in knots. +-- @return #number Speed in m/s. UTILS.KnotsToMps = function( knots ) return knots / 1.94384 --* 1852 / 3600 end +--- Convert temperature from Celsius to Farenheit. +-- @param #number Celcius Temperature in degrees Celsius. +-- @return #number Temperature in degrees Farenheit. UTILS.CelciusToFarenheit = function( Celcius ) return Celcius * 9/5 + 32 end @@ -982,7 +997,7 @@ end --- Returns the DCS map/theatre as optained by env.mission.theatre --- @return #string DCS map name . +-- @return #string DCS map name. function UTILS.GetDCSMap() return env.mission.theatre end @@ -1100,7 +1115,7 @@ end --- Get the callsign name from its enumerator value -- @param #number Callsign The enumerator callsign. --- @return #string The callsign name. +-- @return #string The callsign name or "Ghostrider". function UTILS.GetCallsignName(Callsign) for name, value in pairs(CALLSIGN.Aircraft) do @@ -1127,7 +1142,5 @@ function UTILS.GetCallsignName(Callsign) end end - return "Unknown Calsing" + return "Ghostrider" end - --- Just a test to see commits in new environment for Wingthor \ No newline at end of file diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 8661f648a..e1be30eb4 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -751,7 +751,7 @@ end function CONTROLLABLE:CommandSetCallsign(CallName, CallNumber, Delay) -- Command to set the callsign. - local CommandSetCallsign={id='SetCallsign', params={callname=CallName, callnumber=CallNumber or 1}} + local CommandSetCallsign={id='SetCallsign', params={callname=CallName, number=CallNumber or 1}} if Delay and Delay>0 then SCHEDULER:New(nil, self.CommandSetCallsign, {self, CallName, CallNumber}, Delay)