Module AI_Balancer
-
-Single-Player:No / Multi-Player:Yes / AI:Yes / Human:No / Types:All -- 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.
- -- -
1) AIBalancer#AIBALANCER class, extends Fsm#FSM_SET
- -The AIBalancer#AIBALANCER class monitors and manages as many replacement AI groups as there are -CLIENTS in a SET_CLIENT 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.1) AI_BALANCER construction
- -Create a new AI_BALANCER object with the AI_BALANCER.New() method:
- -1.2) AI_BALANCER is a FSM
- -1.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. -
1.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. -
1.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.
- -1.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.
- -- -
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-17: There is still a problem with AI being destroyed, but not respawned. Need to check further upon that.
- -2017-01-08: AI_BALANCER:InitSpawnInterval( Earliest, Latest ) added.
- -- -
AUTHORS and CONTRIBUTIONS
- -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 :-) -
- SNAFU: Had a couple of mails with the guys to validate, if the same concept in the GCI/CAP script could be reworked within MOOSE. None of the script code has been used however within the new AI_BALANCER moose class. -
Authors:
- --
-
- FlightControl: Framework Design & Programming and Documentation. -
Global(s)
-| AI_BALANCER | -- - | -
Type AI_BALANCER
- Global(s)
--
-
- - - #AI_BALANCER - -AI_BALANCER - - -
- - - - - -
Type AI_Balancer
-
- Type AI_BALANCER
-
-AI_BALANCER class
- -Field(s)
--
-
- - - - -AI_BALANCER.AIGroups - - -
- - - - - -
-
-
- - - #string - -AI_BALANCER.ClassName - - -
- - - - - -
-
-
- - - - -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.
- - -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.Latest - - -
- - - - - -
-
-
- - - -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).
- -
-
-
- -Functional.Spawn#SPAWN SpawnAI: -The default Spawn object to spawn new AI Groups when needed.
-
Return value
- - - - -
- -
-
-
-
-
- - - - -AI_BALANCER.PatrolZones - - -
- - - - - -
-
-
- - - - -AI_BALANCER.ReturnAirbaseSet - - -
- - - - - -
-
-
- - - -AI_BALANCER:ReturnToHomeAirbase(ReturnTresholdRange) - - -
-
-
-
Returns the AI to the home Airbase#AIRBASE.
- -Parameter
--
-
-
-
-
- -Dcs.DCSTypes#Distance ReturnTresholdRange: -If there is an enemy Client#CLIENT within the ReturnTresholdRange given in meters, the AI will not return to the nearest Airbase#AIRBASE.
-
- -
-
-
-
-
- - - -AI_BALANCER:ReturnToNearestAirbases(ReturnTresholdRange, ReturnAirbaseSet) - - -
-
-
-
Returns the AI to the nearest friendly Airbase#AIRBASE.
- -Parameters
--
-
-
-
-
- -Dcs.DCSTypes#Distance ReturnTresholdRange: -If there is an enemy Client#CLIENT within the ReturnTresholdRange 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.
-
- -
-
-
-
-
- - - - -AI_BALANCER.ReturnTresholdRange - - -
- - - - - -
-
-
- - - Core.Set#SET_CLIENT - -AI_BALANCER.SetClient - - -
- - - - - -
-
-
- - - Functional.Spawn#SPAWN - -AI_BALANCER.SpawnAI - - -
- - - - - -
-
-
- - - Wrapper.Group#GROUP - -AI_BALANCER.Test - - -
- - - - - -
-
-
- - - #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:
-
- -
-
-