From a97d7abc243ca4029a71c64580cbe2ed9752db0b Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 30 Aug 2020 17:03:16 +0200 Subject: [PATCH] Range Ops --- Moose Development/Moose/Functional/Range.lua | 14 +++++++++++--- Moose Development/Moose/Functional/Warehouse.lua | 1 + Moose Development/Moose/Ops/OpsGroup.lua | 14 +++++++++----- Moose Development/Moose/Ops/Target.lua | 9 +++++++-- Moose Development/Moose/Wrapper/Positionable.lua | 8 ++++++-- 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Moose Development/Moose/Functional/Range.lua b/Moose Development/Moose/Functional/Range.lua index 6b292f2fd..6810783c8 100644 --- a/Moose Development/Moose/Functional/Range.lua +++ b/Moose Development/Moose/Functional/Range.lua @@ -93,6 +93,8 @@ -- @field Core.RadioQueue#RADIOQUEUE instructor Instructor radio queue. -- @field #number rangecontrolfreq Frequency on which the range control transmitts. -- @field Core.RadioQueue#RADIOQUEUE rangecontrol Range control radio queue. +-- @field #string rangecontrolrelayname Name of relay unit. +-- @field #string instructorrelayname Name of relay unit. -- @field #string soundpath Path inside miz file where the sound files are located. Default is "Range Soundfiles/". -- @extends Core.Fsm#FSM @@ -516,7 +518,7 @@ RANGE.MenuF10Root=nil --- Range script version. -- @field #string version -RANGE.version="2.2.2" +RANGE.version="2.2.3" --TODO list: --TODO: Verbosity level for messages. @@ -770,6 +772,7 @@ function RANGE:onafterStart() -- Set location where the messages are transmitted from. self.rangecontrol:SetSenderCoordinate(self.location) + self.rangecontrol:SetSenderUnitName(self.rangecontrolrelayname) -- Start range control radio queue. self.rangecontrol:Start(1, 0.1) @@ -794,6 +797,7 @@ function RANGE:onafterStart() -- Set location where the messages are transmitted from. self.instructor:SetSenderCoordinate(self.location) + self.instructor:SetSenderUnitName(self.instructorrelayname) -- Start instructor radio queue. self.instructor:Start(1, 0.1) @@ -1067,18 +1071,22 @@ end --- Enable range control and set frequency. -- @param #RANGE self -- @param #number frequency Frequency in MHz. Default 256 MHz. +-- @param #string relayunitname Name of the unit used for transmission. -- @return #RANGE self -function RANGE:SetRangeControl(frequency) +function RANGE:SetRangeControl(frequency, relayunitname) self.rangecontrolfreq=frequency or 256 + self.rangecontrolrelayname=relayunitname return self end --- Enable instructor radio and set frequency. -- @param #RANGE self -- @param #number frequency Frequency in MHz. Default 305 MHz. +-- @param #string relayunitname Name of the unit used for transmission. -- @return #RANGE self -function RANGE:SetInstructorRadio(frequency) +function RANGE:SetInstructorRadio(frequency, relayunitname) self.instructorfreq=frequency or 305 + self.instructorrelayname=relayunitname return self end diff --git a/Moose Development/Moose/Functional/Warehouse.lua b/Moose Development/Moose/Functional/Warehouse.lua index eb851a28e..605fdd94a 100644 --- a/Moose Development/Moose/Functional/Warehouse.lua +++ b/Moose Development/Moose/Functional/Warehouse.lua @@ -1552,6 +1552,7 @@ WAREHOUSE = { ClassName = "WAREHOUSE", Debug = false, + verbosity = 0, lid = nil, Report = true, warehouse = nil, diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index 91ef5f94f..1976f178b 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -487,8 +487,9 @@ end -- @return DCS#Vec3 Vector with x,y,z components. function OPSGROUP:GetVec3() if self:IsAlive() then - return self.group:GetVec3() - end + local vec3=self.group:GetVec3() + return vec3 + end return nil end @@ -520,7 +521,8 @@ end -- @return #number Velocity in m/s. function OPSGROUP:GetVelocity() if self:IsAlive()~=nil then - return self.group:GetVelocityMPS() + local vel=self.group:GetVelocityMPS() + return rel else self:E(self.lid.."WARNING: Group is not alive. Cannot get velocity!") end @@ -532,7 +534,8 @@ end -- @return #number Current heading of the group in degrees. function OPSGROUP:GetHeading() if self:IsAlive()~=nil then - return self.group:GetHeading() + local heading=self.group:GetHeading() + return heading else self:E(self.lid.."WARNING: Group is not alive. Cannot get heading!") end @@ -618,7 +621,8 @@ end function OPSGROUP:IsAlive() if self.group then - return self.group:IsAlive() + local alive=self.group:IsAlive() + return alive end return nil diff --git a/Moose Development/Moose/Ops/Target.lua b/Moose Development/Moose/Ops/Target.lua index a4e44a61f..0e8909566 100644 --- a/Moose Development/Moose/Ops/Target.lua +++ b/Moose Development/Moose/Ops/Target.lua @@ -593,8 +593,13 @@ function TARGET:GetTargetLife(Target) elseif Target.Type==TARGET.ObjectType.UNIT then - if Target.Object and Target.Object:IsAlive() then - return Target.Object:GetLife() + local unit=Target.Object --Wrapper.Unit#UNIT + + if unit and unit:IsAlive() then + + -- Note! According to the profiler, there is a big difference if we "return unit:GetLife()" or "local life=unit:GetLife(); return life"! + local life=unit:GetLife() + return life else return 0 end diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index 5097935bb..53db3504b 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -375,8 +375,10 @@ function POSITIONABLE:GetCoordinate() -- Get the current position. local PositionableVec3 = self:GetVec3() + local coord=COORDINATE:NewFromVec3(PositionableVec3) + -- Return a new coordiante object. - return COORDINATE:NewFromVec3(PositionableVec3) + return coord end @@ -420,8 +422,10 @@ function POSITIONABLE:GetOffsetCoordinate(x,y,z) -- Translate offset vector from map origin to the unit: v=u+a. local v={x=a.x+u.x, y=a.y+u.y, z=a.z+u.z} + local coord=COORDINATE:NewFromVec3(v) + -- Return the offset coordinate. - return COORDINATE:NewFromVec3(v) + return coord end --- Returns a random @{DCS#Vec3} vector within a range, indicating the point in 3D of the POSITIONABLE within the mission.