# Number Of Weapons On Unit
Grammar — Number of weapons on unit
Flags —Native
|Function
Returns the number of weapons on a unit.
# Arguments
unit
— Unit
Returns — int
native int UnitWeaponCount(unit inUnit);
# Related
Category: Unit / Weapons
- Remove Weapon From Unit —
void
— UnitWeaponRemove - Add Weapon To Unit —
void
— UnitWeaponAdd - Number Of Weapons On Unit —
int
— UnitWeaponCount - Unit Weapon —
string
<gamelink::Weapon> — UnitWeaponGet - Weapon Is Enabled —
bool
— UnitWeaponIsEnabled - Weapon Target Check —
bool
— UnitWeaponCheck - Weapon Cooldown —
fixed
— UnitWeaponPeriod - Weapon Range —
fixed
— UnitWeaponRange - Weapon Cooldown Remaining —
fixed
— UnitWeaponPeriodRemaining - Add Ammo To Magazine —
void
— UnitMagazineArm - Last Created Magazine Ammo Unit —
unit
— UnitMagazineLastCreated - Last Created Magazine Ammo Units —
unitgroup
— UnitMagazineLastCreatedGroup - Magazine Count Of Unit —
int
— UnitMagazineCount - Magazine Owner Of Unit —
unit
— UnitGetMagazine - Unit Can Attack Unit Old —
bool
— libNtve_gf_UnitCanAttackUnit - Unit Can Attack Unit Type —
bool
— UnitCanAttackTarget - Unit In Range And Able To Attack Target —
bool
— UnitInRangeAndAbleToAttackTarget - Weapon Damage —
fixed
— UnitWeaponDamage - Weapon Speed Multiplier —
fixed
— UnitWeaponSpeedMultiplier - Set Weapon Cooldown Remaining —
void
— UnitWeaponSetPeriodRemaining
# Examples
mods/core.sc2mod — base.sc2data/TriggerLibs/NativeLib.galaxy:5756
// Implementation
auto761381D2_ae = UnitWeaponCount(lp_u);
lv_weapon = 1;
for ( ; ( (auto761381D2_ai >= 0 && lv_weapon <= auto761381D2_ae) || (auto761381D2_ai < 0 && lv_weapon >= auto761381D2_ae) ) ; lv_weapon += auto761381D2_ai ) {
mods/core.sc2mod — base.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:1321
(UnitGetPropertyInt(unitToCheck, c_unitPropLife, c_unitPropCurrent) <= 400);
if ( (UnitWeaponCount(unitToCheck) == 0) && (isFarm == false) ) {
continue;
}
mods/core.stormmod — base.stormdata/TriggerLibs/NativeLib.galaxy:4894
// Implementation
auto761381D2_ae = UnitWeaponCount(lp_u);
lv_weapon = 1;
for ( ; ( (auto761381D2_ai >= 0 && lv_weapon <= auto761381D2_ae) || (auto761381D2_ai < 0 && lv_weapon >= auto761381D2_ae) ) ; lv_weapon += auto761381D2_ai ) {
mods/heroesdata.stormmod — base.stormdata/TriggerLibs/AILib.galaxy:2202
// Implementation
autoEDA1BD1C_ae = UnitWeaponCount(lp_unit);
lv_weaponIndex = 1;
for ( ; ( (autoEDA1BD1C_ai >= 0 && lv_weaponIndex <= autoEDA1BD1C_ae) || (autoEDA1BD1C_ai < 0 && lv_weaponIndex >= autoEDA1BD1C_ae) ) ; lv_weaponIndex += autoEDA1BD1C_ai ) {
mods/heroesdata.stormmod — base.stormdata/TriggerLibs/HeroesLib.galaxy:2535
// Implementation
auto91D56C1A_ae = UnitWeaponCount(lp_unit);
lv_itWeapon = 1;
for ( ; ( (auto91D56C1A_ai >= 0 && lv_itWeapon <= auto91D56C1A_ae) || (auto91D56C1A_ai < 0 && lv_itWeapon >= auto91D56C1A_ae) ) ; lv_itWeapon += auto91D56C1A_ai ) {
mods/heroesdata.stormmod — base.stormdata/TriggerLibs/HeroesLib.galaxy:2557
// Implementation
auto3CC89007_ae = UnitWeaponCount(lp_unit);
lv_itWeapon = 1;
for ( ; ( (auto3CC89007_ai >= 0 && lv_itWeapon <= auto3CC89007_ae) || (auto3CC89007_ai < 0 && lv_itWeapon >= auto3CC89007_ae) ) ; lv_itWeapon += auto3CC89007_ai ) {
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMI.galaxy:3446
return true;
}
else if ((UnitWeaponCount(lp_pingableUnit) <= 0)) {
return false;
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMU.galaxy:714
lv_nearbyUnit = UnitGroupUnitFromEnd(autoF1DA6167_g, autoF1DA6167_u);
if (lv_nearbyUnit == null) { break; }
if ((UnitWeaponCount(lv_nearbyUnit) == 0) && (UnitGetType(lv_nearbyUnit) != "VoidThrasher")) {
continue;
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMU.galaxy:999
// Implementation
if (((libCOMU_gv_cT_MutatorEnabledQuickList[(libCOMU_ge_CT_MutatorQuickList_CT_QuickSidestep)] == false) || (PlayerGroupHasPlayer(libCOOC_gf_HumanPlayers(), UnitGetOwner(lp_damagedUnit)) == true) || (PlayerGroupHasPlayer(PlayerGroupAlliance(c_playerGroupEnemy, UnitGetOwner(lp_damagingUnit)), UnitGetOwner(lp_damagedUnit)) == false) || (UnitFilterMatch(lp_damagedUnit, 1, UnitFilter(0, 0, (1 << c_targetFilterPlayer) | (1 << c_targetFilterAlly) | (1 << c_targetFilterNeutral) | (1 << c_targetFilterStructure) | (1 << c_targetFilterHeroic) | (1 << c_targetFilterMissile), (1 << (c_targetFilterHidden - 32)))) == false) || (UnitHasBehavior2(lp_damagedUnit, "MutatorSideStep") == true) || (UnitWeaponCount(lp_damagedUnit) == 0) || (UnitHasBehavior2(lp_damagedUnit, "UnitKnockback") == true))) {
return ;
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMU.galaxy:2417
lv_victim = UnitGroupUnitFromEnd(auto406256FF_g, auto406256FF_u);
if (lv_victim == null) { break; }
if ((UnitWeaponCount(lv_victim) <= 0) && (UnitFilterMatch(lv_victim, lp_owner, UnitFilter((1 << c_targetFilterStructure), 0, 0, 0)) == true)) {
UnitGroupRemove(lv_enemiesNearby, lv_victim);
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMU.galaxy:2983
}
if (((UnitWeaponCount(lv_bonusUnit) == 0) || (UnitIsValid(lv_bonusUnit) == false) || (UnitHasBehavior2(lv_bonusUnit, "MutatorAvenger") == true))) {
UnitGroupRemove(lv_bonusUnits, lv_bonusUnit);
continue;
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMU.galaxy:3735
}
if ((lp_ability == libCOMU_ge_CT_AllCastersAbilities_CT_AllCastersDisruptionWeb) && (UnitWeaponCount(lp_targetUnit) == 0)) {
return 0;
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMU.galaxy:11027
lv_dropTarget = UnitGroupUnitFromEnd(autoA95181C3_g, autoA95181C3_u);
if (lv_dropTarget == null) { break; }
if (((UnitWeaponCount(lv_dropTarget) == 0) || (UnitGetPropertyFixed(lv_dropTarget, c_unitPropSuppliesUsed, c_unitPropCurrent) <= 0.0) || (libCOOC_gf_CC_UnitIsInternal(lv_dropTarget) == true) || (UnitGetType(lv_dropTarget) == "QueenCoop") || (UnitGetType(lv_dropTarget) == "QueenCoopBurrowed") || (DistanceBetweenPoints(UnitGetPosition(lv_dropTarget), PlayerStartLocation(1)) <= 15.0) || (DistanceBetweenPoints(UnitGetPosition(lv_dropTarget), PlayerStartLocation(2)) <= 15.0))) {
UnitGroupRemove(lv_targetCandidates, lv_dropTarget);
}
mods/warcoop/warclassicsystem.sc2mod — base.sc2data/TriggerLibs/WarClassicTactical.galaxy:233
lv_itUnit = UnitGroupUnitFromEnd(auto2822F891_g, auto2822F891_u);
if (lv_itUnit == null) { break; }
auto05DEC010_ae = UnitWeaponCount(lv_itUnit);
lv_itWeaponIndex = 1;
for ( ; ( (auto05DEC010_ai >= 0 && lv_itWeaponIndex <= auto05DEC010_ae) || (auto05DEC010_ai < 0 && lv_itWeaponIndex >= auto05DEC010_ae) ) ; lv_itWeaponIndex += auto05DEC010_ai ) {
mods/warcoop/warclassicsystem.sc2mod — base.sc2data/TriggerLibs/WarClassicTactical.galaxy:298
lv_itUnit = UnitGroupUnitFromEnd(auto9461D501_g, auto9461D501_u);
if (lv_itUnit == null) { break; }
auto35BE4688_ae = UnitWeaponCount(lv_itUnit);
lv_itWeaponIndex = 1;
for ( ; ( (auto35BE4688_ai >= 0 && lv_itWeaponIndex <= auto35BE4688_ae) || (auto35BE4688_ai < 0 && lv_itWeaponIndex >= auto35BE4688_ae) ) ; lv_itWeaponIndex += auto35BE4688_ai ) {