- Joined
- Jan 9, 2005
- Messages
- 2,131
Ok, so I have a building that periodically creates 1 unit at X angle every Y seconds, up to 5 units. If one of those units die, a new one takes its place after Y seconds. The angle will always be 360° / Maximum Unit Count, so in this case, 72°. What angles get used is random, so a unit might be appearing at 72°, then at 288°, and then at 144°, etc.
I'm deliberating how to tackle this. I made that system with fake 2D arrays for my TC11 submission (the Fabricator. click here for a video), but making it random doesn't seem to work as GetRandomInt() doesn't seem able to cycle indefinitely. Eg:
When I did that, sometimes the system would stop at two or three units, unable to randomise past a certain point, which leads me to believe the randomization is not actually random at all.
I need a smart person to tell me how to do this :/
Now, as far as containers are concerned, their not strictly needed for this system, but something of the like can always come in handy in the future. Usually, I'd just use unit groups, but I've had problems with that in the past and was also advised to use LinkedLists over unit groups. Sadly, I'm at a complete loss when it comes to LinkedList. I've looked at Hashtables, but these confound me as well and I have no idea what I'm flushing or what is being bound to what???
Does anyone have an alternative, or perhaps can explain to me how to get LinkedLists to work?
I'm deliberating how to tackle this. I made that system with fake 2D arrays for my TC11 submission (the Fabricator. click here for a video), but making it random doesn't seem to work as GetRandomInt() doesn't seem able to cycle indefinitely. Eg:
JASS:
loop
set RandomInt = GetRandomInt(1, Max_Units)
set angle = ((6.28319 / Max_Units) * RandomInt)
set x = GetUnitX(Building) + Cos(angle) * PortsRadius
set y = GetUnitY(Building) + Sin(angle) * PortsRadius
if Unit[Building_ID * Max_Units + Current_Unit_Count] == null then
set Unit[Building_ID * Max_Units + Current_Unit_Count] == CreateUnit(player, unittype, x, y, Rad2Deg(angle))
endif
endloop
I need a smart person to tell me how to do this :/
Now, as far as containers are concerned, their not strictly needed for this system, but something of the like can always come in handy in the future. Usually, I'd just use unit groups, but I've had problems with that in the past and was also advised to use LinkedLists over unit groups. Sadly, I'm at a complete loss when it comes to LinkedList. I've looked at Hashtables, but these confound me as well and I have no idea what I'm flushing or what is being bound to what???
Does anyone have an alternative, or perhaps can explain to me how to get LinkedLists to work?
Last edited: