# Start AI

Grammar — Start AI for player player in mode mode with APM Actions Per Minute
FlagsNative | Action

Starts the AI for a player in either campaign or melee mode, limiting the computer’s actions per minute to the specified number.

# Arguments

  • int — Player
  • bool<preset::AIMode> — Mode
  • int — APM

Returns — void

native void AIStart(int player, bool isCampaign, int apm);

Category: AI Advanced / Utility / Actions

# Examples

mods/core.sc2modbase.sc2data/TriggerLibs/BaseAI.galaxy:107

    int attackersLimit;

	AIStart(player, false, DifficultyAPM(diff));

    if (diff == c_skirChInsane) {

mods/core.sc2modbase.sc2data/TriggerLibs/BaseAI.galaxy:244

    int diff = AIPlayerDifficulty(player);
    
    AIStart(player, true, DifficultyAPM(diff));
    AIDeclareTown(player, c_townOne, PlayerStartLocation(player));
    AISetMainTown(player, c_townOne);

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/BaseAI.galaxy:143

    int attackersLimit;

	AIStart(player, false, DifficultyAPM(diff));

    if (diff == c_skirChInsane) {

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/BaseAI.galaxy:287

    int attackersLimit;
    
    AIStart(player, true, DifficultyAPM(diff));
	AIDeclareTown(player, c_townOne, PlayerStartLocation(player));
    AISetMainTown(player, c_townOne);