Module AI_Cas
AI -- Provide Close Air Support to friendly ground troops.
AI CAS classes makes AI Controllables execute a Close Air Support.
There are the following types of CAS classes defined:
- #AICASZONE: Perform a CAS in a zone.
API CHANGE HISTORY
The underlying change log documents the API changes. Please read this carefully. The following notation is used:
- Added parts are expressed in bold type face.
- Removed parts are expressed in italic type face.
Hereby the change log:
2017-01-15: Initial class and API.
AUTHORS and CONTRIBUTIONS
Contributions:
- Quax: Concept, Advice & Testing.
- Pikey: Concept, Advice & Testing.
- Gunterlund: Test case revision.
Authors:
- FlightControl: Concept, Design & Programming.
Global(s)
| AI_CAS_ZONE |
1) #AICASZONE class, extends AIPatrol#AIPATROL_ZONE#AICASZONE derives from the AIPatrol#AIPATROL_ZONE, inheriting its methods and behaviour. |
| _NewEngageRoute(AIControllable) |
Type AI_CAS_ZONE
Global(s)
- #AI_CAS_ZONE AI_CAS_ZONE
-
1) #AICASZONE class, extends AIPatrol#AIPATROL_ZONE
#AICASZONE derives from the AIPatrol#AIPATROL_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.
The AICASZONE is assigned a Group and this must be done before the AICASZONE process can be started through the 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.
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.
The AI will detect the targets and will only destroy the targets within the Engage Zone.
Every target that is destroyed, is reported< by the AI.
Note that the AI does not know when the Engage Zone is cleared, and therefore will keep circling in the zone.
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 ...
When the AI has accomplished the CAS, it will fly back to the Patrol Zone.
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.
1.1) AICASZONE constructor
- AICASZONE.New(): Creates a new AICASZONE object.
1.2) AICASZONE is a FSM
1.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..
1.2.2) AICASZONE Events
- **AIPatrol#AIPATROL_ZONE.Start**: Start the process.
- **AIPatrol#AIPATROL_ZONE.Route**: Route the AI to a new random 3D point within the Patrol Zone.
- **AICASZONE.Engage**: Engage the AI to provide CAS in the Engage Zone, destroying any target it finds.
- **AICASZONE.Abort**: Aborts the engagement and return patrolling in the patrol zone.
- **AIPatrol#AIPATROL_ZONE.RTB**: Route the AI to the home base.
- **AIPatrol#AIPATROL_ZONE.Detect**: The AI is detecting targets.
- **AIPatrol#AIPATROL_ZONE.Detected**: The AI has detected new targets.
- **AICASZONE.Destroy**: The AI has destroyed a target Unit.
- **AICASZONE.Destroyed**: The AI has destroyed all target Units assigned in the CAS task.
- Status: The AI is checking status (fuel and damage). When the tresholds have been reached, the AI will RTB.
- _NewEngageRoute(AIControllable)
-
Parameter
-
Wrapper.Controllable#CONTROLLABLE AIControllable:
-
Type AI_Cas
Type AI_CAS_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:Fired()
-
Synchronous Event Trigger for Event Fired.
- AI_CAS_ZONE:New(PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, EngageZone, PatrolAltType)
-
Creates a new AICASZONE object
Parameters
-
Core.Zone#ZONE_BASE PatrolZone: The Zone where the patrol needs to be executed. -
Dcs.DCSTypes#Altitude PatrolFloorAltitude: The lowest altitude in meters where to execute the patrol. -
Dcs.DCSTypes#Altitude PatrolCeilingAltitude: The highest altitude in meters where to execute the patrol. -
Dcs.DCSTypes#Speed PatrolMinSpeed: The minimum speed of the Controllable in km/h. -
Dcs.DCSTypes#Speed PatrolMaxSpeed: The maximum speed of the Controllable in km/h. -
Core.Zone#ZONE_BASE EngageZone: The zone where the engage will happen. -
Dcs.DCSTypes#AltitudeType PatrolAltType: The altitude type ("RADIO"=="AGL", "BARO"=="ASL"). Defaults to RADIO
Return value
#AICASZONE: 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
-
Core.Event#EVENTDATA EventData:
-
- 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
#AICASZONE: 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
-
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. -
Core.Event#EVENTDATA EventData:
-
- 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.
-