• 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.

Make a trigger to pick a random region

Status
Not open for further replies.
Level 5
Joined
Jan 3, 2008
Messages
164
don't worry man! After about 50 trials I managed to make ^^ You will need 3 triggers for this. 1 - To set the regions for the RegionArray. 2 - The most important one, creates a random number, then checks some conditions. 3 - if all the regions have already been chosen, it re-sets them, but you don't have to do that, you can add your own actions there.

  • Beginning
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Set RegionArray[1] = Region 000 <gen>
      • Set RegionArray[2] = Region 000 Copy <gen>
      • Set RegionArray[3] = Region 000 Copy 2 <gen>
      • Set RegionArray[4] = Region 000 Copy 3 <gen>
      • Set RegionArray[5] = Region 000 Copy 4 <gen>
      • Set RegionArray[6] = Region 000 Copy 5 <gen>
      • Set RegionArray[7] = Region 000 Copy 6 <gen>
      • Set RegionArray[8] = Region 000 Copy 7 <gen>
      • Set RegionArray[9] = Region 000 Copy 8 <gen>
      • Set RegionArray[10] = Region 000 Copy 9 <gen>
      • Set RegionArray[11] = Region 000 Copy 10 <gen>
      • Set RegionArray[12] = Region 000 Copy 11 <gen>
  • Every seconds
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set RandomNumber = (Random integer number between 1 and 12)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • RegionBooleanArray[RandomNumber] Equal to False
        • Then - Actions
          • Set TriggerRunTimes = 0
          • Unit - Create 1 Paladin for Player 1 (Red) at (Center of RegionArray[RandomNumber]) facing Default building facing degrees
          • Set RegionBooleanArray[RandomNumber] = True
          • Skip remaining actions
        • Else - Actions
          • Set TriggerRunTimes = (TriggerRunTimes + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TriggerRunTimes Not equal to 13
            • Then - Actions
              • Trigger - Run (This trigger) (checking conditions)
            • Else - Actions
              • Trigger - Run Region Clash <gen> (checking conditions)
  • Region Clash
    • Events
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • RegionBooleanArray[1] Equal to True
          • RegionBooleanArray[2] Equal to True
          • RegionBooleanArray[3] Equal to True
          • RegionBooleanArray[4] Equal to True
          • RegionBooleanArray[5] Equal to True
          • RegionBooleanArray[6] Equal to True
          • RegionBooleanArray[7] Equal to True
          • RegionBooleanArray[8] Equal to True
          • RegionBooleanArray[9] Equal to True
          • RegionBooleanArray[10] Equal to True
          • RegionBooleanArray[11] Equal to True
          • RegionBooleanArray[12] Equal to True
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set RegionBooleanArray[(Integer A)] = False
There might be some leaks, I donno, I was only concentrating on making it work..

By the way, I used 12 regions to test it, but you can make as many as you want, but be sure to change all 3 triggers appropriately.
 
Level 5
Joined
Jan 3, 2008
Messages
164
Well hawk900, if you would have read through the whole of the topic, including post one, then you would see that I what I did is just what he needs:

But it has to pick a region from a list and it cant pick the same one twice....

also, he said that he has already tested my system, and it work perfectly:

hell yeah man nice job i just tried it with 8 and it owned.....

Unless you were saying it to bounty hunter2..
 
Status
Not open for further replies.
Top