• 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.

[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)
 
Level 16
Joined
Mar 25, 2016
Messages
1,327
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.
 
Level 4
Joined
Feb 18, 2011
Messages
62
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
 
Level 4
Joined
Feb 18, 2011
Messages
62
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.
Top