SC2Mapster.com Wiki

UnitGetType

string UnitGetType (unit u);

Type of the unit.

Parameters

unit u

Unit to get the type

Return value

string - Type of the unit. Can be one of:

  • "Observer" (c_PU_Observer)
  • "Marauder" (c_TU_Marauder)
  • "Corruptor" (c_ZU_Corruptor)
  • ... full list ...

Examples

Example: Sample Usage
void Sample(unit u) {
  string type = UnitGetType(u);

  if (type == c_PU_WarpPrism) {
    // Warp Prism
  }
  if (UnitTypeTestAttribute(type, c_unitAttributeStructure)) {
    // Structure
  }
  if (UnitTypeTestFlag(type, c_unitFlagWorker)) {
    // Worker
  }
}

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

  • 1 comment
  • Avatar of Noio Noio Dec 06, 2010 at 12:44 UTC - 0 likes

    Though the return type is a string, the GUI doesn't know. In the GUI the return type is "UnitType", and it doesn't allow you to do an implicit cast, so some custom script is required to use this value for Catalog entries.

    Last edited Dec 06, 2010 by Noio
  • 1 comment

Facts

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

Author