• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Type mismatch? (unittype)

Status
Not open for further replies.
Level 4
Joined
Dec 30, 2009
Messages
60
I am trying to define a unit type and when defining with raw code it doesn't work. I get a Type Mismatch error.

Here is the snippet:
JASS:
local unittype Dmmy
//(INSERT OTHER CODE HERE)
//Dummy Unit RAW ID
    set Dmmy = 'h000'
//(INSERT OTHER CODE HERE)

All locals are defined in 1 place, right after the beginning of the function and before the first "set" code.

Simply, how do i set a unit type in jass?
 
Rawcodes are integers. =)

JASS:
local integer Dmmy
//(INSERT OTHER CODE HERE)
//Dummy Unit RAW ID
    set Dmmy = 'h000'
//(INSERT OTHER CODE HERE)

Here is a list of the constant unit-types Blizzard has, there might be more unit-types but these are the ones they bothered to make constants for:

UNIT_TYPE_ANCIENT
UNIT_TYPE_ATTACKS_FLYING
UNIT_TYPE_ATTACKS_GROUND
UNIT_TYPE_DEAD
UNIT_TYPE_ETHEREAL
UNIT_TYPE_FLYING
UNIT_TYPE_GIANT
UNIT_TYPE_GROUND
UNIT_TYPE_HERO
UNIT_TYPE_MAGIC_IMMUNE
UNIT_TYPE_MECHANICAL
UNIT_TYPE_MELEE_ATTACKER
UNIT_TYPE_PEON
UNIT_TYPE_PLAGUED
UNIT_TYPE_POISONED
UNIT_TYPE_POLYMORPHED
UNIT_TYPE_RANGED_ATTACKER
UNIT_TYPE_RESISTANT
UNIT_TYPE_SAPPER
UNIT_TYPE_SLEEPING
UNIT_TYPE_SNARED
UNIT_TYPE_STRUCTURE
UNIT_TYPE_STUNNED
UNIT_TYPE_SUMMONED
UNIT_TYPE_TAUREN
UNIT_TYPE_TOWNHALL
UNIT_TYPE_UNDEAD
 
JASS:
native          CreateUnit              takes player id, integer unitid, real x, real y, real face returns unit

So, you would do:
JASS:
call CreateUnit(Player(#),'rawcode',x-coordinate,y-coordinate,facing)

Example:
JASS:
call CreateUnit(Player(0),'hfoo',0,0,270)

This creates a footman for Player 1 (Red) at the coordinates (0,0) with default unit facing (270). Unit-types are really only used as checking for this:
JASS:
constant native IsUnitType          takes unit whichUnit, unittype whichUnitType returns boolean
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Some of the stuff blizzard did when implementing these types doesn't make much sense. For example, in the GUI interface abilities are represented by types known as Ability. However, when you do a direct conversion from GUI to JASS (convert to custom script) the function GetSpellAbilityId() returns an integer, rather than this mysterious ability type.

Even when GetUnitTypeId is used it returns an integer, though when used within the GUI interface it must be compared to a variable of type unittype. I find it strange how blizzard exceeds their expectations in certain areas and then in others they make obvious mistakes.
 
Status
Not open for further replies.
Top