• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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)
 

Jampion

Code Reviewer
Level 15
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