HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Region Assistance

10-10-2004, 03:02 AM#1
Miningjrk
Hey,

How do you make the game pick a random 5 regions out of 21. Like, I have 21 regions in a neighborhood, every 1-3 seconds i want a certian type of unit to spawn. Iv got everything except how to make it pick 5 out of those 21.

Event
Time - Every (Random real number between 0.00 and 3.00) seconds of game time

I have that, now how do i randomly pick 5 regions out of the 21?
(i would like to be able to specify the 21 to be chosen from)

Thanks in advance
-Miningjrk
10-10-2004, 03:05 AM#2
BuRnInSpartan
Events: (what you have)

Conditions: NONE

Actions: Set Math-Random number 1-21
If then else do multiple functions
If random number= to 1
then do create (w/e creeps) at (w/e region)
If then else do multiple functions
If random number= to 2
then do create (w/e creeps) at (w/e region)

If then else do multiple functions
If random number= to 3
then do create (w/e creeps) at (w/e region)

If then else do multiple functions
If random number= to 4
then do create (w/e creeps) at (w/e region)

If then else do multiple functions
If random number= to 5
then do create (w/e creeps) at (w/e region)
10-10-2004, 03:16 AM#3
Miningjrk
Quote:
Originally Posted by BuRnInSpartan
Events: (what you have)

Conditions: NONE

Actions: Set Math-Random number 1-21
If then else do multiple functions
If random number= to 1
then do create (w/e creeps) at (w/e region)
If then else do multiple functions
If random number= to 2
then do create (w/e creeps) at (w/e region)

If then else do multiple functions
If random number= to 3
then do create (w/e creeps) at (w/e region)

If then else do multiple functions
If random number= to 4
then do create (w/e creeps) at (w/e region)

If then else do multiple functions
If random number= to 5
then do create (w/e creeps) at (w/e region)

Sorry, but how is that going to choose 5 regions? Wont that only choose 1? Though i think i can modify that to choose 5...
10-10-2004, 02:46 PM#4
Guest
Do a For Loop to 5 to have the trigger run 5 times, thereby choosing 5 regions. It is possible that it would chooce the same region twice (or even 5 times.) If that is a big deal, you could save the randomnumber in an array and use integer A as the index and compare randonmuber to the values in the array and have it start over if it is a value that has been used before.



Untitled Trigger 001
Events
Time - Every (Random real number between 1.00 and 3.00) seconds of game time
Conditions
Actions
For each (Integer A) from 1 to 5, do (Actions)
Loop - Actions
Set RandomNumber = (Random integer number between 1 and 21)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
RandomNumber Equal to 1
Then - Actions
Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
RandomNumber Equal to 2
Then - Actions
Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
Else - Actions
More If statements to 21 for the 21 regions
10-10-2004, 09:50 PM#5
Gandalf2349
put the regions in an array. Then generate 5 random numbers, check for consitancy, and then make the units in the regions picked.
10-10-2004, 10:49 PM#6
Miningjrk
Yeh, I figured the loop out myself after reading the first reply to this thread, thats for your help anyway, rep for u!
10-11-2004, 01:42 PM#7
BuRnInSpartan
i'm glad it worked what was wrong with what i said? besides it didn't pic 5 regions?
10-11-2004, 11:42 PM#8
Gandalf2349
Well, it would work, but it would be laggier, would leave more mem leaks (which could be fixed) and is just plain harder to write.