# AI Pathing Cost Unit
Grammar — Pathing cost for unit unit to point to, considering buildings of type type
Flags —Native
|Function
Returns the pathing cost from a unit.
# Arguments
unit
— Unitpoint
— Tobool
<preset::AIPathBlockType> — Type
Returns — int
native int AIPathingCostUnit(
unit u,
point to,
bool ignoreEnemyBuildings,
);
# 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/starcoop/starcoop.sc2mod — base.sc2data/LibCOMI.galaxy:3767
if (lv_currentattacktargetunit == null) { break; }
if ((libNtve_gf_UnitCanCreateEffectOnUnit(lv_currentattacktargetunit, "ThreatTest", lp_attacker) == true) && ((UnitFilterMatch(lv_currentattacktargetunit, UnitGetOwner(lp_attacker), UnitFilter(0, 0, (1 << c_targetFilterCloaked), 0)) == true) || (libNtve_gf_UnitIsVisibleToPlayer(lv_currentattacktargetunit, UnitGetOwner(lp_attacker)) == true))) {
lv_currentpathingdistance = AIPathingCostUnit(lp_attacker, UnitGetPosition(lv_currentattacktargetunit), c_ignoreEnemyBuildings);
if ((lv_currentpathingdistance < lp_satisfiedPathingDistance)) {
lv_bestattacktargetunit = lv_currentattacktargetunit;
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMU.galaxy:4283
if ((PathingType(lv_spawnLocation) == c_pathingGround) && (PointPathingIsConnected(lv_spawnLocation, PlayerStartLocation(1)) == true)) {
UnitSetPosition(lv_birthingUnit, lv_spawnLocation, false);
if ((AIPathingCostUnit(lv_birthingUnit, PlayerStartLocation(1), c_ignoreEnemyBuildings) > 0)) {
break;
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMU.galaxy:5741
}
TriggerDebugOutput(1, IntToText(AIPathingCostUnit(UnitGroupUnit(UnitGroupSelected(1), 1), PlayerStartLocation(1), c_ignoreEnemyBuildings)), true);
return true;
}
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactCampAI.galaxy:1579
if ((TechTreeUpgradeCount(player, c_ZR_RoachUnderground, c_techCountCompleteOnly) > 0)) {
if (AIPathingCostUnit (aiUnit, AIWaveGoal(AIUnitGetWave(aiUnit)), true) < 0) {
return;
}
mods/starcoop/starcoop.sc2mod — base.sc2data/TriggerLibs/Tactical/TactCampAI.galaxy:1604
if (TechTreeUpgradeCount(player, c_ZR_RoachUnderground, c_techCountCompleteOnly) > 0) {
if (AIPathingCostUnit (aiUnit, AIWaveGoal(AIUnitGetWave(aiUnit)), true) < 0) {
return;
}