# Unit Type Cost

GrammarinCostType cost of inUnitType
FlagsNative | Function

Returns the cost of a unit type.

# Arguments

  • string<gamelink::Unit> — Unit Type
  • int<preset::UnitCostType> — Resource Type

Returns — int

native int UnitTypeGetCost(
	string inUnitType,
	int inCostType,
);

Category: Unit / Properties

# Examples

campaigns/liberty.sc2campaignbase.sc2maps/maps/campaign/tzeratul02.sc2map/MapScript.galaxy:547

    }

    PlayerModifyPropertyInt(gv_p1_USER, c_playerPropMinerals, c_playerPropOperAdd, UnitTypeGetCost("Nexus", c_unitCostMinerals));
    libNtve_gf_SetAlliance(gv_p1_USER, gv_p5_ABANDONED_STRUCTURES, libNtve_ge_AllianceSetting_Neutral);
    libNtve_gf_SetAlliance(gv_p1_USER, gv_p7_NEUTRAL, libNtve_ge_AllianceSetting_Neutral);

campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign/tzeratul02.sc2mapMapScript.galaxy:547

    }

    PlayerModifyPropertyInt(gv_p1_USER, c_playerPropMinerals, c_playerPropOperAdd, UnitTypeGetCost("Nexus", c_unitCostMinerals));
    libNtve_gf_SetAlliance(gv_p1_USER, gv_p5_ABANDONED_STRUCTURES, libNtve_ge_AllianceSetting_Neutral);
    libNtve_gf_SetAlliance(gv_p1_USER, gv_p7_NEUTRAL, libNtve_ge_AllianceSetting_Neutral);

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/zlab03.sc2map/MapScript.galaxy:2723

        }

        if (!((PlayerGetPropertyInt(EventPlayer(), c_playerPropMinerals) >= UnitTypeGetCost("SpineCrawler", c_unitCostMinerals)))) {
            return false;
        }

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/zlab03.sc2mapMapScript.galaxy:2723

        }

        if (!((PlayerGetPropertyInt(EventPlayer(), c_playerPropMinerals) >= UnitTypeGetCost("SpineCrawler", c_unitCostMinerals)))) {
            return false;
        }

campaigns/voidstory.sc2campaignbase.sc2data/TriggerLibs/VoidCampaignLib.galaxy:10690

    DataTableSetInt(true, ("UnitMade_" + lv_iD), lv_previousValue);
    lv_previousValue = DataTableGetInt(true, ("MinSpent_" + lv_iD));
    DataTableSetInt(true, ("MinSpent_" + lv_iD), (lv_previousValue+UnitTypeGetCost(UnitGetType(EventUnitCreatedUnit()), c_unitCostMinerals)));
    lv_previousValue = DataTableGetInt(true, ("VesSpent_" + lv_iD));
    DataTableSetInt(true, ("VesSpent_" + lv_iD), (lv_previousValue+UnitTypeGetCost(UnitGetType(EventUnitCreatedUnit()), c_unitCostVespene)));

campaigns/voidstory.sc2campaignbase.sc2data/TriggerLibs/VoidCampaignLib.galaxy:10692

    DataTableSetInt(true, ("MinSpent_" + lv_iD), (lv_previousValue+UnitTypeGetCost(UnitGetType(EventUnitCreatedUnit()), c_unitCostMinerals)));
    lv_previousValue = DataTableGetInt(true, ("VesSpent_" + lv_iD));
    DataTableSetInt(true, ("VesSpent_" + lv_iD), (lv_previousValue+UnitTypeGetCost(UnitGetType(EventUnitCreatedUnit()), c_unitCostVespene)));
    return true;
}

campaigns/voidstory.sc2campaignbase.sc2data/TriggerLibs/VoidCampaignLib.galaxy:10750

            lv_previousValue = DataTableGetInt(true, ("DmgDone_" + lv_triggeringArmyString));
            DataTableSetInt(true, ("DmgDone_" + lv_triggeringArmyString), (lv_previousValue+FixedToInt(EventUnitDamageAmount())));
            lv_mineralValue = (EventUnitDamageAmount()*UnitTypeGetCost(UnitGetType(EventUnit()), c_unitCostMinerals)/UnitGetPropertyFixed(EventUnit(), c_unitPropLifeMax, c_unitPropCurrent));
            lv_previousValue = DataTableGetInt(true, ("MinDone_" + lv_triggeringArmyString));
            DataTableSetInt(true, ("MinDone_" + lv_triggeringArmyString), (lv_previousValue+FixedToInt(lv_mineralValue)));

