Module AI_Follow

AI -- (R2.1) Build large formations of AI Groups flying together.

Banner Image


AI_FORMATION makes AI GROUPs fly in formation of various compositions.

There are the following types of classes defined:


Demo Missions

AI_FORMATION Demo Missions source code

AI_FORMATION Demo Missions, only for beta testers

ALL Demo Missions pack of the last release


YouTube Channel


AUTHORS and CONTRIBUTIONS

Contributions:

Authors:

  • FlightControl: Concept, Design & Programming.

Global(s)

AI_FORMATION

AI_FORMATION class, extends Fsm#FSM_SET

The #AI_FORMATION class allows you to build large formations, make AI follow a Client#CLIENT (player) leader or a Unit#UNIT (AI) leader.

Type AI_FORMATION

AI_FORMATION.FollowDistance

The current follow distance.

AI_FORMATION.FollowGroupSet
AI_FORMATION.FollowMenuResumeMission
AI_FORMATION.FollowMode

The mode the escort is in.

AI_FORMATION.FollowName
AI_FORMATION.FollowScheduler

The instance of the SCHEDULER class.

AI_FORMATION.FollowUnit
AI_FORMATION:FormationLeftLine(XStart, YStart, ZStart, ZSpace)

FormationLeftLine Trigger for AI_FORMATION

AI_FORMATION:FormationLeftWing(XStart, XSpace, YStart, ZStart, ZSpace)

FormationLeftWing Trigger for AI_FORMATION

AI_FORMATION:FormationRightLine(XStart, YStart, ZStart, ZSpace)

FormationRightLine Trigger for AI_FORMATION

AI_FORMATION:FormationRightWing(XStart, XSpace, YStart, ZStart, ZSpace)

FormationRightWing Trigger for AI_FORMATION

AI_FORMATION:New(FollowUnit, FollowGroupSet, FollowName, FollowBriefing)

AI_FORMATION class constructor for an AI group

AI_FORMATION:OnAfterFormationLeftLine(FollowGroupSet, From, Event, To, XStart, YStart, ZStart, ZSpace)

FormationLeftLine Handler OnAfter for AI_FORMATION

AI_FORMATION:OnAfterFormationLeftWing(FollowGroupSet, From, Event, To, XStart, XSpace, YStart, ZStart, ZSpace)

FormationLeftWing Handler OnAfter for AI_FORMATION

AI_FORMATION:OnAfterFormationRightLine(FollowGroupSet, From, Event, To, XStart, YStart, ZStart, ZSpace)

FormationRightLine Handler OnAfter for AI_FORMATION

AI_FORMATION:OnAfterFormationRightWing(FollowGroupSet, From, Event, To, XStart, XSpace, YStart, ZStart, ZSpace)

FormationRightWing Handler OnAfter for AI_FORMATION

AI_FORMATION:OnBeforeFormationLeftLine(FollowGroupSet, From, Event, To, XStart, YStart, ZStart, ZSpace)

FormationLeftLine Handler OnBefore for AI_FORMATION

AI_FORMATION:OnBeforeFormationLeftWing(FollowGroupSet, From, Event, To, XStart, XSpace, YStart, ZStart, ZSpace)

FormationLeftWing Handler OnBefore for AI_FORMATION

AI_FORMATION:OnBeforeFormationRightLine(FollowGroupSet, From, Event, To, XStart, YStart, ZStart, ZSpace)

FormationRightLine Handler OnBefore for AI_FORMATION

AI_FORMATION:OnBeforeFormationRightWing(FollowGroupSet, From, Event, To, XStart, XSpace, YStart, ZStart, ZSpace)

FormationRightWing Handler OnBefore for AI_FORMATION

AI_FORMATION.OptionReactionOnThreat

Which REACTIONONTHREAT is set to the FollowGroup.

AI_FORMATION.ReportTargets

If true, nearby targets are reported.

AI_FORMATION.SmokeDirectionVector
AI_FORMATION:TestSmokeDirectionVector(SmokeDirection)

This function is for test, it will put on the frequency of the FollowScheduler a red smoke at the direction vector calculated for the escort to fly to.

