• 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] JASS and UnitId

Status
Not open for further replies.
Level 2
Joined
Apr 8, 2009
Messages
21
Hey guys! I'm just beginning to move into JASS, and so far I've hit it off quite well, as I've managed to get some basic functions working. Anyway, I'm trying to create a little function that will move a unit/move camera/delete the "buying unit" when a unit is bought. I'm using a rect in an event (since when you buy the unit it enters the region) and I was going to make it check if it wasn't the wisp unit (which everyone gets on in the beginning), simply by checking if the ID for the unit wasn't the ID for the wisp and I've got this:

  • SpawnSelectHero
    • Events
      • Unit - A unit enters areaSpawnAreaHero <gen>
    • Conditions
    • Actions
      • Custom script: call SpawnSelectHero()
JASS:
//e000 is the Wisp ID
function SpawnSelectHero takes nothing returns nothing
    if UnitId2String(GetTriggerUnit()) != 'e000' then
        call SetUnitPositionLoc(GetTriggerUnit(), Location(-2580.0, -17994.0))
    endif
endfunction

I don't know how to convert GetTriggerUnit() into a UnitId to compare with 'e000' since the functions in the function list that relate to UnitId only return integer or string. Does anyone have an suggestions?
 
Level 9
Joined
Jul 10, 2011
Messages
562
its what Garfield1337 said.

the difference is that the UnitId is unique for every unit & the UnitTypeId is unique for the every unit type.
 
Level 13
Joined
Sep 13, 2010
Messages
550
UnitId2String means ConvertUnitIDintoString. But you can check what does the native take and return by shift clicking on the native: constant native UnitId2String takes integer unitId returns string

You were giving a unit instead an integer, and comparing a string with an integer.

Anyways, what are UnitID stuffs good for? :/

Also Handle ID: GetHandleId and unit type: GetUnitTypeId. Handle ID is unique for every handle, Unit Type ID is the 'u???' rawcode( integer ) stuff.
 
Anyways, what are UnitID stuffs good for? :/

See my group enumeration video to see what unit id strings are good for =). It's in my video tutorial on vjass.

edit
unit string id is a unique string for unit type id. It is used for group enumerations when selecting units of type (it takes string, not integer >.>).

'hbar' is humanbarrack as a string I believe.

Default unit type ids are racetype and custom have a small thing in front, an underscore, and then the unit type id.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Unit strings are localized if they are not defined by the mapmaker or if it's not a custom rawcode like said above.
For example in english UnitId2String('hfoo') == "footman" and "fantassin" in french, and something else in other languages.


EDIT : Ok, just tested it's the english name with UnitId2String, only GetObjectName returns the localized string.

Plus, UnitId2String always return null when it's a saved game.

Now you can edit the unit name to get rid of the localization issue, but you can't do anything about the saved game thing (except use your own custom function to substitute UnitId2String)
 
Last edited:
Status
Not open for further replies.
Top