mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Progress
This commit is contained in:
@@ -221,6 +221,7 @@ function AI_A2A:New( AIGroup )
|
|||||||
|
|
||||||
|
|
||||||
self:AddTransition( "*", "Return", "Returning" )
|
self:AddTransition( "*", "Return", "Returning" )
|
||||||
|
self:AddTransition( "*", "Home", "Home" )
|
||||||
self:AddTransition( "*", "LostControl", "LostControl" )
|
self:AddTransition( "*", "LostControl", "LostControl" )
|
||||||
self:AddTransition( "*", "Fuel", "Fuel" )
|
self:AddTransition( "*", "Fuel", "Fuel" )
|
||||||
self:AddTransition( "*", "Damaged", "Damaged" )
|
self:AddTransition( "*", "Damaged", "Damaged" )
|
||||||
@@ -415,7 +416,7 @@ function AI_A2A:onafterStatus()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if RTB == true then
|
if RTB == true then
|
||||||
self:RTB()
|
self:__RTB( 0.5 )
|
||||||
else
|
else
|
||||||
self:__Status( 10 ) -- Execute the Patrol event after 30 seconds.
|
self:__Status( 10 ) -- Execute the Patrol event after 30 seconds.
|
||||||
end
|
end
|
||||||
@@ -428,7 +429,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:RTB()
|
_AI_A2A:__RTB( 0.5 )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_A2A self
|
--- @param #AI_A2A self
|
||||||
@@ -436,7 +437,7 @@ end
|
|||||||
function AI_A2A:onafterRTB( AIGroup, From, Event, To )
|
function AI_A2A:onafterRTB( AIGroup, From, Event, To )
|
||||||
self:F( { AIGroup, From, Event, To } )
|
self:F( { AIGroup, From, Event, To } )
|
||||||
|
|
||||||
self:E( "Group " .. self.Controllable:GetName() .. " ... RTB! ( " .. self:GetState() .. " )" )
|
self:E( "Group " .. self.Controllable:GetName() .. " ... Returning! ( " .. self:GetState() .. " )" )
|
||||||
|
|
||||||
if AIGroup and AIGroup:IsAlive() then
|
if AIGroup and AIGroup:IsAlive() then
|
||||||
|
|
||||||
@@ -456,8 +457,9 @@ function AI_A2A:onafterRTB( AIGroup, From, Event, To )
|
|||||||
local Distance = CurrentCoord:Get2DDistance( ToTargetCoord )
|
local Distance = CurrentCoord:Get2DDistance( ToTargetCoord )
|
||||||
|
|
||||||
local ToAirbaseCoord = CurrentCoord:Translate( 5000, ToAirbaseAngle )
|
local ToAirbaseCoord = CurrentCoord:Translate( 5000, ToAirbaseAngle )
|
||||||
if Distance > 10000 then
|
if Distance < 5000 then
|
||||||
ToAirbaseCoord = ToTargetCoord
|
self:Home()
|
||||||
|
return
|
||||||
end
|
end
|
||||||
--- Create a route point of type air.
|
--- Create a route point of type air.
|
||||||
local ToPatrolRoutePoint = ToAirbaseCoord:RoutePointAir(
|
local ToPatrolRoutePoint = ToAirbaseCoord:RoutePointAir(
|
||||||
@@ -492,6 +494,19 @@ function AI_A2A:onafterRTB( AIGroup, From, Event, To )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @param #AI_A2A self
|
||||||
|
-- @param Wrapper.Group#GROUP AIGroup
|
||||||
|
function AI_A2A:onafterHome( AIGroup, From, Event, To )
|
||||||
|
self:F( { AIGroup, From, Event, To } )
|
||||||
|
|
||||||
|
self:E( "Group " .. self.Controllable:GetName() .. " ... Home! ( " .. self:GetState() .. " )" )
|
||||||
|
|
||||||
|
if AIGroup and AIGroup:IsAlive() then
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- @param #AI_A2A self
|
--- @param #AI_A2A self
|
||||||
function AI_A2A:onafterDead()
|
function AI_A2A:onafterDead()
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ end
|
|||||||
function AI_A2A_CAP.AttackRoute( AIGroup )
|
function AI_A2A_CAP.AttackRoute( AIGroup )
|
||||||
|
|
||||||
local EngageZone = AIGroup:GetState( AIGroup, "EngageZone" ) -- AI.AI_Cap#AI_A2A_CAP
|
local EngageZone = AIGroup:GetState( AIGroup, "EngageZone" ) -- AI.AI_Cap#AI_A2A_CAP
|
||||||
EngageZone:Engage()
|
EngageZone:__Engage( 0.5 )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_A2A_CAP self
|
--- @param #AI_A2A_CAP self
|
||||||
@@ -373,7 +373,7 @@ end
|
|||||||
-- @param #string To The To State string.
|
-- @param #string To The To State string.
|
||||||
function AI_A2A_CAP:onafterAbort( AIGroup, From, Event, To )
|
function AI_A2A_CAP:onafterAbort( AIGroup, From, Event, To )
|
||||||
AIGroup:ClearTasks()
|
AIGroup:ClearTasks()
|
||||||
self:Route()
|
self:__Route( 0.5 )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -435,8 +435,7 @@ function AI_A2A_CAP:onafterEngage( AIGroup, From, Event, To, AttackSetUnit )
|
|||||||
|
|
||||||
if #AttackTasks == 0 then
|
if #AttackTasks == 0 then
|
||||||
self:E("No targets found -> Going back to Patrolling")
|
self:E("No targets found -> Going back to Patrolling")
|
||||||
self:Abort()
|
self:__Abort( 0.5 )
|
||||||
self:Route()
|
|
||||||
else
|
else
|
||||||
AttackTasks[#AttackTasks+1] = AIGroup:TaskFunction( 1, #AttackTasks, "AI_A2A_CAP.AttackRoute" )
|
AttackTasks[#AttackTasks+1] = AIGroup:TaskFunction( 1, #AttackTasks, "AI_A2A_CAP.AttackRoute" )
|
||||||
EngageRoute[1].task = AIGroup:TaskCombo( AttackTasks )
|
EngageRoute[1].task = AIGroup:TaskCombo( AttackTasks )
|
||||||
@@ -450,8 +449,7 @@ function AI_A2A_CAP:onafterEngage( AIGroup, From, Event, To, AttackSetUnit )
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
self:E("No targets found -> Going back to Patrolling")
|
self:E("No targets found -> Going back to Patrolling")
|
||||||
self:Abort()
|
self:__Abort( 0.5 )
|
||||||
self:Route()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1035,7 +1035,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
self.Defenders = self.Defenders or {}
|
self.Defenders = self.Defenders or {}
|
||||||
local DefenderName = Defender:GetName()
|
local DefenderName = Defender:GetName()
|
||||||
self.Defenders[ DefenderName ] = Squadron
|
self.Defenders[ DefenderName ] = Squadron
|
||||||
Squadron.Resources = Squadron.Resources - 1
|
Squadron.Resources = Squadron.Resources - Defender:GetSize()
|
||||||
self:F( { DefenderName = DefenderName, SquadronResources = Squadron.Resources } )
|
self:F( { DefenderName = DefenderName, SquadronResources = Squadron.Resources } )
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1043,7 +1043,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
function AI_A2A_DISPATCHER:RemoveDefenderFromSquadron( Squadron, Defender )
|
function AI_A2A_DISPATCHER:RemoveDefenderFromSquadron( Squadron, Defender )
|
||||||
self.Defenders = self.Defenders or {}
|
self.Defenders = self.Defenders or {}
|
||||||
local DefenderName = Defender:GetName()
|
local DefenderName = Defender:GetName()
|
||||||
Squadron.Resources = Squadron.Resources + 1
|
Squadron.Resources = Squadron.Resources + Defender:GetSize()
|
||||||
self.Defenders[ DefenderName ] = nil
|
self.Defenders[ DefenderName ] = nil
|
||||||
self:F( { DefenderName = DefenderName, SquadronResources = Squadron.Resources } )
|
self:F( { DefenderName = DefenderName, SquadronResources = Squadron.Resources } )
|
||||||
end
|
end
|
||||||
@@ -1312,15 +1312,28 @@ do -- AI_A2A_DISPATCHER
|
|||||||
self:SetDefenderTask( DefenderGCI, "GCI", Fsm, Target )
|
self:SetDefenderTask( DefenderGCI, "GCI", Fsm, Target )
|
||||||
|
|
||||||
|
|
||||||
function Fsm:onafterRTB( AIGroup, From, Event, To )
|
function Fsm:onafterRTB( Defender, From, Event, To )
|
||||||
self:F({"GCI RTB"})
|
self:F({"GCI RTB"})
|
||||||
self:GetParent(self).onafterRTB( self, AIGroup, From, Event, To )
|
self:GetParent(self).onafterRTB( self, Defender, From, Event, To )
|
||||||
|
|
||||||
local Dispatcher = self:GetDispatcher() -- #AI_A2A_DISPATCHER
|
local Dispatcher = self:GetDispatcher() -- #AI_A2A_DISPATCHER
|
||||||
local AIGroup = self:GetControllable()
|
local AIGroup = self:GetControllable()
|
||||||
Dispatcher:ClearDefenderTaskTarget( AIGroup )
|
Dispatcher:ClearDefenderTaskTarget( AIGroup )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @param #AI_A2A_DISPATCHER self
|
||||||
|
function Fsm:onafterHome( Defender, From, Event, To )
|
||||||
|
self:F({"GCI Home"})
|
||||||
|
self:GetParent(self).onafterHome( self, Defender, From, Event, To )
|
||||||
|
|
||||||
|
local Dispatcher = self:GetDispatcher() -- #AI_A2A_DISPATCHER
|
||||||
|
local AIGroup = self:GetControllable()
|
||||||
|
local Squadron = self:GetSquadronFromDefender( Defender )
|
||||||
|
if self:GetSquadronLanding( Squadron.Name ) == AI_A2A_DISPATCHER.Landing.NearAirbase then
|
||||||
|
Dispatcher:RemoveDefenderFromSquadron( Squadron, Defender )
|
||||||
|
Defender:Destroy()
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1457,7 +1470,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
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
|
||||||
Report:Add( string.format( " - %s ( %s - %s )", Defender:GetName(), DefenderTask.Type, DefenderTask.Fsm:GetState() ) )
|
Report:Add( string.format( " - %s ( %s - %s ) %s", Defender:GetName(), DefenderTask.Type, DefenderTask.Fsm:GetState(), Defender:HasTask() == true and "Executing" or "Idle" ) )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ function AI_A2A_GCI.InterceptRoute( AIControllable )
|
|||||||
|
|
||||||
AIControllable:T( "NewEngageRoute" )
|
AIControllable:T( "NewEngageRoute" )
|
||||||
local EngageZone = AIControllable:GetState( AIControllable, "EngageZone" ) -- AI.AI_Cap#AI_A2A_GCI
|
local EngageZone = AIControllable:GetState( AIControllable, "EngageZone" ) -- AI.AI_Cap#AI_A2A_GCI
|
||||||
EngageZone:Engage()
|
EngageZone:__Engage( 0.5 )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_A2A_GCI self
|
--- @param #AI_A2A_GCI self
|
||||||
@@ -338,7 +338,7 @@ end
|
|||||||
function AI_A2A_GCI:onafterAbort( AIGroup, From, Event, To )
|
function AI_A2A_GCI:onafterAbort( AIGroup, From, Event, To )
|
||||||
AIGroup:ClearTasks()
|
AIGroup:ClearTasks()
|
||||||
self:Return()
|
self:Return()
|
||||||
self:RTB()
|
self:__RTB( 0.5 )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -405,7 +405,7 @@ function AI_A2A_GCI:onafterEngage( AIGroup, From, Event, To, AttackSetUnit )
|
|||||||
if #AttackTasks == 0 then
|
if #AttackTasks == 0 then
|
||||||
self:E("No targets found -> Going RTB")
|
self:E("No targets found -> Going RTB")
|
||||||
self:Return()
|
self:Return()
|
||||||
self:RTB()
|
self:__RTB( 0.5 )
|
||||||
else
|
else
|
||||||
AttackTasks[#AttackTasks+1] = AIGroup:TaskFunction( 1, #AttackTasks, "AI_A2A_GCI.InterceptRoute" )
|
AttackTasks[#AttackTasks+1] = AIGroup:TaskFunction( 1, #AttackTasks, "AI_A2A_GCI.InterceptRoute" )
|
||||||
EngageRoute[1].task = AIGroup:TaskCombo( AttackTasks )
|
EngageRoute[1].task = AIGroup:TaskCombo( AttackTasks )
|
||||||
@@ -421,7 +421,7 @@ function AI_A2A_GCI:onafterEngage( AIGroup, From, Event, To, AttackSetUnit )
|
|||||||
else
|
else
|
||||||
self:E("No targets found -> Going RTB")
|
self:E("No targets found -> Going RTB")
|
||||||
self:Return()
|
self:Return()
|
||||||
self:RTB()
|
self:__RTB( 0.5 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -352,6 +352,24 @@ function CONTROLLABLE:SetTask( DCSTask, WaitTime )
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Checking the Task Queue of the controllable. Returns false if no task is on the queue. true if there is a task.
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @return Wrapper.Controllable#CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:HasTask() --R2.2
|
||||||
|
|
||||||
|
local HasTaskResult = false
|
||||||
|
|
||||||
|
local DCSControllable = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSControllable then
|
||||||
|
|
||||||
|
local Controller = self:_GetController()
|
||||||
|
HasTaskResult = Controller:hasTask()
|
||||||
|
end
|
||||||
|
|
||||||
|
return HasTaskResult
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Return a condition section for a controlled task.
|
--- Return a condition section for a controlled task.
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
|
|||||||
Reference in New Issue
Block a user