AI_FORMATION:__FormationLeftLine(Delay, XStart, YStart, ZStart, ZSpace)

FormationLeftLine Asynchronous Trigger for AI_FORMATION

AI_FORMATION:__FormationLeftWing(Delay, XStart, XSpace, YStart, ZStart, ZSpace)

FormationLeftWing Asynchronous Trigger for AI_FORMATION

AI_FORMATION:__FormationRightLine(Delay, XStart, YStart, ZStart, ZSpace)

FormationRightLine Asynchronous Trigger for AI_FORMATION

AI_FORMATION:__FormationRightWing(Delay, XStart, XSpace, YStart, ZStart, ZSpace)

FormationRightWing Asynchronous Trigger for AI_FORMATION

AI_FORMATION:onafterFormationLeftLine(FollowGroupSet, From, Event, To, XStart, YStart, ZStart, ZSpace)
AI_FORMATION:onafterFormationLeftWing(FollowGroupSet, From, Event, To, XStart, XSpace, YStart, ZStart, ZSpace)
AI_FORMATION:onafterFormationRightLine(FollowGroupSet, From, Event, To, XStart, YStart, ZStart, ZSpace)
AI_FORMATION:onafterFormationRightWing(FollowGroupSet, From, Event, To, XStart, XSpace, YStart, ZStart, ZSpace)
AI_FORMATION:onenterFollowing(FollowGroupSet)

Type AI_FORMATION.MODE

AI_FORMATION.MODE.FOLLOW
AI_FORMATION.MODE.MISSION

Type MENUPARAM

MENUPARAM.ParamDistance
MENUPARAM.ParamFunction
MENUPARAM.ParamMessage
MENUPARAM.ParamSelf

Global(s)

#AI_FORMATION AI_FORMATION

AI_FORMATION class, extends Fsm#FSM_SET

The #AI_FORMATION class allows you to build large formations, make AI follow a Client#CLIENT (player) leader or a Unit#UNIT (AI) leader.

AI_FORMATION construction

Create a new SPAWN object with the AI_FORMATION.New method:

Initialization methods

The following menus are created within the RADIO MENU of an active unit hosted by a player:

Usage:

-- Declare a new FollowPlanes object as follows:

-- First find the GROUP object and the CLIENT object.
local FollowUnit = CLIENT:FindByName( "Unit Name" ) -- The Unit Name is the name of the unit flagged with the skill Client in the mission editor.
local FollowGroup = GROUP:FindByName( "Group Name" ) -- The Group Name is the name of the group that will escort the Follow Client.

-- Now use these 2 objects to construct the new FollowPlanes object.
FollowPlanes = AI_FORMATION:New( FollowUnit, FollowGroup, "Desert", "Welcome to the mission. You are escorted by a plane with code name 'Desert', which can be instructed through the F10 radio menu." )

Type AI_Follow

Type AI_FORMATION

AI_FORMATION class

Field(s)

#number AI_FORMATION.FollowDistance

The current follow distance.

Set#SET_GROUP AI_FORMATION.FollowGroupSet
Menu#MENU_CLIENT AI_FORMATION.FollowMenuResumeMission
#AI_FORMATION.MODE AI_FORMATION.FollowMode

The mode the escort is in.

#string AI_FORMATION.FollowName
Scheduler#SCHEDULER AI_FORMATION.FollowScheduler

The instance of the SCHEDULER class.

Unit#UNIT AI_FORMATION.FollowUnit
AI_FORMATION:FormationLeftLine(XStart, YStart, ZStart, ZSpace)

FormationLeftLine Trigger for AI_FORMATION

Parameters

  • #number XStart : The start position on the X-axis in meters for the first group.

  • #nubmer YStart : The start position on the Y-axis in meters for the first group.

  • #nubmer ZStart : The start position on the Z-axis in meters for the first group.

  • #number ZSpace : The space between groups on the Z-axis in meters for each sequent group.

AI_FORMATION:FormationLeftWing(XStart, XSpace, YStart, ZStart, ZSpace)

FormationLeftWing Trigger for AI_FORMATION

