# Enable/Disable AI Option For Unit

Grammar — Sets the UnitAIOption option for unit u to state val|Enable/Disable
FlagsNative | Action

Enables or disables an AI option for a unit.

# Arguments

Returns — void

native void UnitSetAIOption(
	unit inUnit,
	int inOption,
	bool inVal,
);

Category: AI Advanced / Utility / Actions

# Examples

campaigns/void.sc2campaignbase.sc2maps/maps/campaign/void/pulnar01.sc2map/MapScript.galaxy:477

            UnitIssueOrder(auto2439952A_var, OrderTargetingPoint(null, PlayerStartLocation(UnitGetOwner(auto2439952A_var))), c_orderQueueReplace);
            AISetUnitScriptControlled(auto2439952A_var, false);
            UnitSetAIOption(auto2439952A_var, c_unitAIOptionUsable, true);
        }

campaigns/void.sc2campaignbase.sc2maps/maps/campaign/void/pulnar01.sc2map/MapScript.galaxy:1978

                auto010F39F1_var = UnitGroupUnitFromEnd(auto010F39F1_g, auto010F39F1_u);
                if (auto010F39F1_var == null) { break; }
                UnitSetAIOption(auto010F39F1_var, c_unitAIOptionUsable, false);
                libNtve_gf_AICast(auto010F39F1_var, OrderTargetingPoint(AbilityCommand("attack", 0), UnitGetPosition(UnitGroupClosestToPoint(UnitGroup(null, gv_pLAYER_01_USER, RegionCircle(UnitGetPosition(gv_titanicWarpPrism), 16.0), UnitFilter(0, 0, (1 << c_targetFilterMissile) | (1 << c_targetFilterCloaked), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0), UnitGetPosition(gv_titanicWarpPrism)))));
            }

campaigns/void.sc2campaignbase.sc2maps/maps/campaign/void/pulnar01.sc2map/MapScript.galaxy:1986

                auto84CB050C_var = UnitGroupUnitFromEnd(auto84CB050C_g, auto84CB050C_u);
                if (auto84CB050C_var == null) { break; }
                UnitSetAIOption(auto84CB050C_var, c_unitAIOptionUsable, false);
                libNtve_gf_AICast(auto84CB050C_var, OrderTargetingPoint(AbilityCommand("attack", 0), UnitGetPosition(UnitGroupClosestToPoint(UnitGroup(null, gv_pLAYER_01_USER, RegionCircle(UnitGetPosition(gv_titanicWarpPrism), 16.0), UnitFilter(0, 0, (1 << c_targetFilterMissile) | (1 << c_targetFilterCloaked), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0), UnitGetPosition(gv_titanicWarpPrism)))));
            }

campaigns/void.sc2campaignbase.sc2maps/maps/campaign/void/pulnar01.sc2map/MapScript.galaxy:1994

                auto6C6E1E30_var = UnitGroupUnitFromEnd(auto6C6E1E30_g, auto6C6E1E30_u);
                if (auto6C6E1E30_var == null) { break; }
                UnitSetAIOption(auto6C6E1E30_var, c_unitAIOptionUsable, false);
                libNtve_gf_AICast(auto6C6E1E30_var, OrderTargetingPoint(AbilityCommand("attack", 0), UnitGetPosition(UnitGroupClosestToPoint(UnitGroup(null, gv_pLAYER_01_USER, RegionCircle(UnitGetPosition(gv_titanicWarpPrism), 16.0), UnitFilter(0, 0, (1 << c_targetFilterMissile) | (1 << c_targetFilterCloaked), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0), UnitGetPosition(gv_titanicWarpPrism)))));
            }

campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/pulnar01.sc2mapMapScript.galaxy:477

            UnitIssueOrder(auto2439952A_var, OrderTargetingPoint(null, PlayerStartLocation(UnitGetOwner(auto2439952A_var))), c_orderQueueReplace);
            AISetUnitScriptControlled(auto2439952A_var, false);
            UnitSetAIOption(auto2439952A_var, c_unitAIOptionUsable, true);
        }

campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/pulnar01.sc2mapMapScript.galaxy:1978

                auto010F39F1_var = UnitGroupUnitFromEnd(auto010F39F1_g, auto010F39F1_u);
                if (auto010F39F1_var == null) { break; }
                UnitSetAIOption(auto010F39F1_var, c_unitAIOptionUsable, false);
                libNtve_gf_AICast(auto010F39F1_var, OrderTargetingPoint(AbilityCommand("attack", 0), UnitGetPosition(UnitGroupClosestToPoint(UnitGroup(null, gv_pLAYER_01_USER, RegionCircle(UnitGetPosition(gv_titanicWarpPrism), 16.0), UnitFilter(0, 0, (1 << c_targetFilterMissile) | (1 << c_targetFilterCloaked), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0), UnitGetPosition(gv_titanicWarpPrism)))));
            }

campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/pulnar01.sc2mapMapScript.galaxy:1986

                auto84CB050C_var = UnitGroupUnitFromEnd(auto84CB050C_g, auto84CB050C_u);
                if (auto84CB050C_var == null) { break; }
                UnitSetAIOption(auto84CB050C_var, c_unitAIOptionUsable, false);
                libNtve_gf_AICast(auto84CB050C_var, OrderTargetingPoint(AbilityCommand("attack", 0), UnitGetPosition(UnitGroupClosestToPoint(UnitGroup(null, gv_pLAYER_01_USER, RegionCircle(UnitGetPosition(gv_titanicWarpPrism), 16.0), UnitFilter(0, 0, (1 << c_targetFilterMissile) | (1 << c_targetFilterCloaked), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0), UnitGetPosition(gv_titanicWarpPrism)))));
            }

campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/pulnar01.sc2mapMapScript.galaxy:1994

                auto6C6E1E30_var = UnitGroupUnitFromEnd(auto6C6E1E30_g, auto6C6E1E30_u);
                if (auto6C6E1E30_var == null) { break; }
                UnitSetAIOption(auto6C6E1E30_var, c_unitAIOptionUsable, false);
                libNtve_gf_AICast(auto6C6E1E30_var, OrderTargetingPoint(AbilityCommand("attack", 0), UnitGetPosition(UnitGroupClosestToPoint(UnitGroup(null, gv_pLAYER_01_USER, RegionCircle(UnitGetPosition(gv_titanicWarpPrism), 16.0), UnitFilter(0, 0, (1 << c_targetFilterMissile) | (1 << c_targetFilterCloaked), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0), UnitGetPosition(gv_titanicWarpPrism)))));
            }