1. Fill your cup and take your pick among the maps best suited for this year's Hive Cup. The 6th Melee Mapping Contest Poll is up!
    Dismiss Notice
  2. Shoot to thrill, play to kill. Sate your hunger with the 33rd Modeling Contest!
    Dismiss Notice
  3. Do you hear boss music? It's the 17th Mini Mapping Contest!
    Dismiss Notice
  4. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[vJASS] GetUnitIdRace

Discussion in 'JASS Resources' started by Flux, Jul 16, 2016.

Tags:
  1. Flux

    Flux

    Joined:
    Feb 6, 2014
    Messages:
    2,333
    Resources:
    28
    Maps:
    1
    Spells:
    19
    Tutorials:
    2
    JASS:
    6
    Resources:
    28
    Code (vJASS):

    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
     
  2. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,842
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    hehe now we need a library that defines the rawcode ie. 'A000' is an ability, 'B000' is a buff.
     
  3. DracoL1ch

    DracoL1ch

    Joined:
    Dec 12, 2010
    Messages:
    2,024
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    not really handy, calling buffs just like ability with lower case first letter much cooler
     
  4. Wietlol

    Wietlol

    Joined:
    Aug 1, 2013
    Messages:
    4,638
    Resources:
    3
    Spells:
    3
    Resources:
    3
    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
     
  5. Flux

    Flux

    Joined:
    Feb 6, 2014
    Messages:
    2,333
    Resources:
    28
    Maps:
    1
    Spells:
    19
    Tutorials:
    2
    JASS:
    6
    Resources:
    28
    That's why I put this:
    Code (vJASS):
    /*
            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.
     
  6. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,525
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    Can be useful.