Module AI_A2A
+
+AI -- AI A2A Air Patrolling or Staging.
+ ++ +
Author: Sven Van de Velde (FlightControl)
+Contributions:
+ +-
+
- Dutch_Baron: Working together with James has resulted in the creation of the AI_BALANCER class. +
James has shared his ideas on balancing AI with air units, and together we made a first design which you can use now :-) + * Pikey: Testing and API concept review.
+ ++ + +
Global(s)
+| AI_A2A | +
+AI_A2A class, extends Fsm#FSM_CONTROLLABLE+ +The AI_A2A class implements the core functions to operate an AI Group A2A tasking. + |
+
Type AI_A2A
+ | AI_A2A.CheckStatus | ++ + | +
| AI_A2A:ClearTargetDistance() | ++ + | +
| AI_A2A:GetDispatcher() | ++ + | +
| AI_A2A.HomeAirbase | ++ + | +
| AI_A2A:ManageDamage(PatrolDamageTreshold) | +
+ When the AI is damaged beyond a certain treshold, it is required that the AI returns to the home base. + |
+
| AI_A2A:ManageFuel(PatrolFuelTresholdPercentage, PatrolOutOfFuelOrbitTime) | +
+ When the AI is out of fuel, it is required that a new AI is started, before the old AI can return to the home base. + |
+
| AI_A2A:New(AIGroup) | +
+ Creates a new AI_A2A object + |
+
| AI_A2A:OnAfterRTB(Controllable, From, Event, To) | +
+ OnAfter Transition Handler for Event RTB. + |
+
| AI_A2A:OnAfterStart(From, Event, To) | +
+ Start Handler OnAfter for AI_A2A + |
+
| AI_A2A:OnAfterStatus(Controllable, From, Event, To) | +
+ OnAfter Transition Handler for Event Status. + |
+
| AI_A2A:OnAfterStop(Controllable, From, Event, To) | +
+ OnAfter Transition Handler for Event Stop. + |
+
| AI_A2A:OnBeforeRTB(Controllable, From, Event, To) | +
+ OnBefore Transition Handler for Event RTB. + |
+
| AI_A2A:OnBeforeStart(From, Event, To) | +
+ Start Handler OnBefore for AI_A2A + |
+
| AI_A2A:OnBeforeStatus(Controllable, From, Event, To) | +
+ OnBefore Transition Handler for Event Status. + |
+
| AI_A2A:OnBeforeStop(Controllable, From, Event, To) | +
+ OnBefore Transition Handler for Event Stop. + |
+
| AI_A2A:OnCrash(EventData) | ++ + | +
| AI_A2A:OnEjection(EventData) | ++ + | +
| AI_A2A:OnEnterReturning(Controllable, From, Event, To) | +
+ OnEnter Transition Handler for State Returning. + |
+
| AI_A2A:OnEnterStopped(Controllable, From, Event, To) | +
+ OnEnter Transition Handler for State Stopped. + |
+
| AI_A2A:OnLeaveReturning(Controllable, From, Event, To) | +
+ OnLeave Transition Handler for State Returning. + |
+
| AI_A2A:OnLeaveStopped(Controllable, From, Event, To) | +
+ OnLeave Transition Handler for State Stopped. + |
+
| AI_A2A:OnPilotDead(EventData) | ++ + | +
| AI_A2A.PatrolCeilingAltitude | ++ + | +
| AI_A2A.PatrolDamageTreshold | ++ + | +
| AI_A2A.PatrolFloorAltitude | ++ + | +
| AI_A2A.PatrolFuelTresholdPercentage | ++ + | +
| AI_A2A.PatrolManageDamage | ++ + | +
| AI_A2A.PatrolManageFuel | ++ + | +
| AI_A2A.PatrolMaxSpeed | ++ + | +
| AI_A2A.PatrolMinSpeed | ++ + | +
| AI_A2A.PatrolOutOfFuelOrbitTime | ++ + | +
| AI_A2A:RTB() | +
+ Synchronous Event Trigger for Event RTB. + |
+
| AI_A2A.RTBRoute(AIGroup) | ++ + | +
| AI_A2A:SetAltitude(PatrolFloorAltitude, PatrolCeilingAltitude) | +
+ Sets the floor and ceiling altitude of the patrol. + |
+
| AI_A2A:SetDispatcher(Dispatcher) | ++ + | +
| AI_A2A:SetHomeAirbase(HomeAirbase) | +
+ Sets the home airbase. + |
+
| AI_A2A:SetSpeed(PatrolMinSpeed, PatrolMaxSpeed) | +
+ Sets (modifies) the minimum and maximum speed of the patrol. + |
+
| AI_A2A:SetStatusOff() | +
+ Set the status checking off. + |
+
| AI_A2A:SetTargetDistance(Coordinate) | ++ + | +
| AI_A2A:Start() | +
+ Start Trigger for AI_A2A + |
+
| AI_A2A:Status() | +
+ Synchronous Event Trigger for Event Status. + |
+
| AI_A2A:Stop() | +
+ Synchronous Event Trigger for Event Stop. + |
+
| AI_A2A:__RTB(Delay) | +
+ Asynchronous Event Trigger for Event RTB. + |
+
| AI_A2A:__Start(Delay) | +
+ Start Asynchronous Trigger for AI_A2A + |
+
| AI_A2A:__Status(Delay) | +
+ Asynchronous Event Trigger for Event Status. + |
+
| AI_A2A:__Stop(Delay) | +
+ Asynchronous Event Trigger for Event Stop. + |
+
| AI_A2A:onafterDead() | ++ + | +
| AI_A2A:onafterHome(AIGroup, From, Event, To) | ++ + | +
| AI_A2A:onafterRTB(AIGroup, From, Event, To) | ++ + | +
| AI_A2A:onafterStart(Controllable, From, Event, To) | +
+ Defines a new patrol route using the Process_PatrolZone parameters and settings. + |
+
| AI_A2A:onafterStatus() | ++ + | +
| AI_A2A:onbeforeStatus() | ++ + | +
Global(s)
+-
+
- + + #AI_A2A + +AI_A2A + + +
-
+
+
AI_A2A class, extends Fsm#FSM_CONTROLLABLE
+ +The AI_A2A class implements the core functions to operate an AI Group A2A tasking.
+ + + + +AI_A2A constructor
+ +-
+
- AI_A2A.New(): Creates a new AI_A2A object. +
2. AI_A2A is a FSM
+ +
+ +2.1. AI_A2A States
+ +-
+
- None ( Group ): The process is not started yet. +
- Patrolling ( Group ): The AI is patrolling the Patrol Zone. +
- Returning ( Group ): The AI is returning to Base. +
- Stopped ( Group ): The process is stopped. +
- Crashed ( Group ): The AI has crashed or is dead. +
2.2. AI_A2A Events
+ +-
+
- Start ( Group ): Start the process. +
- Stop ( Group ): Stop the process. +
- Route ( Group ): Route the AI to a new random 3D point within the Patrol Zone. +
- RTB ( Group ): Route the AI to the home base. +
- Detect ( Group ): The AI is detecting targets. +
- Detected ( Group ): The AI has detected new targets. +
- Status ( Group ): The AI is checking status (fuel and damage). When the tresholds have been reached, the AI will RTB. +
3. Set or Get the AI controllable
+ +-
+
- AI_A2A.SetControllable(): Set the AIControllable. +
- AI_A2A.GetControllable(): Get the AIControllable. +
+
Type AI_A2A
+ Field(s)
+-
+
- + + #boolean + +AI_A2A.CheckStatus + + +
- + + + + +
-
+
- + + +AI_A2A:ClearTargetDistance() + + +
- + + + + +
-
+
- + + +AI_A2A:GetDispatcher() + + +
- + + + + +
-
+
- + + + +AI_A2A.HomeAirbase + + +
- + + + + +
-
+
- + + +AI_A2A:ManageDamage(PatrolDamageTreshold) + + +
-
+
+
When the AI is damaged beyond a certain treshold, it is required that the AI returns to the home base.
+ + +However, damage cannot be foreseen early on. +Therefore, when the damage treshold is reached, +the AI will return immediately to the home base (RTB). +Note that for groups, the average damage of the complete group will be calculated. +So, in a group of 4 airplanes, 2 lost and 2 with damage 0.2, the damage treshold will be 0.25.
+ +Parameter
+-
+
-
+
+
+ +#number PatrolDamageTreshold: +The treshold in percentage (between 0 and 1) when the AI is considered to be damaged.
+
Return value
+ +#AI_A2A: +self
+ +
+ -
+
+
-
+
- + + +AI_A2A:ManageFuel(PatrolFuelTresholdPercentage, PatrolOutOfFuelOrbitTime) + + +
-
+
+
When the AI is out of fuel, it is required that a new AI is started, before the old AI can return to the home base.
+ + +Therefore, with a parameter and a calculation of the distance to the home base, the fuel treshold is calculated. +When the fuel treshold is reached, the AI will continue for a given time its patrol task in orbit, while a new AIControllable is targetted to the AI_A2A. +Once the time is finished, the old AI will return to the base.
+ +Parameters
+-
+
-
+
+
+ +#number PatrolFuelTresholdPercentage: +The treshold in percentage (between 0 and 1) when the AIControllable is considered to get out of fuel.
+ -
+
+
+ +#number PatrolOutOfFuelOrbitTime: +The amount of seconds the out of fuel AIControllable will orbit before returning to the base.
+
Return value
+ +#AI_A2A: +self
+ +
+ -
+
+
-
+
- + + +AI_A2A:New(AIGroup) + + +
-
+
+
Creates a new AI_A2A object
+ +Parameter
+-
+
-
+
+
+ +Wrapper.Group#GROUP AIGroup: +The GROUP object to receive the A2A Process.
+
Return value
+ + + + +
+ -
+
+
-
+
- + + +AI_A2A:OnAfterRTB(Controllable, From, Event, To) + + +
-
+
+
OnAfter Transition Handler for Event RTB.
+ +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_A2A:OnAfterStart(From, Event, To) + + +
-
+
+
Start Handler OnAfter for AI_A2A
+ +Parameters
+-
+
-
+
+
+ +#string From:
+ -
+
+
+ +#string Event:
+ -
+
+
+ +#string To:
+
+ -
+
+
-
+
- + + +AI_A2A:OnAfterStatus(Controllable, From, Event, To) + + +
-
+
+
OnAfter Transition Handler for Event Status.
+ +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_A2A:OnAfterStop(Controllable, From, Event, To) + + +
-
+
+
OnAfter Transition Handler for Event Stop.
+ +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_A2A:OnBeforeRTB(Controllable, From, Event, To) + + +
-
+
+
OnBefore Transition Handler for Event RTB.
+ +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_A2A:OnBeforeStart(From, Event, To) + + +
-
+
+
Start Handler OnBefore for AI_A2A
+ +Parameters
+-
+
-
+
+
+ +#string From:
+ -
+
+
+ +#string Event:
+ -
+
+
+ +#string To:
+
Return value
+ +#boolean:
+ + +
+ -
+
+
-
+
- + + +AI_A2A:OnBeforeStatus(Controllable, From, Event, To) + + +
-
+
+
OnBefore Transition Handler for Event Status.
+ +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_A2A:OnBeforeStop(Controllable, From, Event, To) + + +
-
+
+
OnBefore Transition Handler for Event Stop.
+ +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_A2A:OnCrash(EventData) + + +
-
+
+
+
+
Parameter
+-
+
-
+
+
+ +Core.Event#EVENTDATA EventData:
+
+ -
+
+
-
+
- + + +AI_A2A:OnEjection(EventData) + + +
-
+
+
+
+
Parameter
+-
+
-
+
+
+ +Core.Event#EVENTDATA EventData:
+
+ -
+
+
-
+
- + + +AI_A2A:OnEnterReturning(Controllable, From, Event, To) + + +
-
+
+
OnEnter Transition Handler for State Returning.
+ +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_A2A:OnEnterStopped(Controllable, From, Event, To) + + +
-
+
+
OnEnter Transition Handler for State Stopped.
+ +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_A2A:OnLeaveReturning(Controllable, From, Event, To) + + +
-
+
+
OnLeave Transition Handler for State Returning.
+ +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_A2A:OnLeaveStopped(Controllable, From, Event, To) + + +
-
+
+
OnLeave Transition Handler for State Stopped.
+ +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_A2A:OnPilotDead(EventData) + + +
-
+
+
+
+
Parameter
+-
+
-
+
+
+ +Core.Event#EVENTDATA EventData:
+
+ -
+
+
-
+
- + + + +AI_A2A.PatrolCeilingAltitude + + +
- + + + + +
-
+
- + + + +AI_A2A.PatrolDamageTreshold + + +
- + + + + +
-
+
- + + + +AI_A2A.PatrolFloorAltitude + + +
- + + + + +
-
+
- + + + +AI_A2A.PatrolFuelTresholdPercentage + + +
- + + + + +
-
+
- + + #boolean + +AI_A2A.PatrolManageDamage + + +
- + + + + +
-
+
- + + #boolean + +AI_A2A.PatrolManageFuel + + +
- + + + + +
-
+
- + + + +AI_A2A.PatrolMaxSpeed + + +
- + + + + +
-
+
- + + + +AI_A2A.PatrolMinSpeed + + +
- + + + + +
-
+
- + + + +AI_A2A.PatrolOutOfFuelOrbitTime + + +
- + + + + +
-
+
- + + +AI_A2A:RTB() + + +
-
+
+
Synchronous Event Trigger for Event RTB.
+ +
+
-
+
- + + +AI_A2A.RTBRoute(AIGroup) + + +
-
+
+
+
+
Parameter
+-
+
-
+
+
+ +Wrapper.Group#GROUP AIGroup:
+
+ -
+
+
-
+
- + + +AI_A2A:SetAltitude(PatrolFloorAltitude, PatrolCeilingAltitude) + + +
-
+
+
Sets the floor and ceiling altitude of the patrol.
+ +Parameters
+-
+
-
+
+
+ +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.
+
Return value
+ +#AI_A2A: +self
+ +
+ -
+
+
-
+
- + + +AI_A2A:SetDispatcher(Dispatcher) + + +
-
+
+
+
+
Parameter
+-
+
-
+
+
+ +Dispatcher:
+
+ -
+
+
-
+
- + + +AI_A2A:SetHomeAirbase(HomeAirbase) + + +
-
+
+
Sets the home airbase.
+ +Parameter
+-
+
-
+
+
+ +Wrapper.Airbase#AIRBASE HomeAirbase:
+
Return value
+ +#AI_A2A: +self
+ +
+ -
+
+
-
+
- + + +AI_A2A:SetSpeed(PatrolMinSpeed, PatrolMaxSpeed) + + +
-
+
+
Sets (modifies) the minimum and maximum speed of the patrol.
+ +Parameters
+-
+
-
+
+
+ +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.
+
Return value
+ +#AI_A2A: +self
+ +
+ -
+
+
-
+
- + + +AI_A2A:SetStatusOff() + + +
-
+
+
Set the status checking off.
+ +Return value
+ +#AI_A2A: +self
+ +
+
-
+
- + + +AI_A2A:SetTargetDistance(Coordinate) + + +
-
+
+
+
+
Parameter
+-
+
-
+
+
+ +Coordinate:
+
+ -
+
+
-
+
- + + +AI_A2A:Start() + + +
-
+
+
Start Trigger for AI_A2A
+ +
+
-
+
- + + +AI_A2A:Status() + + +
-
+
+
Synchronous Event Trigger for Event Status.
+ +
+
-
+
- + + +AI_A2A:Stop() + + +
-
+
+
Synchronous Event Trigger for Event Stop.
+ +
+
-
+
- + + +AI_A2A:__RTB(Delay) + + +
-
+
+
Asynchronous Event Trigger for Event RTB.
+ +Parameter
+-
+
-
+
+
+ +#number Delay: +The delay in seconds.
+
+ -
+
+
-
+
- + + +AI_A2A:__Start(Delay) + + +
-
+
+
Start Asynchronous Trigger for AI_A2A
+ +Parameter
+-
+
-
+
+
+ +#number Delay:
+
+ -
+
+
-
+
- + + +AI_A2A:__Status(Delay) + + +
-
+
+
Asynchronous Event Trigger for Event Status.
+ +Parameter
+-
+
-
+
+
+ +#number Delay: +The delay in seconds.
+
+ -
+
+
-
+
- + + +AI_A2A:__Stop(Delay) + + +
-
+
+
Asynchronous Event Trigger for Event Stop.
+ +Parameter
+-
+
-
+
+
+ +#number Delay: +The delay in seconds.
+
+ -
+
+
-
+
- + + +AI_A2A:onafterDead() + + +
- + + + + +
-
+
- + + +AI_A2A:onafterHome(AIGroup, From, Event, To) + + +
-
+
+
+
+
Parameters
+-
+
-
+
+
+ +Wrapper.Group#GROUP AIGroup:
+ -
+
+
+ +From:
+ -
+
+
+ +Event:
+ -
+
+
+ +To:
+
+ -
+
+
-
+
- + + +AI_A2A:onafterRTB(AIGroup, From, Event, To) + + +
-
+
+
+
+
Parameters
+-
+
-
+
+
+ +Wrapper.Group#GROUP AIGroup:
+ -
+
+
+ +From:
+ -
+
+
+ +Event:
+ -
+
+
+ +To:
+
+ -
+
+
-
+
- + + +AI_A2A:onafterStart(Controllable, From, Event, To) + + +
-
+
+
Defines a new patrol route using the Process_PatrolZone parameters and settings.
+ +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
+ +#AI_A2A: +self
+ +
+ -
+
+
-
+
- + + +AI_A2A:onafterStatus() + + +
- + + + + +
-
+
- + + +AI_A2A:onbeforeStatus() + + +
- + + + + +