mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Update
A2A_DISPATCHER - Docs CONTROLLABLE - OptionROEOpenFireWeaponFree() - Fixed OptionRTBBingoFuel()
This commit is contained in:
parent
8780ec3687
commit
6f140be710
@ -833,7 +833,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
|
|
||||||
|
|
||||||
--- Squadron data structure.
|
--- Squadron data structure.
|
||||||
-- @type AI_A2A_Dispatcher.Squadron
|
-- @type AI_A2A_DISPATCHER.Squadron
|
||||||
-- @field #string Name Name of the squadron.
|
-- @field #string Name Name of the squadron.
|
||||||
-- @field #number ResourceCount Number of resources.
|
-- @field #number ResourceCount Number of resources.
|
||||||
-- @field #string AirbaseName Name of the home airbase.
|
-- @field #string AirbaseName Name of the home airbase.
|
||||||
@ -978,15 +978,24 @@ do -- AI_A2A_DISPATCHER
|
|||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
|
-- @param Functional.Detection#DETECTION_BASE.DetectedItem AttackerDetection Detected item.
|
||||||
|
-- @param #number DefendersMissing Number of missing defenders.
|
||||||
|
-- @param #table DefenderFriendlies Friendly defenders.
|
||||||
|
|
||||||
--- GCI Trigger for AI_A2A_DISPATCHER
|
--- GCI Trigger for AI_A2A_DISPATCHER
|
||||||
-- @function [parent=#AI_A2A_DISPATCHER] GCI
|
-- @function [parent=#AI_A2A_DISPATCHER] GCI
|
||||||
-- @param #AI_A2A_DISPATCHER self
|
-- @param #AI_A2A_DISPATCHER self
|
||||||
|
-- @param Functional.Detection#DETECTION_BASE.DetectedItem AttackerDetection Detected item.
|
||||||
|
-- @param #number DefendersMissing Number of missing defenders.
|
||||||
|
-- @param #table DefenderFriendlies Friendly defenders.
|
||||||
|
|
||||||
--- GCI Asynchronous Trigger for AI_A2A_DISPATCHER
|
--- GCI Asynchronous Trigger for AI_A2A_DISPATCHER
|
||||||
-- @function [parent=#AI_A2A_DISPATCHER] __GCI
|
-- @function [parent=#AI_A2A_DISPATCHER] __GCI
|
||||||
-- @param #AI_A2A_DISPATCHER self
|
-- @param #AI_A2A_DISPATCHER self
|
||||||
-- @param #number Delay
|
-- @param #number Delay
|
||||||
|
-- @param Functional.Detection#DETECTION_BASE.DetectedItem AttackerDetection Detected item.
|
||||||
|
-- @param #number DefendersMissing Number of missing defenders.
|
||||||
|
-- @param #table DefenderFriendlies Friendly defenders.
|
||||||
|
|
||||||
self:AddTransition( "*", "ENGAGE", "*" )
|
self:AddTransition( "*", "ENGAGE", "*" )
|
||||||
|
|
||||||
@ -996,6 +1005,8 @@ do -- AI_A2A_DISPATCHER
|
|||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
|
-- @param Functional.Detection#DETECTION_BASE.DetectedItem AttackerDetection Detected item.
|
||||||
|
-- @param #table Defenders Defenders table.
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
|
|
||||||
--- ENGAGE Handler OnAfter for AI_A2A_DISPATCHER
|
--- ENGAGE Handler OnAfter for AI_A2A_DISPATCHER
|
||||||
@ -1004,15 +1015,21 @@ do -- AI_A2A_DISPATCHER
|
|||||||
-- @param #string From
|
-- @param #string From
|
||||||
-- @param #string Event
|
-- @param #string Event
|
||||||
-- @param #string To
|
-- @param #string To
|
||||||
|
-- @param Functional.Detection#DETECTION_BASE.DetectedItem AttackerDetection Detected item.
|
||||||
|
-- @param #table Defenders Defenders table.
|
||||||
|
|
||||||
--- ENGAGE Trigger for AI_A2A_DISPATCHER
|
--- ENGAGE Trigger for AI_A2A_DISPATCHER
|
||||||
-- @function [parent=#AI_A2A_DISPATCHER] ENGAGE
|
-- @function [parent=#AI_A2A_DISPATCHER] ENGAGE
|
||||||
-- @param #AI_A2A_DISPATCHER self
|
-- @param #AI_A2A_DISPATCHER self
|
||||||
|
-- @param Functional.Detection#DETECTION_BASE.DetectedItem AttackerDetection Detected item.
|
||||||
|
-- @param #table Defenders Defenders table.
|
||||||
|
|
||||||
--- ENGAGE Asynchronous Trigger for AI_A2A_DISPATCHER
|
--- ENGAGE Asynchronous Trigger for AI_A2A_DISPATCHER
|
||||||
-- @function [parent=#AI_A2A_DISPATCHER] __ENGAGE
|
-- @function [parent=#AI_A2A_DISPATCHER] __ENGAGE
|
||||||
-- @param #AI_A2A_DISPATCHER self
|
-- @param #AI_A2A_DISPATCHER self
|
||||||
-- @param #number Delay
|
-- @param #number Delay
|
||||||
|
-- @param Functional.Detection#DETECTION_BASE.DetectedItem AttackerDetection Detected item.
|
||||||
|
-- @param #table Defenders Defenders table.
|
||||||
|
|
||||||
|
|
||||||
-- Subscribe to the CRASH event so that when planes are shot
|
-- Subscribe to the CRASH event so that when planes are shot
|
||||||
@ -1062,7 +1079,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
|
|
||||||
--- Park defender.
|
--- Park defender.
|
||||||
-- @param #AI_A2A_DISPATCHER self
|
-- @param #AI_A2A_DISPATCHER self
|
||||||
-- @param #AI_A2A_Dispatcher.Squadron DefenderSquadron The squadron.
|
-- @param #AI_A2A_DISPATCHER.Squadron DefenderSquadron The squadron.
|
||||||
function AI_A2A_DISPATCHER:ParkDefender( DefenderSquadron )
|
function AI_A2A_DISPATCHER:ParkDefender( DefenderSquadron )
|
||||||
local TemplateID = math.random( 1, #DefenderSquadron.Spawn )
|
local TemplateID = math.random( 1, #DefenderSquadron.Spawn )
|
||||||
local Spawn = DefenderSquadron.Spawn[ TemplateID ] -- Core.Spawn#SPAWN
|
local Spawn = DefenderSquadron.Spawn[ TemplateID ] -- Core.Spawn#SPAWN
|
||||||
@ -1384,7 +1401,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
|
|
||||||
--- Calculates which AI friendlies are nearby the area
|
--- Calculates which AI friendlies are nearby the area
|
||||||
-- @param #AI_A2A_DISPATCHER self
|
-- @param #AI_A2A_DISPATCHER self
|
||||||
-- @param DetectedItem
|
-- @param Functional.Detection#DETECTION_BASE.DetectedItem DetectedItem
|
||||||
-- @return #table A list of the friendlies nearby.
|
-- @return #table A list of the friendlies nearby.
|
||||||
function AI_A2A_DISPATCHER:GetAIFriendliesNearBy( DetectedItem )
|
function AI_A2A_DISPATCHER:GetAIFriendliesNearBy( DetectedItem )
|
||||||
|
|
||||||
@ -1489,7 +1506,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
-- @return #AI_A2A_DISPATCHER self
|
-- @return #AI_A2A_DISPATCHER self
|
||||||
function AI_A2A_DISPATCHER:SetDefenderTask( SquadronName, Defender, Type, Fsm, Target )
|
function AI_A2A_DISPATCHER:SetDefenderTask( SquadronName, Defender, Type, Fsm, Target )
|
||||||
|
|
||||||
self:F( { SquadronName = SquadronName, Defender = Defender:GetName() } )
|
self:F( { SquadronName = SquadronName, Defender = Defender:GetName(), Type=Type, Target=Target } )
|
||||||
|
|
||||||
self.DefenderTasks[Defender] = self.DefenderTasks[Defender] or {}
|
self.DefenderTasks[Defender] = self.DefenderTasks[Defender] or {}
|
||||||
self.DefenderTasks[Defender].Type = Type
|
self.DefenderTasks[Defender].Type = Type
|
||||||
@ -1596,7 +1613,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
|
|
||||||
self.DefenderSquadrons[SquadronName] = self.DefenderSquadrons[SquadronName] or {}
|
self.DefenderSquadrons[SquadronName] = self.DefenderSquadrons[SquadronName] or {}
|
||||||
|
|
||||||
local DefenderSquadron = self.DefenderSquadrons[SquadronName] --#AI_A2A_Dispatcher.Squadron
|
local DefenderSquadron = self.DefenderSquadrons[SquadronName] --#AI_A2A_DISPATCHER.Squadron
|
||||||
|
|
||||||
DefenderSquadron.Name = SquadronName
|
DefenderSquadron.Name = SquadronName
|
||||||
DefenderSquadron.Airbase = AIRBASE:FindByName( AirbaseName )
|
DefenderSquadron.Airbase = AIRBASE:FindByName( AirbaseName )
|
||||||
@ -1628,7 +1645,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
--- Get an item from the Squadron table.
|
--- Get an item from the Squadron table.
|
||||||
-- @param #AI_A2A_DISPATCHER self
|
-- @param #AI_A2A_DISPATCHER self
|
||||||
-- @param #string SquadronName Name of the squadron.
|
-- @param #string SquadronName Name of the squadron.
|
||||||
-- @return #AI_A2A_Dispatcher.Squadron Defender squadron table.
|
-- @return #AI_A2A_DISPATCHER.Squadron Defender squadron table.
|
||||||
function AI_A2A_DISPATCHER:GetSquadron( SquadronName )
|
function AI_A2A_DISPATCHER:GetSquadron( SquadronName )
|
||||||
local DefenderSquadron = self.DefenderSquadrons[SquadronName]
|
local DefenderSquadron = self.DefenderSquadrons[SquadronName]
|
||||||
|
|
||||||
@ -1655,7 +1672,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
|
|
||||||
self.DefenderSquadrons[SquadronName] = self.DefenderSquadrons[SquadronName] or {}
|
self.DefenderSquadrons[SquadronName] = self.DefenderSquadrons[SquadronName] or {}
|
||||||
|
|
||||||
local DefenderSquadron = self:GetSquadron( SquadronName ) --#AI_A2A_Dispatcher.Squadron
|
local DefenderSquadron = self:GetSquadron( SquadronName ) --#AI_A2A_DISPATCHER.Squadron
|
||||||
|
|
||||||
DefenderSquadron.Uncontrolled = true
|
DefenderSquadron.Uncontrolled = true
|
||||||
|
|
||||||
@ -1678,7 +1695,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
|
|
||||||
self.DefenderSquadrons[SquadronName] = self.DefenderSquadrons[SquadronName] or {}
|
self.DefenderSquadrons[SquadronName] = self.DefenderSquadrons[SquadronName] or {}
|
||||||
|
|
||||||
local DefenderSquadron = self:GetSquadron( SquadronName ) --#AI_A2A_Dispatcher.Squadron
|
local DefenderSquadron = self:GetSquadron( SquadronName ) --#AI_A2A_DISPATCHER.Squadron
|
||||||
|
|
||||||
if DefenderSquadron then
|
if DefenderSquadron then
|
||||||
return DefenderSquadron.Uncontrolled == true
|
return DefenderSquadron.Uncontrolled == true
|
||||||
@ -2968,6 +2985,8 @@ do -- AI_A2A_DISPATCHER
|
|||||||
-- @param #table Defenders Defenders table.
|
-- @param #table Defenders Defenders table.
|
||||||
function AI_A2A_DISPATCHER:onafterENGAGE( From, Event, To, AttackerDetection, Defenders )
|
function AI_A2A_DISPATCHER:onafterENGAGE( From, Event, To, AttackerDetection, Defenders )
|
||||||
|
|
||||||
|
self:F("ENGAGING "..tostring(AttackerDetection.Name))
|
||||||
|
|
||||||
if Defenders then
|
if Defenders then
|
||||||
|
|
||||||
for DefenderID, Defender in pairs( Defenders ) do
|
for DefenderID, Defender in pairs( Defenders ) do
|
||||||
@ -2991,6 +3010,8 @@ do -- AI_A2A_DISPATCHER
|
|||||||
-- @param #table DefenderFriendlies Friendly defenders.
|
-- @param #table DefenderFriendlies Friendly defenders.
|
||||||
function AI_A2A_DISPATCHER:onafterGCI( From, Event, To, AttackerDetection, DefendersMissing, DefenderFriendlies )
|
function AI_A2A_DISPATCHER:onafterGCI( From, Event, To, AttackerDetection, DefendersMissing, DefenderFriendlies )
|
||||||
|
|
||||||
|
self:F("GCI "..tostring(AttackerDetection.Name))
|
||||||
|
|
||||||
self:F( { From, Event, To, AttackerDetection.Index, DefendersMissing, DefenderFriendlies } )
|
self:F( { From, Event, To, AttackerDetection.Index, DefendersMissing, DefenderFriendlies } )
|
||||||
|
|
||||||
local AttackerSet = AttackerDetection.Set
|
local AttackerSet = AttackerDetection.Set
|
||||||
@ -3262,7 +3283,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local Report = REPORT:New( "\nTactical Overview" )
|
local Report = REPORT:New( "Tactical Overview" )
|
||||||
|
|
||||||
local DefenderGroupCount = 0
|
local DefenderGroupCount = 0
|
||||||
|
|
||||||
@ -3299,11 +3320,11 @@ do -- AI_A2A_DISPATCHER
|
|||||||
|
|
||||||
if self.TacticalDisplay then
|
if self.TacticalDisplay then
|
||||||
-- Show tactical situation
|
-- Show tactical situation
|
||||||
Report:Add( string.format( "\n - Target %s ( %s ): ( #%d ) %s" , DetectedItem.ItemID, DetectedItem.Index, DetectedItem.Set:Count(), DetectedItem.Set:GetObjectNames() ) )
|
Report:Add( string.format( "\n- Target %s ( %s ): ( #%d ) %s" , DetectedItem.ItemID, DetectedItem.Index, DetectedItem.Set:Count(), DetectedItem.Set:GetObjectNames() ) )
|
||||||
for Defender, DefenderTask in pairs( self:GetDefenderTasks() ) do
|
for Defender, DefenderTask in pairs( self:GetDefenderTasks() ) do
|
||||||
local Defender = Defender -- Wrapper.Group#GROUP
|
local Defender = Defender -- Wrapper.Group#GROUP
|
||||||
if DefenderTask.Target and DefenderTask.Target.Index == DetectedItem.Index then
|
if DefenderTask.Target and DefenderTask.Target.Index == DetectedItem.Index then
|
||||||
if Defender:IsAlive() then
|
if Defender and Defender:IsAlive() then
|
||||||
DefenderGroupCount = DefenderGroupCount + 1
|
DefenderGroupCount = DefenderGroupCount + 1
|
||||||
local Fuel = Defender:GetFuelMin() * 100
|
local Fuel = Defender:GetFuelMin() * 100
|
||||||
local Damage = Defender:GetLife() / Defender:GetLife0() * 100
|
local Damage = Defender:GetLife() / Defender:GetLife0() * 100
|
||||||
@ -3322,7 +3343,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
end
|
end
|
||||||
|
|
||||||
if self.TacticalDisplay then
|
if self.TacticalDisplay then
|
||||||
Report:Add( "\n - No Targets:")
|
Report:Add( "\n- No Targets:")
|
||||||
local TaskCount = 0
|
local TaskCount = 0
|
||||||
for Defender, DefenderTask in pairs( self:GetDefenderTasks() ) do
|
for Defender, DefenderTask in pairs( self:GetDefenderTasks() ) do
|
||||||
TaskCount = TaskCount + 1
|
TaskCount = TaskCount + 1
|
||||||
@ -3344,7 +3365,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Report:Add( string.format( "\n - %d Tasks - %d Defender Groups", TaskCount, DefenderGroupCount ) )
|
Report:Add( string.format( "\n- %d Tasks - %d Defender Groups", TaskCount, DefenderGroupCount ) )
|
||||||
|
|
||||||
self:F( Report:Text( "\n" ) )
|
self:F( Report:Text( "\n" ) )
|
||||||
trigger.action.outText( Report:Text( "\n" ), 25 )
|
trigger.action.outText( Report:Text( "\n" ), 25 )
|
||||||
|
|||||||
@ -2806,6 +2806,8 @@ function CONTROLLABLE:GetDetectedTargets( DetectVisual, DetectOptical, DetectRad
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Check if a target is detected.
|
||||||
|
-- @param Wrapper.Controllable#CONTROLLABLE self
|
||||||
function CONTROLLABLE:IsTargetDetected( DCSObject, DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK )
|
function CONTROLLABLE:IsTargetDetected( DCSObject, DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK )
|
||||||
self:F2( self.ControllableName )
|
self:F2( self.ControllableName )
|
||||||
|
|
||||||
@ -2851,7 +2853,7 @@ function CONTROLLABLE:OptionROEHoldFirePossible()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Holding weapons.
|
--- Weapons Hold: AI will hold fire under all circumstances.
|
||||||
-- @param Wrapper.Controllable#CONTROLLABLE self
|
-- @param Wrapper.Controllable#CONTROLLABLE self
|
||||||
-- @return Wrapper.Controllable#CONTROLLABLE self
|
-- @return Wrapper.Controllable#CONTROLLABLE self
|
||||||
function CONTROLLABLE:OptionROEHoldFire()
|
function CONTROLLABLE:OptionROEHoldFire()
|
||||||
@ -2893,7 +2895,7 @@ function CONTROLLABLE:OptionROEReturnFirePossible()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Return fire.
|
--- Return Fire: AI will only engage threats that shoot first.
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:OptionROEReturnFire()
|
function CONTROLLABLE:OptionROEReturnFire()
|
||||||
@ -2935,7 +2937,7 @@ function CONTROLLABLE:OptionROEOpenFirePossible()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Openfire.
|
--- Open Fire (Only Designated): AI will engage only targets specified in its taskings.
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @return #CONTROLLABLE self
|
-- @return #CONTROLLABLE self
|
||||||
function CONTROLLABLE:OptionROEOpenFire()
|
function CONTROLLABLE:OptionROEOpenFire()
|
||||||
@ -2959,6 +2961,45 @@ function CONTROLLABLE:OptionROEOpenFire()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Can the CONTROLLABLE attack priority designated targets? Only for AIR!
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @return #boolean
|
||||||
|
function CONTROLLABLE:OptionROEOpenFireWeaponFreePossible()
|
||||||
|
self:F2( { self.ControllableName } )
|
||||||
|
|
||||||
|
local DCSControllable = self:GetDCSObject()
|
||||||
|
if DCSControllable then
|
||||||
|
if self:IsAir() then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Open Fire, Weapons Free (Priority Designated): AI will engage any enemy group it detects, but will prioritize targets specified in the groups tasking.
|
||||||
|
-- **Only for AIR units!**
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:OptionROEOpenFireWeaponFree()
|
||||||
|
self:F2( { self.ControllableName } )
|
||||||
|
|
||||||
|
local DCSControllable = self:GetDCSObject()
|
||||||
|
if DCSControllable then
|
||||||
|
local Controller = self:_GetController()
|
||||||
|
|
||||||
|
if self:IsAir() then
|
||||||
|
Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.OPEN_FIRE_WEAPON_FREE )
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Can the CONTROLLABLE attack targets of opportunity?
|
--- Can the CONTROLLABLE attack targets of opportunity?
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
@ -3231,7 +3272,10 @@ end
|
|||||||
function CONTROLLABLE:OptionRTBBingoFuel( RTB ) --R2.2
|
function CONTROLLABLE:OptionRTBBingoFuel( RTB ) --R2.2
|
||||||
self:F2( { self.ControllableName } )
|
self:F2( { self.ControllableName } )
|
||||||
|
|
||||||
RTB = RTB or true
|
--RTB = RTB or true
|
||||||
|
if RTB==nil then
|
||||||
|
RTB=true
|
||||||
|
end
|
||||||
|
|
||||||
local DCSControllable = self:GetDCSObject()
|
local DCSControllable = self:GetDCSObject()
|
||||||
if DCSControllable then
|
if DCSControllable then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user