Module AI_Balancer
AI -- AI Balancing will replace in multi player missions non-occupied human slots with AI groups, in order to provide an engaging simulation environment, even when there are hardly any players in the mission.
Demo Missions
AI_BALANCER Demo Missions source code
AI_BALANCER Demo Missions, only for beta testers
ALL Demo Missions pack of the last release
YouTube Channel
AI_BALANCER YouTube Channel
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 :-)
Global(s)
| AI_BALANCER |
AI_BALANCER class, extends Fsm#FSM_SETThe AIBALANCER class monitors and manages as many replacement AI groups as there are CLIENTS in a SETCLIENT collection, which are not occupied by human players. |
Type AI_BALANCER
| AI_BALANCER.Earliest | |
| AI_BALANCER:InitSpawnInterval(Earliest, Latest) |
Sets the earliest to the latest interval in seconds how long AI_BALANCER will wait to spawn a new AI. |
| AI_BALANCER.Latest | |
| AI_BALANCER:New(SetClient, SpawnAI) |
Creates a new AI_BALANCER object |
| AI_BALANCER.ReturnAirbaseSet | |
| AI_BALANCER.ReturnThresholdRange | |
| AI_BALANCER:ReturnToHomeAirbase(ReturnThresholdRange) |
Returns the AI to the home Airbase#AIRBASE. |
| AI_BALANCER:ReturnToNearestAirbases(ReturnThresholdRange, ReturnAirbaseSet) |
Returns the AI to the nearest friendly Airbase#AIRBASE. |
| AI_BALANCER.SetClient | |
| AI_BALANCER.SpawnAI | |
| AI_BALANCER.Test | |
| AI_BALANCER.ToHomeAirbase | |
| AI_BALANCER.ToNearestAirbase | |
| AI_BALANCER:onenterDestroying(SetGroup, AIGroup, From, Event, To, ClientName) | |
| AI_BALANCER:onenterMonitoring(SetGroup) | |
| AI_BALANCER:onenterReturning(SetGroup, AIGroup, From, Event, To) | |
| AI_BALANCER:onenterSpawning(SetGroup, ClientName, AIGroup, From, Event, To) |
Global(s)
- #AI_BALANCER AI_BALANCER
-
AI_BALANCER class, extends Fsm#FSM_SET
The AIBALANCER class monitors and manages as many replacement AI groups as there are CLIENTS in a SETCLIENT collection, which are not occupied by human players.
In other words, use AI_BALANCER to simulate human behaviour by spawning in replacement AI in multi player missions.
The parent class Fsm#FSM_SET manages the functionality to control the Finite State Machine (FSM). The mission designer can tailor the behaviour of the AI_BALANCER, by defining event and state transition methods. An explanation about state and event transition methods can be found in the FSM module documentation.
The mission designer can tailor the AI_BALANCER behaviour, by implementing a state or event handling method for the following:
- AI_BALANCER.OnAfterSpawned( AISet, From, Event, To, AIGroup ): Define to add extra logic when an AI is spawned.
1. AI_BALANCER construction
Create a new AI_BALANCER object with the AI_BALANCER.New() method:
2. AI_BALANCER is a FSM
2.1. AI_BALANCER States
- Monitoring ( Set ): Monitoring the Set if all AI is spawned for the Clients.
- Spawning ( Set, ClientName ): There is a new AI group spawned with ClientName as the name of reference.
- Spawned ( Set, AIGroup ): A new AI has been spawned. You can handle this event to customize the AI behaviour with other AI FSMs or own processes.
- Destroying ( Set, AIGroup ): The AI is being destroyed.
- Returning ( Set, AIGroup ): The AI is returning to the airbase specified by the ReturnToAirbase methods. Handle this state to customize the return behaviour of the AI, if any.
2.2. AI_BALANCER Events
- Monitor ( Set ): Every 10 seconds, the Monitor event is triggered to monitor the Set.
- Spawn ( Set, ClientName ): Triggers when there is a new AI group to be spawned with ClientName as the name of reference.
- Spawned ( Set, AIGroup ): Triggers when a new AI has been spawned. You can handle this event to customize the AI behaviour with other AI FSMs or own processes.
- Destroy ( Set, AIGroup ): The AI is being destroyed.
- Return ( Set, AIGroup ): The AI is returning to the airbase specified by the ReturnToAirbase methods.
3. AI_BALANCER spawn interval for replacement AI
Use the method AI_BALANCER.InitSpawnInterval() to set the earliest and latest interval in seconds that is waited until a new replacement AI is spawned.
4. AI_BALANCER returns AI to Airbases
By default, When a human player joins a slot that is AI_BALANCED, the AI group will be destroyed by default. However, there are 2 additional options that you can use to customize the destroy behaviour. When a human player joins a slot, you can configure to let the AI return to:
- AI_BALANCER.ReturnToHomeAirbase: Returns the AI to the home Airbase#AIRBASE.
- AI_BALANCER.ReturnToNearestAirbases: Returns the AI to the nearest friendly Airbase#AIRBASE.
Note that when AI returns to an airbase, the AIBALANCER will trigger the Return event and the AI will return, otherwise the AIBALANCER will trigger a Destroy event, and the AI will be destroyed.
Type AI_Balancer
Type AI_BALANCER
Field(s)
- AI_BALANCER:InitSpawnInterval(Earliest, Latest)
-
Sets the earliest to the latest interval in seconds how long AI_BALANCER will wait to spawn a new AI.
Provide 2 identical seconds if the interval should be a fixed amount of seconds.
Parameters
-
#number Earliest: The earliest a new AI can be spawned in seconds. -
#number Latest: The latest a new AI can be spawned in seconds.
Return value
self
-
- AI_BALANCER:New(SetClient, SpawnAI)
-
Creates a new AI_BALANCER object
Parameters
-
Core.Set#SET_CLIENT SetClient: A SET_CLIENT object that will contain the CLIENT objects to be monitored if they are alive or not (joined by a player). -
Core.Spawn#SPAWN SpawnAI: The default Spawn object to spawn new AI Groups when needed.
Return value
-
- AI_BALANCER:ReturnToHomeAirbase(ReturnThresholdRange)
-
Returns the AI to the home Airbase#AIRBASE.
Parameter
-
Dcs.DCSTypes#Distance ReturnThresholdRange: If there is an enemy Client#CLIENT within the ReturnThresholdRange given in meters, the AI will not return to the nearest Airbase#AIRBASE.
-
- AI_BALANCER:ReturnToNearestAirbases(ReturnThresholdRange, ReturnAirbaseSet)
-
Returns the AI to the nearest friendly Airbase#AIRBASE.
Parameters
-
Dcs.DCSTypes#Distance ReturnThresholdRange: If there is an enemy Client#CLIENT within the ReturnThresholdRange given in meters, the AI will not return to the nearest Airbase#AIRBASE. -
Core.Set#SET_AIRBASE ReturnAirbaseSet: The SET of Set#SET_AIRBASEs to evaluate where to return to.
-
- #boolean AI_BALANCER.ToHomeAirbase
- #boolean AI_BALANCER.ToNearestAirbase
- AI_BALANCER:onenterDestroying(SetGroup, AIGroup, From, Event, To, ClientName)
-
Parameters
-
Core.Set#SET_GROUP SetGroup: -
Wrapper.Group#GROUP AIGroup: -
From: -
Event: -
To: -
ClientName:
-
- AI_BALANCER:onenterMonitoring(SetGroup)
-
Parameter
-
SetGroup:
-
- AI_BALANCER:onenterReturning(SetGroup, AIGroup, From, Event, To)
-
Parameters
-
Core.Set#SET_GROUP SetGroup: -
Wrapper.Group#GROUP AIGroup: -
From: -
Event: -
To:
-
- AI_BALANCER:onenterSpawning(SetGroup, ClientName, AIGroup, From, Event, To)
-
Parameters
-
Core.Set#SET_GROUP SetGroup: -
#string ClientName: -
Wrapper.Group#GROUP AIGroup: -
From: -
Event: -
To:
-