Module AI_Cas

AI -- (R2.1) - Manages the independent process of Close Air Support for airplanes.


Banner Image


Demo Missions


YouTube Playlist


Author: FlightControl

Contributions:

  • Quax: Concept, Advice & Testing.
  • Pikey: Concept, Advice & Testing.
  • Gunterlund: Test case revision.

Global(s)

AI_CAS_ZONE

AICASZONE class, extends AI_Patrol#AI_PATROL_ZONE

AICASZONE derives from the AI_Patrol#AI_PATROL_ZONE, inheriting its methods and behaviour.

Type AI_CAS_ZONE

AI_CAS_ZONE.AIControllable

The Controllable patrolling.

AI_CAS_ZONE:Abort()

Synchronous Event Trigger for Event Abort.

AI_CAS_ZONE:Accomplish()

Synchronous Event Trigger for Event Accomplish.

AI_CAS_ZONE.Accomplished
AI_CAS_ZONE:Destroy()

Synchronous Event Trigger for Event Destroy.

AI_CAS_ZONE:Engage(EngageSpeed, EngageAltitude, EngageWeaponExpend, EngageAttackQty, EngageDirection)

Synchronous Event Trigger for Event Engage.

AI_CAS_ZONE.EngageAltitude
AI_CAS_ZONE.EngageAttackQty
AI_CAS_ZONE.EngageDirection
AI_CAS_ZONE.EngageRoute(AI, EngageGroup, Fsm)
AI_CAS_ZONE.EngageSpeed
AI_CAS_ZONE.EngageWeaponExpend
AI_CAS_ZONE.EngageZone
AI_CAS_ZONE:Fired()

Synchronous Event Trigger for Event Fired.

AI_CAS_ZONE:New(PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, EngageZone, PatrolAltType)

Creates a new AICASZONE object

AI_CAS_ZONE:OnAfterAbort(Controllable, From, Event, To)

OnAfter Transition Handler for Event Abort.

AI_CAS_ZONE:OnAfterAccomplish(Controllable, From, Event, To)

OnAfter Transition Handler for Event Accomplish.

AI_CAS_ZONE:OnAfterDestroy(Controllable, From, Event, To)

OnAfter Transition Handler for Event Destroy.

AI_CAS_ZONE:OnAfterEngage(Controllable, From, Event, To)

OnAfter Transition Handler for Event Engage.

AI_CAS_ZONE:OnAfterFired(Controllable, From, Event, To)

OnAfter Transition Handler for Event Fired.

AI_CAS_ZONE:OnBeforeAbort(Controllable, From, Event, To)

OnBefore Transition Handler for Event Abort.

AI_CAS_ZONE:OnBeforeAccomplish(Controllable, From, Event, To)

OnBefore Transition Handler for Event Accomplish.

AI_CAS_ZONE:OnBeforeDestroy(Controllable, From, Event, To)

OnBefore Transition Handler for Event Destroy.

AI_CAS_ZONE:OnBeforeEngage(Controllable, From, Event, To)

OnBefore Transition Handler for Event Engage.

AI_CAS_ZONE:OnBeforeFired(Controllable, From, Event, To)

OnBefore Transition Handler for Event Fired.

AI_CAS_ZONE:OnEnterEngaging(Controllable, From, Event, To)

OnEnter Transition Handler for State Engaging.

AI_CAS_ZONE:OnEventDead(EventData)
AI_CAS_ZONE:OnLeaveEngaging(Controllable, From, Event, To)

OnLeave Transition Handler for State Engaging.

AI_CAS_ZONE:SetEngageZone(EngageZone)

Set the Engage Zone where the AI is performing CAS.

AI_CAS_ZONE.TargetZone

The Zone where the patrol needs to be executed.

AI_CAS_ZONE:__Abort(Delay)

Asynchronous Event Trigger for Event Abort.

AI_CAS_ZONE:__Accomplish(Delay)

