• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Random Spawn Regions

Status
Not open for further replies.
Level 3
Joined
Oct 6, 2008
Messages
47
I've got a bunch of regions scattered around my map (22 to be exact - this might increase) and I'm trying to have each player spawn in a different region.

At the moment I've got something really basic like this for each player:
  • spawn Copy
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set spawnpoint = (Random integer number between 1 and 22)
      • Unit - Move Donkey <gen> instantly to (Center of spawnregion[spawnpoint])
Does anybody know how can I achieve unique random spawn locations for each player?

Cheers in advance.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
The system Defskull posted works, but it does too much work, the complexity with the exececution method is not optimal.

The first trigger would be the same, the second trigger would be:
  • Untitled Trigger 047
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set random = (Random integer number between 1 and max)
      • Set number[random] = number[max]
      • Set max = (max - 1)
This does much less actions, and the diference increases when more indexes are used. At 22 indexes, the difference is huge.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Sorting out elements of array "does too much work", can you even see the difference ?
"Huge" in terms of 0.003125 seconds - that's a lot... or is it ?
Just curious.

Let's look at the worst case scenario. 12 players, 22 array indexes, the random number is 1 every time.

With my method, the recycling does 24 actions.
With your method, the recycling does 198 actions if I calculated correctly, not to mention that it has to perform the looping, which adds even more actions.

Your method does more than 9 times as many actions in the worst case scenario and about 7 times as many in the average scenario.
 
Status
Not open for further replies.
Top