[Solved] A way to extract unit-type from given unit?

Status
Not open for further replies.
Level 4
Joined
Feb 18, 2011
Messages
62
So for the last days, I am stuck at this problem.
I want to make a JASS function(plz no vJASS) that takes a unit, and returns the raw code of the unit, in unit-type/integer/string form(form doesn't really matter as long it works)

I also have an global integer array(easily converted to unit-type or string if that helps), that stores all unit-type raw codes at map initialization(so the above function, will definitely take advantage of this)
 
Raw code ('h000') is an integer. It is just a different display style.
You can convert it with a lot of math:
Turn Item raw code into item ID

Should also work for units, but I am not sure.

If you have all raw codes as strings saved, you can assign every unit type it's raw code string with a hashtable using unit type (integer) as parent key, but I would try the math method first.
 
Hmmm.. I was testing that native function allday yesterday... Consistently failed result(always got 0 as text message at S2I and no unit at CreateUnit), but it works now(although I didnt test it onto complex stuff like yesterday)
Thanks!
If I bump into any problem related to that, will come back here :thumbs_up:

@Jampion I know about raw codes, and if I used hashtables(I don't :wink:) I would use that, but thanks anyway
 
Highly likely. But it matters not, these days I was testing that native func on a lot of stuff, and it seems like I can achieve what I want with its many uses.
Thanks DSG, time to put [SOLVED] onto this thread :grin:
 
Status
Not open for further replies.
Back
Top