From 367d1c67158586f2cea40391f883e78aaa2f8e47 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Fri, 21 Feb 2025 10:39:38 +0100 Subject: [PATCH] xx --- Moose Development/Moose/Core/Set.lua | 15 ++++++++++++++ .../Moose/Functional/Autolase.lua | 18 +++++++++-------- Moose Development/Moose/Ops/OpsZone.lua | 2 ++ Moose Development/Moose/Ops/Target.lua | 20 ++++++++++++++++++- 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index a2da90730..56ec9ecab 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -531,6 +531,21 @@ do -- SET_BASE return self.SomeIteratorLimit or self:Count() end + + --- Get max threat level of all objects in the SET. + -- @param #SET_BASE self + -- @return #number Max threat level found. + function SET_BASE:GetThreatLevelMax() + local ThreatMax = 0 + for _,_unit in pairs(self.Set or {}) do + local unit = _unit -- Wrapper.Unit#UNIT + local threat = unit.GetThreatLevel and unit:GetThreatLevel() or 0 + if threat > ThreatMax then + ThreatMax = threat + end + end + return ThreatMax + end --- Filters for the defined collection. -- @param #SET_BASE self diff --git a/Moose Development/Moose/Functional/Autolase.lua b/Moose Development/Moose/Functional/Autolase.lua index 7fb980ba8..88cb6c9e6 100644 --- a/Moose Development/Moose/Functional/Autolase.lua +++ b/Moose Development/Moose/Functional/Autolase.lua @@ -994,10 +994,11 @@ function AUTOLASE:_Prescient() -- loop found units if hasunits then self:T(self.lid.."Checking possibly visible UNITs for Recce "..unit:GetName()) - for _,_target in pairs(Units) do -- _, Wrapper.Unit#UNIT - if _target:GetCoalition() ~= self.coalition then - if unit:IsLOS(_target) and (not _target:IsUnitDetected(unit))then - unit:KnowUnit(_target,true,true) + for _,_target in pairs(Units) do -- Wrapper.Unit#UNIT object here + local target = _target -- Wrapper.Unit#UNIT + if target and target:GetCoalition() ~= self.coalition then + if unit:IsLOS(target) and (not target:IsUnitDetected(unit))then + unit:KnowUnit(target,true,true) end end end @@ -1005,11 +1006,12 @@ function AUTOLASE:_Prescient() -- loop found statics if hasstatics then self:T(self.lid.."Checking possibly visible STATICs for Recce "..unit:GetName()) - for _,_static in pairs(Statics) do -- _, Wrapper.Unit#UNIT - if _static:GetCoalition() ~= self.coalition then - local IsLOS = position:IsLOS(_static:GetCoordinate()) + for _,_static in pairs(Statics) do -- DCS static object here + local static = STATIC:Find(_static) + if static and static:GetCoalition() ~= self.coalition then + local IsLOS = position:IsLOS(static:GetCoordinate()) if IsLOS then - unit:KnowUnit(_static,true,true) + unit:KnowUnit(static,true,true) end end end diff --git a/Moose Development/Moose/Ops/OpsZone.lua b/Moose Development/Moose/Ops/OpsZone.lua index 12c4b4608..bbcf4f97b 100644 --- a/Moose Development/Moose/Ops/OpsZone.lua +++ b/Moose Development/Moose/Ops/OpsZone.lua @@ -723,6 +723,7 @@ end -- @param #string From From state. -- @param #string Event Event. -- @param #string To To state. +-- @return #OPSZONE self function OPSZONE:onafterStart(From, Event, To) -- Info. @@ -739,6 +740,7 @@ function OPSZONE:onafterStart(From, Event, To) self:HandleEvent(EVENTS.BaseCaptured) end + return self end --- Stop OPSZONE FSM. diff --git a/Moose Development/Moose/Ops/Target.lua b/Moose Development/Moose/Ops/Target.lua index e0b750679..fcc108087 100644 --- a/Moose Development/Moose/Ops/Target.lua +++ b/Moose Development/Moose/Ops/Target.lua @@ -387,6 +387,8 @@ function TARGET:AddObject(Object) if Object:IsInstanceOf("OPSGROUP") then self:_AddObject(Object:GetGroup()) -- We add the MOOSE GROUP object not the OPSGROUP object. + --elseif Object:IsInstanceOf("OPSZONE") then + --self:_AddObject(Object:GetZone()) else self:_AddObject(Object) end @@ -1296,11 +1298,27 @@ function TARGET:GetTargetThreatLevelMax(Target) return 0 elseif Target.Type==TARGET.ObjectType.ZONE then + + local zone = Target.Object -- Core.Zone#ZONE_RADIUS + local foundunits = {} + if zone:IsInstanceOf("ZONE_RADIUS") or zone:IsInstanceOf("ZONE_POLYGON") then + zone:Scan({Object.Category.UNIT},{Unit.Category.GROUND_UNIT,Unit.Category.SHIP}) + foundunits = zone:GetScannedSetUnit() + else + foundunits = SET_UNIT:New():FilterZones({zone}):FilterOnce() + end + local ThreatMax = foundunits:GetThreatLevelMax() or 0 + return ThreatMax - return 0 + elseif Target.Type==TARGET.ObjectType.OPSZONE then + + local unitset = Target.Object:GetScannedUnitSet() -- Core.Set#SET_UNIT + local ThreatMax = unitset:GetThreatLevelMax() + return ThreatMax else self:E("ERROR: unknown target object type in GetTargetThreatLevel!") + return 0 end return self