Asynchronous Event Trigger for Event Accomplish.

AI_CAS_ZONE:__Destroy(Delay)

Asynchronous Event Trigger for Event Destroy.

AI_CAS_ZONE:__Engage(Delay, EngageSpeed, EngageAltitude, EngageWeaponExpend, EngageAttackQty, EngageDirection)

Asynchronous Event Trigger for Event Engage.

AI_CAS_ZONE:__Fired(Delay)

Asynchronous Event Trigger for Event Fired.

AI_CAS_ZONE:onafterAbort(Controllable, From, Event, To)
AI_CAS_ZONE:onafterAccomplish(Controllable, From, Event, To)
AI_CAS_ZONE:onafterDestroy(Controllable, From, Event, To, EventData)
AI_CAS_ZONE:onafterEngage(Controllable, From, Event, To, EngageSpeed, EngageAltitude, EngageWeaponExpend, EngageAttackQty, EngageDirection)
AI_CAS_ZONE:onafterStart(Controllable, From, Event, To)

onafter State Transition for Event Start.

AI_CAS_ZONE:onafterTarget(Controllable, From, Event, To)
AI_CAS_ZONE:onbeforeEngage(Controllable, From, Event, To)

Global(s)

#AI_CAS_ZONE AI_CAS_ZONE

AICASZONE class, extends AI_Patrol#AI_PATROL_ZONE

AICASZONE derives from the AI_Patrol#AI_PATROL_ZONE, inheriting its methods and behaviour.

The AICASZONE class implements the core functions to provide Close Air Support in an Engage Zone by an AIR Controllable or Group. The AICASZONE runs a process. It holds an AI in a Patrol Zone and when the AI is commanded to engage, it will fly to an Engage Zone.

HoldAndEngage

The AICASZONE is assigned a Group and this must be done before the AICASZONE process can be started through the Start event.

Start Event

Upon started, The AI will Route itself towards the random 3D point within a patrol zone, using a random speed within the given altitude and speed limits. Upon arrival at the 3D point, a new random 3D point will be selected within the patrol zone using the given limits. This cycle will continue until a fuel or damage treshold has been reached by the AI, or when the AI is commanded to RTB.

Route Event

When the AI is commanded to provide Close Air Support (through the event Engage), the AI will fly towards the Engage Zone. Any target that is detected in the Engage Zone will be reported and will be destroyed by the AI.

Engage Event

The AI will detect the targets and will only destroy the targets within the Engage Zone.

Engage Event

Every target that is destroyed, is reported< by the AI.

Engage Event

Note that the AI does not know when the Engage Zone is cleared, and therefore will keep circling in the zone.

Engage Event

Until it is notified through the event Accomplish, which is to be triggered by an observing party:

  • a FAC
  • a timed event
  • a menu option selected by a human
  • a condition
  • others ...

Engage Event

When the AI has accomplished the CAS, it will fly back to the Patrol Zone.

Engage Event

It will keep patrolling there, until it is notified to RTB or move to another CAS Zone. It can be notified to go RTB through the RTB event.

When the fuel treshold has been reached, the airplane will fly towards the nearest friendly airbase and will land.

Engage Event

AICASZONE constructor

AICASZONE is a FSM

Process

2.1. AICASZONE States

  • None ( Group ): The process is not started yet.
  • Patrolling ( Group ): The AI is patrolling the Patrol Zone.
  • Engaging ( Group ): The AI is engaging the targets in the Engage Zone, executing CAS.
  • Returning ( Group ): The AI is returning to Base..

2.2. AICASZONE Events


Type AI_Cas

Type AI_CAS_ZONE

Extends AI.AI_Patrol#AI_PATROL_ZONE

AICASZONE class

Field(s)

Wrapper.Controllable#CONTROLLABLE AI_CAS_ZONE.AIControllable

The Controllable patrolling.

AI_CAS_ZONE:Abort()

