# Grab Unit
Grammar — Find player player’s lowest priority unit of type unitType closest to the optional location location and claims it for a task of priority priority
Flags —Native
|Function
Finds a player’s lowest priority unit of the specified unit type, closest to the specified location, and claims it for a task, setting the priority of the new task.
# Arguments
int
— Playerstring
— Unit Typeint
— Prioritypoint
— Location
Returns — unit
native unit AIGrabUnit(
int player,
string aliasUnitType,
int prio,
point location,
);
# Related
Category: AI Advanced / Utility / Functions
- Is Point In Shrub —
bool
— InShrub - Is Campaign AI —
bool
— AIIsCampaign - Grab Unit —
unit
— AIGrabUnit - Get State —
int
— AIState - Get Flag —
bool
— AIGetFlag - Get Coop Flag —
bool
— AIGetCoopFlag - Unit Has AI Option —
bool
— UnitGetAIOption - Wants To Surrender —
bool
— AIGivingUp - AI Pathing Cost Map —
int
— AIPathingCostMap - AI Pathing Cost Unit —
int
— AIPathingCostUnit - AI Self Reinforce Point —
point
— AISelfReinforceDropPoint
# Examples
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:146
return prev;
}
return AIGrabUnit(player, c_PU_Probe, c_prioScout, null);
}
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:153
return prev;
}
obs = AIGrabUnit(player, c_PU_Observer, c_prioScout, null);
if (obs) {
return obs;
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:167
return c_nullUnit;
}
return AIGrabUnit(player, c_PU_Probe, c_prioScout, null);
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:184
return prev;
}
obs = AIGrabUnit(player, c_PU_Observer, c_prioScout, null);
if (obs) {
return obs;
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:191
return prev;
}
obs = AIGrabUnit(player, c_PU_Zealot, c_prioScout, null);
if (obs) {
return obs;
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:201
return c_nullUnit;
}
return AIGrabUnit(player, c_PU_Probe, c_prioScout, null);
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:165
return prev;
}
return AIGrabUnit(player, c_TU_SCV, c_prioScout, null);
}
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:175
return prev;
}
medivac = AIGrabUnit(player, c_TU_Medivac, c_prioScout, null);
if (medivac) {
return medivac;
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:192
return c_nullUnit;
}
return AIGrabUnit(player, c_TU_SCV, c_prioScout, null);
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:209
return prev;
}
obs = AIGrabUnit(player, c_TU_Medivac, c_prioScout, null);
if (obs) {
return obs;
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:216
return prev;
}
obs = AIGrabUnit(player, c_TU_Marine, c_prioScout, null);
if (obs) {
return obs;
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:226
return c_nullUnit;
}
return AIGrabUnit(player, c_TU_SCV, c_prioScout, null);
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:174
return prev;
}
scout = AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null);
if (scout) {
return scout;
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:181
return prev;
}
return AIGrabUnit(player, c_ZU_Drone, c_prioScout, null);
}
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:188
return prev;
}
scout = AIGrabUnit(player, c_ZU_Overseer, c_prioScout, null);
if (scout) {
return scout;
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:195
return prev;
}
scout = AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null);
if (scout) {
return scout;
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:202
return c_nullUnit;
}
return AIGrabUnit(player, c_ZU_Drone, c_prioScout, null);
}
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:219
return prev;
}
obs = AIGrabUnit(player, c_ZU_Overseer, c_prioScout, null);
if (obs) {
return obs;
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:226
return prev;
}
obs = AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null);
if (obs) {
return obs;
mods/liberty.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:236
return c_nullUnit;
}
return AIGrabUnit(player, c_ZU_Drone, c_prioScout, null);
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMI.galaxy:13123
lv_detectorsIter = 1;
for ( ; ( (auto6C9E8A6C_ai >= 0 && lv_detectorsIter <= auto6C9E8A6C_ae) || (auto6C9E8A6C_ai < 0 && lv_detectorsIter >= auto6C9E8A6C_ae) ) ; lv_detectorsIter += auto6C9E8A6C_ai ) {
lv_nearbyDetector = AIGrabUnit(autoE0B4BAF2_var, (lv_detectors[lv_detectorsIter]), c_prioStaticBully, lv_cloakedAttackerLocation[auto62A946DE_var]);
UnitGroupAdd(lv_nearbyDetectors, lv_nearbyDetector);
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:171
return prev;
}
return AIGrabUnit(player, c_PU_Probe, c_prioScout, null);
}
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:178
return prev;
}
obs = AIGrabUnit(player, c_PU_Observer, c_prioScout, null);
if (obs) {
return obs;
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:192
return c_nullUnit;
}
return AIGrabUnit(player, c_PU_Probe, c_prioScout, null);
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:209
return prev;
}
obs = AIGrabUnit(player, c_PU_Observer, c_prioScout, null);
if (obs) {
return obs;
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:216
return prev;
}
obs = AIGrabUnit(player, c_PU_Zealot, c_prioScout, null);
if (obs) {
return obs;
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:226
return c_nullUnit;
}
return AIGrabUnit(player, c_PU_Probe, c_prioScout, null);
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:171
return prev;
}
return AIGrabUnit(player, c_TU_SCV, c_prioScout, null);
}
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:181
return prev;
}
medivac = AIGrabUnit(player, c_TU_Medivac, c_prioScout, null);
if (medivac) {
return medivac;
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:198
return c_nullUnit;
}
return AIGrabUnit(player, c_TU_SCV, c_prioScout, null);
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:215
return prev;
}
obs = AIGrabUnit(player, c_TU_Medivac, c_prioScout, null);
if (obs) {
return obs;
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:222
return prev;
}
obs = AIGrabUnit(player, c_TU_Marine, c_prioScout, null);
if (obs) {
return obs;
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:232
return c_nullUnit;
}
return AIGrabUnit(player, c_TU_SCV, c_prioScout, null);
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:180
return prev;
}
scout = AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null);
if (scout) {
return scout;
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:187
return prev;
}
return AIGrabUnit(player, c_ZU_Drone, c_prioScout, null);
}
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:194
return prev;
}
scout = AIGrabUnit(player, c_ZU_Overseer, c_prioScout, null);
if (scout) {
return scout;
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:201
return prev;
}
scout = AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null);
if (scout) {
return scout;
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:208
return c_nullUnit;
}
return AIGrabUnit(player, c_ZU_Drone, c_prioScout, null);
}
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:225
return prev;
}
obs = AIGrabUnit(player, c_ZU_Overseer, c_prioScout, null);
if (obs) {
return obs;
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:232
return prev;
}
obs = AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null);
if (obs) {
return obs;
mods/swarm.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:242
return c_nullUnit;
}
return AIGrabUnit(player, c_ZU_Drone, c_prioScout, null);
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:180
return prev;
}
return AIGrabUnit(player, c_PU_Probe, c_prioScout, null);
}
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:187
return prev;
}
obs = AIGrabUnit(player, c_PU_Observer, c_prioScout, null);
if (obs) {
return obs;
mods/void.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:201
return c_nullUnit;
}
return AIGrabUnit(player, c_PU_Probe, c_prioScout, null);
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:218
return prev;
}
obs = AIGrabUnit(player, c_PU_Observer, c_prioScout, null);
if (obs) {
return obs;
mods/void.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:225
return prev;
}
obs = AIGrabUnit(player, c_PU_Zealot, c_prioScout, null);
if (obs) {
return obs;
mods/void.sc2mod — base.sc2data/TriggerLibs/Protoss/Protoss.galaxy:235
return c_nullUnit;
}
return AIGrabUnit(player, c_PU_Probe, c_prioScout, null);
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:177
return prev;
}
return AIGrabUnit(player, c_TU_SCV, c_prioScout, null);
}
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:187
return prev;
}
medivac = AIGrabUnit(player, c_TU_Medivac, c_prioScout, null);
if (medivac) {
return medivac;
mods/void.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:204
return c_nullUnit;
}
return AIGrabUnit(player, c_TU_SCV, c_prioScout, null);
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:221
return prev;
}
obs = AIGrabUnit(player, c_TU_Medivac, c_prioScout, null);
if (obs) {
return obs;
mods/void.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:228
return prev;
}
obs = AIGrabUnit(player, c_TU_Marine, c_prioScout, null);
if (obs) {
return obs;
mods/void.sc2mod — base.sc2data/TriggerLibs/Terran/Terran.galaxy:238
return c_nullUnit;
}
return AIGrabUnit(player, c_TU_SCV, c_prioScout, null);
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:186
return prev;
}
scout = AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null);
if (scout) {
return scout;
mods/void.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:193
return prev;
}
return AIGrabUnit(player, c_ZU_Drone, c_prioScout, null);
}
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:200
return prev;
}
scout = AIGrabUnit(player, c_ZU_Overseer, c_prioScout, null);
if (scout) {
return scout;
mods/void.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:207
return prev;
}
scout = AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null);
if (scout) {
return scout;
mods/void.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:214
return c_nullUnit;
}
return AIGrabUnit(player, c_ZU_Drone, c_prioScout, null);
}
mods/void.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:231
return prev;
}
obs = AIGrabUnit(player, c_ZU_Overseer, c_prioScout, null);
if (obs) {
return obs;
mods/void.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:238
return prev;
}
obs = AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null);
if (obs) {
return obs;
mods/void.sc2mod — base.sc2data/TriggerLibs/Zerg/Zerg.galaxy:248
return c_nullUnit;
}
return AIGrabUnit(player, c_ZU_Drone, c_prioScout, null);
}
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeSC.galaxy:171
return prev;
}
return AIGrabUnit(player, c_TU_SCV, c_prioScout, null);
}
}
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeSC.galaxy:181
return prev;
}
medivac = AIGrabUnit(player, c_TU_Medivac, c_prioScout, null);
if (medivac) {
return medivac;
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeSC.galaxy:198
return c_nullUnit;
}
return AIGrabUnit(player, c_TU_SCV, c_prioScout, null);
}
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeSC.galaxy:215
return prev;
}
obs = AIGrabUnit(player, c_TU_Medivac, c_prioScout, null);
if (obs) {
return obs;
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeSC.galaxy:222
return prev;
}
obs = AIGrabUnit(player, c_TU_Marine, c_prioScout, null);
if (obs) {
return obs;
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/MeleeSC.galaxy:232
return c_nullUnit;
}
return AIGrabUnit(player, c_TU_SCV, c_prioScout, null);
}
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/Orc/Orc.galaxy:568
return prev;
}
return AIGrabUnit(player, "opeo", c_prioScout, null);
}
}
mods/warcoop/warmeleeai.sc2mod — base.sc2data/TriggerLibs/Orc/Orc.galaxy:581
return c_nullUnit;
}
return AIGrabUnit(player, "opeo", c_prioScout, null);
}
void OrcInit(int player){