# [Trigger]Trigger help, picking a random region

Status
Not open for further replies.

#### skaterjcp

Level 10
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

#### Ghan_04

Level 22
Set all of those regions in a region array variable, then pick a random number between one and four and use that as the array's index.
That should do it. Does it make sense, or do you need more explanation?

#### TurtleGlove

Level 3
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.

#### skaterjcp

Level 10
Ok so, picking a random number between 1 and 4, then getting the item to that region, how would i do that? (dont know how to pick a random number)

#### Rheias

Level 5
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)]

#### skaterjcp

Level 10
Ok I got it, thanks a ton

Status
Not open for further replies.

Replies
8
Views
614
Replies
7
Views
1K
Replies
8
Views
2K
Replies
4
Views
716
Replies
10
Views
2K