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

[Trigger] Trigger help, picking a random region

Status
Not open for further replies.
Level 10
Joined
Jul 10, 2004
Messages
595
Well ive been trying but I cant figure it out. I need a way to pick a random region out of four to make an item in that region.
What I want to do is after a player gets a quest an item apears in on of 4 regions, but the region it apears in is random.

If anyone could help me that'd be awsome, thanks in advance
 
Level 3
Joined
Jul 14, 2007
Messages
34
Also, if you don't like variables you could just pick a random number and make a if/then/else and set if that number is equal to one two three or four, but Ghan's method is definetly more efficient.
 
Level 5
Joined
Sep 13, 2007
Messages
33
Create a new global array variable of type region.
In my example I named it Rect.

In one trigger (event of time elapsed 0) set four of its indexes to different regions on the map, for example:

  • Untitled Trigger 002
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set Rect[1] = Region 000 <gen>
      • Set Rect[2] = Region 001 <gen>
      • Set Rect[3] = Region 002 <gen>
      • Set Rect[4] = Region 003 <gen>
In order to get a random region of the four simply do:

  • Set <Variable> = Rect[(Random integer number between 1 and 4)]
 
Status
Not open for further replies.
Top