IsUnitType

From WarCraft3

Jump to: navigation, search

Template:common.j article series


common.j

constant native IsUnitType          takes unit whichUnit, unittype whichUnitType returns boolean
Confused? Jass help forum!

This native checks if the unit whichUnit is of the unittype whichUnitType.

Bugs

The return value is a boolean that behaves slightly different than most other booleans in WC3. Booleans in WC3 are, as in many other programming languages, just integers. A value 0 means false and all other values mean true. However, the function used as boolean expressions behave differently. When a function is used as a boolexpr a return value of 1 means true and everything else is false. Normally this isn't a problem because all WC3 true booleans are 1, except the ones returned by IsUnitType. This means that if you return the value from IsUnitType in a boolexpr function you might get a false value when you really expected a true value. An easy fix to this is to always compare the return value of IsUnitType with true when used in a boolexpr function return.

Personal tools