UnitCargoValue
int UnitCargoValue(unit u, int property);
Get a property related to Cargo from an unit.
Parameters
- unit u
The unit
- int property
- 0: Number of units in the cargo unit
- 1: Maximum number of slots the cargo unit has
- 2: Number of slots used by the cargo unit
- 3: Number of slots left in the cargo unit
- 4: Number of slots used by the unit
- 5: Maximum number of slots the cargo unit has.
- 6: Position of the unit in the cargo. From 1 to the cargo size
Return value
int - Property of the unit
Examples
- Example #1: UnitCargoIsEmpty
// A unit is a cargo if it has 1 or more slots bool UnitIsCargo(unit u) { return UnitCargoValue(u, 1) > 0; }
- Example #2: UnitIsCargoFull
// A cargo is full if it has no remaining slots bool UnitIsCargoFull(unit u) { return UnitCargoValue(u, 3); }