# Unit Weapon

Grammarunit weapon weapon
FlagsNative | Function

Returns the weapon at the specified index on the specified unit.

# Arguments

  • unit — Unit
  • int — Weapon

Returns — string<gamelink::Weapon>

native string UnitWeaponGet(unit inUnit, int inIndex);

Category: Unit / Weapons

# Examples

mods/core.sc2modbase.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.stormmodbase.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.stormmodbase.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.stormmodbase.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.stormmodbase.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.stormmodbase.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.sc2modbase.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.sc2modbase.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.sc2modbase.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)) {