Fixed overhead (again), and optimized defense radius logic.

This commit is contained in:
FlightControl 2018-11-11 08:43:20 +01:00
parent ed60c5dca4
commit 252950af73

View File

@ -450,7 +450,6 @@ do -- AI_A2G_DISPATCHER
self.DefenderPatrolIndex = 0 self.DefenderPatrolIndex = 0
self:SetDefenseDistance()
self:SetDefenseReactivityMedium() self:SetDefenseReactivityMedium()
self:__Start( 5 ) self:__Start( 5 )
@ -587,12 +586,6 @@ do -- AI_A2G_DISPATCHER
self.DefenseReactivity = 0.5 self.DefenseReactivity = 0.5
end end
--- @param #AI_A2G_DISPATCHER self
-- @param #number DefensiveDistance The distance in meters from where the evaluation of defense reactivity will be calculated.
function AI_A2G_DISPATCHER:SetDefenseDistance( DefensiveDistance )
self.DefenseDistance = DefensiveDistance or 60000
end
end end
--- Define the radius to engage any target by airborne friendlies, which are executing cap or returning from an defense mission. --- Define the radius to engage any target by airborne friendlies, which are executing cap or returning from an defense mission.
@ -679,6 +672,8 @@ do -- AI_A2G_DISPATCHER
self.DefenseRadius = DefenseRadius or 100000 self.DefenseRadius = DefenseRadius or 100000
self.Detection:SetAcceptRange( self.DefenseRadius )
return self return self
end end
@ -1123,20 +1118,27 @@ do -- AI_A2G_DISPATCHER
end end
--- Set the squadron Patrol parameters. --- Set the squadron patrol parameters for a specific task type.
-- Mission designers should not use this method, instead use the below methods. This method is used by the below methods.
--
-- - @{#AI_A2G_DISPATCHER:SetSquadronSeadPatrolInterval} for SEAD tasks.
-- - @{#AI_A2G_DISPATCHER:SetSquadronSeadPatrolInterval} for CAS tasks.
-- - @{#AI_A2G_DISPATCHER:SetSquadronSeadPatrolInterval} for BAI tasks.
--
-- @param #AI_A2G_DISPATCHER self -- @param #AI_A2G_DISPATCHER self
-- @param #string SquadronName The squadron name. -- @param #string SquadronName The squadron name.
-- @param #number PatrolLimit (optional) The maximum amount of Patrol groups to be spawned. Note that a Patrol is a group, so can consist out of 1 to 4 airplanes. The default is 1 Patrol group. -- @param #number PatrolLimit (optional) The maximum amount of Patrol groups to be spawned. Note that a Patrol is a group, so can consist out of 1 to 4 airplanes. The default is 1 Patrol group.
-- @param #number LowInterval (optional) The minimum time boundary in seconds when a new Patrol will be spawned. The default is 180 seconds. -- @param #number LowInterval (optional) The minimum time boundary in seconds when a new Patrol will be spawned. The default is 180 seconds.
-- @param #number HighInterval (optional) The maximum time boundary in seconds when a new Patrol will be spawned. The default is 600 seconds. -- @param #number HighInterval (optional) The maximum time boundary in seconds when a new Patrol will be spawned. The default is 600 seconds.
-- @param #number Probability Is not in use, you can skip this parameter. -- @param #number Probability Is not in use, you can skip this parameter.
-- @param #string DefenseTaskType Should contain "SEAD", "CAS" or "BAI".
-- @return #AI_A2G_DISPATCHER -- @return #AI_A2G_DISPATCHER
-- @usage -- @usage
-- --
-- -- Patrol Squadron execution. -- -- Patrol Squadron execution.
-- PatrolZoneEast = ZONE_POLYGON:New( "Patrol Zone East", GROUP:FindByName( "Patrol Zone East" ) ) -- PatrolZoneEast = ZONE_POLYGON:New( "Patrol Zone East", GROUP:FindByName( "Patrol Zone East" ) )
-- A2GDispatcher:SetSquadronSeadPatrol( "Mineralnye", PatrolZoneEast, 4000, 10000, 500, 600, 800, 900 ) -- A2GDispatcher:SetSquadronSeadPatrol( "Mineralnye", PatrolZoneEast, 4000, 10000, 500, 600, 800, 900 )
-- A2GDispatcher:SetSquadronPatrolInterval( "Mineralnye", 2, 30, 60, 1 ) -- A2GDispatcher:SetSquadronPatrolInterval( "Mineralnye", 2, 30, 60, 1, "SEAD" )
-- --
function AI_A2G_DISPATCHER:SetSquadronPatrolInterval( SquadronName, PatrolLimit, LowInterval, HighInterval, Probability, DefenseTaskType ) function AI_A2G_DISPATCHER:SetSquadronPatrolInterval( SquadronName, PatrolLimit, LowInterval, HighInterval, Probability, DefenseTaskType )
@ -1167,6 +1169,72 @@ do -- AI_A2G_DISPATCHER
end end
--- Set the squadron Patrol parameters for SEAD tasks.
-- @param #AI_A2G_DISPATCHER self
-- @param #string SquadronName The squadron name.
-- @param #number PatrolLimit (optional) The maximum amount of Patrol groups to be spawned. Note that a Patrol is a group, so can consist out of 1 to 4 airplanes. The default is 1 Patrol group.
-- @param #number LowInterval (optional) The minimum time boundary in seconds when a new Patrol will be spawned. The default is 180 seconds.
-- @param #number HighInterval (optional) The maximum time boundary in seconds when a new Patrol will be spawned. The default is 600 seconds.
-- @param #number Probability Is not in use, you can skip this parameter.
-- @return #AI_A2G_DISPATCHER
-- @usage
--
-- -- Patrol Squadron execution.
-- PatrolZoneEast = ZONE_POLYGON:New( "Patrol Zone East", GROUP:FindByName( "Patrol Zone East" ) )
-- A2GDispatcher:SetSquadronSeadPatrol( "Mineralnye", PatrolZoneEast, 4000, 10000, 500, 600, 800, 900 )
-- A2GDispatcher:SetSquadronSeadPatrolInterval( "Mineralnye", 2, 30, 60, 1 )
--
function AI_A2G_DISPATCHER:SetSquadronSeadPatrolInterval( SquadronName, PatrolLimit, LowInterval, HighInterval, Probability )
self:SetSquadronPatrolInterval( SquadronName, PatrolLimit, LowInterval, HighInterval, Probability, "SEAD" )
end
--- Set the squadron Patrol parameters for CAS tasks.
-- @param #AI_A2G_DISPATCHER self
-- @param #string SquadronName The squadron name.
-- @param #number PatrolLimit (optional) The maximum amount of Patrol groups to be spawned. Note that a Patrol is a group, so can consist out of 1 to 4 airplanes. The default is 1 Patrol group.
-- @param #number LowInterval (optional) The minimum time boundary in seconds when a new Patrol will be spawned. The default is 180 seconds.
-- @param #number HighInterval (optional) The maximum time boundary in seconds when a new Patrol will be spawned. The default is 600 seconds.
-- @param #number Probability Is not in use, you can skip this parameter.
-- @return #AI_A2G_DISPATCHER
-- @usage
--
-- -- Patrol Squadron execution.
-- PatrolZoneEast = ZONE_POLYGON:New( "Patrol Zone East", GROUP:FindByName( "Patrol Zone East" ) )
-- A2GDispatcher:SetSquadronCasPatrol( "Mineralnye", PatrolZoneEast, 4000, 10000, 500, 600, 800, 900 )
-- A2GDispatcher:SetSquadronCasPatrolInterval( "Mineralnye", 2, 30, 60, 1 )
--
function AI_A2G_DISPATCHER:SetSquadronCasPatrolInterval( SquadronName, PatrolLimit, LowInterval, HighInterval, Probability )
self:SetSquadronPatrolInterval( SquadronName, PatrolLimit, LowInterval, HighInterval, Probability, "CAS" )
end
--- Set the squadron Patrol parameters for BAI tasks.
-- @param #AI_A2G_DISPATCHER self
-- @param #string SquadronName The squadron name.
-- @param #number PatrolLimit (optional) The maximum amount of Patrol groups to be spawned. Note that a Patrol is a group, so can consist out of 1 to 4 airplanes. The default is 1 Patrol group.
-- @param #number LowInterval (optional) The minimum time boundary in seconds when a new Patrol will be spawned. The default is 180 seconds.
-- @param #number HighInterval (optional) The maximum time boundary in seconds when a new Patrol will be spawned. The default is 600 seconds.
-- @param #number Probability Is not in use, you can skip this parameter.
-- @return #AI_A2G_DISPATCHER
-- @usage
--
-- -- Patrol Squadron execution.
-- PatrolZoneEast = ZONE_POLYGON:New( "Patrol Zone East", GROUP:FindByName( "Patrol Zone East" ) )
-- A2GDispatcher:SetSquadronBaiPatrol( "Mineralnye", PatrolZoneEast, 4000, 10000, 500, 600, 800, 900 )
-- A2GDispatcher:SetSquadronBaiPatrolInterval( "Mineralnye", 2, 30, 60, 1 )
--
function AI_A2G_DISPATCHER:SetSquadronBaiPatrolInterval( SquadronName, PatrolLimit, LowInterval, HighInterval, Probability )
self:SetSquadronPatrolInterval( SquadronName, PatrolLimit, LowInterval, HighInterval, Probability, "BAI" )
end
--- ---
-- @param #AI_A2G_DISPATCHER self -- @param #AI_A2G_DISPATCHER self
-- @param #string SquadronName The squadron name. -- @param #string SquadronName The squadron name.
@ -2530,7 +2598,7 @@ do -- AI_A2G_DISPATCHER
self:SetDefenderTaskTarget( DefenderGroup, AttackerDetection ) self:SetDefenderTaskTarget( DefenderGroup, AttackerDetection )
DefendersMissing = DefendersMissing - DefenderGroup:GetSize() DefendersMissing = DefendersMissing - DefenderGroup:GetSize() / SquadronOverhead
if DefendersMissing <= 0 then if DefendersMissing <= 0 then
break break
@ -2861,7 +2929,10 @@ do -- AI_A2G_DISPATCHER
for DefenseCoordinateName, EvaluateCoordinate in pairs( self.DefenseCoordinates ) do for DefenseCoordinateName, EvaluateCoordinate in pairs( self.DefenseCoordinates ) do
local EvaluateDistance = AttackerCoordinate:Get2DDistance( EvaluateCoordinate ) local EvaluateDistance = AttackerCoordinate:Get2DDistance( EvaluateCoordinate )
local DistanceProbability = ( self.DefenseDistance / EvaluateDistance * self.DefenseReactivity )
if EvaluateDistance <= self.DefenseRadius then
local DistanceProbability = ( self.DefenseRadius / EvaluateDistance * self.DefenseReactivity )
local DefenseProbability = math.random() local DefenseProbability = math.random()
self:F( { DistanceProbability = DistanceProbability, DefenseProbability = DefenseProbability } ) self:F( { DistanceProbability = DistanceProbability, DefenseProbability = DefenseProbability } )
@ -2871,6 +2942,7 @@ do -- AI_A2G_DISPATCHER
break break
end end
end end
end
if DefenseCoordinate then if DefenseCoordinate then
do do