Progress on AI_CAS_ZONE and AI_PATROL_ZONE rework.

This commit is contained in:
FlightControl 2017-01-15 11:11:58 +01:00
parent e552e70e2a
commit 6d5655e56a
19 changed files with 536 additions and 61600 deletions

View File

@ -95,34 +95,12 @@ function AI_CAS_ZONE:New( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude
-- Inherits from BASE
local self = BASE:Inherit( self, AI_PATROLZONE:New( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed ) ) -- #AI_CAS_ZONE
self.PatrolZone = PatrolZone
self.PatrolFloorAltitude = PatrolFloorAltitude
self.PatrolCeilingAltitude = PatrolCeilingAltitude
self.PatrolMinSpeed = PatrolMinSpeed
self.PatrolMaxSpeed = PatrolMaxSpeed
self.EngageZone = EngageZone
self.Accomplished = false
do self:AddTransition( { "Patrol", "Route", "Engaging" }, "Engage", "Engaging" ) -- FSM_CONTROLLABLE Transition for type #AI_CAS_ZONE.
self:AddTransition( { "Patrolling", "Engaging" }, "Engage", "Engaging" ) -- FSM_CONTROLLABLE Transition for type #AI_CAS_ZONE.
--- OnLeave State Transition for Holding.
-- @function [parent=#AI_CAS_ZONE] OnLeaveHolding
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnEnter State Transition for Engaging.
-- @function [parent=#AI_CAS_ZONE] OnEnterEngaging
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- OnBefore State Transition for Engage.
--- OnBefore Transition Handler for Event Engage.
-- @function [parent=#AI_CAS_ZONE] OnBeforeEngage
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
@ -131,7 +109,7 @@ function AI_CAS_ZONE:New( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnAfter State Transition for Engage.
--- OnAfter Transition Handler for Event Engage.
-- @function [parent=#AI_CAS_ZONE] OnAfterEngage
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
@ -139,38 +117,35 @@ function AI_CAS_ZONE:New( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- Embedded Event Trigger for Engage.
--- Synchronous Event Trigger for Event Engage.
-- @function [parent=#AI_CAS_ZONE] Engage
-- @param #AI_CAS_ZONE self
--- Delayed Event Trigger for Engage
--- Asynchronous Event Trigger for Event Engage.
-- @function [parent=#AI_CAS_ZONE] __Engage
-- @param #AI_CAS_ZONE self
-- @param #number Delay The delay in seconds.
end -- AI_CAS_ZONE
--- OnLeave Transition Handler for State Engaging.
-- @function [parent=#AI_CAS_ZONE] OnLeaveEngaging
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnEnter Transition Handler for State Engaging.
-- @function [parent=#AI_CAS_ZONE] OnEnterEngaging
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
do self:AddTransition( "Engaging", "Fired", "Engaging" ) -- FSM_CONTROLLABLE Transition for type #AI_CAS_ZONE.
self:AddTransition( "Engaging", "Fired", "Engaging" ) -- FSM_CONTROLLABLE Transition for type #AI_CAS_ZONE.
--- OnLeave State Transition for Engaging.
-- @function [parent=#AI_CAS_ZONE] OnLeaveEngaging
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnEnter State Transition for Engaging.
-- @function [parent=#AI_CAS_ZONE] OnEnterEngaging
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- OnBefore State Transition for Fired.
--- OnBefore Transition Handler for Event Fired.
-- @function [parent=#AI_CAS_ZONE] OnBeforeFired
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
@ -179,46 +154,26 @@ function AI_CAS_ZONE:New( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnAfter State Transition for Fired.
--- OnAfter Transition Handler for Event Fired.
-- @function [parent=#AI_CAS_ZONE] OnAfterFired
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean
--- Embedded Event Trigger for Fired.
--- Synchronous Event Trigger for Event Fired.
-- @function [parent=#AI_CAS_ZONE] Fired
-- @param #AI_CAS_ZONE self
--- Delayed Event Trigger for Fired
--- Asynchronous Event Trigger for Event Fired.
-- @function [parent=#AI_CAS_ZONE] __Fired
-- @param #AI_CAS_ZONE self
-- @param #number Delay The delay in seconds.
end -- AI_CAS_ZONE
self:AddTransition( "*", "Destroy", "*" ) -- FSM_CONTROLLABLE Transition for type #AI_CAS_ZONE.
do self:AddTransition( "Engaging", "Destroy", "Engaging" ) -- FSM_CONTROLLABLE Transition for type #AI_CAS_ZONE.
--- OnLeave State Transition for Engaging.
-- @function [parent=#AI_CAS_ZONE] OnLeaveEngaging
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnEnter State Transition for Engaging.
-- @function [parent=#AI_CAS_ZONE] OnEnterEngaging
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- OnBefore State Transition for Destroy.
--- OnBefore Transition Handler for Event Destroy.
-- @function [parent=#AI_CAS_ZONE] OnBeforeDestroy
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
@ -227,7 +182,7 @@ function AI_CAS_ZONE:New( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnAfter State Transition for Destroy.
--- OnAfter Transition Handler for Event Destroy.
-- @function [parent=#AI_CAS_ZONE] OnAfterDestroy
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
@ -235,37 +190,19 @@ function AI_CAS_ZONE:New( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- Embedded Event Trigger for Destroy.
--- Synchronous Event Trigger for Event Destroy.
-- @function [parent=#AI_CAS_ZONE] Destroy
-- @param #AI_CAS_ZONE self
--- Delayed Event Trigger for Destroy
--- Asynchronous Event Trigger for Event Destroy.
-- @function [parent=#AI_CAS_ZONE] __Destroy
-- @param #AI_CAS_ZONE self
-- @param #number Delay The delay in seconds.
end -- AI_CAS_ZONE
do self:AddTransition( "Engaging", "Abort", "Patrol" ) -- FSM_CONTROLLABLE Transition for type #AI_CAS_ZONE.
self:AddTransition( "Engaging", "Abort", "Patrolling" ) -- FSM_CONTROLLABLE Transition for type #AI_CAS_ZONE.
--- OnLeave State Transition for Engaging.
-- @function [parent=#AI_CAS_ZONE] OnLeaveEngaging
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnEnter State Transition for Patrol.
-- @function [parent=#AI_CAS_ZONE] OnEnterPatrol
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- OnBefore State Transition for Abort.
--- OnBefore Transition Handler for Event Abort.
-- @function [parent=#AI_CAS_ZONE] OnBeforeAbort
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
@ -274,7 +211,7 @@ do self:AddTransition( "Engaging", "Abort", "Patrol" ) -- FSM_CONTROLLABLE Trans
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnAfter State Transition for Abort.
--- OnAfter Transition Handler for Event Abort.
-- @function [parent=#AI_CAS_ZONE] OnAfterAbort
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
@ -282,22 +219,19 @@ do self:AddTransition( "Engaging", "Abort", "Patrol" ) -- FSM_CONTROLLABLE Trans
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- Embedded Event Trigger for Abort.
--- Synchronous Event Trigger for Event Abort.
-- @function [parent=#AI_CAS_ZONE] Abort
-- @param #AI_CAS_ZONE self
--- Delayed Event Trigger for Abort
--- Asynchronous Event Trigger for Event Abort.
-- @function [parent=#AI_CAS_ZONE] __Abort
-- @param #AI_CAS_ZONE self
-- @param #number Delay The delay in seconds.
end -- AI_CAS_ZONE
self:AddTransition( "Engaging", "Accomplish", "Patrolling" ) -- FSM_CONTROLLABLE Transition for type #AI_CAS_ZONE.
do self:AddTransition( "Engaging", "Completed", "Patrol" ) -- FSM_CONTROLLABLE Transition for type #AI_CAS_ZONE.
--- OnLeave State Transition for Engaging.
-- @function [parent=#AI_CAS_ZONE] OnLeaveEngaging
--- OnBefore Transition Handler for Event Accomplish.
-- @function [parent=#AI_CAS_ZONE] OnBeforeAccomplish
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
@ -305,42 +239,23 @@ end -- AI_CAS_ZONE
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnEnter State Transition for Patrol.
-- @function [parent=#AI_CAS_ZONE] OnEnterPatrol
--- OnAfter Transition Handler for Event Accomplish.
-- @function [parent=#AI_CAS_ZONE] OnAfterAccomplish
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- OnBefore State Transition for Completed.
-- @function [parent=#AI_CAS_ZONE] OnBeforeCompleted
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnAfter State Transition for Completed.
-- @function [parent=#AI_CAS_ZONE] OnAfterCompleted
-- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- Embedded Event Trigger for Completed.
-- @function [parent=#AI_CAS_ZONE] Completed
--- Synchronous Event Trigger for Event Accomplish.
-- @function [parent=#AI_CAS_ZONE] Accomplish
-- @param #AI_CAS_ZONE self
--- Delayed Event Trigger for Completed
-- @function [parent=#AI_CAS_ZONE] __Completed
--- Asynchronous Event Trigger for Event Accomplish.
-- @function [parent=#AI_CAS_ZONE] __Accomplish
-- @param #AI_CAS_ZONE self
-- @param #number Delay The delay in seconds.
end -- AI_CAS_ZONE
return self
end
@ -354,15 +269,14 @@ end
function AI_CAS_ZONE:onafterStart( Controllable, From, Event, To )
if Controllable:IsAlive() then
self:__Route( 1 )
end
self:Route()
self:__Status( 30 ) -- Check status status every 30 seconds.
self:__Detect( 30, self.EngageZone ) -- Detect for new targets every 30 seconds in the EngageZone.
self:EventOnDead( self.OnDead )
Controllable:OptionROEHoldFire()
Controllable:OptionROTVertical()
end
--- @param Wrapper.Controllable#CONTROLLABLE AIControllable
@ -373,6 +287,18 @@ function _NewEngageRoute( AIControllable )
EngageZone:__Engage( 1 )
end
--- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
function AI_CAS_ZONE:onbeforeEngage( Controllable, From, Event, To )
if self.Accomplished == true then
return false
end
end
--- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
@ -383,8 +309,28 @@ function AI_CAS_ZONE:onafterEngage( Controllable, From, Event, To )
if Controllable:IsAlive() then
self:Detect( self.EngageZone )
local EngageRoute = {}
--- Calculate the current route point.
local CurrentVec2 = self.Controllable:GetVec2()
--TODO: Create GetAltitude function for GROUP, and delete GetUnit(1).
local CurrentAltitude = self.Controllable:GetUnit(1):GetAltitude()
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
local ToEngageZoneSpeed = self.PatrolMaxSpeed
local CurrentRoutePoint = CurrentPointVec3:RoutePointAir(
POINT_VEC3.RoutePointAltType.BARO,
POINT_VEC3.RoutePointType.TurningPoint,
POINT_VEC3.RoutePointAction.TurningPoint,
ToEngageZoneSpeed,
true
)
EngageRoute[#EngageRoute+1] = CurrentRoutePoint
if self.Controllable:IsNotInZone( self.EngageZone ) then
-- Find a random 2D point in EngageZone.
@ -435,7 +381,7 @@ function AI_CAS_ZONE:onafterEngage( Controllable, From, Event, To )
true
)
ToTargetPointVec3:SmokeRed()
ToTargetPointVec3:SmokeBlue()
EngageRoute[#EngageRoute+1] = ToTargetRoutePoint
@ -445,21 +391,16 @@ function AI_CAS_ZONE:onafterEngage( Controllable, From, Event, To )
local AttackTasks = {}
local DetectedTargets = Controllable:GetDetectedTargets()
for TargetID, Target in pairs( DetectedTargets ) do
local TargetObject = Target.object
self:T( TargetObject )
if TargetObject and TargetObject:isExist() and TargetObject.id_ < 50000000 then
local TargetUnit = UNIT:Find( TargetObject )
local TargetUnitName = TargetUnit:GetName()
if TargetUnit:IsInZone( self.EngageZone ) then
self:E( {"Engaging ", TargetUnit } )
--local EngageTask = Controllable:EnRouteTaskEngageUnit( TargetUnit, 1 )
AttackTasks[#AttackTasks+1] = Controllable:TaskAttackUnit( TargetUnit )
for DetectedUnitID, DetectedUnit in pairs( self.DetectedUnits ) do
local DetectedUnit = DetectedUnit -- Wrapper.Unit#UNIT
self:T( DetectedUnit )
if DetectedUnit:IsAlive() then
if DetectedUnit:IsInZone( self.EngageZone ) then
self:E( {"Engaging ", DetectedUnit } )
AttackTasks[#AttackTasks+1] = Controllable:TaskAttackUnit( DetectedUnit )
end
else
self.DetectedUnits[DetectedUnit] = nil
end
end
@ -474,7 +415,7 @@ function AI_CAS_ZONE:onafterEngage( Controllable, From, Event, To )
self.Controllable:WayPointFunction( #EngageRoute, 1, "_NewEngageRoute" )
--- NOW ROUTE THE GROUP!
self.Controllable:WayPointExecute( 1, 5 )
self.Controllable:WayPointExecute( 1, 2 )
end
end
@ -483,11 +424,35 @@ end
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
function AI_CAS_ZONE:onafterDestroy( Controllable, From, Event, To )
-- @param Core.Event#EVENTDATA EventData
function AI_CAS_ZONE:onafterDestroy( Controllable, From, Event, To, EventData )
if EventData.IniUnit then
self.DetectedUnits[EventData.IniUnit] = nil
end
Controllable:MessageToAll( "Destroyed a target", 15 , "Destroyed!" )
end
--- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
function AI_CAS_ZONE:onafterRTB( Controllable, From, Event, To, EventData )
self.CheckStatus = false
end
--- @param #AI_CAS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
function AI_CAS_ZONE:onafterAccomplish( Controllable, From, Event, To )
self.Accomplished = true
self.DetectUnits = false
end
--- @param #AI_CAS_ZONE self
-- @param Core.Event#EVENTDATA EventData
function AI_CAS_ZONE:OnDead( EventData )

View File

@ -140,6 +140,7 @@
-- @field Dcs.DCSTypes#Altitude PatrolCeilingAltitude The highest altitude in meters where to execute the patrol.
-- @field Dcs.DCSTypes#Speed PatrolMinSpeed The minimum speed of the @{Controllable} in km/h.
-- @field Dcs.DCSTypes#Speed PatrolMaxSpeed The maximum speed of the @{Controllable} in km/h.
-- @field Functional.Spawn#SPAWN CoordTest
-- @extends Core.Fsm#FSM_CONTROLLABLE
AI_PATROLZONE = {
ClassName = "AI_PATROLZONE",
@ -172,198 +173,188 @@ function AI_PATROLZONE:New( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitu
self.PatrolMinSpeed = PatrolMinSpeed
self.PatrolMaxSpeed = PatrolMaxSpeed
self.PatrolFuelTresholdPercentage = 0.2
self.DetectUnits = true
self.CheckStatus = true
self.DetectedUnits = {} -- This table contains the targets detected during patrol.
self.PatrolFuelTresholdPercentage = 0.2
self:SetStartState( "None" )
do self:AddTransition( "*", "Start", "Route" ) -- FSM_CONTROLLABLE Transition for type #AI_PATROLZONE.
self:AddTransition( "None", "Start", "Patrolling" )
--- OnLeave State Transition for Route.
-- @function [parent=#AI_PATROLZONE] OnLeaveRoute
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnBefore Transition Handler for Event Start.
-- @function [parent=#AI_PATROLZONE] OnBeforeStart
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnEnter State Transition for Route.
-- @function [parent=#AI_PATROLZONE] OnEnterRoute
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- OnAfter Transition Handler for Event Start.
-- @function [parent=#AI_PATROLZONE] OnAfterStart
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- OnBefore State Transition for Start.
-- @function [parent=#AI_PATROLZONE] OnBeforeStart
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- Synchronous Event Trigger for Event Start.
-- @function [parent=#AI_PATROLZONE] Start
-- @param #AI_PATROLZONE self
--- OnAfter State Transition for Start.
-- @function [parent=#AI_PATROLZONE] OnAfterStart
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- Asynchronous Event Trigger for Event Start.
-- @function [parent=#AI_PATROLZONE] __Start
-- @param #AI_PATROLZONE self
-- @param #number Delay The delay in seconds.
--- Embedded Event Trigger for Start.
-- @function [parent=#AI_PATROLZONE] Start
-- @param #AI_PATROLZONE self
--- OnLeave Transition Handler for State Patrolling.
-- @function [parent=#AI_PATROLZONE] OnLeavePatrolling
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- Delayed Event Trigger for Start
-- @function [parent=#AI_PATROLZONE] __Start
-- @param #AI_PATROLZONE self
-- @param #number Delay The delay in seconds.
--- OnEnter Transition Handler for State Patrolling.
-- @function [parent=#AI_PATROLZONE] OnEnterPatrolling
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
end -- AI_PATROLZONE
self:AddTransition( "Patrolling", "Route", "Patrolling" ) -- FSM_CONTROLLABLE Transition for type #AI_PATROLZONE.
do self:AddTransition( "*", "Route", "Route" ) -- FSM_CONTROLLABLE Transition for type #AI_PATROLZONE.
--- OnBefore Transition Handler for Event Route.
-- @function [parent=#AI_PATROLZONE] OnBeforeRoute
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnLeave State Transition for Route.
-- @function [parent=#AI_PATROLZONE] OnLeaveRoute
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnAfter Transition Handler for Event Route.
-- @function [parent=#AI_PATROLZONE] OnAfterRoute
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- OnEnter State Transition for Route.
-- @function [parent=#AI_PATROLZONE] OnEnterRoute
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- Synchronous Event Trigger for Event Route.
-- @function [parent=#AI_PATROLZONE] Route
-- @param #AI_PATROLZONE self
--- OnBefore State Transition for Route.
-- @function [parent=#AI_PATROLZONE] OnBeforeRoute
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- Asynchronous Event Trigger for Event Route.
-- @function [parent=#AI_PATROLZONE] __Route
-- @param #AI_PATROLZONE self
-- @param #number Delay The delay in seconds.
--- OnAfter State Transition for Route.
-- @function [parent=#AI_PATROLZONE] OnAfterRoute
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
self:AddTransition( "*", "Status", "*" ) -- FSM_CONTROLLABLE Transition for type #AI_PATROLZONE.
--- Embedded Event Trigger for Route.
-- @function [parent=#AI_PATROLZONE] Route
-- @param #AI_PATROLZONE self
--- OnBefore Transition Handler for Event Status.
-- @function [parent=#AI_PATROLZONE] OnBeforeStatus
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- Delayed Event Trigger for Route
-- @function [parent=#AI_PATROLZONE] __Route
-- @param #AI_PATROLZONE self
-- @param #number Delay The delay in seconds.
--- OnAfter Transition Handler for Event Status.
-- @function [parent=#AI_PATROLZONE] OnAfterStatus
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
end -- AI_PATROLZONE
--- Synchronous Event Trigger for Event Status.
-- @function [parent=#AI_PATROLZONE] Status
-- @param #AI_PATROLZONE self
do self:AddTransition( "*", "Patrol", "Patrol" ) -- FSM_CONTROLLABLE Transition for type #AI_PATROLZONE.
--- Asynchronous Event Trigger for Event Status.
-- @function [parent=#AI_PATROLZONE] __Status
-- @param #AI_PATROLZONE self
-- @param #number Delay The delay in seconds.
--- OnLeave State Transition for Patrol.
-- @function [parent=#AI_PATROLZONE] OnLeavePatrol
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
self:AddTransition( "*", "Detect", "*" ) -- FSM_CONTROLLABLE Transition for type #AI_PATROLZONE.
--- OnEnter State Transition for Patrol.
-- @function [parent=#AI_PATROLZONE] OnEnterPatrol
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- OnBefore Transition Handler for Event Detect.
-- @function [parent=#AI_PATROLZONE] OnBeforeDetect
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnBefore State Transition for Patrol.
-- @function [parent=#AI_PATROLZONE] OnBeforePatrol
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnAfter Transition Handler for Event Detect.
-- @function [parent=#AI_PATROLZONE] OnAfterDetect
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- OnAfter State Transition for Patrol.
-- @function [parent=#AI_PATROLZONE] OnAfterPatrol
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- Synchronous Event Trigger for Event Detect.
-- @function [parent=#AI_PATROLZONE] Detect
-- @param #AI_PATROLZONE self
--- Embedded Event Trigger for Patrol.
-- @function [parent=#AI_PATROLZONE] Patrol
-- @param #AI_PATROLZONE self
--- Asynchronous Event Trigger for Event Detect.
-- @function [parent=#AI_PATROLZONE] __Detect
-- @param #AI_PATROLZONE self
-- @param #number Delay The delay in seconds.
--- Delayed Event Trigger for Patrol
-- @function [parent=#AI_PATROLZONE] __Patrol
-- @param #AI_PATROLZONE self
-- @param #number Delay The delay in seconds.
self:AddTransition( "*", "RTB", "RTB" ) -- FSM_CONTROLLABLE Transition for type #AI_PATROLZONE.
end -- AI_PATROLZONE
--- OnBefore Transition Handler for Event RTB.
-- @function [parent=#AI_PATROLZONE] OnBeforeRTB
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
do self:AddTransition( "Patrol", "RTB", "RTB" ) -- FSM_CONTROLLABLE Transition for type #AI_PATROLZONE.
--- OnAfter Transition Handler for Event RTB.
-- @function [parent=#AI_PATROLZONE] OnAfterRTB
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- OnLeave State Transition for Patrol.
-- @function [parent=#AI_PATROLZONE] OnLeavePatrol
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- Synchronous Event Trigger for Event RTB.
-- @function [parent=#AI_PATROLZONE] RTB
-- @param #AI_PATROLZONE self
--- OnEnter State Transition for RTB.
-- @function [parent=#AI_PATROLZONE] OnEnterRTB
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- Asynchronous Event Trigger for Event RTB.
-- @function [parent=#AI_PATROLZONE] __RTB
-- @param #AI_PATROLZONE self
-- @param #number Delay The delay in seconds.
--- OnBefore State Transition for RTB.
-- @function [parent=#AI_PATROLZONE] OnBeforeRTB
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnLeave Transition Handler for State Returning.
-- @function [parent=#AI_PATROLZONE] OnLeaveReturning
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
-- @return #boolean Return false to cancel Transition.
--- OnAfter State Transition for RTB.
-- @function [parent=#AI_PATROLZONE] OnAfterRTB
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
--- Embedded Event Trigger for RTB.
-- @function [parent=#AI_PATROLZONE] RTB
-- @param #AI_PATROLZONE self
--- Delayed Event Trigger for RTB
-- @function [parent=#AI_PATROLZONE] __RTB
-- @param #AI_PATROLZONE self
-- @param #number Delay The delay in seconds.
end -- AI_PATROLZONE
--- OnEnter Transition Handler for State Returning.
-- @function [parent=#AI_PATROLZONE] OnEnterReturning
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
return self
end
@ -399,14 +390,6 @@ end
--- @param Wrapper.Controllable#CONTROLLABLE AIControllable
function _NewPatrolRoute( AIControllable )
AIControllable:T( "NewPatrolRoute" )
local PatrolZone = AIControllable:GetState( AIControllable, "PatrolZone" ) -- PatrolCore.Zone#AI_PATROLZONE
PatrolZone:__Route( 1 )
end
@ -430,29 +413,102 @@ end
--- Defines a new patrol route using the @{Process_PatrolZone} parameters and settings.
-- @param #AI_PATROLZONE self
-- @return #AI_PATROLZONE self
function AI_PATROLZONE:onenterRoute()
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
function AI_PATROLZONE:onafterStart( Controllable, From, Event, To )
self:F2()
self:Route() -- Route to the patrol point.
self:__Status( 30 ) -- Check status status every 30 seconds.
self:__Detect( 30 ) -- Detect for new targets every 30 seconds.
Controllable:OptionROEHoldFire()
Controllable:OptionROTVertical()
end
--- @param #AI_PATROLZONE self
--- @param Wrapper.Controllable#CONTROLLABLE Controllable
function AI_PATROLZONE:onbeforeDetect( Controllable, From, Event, To, DetectZone )
return self.DetectUnits
end
--- @param #AI_PATROLZONE self
--- @param Wrapper.Controllable#CONTROLLABLE Controllable
function AI_PATROLZONE:onafterDetect( Controllable, From, Event, To, DetectZone )
local DetectedTargets = Controllable:GetDetectedTargets()
for TargetID, Target in pairs( DetectedTargets ) do
local TargetObject = Target.object
self:T( TargetObject )
if TargetObject and TargetObject:isExist() and TargetObject.id_ < 50000000 then
local TargetUnit = UNIT:Find( TargetObject )
local TargetUnitName = TargetUnit:GetName()
if DetectZone then
if TargetUnit:IsInZone( DetectZone ) then
self:T( {"Detected ", TargetUnit } )
self.DetectedUnits[TargetUnit] = TargetUnit
end
else
self.DetectedUnits[TargetUnit] = TargetUnit
end
end
end
end
--- @param Wrapper.Controllable#CONTROLLABLE AIControllable
function _NewPatrolRoute( AIControllable )
AIControllable:T( "NewPatrolRoute" )
local PatrolZone = AIControllable:GetState( AIControllable, "PatrolZone" ) -- PatrolCore.Zone#AI_PATROLZONE
PatrolZone:Route()
end
--- Defines a new patrol route using the @{Process_PatrolZone} parameters and settings.
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
-- @param #string From The From State string.
-- @param #string Event The Event string.
-- @param #string To The To State string.
function AI_PATROLZONE:onafterRoute( Controllable, From, Event, To )
self:F2()
-- When RTB, don't allow anymore the routing.
if From == "RTB" then
return
end
local PatrolRoute = {}
if self.Controllable:IsAlive() then
--- Determine if the AIControllable is within the PatrolZone.
-- If not, make a waypoint within the to that the AIControllable will fly at maximum speed to that point.
-- --- Calculate the current route point.
-- local CurrentVec2 = self.Controllable:GetVec2()
-- local CurrentAltitude = self.Controllable:GetUnit(1):GetAltitude()
-- local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
-- local CurrentRoutePoint = CurrentPointVec3:RoutePointAir(
-- POINT_VEC3.RoutePointAltType.BARO,
-- POINT_VEC3.RoutePointType.TurningPoint,
-- POINT_VEC3.RoutePointAction.TurningPoint,
-- ToPatrolZoneSpeed,
-- true
-- )
--
-- PatrolRoute[#PatrolRoute+1] = CurrentRoutePoint
--- Calculate the current route point.
local CurrentVec2 = self.Controllable:GetVec2()
--TODO: Create GetAltitude function for GROUP, and delete GetUnit(1).
local CurrentAltitude = self.Controllable:GetUnit(1):GetAltitude()
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
local ToPatrolZoneSpeed = self.PatrolMaxSpeed
local CurrentRoutePoint = CurrentPointVec3:RoutePointAir(
POINT_VEC3.RoutePointAltType.BARO,
POINT_VEC3.RoutePointType.TurningPoint,
POINT_VEC3.RoutePointAction.TurningPoint,
ToPatrolZoneSpeed,
true
)
PatrolRoute[#PatrolRoute+1] = CurrentRoutePoint
self:T2( PatrolRoute )
@ -505,7 +561,9 @@ function AI_PATROLZONE:onenterRoute()
true
)
--ToTargetPointVec3:SmokeRed()
--self.CoordTest:SpawnFromVec3( ToTargetPointVec3:GetVec3() )
ToTargetPointVec3:SmokeRed()
PatrolRoute[#PatrolRoute+1] = ToTargetRoutePoint
@ -517,16 +575,19 @@ function AI_PATROLZONE:onenterRoute()
self.Controllable:WayPointFunction( #PatrolRoute, 1, "_NewPatrolRoute" )
--- NOW ROUTE THE GROUP!
self.Controllable:WayPointExecute( 1, 5 )
self:__Patrol( 30 )
self.Controllable:WayPointExecute( 1, 2 )
end
end
--- @param #AI_PATROLZONE self
function AI_PATROLZONE:onbeforeStatus()
return self.CheckStatus
end
--- @param #AI_PATROLZONE self
function AI_PATROLZONE:onenterPatrol()
function AI_PATROLZONE:onafterStatus()
self:F2()
if self.Controllable and self.Controllable:IsAlive() then
@ -542,8 +603,10 @@ function AI_PATROLZONE:onenterPatrol()
self:RTB()
else
self:__Patrol( 30 ) -- Execute the Patrol event after 30 seconds.
self:__Status( 30 ) -- Execute the Patrol event after 30 seconds.
end
self:__Detect( 30 ) -- Detect for new targets every 30 seconds.
end
end

View File

@ -535,15 +535,18 @@ do -- FSM
function FSM._handler( self, EventName, ... )
self:E( { EventName, ... } )
local Can, to = self:can( EventName )
self:E( { From = self.current, Event = EventName, To = to, Can = Can } )
if to == "*" then
to = self.current
end
if Can then
local from = self.current
local params = { from, EventName, to, ... }
self:E( "FSM Transition:" .. self.current .. " --> " .. EventName .. " --> " .. to )
if self:_call_handler("onbefore" .. EventName, params) == false
or self:_call_handler("OnBefore" .. EventName, params) == false
or self:_call_handler("onleave" .. from, params) == false
@ -592,6 +595,9 @@ do -- FSM
self:_call_handler("onstatechange", params)
end
else
self:E( "Cannot execute transition." )
self:E( { From = self.current, Event = EventName, To = to, Can = Can } )
end
return nil
@ -667,7 +673,6 @@ do -- FSM
end
function FSM:can(e)
self:E( { e, self.Events, self.Events[e] } )
local Event = self.Events[e]
self:F3( { self.current, Event } )
local To = Event and Event.map[self.current] or Event.map['*']
@ -736,7 +741,7 @@ do -- FSM_CONTROLLABLE
end
if self[handler] then
self:E( "Calling " .. handler )
self:F3( "Calling " .. handler )
return xpcall( function() return self[handler]( self, self.Controllable, unpack( params ) ) end, ErrorHandler )
--return self[handler]( self, self.Controllable, unpack( params ) )
end

View File

@ -68,10 +68,10 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
if Scheduler.MasterObject then
self.ObjectSchedulers[self.CallID] = Scheduler
self:E( { CallID = self.CallID, ObjectScheduler = tostring(self.ObjectSchedulers[self.CallID]), MasterObject = tostring(Scheduler.MasterObject) } )
self:F3( { CallID = self.CallID, ObjectScheduler = tostring(self.ObjectSchedulers[self.CallID]), MasterObject = tostring(Scheduler.MasterObject) } )
else
self.PersistentSchedulers[self.CallID] = Scheduler
self:E( { CallID = self.CallID, PersistentScheduler = self.PersistentSchedulers[self.CallID] } )
self:F3( { CallID = self.CallID, PersistentScheduler = self.PersistentSchedulers[self.CallID] } )
end
self.Schedule = self.Schedule or setmetatable( {}, { __mode = "k" } )

View File

@ -102,7 +102,7 @@ function SCHEDULER:Schedule( SchedulerObject, SchedulerFunction, SchedulerArgume
if SchedulerObject and SchedulerObject.ClassName and SchedulerObject.ClassID then
ObjectName = SchedulerObject.ClassName .. SchedulerObject.ClassID
end
self:E( { "Schedule :", ObjectName, tostring( SchedulerObject ), Start, Repeat, RandomizeFactor, Stop } )
self:F3( { "Schedule :", ObjectName, tostring( SchedulerObject ), Start, Repeat, RandomizeFactor, Stop } )
self.SchedulerObject = SchedulerObject
local ScheduleID = _SCHEDULEDISPATCHER:AddSchedule(

View File

@ -306,6 +306,10 @@ function CONTROLLABLE:TaskCombo( DCSTasks )
}
}
for TaskID, Task in ipairs( DCSTasks ) do
self:E( Task )
end
self:T3( { DCSTaskCombo } )
return DCSTaskCombo
end
@ -490,22 +494,24 @@ function CONTROLLABLE:TaskAttackUnit( AttackUnit, WeaponType, WeaponExpend, Atta
-- }
local DCSTask
DCSTask = { id = 'AttackUnit',
DCSTask = {
id = 'AttackUnit',
params = {
altitudeEnabled = false,
altitudeEnabled = true,
unitId = AttackUnit:GetID(),
attackQtyLimit = AttackQtyLimit or false,
attackQty = AttackQty or 1,
attackQty = AttackQty or 2,
expend = WeaponExpend or "Auto",
altitude = 2000,
directionEnabled = false,
groupAttack = false,
weaponType = WeaponType or 1073741822,
directionEnabled = true,
groupAttack = true,
--weaponType = WeaponType or 1073741822,
direction = Direction or 0,
},
},
}
}
self:E( DCSTask )
self:E( { DCSTask } )
return DCSTask
end

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -13,25 +13,36 @@ local CASPlane = GROUP:FindByName( "Plane" )
local PatrolZone = ZONE:New( "Patrol Zone" )
local AICasZone = AI_CAS_ZONE:New( PatrolZone, 500, 1000, 350, 600, CASEngagementZone )
local AICasZone = AI_CAS_ZONE:New( PatrolZone, 500, 1000, 500, 600, CASEngagementZone )
local Targets = GROUP:FindByName("Targets")
AICasZone:SetControllable(CASPlane)
AICasZone:__Start(1)
AICasZone:__Engage(10)
AICasZone:__Start( 1 ) -- They should statup, and start patrolling in the PatrolZone.
-- After 5 minutes, engage
AICasZone:__Engage( 600 )
-- Check every 60 seconds whether the Targets have been eliminated.
-- When the trigger completed has been fired, the Plane will go back to the Patrol Zone.
Check = SCHEDULER:New(nil,
Check, CheckScheduleID = SCHEDULER:New(nil,
function()
BASE:E( { "In Scheduler: ", Targets:GetSize() } )
if Targets:IsAlive() and Targets:GetSize() ~= 0 then
if Targets:IsAlive() and Targets:GetSize() > 5 then
BASE:E("Still alive")
else
BASE:E("Destroyed")
AICasZone:__Completed(1)
AICasZone:__Accomplish( 1 ) -- Now they should fly back to teh patrolzone and patrol.
Check:Stop(CheckScheduleID)
end
end, {}, 20, 60, 0.2 )
-- When the targets in the zone are destroyed, (see scheduled function), the planes will return homs...
function AICasZone:OnAfterAccomplish( Controllable, From, Event, To )
AICasZone:__RTB( 1 )
end

Binary file not shown.

Binary file not shown.