mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Progress
This commit is contained in:
@@ -317,6 +317,8 @@ function AI_A2A:ManageFuel( PatrolFuelTresholdPercentage, PatrolOutOfFuelOrbitTi
|
|||||||
self.PatrolFuelTresholdPercentage = PatrolFuelTresholdPercentage
|
self.PatrolFuelTresholdPercentage = PatrolFuelTresholdPercentage
|
||||||
self.PatrolOutOfFuelOrbitTime = PatrolOutOfFuelOrbitTime
|
self.PatrolOutOfFuelOrbitTime = PatrolOutOfFuelOrbitTime
|
||||||
|
|
||||||
|
self.Controllable:OptionRTBBingoFuel( false )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -426,7 +428,7 @@ function AI_A2A.RTBRoute( AIGroup )
|
|||||||
|
|
||||||
AIGroup:E( { "RTBRoute:", AIGroup:GetName() } )
|
AIGroup:E( { "RTBRoute:", AIGroup:GetName() } )
|
||||||
local _AI_A2A = AIGroup:GetState( AIGroup, "AI_A2A" ) -- #AI_A2A
|
local _AI_A2A = AIGroup:GetState( AIGroup, "AI_A2A" ) -- #AI_A2A
|
||||||
_AI_A2A:__Engage( 1 )
|
_AI_A2A:__RTB( 1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_A2A self
|
--- @param #AI_A2A self
|
||||||
@@ -449,11 +451,11 @@ function AI_A2A:onafterRTB( AIGroup, From, Event, To )
|
|||||||
local CurrentCoord = AIGroup:GetCoordinate()
|
local CurrentCoord = AIGroup:GetCoordinate()
|
||||||
local ToTargetCoord = self.HomeAirbase:GetCoordinate()
|
local ToTargetCoord = self.HomeAirbase:GetCoordinate()
|
||||||
local ToTargetSpeed = math.random( self.PatrolMinSpeed, self.PatrolMaxSpeed )
|
local ToTargetSpeed = math.random( self.PatrolMinSpeed, self.PatrolMaxSpeed )
|
||||||
local ToInterceptAngle = CurrentCoord:GetAngleDegrees( CurrentCoord:GetDirectionVec3( ToTargetCoord ) )
|
local ToAirbaseAngle = CurrentCoord:GetAngleDegrees( CurrentCoord:GetDirectionVec3( ToTargetCoord ) )
|
||||||
|
|
||||||
local Distance = CurrentCoord:Get2DDistance( ToTargetCoord )
|
local Distance = CurrentCoord:Get2DDistance( ToTargetCoord )
|
||||||
|
|
||||||
local ToAirbaseCoord = CurrentCoord:Translate( 5000, ToInterceptAngle )
|
local ToAirbaseCoord = CurrentCoord:Translate( 5000, ToAirbaseAngle )
|
||||||
if Distance > 10000 then
|
if Distance > 10000 then
|
||||||
ToAirbaseCoord = ToTargetCoord
|
ToAirbaseCoord = ToTargetCoord
|
||||||
end
|
end
|
||||||
@@ -466,7 +468,7 @@ function AI_A2A:onafterRTB( AIGroup, From, Event, To )
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
self:F( { Angle = ToInterceptAngle, ToTargetSpeed = ToTargetSpeed } )
|
self:F( { Angle = ToAirbaseAngle, ToTargetSpeed = ToTargetSpeed } )
|
||||||
self:T2( { self.MinSpeed, self.MaxSpeed, ToTargetSpeed } )
|
self:T2( { self.MinSpeed, self.MaxSpeed, ToTargetSpeed } )
|
||||||
|
|
||||||
EngageRoute[#EngageRoute+1] = ToPatrolRoutePoint
|
EngageRoute[#EngageRoute+1] = ToPatrolRoutePoint
|
||||||
|
|||||||
@@ -476,13 +476,13 @@ do -- AI_A2A_DISPATCHER
|
|||||||
if Defender and DefenderTask and DefenderTask.Target then
|
if Defender and DefenderTask and DefenderTask.Target then
|
||||||
DefenderTask.Target = nil
|
DefenderTask.Target = nil
|
||||||
end
|
end
|
||||||
if Defender and DefenderTask then
|
-- if Defender and DefenderTask then
|
||||||
if DefenderTask.Fsm:Is( "Fuel" )
|
-- if DefenderTask.Fsm:Is( "Fuel" )
|
||||||
or DefenderTask.Fsm:Is( "LostControl")
|
-- or DefenderTask.Fsm:Is( "LostControl")
|
||||||
or DefenderTask.Fsm:Is( "Damaged" ) then
|
-- or DefenderTask.Fsm:Is( "Damaged" ) then
|
||||||
self:ClearDefenderTask( Defender )
|
-- self:ClearDefenderTask( Defender )
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -512,7 +512,6 @@ do -- AI_A2A_DISPATCHER
|
|||||||
Message = Message .. ( Target and ( " target " .. Target.Index .. " [" .. Target.Set:Count() .. "]" ) ) or ""
|
Message = Message .. ( Target and ( " target " .. Target.Index .. " [" .. Target.Set:Count() .. "]" ) ) or ""
|
||||||
self:F( { Target = Message } )
|
self:F( { Target = Message } )
|
||||||
if Target then
|
if Target then
|
||||||
Defender:MessageToAll( Message, 1200 )
|
|
||||||
self.DefenderTasks[Defender].Target = Target
|
self.DefenderTasks[Defender].Target = Target
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
@@ -1125,10 +1124,13 @@ do -- AI_A2A_DISPATCHER
|
|||||||
if DefenderTask.Type == "CAP" or DefenderTask.Type == "INTERCEPT" then
|
if DefenderTask.Type == "CAP" or DefenderTask.Type == "INTERCEPT" then
|
||||||
-- If there is no target, then add the AIGroup to the ResultAIGroups for Engagement to the TargetSet
|
-- If there is no target, then add the AIGroup to the ResultAIGroups for Engagement to the TargetSet
|
||||||
if DefenderTask.Target == nil then
|
if DefenderTask.Target == nil then
|
||||||
Friendlies = Friendlies or {}
|
if DefenderTask.Fsm:Is( "Returning" )
|
||||||
Friendlies[Friendly] = Friendly
|
or DefenderTask.Fsm:Is( "Patrolling" ) then
|
||||||
DefenderCount = DefenderCount + Friendly:GetSize()
|
Friendlies = Friendlies or {}
|
||||||
self:F( { Friendly = Friendly:GetName(), FriendlyDistance = FriendlyDistance } )
|
Friendlies[Friendly] = Friendly
|
||||||
|
DefenderCount = DefenderCount + Friendly:GetSize()
|
||||||
|
self:F( { Friendly = Friendly:GetName(), FriendlyDistance = FriendlyDistance } )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1368,15 +1370,24 @@ do -- AI_A2A_DISPATCHER
|
|||||||
self:ClearDefenderTask( AIGroup )
|
self:ClearDefenderTask( AIGroup )
|
||||||
else
|
else
|
||||||
if DefenderTask.Target then
|
if DefenderTask.Target then
|
||||||
if DefenderTask.Target.Set then
|
local Target = Detection:GetDetectedItem( DefenderTask.Target.Index )
|
||||||
if DefenderTask.Target.Set:Count() == 0 then
|
if not Target then
|
||||||
self:ClearDefenderTaskTarget( AIGroup )
|
self:F( { "Removing obsolete Target:", DefenderTask.Target.Index } )
|
||||||
|
self:ClearDefenderTaskTarget( AIGroup )
|
||||||
|
else
|
||||||
|
if DefenderTask.Target.Set then
|
||||||
|
if DefenderTask.Target.Set:Count() == 0 then
|
||||||
|
self:F( { "All Targets destroyed in Target, removing:", DefenderTask.Target.Index } )
|
||||||
|
self:ClearDefenderTaskTarget( AIGroup )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local Report = REPORT:New( "\nTactical Overview" )
|
||||||
|
|
||||||
-- Now that all obsolete tasks are removed, loop through the detected targets.
|
-- Now that all obsolete tasks are removed, loop through the detected targets.
|
||||||
for DetectedItemID, DetectedItem in pairs( Detection:GetDetectedItems() ) do
|
for DetectedItemID, DetectedItem in pairs( Detection:GetDetectedItems() ) do
|
||||||
|
|
||||||
@@ -1407,19 +1418,30 @@ do -- AI_A2A_DISPATCHER
|
|||||||
self:INTERCEPT( DetectedItem, DefendersMissing, Friendlies )
|
self:INTERCEPT( DetectedItem, DefendersMissing, Friendlies )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Show tactical situation
|
||||||
|
Report:Add( string.format( "\n - Target %s ( %s ): %s" , DetectedItem.ItemID, DetectedItem.Index, DetectedItem.Set:GetObjectNames() ) )
|
||||||
|
for Defender, DefenderTask in pairs( self:GetDefenderTasks() ) do
|
||||||
|
local Defender = Defender -- Wrapper.Group#GROUP
|
||||||
|
if DefenderTask.Target and DefenderTask.Target.ItemID == DetectedItem.ItemID then
|
||||||
|
Report:Add( string.format( " - %s ( %s - %s )", Defender:GetName(), DefenderTask.Type, DefenderTask.Fsm:GetState() ) )
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Show tactical situation
|
Report:Add( "\n - No Targets:")
|
||||||
|
local TaskCount = 0
|
||||||
for Defender, DefenderTask in pairs( self:GetDefenderTasks() ) do
|
for Defender, DefenderTask in pairs( self:GetDefenderTasks() ) do
|
||||||
|
TaskCount = TaskCount + 1
|
||||||
local Defender = Defender -- Wrapper.Group#GROUP
|
local Defender = Defender -- Wrapper.Group#GROUP
|
||||||
local Message = string.format( "%s ( %s - %s )", Defender:GetName(), DefenderTask.Type, DefenderTask.Fsm:GetState() )
|
if not DefenderTask.Target then
|
||||||
if DefenderTask.Target then
|
Report:Add( string.format( " - %s ( %s - %s )", Defender:GetName(), DefenderTask.Type, DefenderTask.Fsm:GetState() ) )
|
||||||
Message = Message .. string.format( " => %s : %s", DefenderTask.Target.ItemID, DefenderTask.Target.Set:GetObjectNames() )
|
|
||||||
end
|
end
|
||||||
self:F( { Tactical = Message } )
|
|
||||||
end
|
end
|
||||||
|
Report:Add( string.format( "\n - %d Tasks", TaskCount ) )
|
||||||
|
|
||||||
|
self:T( Report:Text( "\n" ) )
|
||||||
|
trigger.action.outText( Report:Text( "\n" ), 25 )
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2210,6 +2210,57 @@ function CONTROLLABLE:OptionROTVertical()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set RTB on bingo fuel.
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @param #boolean RTB true if RTB on bingo fuel (default), false if no RTB on bingo fuel.
|
||||||
|
-- Warning! When you switch this option off, the airborne group will continue to fly until all fuel has been consumed, and will crash.
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:OptionRTBBingoFuel( RTB ) --R2.2
|
||||||
|
self:F2( { self.ControllableName } )
|
||||||
|
|
||||||
|
RTB = RTB or true
|
||||||
|
|
||||||
|
local DCSControllable = self:GetDCSObject()
|
||||||
|
if DCSControllable then
|
||||||
|
local Controller = self:_GetController()
|
||||||
|
|
||||||
|
if self:IsAir() then
|
||||||
|
Controller:setOption( AI.Option.Air.id.RTB_ON_BINGO, RTB )
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set RTB on ammo.
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @param #boolean WeaponsFlag Weapons.flag enumerator.
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:OptionRTBAmmo( WeaponsFlag )
|
||||||
|
self:F2( { self.ControllableName } )
|
||||||
|
|
||||||
|
local DCSControllable = self:GetDCSObject()
|
||||||
|
if DCSControllable then
|
||||||
|
local Controller = self:_GetController()
|
||||||
|
|
||||||
|
if self:IsAir() then
|
||||||
|
Controller:setOption( AI.Option.GROUND.id.RTB_ON_OUT_OF_AMMO, WeaponsFlag )
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Retrieve the controllable mission and allow to place function hooks within the mission waypoint plan.
|
--- Retrieve the controllable mission and allow to place function hooks within the mission waypoint plan.
|
||||||
-- Use the method @{Controllable#CONTROLLABLE:WayPointFunction} to define the hook functions for specific waypoints.
|
-- Use the method @{Controllable#CONTROLLABLE:WayPointFunction} to define the hook functions for specific waypoints.
|
||||||
-- Use the method @{Controllable@CONTROLLABLE:WayPointExecute) to start the execution of the new mission plan.
|
-- Use the method @{Controllable@CONTROLLABLE:WayPointExecute) to start the execution of the new mission plan.
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user