Make a trigger that selects multiple random things

Ioannes

Oh man, I shot Marvin in the face.
Reaction score
49
There's these 6 regions and I could use some help making a trigger that selects at random 2 of them (and creates a building in the center). Selecting one at random is easy but when I try to select two there is a chance that it picks the same region twice :confused:

randomregions.jpg


Any help will be appreciated and rep'd.
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
I really don't know why were you ignoring my post, maybe you're not familiar with Jass?
anyway, I'll try again:

Trigger:
  • MapInit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Region[0] = Region 1 <gen>
      • Set Region[1] = Region 2 <gen>
      • Set Region[2] = Region 3 <gen>
      • Set Region[3] = Region 4 <gen>
      • Set Region[4] = Region 5 <gen>
      • Set Region[5] = Region 6 <gen>

Trigger:
  • CreateRandom
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set Count = 5
      • For each (Integer A) from 0 to 5, do (Actions)
        • Loop - Actions
          • Set Index[(Integer A)] = (Integer A)
      • For each (Integer B) from 0 to 1, do (Actions)
        • Loop - Actions
          • Set RandomInt = (Random integer number between 0 and Count)
          • Set Point = (Center of Region[Index[RandomInt]])
          • Special Effect - Create a special effect at Point using Abilities\Spells\Human\MarkOfChaos\MarkOfChaosTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_Point)
          • Set Index[RandomInt] = Count
          • Set Count = (Count - 1)


to demonstrate you that this is really working, here's a test map
 

Ioannes

Oh man, I shot Marvin in the face.
Reaction score
49
I really don't know why were you ignoring my post, maybe you're not familiar with Jass?
anyway, I'll try again:

Trigger:
  • MapInit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Region[0] = Region 1 <gen>
      • Set Region[1] = Region 2 <gen>
      • Set Region[2] = Region 3 <gen>
      • Set Region[3] = Region 4 <gen>
      • Set Region[4] = Region 5 <gen>
      • Set Region[5] = Region 6 <gen>

Trigger:
  • CreateRandom
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set Count = 5
      • For each (Integer A) from 0 to 5, do (Actions)
        • Loop - Actions
          • Set Index[(Integer A)] = (Integer A)
      • For each (Integer B) from 0 to 1, do (Actions)
        • Loop - Actions
          • Set RandomInt = (Random integer number between 0 and Count)
          • Set Point = (Center of Region[Index[RandomInt]])
          • Special Effect - Create a special effect at Point using Abilities\Spells\Human\MarkOfChaos\MarkOfChaosTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_Point)
          • Set Index[RandomInt] = Count
          • Set Count = (Count - 1)


to demonstrate you that this is really working, here's a test map

Yep, I have no idea how Jass works ^^ Care to explain the logic behind the second half?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top