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

[vJASS] GetUnitIdRace

Level 23
Joined
Feb 6, 2014
Messages
2,466
JASS:
library GetUnitIdRace 
    /******************************************************************    
                          GetUnitIdRace v1.00
                               by Flux
                                 
        Allows you to get the race of a unit based on the rawcode.
        Only works if the user followed the Blizzard Race rawcode 
        convention:
            H/h: RACE_HUMAN
            O/o: RACE_ORC
            U/u: RACE_UNDEAD
            E/e: RACE_NIGHTELF
       
        API:
            function GetUnitIdRace takes integer unitId returns race
   
    ******************************************************************/

    private struct Data extends array
       
        readonly static integer array raceId
       
        private static method onInit takes nothing returns nothing
            set thistype.raceId[0x48] = 1
            set thistype.raceId[0x68] = 1
            set thistype.raceId[0x4F] = 2
            set thistype.raceId[0x6F] = 2
            set thistype.raceId[0x55] = 3
            set thistype.raceId[0x75] = 3
            set thistype.raceId[0x45] = 4
            set thistype.raceId[0x65] = 4
        endmethod
       
    endstruct
   
    function GetUnitIdRace takes integer unitId returns race
        return ConvertRace(Data.raceId[unitId/(0x01000000)])
    endfunction
   
   
endlibrary

Changelog:
v1.00 - [16 July 2016]
- Initial Release
 
Level 23
Joined
Feb 6, 2014
Messages
2,466
Except that you can literally make any combination for any unit/item/destructable/doodad/ability/buff/upgrade... :p

The only thing you could really do is check if it is a hero... which we are already able to do.

I think ill just wait until ODE gets an update for 1.27
That's why I put this:
JASS:
/*
        Only works if the user followed the Blizzard Race rawcode
        convention:
            H/h: RACE_HUMAN
            O/o: RACE_ORC
            U/u: RACE_UNDEAD
            E/e: RACE_NIGHTELF
*/

Anyways, it was just a simple snippet I made and I thought it could still be useful to some so might as well upload it.
Could also be used as a reference about integers in rawcode form.
 
Top