Module AI_Bai

AI -- (R2.1) - Manages the independent process of Battlefield Air Interdiction (bombing) for airplanes.


Banner Image


Demo Missions


YouTube Playlist


Author: FlightControl

Contributions:


Global(s)

AI_BAI_ZONE

AIBAIZONE class, extends AI_Patrol#AI_PATROL_ZONE

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

_NewEngageRoute(AIControllable)

Type AI_BAI_ZONE

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.

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.

AI_BAI_ZONE.EngageAltitude
AI_BAI_ZONE.EngageAttackQty
AI_BAI_ZONE.EngageDirection
AI_BAI_ZONE.EngageSpeed
AI_BAI_ZONE.EngageWeaponExpend
AI_BAI_ZONE.EngageZone
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

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

OnAfter Transition Handler for Event Abort.

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

OnAfter Transition Handler for Event Accomplish.

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

OnAfter Transition Handler for Event Destroy.

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

OnAfter Transition Handler for Event Engage.

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

OnAfter Transition Handler for Event Fired.

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

OnBefore Transition Handler for Event Abort.

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

OnBefore Transition Handler for Event Accomplish.

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

OnBefore Transition Handler for Event Destroy.

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

OnBefore Transition Handler for Event Engage.

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

OnBefore Transition Handler for Event Fired.

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

OnEnter Transition Handler for State Engaging.

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

OnLeave Transition Handler for State Engaging.

AI_BAI_ZONE.Search
AI_BAI_ZONE:SearchOff()

If Search is Off, the current zone coordinate will be the center of the bombing.

AI_BAI_ZONE:SearchOn()

If Search is On, BAI will search for potential targets in the zone.

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.

AI_BAI_ZONE:SetEngageZone(EngageZone)

Set the Engage Zone where the AI is performing BOMB.

AI_BAI_ZONE.TargetZone

The Zone where the patrol needs to be executed.

AI_BAI_ZONE:__Abort(Delay)

Asynchronous Event Trigger for Event Abort.

AI_BAI_ZONE:__Accomplish(Delay)

Asynchronous Event Trigger for Event Accomplish.

AI_BAI_ZONE:__Destroy(Delay)

Asynchronous Event Trigger for Event Destroy.

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

Asynchronous Event Trigger for Event Engage.

AI_BAI_ZONE:__Fired(Delay)

Asynchronous Event Trigger for Event Fired.

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

onafter State Transition for Event Start.

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

Global(s)

#AI_BAI_ZONE AI_BAI_ZONE

AIBAIZONE class, extends AI_Patrol#AI_PATROL_ZONE

AIBAIZONE derives from the AI_Patrol#AI_PATROL_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.

HoldAndEngage

The AIBAIZONE is assigned a Group and this must be done before the AIBAIZONE 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 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.

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 Bombing, 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 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.

Engage Event

1. AIBAIZONE constructor

2. AIBAIZONE is a FSM

Process

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

3. Modify the Engage Zone behaviour to pinpoint a map object or scenery object

Use the method AI_BAI_ZONE.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 AI_BAI_ZONE.SearchOn(). Use the method AI_BAI_ZONE.SearchOnOff() to flexibily switch searching on or off.


_NewEngageRoute(AIControllable)

Parameter

Type AI_Bai

Type AI_BAI_ZONE

Extends AI.AI_Patrol#AI_PATROL_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.EngageAltitude
AI_BAI_ZONE.EngageAttackQty
AI_BAI_ZONE.EngageDirection
AI_BAI_ZONE.EngageSpeed
AI_BAI_ZONE.EngageWeaponExpend
AI_BAI_ZONE.EngageZone
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

Return value

#AI_BAI_ZONE: 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

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.Search
AI_BAI_ZONE:SearchOff()

If Search is Off, the current zone coordinate will be the center of the bombing.

Return value

#AI_BAI_ZONE:

AI_BAI_ZONE:SearchOn()

If Search is On, BAI will search for potential targets in the zone.

Return value

#AI_BAI_ZONE:

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:

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

#AI_BAI_ZONE: 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

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.