# 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
FlagsNative | 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 — Player
  • string — Unit Type
  • int — Priority
  • point — Location

Returns — unit

native unit AIGrabUnit(
	int player,
	string aliasUnitType,
	int prio,
	point location,
);

Category: AI Advanced / Utility / Functions

# Examples

# mods/liberty.sc2mod

Protoss.galaxy

// L146
AIGrabUnit(player, c_PU_Probe, c_prioScout, null)
// L153
AIGrabUnit(player, c_PU_Observer, c_prioScout, null)
// L167
AIGrabUnit(player, c_PU_Probe, c_prioScout, null)
// L184
AIGrabUnit(player, c_PU_Observer, c_prioScout, null)
// L191
AIGrabUnit(player, c_PU_Zealot, c_prioScout, null)
// L201
AIGrabUnit(player, c_PU_Probe, c_prioScout, null)

# mods/liberty.sc2mod

Terran.galaxy

// L165
AIGrabUnit(player, c_TU_SCV, c_prioScout, null)
// L175
AIGrabUnit(player, c_TU_Medivac, c_prioScout, null)
// L192
AIGrabUnit(player, c_TU_SCV, c_prioScout, null)
// L209
AIGrabUnit(player, c_TU_Medivac, c_prioScout, null)
// L216
AIGrabUnit(player, c_TU_Marine, c_prioScout, null)
// L226
AIGrabUnit(player, c_TU_SCV, c_prioScout, null)

# mods/liberty.sc2mod

Zerg.galaxy

// L174
AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null)
// L181
AIGrabUnit(player, c_ZU_Drone, c_prioScout, null)
// L188
AIGrabUnit(player, c_ZU_Overseer, c_prioScout, null)
// L195
AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null)
// L202
AIGrabUnit(player, c_ZU_Drone, c_prioScout, null)
// L219
AIGrabUnit(player, c_ZU_Overseer, c_prioScout, null)
// L226
AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null)
// L236
AIGrabUnit(player, c_ZU_Drone, c_prioScout, null)

# mods/starcoop/starcoop.sc2mod

LibCOMI.galaxy

// L13087
AIGrabUnit(autoE0B4BAF2_var, (lv_detectors[lv_detectorsIter]), c_prioStaticBully, lv_cloakedAttackerLocation[auto62A946DE_var])

# mods/swarm.sc2mod

Protoss.galaxy

// L171
AIGrabUnit(player, c_PU_Probe, c_prioScout, null)
// L178
AIGrabUnit(player, c_PU_Observer, c_prioScout, null)
// L192
AIGrabUnit(player, c_PU_Probe, c_prioScout, null)
// L209
AIGrabUnit(player, c_PU_Observer, c_prioScout, null)
// L216
AIGrabUnit(player, c_PU_Zealot, c_prioScout, null)
// L226
AIGrabUnit(player, c_PU_Probe, c_prioScout, null)

# mods/swarm.sc2mod

Terran.galaxy

// L171
AIGrabUnit(player, c_TU_SCV, c_prioScout, null)
// L181
AIGrabUnit(player, c_TU_Medivac, c_prioScout, null)
// L198
AIGrabUnit(player, c_TU_SCV, c_prioScout, null)
// L215
AIGrabUnit(player, c_TU_Medivac, c_prioScout, null)
// L222
AIGrabUnit(player, c_TU_Marine, c_prioScout, null)
// L232
AIGrabUnit(player, c_TU_SCV, c_prioScout, null)

# mods/swarm.sc2mod

Zerg.galaxy

// L180
AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null)
// L187
AIGrabUnit(player, c_ZU_Drone, c_prioScout, null)
// L194
AIGrabUnit(player, c_ZU_Overseer, c_prioScout, null)
// L201
AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null)
// L208
AIGrabUnit(player, c_ZU_Drone, c_prioScout, null)
// L225
AIGrabUnit(player, c_ZU_Overseer, c_prioScout, null)
// L232
AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null)
// L242
AIGrabUnit(player, c_ZU_Drone, c_prioScout, null)

# mods/void.sc2mod

Protoss.galaxy

// L180
AIGrabUnit(player, c_PU_Probe, c_prioScout, null)
// L187
AIGrabUnit(player, c_PU_Observer, c_prioScout, null)
// L201
AIGrabUnit(player, c_PU_Probe, c_prioScout, null)
// L218
AIGrabUnit(player, c_PU_Observer, c_prioScout, null)
// L225
AIGrabUnit(player, c_PU_Zealot, c_prioScout, null)
// L235
AIGrabUnit(player, c_PU_Probe, c_prioScout, null)

# mods/void.sc2mod

Terran.galaxy

// L177
AIGrabUnit(player, c_TU_SCV, c_prioScout, null)
// L187
AIGrabUnit(player, c_TU_Medivac, c_prioScout, null)
// L204
AIGrabUnit(player, c_TU_SCV, c_prioScout, null)
// L221
AIGrabUnit(player, c_TU_Medivac, c_prioScout, null)
// L228
AIGrabUnit(player, c_TU_Marine, c_prioScout, null)
// L238
AIGrabUnit(player, c_TU_SCV, c_prioScout, null)

# mods/void.sc2mod

Zerg.galaxy

// L186
AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null)
// L193
AIGrabUnit(player, c_ZU_Drone, c_prioScout, null)
// L200
AIGrabUnit(player, c_ZU_Overseer, c_prioScout, null)
// L207
AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null)
// L214
AIGrabUnit(player, c_ZU_Drone, c_prioScout, null)
// L231
AIGrabUnit(player, c_ZU_Overseer, c_prioScout, null)
// L238
AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null)
// L248
AIGrabUnit(player, c_ZU_Drone, c_prioScout, null)

# mods/warcoop/warmeleeai.sc2mod

MeleeSC.galaxy

// L171
AIGrabUnit(player, c_TU_SCV, c_prioScout, null)
// L181
AIGrabUnit(player, c_TU_Medivac, c_prioScout, null)
// L198
AIGrabUnit(player, c_TU_SCV, c_prioScout, null)
// L215
AIGrabUnit(player, c_TU_Medivac, c_prioScout, null)
// L222
AIGrabUnit(player, c_TU_Marine, c_prioScout, null)
// L232
AIGrabUnit(player, c_TU_SCV, c_prioScout, null)

# mods/warcoop/warmeleeai.sc2mod

Orc.galaxy

// L568
AIGrabUnit(player, "opeo", c_prioScout, null)
// L581
AIGrabUnit(player, "opeo", c_prioScout, null)