- Joined
- Aug 19, 2008
- Messages
- 491
Hey dudes, a quick question before I leave:
Is there any way I could 'go around' the Set Unit's Custom Value function?
I mean, by using variables and such to get the same result.
Why?
Well, I've solved a problem in my spell using this method, however I wanna make it 100% multi-instancable, and if a map uses this function for other features, it won't compile correctly.
Sorry for this quick question, but I'm in a hurry.
+Rep to the first dude who solves this!
Solved!
By a dude named grim001 in wc3c.net.
You can easily replace the Set/GetUnitUserData with an integer array, as long as the Index of the array is the 'id-number' of the unit. So a line like Set Footman's Custom Value to (Custom Value of (Footman)) + 1 will be Set Integer_Array[UnitId] = Set Integer_Array[UnitId] + 1
The "UnitId" can be obtained in this function: (only operational in vJass)
Is there any way I could 'go around' the Set Unit's Custom Value function?
I mean, by using variables and such to get the same result.
Why?
Well, I've solved a problem in my spell using this method, however I wanna make it 100% multi-instancable, and if a map uses this function for other features, it won't compile correctly.
Sorry for this quick question, but I'm in a hurry.
+Rep to the first dude who solves this!
Solved!
By a dude named grim001 in wc3c.net.
You can easily replace the Set/GetUnitUserData with an integer array, as long as the Index of the array is the 'id-number' of the unit. So a line like Set Footman's Custom Value to (Custom Value of (Footman)) + 1 will be Set Integer_Array[UnitId] = Set Integer_Array[UnitId] + 1
The "UnitId" can be obtained in this function: (only operational in vJass)
JASS:
//========================================
function H2I takes handle h returns integer
return h
return 0
endfunction
function GetUnitIndex takes unit u returns integer
return H2I(u) - 0x100000
//Note that the returned value is extremely large,
//so you have to remove some of the numbers with "- 0x100000"
endfunction
//========================================
function Actions takes nothing returns nothing
set UnitId = GetUnitIndex( f ) //Gets the unit's id
set Integer_Array[UnitId] = Set Integer_Array[UnitId] + 1 //"Set unit's custom value to +1"
endfunction
//========================================
Last edited: