Module AI_Bai
AI -- Provide Battlefield Air Interdiction (bombing).
AI_BAI classes makes AI Controllables execute bombing tasks.
There are the following types of BAI classes defined:
- #AIBAIZONE: Perform a BAI in a zone.
Demo Missions
AI_BAI Demo Missions source code
AI_BAI Demo Missions, only for beta testers
ALL Demo Missions pack of the last release
YouTube Channel
AI_BAI YouTube Channel
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:
- Gunterlund: Test case revision.
Authors:
- FlightControl: Concept, Design & Programming.
Global(s)
| AI_BAI_ZONE |
AIBAIZONE class, extends AIPatrol#AIPATROL_ZONEAIBAIZONE derives from the AIPatrol#AIPATROL_ZONE, inheriting its methods and behaviour. |
| _NewEngageRoute(AIControllable) |
Type AI_BAI_ZONE
Global(s)
- #AI_BAI_ZONE AI_BAI_ZONE
-
AIBAIZONE class, extends AIPatrol#AIPATROL_ZONE
AIBAIZONE derives from the AIPatrol#AIPATROL_ZONE, inheriting its methods and behaviour.
The AIBAIZONE class implements the core functions to provide BattleGround Air Interdiction in an Engage Zone by an AIR Controllable or Group. The AIBAIZONE 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 AIBAIZONE is assigned a Group and this must be done before the AIBAIZONE 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 BattleGround Air Interdiction (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 Bombing, it will fly back to the Patrol Zone.
It will keep patrolling there, until it is notified to RTB or move to another BOMB 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. AIBAIZONE constructor
- AIBAIZONE.New(): Creates a new AIBAIZONE object.
2. AIBAIZONE is a FSM
2.1. AIBAIZONE 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 BOMB.
- Returning ( Group ): The AI is returning to Base..
2.2. AIBAIZONE 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.
- **AIBAIZONE.Engage**: Engage the AI to provide BOMB in the Engage Zone, destroying any target it finds.
- **AIBAIZONE.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.
- **AIBAIZONE.Destroy**: The AI has destroyed a target Unit.
- **AIBAIZONE.Destroyed**: The AI has destroyed all target Units assigned in the BOMB task.
- Status: The AI is checking status (fuel and damage). When the tresholds have been reached, the AI will RTB.
3. Modify the Engage Zone behaviour to pinpoint a map object or scenery object
Use the method AIBAIZONE.SearchOff() to specify that the EngageZone is not to be searched for potential targets (UNITs), but that the center of the zone is the point where a map object is to be destroyed (like a bridge).
Example:
-- Tell the BAI not to search for potential targets in the BAIEngagementZone, but rather use the center of the BAIEngagementZone as the bombing location. AIBAIZone:SearchOff()Searching can be switched back on with the method AIBAIZONE.SearchOn(). Use the method AIBAIZONE.SearchOnOff() to flexibily switch searching on or off.
- _NewEngageRoute(AIControllable)
-
Parameter
-
Wrapper.Controllable#CONTROLLABLE AIControllable:
-
Type AI_Bai
Type AI_BAI_ZONE
AIBAIZONE class
Field(s)
- Wrapper.Controllable#CONTROLLABLE AI_BAI_ZONE.AIControllable
-
The Controllable patrolling.
- AI_BAI_ZONE:Abort()
-
Synchronous Event Trigger for Event Abort.
- AI_BAI_ZONE:Accomplish()
-
Synchronous Event Trigger for Event Accomplish.
- #boolean AI_BAI_ZONE.Accomplished
- AI_BAI_ZONE:Destroy()
-
Synchronous Event Trigger for Event Destroy.
- AI_BAI_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_BAI_ZONE:Fired()
-
Synchronous Event Trigger for Event Fired.
- AI_BAI_ZONE:New(PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, EngageZone, PatrolAltType)
-
Creates a new AIBAIZONE 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
#AIBAIZONE: self
-
- AI_BAI_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_BAI_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_BAI_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_BAI_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_BAI_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_BAI_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_BAI_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_BAI_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_BAI_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_BAI_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_BAI_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_BAI_ZONE:OnEventDead(EventData)
-
Parameter
-
Core.Event#EVENTDATA EventData:
-
- AI_BAI_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_BAI_ZONE:SearchOff()
-
If Search is Off, the current zone coordinate will be the center of the bombing.
Return value
- AI_BAI_ZONE:SearchOn()
-
If Search is On, BAI will search for potential targets in the zone.
Return value
- AI_BAI_ZONE:SearchOnOff(Search)
-
Specifies whether to search for potential targets in the zone, or let the center of the zone be the bombing coordinate.
AIBAIZONE will search for potential targets by default.
Parameter
-
Search:
Return value
-
- AI_BAI_ZONE:SetEngageZone(EngageZone)
-
Set the Engage Zone where the AI is performing BOMB.
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 BOMB.
Return value
#AIBAIZONE: self
-
- Core.Zone#ZONE_BASE AI_BAI_ZONE.TargetZone
-
The Zone where the patrol needs to be executed.
- AI_BAI_ZONE:__Abort(Delay)
-
Asynchronous Event Trigger for Event Abort.
Parameter
-
#number Delay: The delay in seconds.
-
- AI_BAI_ZONE:__Accomplish(Delay)
-
Asynchronous Event Trigger for Event Accomplish.
Parameter
-
#number Delay: The delay in seconds.
-
- AI_BAI_ZONE:__Destroy(Delay)
-
Asynchronous Event Trigger for Event Destroy.
Parameter
-
#number Delay: The delay in seconds.
-
- AI_BAI_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_BAI_ZONE:__Fired(Delay)
-
Asynchronous Event Trigger for Event Fired.
Parameter
-
#number Delay: The delay in seconds.
-
- AI_BAI_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_BAI_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_BAI_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_BAI_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_BAI_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_BAI_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_BAI_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.
-