From 093526f4ffed53c944a43be7fde725da25d6cf40 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Sun, 14 Dec 2025 14:35:50 +0100 Subject: [PATCH] #ZONE - Added optional coalition filter on GetScannedUnitSet() and GetScannedGroupSet() --- Moose Development/Moose/Core/Zone.lua | 30 ++++++++++++++++++++------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/Moose Development/Moose/Core/Zone.lua b/Moose Development/Moose/Core/Zone.lua index 2c8459c9d..e9b618cf2 100644 --- a/Moose Development/Moose/Core/Zone.lua +++ b/Moose Development/Moose/Core/Zone.lua @@ -1158,7 +1158,7 @@ end -- myzone:Scan({Object.Category.UNIT},{Unit.Category.GROUND_UNIT}) -- local IsAttacked = myzone:IsSomeInZoneOfCoalition( self.Coalition ) function ZONE_RADIUS:Scan( ObjectCategories, UnitCategories ) - + self.ScanData = {} self.ScanData.Coalitions = {} self.ScanData.Scenery = {} @@ -1168,7 +1168,7 @@ function ZONE_RADIUS:Scan( ObjectCategories, UnitCategories ) local ZoneCoord = self:GetCoordinate():SetAlt() local ZoneRadius = self:GetRadius() - --self:F({ZoneCoord = ZoneCoord, ZoneRadius = ZoneRadius, ZoneCoordLL = ZoneCoord:ToStringLLDMS()}) + --self:I({x = ZoneCoord.x, y=ZoneCoord.y, z=ZoneCoord.z, ZoneRadius = ZoneRadius}) local SphereSearch = { id = world.VolumeType.SPHERE, @@ -1180,6 +1180,7 @@ function ZONE_RADIUS:Scan( ObjectCategories, UnitCategories ) local function EvaluateZone( ZoneObject ) --if ZoneObject:isExist() then --FF: isExist always returns false for SCENERY objects since DCS 2.2 and still in DCS 2.5 + if ZoneObject and self:IsVec3InZone(ZoneObject:getPoint()) then -- Get object category. @@ -1265,8 +1266,9 @@ end --- Get a set of scanned units. -- @param #ZONE_RADIUS self +-- @param #number Coalition (optional) Filter for this coalition only. -- @return Core.Set#SET_UNIT Set of units and statics inside the zone. -function ZONE_RADIUS:GetScannedSetUnit() +function ZONE_RADIUS:GetScannedSetUnit(Coalition) local SetUnit = SET_UNIT:New() @@ -1275,7 +1277,12 @@ function ZONE_RADIUS:GetScannedSetUnit() local UnitObject = UnitObject -- DCS#Unit if UnitObject:isExist() then local FoundUnit = UNIT:FindByName( UnitObject:getName() ) - if FoundUnit then + local FoundCoalition = FoundUnit and FoundUnit:GetCoalition() or nil + local includeoncoalition = true + if Coalition ~= nil and FoundCoalition==Coalition then includeoncoalition = true else includeoncoalition = false end + if Coalition == nil then includeoncoalition = true end + --self:I(string.format("Unit name %s coalition %s filter coalition = %s include = %s",FoundUnit:GetName(),tostring(FoundCoalition),tostring(Coalition),tostring(includeoncoalition))) + if FoundUnit and includeoncoalition then SetUnit:AddUnit( FoundUnit ) else local FoundStatic = STATIC:FindByName( UnitObject:getName(), false ) @@ -1292,11 +1299,13 @@ end --- Get a set of scanned groups. -- @param #ZONE_RADIUS self +-- @param #number Coalition (optional) Filter for this coalition only. -- @return Core.Set#SET_GROUP Set of groups. -function ZONE_RADIUS:GetScannedSetGroup() +function ZONE_RADIUS:GetScannedSetGroup(Coalition) self.ScanSetGroup=self.ScanSetGroup or SET_GROUP:New() --Core.Set#SET_GROUP - + + self.ScanSetGroup:Clear(false) self.ScanSetGroup.Set={} if self.ScanData then @@ -1305,7 +1314,12 @@ function ZONE_RADIUS:GetScannedSetGroup() if UnitObject:isExist() then local FoundUnit=UNIT:FindByName(UnitObject:getName()) - if FoundUnit then + local FoundCoalition = FoundUnit and FoundUnit:GetCoalition() or nil + local includeoncoalition = true + if Coalition ~= nil and FoundCoalition==Coalition then includeoncoalition = true else includeoncoalition = false end + if Coalition == nil then includeoncoalition = true end + --self:I(string.format("Unit name %s coalition %s filter coalition = %s include = %s",FoundUnit:GetName(),tostring(FoundCoalition),tostring(Coalition),tostring(includeoncoalition))) + if FoundUnit and includeoncoalition then local group=FoundUnit:GetGroup() self.ScanSetGroup:AddGroup(group) end @@ -3380,7 +3394,7 @@ function ZONE_POLYGON:Scan( ObjectCategories, UnitCategories ) self.ScanData.Scenery[SceneryType] = self.ScanData.Scenery[SceneryType] or {} self.ScanData.Scenery[SceneryType][SceneryName] = SCENERY:Register( SceneryName, ZoneObject ) table.insert(self.ScanData.SceneryTable,self.ScanData.Scenery[SceneryType][SceneryName]) - --self:T( { SCENERY = self.ScanData.Scenery[SceneryType][SceneryName] } ) + --self:I( { SCENERY = self.ScanData.Scenery[SceneryType][SceneryName] } ) end end