From e83ea8124e380e027aa37989c8d2134996634f8b Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Sat, 7 May 2022 11:54:48 +0200 Subject: [PATCH 1/3] GROUP - change to GetUnits(n) to make it more robust, now returns first alive unit,actually. Similar changes to GetHeading() --- Moose Development/Moose/Wrapper/Group.lua | 27 ++++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index d8b23a871..076d6e623 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -701,15 +701,26 @@ function GROUP:GetUnit( UnitNumber ) local DCSGroup = self:GetDCSObject() if DCSGroup then - - local DCSUnit = DCSGroup:getUnit( UnitNumber ) - local UnitFound = UNIT:Find(DCSUnit) + local UnitFound = nil + -- 2.7.1 dead event bug, return the first alive unit instead + local units = DCSGroup:getUnits() or {} + + for _,_unit in pairs(units) do + + local UnitFound = UNIT:Find(_unit) + + if UnitFound and UnitFound:IsAlive() then + + return UnitFound + + end + end - return UnitFound end return nil + end --- Returns the DCS Unit with number UnitNumber. @@ -1105,17 +1116,17 @@ function GROUP:GetHeading() local GroupSize = self:GetSize() local HeadingAccumulator = 0 - local n=0 + local Units = self:GetUnits() + if GroupSize then - for i = 1, GroupSize do - local unit=self:GetUnit(i) + for _,unit in pairs(Units) do if unit and unit:IsAlive() then HeadingAccumulator = HeadingAccumulator + unit:GetHeading() n=n+1 end end - return math.floor(HeadingAccumulator / n) + return math.floor(HeadingAccumulator / n) end BASE:E( { "Cannot GetHeading", Group = self, Alive = self:IsAlive() } ) From 6793228fbef744c51a37d6b869a9b1558ef41d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fassot?= Date: Sat, 7 May 2022 15:32:48 +0200 Subject: [PATCH 2/3] Add an option to display arrows if clusters are moving (#1728) --- Moose Development/Moose/Ops/Intelligence.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Ops/Intelligence.lua b/Moose Development/Moose/Ops/Intelligence.lua index c34e31836..28f91150d 100644 --- a/Moose Development/Moose/Ops/Intelligence.lua +++ b/Moose Development/Moose/Ops/Intelligence.lua @@ -98,6 +98,7 @@ INTEL = { clusterradius = 15000, clusteranalysis = true, clustermarkers = false, + clusterarrows = false, prediction = 300, detectStatics = false, } @@ -528,10 +529,12 @@ end -- @param #INTEL self -- @param #boolean Switch If true, enable cluster analysis. -- @param #boolean Markers If true, place markers on F10 map. +-- @param #boolean Arrows If true, draws arrows on F10 map. -- @return #INTEL self -function INTEL:SetClusterAnalysis(Switch, Markers) +function INTEL:SetClusterAnalysis(Switch, Markers, Arrows) self.clusteranalysis=Switch self.clustermarkers=Markers + self.clusterarrows=Arrows return self end @@ -1760,7 +1763,7 @@ function INTEL:CalcClusterFuturePosition(cluster, seconds) local futureposition=COORDINATE:NewFromVec3(Vec3) -- Create an arrow pointing in the direction of the movement. - if self.clustermarkers and self.verbose>1 then + if self.clustermarkers and self.clusterarrows then if cluster.markerID then COORDINATE:RemoveMark(cluster.markerID) end From e74aa160af9bf0681761b4bbee9e60093ac69cb9 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Sat, 7 May 2022 19:42:10 +0200 Subject: [PATCH 3/3] Group - small change --- Moose Development/Moose/Wrapper/Group.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index 076d6e623..73a306509 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -710,7 +710,7 @@ function GROUP:GetUnit( UnitNumber ) local UnitFound = UNIT:Find(_unit) - if UnitFound and UnitFound:IsAlive() then + if UnitFound then return UnitFound