mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Fixed friendlies nearby calculation
* Added DETECTION_BASE:FilterFriendliesCategory() method, which allows to filter friendlies based on the category of the units found. This method was required to be added to avoid counting airborne units as friendlies in A2G missions.
This commit is contained in:
@@ -1239,7 +1239,7 @@ do -- AI_A2A_DISPATCHER
|
||||
|
||||
|
||||
--- Set the default CAP limit for squadrons, which will be used to determine how many CAP can be airborne at the same time for the squadron.
|
||||
-- The default CAP time interval is 1 CAP.
|
||||
-- The default CAP limit is 1 CAP, which means one CAP group being spawned.
|
||||
-- @param #AI_A2A_DISPATCHER self
|
||||
-- @param #number CapLimit The maximum amount of CAP that can be airborne at the same time for the squadron.
|
||||
-- @return #AI_A2A_DISPATCHER
|
||||
@@ -1497,7 +1497,7 @@ do -- AI_A2A_DISPATCHER
|
||||
end
|
||||
|
||||
|
||||
---
|
||||
--- Set a CAP for a Squadron.
|
||||
-- @param #AI_A2A_DISPATCHER self
|
||||
-- @param #string SquadronName The squadron name.
|
||||
-- @param Core.Zone#ZONE_BASE Zone The @{Zone} object derived from @{Zone#ZONE_BASE} that defines the zone wherein the CAP will be executed.
|
||||
@@ -1549,9 +1549,13 @@ do -- AI_A2A_DISPATCHER
|
||||
return self
|
||||
end
|
||||
|
||||
---
|
||||
--- Set the squadron CAP parameters.
|
||||
-- @param #AI_A2A_DISPATCHER self
|
||||
-- @param #string SquadronName The squadron name.
|
||||
-- @param #number CapLimit (optional) The maximum amount of CAP groups to be spawned. Note that a CAP is a group, so can consist out of 1 to 4 airplanes. The default is 1 CAP group.
|
||||
-- @param #number LowInterval (optional) The minimum time boundary in seconds when a new CAP will be spawned. The default is 180 seconds.
|
||||
-- @param #number HighInterval (optional) The maximum time boundary in seconds when a new CAP will be spawned. The default is 600 seconds.
|
||||
-- @param #number Probability Is not in use, you can skip this parameter.
|
||||
-- @return #AI_A2A_DISPATCHER
|
||||
-- @usage
|
||||
--
|
||||
@@ -1577,10 +1581,10 @@ do -- AI_A2A_DISPATCHER
|
||||
|
||||
local Cap = self.DefenderSquadrons[SquadronName].Cap
|
||||
if Cap then
|
||||
Cap.LowInterval = LowInterval or 300
|
||||
Cap.LowInterval = LowInterval or 180
|
||||
Cap.HighInterval = HighInterval or 600
|
||||
Cap.Probability = Probability or 1
|
||||
Cap.CapLimit = CapLimit
|
||||
Cap.CapLimit = CapLimit or 1
|
||||
Cap.Scheduler = Cap.Scheduler or SCHEDULER:New( self )
|
||||
local Scheduler = Cap.Scheduler -- Core.Scheduler#SCHEDULER
|
||||
local ScheduleID = Cap.ScheduleID
|
||||
|
||||
@@ -1140,7 +1140,7 @@ do -- DETECTION_BASE
|
||||
|
||||
end
|
||||
|
||||
do -- Threat
|
||||
do -- NearBy calculations
|
||||
|
||||
--- Returns if there are friendlies nearby the FAC units ...
|
||||
-- @param #DETECTION_BASE self
|
||||
@@ -1157,6 +1157,15 @@ do -- DETECTION_BASE
|
||||
|
||||
return DetectedItem.FriendliesNearBy
|
||||
end
|
||||
|
||||
--- Filters friendly units by unit category.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param FriendliesCategory
|
||||
-- @return #DETECTION_BASE
|
||||
function DETECTION_BASE:FilterFriendliesCategory( FriendliesCategory )
|
||||
self.FriendliesCategory = FriendliesCategory
|
||||
return self
|
||||
end
|
||||
|
||||
--- Returns if there are friendlies nearby the intercept ...
|
||||
-- @param #DETECTION_BASE self
|
||||
@@ -1245,15 +1254,18 @@ do -- DETECTION_BASE
|
||||
--self:F( { "Friendlies search:", FoundUnitName, FoundUnitCoalition, EnemyUnitName, EnemyCoalition, FoundUnitInReportSetGroup } )
|
||||
|
||||
if FoundUnitCoalition ~= EnemyCoalition and FoundUnitInReportSetGroup == false then
|
||||
DetectedItem.FriendliesNearBy = DetectedItem.FriendliesNearBy or {}
|
||||
local FriendlyUnit = UNIT:Find( FoundDCSUnit )
|
||||
local FriendlyUnitName = FriendlyUnit:GetName()
|
||||
|
||||
DetectedItem.FriendliesNearBy[FriendlyUnitName] = FriendlyUnit
|
||||
local FriendlyUnitCategory = FriendlyUnit:GetDesc().category
|
||||
self:T( { FriendlyUnitCategory = FriendlyUnitCategory, FriendliesCategory = self.FriendliesCategory } )
|
||||
|
||||
local Distance = DetectedUnitCoord:Get2DDistance( FriendlyUnit:GetCoordinate() )
|
||||
DetectedItem.FriendliesDistance = DetectedItem.FriendliesDistance or {}
|
||||
DetectedItem.FriendliesDistance[Distance] = FriendlyUnit
|
||||
if ( not self.FriendliesCategory ) or ( self.FriendliesCategory and ( self.FriendliesCategory == FriendlyUnitCategory ) ) then
|
||||
DetectedItem.FriendliesNearBy = DetectedItem.FriendliesNearBy or {}
|
||||
DetectedItem.FriendliesNearBy[FriendlyUnitName] = FriendlyUnit
|
||||
local Distance = DetectedUnitCoord:Get2DDistance( FriendlyUnit:GetCoordinate() )
|
||||
DetectedItem.FriendliesDistance = DetectedItem.FriendliesDistance or {}
|
||||
DetectedItem.FriendliesDistance[Distance] = FriendlyUnit
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -1269,23 +1281,28 @@ do -- DETECTION_BASE
|
||||
--- @param Wrapper.Unit#UNIT PlayerUnit
|
||||
function( PlayerUnitName )
|
||||
local PlayerUnit = UNIT:FindByName( PlayerUnitName )
|
||||
|
||||
local PlayerUnitCategory = PlayerUnit:GetDesc().category
|
||||
|
||||
if PlayerUnit and PlayerUnit:IsInZone(DetectionZone) then
|
||||
|
||||
DetectedItem.FriendliesNearBy = DetectedItem.FriendliesNearBy or {}
|
||||
local PlayerUnitName = PlayerUnit:GetName()
|
||||
|
||||
DetectedItem.PlayersNearBy = DetectedItem.PlayersNearBy or {}
|
||||
DetectedItem.PlayersNearBy[PlayerUnitName] = PlayerUnit
|
||||
|
||||
DetectedItem.FriendliesNearBy = DetectedItem.FriendliesNearBy or {}
|
||||
DetectedItem.FriendliesNearBy[PlayerUnitName] = PlayerUnit
|
||||
|
||||
local CenterCoord = DetectedUnit:GetCoordinate()
|
||||
if ( not self.FriendliesCategory ) or ( self.FriendliesCategory and ( self.FriendliesCategory == PlayerUnitCategory ) ) then
|
||||
|
||||
local Distance = CenterCoord:Get2DDistance( PlayerUnit:GetCoordinate() )
|
||||
DetectedItem.FriendliesDistance = DetectedItem.FriendliesDistance or {}
|
||||
DetectedItem.FriendliesDistance[Distance] = PlayerUnit
|
||||
DetectedItem.FriendliesNearBy = DetectedItem.FriendliesNearBy or {}
|
||||
local PlayerUnitName = PlayerUnit:GetName()
|
||||
|
||||
DetectedItem.PlayersNearBy = DetectedItem.PlayersNearBy or {}
|
||||
DetectedItem.PlayersNearBy[PlayerUnitName] = PlayerUnit
|
||||
|
||||
DetectedItem.FriendliesNearBy = DetectedItem.FriendliesNearBy or {}
|
||||
DetectedItem.FriendliesNearBy[PlayerUnitName] = PlayerUnit
|
||||
|
||||
local CenterCoord = DetectedUnit:GetCoordinate()
|
||||
|
||||
local Distance = CenterCoord:Get2DDistance( PlayerUnit:GetCoordinate() )
|
||||
DetectedItem.FriendliesDistance = DetectedItem.FriendliesDistance or {}
|
||||
DetectedItem.FriendliesDistance[Distance] = PlayerUnit
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
@@ -59,6 +59,7 @@ do -- TASK_A2G_DISPATCHER
|
||||
self.Mission = Mission
|
||||
|
||||
self.Detection:FilterCategories( Unit.Category.GROUND_UNIT, Unit.Category.SHIP )
|
||||
self.Detection:FilterFriendliesCategory( Unit.Category.GROUND_UNIT )
|
||||
|
||||
self:AddTransition( "Started", "Assign", "Started" )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user