# Start AI
Grammar — Start AI for player player in mode mode with APM Actions Per Minute
Flags —Native
|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
— Playerbool
<preset::AIMode> — Modeint
— APM
Returns — void
native void AIStart(int player, bool isCampaign, int apm);
# Related
Category: AI Advanced / Utility / Actions
- Start AI —
void
— AIStart - Accept Surrender —
void
— AIGoodGame - Init Melee AI —
void
— AIMeleeStart - Set APM —
void
— AISetAPM - Release Unit —
void
— AIReleaseUnit - Set State —
void
— AISetSpecificState - Set All States —
void
— AISetAllStates - Set Flag —
void
— AISetFlag - Set Coop Flag —
void
— AISetCoopFlag - Set Tech Flag State —
void
— AITechFlag - Set Unit Evaluation Custom Index —
void
— AIEvalSetCustomIndex - Enable/Disable AI Option For Unit —
void
— UnitSetAIOption - Set Defense Radii —
void
— AISetDefenseRadii
# Examples
mods/core.sc2mod — base.sc2data/TriggerLibs/BaseAI.galaxy:107
int attackersLimit;
AIStart(player, false, DifficultyAPM(diff));
if (diff == c_skirChInsane) {
mods/core.sc2mod — base.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.sc2mod — base.sc2data/TriggerLibs/BaseAI.galaxy:143
int attackersLimit;
AIStart(player, false, DifficultyAPM(diff));
if (diff == c_skirChInsane) {
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/BaseAI.galaxy:287
int attackersLimit;
AIStart(player, true, DifficultyAPM(diff));
AIDeclareTown(player, c_townOne, PlayerStartLocation(player));
AISetMainTown(player, c_townOne);