# Enable/Disable AI Option For Unit
Grammar — Sets the UnitAIOption option for unit u to state val|Enable/Disable
Flags —Native
|Action
Enables or disables an AI option for a unit.
# Arguments
unit
— Unitint
<preset::UnitAIOption> — Optionbool
<preset::Enable_Disable_Option> — Enable
Returns — void
native void UnitSetAIOption(
unit inUnit,
int inOption,
bool inVal,
);
# 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
campaigns/void.sc2campaign — base.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.sc2campaign — base.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.sc2campaign — base.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.sc2campaign — base.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.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.sc2campaign/base.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.sc2campaign/base.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.sc2campaign/base.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)))));
}