Parameters

  • #number XStart : The start position on the X-axis in meters for the first group.

  • #number XSpace : The space between groups on the X-axis in meters for each sequent group.

  • #nubmer YStart : The start position on the Y-axis in meters for the first group.

  • #nubmer ZStart : The start position on the Z-axis in meters for the first group.

  • #number ZSpace : The space between groups on the Z-axis in meters for each sequent group.

AI_FORMATION:FormationRightLine(XStart, YStart, ZStart, ZSpace)

FormationRightLine Trigger for AI_FORMATION

Parameters

  • #number XStart : The start position on the X-axis in meters for the first group.

  • #nubmer YStart : The start position on the Y-axis in meters for the first group.

  • #nubmer ZStart : The start position on the Z-axis in meters for the first group.

  • #number ZSpace : The space between groups on the Z-axis in meters for each sequent group.

AI_FORMATION:FormationRightWing(XStart, XSpace, YStart, ZStart, ZSpace)

FormationRightWing Trigger for AI_FORMATION

Parameters

  • #number XStart : The start position on the X-axis in meters for the first group.

  • #number XSpace : The space between groups on the X-axis in meters for each sequent group.

  • #nubmer YStart : The start position on the Y-axis in meters for the first group.

  • #nubmer ZStart : The start position on the Z-axis in meters for the first group.

  • #number ZSpace : The space between groups on the Z-axis in meters for each sequent group.

AI_FORMATION:New(FollowUnit, FollowGroupSet, FollowName, FollowBriefing)

AI_FORMATION class constructor for an AI group

Parameters

  • Unit#UNIT FollowUnit : The UNIT leading the FolllowGroupSet.

  • Core.Set#SET_GROUP FollowGroupSet : The group AI escorting the FollowUnit.

  • #string FollowName : Name of the escort.

  • FollowBriefing :

Return value

#AI_FORMATION: self

AI_FORMATION:OnAfterFormationLeftLine(FollowGroupSet, From, Event, To, XStart, YStart, ZStart, ZSpace)

FormationLeftLine Handler OnAfter for AI_FORMATION

Parameters

  • Core.Set#SET_GROUP FollowGroupSet : The group AI escorting the FollowUnit.

  • #string From :

  • #string Event :

  • #string To :

  • #number XStart : The start position on the X-axis in meters for the first group.

  • #nubmer YStart : The start position on the Y-axis in meters for the first group.

  • #nubmer ZStart : The start position on the Z-axis in meters for the first group.

  • #number ZSpace : The space between groups on the Z-axis in meters for each sequent group.

AI_FORMATION:OnAfterFormationLeftWing(FollowGroupSet, From, Event, To, XStart, XSpace, YStart, ZStart, ZSpace)

FormationLeftWing Handler OnAfter for AI_FORMATION

Parameters

  • Core.Set#SET_GROUP FollowGroupSet : The group AI escorting the FollowUnit.

  • #string From :

  • #string Event :

  • #string To :

  • #number XStart : The start position on the X-axis in meters for the first group.

  • #number XSpace : The space between groups on the X-axis in meters for each sequent group.

  • #nubmer YStart : The start position on the Y-axis in meters for the first group.

  • #nubmer ZStart : The start position on the Z-axis in meters for the first group.

  • #number ZSpace : The space between groups on the Z-axis in meters for each sequent group.

AI_FORMATION:OnAfterFormationRightLine(FollowGroupSet, From, Event, To, XStart, YStart, ZStart, ZSpace)

FormationRightLine Handler OnAfter for AI_FORMATION

Parameters

  • Core.Set#SET_GROUP FollowGroupSet : The group AI escorting the FollowUnit.

  • #string From :

  • #string Event :

  • #string To :

  • #number XStart : The start position on the X-axis in meters for the first group.

  • #nubmer YStart : The start position on the Y-axis in meters for the first group.

  • #nubmer ZStart : The start position on the Z-axis in meters for the first group.

  • #number ZSpace : The space between groups on the Z-axis in meters for each sequent group.

AI_FORMATION:OnAfterFormationRightWing(FollowGroupSet, From, Event, To, XStart, XSpace, YStart, ZStart, ZSpace)

FormationRightWing Handler OnAfter for AI_FORMATION

