# Unit Weapon
Grammar — unit weapon weapon
Flags —Native
|Function
Returns the weapon at the specified index on the specified unit.
# Arguments
unit
— Unitint
— Weapon
Returns — string
<gamelink::Weapon>
native string UnitWeaponGet(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/core.sc2mod — base.sc2data/TriggerLibs/NativeLib.galaxy:5759
lv_weapon = 1;
for ( ; ( (auto761381D2_ai >= 0 && lv_weapon <= auto761381D2_ae) || (auto761381D2_ai < 0 && lv_weapon >= auto761381D2_ae) ) ; lv_weapon += auto761381D2_ai ) {
lv_weaponFilter = libNtve_gf_ConvertTargetFilterStringToUnitFilter(CatalogFieldValueGet(c_gameCatalogWeapon, UnitWeaponGet(lp_u, lv_weapon), "TargetFilters", UnitGetOwner(lp_u)));
if ((UnitWeaponIsEnabled(lp_u, lv_weapon) == true) && (UnitFilterMatch(lp_s, UnitGetOwner(lp_u), lv_weaponFilter) == true)) {
return true;
mods/core.stormmod — base.stormdata/TriggerLibs/NativeLib.galaxy:4897
lv_weapon = 1;
for ( ; ( (auto761381D2_ai >= 0 && lv_weapon <= auto761381D2_ae) || (auto761381D2_ai < 0 && lv_weapon >= auto761381D2_ae) ) ; lv_weapon += auto761381D2_ai ) {
lv_weaponFilter = libNtve_gf_ConvertTargetFilterStringToUnitFilter(CatalogFieldValueGet(c_gameCatalogWeapon, UnitWeaponGet(lp_u, lv_weapon), "TargetFilters", UnitGetOwner(lp_u)));
if ((UnitWeaponIsEnabled(lp_u, lv_weapon) == true) && (UnitFilterMatch(lp_s, UnitGetOwner(lp_u), lv_weaponFilter) == true)) {
return true;
mods/heroesdata.stormmod — base.stormdata/TriggerLibs/HeroesLib.galaxy:2538
lv_itWeapon = 1;
for ( ; ( (auto91D56C1A_ai >= 0 && lv_itWeapon <= auto91D56C1A_ae) || (auto91D56C1A_ai < 0 && lv_itWeapon >= auto91D56C1A_ae) ) ; lv_itWeapon += auto91D56C1A_ai ) {
if ((UnitWeaponGet(lp_unit, lv_itWeapon) != null) && (UnitWeaponIsEnabled(lp_unit, lv_itWeapon) == true)) {
return UnitWeaponDamage(lp_unit, lv_itWeapon, c_unitAttributeNone, false);
}
mods/heroesdata.stormmod — base.stormdata/TriggerLibs/HeroesLib.galaxy:2560
lv_itWeapon = 1;
for ( ; ( (auto3CC89007_ai >= 0 && lv_itWeapon <= auto3CC89007_ae) || (auto3CC89007_ai < 0 && lv_itWeapon >= auto3CC89007_ae) ) ; lv_itWeapon += auto3CC89007_ai ) {
if ((UnitWeaponGet(lp_unit, lv_itWeapon) != null) && (UnitWeaponIsEnabled(lp_unit, lv_itWeapon) == true)) {
return UnitWeaponSpeedMultiplier(lp_unit, lv_itWeapon);
}
mods/heroesdata.stormmod — base.stormdata/TriggerLibs/SupportLib.galaxy:8819
lv_baseHealthRegen = FixedToText(CatalogFieldValueGetAsFixed(c_gameCatalogUnit, UnitGetType(lv_selectedUnit), "LifeRegenRate", 0), c_fixedPrecisionAny);
lv_baseHealthScaling = FixedToText(CatalogFieldValueGetAsFixed(c_gameCatalogHero, PlayerHero(EventPlayer()), "LevelScalingArray[" + IntToString(6) + "].Modifications[" + IntToString(1) + "].Value", 0), c_fixedPrecisionAny);
lv_weaponDamage = FixedToText(CatalogFieldValueGetAsFixed(c_gameCatalogEffect, CatalogFieldValueGet(c_gameCatalogWeapon, UnitWeaponGet(lv_selectedUnit, 1), "DisplayEffect", c_playerAny), "Amount", 0), c_fixedPrecisionAny);
}
else if (true) {
mods/heroesdata.stormmod — base.stormdata/TriggerLibs/SupportLib.galaxy:8825
lv_baseHealthRegen = FixedToText(CatalogFieldValueGetAsFixed(c_gameCatalogUnit, UnitGetType(lv_selectedUnit), "LifeRegenRate", 0), c_fixedPrecisionAny);
lv_baseHealthScaling = FixedToText(CatalogFieldValueGetAsFixed(c_gameCatalogHero, PlayerHero(EventPlayer()), "LevelScalingArray[" + IntToString(1) + "].Modifications[" + IntToString(0) + "].Value", 0), c_fixedPrecisionAny);
lv_weaponDamage = FixedToText(CatalogFieldValueGetAsFixed(c_gameCatalogEffect, CatalogFieldValueGet(c_gameCatalogWeapon, UnitWeaponGet(lv_selectedUnit, 1), "DisplayEffect", c_playerAny), "Amount", 0), c_fixedPrecisionAny);
}
UIDisplayMessage(PlayerGroupActive(), c_messageAreaChat, (StringExternal("Param/Value/lib_Sprt_89ADB976") + UnitGetName(auto8C3F4A95_var)));
mods/warcoop/warclassicsystem.sc2mod — base.sc2data/TriggerLibs/Tactical/TacticalAIWar3.galaxy:428
WakeUpCreepGroupAndAttackTarget(creepGroup,oldTar);
}
weapon=UnitWeaponGet(aiUnit,1);
if(CatalogFieldValueGet(c_gameCatalogWeapon, weapon, "Name", c_playerAny) == "DAMAGE_CHAOS"){
chaos=true;
mods/warcoop/warclassicsystem.sc2mod — base.sc2data/TriggerLibs/WarClassicTactical.galaxy:236
lv_itWeaponIndex = 1;
for ( ; ( (auto05DEC010_ai >= 0 && lv_itWeaponIndex <= auto05DEC010_ae) || (auto05DEC010_ai < 0 && lv_itWeaponIndex >= auto05DEC010_ae) ) ; lv_itWeaponIndex += auto05DEC010_ai ) {
lv_itWeapon = UnitWeaponGet(lv_itUnit, lv_itWeaponIndex);
if ((UnitWeaponIsEnabled(lv_itUnit, lv_itWeaponIndex) == true) && (libGAw3_gf_GAw3_WeaponAtkType(lv_itWeapon) == "Pierce")) {
if ((lv_canDefend == true)) {
mods/warcoop/warclassicsystem.sc2mod — base.sc2data/TriggerLibs/WarClassicTactical.galaxy:301
lv_itWeaponIndex = 1;
for ( ; ( (auto35BE4688_ai >= 0 && lv_itWeaponIndex <= auto35BE4688_ae) || (auto35BE4688_ai < 0 && lv_itWeaponIndex >= auto35BE4688_ae) ) ; lv_itWeaponIndex += auto35BE4688_ai ) {
lv_itWeapon = UnitWeaponGet(lv_itUnit, lv_itWeaponIndex);
if ((UnitWeaponIsEnabled(lv_itUnit, lv_itWeaponIndex) == true) && (libGAw3_gf_GAw3_WeaponAtkType(lv_itWeapon) == "Magic")) {
if ((lv_canDefend == true)) {