This commit is contained in:
Applevangelist 2025-02-21 10:39:38 +01:00
parent 093c3fe7c9
commit 367d1c6715
4 changed files with 46 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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