• 🏆 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!

[Trigger] Trigger help, picking a random region

Not open for further replies.
Level 10
Jul 10, 2004
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
Jul 14, 2007
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
Sep 13, 2007
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)]
Not open for further replies.