• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Cannot assign Unittype to local

Status
Not open for further replies.
Level 2
Joined
Dec 1, 2008
Messages
7
For some reason my world editor does not accept unit codes to be assigned to local variables claiming that integers cannot be converted to unittype

I tried to reduce all error sources but even on a new map a simple function like this would generate the same error


JASS:
function test takes nothing returns nothing
local unittype u
set u = 'hpea'
endfunction

However, with functions that take a unittype as argument it works, like createunit(player, 'hpea', .....), would compile and work.
 
Level 14
Joined
Nov 18, 2007
Messages
816
JASS:
constant unittype UNIT_TYPE_ANCIENT=ConvertUnitType(19)
constant unittype UNIT_TYPE_ATTACKS_FLYING=ConvertUnitType(5)
constant unittype UNIT_TYPE_ATTACKS_GROUND=ConvertUnitType(6)
constant unittype UNIT_TYPE_DEAD=ConvertUnitType(1)
constant unittype UNIT_TYPE_ETHEREAL=ConvertUnitType(25)
constant unittype UNIT_TYPE_FLYING=ConvertUnitType(3)
constant unittype UNIT_TYPE_GIANT=ConvertUnitType(9)
constant unittype UNIT_TYPE_GROUND=ConvertUnitType(4)
constant unittype UNIT_TYPE_HERO=ConvertUnitType(0)
constant unittype UNIT_TYPE_MAGIC_IMMUNE=ConvertUnitType(26)
constant unittype UNIT_TYPE_MECHANICAL=ConvertUnitType(15)
constant unittype UNIT_TYPE_MELEE_ATTACKER=ConvertUnitType(7)
constant unittype UNIT_TYPE_PEON=ConvertUnitType(16)
constant unittype UNIT_TYPE_PLAGUED=ConvertUnitType(12)
constant unittype UNIT_TYPE_POISONED=ConvertUnitType(21)
constant unittype UNIT_TYPE_POLYMORPHED=ConvertUnitType(22)
constant unittype UNIT_TYPE_RANGED_ATTACKER=ConvertUnitType(8)
constant unittype UNIT_TYPE_RESISTANT=ConvertUnitType(24)
constant unittype UNIT_TYPE_SAPPER=ConvertUnitType(17)
constant unittype UNIT_TYPE_SLEEPING=ConvertUnitType(23)
constant unittype UNIT_TYPE_SNARED=ConvertUnitType(13)
constant unittype UNIT_TYPE_STRUCTURE=ConvertUnitType(2)
constant unittype UNIT_TYPE_STUNNED=ConvertUnitType(11)
constant unittype UNIT_TYPE_SUMMONED=ConvertUnitType(10)
constant unittype UNIT_TYPE_TAUREN=ConvertUnitType(20)
constant unittype UNIT_TYPE_TOWNHALL=ConvertUnitType(18)
constant unittype UNIT_TYPE_UNDEAD=ConvertUnitType(14)

These are unittypes.

'A000' and similar values are integers (base 256).
 
For some reason my world editor does not accept unit codes to be assigned to local variables claiming that integers cannot be converted to unittype

I tried to reduce all error sources but even on a new map a simple function like this would generate the same error


JASS:
function test takes nothing returns nothing
local unittype u
set u = 'hpea'
endfunction

However, with functions that take a unittype as argument it works, like createunit(player, 'hpea', .....), would compile and work.

'hpea' is a raw code and is considered as an integer so to store it you can use an integer variable.... but I don't see a use for storing the raw code of the unit which you already know,

if you're thinking of storing unittypes of units affected by maybe a triggered spell then you could use a function which does something like getting the unittype of the triggering unit I think there a function for this just search the functions library...
 
Level 3
Joined
Sep 11, 2004
Messages
63
I think unittype and the four char rawcode are not the same thing, unittype is classification of unit(undead etc), and rawcode is just a unique identification of unit object used in worldedit and map data.

Code:
function foo takes unit u returns nothing
local unittype ut
set ut = ConvertUnitType(GetUnitTypeId(u))

is what you wanted to do I guess
 
Status
Not open for further replies.
Top