Synchronous Event Trigger for Event Abort.

AI_CAS_ZONE:Accomplish()

Synchronous Event Trigger for Event Accomplish.

#boolean AI_CAS_ZONE.Accomplished
AI_CAS_ZONE:Destroy()

Synchronous Event Trigger for Event Destroy.

AI_CAS_ZONE:Engage(EngageSpeed, EngageAltitude, EngageWeaponExpend, EngageAttackQty, EngageDirection)

Synchronous Event Trigger for Event Engage.

Parameters

  • #number EngageSpeed : (optional) The speed the Group will hold when engaging to the target zone.

  • Dcs.DCSTypes#Distance EngageAltitude : (optional) Desired altitude to perform the unit engagement.

  • Dcs.DCSTypes#AI.Task.WeaponExpend EngageWeaponExpend : (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / controllable will choose expend on its own discretion. Use the structure DCSTypes#AI.Task.WeaponExpend to define the amount of weapons to be release at each attack.

  • #number EngageAttackQty : (optional) This parameter limits maximal quantity of attack. The aicraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aicraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo.

  • Dcs.DCSTypes#Azimuth EngageDirection : (optional) Desired ingress direction from the target to the attacking aircraft. Controllable/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain controllable/aircraft will choose another direction.

AI_CAS_ZONE.EngageAltitude
AI_CAS_ZONE.EngageAttackQty
AI_CAS_ZONE.EngageDirection
AI_CAS_ZONE.EngageRoute(AI, EngageGroup, Fsm)

Parameters

AI_CAS_ZONE.EngageSpeed
AI_CAS_ZONE.EngageWeaponExpend
AI_CAS_ZONE.EngageZone
AI_CAS_ZONE:Fired()

Synchronous Event Trigger for Event Fired.

AI_CAS_ZONE:New(PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, EngageZone, PatrolAltType)

Creates a new AICASZONE object

Parameters

Return value

#AI_CAS_ZONE: self

AI_CAS_ZONE:OnAfterAbort(Controllable, From, Event, To)

OnAfter Transition Handler for Event Abort.

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.

AI_CAS_ZONE:OnAfterAccomplish(Controllable, From, Event, To)

OnAfter Transition Handler for Event Accomplish.

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.

AI_CAS_ZONE:OnAfterDestroy(Controllable, From, Event, To)

OnAfter Transition Handler for Event Destroy.

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.

AI_CAS_ZONE:OnAfterEngage(Controllable, From, Event, To)

OnAfter Transition Handler for Event Engage.

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.

AI_CAS_ZONE:OnAfterFired(Controllable, From, Event, To)

OnAfter Transition Handler for Event Fired.

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.

AI_CAS_ZONE:OnBeforeAbort(Controllable, From, Event, To)

OnBefore Transition Handler for Event Abort.

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.

Return value

#boolean: Return false to cancel Transition.

AI_CAS_ZONE:OnBeforeAccomplish(Controllable, From, Event, To)

OnBefore Transition Handler for Event Accomplish.

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.

Return value

#boolean: Return false to cancel Transition.

AI_CAS_ZONE:OnBeforeDestroy(Controllable, From, Event, To)

OnBefore Transition Handler for Event Destroy.

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.

Return value

#boolean: Return false to cancel Transition.

AI_CAS_ZONE:OnBeforeEngage(Controllable, From, Event, To)

OnBefore Transition Handler for Event Engage.

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.

AI_CAS_ZONE:OnBeforeFired(Controllable, From, Event, To)

OnBefore Transition Handler for Event Fired.

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.

Return value

#boolean: Return false to cancel Transition.

AI_CAS_ZONE:OnEnterEngaging(Controllable, From, Event, To)

OnEnter Transition Handler for State Engaging.

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.

AI_CAS_ZONE:OnEventDead(EventData)

Parameter

AI_CAS_ZONE:OnLeaveEngaging(Controllable, From, Event, To)

