# Weapon Range
Grammar — Range of unit weapon weapon
Flags —Native
|Function
Returns a unit’s weapon range.
# Arguments
unit
— Unitint
— Weapon
Returns — fixed
native fixed UnitWeaponRange(unit inUnit, int inIndex);
# 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/heroesdata.stormmod — base.stormdata/TriggerLibs/AILib.galaxy:2205
lv_weaponIndex = 1;
for ( ; ( (autoEDA1BD1C_ai >= 0 && lv_weaponIndex <= autoEDA1BD1C_ae) || (autoEDA1BD1C_ai < 0 && lv_weaponIndex >= autoEDA1BD1C_ae) ) ; lv_weaponIndex += autoEDA1BD1C_ai ) {
if ((UnitWeaponIsEnabled(lp_unit, lv_weaponIndex) == true) && (UnitWeaponRange(lp_unit, lv_weaponIndex) > lv_bestRange)) {
lv_bestRange = UnitWeaponRange(lp_unit, lv_weaponIndex);
}
mods/heroesdata.stormmod — base.stormdata/TriggerLibs/AILib.galaxy:2206
for ( ; ( (autoEDA1BD1C_ai >= 0 && lv_weaponIndex <= autoEDA1BD1C_ae) || (autoEDA1BD1C_ai < 0 && lv_weaponIndex >= autoEDA1BD1C_ae) ) ; lv_weaponIndex += autoEDA1BD1C_ai ) {
if ((UnitWeaponIsEnabled(lp_unit, lv_weaponIndex) == true) && (UnitWeaponRange(lp_unit, lv_weaponIndex) > lv_bestRange)) {
lv_bestRange = UnitWeaponRange(lp_unit, lv_weaponIndex);
}
mods/warcoop/warclassicsystem.sc2mod — base.sc2data/TriggerLibs/Tactical/TacticalAIWar3.galaxy:433
}
ord = AICreateOrder(player, "Aatk", 0);
range=UnitWeaponRange(aiUnit,1);
AIWeaponGroup(player, weapon, scanGroup);
filter = AIFilter(player);