Parameters

  • Core.Set#SET_GROUP FollowGroupSet : The group AI escorting the FollowUnit.

  • #string From :

  • #string Event :

  • #string To :

  • #number XStart : The start position on the X-axis in meters for the first group.

  • #number XSpace : The space between groups on the X-axis in meters for each sequent group.

  • #nubmer YStart : The start position on the Y-axis in meters for the first group.

  • #nubmer ZStart : The start position on the Z-axis in meters for the first group.

  • #number ZSpace : The space between groups on the Z-axis in meters for each sequent group.

AI_FORMATION:OnBeforeFormationLeftLine(FollowGroupSet, From, Event, To, XStart, YStart, ZStart, ZSpace)

FormationLeftLine Handler OnBefore for AI_FORMATION

Parameters

  • Core.Set#SET_GROUP FollowGroupSet : The group AI escorting the FollowUnit.

  • #string From :

  • #string Event :

  • #string To :

  • #number XStart : The start position on the X-axis in meters for the first group.

  • #nubmer YStart : The start position on the Y-axis in meters for the first group.

  • #nubmer ZStart : The start position on the Z-axis in meters for the first group.

  • #number ZSpace : The space between groups on the Z-axis in meters for each sequent group.

Return value

#boolean:

AI_FORMATION:OnBeforeFormationLeftWing(FollowGroupSet, From, Event, To, XStart, XSpace, YStart, ZStart, ZSpace)

FormationLeftWing Handler OnBefore for AI_FORMATION

Parameters

  • Core.Set#SET_GROUP FollowGroupSet : The group AI escorting the FollowUnit.

  • #string From :

  • #string Event :

  • #string To :

  • #number XStart : The start position on the X-axis in meters for the first group.

  • #number XSpace : The space between groups on the X-axis in meters for each sequent group.

  • #nubmer YStart : The start position on the Y-axis in meters for the first group.

  • #nubmer ZStart : The start position on the Z-axis in meters for the first group.

  • #number ZSpace : The space between groups on the Z-axis in meters for each sequent group.

Return value

#boolean:

AI_FORMATION:OnBeforeFormationRightLine(FollowGroupSet, From, Event, To, XStart, YStart, ZStart, ZSpace)

FormationRightLine Handler OnBefore for AI_FORMATION

Parameters

  • Core.Set#SET_GROUP FollowGroupSet : The group AI escorting the FollowUnit.

  • #string From :

  • #string Event :

  • #string To :

  • #number XStart : The start position on the X-axis in meters for the first group.

  • #nubmer YStart : The start position on the Y-axis in meters for the first group.

  • #nubmer ZStart : The start position on the Z-axis in meters for the first group.

  • #number ZSpace : The space between groups on the Z-axis in meters for each sequent group.

Return value

#boolean:

AI_FORMATION:OnBeforeFormationRightWing(FollowGroupSet, From, Event, To, XStart, XSpace, YStart, ZStart, ZSpace)

FormationRightWing Handler OnBefore for AI_FORMATION

Parameters

  • Core.Set#SET_GROUP FollowGroupSet : The group AI escorting the FollowUnit.

  • #string From :

  • #string Event :

  • #string To :

  • #number XStart : The start position on the X-axis in meters for the first group.

  • #number XSpace : The space between groups on the X-axis in meters for each sequent group.

  • #nubmer YStart : The start position on the Y-axis in meters for the first group.

  • #nubmer ZStart : The start position on the Z-axis in meters for the first group.

  • #number ZSpace : The space between groups on the Z-axis in meters for each sequent group.

Return value

#boolean:

DCSTypes#AI.Option.Air.val.REACTION_ON_THREAT AI_FORMATION.OptionReactionOnThreat

Which REACTIONONTHREAT is set to the FollowGroup.

#boolean AI_FORMATION.ReportTargets

If true, nearby targets are reported.

AI_FORMATION.SmokeDirectionVector
AI_FORMATION:TestSmokeDirectionVector(SmokeDirection)

This function is for test, it will put on the frequency of the FollowScheduler a red smoke at the direction vector calculated for the escort to fly to.

This allows to visualize where the escort is flying to.

Parameter

  • #boolean SmokeDirection : If true, then the direction vector will be smoked.

