# Unit Is Script Controlled
Grammar — unit is script controlled
Flags —Native
|Function
Returns true if the unit is being controlled by scripts/triggers instead of by AI. This function only works for units owned by an AI player. Script-controlled units are not used by the AI for attack waves. Units that are issued orders via trigger actions are automatically marked as script-controlled. You can manually mark a unit as script-controlled using the Enable/Disable Script Control trigger actions.
# Arguments
unit
— Unit
Returns — bool
native bool AIIsScriptControlled(unit u);
# Related
Category: AI / MiscCampaign / Functions
- AI Time Is Paused —
bool
— AITimeIsPaused - Elapsed AI Time —
fixed
— AIGetTime - Wave Of Unit —
wave
— AIUnitGetWave - Units Of Wave —
unitgroup
— AIWaveGetUnits - Escorts Of Unit —
unitgroup
— AIGetAllEscorts - Escorts Of Unit Group —
unitgroup
— AIGetAllEscortsGroup - Units In Waves With Target —
unitgroup
— AIGetUnitsInWavesWithTarget - Unit Is Script Controlled —
bool
— AIIsScriptControlled - Unit Is Unavailable For Wave Use —
bool
— AIIsNotUsableInWaves - Unit Is Suicidal —
bool
— AIIsSuicideUnit - Difficulty Value (Integer) —
int
— libNtve_gf_DifficultyValueInt - Difficulty Value (Real) —
fixed
— libNtve_gf_DifficultyValueFixed - Difficulty Value (Unit Type) —
string
<gamelink::Unit> — libNtve_gf_DifficultyValueUnitType - Difficulty Is (one)
- Difficulty Is (two)
- Difficulty High
- Difficulty Low
- Random Spawn Point —
point
— AIRandomSpawnPoint
# Examples
campaigns/void.sc2campaign — base.sc2maps/maps/campaign/void/paiur06.sc2map/MapScript.galaxy:3163
}
if (!((AIIsScriptControlled(EventUnit()) == true))) {
return false;
}
campaigns/void.sc2campaign — base.sc2maps/maps/campaign/void/pkorhal01.sc2map/MapScript.galaxy:1455
lv_homePoint = UnitGetPosition(lp_flyer);
while ((UnitIsAlive(lp_flyer) == true)) {
if ((AIIsScriptControlled(lp_flyer) == true) && (UnitGroupCount(libVCMI_gf_AITacticalEnemiesWithinRange(lp_flyer, 10.0, UnitFilter(0, 0, (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)) | (1 << (c_targetFilterInvulnerable - 32)))), c_unitCountAlive) > 0)) {
UnitIssueOrder(lp_flyer, Order(AbilityCommand("stop", 0)), c_orderQueueReplace);
AISetUnitScriptControlled(lp_flyer, false);
campaigns/void.sc2campaign — base.sc2maps/maps/campaign/void/pkorhal01.sc2map/MapScript.galaxy:1460
}
if ((AIIsScriptControlled(lp_flyer) == false) && (DistanceBetweenPoints(UnitGetPosition(lp_flyer), lv_homePoint) > 12.0)) {
UnitIssueOrder(lp_flyer, OrderTargetingPoint(AbilityCommand("move", 0), lv_homePoint), c_orderQueueReplace);
UnitIssueOrder(lp_flyer, Order(AbilityCommand("move", 2)), c_orderQueueAddToEnd);
campaigns/void.sc2campaign — base.sc2maps/maps/campaign/void/ptaldarim01.sc2map/MapScript.galaxy:2413
auto065A6ADA_var = UnitGroupUnitFromEnd(auto065A6ADA_g, auto065A6ADA_u);
if (auto065A6ADA_var == null) { break; }
if ((AIIsScriptControlled(auto065A6ADA_var) == true)) {
AISetUnitScriptControlled(auto065A6ADA_var, false);
}
campaigns/void.sc2campaign — base.sc2maps/maps/campaign/void/ptaldarim01.sc2map/MapScript.galaxy:2534
auto2BE86D1D_var = UnitGroupUnitFromEnd(auto2BE86D1D_g, auto2BE86D1D_u);
if (auto2BE86D1D_var == null) { break; }
if ((AIIsScriptControlled(auto2BE86D1D_var) == true)) {
AISetUnitScriptControlled(auto2BE86D1D_var, false);
}
campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/paiur06.sc2map — MapScript.galaxy:3163
}
if (!((AIIsScriptControlled(EventUnit()) == true))) {
return false;
}
campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/pkorhal01.sc2map — MapScript.galaxy:1455
lv_homePoint = UnitGetPosition(lp_flyer);
while ((UnitIsAlive(lp_flyer) == true)) {
if ((AIIsScriptControlled(lp_flyer) == true) && (UnitGroupCount(libVCMI_gf_AITacticalEnemiesWithinRange(lp_flyer, 10.0, UnitFilter(0, 0, (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)) | (1 << (c_targetFilterInvulnerable - 32)))), c_unitCountAlive) > 0)) {
UnitIssueOrder(lp_flyer, Order(AbilityCommand("stop", 0)), c_orderQueueReplace);
AISetUnitScriptControlled(lp_flyer, false);
campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/pkorhal01.sc2map — MapScript.galaxy:1460
}
if ((AIIsScriptControlled(lp_flyer) == false) && (DistanceBetweenPoints(UnitGetPosition(lp_flyer), lv_homePoint) > 12.0)) {
UnitIssueOrder(lp_flyer, OrderTargetingPoint(AbilityCommand("move", 0), lv_homePoint), c_orderQueueReplace);
UnitIssueOrder(lp_flyer, Order(AbilityCommand("move", 2)), c_orderQueueAddToEnd);
campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/ptaldarim01.sc2map — MapScript.galaxy:2413
auto065A6ADA_var = UnitGroupUnitFromEnd(auto065A6ADA_g, auto065A6ADA_u);
if (auto065A6ADA_var == null) { break; }
if ((AIIsScriptControlled(auto065A6ADA_var) == true)) {
AISetUnitScriptControlled(auto065A6ADA_var, false);
}
campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/ptaldarim01.sc2map — MapScript.galaxy:2534
auto2BE86D1D_var = UnitGroupUnitFromEnd(auto2BE86D1D_g, auto2BE86D1D_u);
if (auto2BE86D1D_var == null) { break; }
if ((AIIsScriptControlled(auto2BE86D1D_var) == true)) {
AISetUnitScriptControlled(auto2BE86D1D_var, false);
}
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:787
continue;
}
if (AIIsScriptControlled(unitToCheck)) {
continue;
}
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:921
continue;
}
if (AIIsScriptControlled(unitToCheck)) {
continue;
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMI.galaxy:2080
auto514B4646_val = lv_unitTypeToCreate;
if (auto514B4646_val == "Scourge") {
if ((AIIsScriptControlled(UnitLastCreated()) == true)) {
UnitIssueOrder(UnitLastCreated(), Order(AbilityCommand("SuicideBuilding", 0)), c_orderQueueAddToFront);
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMI.galaxy:2175
auto43B5D7F2_val = lv_unitTypeToCreate;
if (auto43B5D7F2_val == "Scourge") {
if ((AIIsScriptControlled(UnitLastCreated()) == true)) {
UnitIssueOrder(UnitLastCreated(), Order(AbilityCommand("SuicideBuilding", 0)), c_orderQueueAddToFront);
}
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:763
continue;
}
if (AIIsScriptControlled(unitToCheck)) {
continue;
}
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:886
continue;
}
if (AIIsScriptControlled(unitToCheck)) {
continue;
}