# Order Set Target Unit
Grammar — Set Target Unit for inOrder to inUnit
Flags —Native
|Action
# Arguments
order
— Orderunit
— Unit
Returns — void
native void OrderSetTargetUnit(order inOrder, unit inUnit);
# Related
Category: Order / Orders To Be Issued
- Order Targeting Item —
order
— OrderTargetingItem - Order Targeting Point —
order
— OrderTargetingPoint - Revive Order Targeting Point —
order
— libNtve_gf_ReviveOrderTargetingPoint - Order Targeting Relative Points —
order
— OrderTargetingRelativePoint - Order Targeting Unit —
order
— OrderTargetingUnit - Order Targeting Unit Group —
order
— OrderTargetingUnitGroup - Order Targeting Valid Unit In Group —
order
— AIUnitGroupGetValidOrder - Order With No Target —
order
— Order - Revive Order With No Target —
order
— libNtve_gf_ReviveOrderWithNoTarget - Change Autocast Mode —
order
— OrderSetAutoCast - Order Set Target Item —
void
— OrderSetTargetItem - Order Set Target Unit —
void
— OrderSetTargetUnit - Order Set Target Point —
void
— OrderSetTargetPoint - Order Set Target Passenger —
void
— OrderSetTargetPassenger
# Examples
campaigns/liberty.sc2campaign — base.sc2data/TriggerLibs/Tactical/TactCampAI.galaxy:356
scanCount = scanCount - 1;
OrderSetTargetUnit(ord, unitToCheck);
if (UnitOrderIsValid(aiUnit, ord)) {
AICast(aiUnit, ord, c_noMarker, c_castHold);
campaigns/swarm.sc2campaign — base.sc2data/TriggerLibs/Tactical/TactCampAI.galaxy:356
scanCount = scanCount - 1;
OrderSetTargetUnit(ord, unitToCheck);
if (UnitOrderIsValid(aiUnit, ord)) {
AICast(aiUnit, ord, c_noMarker, c_castHold);
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:500
}
OrderSetTargetUnit(ord, unitToCheck);
if (!UnitOrderIsValid(aiUnit, ord)) {
continue;
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:527
}
OrderSetTargetUnit(ord, targetBuilding);
if (!UnitOrderIsValid(aiUnit, ord)) {
// should always be valid since it was checked above
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:639
}
OrderSetTargetUnit(ord, targetUnit);
if (!UnitOrderIsValid(aiUnit, ord)) {
return null;
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:1447
if (bestReplicate >= 0) {
OrderSetTargetUnit(ord, bestUnit);
if (UnitOrderIsValid(aiUnit, ord)) {
return ord;
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:1817
if (targetUnit != null) {
OrderSetTargetUnit(ord, targetUnit);
}
else {
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:388
// Check target validity.
//
OrderSetTargetUnit(ord, target);
if (UnitOrderIsValid(aiUnit, ord)) {
return ord;
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:883
if (unitToCheck != null) {
ord = AICreateOrder(player, command, e_AB_TransportLoadUnit); // load the bunker.
OrderSetTargetUnit(ord, unitToCheck);
}
}
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:933
else {
ord = AICreateOrder(player, command, e_AB_TransportLoadUnit);
OrderSetTargetUnit(ord, unitToCheck);
}
break;
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:1634
}
if (airOnly == false || UnitTestPlane(curTarget, c_planeAir) == true) {
OrderSetTargetUnit(ord, curTarget);
if (UnitOrderIsValid(aiUnit, ord)) {
AICast(aiUnit, ord, c_noMarker, c_castHold);
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:1659
}
OrderSetTargetUnit(ord, UnitGroupUnit(targetGroup, 1));
if (UnitOrderIsValid(aiUnit, ord)) {
AICast(aiUnit, ord, c_noMarker, c_castHold);
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:329
target = UnitGroupClosestToPoint(airGroup, loc);
OrderSetTargetUnit(ord, target);
if (!UnitOrderIsValid(aiUnit, ord)) {
return null;
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:403
}
OrderSetTargetUnit(ord, targetUnit);
if (!UnitOrderIsValid(aiUnit, ord)) {
return null;
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:1331
if (immCount > 0) {
// randomly pick a threatening immobile unit
OrderSetTargetUnit(ord, UnitGroupUnit(immobileGroup, RandomInt(1, immCount)));
if (UnitOrderIsValid(aiUnit, ord)) {
return ord;
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:1339
// else just try any random target
OrderSetTargetUnit(ord, UnitGroupUnit(scanGroup, RandomInt(1, count)));
if (!UnitOrderIsValid(aiUnit, ord)) {
ord = AIUnitGroupGetValidOrder(scanGroup, ord, aiUnit, c_forwards);
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:1383
// try a random target first
OrderSetTargetUnit(ord, UnitGroupUnit(targetGroup, RandomInt(1, count)));
if (!UnitOrderIsValid(aiUnit, ord)) {
ord = AIUnitGroupGetValidOrder(targetGroup, ord, aiUnit, c_forwards);
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactCampAI.galaxy:712
scanCount = scanCount - 1;
OrderSetTargetUnit(ord, unitToCheck);
if (UnitOrderIsValid(aiUnit, ord)) {
AICast(aiUnit, ord, c_noMarker, c_castHold);
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactCampAI.galaxy:1068
target = UnitGroupUnit(enemyGroup, RandomInt(1, count));
if (UnitIsValid(target)) {
OrderSetTargetUnit(ord, target);
if (UnitOrderIsValid(aiUnit, ord)) {
return ord;
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactCampAI.galaxy:1693
}
OrderSetTargetUnit(ord, UnitGroupUnit(irradiateGroup, RandomInt(1, count)));
if (!UnitOrderIsValid(aiUnit, ord)) {
ord = AIUnitGroupGetValidOrder(irradiateGroup, ord, aiUnit, c_backwards);
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:493
}
OrderSetTargetUnit(ord, unitToCheck);
if (!UnitOrderIsValid(aiUnit, ord)) {
continue;
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:618
}
OrderSetTargetUnit(ord, targetUnit);
if (!UnitOrderIsValid(aiUnit, ord)) {
return null;
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:1448
if (bestReplicate >= 0) {
OrderSetTargetUnit(ord, bestUnit);
if (UnitOrderIsValid(aiUnit, ord)) {
return ord;
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:1806
if (targetUnit != null) {
OrderSetTargetUnit(ord, targetUnit);
}
else {
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:229
count = UnitGroupCount(targetGroup, c_unitCountAll);
OrderSetTargetUnit(ord, UnitGroupUnit(targetGroup, RandomInt(1, count)));
if (!UnitOrderIsValid(aiUnit, ord)) {
ord = AIUnitGroupGetValidOrder(targetGroup, ord, aiUnit, c_backwards);
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:370
// Check target validity.
//
OrderSetTargetUnit(ord, target);
if (UnitOrderIsValid(aiUnit, ord)) {
return ord;
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:854
if (unitToCheck != null) {
ord = AICreateOrder(player, command, e_AB_TransportLoadUnit); // load the bunker.
OrderSetTargetUnit(ord, unitToCheck);
}
}
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:898
else {
ord = AICreateOrder(player, command, e_AB_TransportLoadUnit);
OrderSetTargetUnit(ord, unitToCheck);
}
break;
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:1581
}
if (airOnly == false || UnitTestPlane(curTarget, c_planeAir) == true) {
OrderSetTargetUnit(ord, curTarget);
if (UnitOrderIsValid(aiUnit, ord)) {
AICast(aiUnit, ord, c_noMarker, c_castHold);
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:1606
}
OrderSetTargetUnit(ord, UnitGroupUnit(targetGroup, 1));
if (UnitOrderIsValid(aiUnit, ord)) {
AICast(aiUnit, ord, c_noMarker, c_castHold);
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:401
target = UnitGroupClosestToPoint(airGroup, loc);
OrderSetTargetUnit(ord, target);
if (!UnitOrderIsValid(aiUnit, ord)) {
return null;
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:614
}
OrderSetTargetUnit(ord, targetUnit);
if (!UnitOrderIsValid(aiUnit, ord)) {
return null;
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:1497
// try a random target first
OrderSetTargetUnit(ord, UnitGroupUnit(targetGroup, RandomInt(1, count)));
if (!UnitOrderIsValid(aiUnit, ord)) {
ord = AIUnitGroupGetValidOrder(targetGroup, ord, aiUnit, c_forwards);
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:1541
// try a random target first
OrderSetTargetUnit(ord, UnitGroupUnit(targetGroup, RandomInt(1, count)));
if (!UnitOrderIsValid(aiUnit, ord)) {
ord = AIUnitGroupGetValidOrder(targetGroup, ord, aiUnit, c_forwards);