campaigns/voidstory.sc2campaignbase.sc2data/TriggerLibs/VoidCampaignLib.galaxy:10753

            lv_previousValue = DataTableGetInt(true, ("MinDone_" + lv_triggeringArmyString));
            DataTableSetInt(true, ("MinDone_" + lv_triggeringArmyString), (lv_previousValue+FixedToInt(lv_mineralValue)));
            lv_vespeneValue = (EventUnitDamageAmount()*UnitTypeGetCost(UnitGetType(EventUnit()), c_unitCostVespene)/UnitGetPropertyFixed(EventUnit(), c_unitPropLifeMax, c_unitPropCurrent));
            lv_previousValue = DataTableGetInt(true, ("VesDone_" + lv_triggeringArmyString));
            DataTableSetInt(true, ("VesDone_" + lv_triggeringArmyString), (lv_previousValue+FixedToInt(lv_vespeneValue)));

campaigns/voidstory.sc2campaignbase.sc2data/TriggerLibs/VoidCampaignLib.galaxy:10867

            DataTableSetInt(true, ("UnitDied_" + lv_triggeringArmyString), (lv_previousValue+1));
            lv_previousValue = DataTableGetInt(true, ("MinLost_" + lv_triggeringArmyString));
            DataTableSetInt(true, ("MinLost_" + lv_triggeringArmyString), (lv_previousValue+UnitTypeGetCost(UnitGetType(EventUnit()), c_unitCostMinerals)));
            lv_previousValue = DataTableGetInt(true, ("VesLost_" + lv_triggeringArmyString));
            DataTableSetInt(true, ("VesLost_" + lv_triggeringArmyString), (lv_previousValue+UnitTypeGetCost(UnitGetType(EventUnit()), c_unitCostVespene)));

