View Full Version : [JASS] JASS and UnitId
wiredbomb0
08-18-2012, 02:41 PM
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()
//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?
Garfield1337
08-18-2012, 02:49 PM
GetUnitTypeId(GetTriggerUnit()) != 'e000'
claptomanic
08-18-2012, 04:13 PM
its what Garfield1337 said.
the difference is that the UnitId is unique for every unit & the UnitTypeId is unique for the every unit type.
Geries
08-18-2012, 04:19 PM
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.
Nestharus
08-18-2012, 09:54 PM
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.
Troll-Brain
08-18-2012, 10:26 PM
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)
mckill2009
08-19-2012, 02:35 AM
Plus, UnitId2String always return null when it's a saved game.
that doesnt work for me coz it always returns null...
Troll-Brain
08-19-2012, 06:07 AM
that doesnt work for me coz it always returns null...
Then you use an invalid rawcode.
mckill2009
08-19-2012, 02:49 PM
Then you use an invalid rawcode.
F***!, my mistake!, as I've input orderID :P...
Troll-Brain
08-19-2012, 03:08 PM
F***!, my mistake!, as I've input orderID :P...
It should work with upgrading unit orders, and/or constructing ones.
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.
Search Engine Optimization by
vBSEO 3.5.1 PL2