mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Progress
This commit is contained in:
parent
9f22e2cc71
commit
4f91ba6081
@ -317,6 +317,8 @@ function AI_A2A:ManageFuel( PatrolFuelTresholdPercentage, PatrolOutOfFuelOrbitTi
|
||||
self.PatrolFuelTresholdPercentage = PatrolFuelTresholdPercentage
|
||||
self.PatrolOutOfFuelOrbitTime = PatrolOutOfFuelOrbitTime
|
||||
|
||||
self.Controllable:OptionRTBBingoFuel( false )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -426,7 +428,7 @@ function AI_A2A.RTBRoute( AIGroup )
|
||||
|
||||
AIGroup:E( { "RTBRoute:", AIGroup:GetName() } )
|
||||
local _AI_A2A = AIGroup:GetState( AIGroup, "AI_A2A" ) -- #AI_A2A
|
||||
_AI_A2A:__Engage( 1 )
|
||||
_AI_A2A:__RTB( 1 )
|
||||
end
|
||||
|
||||
--- @param #AI_A2A self
|
||||
@ -449,11 +451,11 @@ function AI_A2A:onafterRTB( AIGroup, From, Event, To )
|
||||
local CurrentCoord = AIGroup:GetCoordinate()
|
||||
local ToTargetCoord = self.HomeAirbase:GetCoordinate()
|
||||
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 ToAirbaseCoord = CurrentCoord:Translate( 5000, ToInterceptAngle )
|
||||
local ToAirbaseCoord = CurrentCoord:Translate( 5000, ToAirbaseAngle )
|
||||
if Distance > 10000 then
|
||||
ToAirbaseCoord = ToTargetCoord
|
||||
end
|
||||
@ -466,7 +468,7 @@ function AI_A2A:onafterRTB( AIGroup, From, Event, To )
|
||||
true
|
||||
)
|
||||
|
||||
self:F( { Angle = ToInterceptAngle, ToTargetSpeed = ToTargetSpeed } )
|
||||
self:F( { Angle = ToAirbaseAngle, ToTargetSpeed = ToTargetSpeed } )
|
||||
self:T2( { self.MinSpeed, self.MaxSpeed, ToTargetSpeed } )
|
||||
|
||||
EngageRoute[#EngageRoute+1] = ToPatrolRoutePoint
|
||||
|
||||
@ -476,13 +476,13 @@ do -- AI_A2A_DISPATCHER
|
||||
if Defender and DefenderTask and DefenderTask.Target then
|
||||
DefenderTask.Target = nil
|
||||
end
|
||||
if Defender and DefenderTask then
|
||||
if DefenderTask.Fsm:Is( "Fuel" )
|
||||
or DefenderTask.Fsm:Is( "LostControl")
|
||||
or DefenderTask.Fsm:Is( "Damaged" ) then
|
||||
self:ClearDefenderTask( Defender )
|
||||
end
|
||||
end
|
||||
-- if Defender and DefenderTask then
|
||||
-- if DefenderTask.Fsm:Is( "Fuel" )
|
||||
-- or DefenderTask.Fsm:Is( "LostControl")
|
||||
-- or DefenderTask.Fsm:Is( "Damaged" ) then
|
||||
-- self:ClearDefenderTask( Defender )
|
||||
-- end
|
||||
-- end
|
||||
return self
|
||||
end
|
||||
|
||||
@ -512,7 +512,6 @@ do -- AI_A2A_DISPATCHER
|
||||
Message = Message .. ( Target and ( " target " .. Target.Index .. " [" .. Target.Set:Count() .. "]" ) ) or ""
|
||||
self:F( { Target = Message } )
|
||||
if Target then
|
||||
Defender:MessageToAll( Message, 1200 )
|
||||
self.DefenderTasks[Defender].Target = Target
|
||||
end
|
||||
return self
|
||||
@ -1125,10 +1124,13 @@ do -- AI_A2A_DISPATCHER
|
||||
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 DefenderTask.Target == nil then
|
||||
Friendlies = Friendlies or {}
|
||||
Friendlies[Friendly] = Friendly
|
||||
DefenderCount = DefenderCount + Friendly:GetSize()
|
||||
self:F( { Friendly = Friendly:GetName(), FriendlyDistance = FriendlyDistance } )
|
||||
if DefenderTask.Fsm:Is( "Returning" )
|
||||
or DefenderTask.Fsm:Is( "Patrolling" ) then
|
||||
Friendlies = Friendlies or {}
|
||||
Friendlies[Friendly] = Friendly
|
||||
DefenderCount = DefenderCount + Friendly:GetSize()
|
||||
self:F( { Friendly = Friendly:GetName(), FriendlyDistance = FriendlyDistance } )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1368,15 +1370,24 @@ do -- AI_A2A_DISPATCHER
|
||||
self:ClearDefenderTask( AIGroup )
|
||||
else
|
||||
if DefenderTask.Target then
|
||||
if DefenderTask.Target.Set then
|
||||
if DefenderTask.Target.Set:Count() == 0 then
|
||||
self:ClearDefenderTaskTarget( AIGroup )
|
||||
local Target = Detection:GetDetectedItem( DefenderTask.Target.Index )
|
||||
if not Target then
|
||||
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
|
||||
|
||||
local Report = REPORT:New( "\nTactical Overview" )
|
||||
|
||||
-- Now that all obsolete tasks are removed, loop through the detected targets.
|
||||
for DetectedItemID, DetectedItem in pairs( Detection:GetDetectedItems() ) do
|
||||
|
||||
@ -1407,19 +1418,30 @@ do -- AI_A2A_DISPATCHER
|
||||
self:INTERCEPT( DetectedItem, DefendersMissing, Friendlies )
|
||||
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
|
||||
|
||||
-- Show tactical situation
|
||||
|
||||
Report:Add( "\n - No Targets:")
|
||||
local TaskCount = 0
|
||||
for Defender, DefenderTask in pairs( self:GetDefenderTasks() ) do
|
||||
TaskCount = TaskCount + 1
|
||||
local Defender = Defender -- Wrapper.Group#GROUP
|
||||
local Message = string.format( "%s ( %s - %s )", Defender:GetName(), DefenderTask.Type, DefenderTask.Fsm:GetState() )
|
||||
if DefenderTask.Target then
|
||||
Message = Message .. string.format( " => %s : %s", DefenderTask.Target.ItemID, DefenderTask.Target.Set:GetObjectNames() )
|
||||
if not DefenderTask.Target then
|
||||
Report:Add( string.format( " - %s ( %s - %s )", Defender:GetName(), DefenderTask.Type, DefenderTask.Fsm:GetState() ) )
|
||||
end
|
||||
self:F( { Tactical = Message } )
|
||||
end
|
||||
|
||||
|
||||
Report:Add( string.format( "\n - %d Tasks", TaskCount ) )
|
||||
|
||||
self:T( Report:Text( "\n" ) )
|
||||
trigger.action.outText( Report:Text( "\n" ), 25 )
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
@ -2210,6 +2210,57 @@ function CONTROLLABLE:OptionROTVertical()
|
||||
return nil
|
||||
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.
|
||||
-- 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.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user