Return value

#AI_FORMATION:

AI_FORMATION:__FormationLeftLine(Delay, XStart, YStart, ZStart, ZSpace)

FormationLeftLine Asynchronous Trigger for AI_FORMATION

Parameters

  • #number Delay :

  • #number XStart : The start position on the X-axis in meters for the first group.

  • #nubmer YStart : The start position on the Y-axis in meters for the first group.

  • #nubmer ZStart : The start position on the Z-axis in meters for the first group.

  • #number ZSpace : The space between groups on the Z-axis in meters for each sequent group.

AI_FORMATION:__FormationLeftWing(Delay, XStart, XSpace, YStart, ZStart, ZSpace)

FormationLeftWing Asynchronous Trigger for AI_FORMATION

Parameters

  • #number Delay :

  • #number XStart : The start position on the X-axis in meters for the first group.

  • #number XSpace : The space between groups on the X-axis in meters for each sequent group.

  • #nubmer YStart : The start position on the Y-axis in meters for the first group.

  • #nubmer ZStart : The start position on the Z-axis in meters for the first group.

  • #number ZSpace : The space between groups on the Z-axis in meters for each sequent group.

AI_FORMATION:__FormationRightLine(Delay, XStart, YStart, ZStart, ZSpace)

FormationRightLine Asynchronous Trigger for AI_FORMATION

Parameters

  • #number Delay :

  • #number XStart : The start position on the X-axis in meters for the first group.

  • #nubmer YStart : The start position on the Y-axis in meters for the first group.

  • #nubmer ZStart : The start position on the Z-axis in meters for the first group.

  • #number ZSpace : The space between groups on the Z-axis in meters for each sequent group.

AI_FORMATION:__FormationRightWing(Delay, XStart, XSpace, YStart, ZStart, ZSpace)

FormationRightWing Asynchronous Trigger for AI_FORMATION

Parameters

  • #number Delay :

  • #number XStart : The start position on the X-axis in meters for the first group.

  • #number XSpace : The space between groups on the X-axis in meters for each sequent group.

  • #nubmer YStart : The start position on the Y-axis in meters for the first group.

  • #nubmer ZStart : The start position on the Z-axis in meters for the first group.

  • #number ZSpace : The space between groups on the Z-axis in meters for each sequent group.

AI_FORMATION:onafterFormationLeftLine(FollowGroupSet, From, Event, To, XStart, YStart, ZStart, ZSpace)

Parameters

  • FollowGroupSet :

  • From :

  • Event :

  • To :

  • XStart :

  • YStart :

  • ZStart :

  • ZSpace :

AI_FORMATION:onafterFormationLeftWing(FollowGroupSet, From, Event, To, XStart, XSpace, YStart, ZStart, ZSpace)

Parameters

  • FollowGroupSet :

  • From :

  • Event :

  • To :

  • XStart :

  • XSpace :

  • YStart :

  • ZStart :

  • ZSpace :

AI_FORMATION:onafterFormationRightLine(FollowGroupSet, From, Event, To, XStart, YStart, ZStart, ZSpace)

Parameters

  • FollowGroupSet :

  • From :

  • Event :

  • To :

  • XStart :

  • YStart :

  • ZStart :

  • ZSpace :

AI_FORMATION:onafterFormationRightWing(FollowGroupSet, From, Event, To, XStart, XSpace, YStart, ZStart, ZSpace)

Parameters

  • FollowGroupSet :

  • From :

  • Event :

  • To :

  • XStart :

  • XSpace :

  • YStart :

  • ZStart :

  • ZSpace :

AI_FORMATION:onenterFollowing(FollowGroupSet)

Parameter

  • FollowGroupSet :

Type AI_FORMATION.MODE

AI_FORMATION.Mode class

Field(s)

#number AI_FORMATION.MODE.FOLLOW
#number AI_FORMATION.MODE.MISSION

Type Distance

Type MENUPARAM

MENUPARAM type

Field(s)

#Distance MENUPARAM.ParamDistance
#function MENUPARAM.ParamFunction
#string MENUPARAM.ParamMessage
#AI_FORMATION MENUPARAM.ParamSelf

Type nubmer