| 01-19-2008, 09:28 PM | #1 |
i have 650 small, evenly placed regions that is layed out much like a chess-board. I have each region set to a region variable [integer a] 1-650 Now, my problem is i want to create 270 of this one kind of unit in 270 of the 650 regions, randomly picked... we'll say he is a Peon unit-type. Also, there are existing Neutral Creeps on the map to concider, scattered randomly that could be within any given region at any time because they have the "wander" ability. I dont want those regions concidered that have these, or any units already there. How do i create 1 unique Peon per 1 random region that has no units currently within it... my problem is that when i do this, it sometimes randomly chooses the same region that already has a peon generated for it. and when i try a different way to get 1 peon per 1 region it ends up selecting the regions in an orderly fashion .. which i dont want. this needs to be completely random. Summary: I want it so that out of 650 regions, 270 of them are randomly chosen to have 1 peon in each and no other unit at the time of creation. |
| 01-19-2008, 09:56 PM | #2 |
Check if the region has a unit in it. If it does, then get a new random region. Rinse and repeat. You may want to use a boolean array so you don't have to keep checking if a unit exists (which is slower than a boolean check). If this is related to your random number thread, then use that method instead. |
| 01-20-2008, 06:14 AM | #4 |
I think you're hitting the operator limit and that could be hindering your trigger. |
