# Unit Property (Int)

Grammaru prop (current|Current/Default)
FlagsNative | Function

Returns a unit property.

# Arguments

Returns — int

native int UnitGetPropertyInt(
	unit inUnit,
	int inProp,
	bool inCurrent,
);

Category: Unit / Properties

# Examples

mods/core.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:300


    // Defend against threats, unless we're almost done destroying the obstruction
    obsLife = UnitGetPropertyInt(obstruction, c_unitPropLifePercent, c_unitPropCurrent);
    if (obsLife > 15) {
        if (AIDefenseThreat(c_dtRealThreat, player, w)) {

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:102

            friendlyCount = friendlyCount - 1;

            friendlyVit = UnitGetPropertyInt(friendlyUnit, c_unitPropVitalityPercent, c_unitPropCurrent);
            if (friendlyVit < 20) {
                bestTargetUnit = enemyUnit;

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:121

    if (bestPrio == 0) {
        // no dangerous melee units found, split large ranged groups if we have extra energy 
        if (UnitGetPropertyInt(aiUnit, c_unitPropEnergy, c_unitPropCurrent) <= 125) {
            if (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) > 40) {
                // not about to die and won't have 75 energy left

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:122

        // no dangerous melee units found, split large ranged groups if we have extra energy 
        if (UnitGetPropertyInt(aiUnit, c_unitPropEnergy, c_unitPropCurrent) <= 125) {
            if (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) > 40) {
                // not about to die and won't have 75 energy left
                return false;

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:188

    
    // Save at least 70 energy for other spells, unless we're about to die
    if (UnitGetPropertyInt(aiUnit, c_unitPropEnergy, c_unitPropCurrent) <= 170) {
        if (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) > 25) {
            return false;

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:189

    // Save at least 70 energy for other spells, unless we're about to die
    if (UnitGetPropertyInt(aiUnit, c_unitPropEnergy, c_unitPropCurrent) <= 170) {
        if (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) > 25) {
            return false;
        }

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:481


    // if too few enemies rely on probes and the mothershipcore itself to defend
    if (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) < c_CoreLowVitalityPercent) {
        minEnemies = 2;
    } else {

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:897

    }
    
    lowVitality = (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) < c_HighTemplarLowVitPerc);
    
    mark = AIMarker(aiUnit, c_MK_Feedback);

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:1200

            return null; // no enemies
        }
        if (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) > 50) {
            return null; // not low health & too few enemies
        }

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:1612

        return null;
    }
    if (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) > c_AICarrierLowVitalityPercent) {
        return null;
    }

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:1654

        return null;
    }
    if (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) > 90) {
        return null;
    }

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:1101


    if (AISuspectDetectionDanger(player, c_lateDetectionDangerTime)) {
        if (UnitGetPropertyInt(aiUnit, c_unitPropEnergy, c_unitPropCurrent) < 150) {
            return; // save for two comsats
        }

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:1341

                missleOrd = AITacticalOrder(player, aiUnit, c_AB_SeekerMissile);
                if (missleOrd) {
                    if (UnitGetPropertyInt(aiUnit, c_unitPropEnergy, c_unitPropCurrent) < minToCastAutoTurret(player)) {
                        return false;
                    }

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:1440

    }

    lowVitality = UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) < c_RavenLowVitalityPercent;
    if (CastAutoTurret(player, aiUnit, scanGroup, lowVitality)) {
        AISetCooldown(aiUnit, c_hsMissileCooldown, sharedCoolDown);

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:96

    
    // Save at least 25 energy for spawn larva
    if (UnitGetPropertyInt(aiUnit, c_unitPropEnergy, c_unitPropCurrent) <= 50) {
        return null;
    }

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:583

    if (!lowVitality) {
        //  Reserve 50 leftover mana for neural parasite
        energy = UnitGetPropertyInt(aiUnit, c_unitPropEnergy, c_unitPropCurrent);
        if (energy < MinToCastInfestedTerrans(player) && !lowVitality) {
            return null;

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:708

    }

    lowVitality = (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) < infestorLowVitalityPercent);
    
    // neural parasite

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:1026

    }

    lowVitality = (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) < corruptorLowVitalityPercent);
    if (lowVitality) {
        minVitality = corruptionUrgentMinVitality;

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:1318

            if (UnitTypeTestAttribute(UnitGetType(unitToCheck), c_unitAttributeStructure) == true) {
                // don't target structures without weapons or is a farm  (providing food without a lot of health)
                isFarm = (UnitGetPropertyInt(unitToCheck, c_unitPropSuppliesMade, c_unitPropCurrent) > 0) &&
                         (UnitGetPropertyInt(unitToCheck, c_unitPropLife, c_unitPropCurrent) <= 400);

mods/core.sc2modbase.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:1319

                // don't target structures without weapons or is a farm  (providing food without a lot of health)
                isFarm = (UnitGetPropertyInt(unitToCheck, c_unitPropSuppliesMade, c_unitPropCurrent) > 0) &&
                         (UnitGetPropertyInt(unitToCheck, c_unitPropLife, c_unitPropCurrent) <= 400);

                if ( (UnitWeaponCount(unitToCheck) == 0) && (isFarm == false) ) {

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:103

            friendlyCount = friendlyCount - 1;

            friendlyVit = UnitGetPropertyInt(friendlyUnit, c_unitPropVitalityPercent, c_unitPropCurrent);
            if (friendlyVit < 20) {
                bestTargetUnit = enemyUnit;

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:123

        // no dangerous melee units found, split large ranged groups if we have extra energy 
    
        if (UnitGetPropertyInt(aiUnit, c_unitPropEnergy, c_unitPropCurrent) <= 125) {
            if (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) > 40) {
                // not about to die and won't have 75 energy left

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:124

    
        if (UnitGetPropertyInt(aiUnit, c_unitPropEnergy, c_unitPropCurrent) <= 125) {
            if (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) > 40) {
                // not about to die and won't have 75 energy left
                return false;

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:506


    // if too few enemies rely on probes and the mothershipcore itself to defend
    if (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) < c_CoreLowVitalityPercent) {
        minEnemies = 2;
    } else {

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:869

    }

    lowVitality = (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) < c_HighTemplarLowVitPerc);
    if (lowVitality) {
        if (MergeToSurvive(player, aiUnit, scanGroup)) {

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:1159

            return null; // no enemies
        }
        if (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) > 50) {
            return null; // not low health & too few enemies
        }

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:1601

        return null;
    }
    if (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) > c_AICarrierLowVitalityPercent) {
        return null;
    }

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactProtAI.galaxy:1643

        return null;
    }
    if (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) > 90) {
        return null;
    }

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:1084


    if (AISuspectDetectionDanger(player, 60)) {
        if (UnitGetPropertyInt(aiUnit, c_unitPropEnergy, c_unitPropCurrent) < 150) {
            return; // save for two comsats
        }

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:1313

                missleOrd = AITacticalOrder(player, aiUnit, c_AB_SeekerMissile);
                if (missleOrd) {
                    if (UnitGetPropertyInt(aiUnit, c_unitPropEnergy, c_unitPropCurrent) < minToCastAutoTurret(player)) {
                        return false;
                    }

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactTerrAI.galaxy:1393

    }

    lowVitality = UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) < c_RavenLowVitalityPercent;
    if (CastAutoTurret(player, aiUnit, scanGroup, lowVitality)) {
        return;

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:97

    
    // Save at least 25 energy for spawn larva
    if (UnitGetPropertyInt(aiUnit, c_unitPropEnergy, c_unitPropCurrent) <= 50) {
        return null;
    }

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:794

    if (!lowVitality && AIAlliedCommandWeakerHumanDifficulty() >= c_campAdvanced) {
        //  Reserve 50 leftover mana for neural parasite
        energy = UnitGetPropertyInt(aiUnit, c_unitPropEnergy, c_unitPropCurrent);
        if (energy < MinToCastInfestedTerrans(player) && !lowVitality) {
            return null;

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:921

    }

    lowVitality = (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) < infestorLowVitalityPercent);
    
    // neural parasite

mods/starcoop/starcoop.sc2modbase.sc2data/TriggerLibs/Tactical/TactZergAI.galaxy:1235

    }

    lowVitality = (UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent) < corruptorLowVitalityPercent);
    if (lowVitality) {
        minVitality = corruptionUrgentMinVitality;

mods/warcoop/warclassicsystem.sc2modbase.sc2data/TriggerLibs/Tactical/TacticalAIWar3.galaxy:480

		return;
	}
    if(UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent)<=30){
        hold=c_castRetreat;
    }

mods/warcoop/warclassicsystem.sc2modbase.sc2data/TriggerLibs/Tactical/TacticalAIWar3.galaxy:549

		return;
	}
    if(UnitGetPropertyInt(aiUnit, c_unitPropVitalityPercent, c_unitPropCurrent)<=30){
        hold=c_castRetreat;
    }

mods/warcoop/warclassicsystem.sc2modbase.sc2data/TriggerLibs/WarClassicSystem.galaxy:727

                lv_itUnit = UnitGroupUnitFromEnd(auto5AF0B447_g, auto5AF0B447_u);
                if (lv_itUnit == null) { break; }
                lv_itUnitLevel = UnitGetPropertyInt(lv_itUnit, c_unitPropLevel, c_unitPropCurrent);
                if ((lv_itUnitLevel == 0)) {
                    lv_itUnitLevel = CatalogFieldValueGetAsInt(c_gameCatalogUnit, UnitGetType(lv_itUnit), "Level", lv_itPlayer);

mods/warcoop/warmeleeai.sc2modbase.sc2data/TriggerLibs/Common_ai.galaxy:93

            for(;ui<=uc;ui+=1){
                u=UnitGroupUnit(mines,ui);
                amount+=UnitGetPropertyInt(u, c_unitPropResources, c_unitPropCurrent);
            }
        }

mods/warcoop/warmeleeai.sc2modbase.sc2data/TriggerLibs/MeleeWaveAI.galaxy:389


    // Defend against threats, unless we're almost done destroying the obstruction
    obsLife = UnitGetPropertyInt(obstruction, c_unitPropLifePercent, c_unitPropCurrent);
    if (GAw3_AIThreatedByNonHostilePlayer(player) && obsLife > 20) {
        AIDefendWithWave(player, w);