campaigns/voidstory.sc2campaignbase.sc2data/TriggerLibs/VoidCampaignLib.galaxy:10869

            DataTableSetInt(true, ("MinLost_" + lv_triggeringArmyString), (lv_previousValue+UnitTypeGetCost(UnitGetType(EventUnit()), c_unitCostMinerals)));
            lv_previousValue = DataTableGetInt(true, ("VesLost_" + lv_triggeringArmyString));
            DataTableSetInt(true, ("VesLost_" + lv_triggeringArmyString), (lv_previousValue+UnitTypeGetCost(UnitGetType(EventUnit()), c_unitCostVespene)));
        }

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:91

    libCOMI_gv_catalogAdditiveBonusPrefix = "CatalogAdditiveBonus";
    libCOMI_gv_candyChargeCmd = AbilityCommand("MutatorBuyCandy", 0);
    libCOMI_gv_supplicantWarpTrainActualUnitCost = UnitTypeGetCost("Supplicant", c_unitCostMinerals);
    libCOMI_gv_supplicantWarpTrainActualCommand = AbilityCommand("WarpGateTrainSupplicantTrue", 11);
    libCOMI_gv_cM_PrestigeRaynor_AirUnits = UnitGroupEmpty();

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:2091

                        UnitSetPropertyFixed(UnitLastCreated(), c_unitPropEnergyPercent, 100.0);
                        UnitGroupAdd(lv_attackForce, UnitLastCreated());
                        lv_resourcesForPlayer[lv_playerIter] -= UnitTypeGetCost(lv_unitTypeToCreate, c_unitCostSumMineralsVespene);
                        lv_unitCount -= 1;
                    }

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:2188

                        UnitSetPropertyFixed(lv_unitCreated, c_unitPropEnergyPercent, 100.0);
                        UnitGroupAdd(lv_attackForce, lv_unitCreated);
                        lv_resourcesForPlayer[lv_playerIter] -= UnitTypeGetCost(lv_unitTypeToCreate, c_unitCostSumMineralsVespene);
                        lv_unitCount -= 1;
                    }

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:2642

        }

        if ((UnitTypeGetCost(lv_unitTypesForWave[lv_unitPercentBaseIter], c_unitCostSumMineralsVespene) > 0)) {
            lv_unitPercentBaseCreateCount = MaxI(TruncI((lv_unitTypePercentBase[lv_unitPercentBaseIter] * lv_waveResourceTotal / UnitTypeGetCost(lv_unitTypesForWave[lv_unitPercentBaseIter], c_unitCostSumMineralsVespene))), 1);
        }

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:2643


        if ((UnitTypeGetCost(lv_unitTypesForWave[lv_unitPercentBaseIter], c_unitCostSumMineralsVespene) > 0)) {
            lv_unitPercentBaseCreateCount = MaxI(TruncI((lv_unitTypePercentBase[lv_unitPercentBaseIter] * lv_waveResourceTotal / UnitTypeGetCost(lv_unitTypesForWave[lv_unitPercentBaseIter], c_unitCostSumMineralsVespene))), 1);
        }
        else {

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:2654

            if ((lv_unitTypePerWaveLimit[lv_unitPercentBaseIter] > 0)) {
                lv_unitTypePerWaveLimit[lv_unitPercentBaseIter] -= 1;
                lv_waveResourceUsed += UnitTypeGetCost(lv_unitTypesForWave[lv_unitPercentBaseIter], c_unitCostSumMineralsVespene);
                libCOMI_gf_CM_CoopAI_AttackForce_AddUnitType(lv_unitTypesForWave[lv_unitPercentBaseIter], 1);
                if ((lv_waveResourceUsed > lv_waveResourceTotal)) {

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:2690

            }
        }
        if ((lv_randomUnitFailsafeBreakout == true) && ((lv_randomUnitType == null) || (UnitTypeGetCost(lv_randomUnitType, c_unitCostSumMineralsVespene) <= 0))) {
            TriggerDebugOutput(3, StringExternal("Param/Value/lib_COMI_6B70C116"), libCOMI_gv_showAIDebugging);
            break;

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:2694

            break;
        }
        else if (((lv_randomUnitType == null) || (UnitTypeGetCost(lv_randomUnitType, c_unitCostSumMineralsVespene) <= 0))) {
            lv_randomUnitTryCount += 1;
            continue;

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:2699

        }
        else if (true) {
            lv_waveResourceUsed += UnitTypeGetCost(lv_randomUnitType, c_unitCostSumMineralsVespene);
            lv_unitTypePerWaveLimit[lv_randomUnitIter] -= 1;
            libCOMI_gf_CM_CoopAI_AttackForce_AddUnitType(lv_randomUnitType, 1);

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:2998

        }

        if ((UnitTypeGetCost(lv_unitTypesForWave[lv_unitPercentBaseIter], c_unitCostSumMineralsVespene) > 0)) {
            lv_unitPercentBaseCreateCount = MaxI(TruncI((lv_unitTypePercentBase[lv_unitPercentBaseIter] * lv_waveResourceTotal / UnitTypeGetCost(lv_unitTypesForWave[lv_unitPercentBaseIter], c_unitCostSumMineralsVespene))), 1);
        }

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMU.galaxy:1183

        }

        if ((UnitTypeGetCost(UnitGetType(lp_orderedUnit), c_unitCostVespene) > 0) && (PlayerGetPropertyInt(lv_microPlayer, c_playerPropVespene) > 0) && (UnitGetType(lp_orderedUnit) != "Roach") && (UnitGetType(lp_orderedUnit) != "RoachVile")) {
            lv_useVespene = true;
        }

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMU.galaxy:4399

        libCOMU_gf_CT_RegisterSpawnedUnit(UnitLastCreated());
        UnitGroupAdd(libCOMU_gv_cT_VoidRiftLastSpawnedUnits, UnitLastCreated());
        lv_resourceValue -= UnitTypeGetCost(lv_spawnType, c_unitCostMinerals);
        lv_resourceValue -= UnitTypeGetCost(lv_spawnType, c_unitCostVespene);
    }

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMU.galaxy:4400

        UnitGroupAdd(libCOMU_gv_cT_VoidRiftLastSpawnedUnits, UnitLastCreated());
        lv_resourceValue -= UnitTypeGetCost(lv_spawnType, c_unitCostMinerals);
        lv_resourceValue -= UnitTypeGetCost(lv_spawnType, c_unitCostVespene);
    }
}