OnLeave Transition Handler for State Engaging.

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.

Return value

#boolean: Return false to cancel Transition.

AI_CAS_ZONE:SetEngageZone(EngageZone)

Set the Engage Zone where the AI is performing CAS.

Note that if the EngageZone is changed, the AI needs to re-detect targets.

Parameter

  • Core.Zone#ZONE EngageZone : The zone where the AI is performing CAS.

Return value

#AI_CAS_ZONE: self

Core.Zone#ZONE_BASE AI_CAS_ZONE.TargetZone

The Zone where the patrol needs to be executed.

AI_CAS_ZONE:__Abort(Delay)

Asynchronous Event Trigger for Event Abort.

Parameter

  • #number Delay : The delay in seconds.

AI_CAS_ZONE:__Accomplish(Delay)

Asynchronous Event Trigger for Event Accomplish.

Parameter

  • #number Delay : The delay in seconds.

AI_CAS_ZONE:__Destroy(Delay)

Asynchronous Event Trigger for Event Destroy.

Parameter

  • #number Delay : The delay in seconds.

AI_CAS_ZONE:__Engage(Delay, EngageSpeed, EngageAltitude, EngageWeaponExpend, EngageAttackQty, EngageDirection)

Asynchronous Event Trigger for Event Engage.

Parameters

  • #number Delay : The delay in seconds.

  • #number EngageSpeed : (optional) The speed the Group will hold when engaging to the target zone.

  • Dcs.DCSTypes#Distance EngageAltitude : (optional) Desired altitude to perform the unit engagement.

  • Dcs.DCSTypes#AI.Task.WeaponExpend EngageWeaponExpend : (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / controllable will choose expend on its own discretion. Use the structure DCSTypes#AI.Task.WeaponExpend to define the amount of weapons to be release at each attack.

  • #number EngageAttackQty : (optional) This parameter limits maximal quantity of attack. The aicraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aicraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo.

  • Dcs.DCSTypes#Azimuth EngageDirection : (optional) Desired ingress direction from the target to the attacking aircraft. Controllable/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain controllable/aircraft will choose another direction.

AI_CAS_ZONE:__Fired(Delay)

Asynchronous Event Trigger for Event Fired.

Parameter

  • #number Delay : The delay in seconds.

AI_CAS_ZONE:onafterAbort(Controllable, From, Event, To)

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.

AI_CAS_ZONE:onafterAccomplish(Controllable, From, Event, To)

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.

AI_CAS_ZONE:onafterDestroy(Controllable, From, Event, To, EventData)

Parameters

AI_CAS_ZONE:onafterEngage(Controllable, From, Event, To, EngageSpeed, EngageAltitude, EngageWeaponExpend, EngageAttackQty, EngageDirection)

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.

  • #number EngageSpeed : (optional) The speed the Group will hold when engaging to the target zone.

  • Dcs.DCSTypes#Distance EngageAltitude : (optional) Desired altitude to perform the unit engagement.

  • Dcs.DCSTypes#AI.Task.WeaponExpend EngageWeaponExpend : (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / controllable will choose expend on its own discretion.

  • #number EngageAttackQty : (optional) This parameter limits maximal quantity of attack. The aicraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aicraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo.

  • Dcs.DCSTypes#Azimuth EngageDirection : (optional) Desired ingress direction from the target to the attacking aircraft. Controllable/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain controllable/aircraft will choose another direction.

AI_CAS_ZONE:onafterStart(Controllable, From, Event, To)

onafter State Transition for Event Start.

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.

AI_CAS_ZONE:onafterTarget(Controllable, From, Event, To)

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.

AI_CAS_ZONE:onbeforeEngage(Controllable, From, Event, To)

Parameters

  • Wrapper.Controllable#CONTROLLABLE Controllable : The Controllable Object managed by the FSM.

  • #string From : The From State string.

  • #string Event : The Event string.

  • #string To : The To State string.