• 🏆 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!

Multiple Custom Values

Status
Not open for further replies.
Level 3
Joined
May 26, 2009
Messages
34
Yes, make global variables with array and the array for each unit is the custom value of the unit:
  • Set custom_value2[(Custom value of (Your unit))] = 0
  • Set custom_value3[(Custom value of (Your unit))] = 1
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
JASS:
struct s_unit
    unit    subject             = null

    integer data1
    integer data2
    integer data3

    static method create takes unit u returns s_unit
        local s_unit su = s_unit.allocate()
            set su.subject = u
            call SetUnitUserData(u, su)
        return su
    endmethod
endstruct

Now, whenever you have the value of "s_unit" you can access the unit by substituting "sUnitVar.subject". If you have the value of the unit you can access the struct (and thus the other data values) by using "GetUnitUserData".

To access the other integers within the structure, you'd use: call s_unit( GetUnitUserData( someUnit ) ).data1. You can replace "data1" with "data2" or any other values that are defined within the s_unit struct.
 
Status
Not open for further replies.
Top