- Joined
- Aug 7, 2013
- Messages
- 1,338
Hi,
So suppose I've got a few hundred unique unit types, each of which correspond to some unique object/struct in the map code.
To bind these unit types to these structs, I have been using their unit point value as the index of where the structs are in the global array.
The main function looks something like this:
Would anyone have a better way of doing this?
So suppose I've got a few hundred unique unit types, each of which correspond to some unique object/struct in the map code.
To bind these unit types to these structs, I have been using their unit point value as the index of where the structs are in the global array.
The main function looks something like this:
JASS:
function main takes nothing returns boolean //for some event
...
local unit u = GetTriggerUnit() //this is the type we want
local integer upoi = GetUnitValue(u) //this is the unit point value
…
call structs[upoi].foo(…)
…
endfunction
Would anyone have a better way of doing this?