This section is dedicated to how the AI uses the abilties of units.
Ability Function Tables
Behaviours:
Ability.DoAbility (ability that is self-used on the unit itself) Ability.DoAbilityArea (ability can be activated in an area for an effect) Ability.DoAbilityPos (similiar to DoAbilityArea but targets the ability over a general specified area) Ability.DoAbilityTarget (ability MUST target specific unit or building to be used) Ability.DoAbilityFastMove (mostly used by Eldar to increase unit speed)
Filters:
CloseInfantryEnemy (ability is used close to enemy infantry only) CloseVehicleEnemy (ability is used close to enemy vehicles only) CloseCommanderEnemy (ability is used close to enemy commanders only) CloseEnemy (ability is used close to any kind of enemy unit) CloseInCombat (ability is used close to first enemy units in combat) IsInCombat (ability is used when threatened) LowMorale (ability is used when unit's morale falls below a certain value) CloseHurt (ability is used when unit's health falls below a certain threshold) CloseBroken (ability is used when unit's squad is broken)
Example Abilities
We will now use the above Behaviours and Filters to create a sample ability:
The following ability is activated on the unit but its resulting effect is the proximity around the unit. The resulting effect causes any units around this unit, whether infantry or vehicle, to take damage.
For the sake of this example, we will call the unit ability marines_hero_explode. The Unit is called Hero. This script gets placed in its own .tactic.ai file called herotactic.ai
function HeroTactic:__init( squad_ai ) super( squad_ai )
if Hero.explode_id == nil then
Hero.explode_id = cpu_manager.stats:GetAbilityID( "marines_hero_explode" )
end
function HeroTactic:DoAbilities()
Ability.DoAbilityArea( self.squad_ai, Hero.explode_id, Ability.Filters.CloseInCombat, 8 )
end
Note: The # value after "CloseInCombat" denotes the # of enemy units that need to be present around unit to activate the ability.