- Joined
- Feb 3, 2013
- Messages
- 277
Sorry, maybe the answer is simple, but I'm have a bit of an issue trying to understand how I would go about this.
How would I write this, when I'm using the struct extends array method?
edit: -_- I finally understood it again, I'm sorry
for anyone whos wondering, basically for something like above you would have to do this
JASS:
private struct Hooks
unit array chain[100]
unit head
endstruct
How would I write this, when I'm using the struct extends array method?
edit: -_- I finally understood it again, I'm sorry
for anyone whos wondering, basically for something like above you would have to do this
JASS:
private struct Hooks extends array
integer count
static unit array chain
unit head
private static integer array ccount // No such thing as magic, the arrays in structs are dealt with in math and have a limit as well
private static integer array rn
private static integer ic = 0
static method Create takes nothing returns nothing
local integer this = rn[0]
if this == 0 then
set ic = ic + 1
set this = ic
else
set rn[0] = rn[0]
endif
if this > 80 then // Basically the instance can't go beyond 8191, so one integer below 8191/your array max cap
set this == 0 then // Or you can return here
endif
set .ccount = (this-1) * 100 // The number you multiply by would be your array max cap
endmethod
endstruct
chain[.ccount + .count] // To refer/index the unit chain, it would be something like this
// BTW, this is exactly how the allocation method in vJASS compiler does it
Last edited: