SC2Mapster.com Wiki

SC2 API / Functions / UnitGetPropertyInt

UnitGetPropertyInt

int UnitGetPropertyInt (unit u, int property, bool current);

Property of a unit.

If you want to get a better precision in the result, you can use UnitGetPropertyFixed

Parameters

unit u

Unit to get the property

int property

Property of the unit. Can be one of

  • 0 (c_unitPropLife): Life
  • 1 (c_unitPropLifePercent): Life in percent.
  • 2 (c_unitPropLifeMax): Maximum life
  • 3 (c_unitPropLifeRegen): Life regeneration rate
  • 4 (c_unitPropEnergy): Energy
  • 5 (c_unitPropEnergyPercent): Energy in percent
  • 6 (c_unitPropEnergyMax): Maximum energy
  • 7 (c_unitPropEnergyRegen): Energy regeneration rate
  • 8 (c_unitPropShields): Shield
  • 9 (c_unitPropShieldsPercent): Shield in percent
  • 10 (c_unitPropShieldsMax): Maximum shield
  • 11 (c_unitPropShieldsRegen): Shield regeneration rate
  • 12 (c_unitPropSuppliesUsed): Amount of supplies/control/psi used
  • 13 (c_unitPropSuppliesMade): Amount of supplies/control/psi provided
  • 14 (c_unitPropKills): Amount of kills made by this unit
  • 15 (c_unitPropVitality): Vitality
  • 16 (c_unitPropVitalityPercent): Vitality in percent.
  • 17 (c_unitPropVitalityMax): Maximum vitality
  • 18 (c_unitPropAcceleration): Rate of acceleration
  • 19 (c_unitPropHeight): Height of unit
  • 20 (c_unitPropMovementSpeed): Movement speed
  • 21 (c_unitPropTurnRate): Turning speed
  • 22 (c_unitPropResources): Amount of resources carried(?)
  • 23 (c_unitPropRadius): Radius of unit (model size)
  • 24: Object ID. Each time an object (unit, building, doodad ...) is created on the map it gets a unique ID.

Notes

  • When the value is a percentage, 64% will be 64.
  • Percentage values make the game crash when current = false. Probably because of a division by 0.

Return value

int - Value of the property of the unit

Examples

Example #1: IsUnitDying
bool isUnitDying(unit u) {
  // Return true if the unit has less that 5% of life
  return UnitGetPropertyInt(u, c_unitPropVitalityPercent,
                             c_unitPropCurrent) < 5;
}
Example #2: UnitGetUniqueID
int UnitGetUniqueID(unit u) {
  // Return an ID unique to the unit
  return UnitGetPropertyInt(u, 24, c_unitPropCurrent);
}

You must login to post a comment. Don't have an account? Register to get one!

Facts

Date created
Mar 13, 2010
Last updated
Aug 11, 2010

Authors