# Unit Is Script Controlled

Grammarunit is script controlled
FlagsNative | 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);

Category: AI / MiscCampaign / Functions

# Examples

campaigns/void.sc2campaignbase.sc2maps/maps/campaign/void/paiur06.sc2map/MapScript.galaxy:3163

        }

        if (!((AIIsScriptControlled(EventUnit()) == true))) {
            return false;
        }

campaigns/void.sc2campaignbase.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.sc2campaignbase.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.sc2campaignbase.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.sc2campaignbase.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.sc2mapMapScript.galaxy:3163

        }

        if (!((AIIsScriptControlled(EventUnit()) == true))) {
            return false;
        }

campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/pkorhal01.sc2mapMapScript.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.sc2mapMapScript.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.sc2mapMapScript.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.sc2mapMapScript.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.sc2modbase.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:787

            continue;
        }
        if (AIIsScriptControlled(unitToCheck)) {
            continue;
        }

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:921

                continue;
            }
            if (AIIsScriptControlled(unitToCheck)) {
                continue;
            }

mods/starcoop/starcoop.sc2modbase.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.sc2modbase.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.sc2modbase.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:763

            continue;
        }
        if (AIIsScriptControlled(unitToCheck)) {
            continue;
        }

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:886

                continue;
            }
            if (AIIsScriptControlled(unitToCheck)) {
                continue;
            }