• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Random Starting Points

Status
Not open for further replies.
Level 37
Joined
Aug 14, 2006
Messages
7,602
Hello!

I'm now doing huge real strategy game called "The Nations". It is soon finished but I still have one big problem, hope you guys help me!

I'm trying to make random starting locations for all players, but I don't want many players to have the same location. How could I make it so that every player would get random spawn location out of 11 pre-made starting location.

I would really appreciate your help guys!
Aeroblyctos
 
Level 19
Joined
Apr 25, 2006
Messages
1,309
I might try a trigger like this:
Integer player number=0
Event:Initialization/Time elapsed equal to 0
Actions:
Set Integer player number equal to Integer player number + 1
Set Integer Random=Random number between 1 and 11

If IntRandom equal to 1 and spot 1 filled=false
then
create starting units for player Integer Player number
set boolean spot 1 filled=true
else
Set Integer player number equal to Integer player number - 1

If IntRandom equal to 2 and spot 2 filled=false
then
create starting units for player Integer Player number
set boolean spot 2 filled=true
else
Set Integer player number equal to Integer player number - 1

If IntRandom equal to 3 and spot 3 filled=false
then
create starting units for player Integer Player number
set boolean spot 3 filled=true
else
Set Integer player number equal to Integer player number - 1

If IntRandom equal to 4 and spot 4 filled=false
then
create starting units for player Integer Player number
set boolean spot 4 filled=true
else
Set Integer player number equal to Integer player number - 1

If IntRandom equal to 5 and spot 5 filled=false
then
create starting units for player Integer Player number
set boolean spot 5 filled=true
else
Set Integer player number equal to Integer player number - 1

If IntRandom equal to 7 and spot 7 filled=false
then
create starting units for player Integer Player number
set boolean spot 7 filled=true
else
Set Integer player number equal to Integer player number - 1

If IntRandom equal to 8 and spot 8 filled=false
then
create starting units for player Integer Player number
set boolean spot 8 filled=true
else
Set Integer player number equal to Integer player number - 1

If IntRandom equal to 9 and spot 9 filled=false
then
create starting units for player Integer Player number
set boolean spot 9 filled=true
else
Set Integer player number equal to Integer player number - 1

If IntRandom equal to 10 and spot 10 filled=false
then
create starting units for player Integer Player number
set boolean spot 10 filled=true
else
Set Integer player number equal to Integer player number - 1

If IntRandom equal to 11 and spot 11 filled=false
then
create starting units for player Integer Player number
set boolean spot 11 filled=true
else
Set Integer player number equal to Integer player number - 1

If Integer player number equal to 12
then do nothing
else run this trigger again

Only problem I can think of this trigger could be run in the worst case scenario so many times and I'm not sure will it affect loading much or not. Should be tested.
 
Level 19
Joined
Apr 25, 2006
Messages
1,309
Ok
EDIT: So much better idea for a short trigger:

IntPlayerNumber=0
Event: Initialization
Actions:
Add one unit from each base to UnitGroup (11 actions)
Run next trigger


Actions:
Set IntPlayerNumber=IntPlayerNumber+1
Set RandomUnitVariable=Random unit from UnitGrouP
Pick every unit within (whole base distance from RandomUnitVariable unit) and set owner of picked unit to IntPlayerNumber
Set owner of RandomUnitVariable to IntPlayerNumber
Remove RandomUnitVariable from UnitGroup
If UnitGroup is empty equal to false
then run this trigger
else do nothing

This trigger will repeat itself for eleven times.
 
Level 5
Joined
May 27, 2007
Messages
132
Hmmm...

I recall a tutorial for making Melee maps which explained how you can make sure every player gets a random start location. From the screenshots I know they weren't preset, since they were a non-player color.

I think it was on the World Editor Tutorials website. Check there.
 
Status
Not open for further replies.
Top